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