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