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