Bug 30952: Staff interface redesign (header)
[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 [% USE AuthorisedValues %]
6 [% USE Branches %]
7 [% SET footerjs = 1 %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>
10     [% IF op == 'view' %]
11         Contents of [% shelf.shelfname | html %] &rsaquo; [% END %]
12
13     [% IF op == 'add_form' %]
14         Create new list &rsaquo; [% END %]
15
16     [% IF op == 'edit_form' %]
17         Edit list [% shelf.shelfname | html %] &rsaquo; [% END %]
18     Lists &rsaquo; Koha
19 </title>
20 [% INCLUDE 'doc-head-close.inc' %]
21 <style>textarea { width: 100%; }</style>
22
23 [% BLOCK list_permissions %]
24     <li>
25         <label for="allow_changes_from">Allow changes to contents from: </label>
26         <select name="allow_changes_from" id="allow_changes_from" onchange="AdjustRemark()">
27
28             [% IF shelf.allow_change_from_owner %]
29                 <option value="0">Nobody</option>
30             [% ELSE %]
31                 <option value="0" selected="selected">Nobody</option>
32             [% END %]
33
34             [% IF shelf.allow_change_from_owner && (( !shelf.is_public && !shelf.is_shared ) || !shelf.allow_change_from_others ) %]
35                 <option value="1" selected="selected">Owner only</option>
36             [% ELSE %]
37                 <option value="1">Owner only</option>
38             [% END %]
39
40             [% IF shelf.allow_change_from_others %]
41                 <option value="2" selected="selected">Anyone seeing this list</option>
42             [% ELSE %]
43                 <option value="2">Anyone seeing this list</option>
44             [% END %]
45
46             [% IF shelf.allow_change_from_staff %]
47                 <option value="3" selected="selected">Staff only</option>
48             [% ELSE %]
49                 <option value="3">Staff only</option>
50                 [% END %]
51         </select>
52         &emsp; <span id="anyone_remark" style="display:none;color:red;">The Anyone permission has no actual effect while this list is strictly private.</span>
53         &emsp; <span id="staff_remark" style="display:none;color:red;">The Staff only permission has no actual effect while this list is strictly private.</span>
54     </li>
55 [% END %]
56 </head>
57
58 <body id="lists_shelves" class="lists">
59 [% WRAPPER 'header.inc' %]
60     [% INCLUDE 'cat-search.inc' %]
61 [% END %]
62
63 [% WRAPPER 'sub-header.inc' %]
64 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
65     <ol>
66         <li>
67             <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
68         </li>
69
70         [% IF op != 'list' %]
71             <li>
72                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a>
73             </li>
74         [% ELSE %]
75             <li>
76                 <a href="#" aria-current="page">
77                     Lists
78                 </a>
79             </li>
80         [% END %]
81
82         [% IF shelf AND shelf.is_private %]
83             [% IF op == 'view' OR op == 'edit_form' %]
84                 <li>
85                     <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=0">Your lists</a>
86                 </li>
87             [% ELSE %]
88                 <li>
89                     <a href="#" aria-current="page">
90                         Your lists
91                     </a>
92                 </li>
93             [% END %]
94
95         [% ELSIF shelf AND shelf.is_public %]
96             [% IF op == 'view' %]
97                 <li>
98                     <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=1">Public lists</a>
99                 </li>
100             [% ELSE %]
101                 <li>
102                     <a href="#" aria-current="page">
103                         Public lists
104                     </a>
105                 </li>
106             [% END %]
107         [% END %]
108
109         [% IF op == 'view' %]
110             <li>
111                 <a href="#" aria-current="page">
112                     Contents of <em>[% shelf.shelfname | html %]</em>
113                 </a>
114             </li>
115         [% END %]
116
117         [% IF op == 'add_form' %]
118             <li>
119                 <a href="#" aria-current="page">
120                     Create new list
121                 </a>
122             </li>
123         [% END %]
124
125         [% IF op == 'edit_form' %]
126             <li>
127                 <a href="#" aria-current="page">
128                     Edit list <em>[% shelf.shelfname | html %]</em>
129                 </a>
130             </li>
131         [% END %]
132
133         [% IF op == 'transfer' %]
134             <li>
135                 <a href="#" aria-current="page">Transfer list <em>[% shelf.shelfname | html %]</em></a>
136             </li>
137         [% END %]
138     </ol>
139 </nav>
140 [% END %]
141
142 <div class="main container-fluid">
143     <div class="row">
144         <div class="col-sm-10 col-sm-push-1">
145             <main>
146
147             [% IF op != 'transfer' %][% INCLUDE 'virtualshelves-toolbar.inc' %][% END %]
148
149             [% FOR m IN messages %]
150                 <div class="dialog [% m.type | html %]">
151                     [% SWITCH m.code %]
152                     [% CASE 'error_on_update' %]
153                         <span>An error occurred when updating this list.</span>
154                     [% CASE 'error_on_insert' %]
155                         <span>An error occurred when creating this list.</span>
156                     [% CASE 'error_on_delete' %]
157                         <span>An error occurred when deleting this list.</span>
158                     [% CASE 'error_on_add_biblio' %]
159                         [% IF m.item_barcode %]
160                             <span>The item ([% m.item_barcode | html %]) has not been added to the list. Please verify it is not already in the list.</span>
161                         [% ELSE %]
162                             <span>The record ([% m.bibnum | html %]) has not been added to the list. Please verify it is not already in the list.</span>
163                         [% END %]
164                     [% CASE 'success_on_update' %]
165                         <span>List updated.</span>
166                     [% CASE 'success_on_insert' %]
167                         <span>List created.</span>
168                     [% CASE 'success_on_delete' %]
169                         <span>List deleted.</span>
170                     [% CASE 'success_on_add_biblio' %]
171                         [% IF m.item_barcode %]
172                             <span>The item ([% m.item_barcode | html %]) has been added to the list.</span>
173                         [% ELSE %]
174                             <span>The record ([% m.bibnum | html %]) has been added to the list.</span>
175                         [% END %]
176                     [% CASE 'success_on_remove_biblios' %]
177                         <span>The item has been removed from the list.</span>
178                     [% CASE 'does_not_exist' %]
179                         <span>This list does not exist.</span>
180                     [% CASE 'item_does_not_exist' %]
181                         [% IF m.item_barcode %]
182                             <span>The item ([% m.item_barcode | html %]) does not exist.</span>
183                         [% ELSE %]
184                             <span>The record ([% m.bibnum | html %]) does not exist.</span>
185                         [% END %]
186                     [% CASE 'unauthorized_on_view' %]
187                         <span>You do not have permission to view this list.</span>
188                     [% CASE 'unauthorized_on_update' %]
189                         <span>You do not have permission to update this list.</span>
190                     [% CASE 'unauthorized_on_delete' %]
191                         <span>You do not have permission to delete this list.</span>
192                     [% CASE 'unauthorized_on_add_biblio' %]
193                         <span>You do not have permission to add a record to this list.</span>
194                     [% CASE 'unauthorized_transfer' %]
195                         <span>You do not have permission to transfer ownership of this list.</span>
196                     [% CASE 'new_owner_not_found' %]
197                         <span>The new owner could not be found anymore.</span>
198                     [% CASE 'no_biblio_removed' %]
199                         <span>No record was removed.</span>
200
201                     [% CASE 'Koha::Exceptions::Virtualshelf::DuplicateObject' %]
202                         <span>An error occurred when creating this list. The name [% shelfname | html %] already exists.</span>
203                     [% CASE 'Koha::Exceptions::Virtualshelf::UseDbAdminAccount' %]
204                         <span>List could not be created. (Do not use the database administrator account.)</span>
205                     [% CASE 'DBIx::Class::Exception' %]
206                         [% m.msg | html %]
207
208                     [% CASE %]
209                         [% m.code | html %] [% m.msg | html %]
210                     [% END # /SWITCH %]
211                 </div>
212             [% END # /FOR m IN messages %]
213
214             [% IF op == 'transfer' %]
215                 <h1>Transfer ownership of public list [% shelf.shelfname | html %]</h1>
216
217                 <form action="/cgi-bin/koha/virtualshelves/shelves.pl" id="transferform" method="post">
218                     <fieldset>
219                         <input type="hidden" name="op" value="transfer" />
220                         <input type="hidden" name="public" value="1" />
221                         <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
222
223                         <div>
224                             <label for="find_patron">Search for new owner: </label>
225                             <input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
226                         </div>
227
228                         <br/>
229                         <div>
230                             <label for="find_patron">New owner: </label>
231                             <span id="new_owner_name"></span>
232                             <input type="hidden" id="new_owner" name="new_owner" value="" />
233                         </div>
234
235                         <br/>
236                         <fieldset class="action">
237                             <input type="submit" value="Transfer" class="submit" />
238                             <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=1" class="cancel">Cancel</a>
239                         </fieldset>
240
241                     </fieldset>
242                 </form>
243             [% END # /IF op == transfer %]
244
245             [% IF op == 'view' %]
246                 <h1>Contents of <em>[% shelf.shelfname | html %]</em></h1>
247                 [% IF itemsloop %]
248                     <div class="pages">[% pagination_bar | $raw %]</div>
249                     <form action="/cgi-bin/koha/virtualshelves/shelves.pl" id="listform" method="post">
250                         <input type="hidden" name="op" value="remove_biblios" />
251                         <input type="hidden" name="referer" value="view" />
252                         <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
253
254                         [% IF direction == 'asc' %]
255                             [% SET new_direction = 'desc' %]
256                         [% ELSE %]
257                             [% SET direction = 'desc' %]
258                             [% SET new_direction = 'asc' %]
259                         [% END %]
260
261                         [% IF itemsloop %]
262                             <div id="searchheader" class="searchheader noprint">
263                                 <div id="selection_ops">
264                                     <span class="checkall"></span> |
265                                     <span class="clearall"></span>
266
267                                     <span class="addto">| </span>
268                                     &nbsp;
269                                     [% IF CAN_user_reserveforothers && Koha.Preference('DisplayMultiPlaceHold') %]
270                                         <div class="btn-group"><button class="btn btn-default btn-xs placehold"><i class="fa fa-sticky-note-o"></i> Place hold</button></div>
271                                     [% END %]
272                                     [% IF can_remove_biblios %]
273                                         <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>
274                                     [% END %]
275                                     [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
276                                         <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>
277                                     [% END %]
278                                 </div>
279                             </div>
280                         [% END %]
281
282                         <table id="searchresults" class="dataTable">
283                             <thead>
284                                 <tr>
285                                     [% IF ( itemsloop ) %]
286                                         <th class="checkall">&nbsp;</th>
287                                     [% END %]
288                                     [% UNLESS ( item_level_itypes ) %]
289                                         <th>Item type</th>
290                                     [% END %]
291                                     [% IF sortfield == 'title' %]
292                                         <th class="sorting_[% direction | html %]">
293                                     [% ELSE %]
294                                         <th class="sorting">
295                                     [% END %]
296                                         <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>
297                                     </th>
298                                     [% IF sortfield == 'author' %]
299                                         <th class="sorting_[% direction | html %]">
300                                     [% ELSE %]
301                                         <th class="sorting">
302                                     [% END %]
303                                         <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>
304                                     </th>
305                                     [% IF sortfield == 'dateadded' %]
306                                         <th class="sorting_[% direction | html %]">
307                                     [% ELSE %]
308                                         <th class="sorting">
309                                     [% END %]
310                                         <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>
311                                     </th>
312                                     [% IF sortfield == 'itemcallnumber' %]
313                                         <th class="sorting_[% direction | html %]">
314                                     [% ELSE %]
315                                         <th class="sorting">
316                                     [% END %]
317                                         <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>
318                                     </th>
319                                 </tr>
320                             </thead>
321                             [% FOREACH itemsloo IN itemsloop %]
322                                 <tr>
323                                     [% IF itemsloop %]
324                                         <td>
325                                             <input type="checkbox" class="selection" value="[% itemsloo.biblionumber | html %]" name="biblionumber" />
326                                         </td>
327                                     [% END %]
328                                     [% UNLESS ( item_level_itypes ) %]
329                                         <td>
330                                             [% UNLESS ( noItemTypeImages || !itemsloo.imageurl ) %]
331                                                 <img src="[% itemsloo.imageurl | html %]" alt="[% itemsloo.description | html %]" title="[% itemsloo.description | html %]" />
332                                             [% END %]
333                                             [% itemsloo.description | html %]
334                                         </td>
335                                     [% END %]
336                                     <td>
337                                         [% IF ( itemsloo.XSLTBloc ) %]
338                                             [% itemsloo.XSLTBloc | $raw %]
339                                         [% ELSE %]
340                                             [% INCLUDE 'biblio-title.inc' biblio=itemsloo link = 1 %]
341                                             </a>
342                                         [% END %]
343                                         <p class="hold">
344                                             [% IF ( itemsloo.notforloan ) %]
345                                                 <span class="noholdstext">No holds allowed</span>
346                                             [% ELSE %]
347                                                 [% IF ( itemsloo.ITEM_RESULTS.count ) %]
348                                                     <a id="reserve_[% itemsloo.biblionumber | html %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber | html %]">Holds</a>
349                                                     [% IF ( holdfor ) %]
350                                                         <span class="holdforlink">| <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% itemsloo.biblionumber | uri %]&amp;findborrower=[% holdfor_patron.cardnumber | uri %]">Place hold for [% INCLUDE 'patron-title.inc' patron => holdfor_patron no_title => 1 %]</a></span>
351                                                     [% END %]
352                                                 [% ELSE %]
353                                                     <span class="noholdstext">No holds allowed</span>
354                                                 [% END %]
355                                             [% END %]
356                                             [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]
357                                                 | <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% itemsloo.biblionumber | uri %]">Edit record</a>
358                                             [% END %]
359                                             [% IF ( CAN_user_editcatalogue_edit_items ) %]
360                                                 | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% itemsloo.biblionumber | uri %]">Edit items</a>
361                                             [% END %]
362                                         </p>
363                                     </td>
364                                     <td>
365                                         [% itemsloo.author | html %]
366                                     </td>
367                                     <td>
368                                         [% itemsloo.dateadded | $KohaDates%]
369                                     </td>
370                                     <td>
371                                         <ul>
372                                             [% FOREACH item IN itemsloo.ITEM_RESULTS %]
373                                                 <li>
374                                                     [% Branches.GetName(item.holdingbranch) | html %]
375                                                     [% IF ( item.location ) %]
376                                                         <span class="shelvingloc">
377                                                             [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => item.location ) | html %]
378                                                         </span>
379                                                     [% END %]
380                                                     [% IF ( item.itemcallnumber ) %]
381                                                         [<a href="/cgi-bin/koha/catalogue/search.pl?idx=callnum&amp;q=%22[% item.itemcallnumber | uri %]%22">[% item.itemcallnumber | html %]</a>]
382                                                     [% END %]
383                                                 </li>
384                                             [% END # /FOREACH item %]
385                                         </ul>
386                                     </td>
387                                 </tr>
388                             [% END #/FOREACH itemsloo %]
389                         </table> <!-- /#searchresults -->
390                         <div class="pages">[% pagination_bar | $raw %]</div>
391                     </form>
392                 [% END # /IF itemsloop %]
393             [% END # /IF op == 'view' %]
394
395             [% IF op == 'add_form' OR op == 'edit_form' %]
396
397                 <form method="post" action="/cgi-bin/koha/virtualshelves/shelves.pl" class="validated">
398                     <fieldset class="rows">
399                         [% IF op == 'add_form' %]
400                             <legend><h1>Create a new list</h1></legend>
401                             <input type="hidden" name="op" value="add" />
402                         [% ELSE %]
403                             <legend><h1>Edit list <em>[% shelf.shelfname | html %]</em></h1></legend>
404                             <input type="hidden" name="op" value="edit" />
405                         [% END %]
406                         <input type="hidden" name="referer" value="[% referer | html %]" />
407                         <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
408                         <ol>
409                             <li>
410                                 <label for="shelfname" class="required">Name: </label><input type="text" id="shelfname" name="shelfname" size="25" value="[% shelf.shelfname | html %]" required="required" class="focus required" />
411                                 <span class="required">Required</span>
412                             </li>
413                             <li>
414                                 <span class="label">Owner: </span>
415                                 [% IF op == 'add_form' %]
416                                     <input type="hidden" name="owner" id="owner" value="[% loggedinusernumber | html %]" />[% logged_in_user.userid | html %]
417                                 [% ELSE %]
418                                     [% IF owner %]
419                                         <input type="hidden" id="owner" name="owner" value="[% owner.borrowernumber | html %]" />[% owner.firstname _ ' ' _ owner.surname | html %]
420                                     [% ELSE %]
421                                         <input type="hidden" id="owner" name="owner" value="[% loggedinusernumber | html %]" />[% logged_in_user.userid | html %]
422                                     [% END %]
423                                 [% END %]
424                             </li>
425                             <li>
426                                 <label for="sortfield" >Sort this list by: </label>
427                                 <select name="sortfield">
428                                     [% IF shelf.sortfield == "title" %]
429                                         <option value="title" selected="selected">Title</option>
430                                     [% ELSE %]
431                                         <option value="title">Title</option>
432                                     [% END %]
433                                     [% IF shelf.sortfield == "author" %]
434                                         <option value="author" selected="selected">Author</option>
435                                     [% ELSE %]
436                                         <option value="author">Author</option>
437                                     [% END %]
438                                     [% IF shelf.sortfield == "copyrightdate" %]
439                                         <option value="copyrightdate" selected="selected">Copyrightdate</option>
440                                     [% ELSE %]
441                                         <option value="copyrightdate">Copyrightdate</option>
442                                     [% END %]
443                                     [% IF shelf.sortfield == "itemcallnumber" %]
444                                         <option value="itemcallnumber" selected="selected">Call number</option>
445                                     [% ELSE %]
446                                         <option value="itemcallnumber">Call number</option>
447                                     [% END %]
448                                     [% IF shelf.sortfield == "dateadded" %]
449                                         <option value="dateadded" selected="selected">Date added</option>
450                                     [% ELSE %]
451                                         <option value="dateadded">Date added</option>
452                                     [% END %]
453                                 </select>
454                             </li>
455                             <li>
456                                 <label for="public">Public: </label>
457                                 <select id="public" name="public" onchange="AdjustRemark()">
458                                     [% IF shelf.is_private %]
459                                         <option value="0" selected="selected">Private</option>
460                                     [% ELSE %]
461                                         <option value="0">Private</option>
462                                     [% END %]
463                                     [% IF shelf.is_public %]
464                                         <option value="1" selected="selected">Public</option>
465                                     [% ELSE %]
466                                         <option value="1">Public</option>
467                                     [% END %]
468                                 </select>
469                             </li>
470                             [% INCLUDE list_permissions %]
471                         </ol>
472                     </fieldset>
473
474                     <fieldset class="action">
475                         <input type="submit" value="Save" class="submit" />
476                         [% IF referer == 'view' %]
477                             <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]" class="cancel">Cancel</a>
478                         [% ELSE %]
479                             [% IF public %]
480                                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=1" class="cancel">Cancel</a>
481                             [% ELSE %]
482                                 <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=0" class="cancel">Cancel</a>
483                             [% END %]
484                         [% END %]
485                     </fieldset>
486                 </form>
487             [% END # /IF op == 'add_form'... %]
488
489             [% IF op == 'list' %]
490                 <h1>Lists</h1>
491                 <div id="tabs" class="toptabs">
492                     <ul class="nav nav-tabs" role="tablist">
493                         <li id="privateshelves_tab" role="presentation" class="active">
494                             <a href="#shelves_list" aria-controls="shelves_list" role="tab" data-toggle="tab" data-public="0">Your lists</a>
495                         </li>
496                         <li id="publicshelves_tab" role="presentation">
497                             <a href="#shelves_list" aria-controls="shelves_list" role="tab" data-toggle="tab" data-public="1">Public lists</a>
498                         </li>
499                     </ul>
500
501                     <div class="tab-content">
502                         <div role="tabpanel" class="tab-pane active" id="shelves_list">
503                             <table id="listresultst">
504                                 <thead>
505                                     <tr>
506                                         <th class="NoVisible">Type</th>
507                                         <th>List name</th>
508                                         <th>Contents</th>
509                                         <th>Type</th>
510                                         <th>Owner</th>
511                                         <th>Sort by</th>
512                                         <th>Creation date</th>
513                                         <th>Modification date</th>
514                                         <th class="noExport">Actions</th>
515                                     </tr>
516                                     <tr class="filters_row">
517                                         <th></th>
518                                         <th><input class="filter text_filter" id="searchshelfname_filter" placeholder="List name"></th>
519                                         <th></th>
520                                         <th></th>
521                                         <th><input class="filter text_filter" id="searchowner_filter" placeholder="Owner"></th>
522                                         <th>
523                                             <select class="filter text_filter" id="searchsortby_filter">
524                                                 <option value=""></option>
525                                                 <option value="title">Title</option>
526                                                 <option value="author">Author</option>
527                                                 <option value="copyrightdate">Copyrightdate</option>
528                                                 <option value="itemcallnumber">Call number</option>
529                                                 <option value="dateadded">Date added</option>
530                                             </select>
531                                         </th>
532                                         <th></th>
533                                         <th></th>
534                                         <th></th>
535                                     </tr>
536                                 </thead>
537                                 <tbody></tbody>
538                             </table> <!-- /#listresultst -->
539                         </div> <!-- /#shelves_list -->
540                     </div> <!-- #/.tab-content -->
541                 </div> <!-- /#tabs -->
542             [% END # /IF op == 'list' %]
543
544             <form id="hold_form" method="get" action="/cgi-bin/koha/reserve/request.pl">
545                 <!-- Values will be set here by placeHold() -->
546             </form>
547
548         </main>
549     </div> <!-- /.col-sm-10.col-sm-push-2 -->
550 </div> <!-- /.row -->
551
552 [% IF ( can_add_biblios ) %]
553     <!-- Modal -->
554     <div class="modal" id="addToList" tabindex="-1" role="dialog" aria-labelledby="addToListLabel">
555         <div class="modal-dialog" role="document">
556             <form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post">
557                 <div class="modal-content">
558                     <div class="modal-header">
559                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
560                         <h4 class="modal-title" id="addToListLabel">Add items</h4>
561                     </div>
562                     <div class="modal-body">
563                         <fieldset class="brief">
564                             <ol>
565                                 <li>
566                                     <label for="barcodes">Barcodes:</label>
567                                     <textarea name="barcodes" id="barcodes" rows="5"></textarea>
568                                     <input type="hidden" name="op" value="add_biblio" />
569                                     <input type="hidden" name="referer" value="view" />
570                                     <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
571                                 </li>
572                                 <li>
573                                     <label for="biblionumbers">Biblio numbers:</label>
574                                     <textarea name="biblionumbers" id="biblionumbers" rows="5"></textarea>
575                                     <input type="hidden" name="op" value="add_biblio" />
576                                     <input type="hidden" name="referer" value="view" />
577                                     <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
578                                 </li>
579                             </ol>
580                         </fieldset>
581                     </div> <!-- /.modal-body -->
582                     <div class="modal-footer">
583                         <button type="submit" class="btn btn-default">Save</button>
584                         <a href="#" data-dismiss="modal" class="cancel">Cancel</a>
585                     </div>
586                 </div>
587             </form>
588         </div> <!-- /.modal-dialog -->
589     </div> <!-- /#addToList -->
590 [% END # IF /( can_add_biblios ) %]
591
592 [% MACRO jsinclude BLOCK %]
593     [% INCLUDE 'datatables.inc' %]
594     [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
595     [% IF print %]
596         <script>
597             $( document ).ready(function() {
598                 window.print();
599                 window.onafterprint = function () {
600                     window.close();
601                 }
602                 setTimeout('window.close()', 1000); // Hack for Chrome < 63
603             });
604         </script>
605     [% END #/print %]
606
607     [% IF op == 'view' %]
608         [% Asset.js("lib/hc-sticky.js") | $raw %]
609     [% END %]
610     <script>
611         var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
612         var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?");
613         var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to remove this list?");
614
615         [% IF op == 'list' %]
616             $(document).ready(function(){
617                 var public = [% public | html %];
618
619                 var dtListResults = $("#listresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
620                 "aaSorting": [[ 5, "asc" ]],
621                     'bServerSide': true,
622                     'sAjaxSource': "/cgi-bin/koha/svc/virtualshelves/search",
623                     'fnServerData': function(sSource, aoData, fnCallback) {
624                         aoData.push({
625                             'name': 'public',
626                             'value': public,
627                         },{
628                             'name': 'shelfname',
629                             'value': $("#searchshelfname_filter").val(),
630                         },{
631                             'name': 'owner',
632                             'value': $("#searchowner_filter").val(),
633                         },{
634                             'name': 'sortby',
635                             'value': $("#searchsortby_filter").val(),
636                         },{
637                             'name': 'template_path',
638                             'value': 'virtualshelves/tables/shelves_results.tt',
639                         },{
640                             'name': 'allow_transfer',
641                             'value': '[% allow_transfer | html %]',
642                         },{
643                             'name': 'shelfname_sorton',
644                             'value': 'vs.shelfname',
645                         },{
646                             'name': 'is_shared_sorton',
647                             'value': 'vs.public',
648                         },{
649                             'name': 'owner_sorton',
650                             'value': 'vs.owner',
651                         },{
652                             'name': 'sortby_sorton',
653                             'value': 'vs.sortfield',
654                         },{
655                             'name': 'created_on_sorton',
656                             'value': 'vs.created_on',
657                         },{
658                             'name': 'modification_time_sorton',
659                             'value': 'vs.lastmodified',
660                         });
661                         $.ajax({
662                             'dataType': 'json',
663                             'type': 'POST',
664                             'url': sSource,
665                             'data': aoData,
666                             'success': function(json){
667                                 fnCallback(json);
668                             }
669                         });
670                     },
671                     'aoColumns':[
672                         { 'mDataProp': 'dt_public' },
673                         { 'mDataProp': 'dt_shelfname' },
674                         { 'mDataProp': 'dt_count' },
675                         { 'mDataProp': 'dt_is_shared' },
676                         { 'mDataProp': 'dt_owner' },
677                         { 'mDataProp': 'dt_sortby' },
678                         { 'mDataProp': 'dt_created_on' },
679                         { 'mDataProp': 'dt_modification_time' },
680                         { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
681                     ],
682                     "aoColumnDefs": [
683                         { "bVisible": false, "aTargets": [ 'NoVisible' ] }
684                     ],
685                     'bAutoWidth': false,
686                     'sPaginationType': 'full_numbers',
687                     'bFilter': false,
688                     "bProcessing": true,
689                     "bSortCellsTop": true
690                 }));
691
692                 dtListResults.fnAddFilters("filter", 750);
693
694                 /* Select correct tab based on URL parameter */
695                 if( public == 0 ){
696                     $('#privateshelves_tab').tab('show');
697                 } else {
698                     $("#publicshelves_tab").tab("show");
699                 }
700
701                 $('a[data-toggle="tab"]')
702                 .on("click", function(){
703                     public = $(this).data("public");
704                 })
705                 .on('shown.bs.tab', function (e) {
706                     dtListResults.fnDraw();
707                 });
708
709                 $("body").on("click", ".deleteshelf", function(){
710                     return confirmDelete(MSG_CONFIRM_DELETE_LIST);
711                 });
712             });
713         [% END # /IF op == 'list' %]
714
715         [% IF shelf AND op == 'view' %]
716             var Sticky;
717             $(document).ready(function(){
718                 Sticky = $("#searchheader");
719                 Sticky.hcSticky({
720                     stickTo: "#listform",
721                     stickyClass: "floating"
722                 });
723                 $("span.clearall").html("<a id=\"CheckNone\" href=\"/cgi-bin/koha/shelves.pl\"><i class=\"fa fa-remove\"></i>"+_(" Clear all")+"<\/a>");
724                 $("span.checkall").html("<a id=\"CheckAll\" href=\"/cgi-bin/koha/shelves.pl\"><i class=\"fa fa-check\"></i>"+_(" Select all")+"<\/a>");
725                 $("#CheckAll").click(function(e){
726                     e.preventDefault();
727                     $(".selection").each(function(){
728                         $(this).prop("checked", true);
729                     });
730                 });
731
732                 $("#CheckNone").click(function(e){
733                     e.preventDefault();
734                     $(".selection").each(function(){
735                         $(this).prop("checked", false);
736                     });
737                 });
738                 $(".placehold").on("click",function(e){
739                     placeHold();
740                     e.preventDefault();
741                 });
742                 $(".addtocart").show();
743                 var param1 = "| <label for=\"addto\">"+_("Add to:")+"<\/label><select name=\"addto\" id=\"addto\"><option value=\"\"><\/option>";
744                 [% IF (Koha.Preference("intranetbookbag")) %]
745                      param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>";
746                 [% END %]
747                 [% IF Koha.Preference('virtualshelves') %]
748                     [% IF add_to_some_private_shelves.count %]
749                         param1 += "<optgroup label=\""+_("Your lists:")+"\">";
750                         [% SET number_of_private_shelves = 0 %]
751                         [% FOREACH s IN add_to_some_private_shelves %]
752                             [% IF shelfnumber != s.shelfnumber %]
753                                 param1 += "<option id=\"s[% s.shelfnumber | html %]\" value=\"addtolist\">[% s.shelfname | html %]<\/option>";
754                                 [% SET number_of_private_shelves = number_of_private_shelves + 1 %]
755                                 [% IF number_of_private_shelves == 10 %][% LAST %][% END %]
756                             [% END %]
757                         [% END %]
758                         param1 += "<\/optgroup>";
759                     [% END %]
760                     [% IF add_to_some_public_shelves.count %]
761                         param1 += "<optgroup label=\""+_("Public lists:")+"\">";
762                         [% SET number_of_public_shelves = 0 %]
763                         [% FOREACH s IN add_to_some_public_shelves %]
764                             [% IF shelfnumber != s.shelfnumber %]
765                                 param1 += "<option id=\"s[% s.shelfnumber | html %]\" value=\"addtolist\">[% s.shelfname | html %]<\/option>";
766                                 [% SET number_of_public_shelves = number_of_public_shelves + 1 %]
767                                 [% IF number_of_public_shelves == 10 %][% LAST %][% END %]
768                             [% END %]
769                         [% END %]
770                         param1 += "<\/optgroup>";
771                     [% END %]
772                     [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %]
773                         param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>";
774                     [% END %]
775                     param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>"
776                 [% END %]
777                 param1 += "<\/select> <button id=\"cartsubmit\" type=\"submit\" class=\"btn btn-default btn-xs\">"+_("Save")+"</button>";
778                 $("span.addto").html(param1);
779                 $("#cartsubmit").on("click",function(e){
780                     cartList();
781                     e.preventDefault();
782                 });
783                 $("#addto").change(function(){
784                     cartList();
785                 });
786                 $(".addto").find("input:submit").click(function(e){
787                     e.preventDefault();
788                     cartList();
789                 });
790                 $("#selection_ops").show();
791                 $(".merge-items").on("click",function(e){
792                     e.preventDefault();
793                     MergeItems();
794                 });
795                 $("#listform").on("submit",function(e){
796
797                 });
798                 $(".list-remove").on("click",function(e){
799                     if($(".selection").filter(":checked").length > 0){
800                         return confirm(MSG_REMOVE_FROM_LIST);
801                     } else {
802                         alert(MSG_NO_ITEM_SELECTED);
803                         e.preventDefault();
804                     }
805                 });
806                 $("#addToList").on("shown.bs.modal", function(e){
807                     $("#barcodes").focus();
808                 });
809             });
810         [% END # /IF shelf %]
811
812         [% IF shelf AND op == 'edit_form' %]
813             $(document).ready(function(){
814                 AdjustRemark();
815             });
816         [% END %]
817
818         /**
819          * This function checks if the adequate number of records are checked for merging
820          */
821         function MergeItems() {
822             var checkboxes = $("input:checkbox:checked");
823             if (checkboxes.length < 2) {
824                 alert(_("At least two records must be selected for merging."));
825             } else {
826                 var params = [];
827                 $(checkboxes).each(function() {
828                     params.push('biblionumber=' + $(this).val());
829                 });
830                 var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&');
831                 location.href = url;
832             }
833             return false;
834         }
835
836         /**
837          * This function checks all checkboxes if all are empty,
838          * or unchecks all if any already checked.
839          */
840         function CheckAll(){
841             var checkboxes = document.getElementsByTagName('input');
842             var nbCheckbox = checkboxes.length;
843             var check = areAllChecked();
844             for(var i=0;i<nbCheckbox;i++){
845                 if(checkboxes[i].getAttribute('type') == "checkbox" ){
846                     checkboxes[i].checked = (check) ? 0 : 1;
847                 }
848             }
849         }
850         /**
851          * This function returns true if ALL checkboxes are checked
852          */
853         function areAllChecked(){
854             var checkboxes = document.getElementsByTagName('input');
855             var nbCheckbox = checkboxes.length;
856             for(var i=0;i<nbCheckbox;i++){
857                 if(checkboxes[i].getAttribute('type') == "checkbox" ){
858                     if(checkboxes[i].checked == 0){
859                         return false;
860                     }
861                 }
862             }
863             return true;
864         }
865
866         function placeHold () {
867             var checkedItems = $(".selection:checked");
868             if ($(checkedItems).size() == 0) {
869                 alert(MSG_NO_ITEM_SELECTED);
870                 return false;
871             }
872             $(checkedItems).each(function() {
873                 var bib_param = $("<input>").attr("type", "hidden").attr("name", "biblionumber").val($(this).val());
874                 $('#hold_form').append(bib_param);
875             });
876             $("#hold_form").submit();
877             return false;
878         }
879
880         function cartList(){
881             var checkboxes = $("#searchresults").find(":checkbox");
882             var vshelf = vShelfAdd(checkboxes);
883             if($("#addto").find("option:selected").attr("value") == "addtolist"){
884                 var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s","");
885                 if (vshelf) {
886                      openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?shelfnumber='+shelfnumber+'&confirm=1&' + vshelf,'popup',500,500);
887                 }
888                 return false;
889             } else if($("#addto").find("option:selected").attr("value") == "newlist"){
890                 if (vshelf) {
891                     openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?newshelf=1&' + vshelf,'popup',500,500);
892                 }
893                 return false;
894             } else if($("#addto").find("option:selected").attr("value") == "morelists"){
895                 if (vshelf) {
896                     openWindow('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?' + vshelf,'popup',500,500);
897                 }
898                 return false;
899             }
900             if($("#addto").find("option:selected").attr("value") == "addtocart"){
901                 addMultiple(checkboxes);
902                 return false;
903             }
904         }
905
906         function AdjustRemark() {
907             var public = $("#public").val();
908             var perms = $("#allow_changes_from").val();
909
910             if( perms < 2 ) {
911                 $("#anyone_remark").hide();
912                 $("#staff_remark").hide();
913             } else if( public==0 ) {
914                 // If we move to Private (without shares), show Anyone remark
915                 // Note: the number of shares is not tested real-time
916                 [% IF !shelf.is_shared %]
917                     if( perms== 2) {
918                         $("#anyone_remark").show();
919                         $("#staff_remark").hide();
920                     } else if ( perms==3 ) {
921                         $("#anyone_remark").hide();
922                         $("#staff_remark").show();
923                     }
924                 [% ELSE %]
925                     $("#anyone_remark").hide();
926                     $("#staff_remark").hide();
927                 [% END %]
928             } else { // public==1
929                 $("#anyone_remark").hide();
930                 $("#staff_remark").hide();
931             }
932         }
933         [% IF op == 'view' %]
934
935             function sendList(){
936                 open(CGIBIN+'virtualshelves/sendshelf.pl?shelfid=[% shelf.shelfnumber | html %]','win_form','scrollbars=no,resizable=no,height=300,width=450,top=50,left=100');
937              }
938
939              $(document).ready(function() {
940                 $("#sendlist").click(function(){
941                     sendList();
942                     return false;
943                 });
944                 $("#deleteshelf").click(function(e){
945                     if(confirm(_("Are you sure you want to delete this list?"))){
946                         return true;
947                     } else {
948                         e.preventDefault();
949                     }
950                 });
951              });
952
953         [% END %]
954
955         [% IF op == 'transfer' %]
956             $(document).ready(function() {
957                 patron_autocomplete( $("#find_patron"), { 'on-select-callback': function( event, ui ) {
958                     $('#new_owner_name').html( ui.item.firstname + " " + ui.item.surname );
959                     $('#new_owner').val( ui.item.patron_id );
960                     $('#find_patron').val('').focus();
961                     return false;
962                 }});
963
964                 $('#transferform').submit(function() {
965                     if( $('#new_owner').val() == '' ) {
966                         alert( _("Please select a new owner first") );
967                         return false;
968                     }
969                     return true;
970                 });
971              });
972         [% END %]
973
974     </script>
975 [% END %]
976
977 [% INCLUDE 'intranet-bottom.inc' %]