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