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