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