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