Bug 26204: Remove the use of jquery.checkboxes plugin from staff interface lists
[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 <i>[% shelf.shelfname | html %]</i>[% END %][% IF op == 'add_form' %] &rsaquo; Create new list[% END %][% IF op == 'edit_form' %] &rsaquo; Edit list <i>[% shelf.shelfname | html %]</i>[% 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 <i>[% shelf.shelfname | html %]</i></h3>
131     <div class="pages">[% pagination_bar | $raw %]</div>
132     <form action="/cgi-bin/koha/virtualshelves/shelves.pl" id="listform" method="post" class="checkboxed">
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="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-default-view.inc' biblionumber = itemsloo.biblionumber %]
213                         [% INCLUDE 'biblio-title.inc' biblio=itemsloo %]
214                     </a>
215                 [% END %]
216                     <p class="hold">
217                         [% IF ( itemsloo.notforloan ) %]
218                             <span class="noholdstext">No holds allowed</span>
219                         [% ELSE %]
220                             [% IF ( itemsloo.ITEM_RESULTS.size ) %]
221                                 <a id="reserve_[% itemsloo.biblionumber | html %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber | html %]">Holds</a>
222                                 [% 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 %]
223                             [% ELSE %]
224                                 <span class="noholdstext">No holds allowed</span>
225                             [% END %]
226                         [% END %]
227                         [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
228                             | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% itemsloo.biblionumber | uri %]">Edit record</a>
229                         [% END %]
230                         [% IF ( CAN_user_editcatalogue_edit_items ) %]
231                             | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% itemsloo.biblionumber | uri %]">Edit items</a>
232                         [% END %]
233                     </p>
234             </td>
235             <td>[% itemsloo.author | html %]</td>
236             <td>[% itemsloo.dateadded | $KohaDates%]</td>
237             <td>
238                 <ul>
239                 [% FOREACH result IN itemsloo.ITEM_RESULTS %]
240                     <li>
241                         [% result.holdingbranch | html %]
242                         [% IF ( result.location_intranet ) %]<span class="shelvingloc">[% result.location_intranet | html %]</span>[% END %]
243                         [% IF ( result.itemcallnumber ) %]
244                             [<a href="/cgi-bin/koha/catalogue/search.pl?idx=callnum&amp;q=%22[% result.itemcallnumber |uri %]%22">[% result.itemcallnumber | html %]</a>]
245                         [% END %]
246                     </li>
247                 [% END %]
248                 </ul>
249             </td>
250                         </tr>
251                 [% END %]<!-- /itemsloop -->
252     </table>
253     <div class="pages">[% pagination_bar | $raw %]</div>
254 </form>
255
256         [% END %]
257 [% END %]
258
259 [% IF op == 'add_form' OR op == 'edit_form' %]
260
261     <form method="post" action="/cgi-bin/koha/virtualshelves/shelves.pl" class="validated">
262         <fieldset class="rows">
263
264         [% IF op == 'add_form' %]
265             <legend>Create a new list</legend>
266             <input type="hidden" name="op" value="add" />
267         [% ELSE %]
268             <legend>Edit list <i>[% shelf.shelfname | html %]</i></legend>
269             <input type="hidden" name="op" value="edit" />
270         [% END %]
271         <input type="hidden" name="referer" value="[% referer | html %]" />
272         <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
273         <ol>
274             <li>
275                 <label for="shelfname" class="required">Name: </label><input type="text" id="shelfname" name="shelfname" size="25" value="[% shelf.shelfname | html %]" required="required" class="required" />
276             <span class="required">Required</span>
277             </li>
278             <li>
279                 <span class="label">Owner: </span>
280                 [% IF op == 'add_form' %]
281                     <input type="hidden" name="owner" id="owner" value="[% loggedinusernumber | html %]" />[% logged_in_user.userid | html %]
282                 [% ELSE %]
283                     [% IF owner %]
284                         <input type="hidden" id="owner" name="owner" value="[% owner.borrowernumber | html %]" />[% owner.firstname _ ' ' _ owner.surname | html %]
285                     [% ELSE %]
286                         <input type="hidden" id="owner" name="owner" value="[% loggedinusernumber | html %]" />[% logged_in_user.userid | html %]
287                     [% END %]
288                 [% END %]
289             </li>
290             <li><label for="sortfield" >Sort this list by: </label>
291             <select name="sortfield">
292             [% IF shelf.sortfield == "title" %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
293             [% IF shelf.sortfield == "author" %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
294             [% IF shelf.sortfield == "copyrightdate" %]<option value="copyrightdate" selected="selected">Copyrightdate</option>[% ELSE %]<option value="copyrightdate">Copyrightdate</option>[% END %]
295             [% IF shelf.sortfield == "itemcallnumber" %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
296             [% IF shelf.sortfield == "dateadded" %]<option value="dateadded" selected="selected">Date added</option>[% ELSE %]<option value="dateadded">Date added</option>[% END %]
297             </select></li>
298             <li><label for="category">Category: </label>
299                 <select id="category" name="category" onchange="AdjustRemark()">
300                 [% IF shelf.is_private %]
301                     <option value="1" selected="selected">Private</option>
302                 [% ELSE %]
303                     <option value="1">Private</option>
304                 [% END %]
305                 [% IF shelf.is_public %]
306                     <option value="2" selected="selected">Public</option>
307                 [% ELSE %]
308                     <option value="2">Public</option>
309                 [% END %]
310                            </select></li>
311
312             [% INCLUDE list_permissions %]
313
314         </ol>
315     </fieldset>
316
317     <fieldset class="action">
318         <input type="submit" value="Save" class="submit" />
319         [% IF referer == 'view' %]
320            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]" class="cancel">Cancel</a>
321        [% ELSE %]
322             [% IF category == PUBLIC %]
323                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PUBLIC | uri %]" class="cancel">Cancel</a>
324             [% ELSE %]
325                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PRIVATE | uri %]" class="cancel">Cancel</a>
326             [% END %]
327         [% END %]
328     </fieldset>
329     </form>
330
331 [% END %]
332
333 [% IF op == 'list' %]
334     <h2>Lists</h2>
335     <div id="tabs" class="toptabs">
336         <ul>
337             <li id="privateshelves_tab" class="active"><a href="#tab_content">Your lists</a></li>
338             <li id="publicshelves_tab" class="active"><a href="#tab_content">Public lists</a></li>
339         </ul>
340
341         <div id="tab_content">
342             <table id="listresultst">
343                 <thead>
344                     <tr>
345                         <th class="NoVisible">Type</th>
346                         <th>List name</th>
347                         <th>Contents</th>
348                         <th>Type</th>
349                         <th>Owner</th>
350                         <th>Sort by</th>
351                         <th>Creation date</th>
352                         <th>Modification date</th>
353                         <th>Actions</th>
354                     </tr>
355                     <tr class="filters_row">
356                         <th></th>
357                         <th><input class="filter text_filter" id="searchshelfname_filter" placeholder="List name"></th>
358                         <th></th>
359                         <th></th>
360                         <th><input class="filter text_filter" id="searchowner_filter" placeholder="Owner"></th>
361                         <th>
362                             <select class="filter text_filter" id="searchsortby_filter">
363                                 <option value=""></option>
364                                 <option value="title">Title</option>
365                                 <option value="author">Author</option>
366                                 <option value="copyrightdate">Copyrightdate</option>
367                                 <option value="itemcallnumber">Call number</option>
368                                 <option value="dateadded">Date added</option>
369                             </select>
370                         </th>
371                         <th></th>
372                         <th></th>
373                         <th></th>
374                     </tr>
375                 </thead>
376                 <tbody></tbody>
377             </table>
378         </div>
379     </div>
380 [% END %]
381
382 <form id="hold_form" method="get" action="/cgi-bin/koha/reserve/request.pl">
383     <!-- Value will be set here by placeHold() -->
384     <input id="hold_form_biblios" type="hidden" name="biblionumbers" value="" />
385 </form>
386
387             </main>
388         </div> <!-- /.col-sm-10.col-sm-push-2 -->
389     </div> <!-- /.row -->
390
391 [% IF ( can_add_biblios ) %]
392     <!-- Modal -->
393     <div class="modal" id="addToList" tabindex="-1" role="dialog" aria-labelledby="addToListLabel">
394         <div class="modal-dialog" role="document">
395             <form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post">
396                 <div class="modal-content">
397                     <div class="modal-header">
398                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
399                         <h4 class="modal-title" id="addToListLabel">Add items</h4>
400                     </div>
401                     <div class="modal-body">
402                         <fieldset class="brief">
403                         <ol>
404                             <li>
405                                 <label for="barcodes">Barcodes:</label>
406                                 <textarea name="barcodes" id="barcodes" rows="5"></textarea>
407                                 <input type="hidden" name="op" value="add_biblio" />
408                                 <input type="hidden" name="referer" value="view" />
409                                 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
410                             </li>
411                             <li>
412                                 <label for="biblionumbers">Biblio numbers:</label>
413                                 <textarea name="biblionumbers" id="biblionumbers" rows="5"></textarea>
414                                 <input type="hidden" name="op" value="add_biblio" />
415                                 <input type="hidden" name="referer" value="view" />
416                                 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
417                             </li>
418                         </ol>
419                         </fieldset>
420                     </div>
421                     <div class="modal-footer">
422                         <button type="submit" class="btn btn-default">Save</button>
423                         <a href="#" data-dismiss="modal" class="cancel">Cancel</a>
424                     </div>
425                 </div>
426             </form>
427         </div>
428     </div>
429 [% END %]
430
431 [% MACRO jsinclude BLOCK %]
432     [% INCLUDE 'datatables.inc' %]
433     [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
434     [% IF print %]
435         <script>
436             $( document ).ready(function() {
437                 window.print();
438                 setTimeout('window.close()', 1);
439             });
440         </script>
441     [% END %]
442
443     [% IF op == 'view' %]
444         [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
445         [% Asset.js("lib/hc-sticky.js") | $raw %]
446     [% END %]
447     <script>
448         var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
449         var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?");
450         var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to remove this list?");
451
452         [% IF op == 'list' %]
453             $(document).ready(function(){
454                 [% IF category == PUBLIC %]
455                     var type = [% PUBLIC | html %];
456                 [% ELSE %]
457                     var type = [% PRIVATE | html %];
458                 [% END %]
459
460                 var dtListResults = $("#listresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
461                 "aaSorting": [[ 5, "asc" ]],
462                     'bServerSide': true,
463                     'sAjaxSource': "/cgi-bin/koha/svc/virtualshelves/search",
464                     'fnServerData': function(sSource, aoData, fnCallback) {
465                         aoData.push({
466                             'name': 'type',
467                             'value': type,
468                         },{
469                             'name': 'shelfname',
470                             'value': $("#searchshelfname_filter").val(),
471                         },{
472                             'name': 'owner',
473                             'value': $("#searchowner_filter").val(),
474                         },{
475                             'name': 'sortby',
476                             'value': $("#searchsortby_filter").val(),
477                         },{
478                             'name': 'template_path',
479                             'value': 'virtualshelves/tables/shelves_results.tt',
480                         });
481                         $.ajax({
482                             'dataType': 'json',
483                             'type': 'POST',
484                             'url': sSource,
485                             'data': aoData,
486                             'success': function(json){
487                                 fnCallback(json);
488                             }
489                         });
490                     },
491                     'aoColumns':[
492                         { 'mDataProp': 'dt_type' },
493                         { 'mDataProp': 'dt_shelfname' },
494                         { 'mDataProp': 'dt_count' },
495                         { 'mDataProp': 'dt_is_shared' },
496                         { 'mDataProp': 'dt_owner' },
497                         { 'mDataProp': 'dt_sortby' },
498                         { 'mDataProp': 'dt_created_on' },
499                         { 'mDataProp': 'dt_modification_time' },
500                         { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
501                     ],
502                     "aoColumnDefs": [
503                         { "bVisible": false, "aTargets": [ 'NoVisible' ] }
504                     ],
505                     'bAutoWidth': false,
506                     'sPaginationType': 'full_numbers',
507                     'bFilter': false,
508                     "bProcessing": true,
509                     "bSortCellsTop": true
510                 }));
511
512                 dtListResults.fnAddFilters("filter", 750);
513
514                 var tabs = $("#tabs").tabs({
515                     [% IF category == PUBLIC %]
516                         active: 1,
517                     [% ELSE %]
518                         active: 0,
519                     [% END %]
520                     activate: function(e, ui) {
521                         var active = tabs.tabs("option", "active" );
522                         if ( active == 0 ) {
523                             type = [% PRIVATE | html %];
524                             dtListResults.fnDraw();
525                         } else if ( active == 1 ) {
526                             type = [% PUBLIC | html %];
527                             dtListResults.fnDraw();
528                         }
529                     }
530                 });
531                 $("body").on("click", ".deleteshelf", function(){
532                     return confirmDelete(MSG_CONFIRM_DELETE_LIST);
533                 });
534             });
535         [% END %]
536
537         [% IF shelf AND op == 'view' %]
538             var Sticky;
539             $(document).ready(function(){
540                 Sticky = $("#searchheader");
541                 Sticky.hcSticky({
542                     stickTo: "#listform",
543                     stickyClass: "floating"
544                 });
545                 $("span.clearall").html("<a id=\"CheckNone\" href=\"/cgi-bin/koha/shelves.pl\"><i class=\"fa fa-remove\"></i>"+_(" Clear all")+"<\/a>");
546                 $("span.checkall").html("<a id=\"CheckAll\" href=\"/cgi-bin/koha/shelves.pl\"><i class=\"fa fa-check\"></i>"+_(" Select all")+"<\/a>");
547                 $("#CheckAll").click(function(e){
548                     e.preventDefault();
549                     $(".selection").each(function(){
550                         $(this).prop("checked", true);
551                     });
552                 });
553
554                 $("#CheckNone").click(function(e){
555                     e.preventDefault();
556                     $(".selection").each(function(){
557                         $(this).prop("checked", false);
558                     });
559                 });
560                 $(".placehold").on("click",function(e){
561                     placeHold();
562                     e.preventDefault();
563                 });
564                 $(".addtocart").show();
565                 var param1 = "| <label for=\"addto\">"+_("Add to:")+"<\/label><select name=\"addto\" id=\"addto\"><option value=\"\"><\/option>";
566                 [% IF ( intranetbookbag ) %]
567                      param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
568                 [% END %]
569                 [% IF Koha.Preference('virtualshelves') %]
570                     [% IF add_to_some_private_shelves.count %]
571                         param1 += "<optgroup label=\""+_("Your lists:")+"\">";
572                         [% SET number_of_private_shelves = 0 %]
573                         [% FOREACH s IN add_to_some_private_shelves %]
574                             [% IF shelfnumber != s.shelfnumber %]
575                                 param1 += "<option id=\"s[% s.shelfnumber | html %]\" value=\"addtolist\">[% s.shelfname | html %]<\/option>";
576                                 [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
577                                 [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
578                             [% END %]
579                         [% END %]
580                         param1 += "<\/optgroup>";
581                     [% END %]
582                     [% IF add_to_some_public_shelves.count %]
583                         param1 += "<optgroup label=\""+_("Public lists:")+"\">";
584                         [% SET number_of_public_shelves = 0 %]
585                         [% FOREACH s IN add_to_some_public_shelves %]
586                             [% IF shelfnumber != s.shelfnumber %]
587                                 param1 += "<option id=\"s[% s.shelfnumber | html %]\" value=\"addtolist\">[% s.shelfname | html %]<\/option>";
588                                 [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
589                                 [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
590                             [% END %]
591                         [% END %]
592                         param1 += "<\/optgroup>";
593                     [% END %]
594                     [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
595                         param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
596                     [% END %]
597                     param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
598                 [% END %]
599                 param1 += "<\/select> <button id=\"cartsubmit\" type=\"submit\" class=\"btn btn-default btn-xs\">"+_("Save")+"</button>";
600                 $("span.addto").html(param1);
601                 $("#cartsubmit").on("click",function(e){
602                     cartList();
603                     e.preventDefault();
604                 });
605                 $("#addto").change(function(){
606                     cartList();
607                 });
608                 $(".addto").find("input:submit").click(function(e){
609                     e.preventDefault();
610                     cartList();
611                 });
612                 $("#selection_ops").show();
613                 $(".merge-items").on("click",function(e){
614                     e.preventDefault();
615                     MergeItems();
616                 });
617                 $("#listform").on("submit",function(e){
618
619                 });
620                 $(".list-remove").on("click",function(e){
621                     if($(".selection").filter(":checked").length > 0){
622                         return confirm(MSG_REMOVE_FROM_LIST);
623                     } else {
624                         alert(MSG_NO_ITEM_SELECTED);
625                         e.preventDefault();
626                     }
627                 });
628                 $("#addToList").on("shown.bs.modal", function(e){
629                     $("#barcodes").focus();
630                 });
631             });
632         [% END %]
633
634         [% IF shelf AND op == 'edit_form' %]
635             $(document).ready(function(){
636                 AdjustRemark();
637             });
638         [% END %]
639
640         /**
641          * This function checks if the adequate number of records are checked for merging
642          */
643         function MergeItems() {
644             var checkboxes = $("input:checkbox:checked");
645             if (checkboxes.length < 2) {
646                 alert(_("At least two records must be selected for merging."));
647             } else {
648                 var params = [];
649                 $(checkboxes).each(function() {
650                     params.push('biblionumber=' + $(this).val());
651                 });
652                 var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&');
653                 location.href = url;
654             }
655             return false;
656         }
657
658         /**
659          * This function checks all checkboxes if all are empty,
660          * or unchecks all if any already checked.
661          */
662         function CheckAll(){
663             var checkboxes = document.getElementsByTagName('input');
664             var nbCheckbox = checkboxes.length;
665             var check = areAllChecked();
666             for(var i=0;i<nbCheckbox;i++){
667                 if(checkboxes[i].getAttribute('type') == "checkbox" ){
668                     checkboxes[i].checked = (check) ? 0 : 1;
669                 }
670             }
671         }
672         /**
673          * This function returns true if ALL checkboxes are checked
674          */
675         function areAllChecked(){
676             var checkboxes = document.getElementsByTagName('input');
677             var nbCheckbox = checkboxes.length;
678             for(var i=0;i<nbCheckbox;i++){
679                 if(checkboxes[i].getAttribute('type') == "checkbox" ){
680                     if(checkboxes[i].checked == 0){
681                         return false;
682                     }
683                 }
684             }
685             return true;
686         }
687
688         function placeHold () {
689             var checkedItems = $(".selection:checked");
690             if ($(checkedItems).size() == 0) {
691                 alert(MSG_NO_ITEM_SELECTED);
692                 return false;
693             }
694             var bibs = "";
695             $(checkedItems).each(function() {
696                 bibs += $(this).val() + "/";
697             });
698             $("#hold_form_biblios").val(bibs);
699             $("#hold_form").submit();
700             return false;
701         }
702
703         function cartList(){
704             var checkboxes = $("#searchresults").find(":checkbox");
705             var vshelf = vShelfAdd(checkboxes);
706             if($("#addto").find("option:selected").attr("value") == "addtolist"){
707                 var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s","");
708                 if (vshelf) {
709                      openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&' + vshelf,'popup',500,500);
710                 }
711                 return false;
712             } else if($("#addto").find("option:selected").attr("value") == "newlist"){
713                 if (vshelf) {
714                     openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?newshelf=1&' + vshelf,'popup',500,500);
715                 }
716                 return false;
717             } else if($("#addto").find("option:selected").attr("value") == "morelists"){
718                 if (vshelf) {
719                     openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?' + vshelf,'popup',500,500);
720                 }
721                 return false;
722             }
723             if($("#addto").find("option:selected").attr("value") == "addtocart"){
724                 addMultiple(checkboxes);
725                 return false;
726             }
727         }
728
729         function AdjustRemark() {
730             var category = $("#category").val();
731             var perms = $("#allow_changes_from").val();
732
733             if( perms < 2 ) {
734                 $("#anyone_remark").hide();
735             } else if( category==1 ) {
736                 // If we move to Private (without shares), show Anyone remark
737                 // Note: the number of shares is not tested real-time
738                 [% IF !shelf.is_shared %]
739                     $("#anyone_remark").show();
740                 [% ELSE %]
741                     $("#anyone_remark").hide();
742                 [% END %]
743             } else { // category==2
744                 $("#anyone_remark").hide();
745             }
746         }
747         [% IF op == 'view' %]
748
749             function sendList(){
750                 open(CGIBIN+'virtualshelves/sendshelf.pl?shelfid=[% shelf.shelfnumber | html %]','win_form','scrollbars=no,resizable=no,height=300,width=450,top=50,left=100');
751              }
752
753              $(document).ready(function() {
754                 $("#sendlist").click(function(){
755                     sendList();
756                     return false;
757                 });
758                 $("#deleteshelf").click(function(e){
759                     if(confirm(_("Are you sure you want to delete this list?"))){
760                         return true;
761                     } else {
762                         e.preventDefault();
763                     }
764                 });
765              });
766
767         [% END %]
768     </script>
769 [% END %]
770
771 [% INCLUDE 'intranet-bottom.inc' %]