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