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