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