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