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