Bug 30304: Reindent lists template in the staff interface
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / virtualshelves / shelves.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE AuthorisedValues %]
6 [% USE Branches %]
7 [% SET footerjs = 1 %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>
10     [% IF op == 'view' %]
11         Contents of [% shelf.shelfname | html %] &rsaquo; [% END %]
12
13     [% IF op == 'add_form' %]
14         Create new list &rsaquo; [% END %]
15
16     [% IF op == 'edit_form' %]
17         Edit list [% shelf.shelfname | html %] &rsaquo; [% END %]
18     Lists &rsaquo; Koha
19 </title>
20 [% INCLUDE 'doc-head-close.inc' %]
21 <style>textarea { width: 100%; }</style>
22
23 [% BLOCK list_permissions %]
24     <li>
25         <label for="allow_changes_from">Allow changes to contents from: </label>
26         <select name="allow_changes_from" id="allow_changes_from" onchange="AdjustRemark()">
27
28             [% IF shelf.allow_change_from_owner %]
29                 <option value="0">Nobody</option>
30             [% ELSE %]
31                 <option value="0" selected="selected">Nobody</option>
32             [% END %]
33
34             [% IF shelf.allow_change_from_owner && (( !shelf.is_public && !shelf.is_shared ) || !shelf.allow_change_from_others ) %]
35                 <option value="1" selected="selected">Owner only</option>
36             [% ELSE %]
37                 <option value="1">Owner only</option>
38             [% END %]
39
40             [% IF shelf.allow_change_from_others %]
41                 <option value="2" selected="selected">Anyone seeing this list</option>
42             [% ELSE %]
43                 <option value="2">Anyone seeing this list</option>
44             [% END %]
45
46             [% IF shelf.allow_change_from_staff %]
47                 <option value="3" selected="selected">Staff only</option>
48             [% ELSE %]
49                 <option value="3">Staff only</option>
50                 [% END %]
51         </select>
52         &emsp; <span id="anyone_remark" style="display:none;color:red;">The Anyone permission has no actual effect while this list is strictly private.</span>
53         &emsp; <span id="staff_remark" style="display:none;color:red;">The Staff only permission has no actual effect while this list is strictly private.</span>
54     </li>
55 [% END %]
56 </head>
57
58 <body id="lists_shelves" class="lists">
59 [% INCLUDE 'header.inc' %]
60 [% INCLUDE 'cat-search.inc' %]
61
62 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
63     <ol>
64         <li>
65             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
66         </li>
67
68         [% IF op != 'list' %]
69             <li>
70                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a>
71             </li>
72         [% ELSE %]
73             <li>
74                 <a href="#" aria-current="page">
75                     Lists
76                 </a>
77             </li>
78         [% END %]
79
80         [% IF shelf AND shelf.is_private %]
81             [% IF op == 'view' OR op == 'edit_form' %]
82                 <li>
83                     <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=0">Your lists</a>
84                 </li>
85             [% ELSE %]
86                 <li>
87                     <a href="#" aria-current="page">
88                         Your lists
89                     </a>
90                 </li>
91             [% END %]
92
93         [% ELSIF shelf AND shelf.is_public %]
94             [% IF op == 'view' %]
95                 <li>
96                     <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=1">Public lists</a>
97                 </li>
98             [% ELSE %]
99                 <li>
100                     <a href="#" aria-current="page">
101                         Public lists
102                     </a>
103                 </li>
104             [% END %]
105         [% END %]
106
107         [% IF op == 'view' %]
108             <li>
109                 <a href="#" aria-current="page">
110                     Contents of <em>[% shelf.shelfname | html %]</em>
111                 </a>
112             </li>
113         [% END %]
114
115         [% IF op == 'add_form' %]
116             <li>
117                 <a href="#" aria-current="page">
118                     Create new list
119                 </a>
120             </li>
121         [% END %]
122
123         [% IF op == 'edit_form' %]
124             <li>
125                 <a href="#" aria-current="page">
126                     Edit list <em>[% shelf.shelfname | html %]</em>
127                 </a>
128             </li>
129         [% END %]
130
131         [% IF op == 'transfer' %]
132             <li>
133                 <a href="#" aria-current="page">Transfer list <em>[% shelf.shelfname | html %]</em></a>
134             </li>
135         [% END %]
136     </ol>
137 </nav>
138
139 <div class="main container-fluid">
140     <div class="row">
141         <div class="col-sm-10 col-sm-push-1">
142             <main>
143
144             [% IF op != 'transfer' %][% INCLUDE 'virtualshelves-toolbar.inc' %][% END %]
145
146             [% FOR m IN messages %]
147                 <div class="dialog [% m.type | html %]">
148                     [% SWITCH m.code %]
149                         [% CASE 'error_on_update' %]
150                             <span>An error occurred when updating this list.</span>
151                         [% CASE 'error_on_insert' %]
152                             <span>An error occurred when creating this list.</span>
153                         [% CASE 'error_on_delete' %]
154                             <span>An error occurred when deleting this list.</span>
155                         [% CASE 'error_on_add_biblio' %]
156                             [% IF m.item_barcode %]
157                                 <span>The item ([% m.item_barcode | html %]) has not been added to the list. Please verify it is not already in the list.</span>
158                             [% ELSE %]
159                                 <span>The record ([% m.bibnum | html %]) has not been added to the list. Please verify it is not already in the list.</span>
160                             [% END %]
161                         [% CASE 'success_on_update' %]
162                             <span>List updated.</span>
163                         [% CASE 'success_on_insert' %]
164                             <span>List created.</span>
165                         [% CASE 'success_on_delete' %]
166                             <span>List deleted.</span>
167                         [% CASE 'success_on_add_biblio' %]
168                             [% IF m.item_barcode %]
169                                 <span>The item ([% m.item_barcode | html %]) has been added to the list.</span>
170                             [% ELSE %]
171                                 <span>The record ([% m.bibnum | html %]) has been added to the list.</span>
172                             [% END %]
173                         [% CASE 'success_on_remove_biblios' %]
174                             <span>The item has been removed from the list.</span>
175                         [% CASE 'does_not_exist' %]
176                             <span>This list does not exist.</span>
177                         [% CASE 'item_does_not_exist' %]
178                             [% IF m.item_barcode %]
179                                 <span>The item ([% m.item_barcode | html %]) does not exist.</span>
180                             [% ELSE %]
181                                 <span>The record ([% m.bibnum | html %]) does not exist.</span>
182                             [% END %]
183                         [% CASE 'unauthorized_on_view' %]
184                             <span>You do not have permission to view this list.</span>
185                         [% CASE 'unauthorized_on_update' %]
186                             <span>You do not have permission to update this list.</span>
187                         [% CASE 'unauthorized_on_delete' %]
188                             <span>You do not have permission to delete this list.</span>
189                         [% CASE 'unauthorized_on_add_biblio' %]
190                             <span>You do not have permission to add a record to this list.</span>
191                         [% CASE 'unauthorized_transfer' %]
192                             <span>You do not have permission to transfer ownership of this list.</span>
193                         [% CASE 'new_owner_not_found' %]
194                             <span>The new owner could not be found anymore.</span>
195                         [% CASE 'no_biblio_removed' %]
196                             <span>No record was removed.</span>
197
198                         [% CASE 'Koha::Exceptions::Virtualshelf::DuplicateObject' %]
199                             <span>An error occurred when creating this list. The name [% shelfname | html %] already exists.</span>
200                         [% CASE 'Koha::Exceptions::Virtualshelf::UseDbAdminAccount' %]
201                             <span>List could not be created. (Do not use the database administrator account.)</span>
202                         [% CASE 'DBIx::Class::Exception' %]
203                             [% m.msg | html %]
204
205                         [% CASE %]
206                             [% m.code | html %] [% m.msg | html %]
207                     [% END %]
208                 </div>
209             [% END %]
210
211             [% IF op == 'transfer' %]
212                 <h1>Transfer ownership of public list [% shelf.shelfname | html %]</h1>
213
214                 <form action="/cgi-bin/koha/virtualshelves/shelves.pl" id="transferform" method="post">
215                     <fieldset>
216                         <input type="hidden" name="op" value="transfer" />
217                         <input type="hidden" name="public" value="1" />
218                         <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
219
220                         <div>
221                             <label for="find_patron">Search for new owner: </label>
222                             <input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
223                         </div>
224
225                         <br/>
226                         <div>
227                             <label for="find_patron">New owner: </label>
228                             <span id="new_owner_name"></span>
229                             <input type="hidden" id="new_owner" name="new_owner" value="" />
230                         </div>
231
232                         <br/>
233                         <fieldset class="action">
234                             <input type="submit" value="Transfer" class="submit" />
235                             <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=1" class="cancel">Cancel</a>
236                         </fieldset>
237
238                     </fieldset>
239                 </form>
240             [% END %]
241
242             [% IF op == 'view' %]
243                 <h1>Contents of <em>[% shelf.shelfname | html %]</em></h1>
244                 [% IF itemsloop %]
245                     <div class="pages">[% pagination_bar | $raw %]</div>
246                     <form action="/cgi-bin/koha/virtualshelves/shelves.pl" id="listform" method="post">
247                         <input type="hidden" name="op" value="remove_biblios" />
248                         <input type="hidden" name="referer" value="view" />
249                         <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
250
251                         [% IF direction == 'asc' %]
252                             [% SET new_direction = 'desc' %]
253                         [% ELSE %]
254                             [% SET direction = 'desc' %]
255                             [% SET new_direction = 'asc' %]
256                         [% END %]
257
258                         [% IF itemsloop %]
259                             <div id="searchheader" class="searchheader noprint">
260                                 <div id="selection_ops">
261                                     <span class="checkall"></span> |
262                                     <span class="clearall"></span>
263
264                                     <span class="addto">| </span>
265                                     &nbsp;
266                                     [% IF CAN_user_reserveforothers && Koha.Preference('DisplayMultiPlaceHold') %]
267                                         <div class="btn-group"><button class="btn btn-default btn-xs placehold"><i class="fa fa-sticky-note-o"></i> Place hold</button></div>
268                                     [% END %]
269                                     [% IF can_remove_biblios %]
270                                         <div class="btn-group"><button type="submit" class="btn btn-default btn-xs list-remove"><i class="fa fa-trash"></i> Remove selected</button></div>
271                                     [% END %]
272                                     [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
273                                         <div class="btn-group"><button type="submit" class="btn btn-default btn-xs merge-items"><i class="fa fa-compress"></i> Merge selected</button></div>
274                                     [% END %]
275                                 </div>
276                             </div>
277                         [% END %]
278
279                         <table id="searchresults" class="dataTable">
280                             <thead>
281                                 <tr>
282                                     [% IF ( itemsloop ) %]
283                                         <th class="checkall">&nbsp;</th>
284                                     [% END %]
285                                     [% UNLESS ( item_level_itypes ) %]
286                                         <th>Item type</th>
287                                     [% END %]
288                                     [% IF sortfield == 'title' %]
289                                         <th class="sorting_[% direction | html %]">
290                                     [% ELSE %]
291                                         <th class="sorting">
292                                     [% END %]
293                                         <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]&amp;sortfield=title&amp;direction=[% IF sortfield != 'title' %]asc[% ELSE %][% new_direction | uri %][% END %]">Title</a>
294                                     </th>
295                                     [% IF sortfield == 'author' %]
296                                         <th class="sorting_[% direction | html %]">
297                                     [% ELSE %]
298                                         <th class="sorting">
299                                     [% END %]
300                                         <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]&amp;sortfield=author&amp;direction=[% IF sortfield != 'author' %]asc[% ELSE %][% new_direction | uri %][% END %]">Author</a>
301                                     </th>
302                                     [% IF sortfield == 'dateadded' %]
303                                         <th class="sorting_[% direction | html %]">
304                                     [% ELSE %]
305                                         <th class="sorting">
306                                     [% END %]
307                                         <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]&amp;sortfield=dateadded&amp;direction=[% IF sortfield != 'dateadded' %]asc[% ELSE %][% new_direction | uri %][% END %]">Date added</a>
308                                     </th>
309                                     [% IF sortfield == 'itemcallnumber' %]
310                                         <th class="sorting_[% direction | html %]">
311                                     [% ELSE %]
312                                         <th class="sorting">
313                                     [% END %]
314                                         <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]&amp;sortfield=itemcallnumber&amp;direction=[% IF sortfield != 'itemcallnumber' %]asc[% ELSE %][% new_direction | uri %][% END %]">Call number</a>
315                                     </th>
316                                 </tr>
317                             </thead>
318                             [% FOREACH itemsloo IN itemsloop %]
319                                 <tr>
320                                     [% IF itemsloop %]
321                                         <td>
322                                             <input type="checkbox" class="selection" value="[% itemsloo.biblionumber | html %]" name="biblionumber" />
323                                         </td>
324                                     [% END %]
325                                     [% UNLESS ( item_level_itypes ) %]
326                                         <td>
327                                             [% UNLESS ( noItemTypeImages || !itemsloo.imageurl ) %]
328                                                 <img src="[% itemsloo.imageurl | html %]" alt="[% itemsloo.description | html %]" title="[% itemsloo.description | html %]" />
329                                             [% END %]
330                                             [% itemsloo.description | html %]
331                                         </td>
332                                     [% END %]
333                                     <td>
334                                         [% IF ( itemsloo.XSLTBloc ) %]
335                                             [% itemsloo.XSLTBloc | $raw %]
336                                         [% ELSE %]
337                                             [% INCLUDE 'biblio-title.inc' biblio=itemsloo link = 1 %]
338                                             </a>
339                                         [% END %]
340                                         <p class="hold">
341                                             [% IF ( itemsloo.notforloan ) %]
342                                                 <span class="noholdstext">No holds allowed</span>
343                                             [% ELSE %]
344                                                 [% IF ( itemsloo.ITEM_RESULTS.count ) %]
345                                                     <a id="reserve_[% itemsloo.biblionumber | html %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber | html %]">Holds</a>
346                                                     [% IF ( holdfor ) %]
347                                                         <span class="holdforlink">| <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber | uri %]&amp;findborrower=[% holdfor_patron.cardnumber | uri %]">Place hold for [% INCLUDE 'patron-title.inc' patron => holdfor_patron no_title => 1 %]</a></span>
348                                                     [% END %]
349                                                 [% ELSE %]
350                                                     <span class="noholdstext">No holds allowed</span>
351                                                 [% END %]
352                                             [% END %]
353                                             [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
354                                                 | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% itemsloo.biblionumber | uri %]">Edit record</a>
355                                             [% END %]
356                                             [% IF ( CAN_user_editcatalogue_edit_items ) %]
357                                                 | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% itemsloo.biblionumber | uri %]">Edit items</a>
358                                             [% END %]
359                                         </p>
360                                     </td>
361                                     <td>
362                                         [% itemsloo.author | html %]
363                                     </td>
364                                     <td>
365                                         [% itemsloo.dateadded | $KohaDates%]
366                                     </td>
367                                     <td>
368                                         <ul>
369                                             [% FOREACH item IN itemsloo.ITEM_RESULTS %]
370                                                 <li>
371                                                     [% Branches.GetName(item.holdingbranch) | html %]
372                                                     [% IF ( item.location ) %]
373                                                         <span class="shelvingloc">
374                                                             [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => item.location ) | html %]
375                                                         </span>
376                                                     [% END %]
377                                                     [% IF ( item.itemcallnumber ) %]
378                                                         [<a href="/cgi-bin/koha/catalogue/search.pl?idx=callnum&amp;q=%22[% item.itemcallnumber | uri %]%22">[% item.itemcallnumber | html %]</a>]
379                                                     [% END %]
380                                                 </li>
381                                             [% END %]
382                                         </ul>
383                                     </td>
384                                 </tr>
385                             [% END %]<!-- /itemsloop -->
386                         </table>
387                         <div class="pages">[% pagination_bar | $raw %]</div>
388                     </form>
389                 [% END %]
390             [% END %]
391
392             [% IF op == 'add_form' OR op == 'edit_form' %]
393
394                 <form method="post" action="/cgi-bin/koha/virtualshelves/shelves.pl" class="validated">
395                     <fieldset class="rows">
396                         [% IF op == 'add_form' %]
397                             <legend><h1>Create a new list</h1></legend>
398                             <input type="hidden" name="op" value="add" />
399                         [% ELSE %]
400                             <legend><h1>Edit list <em>[% shelf.shelfname | html %]</em></h1></legend>
401                             <input type="hidden" name="op" value="edit" />
402                         [% END %]
403                         <input type="hidden" name="referer" value="[% referer | html %]" />
404                         <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
405                         <ol>
406                             <li>
407                                 <label for="shelfname" class="required">Name: </label><input type="text" id="shelfname" name="shelfname" size="25" value="[% shelf.shelfname | html %]" required="required" class="focus required" />
408                                 <span class="required">Required</span>
409                             </li>
410                             <li>
411                                 <span class="label">Owner: </span>
412                                 [% IF op == 'add_form' %]
413                                     <input type="hidden" name="owner" id="owner" value="[% loggedinusernumber | html %]" />[% logged_in_user.userid | html %]
414                                 [% ELSE %]
415                                     [% IF owner %]
416                                         <input type="hidden" id="owner" name="owner" value="[% owner.borrowernumber | html %]" />[% owner.firstname _ ' ' _ owner.surname | html %]
417                                     [% ELSE %]
418                                         <input type="hidden" id="owner" name="owner" value="[% loggedinusernumber | html %]" />[% logged_in_user.userid | html %]
419                                     [% END %]
420                                 [% END %]
421                             </li>
422                             <li>
423                                 <label for="sortfield" >Sort this list by: </label>
424                                 <select name="sortfield">
425                                     [% IF shelf.sortfield == "title" %]
426                                         <option value="title" selected="selected">Title</option>
427                                     [% ELSE %]
428                                         <option value="title">Title</option>
429                                     [% END %]
430                                     [% IF shelf.sortfield == "author" %]
431                                         <option value="author" selected="selected">Author</option>
432                                     [% ELSE %]
433                                         <option value="author">Author</option>
434                                     [% END %]
435                                     [% IF shelf.sortfield == "copyrightdate" %]
436                                         <option value="copyrightdate" selected="selected">Copyrightdate</option>
437                                     [% ELSE %]
438                                         <option value="copyrightdate">Copyrightdate</option>
439                                     [% END %]
440                                     [% IF shelf.sortfield == "itemcallnumber" %]
441                                         <option value="itemcallnumber" selected="selected">Call number</option>
442                                     [% ELSE %]
443                                         <option value="itemcallnumber">Call number</option>
444                                     [% END %]
445                                     [% IF shelf.sortfield == "dateadded" %]
446                                         <option value="dateadded" selected="selected">Date added</option>
447                                     [% ELSE %]
448                                         <option value="dateadded">Date added</option>
449                                     [% END %]
450                                 </select>
451                             </li>
452                             <li>
453                                 <label for="public">Public: </label>
454                                 <select id="public" name="public" onchange="AdjustRemark()">
455                                     [% IF shelf.is_private %]
456                                         <option value="0" selected="selected">Private</option>
457                                     [% ELSE %]
458                                         <option value="0">Private</option>
459                                     [% END %]
460                                     [% IF shelf.is_public %]
461                                         <option value="1" selected="selected">Public</option>
462                                     [% ELSE %]
463                                         <option value="1">Public</option>
464                                     [% END %]
465                                 </select>
466                             </li>
467                             [% INCLUDE list_permissions %]
468                         </ol>
469                     </fieldset>
470
471                     <fieldset class="action">
472                         <input type="submit" value="Save" class="submit" />
473                         [% IF referer == 'view' %]
474                             <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]" class="cancel">Cancel</a>
475                         [% ELSE %]
476                             [% IF public %]
477                                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=1" class="cancel">Cancel</a>
478                             [% ELSE %]
479                                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=0" class="cancel">Cancel</a>
480                             [% END %]
481                         [% END %]
482                     </fieldset>
483                 </form>
484             [% END %]
485
486             [% IF op == 'list' %]
487                 <h1>Lists</h1>
488                 <div id="tabs" class="toptabs">
489                     <ul>
490                         <li id="privateshelves_tab" class="active">
491                             <a href="#tab_content">Your lists</a>
492                         </li>
493                         <li id="publicshelves_tab" class="active">
494                             <a href="#tab_content">Public lists</a>
495                         </li>
496                     </ul>
497
498                     <div id="tab_content">
499                         <table id="listresultst">
500                             <thead>
501                                 <tr>
502                                     <th class="NoVisible">Type</th>
503                                     <th>List name</th>
504                                     <th>Contents</th>
505                                     <th>Type</th>
506                                     <th>Owner</th>
507                                     <th>Sort by</th>
508                                     <th>Creation date</th>
509                                     <th>Modification date</th>
510                                     <th class="noExport">Actions</th>
511                                 </tr>
512                                 <tr class="filters_row">
513                                     <th></th>
514                                     <th><input class="filter text_filter" id="searchshelfname_filter" placeholder="List name"></th>
515                                     <th></th>
516                                     <th></th>
517                                     <th><input class="filter text_filter" id="searchowner_filter" placeholder="Owner"></th>
518                                     <th>
519                                         <select class="filter text_filter" id="searchsortby_filter">
520                                             <option value=""></option>
521                                             <option value="title">Title</option>
522                                             <option value="author">Author</option>
523                                             <option value="copyrightdate">Copyrightdate</option>
524                                             <option value="itemcallnumber">Call number</option>
525                                             <option value="dateadded">Date added</option>
526                                         </select>
527                                     </th>
528                                     <th></th>
529                                     <th></th>
530                                     <th></th>
531                                 </tr>
532                             </thead>
533                             <tbody></tbody>
534                         </table>
535                     </div>
536                 </div>
537             [% END %]
538
539             <form id="hold_form" method="get" action="/cgi-bin/koha/reserve/request.pl">
540                 <!-- Values will be set here by placeHold() -->
541             </form>
542
543         </main>
544     </div> <!-- /.col-sm-10.col-sm-push-2 -->
545 </div> <!-- /.row -->
546
547 [% IF ( can_add_biblios ) %]
548     <!-- Modal -->
549     <div class="modal" id="addToList" tabindex="-1" role="dialog" aria-labelledby="addToListLabel">
550         <div class="modal-dialog" role="document">
551             <form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post">
552                 <div class="modal-content">
553                     <div class="modal-header">
554                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
555                         <h4 class="modal-title" id="addToListLabel">Add items</h4>
556                     </div>
557                     <div class="modal-body">
558                         <fieldset class="brief">
559                             <ol>
560                                 <li>
561                                     <label for="barcodes">Barcodes:</label>
562                                     <textarea name="barcodes" id="barcodes" rows="5"></textarea>
563                                     <input type="hidden" name="op" value="add_biblio" />
564                                     <input type="hidden" name="referer" value="view" />
565                                     <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
566                                 </li>
567                                 <li>
568                                     <label for="biblionumbers">Biblio numbers:</label>
569                                     <textarea name="biblionumbers" id="biblionumbers" rows="5"></textarea>
570                                     <input type="hidden" name="op" value="add_biblio" />
571                                     <input type="hidden" name="referer" value="view" />
572                                     <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
573                                 </li>
574                             </ol>
575                         </fieldset>
576                     </div>
577                     <div class="modal-footer">
578                         <button type="submit" class="btn btn-default">Save</button>
579                         <a href="#" data-dismiss="modal" class="cancel">Cancel</a>
580                     </div>
581                 </div>
582             </form>
583         </div>
584     </div>
585 [% END %]
586
587 [% MACRO jsinclude BLOCK %]
588     [% INCLUDE 'datatables.inc' %]
589     [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
590     [% IF print %]
591         <script>
592             $( document ).ready(function() {
593                 window.print();
594                 window.onafterprint = function () {
595                     window.close();
596                 }
597                 setTimeout('window.close()', 1000); // Hack for Chrome < 63
598             });
599         </script>
600     [% END %]
601
602     [% IF op == 'view' %]
603         [% Asset.js("lib/hc-sticky.js") | $raw %]
604     [% END %]
605     <script>
606         var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
607         var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?");
608         var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to remove this list?");
609
610         [% IF op == 'list' %]
611             $(document).ready(function(){
612                 var public = [% public | html %];
613
614                 var dtListResults = $("#listresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
615                 "aaSorting": [[ 5, "asc" ]],
616                     'bServerSide': true,
617                     'sAjaxSource': "/cgi-bin/koha/svc/virtualshelves/search",
618                     'fnServerData': function(sSource, aoData, fnCallback) {
619                         aoData.push({
620                             'name': 'public',
621                             'value': public,
622                         },{
623                             'name': 'shelfname',
624                             'value': $("#searchshelfname_filter").val(),
625                         },{
626                             'name': 'owner',
627                             'value': $("#searchowner_filter").val(),
628                         },{
629                             'name': 'sortby',
630                             'value': $("#searchsortby_filter").val(),
631                         },{
632                             'name': 'template_path',
633                             'value': 'virtualshelves/tables/shelves_results.tt',
634                         },{
635                             'name': 'allow_transfer',
636                             'value': '[% allow_transfer | html %]',
637                         },{
638                             'name': 'shelfname_sorton',
639                             'value': 'vs.shelfname',
640                         },{
641                             'name': 'is_shared_sorton',
642                             'value': 'vs.public',
643                         },{
644                             'name': 'owner_sorton',
645                             'value': 'vs.owner',
646                         },{
647                             'name': 'sortby_sorton',
648                             'value': 'vs.sortfield',
649                         },{
650                             'name': 'created_on_sorton',
651                             'value': 'vs.created_on',
652                         },{
653                             'name': 'modification_time_sorton',
654                             'value': 'vs.lastmodified',
655                         });
656                         $.ajax({
657                             'dataType': 'json',
658                             'type': 'POST',
659                             'url': sSource,
660                             'data': aoData,
661                             'success': function(json){
662                                 fnCallback(json);
663                             }
664                         });
665                     },
666                     'aoColumns':[
667                         { 'mDataProp': 'dt_public' },
668                         { 'mDataProp': 'dt_shelfname' },
669                         { 'mDataProp': 'dt_count' },
670                         { 'mDataProp': 'dt_is_shared' },
671                         { 'mDataProp': 'dt_owner' },
672                         { 'mDataProp': 'dt_sortby' },
673                         { 'mDataProp': 'dt_created_on' },
674                         { 'mDataProp': 'dt_modification_time' },
675                         { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
676                     ],
677                     "aoColumnDefs": [
678                         { "bVisible": false, "aTargets": [ 'NoVisible' ] }
679                     ],
680                     'bAutoWidth': false,
681                     'sPaginationType': 'full_numbers',
682                     'bFilter': false,
683                     "bProcessing": true,
684                     "bSortCellsTop": true
685                 }));
686
687                 dtListResults.fnAddFilters("filter", 750);
688
689                 var tabs = $("#tabs").tabs({
690                     [% IF public %]
691                         active: 1,
692                     [% ELSE %]
693                         active: 0,
694                     [% END %]
695                     activate: function(e, ui) {
696                         var active = tabs.tabs("option", "active" );
697                         if ( active == 0 ) {
698                             public = 0;
699                             dtListResults.fnDraw();
700                         } else if ( active == 1 ) {
701                             public = 1;
702                             dtListResults.fnDraw();
703                         }
704                     }
705                 });
706                 $("body").on("click", ".deleteshelf", function(){
707                     return confirmDelete(MSG_CONFIRM_DELETE_LIST);
708                 });
709             });
710         [% END %]
711
712         [% IF shelf AND op == 'view' %]
713             var Sticky;
714             $(document).ready(function(){
715                 Sticky = $("#searchheader");
716                 Sticky.hcSticky({
717                     stickTo: "#listform",
718                     stickyClass: "floating"
719                 });
720                 $("span.clearall").html("<a id=\"CheckNone\" href=\"/cgi-bin/koha/shelves.pl\"><i class=\"fa fa-remove\"></i>"+_(" Clear all")+"<\/a>");
721                 $("span.checkall").html("<a id=\"CheckAll\" href=\"/cgi-bin/koha/shelves.pl\"><i class=\"fa fa-check\"></i>"+_(" Select all")+"<\/a>");
722                 $("#CheckAll").click(function(e){
723                     e.preventDefault();
724                     $(".selection").each(function(){
725                         $(this).prop("checked", true);
726                     });
727                 });
728
729                 $("#CheckNone").click(function(e){
730                     e.preventDefault();
731                     $(".selection").each(function(){
732                         $(this).prop("checked", false);
733                     });
734                 });
735                 $(".placehold").on("click",function(e){
736                     placeHold();
737                     e.preventDefault();
738                 });
739                 $(".addtocart").show();
740                 var param1 = "| <label for=\"addto\">"+_("Add to:")+"<\/label><select name=\"addto\" id=\"addto\"><option value=\"\"><\/option>";
741                 [% IF (Koha.Preference("intranetbookbag")) %]
742                      param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
743                 [% END %]
744                 [% IF Koha.Preference('virtualshelves') %]
745                     [% IF add_to_some_private_shelves.count %]
746                         param1 += "<optgroup label=\""+_("Your lists:")+"\">";
747                         [% SET number_of_private_shelves = 0 %]
748                         [% FOREACH s IN add_to_some_private_shelves %]
749                             [% IF shelfnumber != s.shelfnumber %]
750                                 param1 += "<option id=\"s[% s.shelfnumber | html %]\" value=\"addtolist\">[% s.shelfname | html %]<\/option>";
751                                 [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
752                                 [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
753                             [% END %]
754                         [% END %]
755                         param1 += "<\/optgroup>";
756                     [% END %]
757                     [% IF add_to_some_public_shelves.count %]
758                         param1 += "<optgroup label=\""+_("Public lists:")+"\">";
759                         [% SET number_of_public_shelves = 0 %]
760                         [% FOREACH s IN add_to_some_public_shelves %]
761                             [% IF shelfnumber != s.shelfnumber %]
762                                 param1 += "<option id=\"s[% s.shelfnumber | html %]\" value=\"addtolist\">[% s.shelfname | html %]<\/option>";
763                                 [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
764                                 [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
765                             [% END %]
766                         [% END %]
767                         param1 += "<\/optgroup>";
768                     [% END %]
769                     [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
770                         param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
771                     [% END %]
772                     param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
773                 [% END %]
774                 param1 += "<\/select> <button id=\"cartsubmit\" type=\"submit\" class=\"btn btn-default btn-xs\">"+_("Save")+"</button>";
775                 $("span.addto").html(param1);
776                 $("#cartsubmit").on("click",function(e){
777                     cartList();
778                     e.preventDefault();
779                 });
780                 $("#addto").change(function(){
781                     cartList();
782                 });
783                 $(".addto").find("input:submit").click(function(e){
784                     e.preventDefault();
785                     cartList();
786                 });
787                 $("#selection_ops").show();
788                 $(".merge-items").on("click",function(e){
789                     e.preventDefault();
790                     MergeItems();
791                 });
792                 $("#listform").on("submit",function(e){
793
794                 });
795                 $(".list-remove").on("click",function(e){
796                     if($(".selection").filter(":checked").length > 0){
797                         return confirm(MSG_REMOVE_FROM_LIST);
798                     } else {
799                         alert(MSG_NO_ITEM_SELECTED);
800                         e.preventDefault();
801                     }
802                 });
803                 $("#addToList").on("shown.bs.modal", function(e){
804                     $("#barcodes").focus();
805                 });
806             });
807         [% END %]
808
809         [% IF shelf AND op == 'edit_form' %]
810             $(document).ready(function(){
811                 AdjustRemark();
812             });
813         [% END %]
814
815         /**
816          * This function checks if the adequate number of records are checked for merging
817          */
818         function MergeItems() {
819             var checkboxes = $("input:checkbox:checked");
820             if (checkboxes.length < 2) {
821                 alert(_("At least two records must be selected for merging."));
822             } else {
823                 var params = [];
824                 $(checkboxes).each(function() {
825                     params.push('biblionumber=' + $(this).val());
826                 });
827                 var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&');
828                 location.href = url;
829             }
830             return false;
831         }
832
833         /**
834          * This function checks all checkboxes if all are empty,
835          * or unchecks all if any already checked.
836          */
837         function CheckAll(){
838             var checkboxes = document.getElementsByTagName('input');
839             var nbCheckbox = checkboxes.length;
840             var check = areAllChecked();
841             for(var i=0;i<nbCheckbox;i++){
842                 if(checkboxes[i].getAttribute('type') == "checkbox" ){
843                     checkboxes[i].checked = (check) ? 0 : 1;
844                 }
845             }
846         }
847         /**
848          * This function returns true if ALL checkboxes are checked
849          */
850         function areAllChecked(){
851             var checkboxes = document.getElementsByTagName('input');
852             var nbCheckbox = checkboxes.length;
853             for(var i=0;i<nbCheckbox;i++){
854                 if(checkboxes[i].getAttribute('type') == "checkbox" ){
855                     if(checkboxes[i].checked == 0){
856                         return false;
857                     }
858                 }
859             }
860             return true;
861         }
862
863         function placeHold () {
864             var checkedItems = $(".selection:checked");
865             if ($(checkedItems).size() == 0) {
866                 alert(MSG_NO_ITEM_SELECTED);
867                 return false;
868             }
869             $(checkedItems).each(function() {
870                 var bib_param = $("<input>").attr("type", "hidden").attr("name", "biblionumber").val($(this).val());
871                 $('#hold_form').append(bib_param);
872             });
873             $("#hold_form").submit();
874             return false;
875         }
876
877         function cartList(){
878             var checkboxes = $("#searchresults").find(":checkbox");
879             var vshelf = vShelfAdd(checkboxes);
880             if($("#addto").find("option:selected").attr("value") == "addtolist"){
881                 var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s","");
882                 if (vshelf) {
883                      openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&' + vshelf,'popup',500,500);
884                 }
885                 return false;
886             } else if($("#addto").find("option:selected").attr("value") == "newlist"){
887                 if (vshelf) {
888                     openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?newshelf=1&' + vshelf,'popup',500,500);
889                 }
890                 return false;
891             } else if($("#addto").find("option:selected").attr("value") == "morelists"){
892                 if (vshelf) {
893                     openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?' + vshelf,'popup',500,500);
894                 }
895                 return false;
896             }
897             if($("#addto").find("option:selected").attr("value") == "addtocart"){
898                 addMultiple(checkboxes);
899                 return false;
900             }
901         }
902
903         function AdjustRemark() {
904             var public = $("#public").val();
905             var perms = $("#allow_changes_from").val();
906
907             if( perms < 2 ) {
908                 $("#anyone_remark").hide();
909                 $("#staff_remark").hide();
910             } else if( public==0 ) {
911                 // If we move to Private (without shares), show Anyone remark
912                 // Note: the number of shares is not tested real-time
913                 [% IF !shelf.is_shared %]
914                     if( perms== 2) {
915                         $("#anyone_remark").show();
916                         $("#staff_remark").hide();
917                     } else if ( perms==3 ) {
918                         $("#anyone_remark").hide();
919                         $("#staff_remark").show();
920                     }
921                 [% ELSE %]
922                     $("#anyone_remark").hide();
923                     $("#staff_remark").hide();
924                 [% END %]
925             } else { // public==1
926                 $("#anyone_remark").hide();
927                 $("#staff_remark").hide();
928             }
929         }
930         [% IF op == 'view' %]
931
932             function sendList(){
933                 open(CGIBIN+'virtualshelves/sendshelf.pl?shelfid=[% shelf.shelfnumber | html %]','win_form','scrollbars=no,resizable=no,height=300,width=450,top=50,left=100');
934              }
935
936              $(document).ready(function() {
937                 $("#sendlist").click(function(){
938                     sendList();
939                     return false;
940                 });
941                 $("#deleteshelf").click(function(e){
942                     if(confirm(_("Are you sure you want to delete this list?"))){
943                         return true;
944                     } else {
945                         e.preventDefault();
946                     }
947                 });
948              });
949
950         [% END %]
951
952         [% IF op == 'transfer' %]
953             $(document).ready(function() {
954                 patron_autocomplete( $("#find_patron"), { 'on-select-callback': function( event, ui ) {
955                     $('#new_owner_name').html( ui.item.firstname + " " + ui.item.surname );
956                     $('#new_owner').val( ui.item.patron_id );
957                     $('#find_patron').val('').focus();
958                     return false;
959                 }});
960
961                 $('#transferform').submit(function() {
962                     if( $('#new_owner').val() == '' ) {
963                         alert( _("Please select a new owner first") );
964                         return false;
965                     }
966                     return true;
967                 });
968              });
969         [% END %]
970
971     </script>
972 [% END %]
973
974 [% INCLUDE 'intranet-bottom.inc' %]