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