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