Bug 11529: Add templates for biblio title display. Unify display.
[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                         [% INCLUDE 'biblio-title.inc' biblio=itemsloo %]
216                     </a>
217                 [% END %]
218                     <p class="hold">
219                         [% IF ( itemsloo.notforloan ) %]
220                             <span class="noholdstext">No holds allowed</span>
221                         [% ELSE %]
222                             [% IF ( itemsloo.ITEM_RESULTS.size ) %]
223                                 <a id="reserve_[% itemsloo.biblionumber | html %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber | html %]">Holds</a>
224                                 [% 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 %]
225                             [% ELSE %]
226                                 <span class="noholdstext">No holds allowed</span>
227                             [% END %]
228                         [% END %]
229                         [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
230                             | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% itemsloo.biblionumber | uri %]">Edit record</a>
231                         [% END %]
232                         [% IF ( CAN_user_editcatalogue_edit_items ) %]
233                             | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% itemsloo.biblionumber | uri %]">Edit items</a>
234                         [% END %]
235                     </p>
236             </td>
237             <td>[% itemsloo.author | html %]</td>
238             <td>[% itemsloo.dateadded | $KohaDates%]</td>
239             <td>
240                 <ul>
241                 [% FOREACH result IN itemsloo.ITEM_RESULTS %]
242                     <li>
243                         [% result.holdingbranch | html %]
244                         [% IF ( result.location_intranet ) %]<span class="shelvingloc">[% result.location_intranet | html %]</span>[% END %]
245                         [% IF ( result.itemcallnumber ) %]
246                             [<a href="/cgi-bin/koha/catalogue/search.pl?idx=callnum&amp;q=%22[% result.itemcallnumber |uri %]%22">[% result.itemcallnumber | html %]</a>]
247                         [% END %]
248                     </li>
249                 [% END %]
250                 </ul>
251             </td>
252                         </tr>
253                 [% END %]<!-- /itemsloop -->
254     </table>
255     <div class="pages">[% pagination_bar | $raw %]</div>
256 </form>
257
258         [% END %]
259 [% END %]
260
261 [% IF op == 'add_form' OR op == 'edit_form' %]
262
263     <form method="post" action="/cgi-bin/koha/virtualshelves/shelves.pl" class="validated">
264         <fieldset class="rows">
265
266         [% IF op == 'add_form' %]
267             <legend>Create a new list</legend>
268             <input type="hidden" name="op" value="add" />
269         [% ELSE %]
270             <legend>Edit list <i>[% shelf.shelfname | html %]</i></legend>
271             <input type="hidden" name="op" value="edit" />
272         [% END %]
273         <input type="hidden" name="referer" value="[% referer | html %]" />
274         <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
275         <ol>
276             <li>
277                 <label for="shelfname" class="required">Name: </label><input type="text" id="shelfname" name="shelfname" size="25" value="[% shelf.shelfname | html %]" required="required" class="required" />
278             <span class="required">Required</span>
279             </li>
280             <li>
281                 <span class="label">Owner: </span>
282                 [% IF op == 'add_form' %]
283                     <input type="hidden" name="owner" id="owner" value="[% loggedinusernumber | html %]" />[% logged_in_user.userid | html %]
284                 [% ELSE %]
285                     [% IF owner %]
286                         <input type="hidden" id="owner" name="owner" value="[% owner.borrowernumber | html %]" />[% owner.firstname _ ' ' _ owner.surname | html %]
287                     [% ELSE %]
288                         <input type="hidden" id="owner" name="owner" value="[% loggedinusernumber | html %]" />[% logged_in_user.userid | html %]
289                     [% END %]
290                 [% END %]
291             </li>
292             <li><label for="sortfield" >Sort this list by: </label>
293             <select name="sortfield">
294             [% IF shelf.sortfield == "title" %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
295             [% IF shelf.sortfield == "author" %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
296             [% IF shelf.sortfield == "copyrightdate" %]<option value="copyrightdate" selected="selected">Copyrightdate</option>[% ELSE %]<option value="copyrightdate">Copyrightdate</option>[% END %]
297             [% IF shelf.sortfield == "itemcallnumber" %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
298             [% IF shelf.sortfield == "dateadded" %]<option value="dateadded" selected="selected">Date added</option>[% ELSE %]<option value="dateadded">Date added</option>[% END %]
299             </select></li>
300             <li><label for="category">Category: </label>
301                 <select id="category" name="category" onchange="AdjustRemark()">
302                 [% IF shelf.is_private %]
303                     <option value="1" selected="selected">Private</option>
304                 [% ELSE %]
305                     <option value="1">Private</option>
306                 [% END %]
307                 [% IF shelf.is_public %]
308                     <option value="2" selected="selected">Public</option>
309                 [% ELSE %]
310                     <option value="2">Public</option>
311                 [% END %]
312                            </select></li>
313
314             [% INCLUDE list_permissions %]
315
316         </ol>
317     </fieldset>
318
319     <fieldset class="action">
320         <input type="submit" value="Save" class="submit" />
321         [% IF referer == 'view' %]
322            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]" class="cancel">Cancel</a>
323        [% ELSE %]
324             [% IF category == PUBLIC %]
325                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PUBLIC | uri %]" class="cancel">Cancel</a>
326             [% ELSE %]
327                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PRIVATE | uri %]" class="cancel">Cancel</a>
328             [% END %]
329         [% END %]
330     </fieldset>
331     </form>
332
333 [% END %]
334
335 [% IF op == 'list' %]
336     <h2>Lists</h2>
337     <div id="tabs" class="toptabs">
338         <ul>
339             <li id="privateshelves_tab" class="active"><a href="#tab_content">Your lists</a></li>
340             <li id="publicshelves_tab" class="active"><a href="#tab_content">Public lists</a></li>
341         </ul>
342
343         <div id="tab_content">
344             <table id="listresultst">
345                 <thead>
346                     <tr>
347                         <th class="NoVisible">Type</th>
348                         <th>List name</th>
349                         <th>Contents</th>
350                         <th>Type</th>
351                         <th>Owner</th>
352                         <th>Sort by</th>
353                         <th>Creation date</th>
354                         <th>Modification date</th>
355                         <th>Actions</th>
356                     </tr>
357                     <tr class="filters_row">
358                         <th></th>
359                         <th><input class="filter text_filter" id="searchshelfname_filter" placeholder="List name"></th>
360                         <th></th>
361                         <th></th>
362                         <th><input class="filter text_filter" id="searchowner_filter" placeholder="Owner"></th>
363                         <th>
364                             <select class="filter text_filter" id="searchsortby_filter">
365                                 <option value=""></option>
366                                 <option value="title">Title</option>
367                                 <option value="author">Author</option>
368                                 <option value="copyrightdate">Copyrightdate</option>
369                                 <option value="itemcallnumber">Call number</option>
370                                 <option value="dateadded">Date added</option>
371                             </select>
372                         </th>
373                         <th></th>
374                         <th></th>
375                         <th></th>
376                     </tr>
377                 </thead>
378                 <tbody></tbody>
379             </table>
380         </div>
381     </div>
382 [% END %]
383
384 <form id="hold_form" method="get" action="/cgi-bin/koha/reserve/request.pl">
385     <!-- Value will be set here by placeHold() -->
386     <input id="hold_form_biblios" type="hidden" name="biblionumbers" value="" />
387     <input type="hidden" name="multi_hold" value="1"/>
388 </form>
389
390             </main>
391         </div> <!-- /.col-sm-10.col-sm-push-2 -->
392     </div> <!-- /.row -->
393
394 [% IF ( can_add_biblios ) %]
395     <!-- Modal -->
396     <div class="modal" id="addToList" tabindex="-1" role="dialog" aria-labelledby="addToListLabel">
397         <div class="modal-dialog" role="document">
398             <form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post">
399                 <div class="modal-content">
400                     <div class="modal-header">
401                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
402                         <h4 class="modal-title" id="addToListLabel">Add items</h4>
403                     </div>
404                     <div class="modal-body">
405                         <fieldset class="brief">
406                         <ol>
407                             <li>
408                                 <label for="barcodes">Barcodes:</label>
409                                 <textarea name="barcodes" id="barcodes" rows="5"></textarea>
410                                 <input type="hidden" name="op" value="add_biblio" />
411                                 <input type="hidden" name="referer" value="view" />
412                                 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
413                             </li>
414                             <li>
415                                 <label for="biblionumbers">Biblio numbers:</label>
416                                 <textarea name="biblionumbers" id="biblionumbers" rows="5"></textarea>
417                                 <input type="hidden" name="op" value="add_biblio" />
418                                 <input type="hidden" name="referer" value="view" />
419                                 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
420                             </li>
421                         </ol>
422                         </fieldset>
423                     </div>
424                     <div class="modal-footer">
425                         <button type="submit" class="btn btn-default">Save</button>
426                         <a href="#" data-dismiss="modal" class="cancel">Cancel</a>
427                     </div>
428                 </div>
429             </form>
430         </div>
431     </div>
432 [% END %]
433
434 [% MACRO jsinclude BLOCK %]
435     [% INCLUDE 'datatables.inc' %]
436     [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
437     [% IF print %]
438         <script>
439             $( document ).ready(function() {
440                 window.print();
441                 setTimeout('window.close()', 1);
442             });
443         </script>
444     [% END %]
445
446     [% IF op == 'view' %]
447         [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
448         [% Asset.js("lib/hc-sticky.js") | $raw %]
449     [% END %]
450     <script>
451         var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
452         var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?");
453         var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to remove this list?");
454
455         [% IF op == 'list' %]
456             $(document).ready(function(){
457                 [% IF category == PUBLIC %]
458                     var type = [% PUBLIC | html %];
459                 [% ELSE %]
460                     var type = [% PRIVATE | html %];
461                 [% END %]
462
463                 var dtListResults = $("#listresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
464                 "aaSorting": [[ 5, "asc" ]],
465                     'bServerSide': true,
466                     'sAjaxSource': "/cgi-bin/koha/svc/virtualshelves/search",
467                     'fnServerData': function(sSource, aoData, fnCallback) {
468                         aoData.push({
469                             'name': 'type',
470                             'value': type,
471                         },{
472                             'name': 'shelfname',
473                             'value': $("#searchshelfname_filter").val(),
474                         },{
475                             'name': 'owner',
476                             'value': $("#searchowner_filter").val(),
477                         },{
478                             'name': 'sortby',
479                             'value': $("#searchsortby_filter").val(),
480                         },{
481                             'name': 'template_path',
482                             'value': 'virtualshelves/tables/shelves_results.tt',
483                         });
484                         $.ajax({
485                             'dataType': 'json',
486                             'type': 'POST',
487                             'url': sSource,
488                             'data': aoData,
489                             'success': function(json){
490                                 fnCallback(json);
491                             }
492                         });
493                     },
494                     'aoColumns':[
495                         { 'mDataProp': 'dt_type' },
496                         { 'mDataProp': 'dt_shelfname' },
497                         { 'mDataProp': 'dt_count' },
498                         { 'mDataProp': 'dt_is_shared' },
499                         { 'mDataProp': 'dt_owner' },
500                         { 'mDataProp': 'dt_sortby' },
501                         { 'mDataProp': 'dt_created_on' },
502                         { 'mDataProp': 'dt_modification_time' },
503                         { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
504                     ],
505                     "aoColumnDefs": [
506                         { "bVisible": false, "aTargets": [ 'NoVisible' ] }
507                     ],
508                     'bAutoWidth': false,
509                     'sPaginationType': 'full_numbers',
510                     'bFilter': false,
511                     "bProcessing": true,
512                     "bSortCellsTop": true
513                 }));
514
515                 dtListResults.fnAddFilters("filter", 750);
516
517                 var tabs = $("#tabs").tabs({
518                     [% IF category == PUBLIC %]
519                         active: 1,
520                     [% ELSE %]
521                         active: 0,
522                     [% END %]
523                     activate: function(e, ui) {
524                         var active = tabs.tabs("option", "active" );
525                         if ( active == 0 ) {
526                             type = [% PRIVATE | html %];
527                             dtListResults.fnDraw();
528                         } else if ( active == 1 ) {
529                             type = [% PUBLIC | html %];
530                             dtListResults.fnDraw();
531                         }
532                     }
533                 });
534                 $("body").on("click", ".deleteshelf", function(){
535                     return confirmDelete(MSG_CONFIRM_DELETE_LIST);
536                 });
537             });
538         [% END %]
539
540         [% IF shelf AND op == 'view' %]
541             var Sticky;
542             $(document).ready(function(){
543                 Sticky = $("#searchheader");
544                 Sticky.hcSticky({
545                     stickTo: "#listform",
546                     stickyClass: "floating"
547                 });
548                 $("span.clearall").html("<a id=\"CheckNone\" href=\"/cgi-bin/koha/shelves.pl\"><i class=\"fa fa-remove\"></i>"+_(" Clear all")+"<\/a>");
549                 $("span.checkall").html("<a id=\"CheckAll\" href=\"/cgi-bin/koha/shelves.pl\"><i class=\"fa fa-check\"></i>"+_(" Select all")+"<\/a>");
550                 $("#CheckAll").click(function(){
551                     $(".checkboxed").checkCheckboxes();
552                     return false;
553                 });
554                 $("#CheckNone").click(function(){
555                     $(".checkboxed").unCheckCheckboxes();
556                     return false;
557                 });
558                 $(".placehold").on("click",function(e){
559                     placeHold();
560                     e.preventDefault();
561                 });
562                 $(".addtocart").show();
563                 var param1 = "| <label for=\"addto\">"+_("Add to:")+"<\/label><select name=\"addto\" id=\"addto\"><option value=\"\"><\/option>";
564                 [% IF ( intranetbookbag ) %]
565                      param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
566                 [% END %]
567                 [% IF Koha.Preference('virtualshelves') %]
568                     [% IF add_to_some_private_shelves.count %]
569                         param1 += "<optgroup label=\""+_("Your lists:")+"\">";
570                         [% SET number_of_private_shelves = 0 %]
571                         [% FOREACH s IN add_to_some_private_shelves %]
572                             [% IF shelfnumber != s.shelfnumber %]
573                                 param1 += "<option id=\"s[% s.shelfnumber | html %]\" value=\"addtolist\">[% s.shelfname | html %]<\/option>";
574                                 [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
575                                 [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
576                             [% END %]
577                         [% END %]
578                         param1 += "<\/optgroup>";
579                     [% END %]
580                     [% IF add_to_some_public_shelves.count %]
581                         param1 += "<optgroup label=\""+_("Public lists:")+"\">";
582                         [% SET number_of_public_shelves = 0 %]
583                         [% FOREACH s IN add_to_some_public_shelves %]
584                             [% IF shelfnumber != s.shelfnumber %]
585                                 param1 += "<option id=\"s[% s.shelfnumber | html %]\" value=\"addtolist\">[% s.shelfname | html %]<\/option>";
586                                 [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
587                                 [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
588                             [% END %]
589                         [% END %]
590                         param1 += "<\/optgroup>";
591                     [% END %]
592                     [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
593                         param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
594                     [% END %]
595                     param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
596                 [% END %]
597                 param1 += "<\/select> <button id=\"cartsubmit\" type=\"submit\" class=\"btn btn-default btn-xs\">"+_("Save")+"</button>";
598                 $("span.addto").html(param1);
599                 $("#cartsubmit").on("click",function(e){
600                     cartList();
601                     e.preventDefault();
602                 });
603                 $("#addto").change(function(){
604                     cartList();
605                 });
606                 $(".addto").find("input:submit").click(function(e){
607                     e.preventDefault();
608                     cartList();
609                 });
610                 $("#selection_ops").show();
611                 $(".merge-items").on("click",function(e){
612                     e.preventDefault();
613                     MergeItems();
614                 });
615                 $("#listform").on("submit",function(e){
616
617                 });
618                 $(".list-remove").on("click",function(e){
619                     if($(".selection").filter(":checked").length > 0){
620                         return confirm(MSG_REMOVE_FROM_LIST);
621                     } else {
622                         alert(MSG_NO_ITEM_SELECTED);
623                         e.preventDefault();
624                     }
625                 });
626                 $("#addToList").on("shown.bs.modal", function(e){
627                     $("#barcodes").focus();
628                 });
629             });
630         [% END %]
631
632         [% IF shelf AND op == 'edit_form' %]
633             $(document).ready(function(){
634                 AdjustRemark();
635             });
636         [% END %]
637
638         /**
639          * This function checks if the adequate number of records are checked for merging
640          */
641         function MergeItems() {
642             var checkboxes = $("input:checkbox:checked");
643             if (checkboxes.length < 2) {
644                 alert(_("At least two records must be selected for merging."));
645             } else {
646                 var params = [];
647                 $(checkboxes).each(function() {
648                     params.push('biblionumber=' + $(this).val());
649                 });
650                 var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&');
651                 location.href = url;
652             }
653             return false;
654         }
655
656         /**
657          * This function checks all checkboxes if all are empty,
658          * or unchecks all if any already checked.
659          */
660         function CheckAll(){
661             var checkboxes = document.getElementsByTagName('input');
662             var nbCheckbox = checkboxes.length;
663             var check = areAllChecked();
664             for(var i=0;i<nbCheckbox;i++){
665                 if(checkboxes[i].getAttribute('type') == "checkbox" ){
666                     checkboxes[i].checked = (check) ? 0 : 1;
667                 }
668             }
669         }
670         /**
671          * This function returns true if ALL checkboxes are checked
672          */
673         function areAllChecked(){
674             var checkboxes = document.getElementsByTagName('input');
675             var nbCheckbox = checkboxes.length;
676             for(var i=0;i<nbCheckbox;i++){
677                 if(checkboxes[i].getAttribute('type') == "checkbox" ){
678                     if(checkboxes[i].checked == 0){
679                         return false;
680                     }
681                 }
682             }
683             return true;
684         }
685
686         function placeHold () {
687             var checkedItems = $(".selection:checked");
688             if ($(checkedItems).size() == 0) {
689                 alert(MSG_NO_ITEM_SELECTED);
690                 return false;
691             }
692             var bibs = "";
693             $(checkedItems).each(function() {
694                 bibs += $(this).val() + "/";
695             });
696             $("#hold_form_biblios").val(bibs);
697             $("#hold_form").submit();
698             return false;
699         }
700
701         function cartList(){
702             var checkboxes = $("#searchresults").find(":checkbox");
703             var vshelf = vShelfAdd(checkboxes);
704             if($("#addto").find("option:selected").attr("value") == "addtolist"){
705                 var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s","");
706                 if (vshelf) {
707                      openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&' + vshelf,'popup',500,500);
708                 }
709                 return false;
710             } else if($("#addto").find("option:selected").attr("value") == "newlist"){
711                 if (vshelf) {
712                     openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?newshelf=1&' + vshelf,'popup',500,500);
713                 }
714                 return false;
715             } else if($("#addto").find("option:selected").attr("value") == "morelists"){
716                 if (vshelf) {
717                     openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?' + vshelf,'popup',500,500);
718                 }
719                 return false;
720             }
721             if($("#addto").find("option:selected").attr("value") == "addtocart"){
722                 addMultiple(checkboxes);
723                 return false;
724             }
725         }
726
727         function AdjustRemark() {
728             var category = $("#category").val();
729             var perms = $("#allow_changes_from").val();
730
731             if( perms < 2 ) {
732                 $("#anyone_remark").hide();
733             } else if( category==1 ) {
734                 // If we move to Private (without shares), show Anyone remark
735                 // Note: the number of shares is not tested real-time
736                 [% IF !shelf.is_shared %]
737                     $("#anyone_remark").show();
738                 [% ELSE %]
739                     $("#anyone_remark").hide();
740                 [% END %]
741             } else { // category==2
742                 $("#anyone_remark").hide();
743             }
744         }
745         [% IF op == 'view' %]
746
747             function sendList(){
748                 open(CGIBIN+'virtualshelves/sendshelf.pl?shelfid=[% shelf.shelfnumber | html %]','win_form','scrollbars=no,resizable=no,height=300,width=450,top=50,left=100');
749              }
750
751              $(document).ready(function() {
752                 $("#sendlist").click(function(){
753                     sendList();
754                     return false;
755                 });
756                 $("#deleteshelf").click(function(e){
757                     if(confirm(_("Are you sure you want to delete this list?"))){
758                         return true;
759                     } else {
760                         e.preventDefault();
761                     }
762                 });
763              });
764
765         [% END %]
766     </script>
767 [% END %]
768
769 [% INCLUDE 'intranet-bottom.inc' %]