Bug 28405: add author name to request.tt when it exists
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reserve / request.tt
1 [% USE raw %]
2 [% USE To %]
3 [% USE Asset %]
4 [% USE JSON.Escape %]
5 [% USE Koha %]
6 [% USE Biblio %]
7 [% USE KohaDates %]
8 [% USE Branches %]
9 [% USE Categories %]
10 [% USE ItemTypes %]
11 [% USE AuthorisedValues %]
12 [% USE Price %]
13 [% USE TablesSettings %]
14 [% PROCESS 'i18n.inc' %]
15 [% SET footerjs = 1 %]
16 [% INCLUDE 'doc-head-open.inc' %]
17 [% UNLESS ( multi_hold ) %]
18     <title>Place a hold on [% INCLUDE 'biblio-title-head.inc' %] &rsaquo; Holds &rsaquo; Circulation &rsaquo; Koha</title>
19 [% ELSE %]
20     <title>Confirm holds &rsaquo; Holds &rsaquo; Circulation &rsaquo; Koha</title>
21 [% END %]
22 [% INCLUDE 'doc-head-close.inc' %]
23 [% Asset.css("css/holds.css") | $raw %]
24 </head>
25
26 <body id="circ_request" class="catalog">
27
28 [% INCLUDE 'header.inc' %]
29 [% INCLUDE 'circ-search.inc' %]
30
31 [% UNLESS ( multi_hold ) %]
32     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
33         <ol>
34             <li>
35                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
36             </li>
37             <li>
38                 <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
39             </li>
40             <li>
41                 [% INCLUDE 'biblio-title.inc' link =1 %]
42             </li>
43             <li>
44                 <a href="#" aria-current="page">
45                     Place a hold
46                 </a>
47             </li>
48         </ol>
49     </nav>
50 [% ELSE %]
51     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
52         <ol>
53             <li>
54                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
55             </li>
56             <li>
57                 <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
58             </li>
59             <li>
60                 [% IF ( patron ) %]
61                     <a href="#" aria-current="page">
62                         Place holds
63                     </a>
64                 [% ELSE %]
65                     [% IF clubcount %]
66                         <a href="#" aria-current="page">
67                             Search patrons or clubs
68                         </a>
69                     [% ELSE %]
70                         <a href="#" aria-current="page">
71                             Search patrons
72                         </a>
73                     [% END %]
74                 [% END %]
75             </li>
76         </ol>
77     </nav>
78 [% END # UNLESS multi_hold %]
79
80 <div class="main container-fluid">
81     <div class="row">
82         [% IF ( multi_hold || nobiblio ) # No sidebar menu when placing multiple holds or biblio not found %]
83             <div class="col-md-10 col-md-offset-1">
84         [% ELSE %]
85             <div class="col-sm-10 col-sm-push-2">
86         [% END %]
87
88         <main>
89
90             [% IF ( nobiblio ) %]
91                 <div class="dialog alert">
92                 [%IF (multi_hold) %]
93                     <strong>Cannot place hold:</strong> one or more records don't exist.
94                 [% ELSE %]
95                     <strong>Cannot place hold:</strong> this record doesn't exist.
96                 [% END %]
97                 </div>
98             [% END %]
99             [% IF ( noitems ) %]
100                 <div class="dialog alert">
101                 [%IF (multi_hold) %]
102                     <strong>Cannot place hold:</strong> one or more records without items attached.
103                 [% ELSE %]
104                     <strong>Cannot place hold:</strong> this record has no items attached.
105                 [% END %]
106                 </div>
107             [% END %]
108
109             [% IF ( messagetransfert ) %]
110                 <div class="dialog message">
111                     <h2>Hold found for ([% nextreservtitle | html %]), please transfer</h2>
112                     <p>Hold placed by : <strong> [% nextreservsurname | html %] [% nextreservfirstname | html %]</strong> at : <strong> [% branchname | html %] </strong>, Please transfer this item.
113                     </p>
114                     <form name="cancelReservewithtransfert" action="branchreserves.pl" method="post">
115                         <input type="submit" class="button" />
116                     </form>
117                 </div>
118             [% END %]
119
120             [% UNLESS ( multi_hold ) %]
121                 <h1>Place a hold on [% INCLUDE 'biblio-title.inc' link = 1 %] [% IF biblio.author %] by [% biblio.author | html %][% END %]</h1>
122             [% ELSE %]
123                 <h1>
124                     [% IF ( patron ) %]
125                         Place holds
126                     [% ELSE %]
127                         [% IF clubcount %]
128                             Search patrons or clubs
129                         [% ELSE %]
130                             Search patrons
131                         [% END %]
132                     [% END %]
133                 </h1>
134             [% END %]
135
136             [% UNLESS club OR patron OR patron.borrowernumber OR noitems OR nobiblio %]
137                 [% IF ( messageborrower ) %]
138                     <div class="dialog alert">
139                         <h3>Patron not found</h3>
140                         <p>No patron with this name, please, try another</p>
141                     </div>
142                 [% END %]
143
144                 [% IF ( messageclub ) %]
145                     <div class="dialog alert">
146                         <h3>Club not found</h3>
147                         <p>No club with this name, please, try another</p>
148                     </div>
149                 [% END %]
150                 <fieldset class="brief">
151                     [% UNLESS multi_hold %]
152                         [% IF clubcount %]
153                             <label>Search patrons or clubs</label>
154                         [% ELSE %]
155                             <label>Search patrons</label>
156                         [% END %]
157                     [% END %]
158                     <div id="circ_holds_select" class="toptabs">
159                         <ul>
160                             <li><a href="#holds_patronsearch_pane">Patrons</a></li>
161                             [% IF clubcount %]
162                                 <li><a href="#holds_clubsearch_pane">Clubs</a></li>
163                             [% END %]
164                         </ul>
165                         <div id="holds_patronsearch_pane">
166                             <form id="holds_patronsearch" action="request.pl?biblionumbers=[% biblionumbers | html %]" method="post">
167                                 <div class="hint">Enter patron card number or partial name:</div>
168                                 <input type="text" size="40" id="patron" class="focus" name="findborrower" autocomplete="off" />
169                                 <input type="submit" value="Search" />
170                                 [% IF multi_hold %]
171                                     <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
172                                 [% ELSE %]
173                                     <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
174                                 [% END %]
175
176                             </form> <!-- /#holds_patronsearch -->
177                             [% IF borrowers %]
178                                 [% INCLUDE 'circ-patron-search-results.inc' destination = "holds" %]
179                             [% END %]
180                         </div>
181                         [% IF clubcount %]
182                             <div id="holds_clubsearch_pane">
183                                 <form id="holds_clubsearch" action="request.pl?biblionumbers=[% biblionumbers | html %]" method="post">
184                                     <div class="hint">Enter club ID or partial name:</div>
185                                     <input type="text" size="40" id="club" class="focus" name="findclub" autocomplete="off" />
186                                     <input type="submit" value="Search" />
187                                     [% IF multi_hold %]
188                                         <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
189                                     [% ELSE %]
190                                         <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
191                                     [% END %]
192
193                                 </form> <!-- /#holds_patronsearch -->
194                                 [% IF clubs %]
195                                     [% INCLUDE 'clubs-table.inc' destination = "holds" %]
196                                 [% END %]
197                             </div>
198                         [% END %]
199                     </div>
200                 </fieldset>
201             [% ELSIF club %]
202                 <div class="dialog alert hide clubalert">
203                 </div>
204                 <fieldset class="rows">
205                     <legend>Hold details</legend>
206                     <form action="/api/v1/clubs/[% club.id | html %]/holds" method="post" name="form" id="club-request-form">
207
208                         [% IF ( multi_hold ) %]
209                             <input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="[% biblionumbers | html %]"/>
210                             <input type="hidden" name="bad_bibs" id="bad_bibs" value=""/>
211                             <input type="hidden" name="request" value="any"/>
212                             [% FOREACH biblioloo IN biblioloop %]
213                                 <input type="hidden" name="title_[% biblioloo.biblionumber | html %]" value="[% biblioloo.title | html %]"/>
214                                 <input type="hidden" name="rank_[% biblioloo.biblionumber | html %]" value="[% biblioloo.rank | html %]"/>
215                             [% END %]
216                         [% ELSE %]
217                             <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
218                             <input type="hidden" name="title" value="[% biblio.title | html %]" />
219                             <input type="hidden" name="rank-request" value="[% fixedRank | html %]" />
220                         [% END # /IF multi_hold %]
221                         <ol>
222                             <li>
223                                 <span class="label">Club: </span> [% club.name | html %]
224                             </li>
225                             <li>
226                                 <span class="label">Description: </span> [% club.description | html %]
227                             </li>
228                             <li>
229                                 <label for="pickup">Pickup at:</label>
230                                 <select name="pickup" id="pickup_club">
231                                     [% PROCESS options_for_libraries libraries => Branches.all({ selected => club.branchcode, search_params => { pickup_location => 1 } }) %]
232                                 </select>
233                             </li>
234                             <li>
235                                 <label for="default_patron_home">Pickup at patron's home library when possible:</label>
236                                 <input type="checkbox" id="default_patron_home" name="default_patron_home"/>
237                             </li>
238                         </ol>
239                         <h2 style="padding: 0 1em;">Members</h2>
240                         <ol>
241                             [% FOREACH member IN members %]
242                                 [% SET patron = member.patron %]
243                                 <li style="padding: 0.5em 1em;">
244                                     <div><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] ([% patron.cardnumber | html %])</a></div>
245                                     [% IF member.exceeded_maxreserves %]
246                                         <div>
247                                             <i class="fa fa-error"></i>
248                                             <strong>Too many holds: </strong> Patron can only place a maximum of [% maxreserves | html %] total holds.
249                                         </div>
250                                     [% END %]
251                                     [% IF ( patron.is_expired ) %]
252                                         <div>
253                                             <i class="fa fa-warning"></i>
254                                             <strong>Account has expired</strong>
255                                         </div>
256                                     [% END %]
257                                     [% IF patron.is_debarred %]
258                                         <div>
259                                             <i class="fa fa-warning"></i>
260                                             <strong>Patron has restrictions</strong>
261                                         </div>
262                                     [% END %]
263                                     [% IF member.amount_outstanding && Koha.Preference('maxoutstanding') && member.amount_outstanding > Koha.Preference('maxoutstanding') %]
264                                         <div>
265                                             <i class="fa fa-warning"></i>
266                                             <strong>Patron has outstanding fines: [% member.amount_outstanding | $Price %]</strong>
267                                         </div>
268                                     [% END %]
269
270                                     [% IF ( member.diffbranch ) %]
271                                         <div>
272                                             <i class="fa fa-warning"></i>
273                                             <strong>Pickup library is different.</strong> Patron's home library: ([% Branches.GetName(patron.branchcode) | html %] / [% patron.branchcode | html %] )
274                                         </div>
275                                     [% END %]
276                                 </li>
277                             [% END %]
278                         [% UNLESS ( multi_hold ) %]
279                             <fieldset class="action">
280                                 <input type="submit" value="Place hold" />
281                             </fieldset>
282                         [% ELSE %]
283                             <table id="requesttitles">
284                                 <tr>
285                                     <th>&nbsp;</th>
286                                     <th>Title</th>
287                                     [% UNLESS ( item_level_itypes ) %]
288                                         <th>Item type</th>
289                                     [% END %]
290                                     <th>Priority</th>
291                                     <th>Information</th>
292                                 </tr>
293                                 [% FOREACH biblioloo IN biblioloop %]
294                                     [% IF ( biblioloo.warn ) %]
295                                         <tr class="onissue">
296                                     [% ELSE %]
297                                         <tr>
298                                     [% END %]
299                                         <td>
300                                             [% UNLESS ( biblioloo.warn ) %]
301                                                     <input class="multi_hold_item_checkbox" type="checkbox" checked="checked" title="[% biblioloo.biblionumber | html %]"/>
302                                                 </td>
303                                             [% END %]
304                                         <td>
305                                             <ul>
306                                                 <li>
307                                                     <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">[% biblioloo.title | html %]</a>
308                                                 </li>
309                                                 [% IF ( biblioloo.publicationyear ) %]
310                                                     <li>
311                                                         <span class="label">Publication year:</span> [% biblioloo.publicationyear | html %]
312                                                     </li>
313                                                 [% END %]
314                                             </ul>
315                                             [% IF ( biblioloo.warn ) %]
316                                                 <span class="not_holdable" title="[% biblioloo.biblionumber | html %]"></span>
317                                             [% END %]
318                                         </td>
319                                         [% UNLESS ( item_level_itypes ) %]
320                                             <td>
321                                                 <img src="[% biblioloo.imageurl | html %]" alt="[% biblioloo.itypename | html %]" title="[% biblioloo.itypename | html %]" />
322                                             </td>
323                                         [% END %]
324                                         <td>[% biblioloo.rank | html %]</td>
325                                         <td>
326                                             [% IF ( biblioloo.checked_previously ) %]
327                                                 <span>Patron has previously checked out this title</span><br/>
328                                             [% END %]
329                                             [% IF ( biblioloo.alreadyres ) %]
330                                                 <ul>
331                                             [% ELSE %]
332                                                 [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
333                                                     <ul>
334                                                 [% END %]
335                                             [% END %]
336
337                                             [% IF ( biblioloo.alreadyres ) %]
338                                                 <li>
339                                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>
340                                                     <strong>already has a hold</strong> on this item
341                                                 </li>
342                                             [% END %]
343                                             [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
344                                                 <li> <strong>No items are available</strong> to be placed on hold</li>
345                                             [% END %]
346
347                                             [% IF ( biblioloo.alreadyres ) %]
348                                                 </ul>
349                                             [% ELSE %]
350                                                 [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
351                                                     </ul>
352                                                 [% END %]
353                                             [% END %]
354                                         </td>
355                                     </tr>
356                                 [% END # /FOREACH biblioloo %]
357                             </table> <!-- /#requesttitles -->
358                         [% END %]
359                     </form>
360                 </fieldset>
361             [% ELSIF NOT ( noitems || nobiblio ) # /UNLESS patron %]
362
363                 [% IF ( checked_previously && !multi_hold ) %]
364                     <div class="dialog alert">
365                         <ul>
366                             <li>Patron has previously checked out this title</li>
367                         </ul>
368                     </div>
369                 [% END %]
370
371                 [% IF ( no_reserves_allowed || exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %]
372                     <div class="dialog alert">
373
374                         [% UNLESS ( multi_hold ) %]
375                             <h3>Cannot place hold</h3>
376                             <ul>
377                                 [% IF ( no_reserves_allowed ) %]
378                                     <li><strong>No holds allowed: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> cannot place a hold on any of these items.</li>
379                                 [% ELSIF ( exceeded_maxreserves ) %]
380                                     <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can only place a maximum of [% maxreserves | html %] total holds.</li>
381                                 [% ELSIF ( exceeded_holds_per_record ) %]
382                                     <li><strong>Too many holds for this record: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can only place a maximum of [% max_holds_for_record | html %] hold(s) on this record.</li>
383                                 [% ELSIF ( alreadypossession ) %]
384                                     <li> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> <strong>is already in possession</strong> of one item.</li>
385                                 [% ELSIF ( alreadyreserved ) %]
386                                     <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> <strong>already has a hold</strong> on this item.</li>
387                                 [% ELSIF ( ageRestricted ) %]
388                                     <li><strong>Age restricted</strong></li>
389                                 [% ELSIF ( none_available ) %]
390                                     <li> <strong>No items are available</strong> to be placed on hold.</li>
391                                 [% ELSIF ( maxreserves ) %]
392                                     <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> has too many holds.</li>
393                                 [% END # /IF exceeded_maxreserves %]
394                             </ul>
395                         [% ELSE # UNLESS multi_hold %]
396                             <h3>Cannot place hold on some items</h3>
397                             [% IF (no_reserves_allowed ) %]
398                                 <li><strong>No holds allowed: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> cannot place holds on some of these title's items.</li>
399                             [% ELSIF ( exceeded_maxreserves ) %]
400                                 <li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can place [% new_reserves_allowed | html %] of the requested [% new_reserves_count | html %] holds for a maximum of [% maxreserves | html %] total holds.</li>
401                             [% ELSIF ( exceeded_holds_per_record ) %]
402                                 [% FOREACH biblioloo IN biblioloop %]
403                                     [% IF (biblioloo.tooManyHoldsForThisRecord) %]
404                                         <li><strong>Too many holds for <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]"> [% biblioloo.title | html %]</a>: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]">[% patron.firstname | html %] [% patron.surname | html %] </a> can only place a maximum of [% max_holds_for_record | html %] hold(s) on this record.</li>
405                                     [% END %]
406                                 [% END %]
407                             [% END # /IF exceeded_maxreserves %]
408                         [% END # /UNLESS multi_hold %]
409                     </div>
410                 [% END # /IF ( exceeded_maxreserves || ... %]
411
412                 [% IF ( patron.is_expired || diffbranch || patron.is_debarred || ( amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') ) ) %]
413                     <div class="dialog message">
414                         <ul>
415                             [% IF ( patron.is_expired ) %]
416                                 <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Account has expired</strong></li>
417                             [% END %]
418
419                             [% IF patron.is_debarred %]
420                                 <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]#reldebarments">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Patron has restrictions</strong></li>
421                             [% END %]
422
423                             [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
424                                 <li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Patron has outstanding fines: [% amount_outstanding | $Price %]</strong></li>
425                             [% END %]
426
427                             [% IF ( diffbranch ) %]
428                                 <li> <strong>Pickup library is different. </strong>Patron: <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a> Patron's home library: ([% Branches.GetName(patron.branchcode) | html %] / [% patron.branchcode | html %] )</li>
429                             [% END %]
430                         </ul> <!-- /.dialog.message -->
431                     </div>
432                 [% END # /IF patron.is_expired || diffbranch ... %]
433
434                 [% IF ( messageborrower ) %]
435                     <div class="dialog alert">
436                         <h3>Patron not found:</h3>
437                         <p>Name or barcode not found. Please try an other </p>
438                     </div>
439                 [% END %]
440
441                 <div class="dialog alert hide holdalert">
442                 </div>
443
444                 <fieldset class="rows">
445                     <legend>Hold details</legend>
446                     <form action="placerequest.pl" method="post" name="form" id="hold-request-form">
447
448                         <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
449                         <input type="hidden" name="type" value="str8" />
450
451                         [% IF ( multi_hold ) %]
452                             <input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="[% biblionumbers | html %]"/>
453                             <input type="hidden" name="multi_holds" id="multi_holds" value="1" />
454                             <input type="hidden" name="bad_bibs" id="bad_bibs" value=""/>
455                             <input type="hidden" name="request" value="any"/>
456                             [% FOREACH biblioloo IN biblioloop %]
457                                 <input type="hidden" name="title_[% biblioloo.biblionumber | html %]" value="[% biblioloo.title | html %]"/>
458                                 <input type="hidden" name="rank_[% biblioloo.biblionumber | html %]" value="[% biblioloo.rank | html %]"/>
459                             [% END %]
460                         [% ELSE %]
461                             <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
462                             <input type="hidden" name="title" value="[% biblio.title | html %]" />
463                             <input type="hidden" name="rank-request" value="[% fixedRank | html %]" />
464                         [% END # /IF multi_hold %]
465
466                         <ol>
467                             <li>
468                                 <span class="label">Patron:</span>
469                                 [% IF ( patron.borrowernumber ) %]
470                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] ([% patron.cardnumber | html %])</a>
471                                 [% ELSE %]
472                                     Not defined yet
473                                 [% END %]
474                             </li>
475
476                             [% UNLESS ( multi_hold ) %]
477                                 <li>
478                                     <span class="label">Estimated priority:</span>
479                                     <strong>[% fixedRank | html %]</strong>
480                                 </li>
481                             [% END %]
482
483                             <li>
484                                 <label for="holdnotes">Notes:</label>
485                                 <textarea id="holdnotes" name="notes" cols="30" rows="1"></textarea>
486                             </li>
487                             <li>
488                                 <label for="pickup">Pickup at:</label>
489                             [% UNLESS ( multi_hold ) %]
490                                 <select name="pickup" id="pickup"
491                                         data-biblio-id="[% biblio.biblionumber | html %]"
492                                         data-patron-id="[% patron.borrowernumber | html %]"
493                                         data-pickup-location-source="biblio">
494                                     [% PROCESS options_for_libraries libraries => Branches.pickup_locations({ search_params => { biblio => biblionumber, patron => patron }, selected => pickup }) %]
495                             [% ELSE %]
496                                 <select name="pickup" id="pickup_multi" data-patron-id="[% patron.borrowernumber | html %]">
497                                     <option value="" selected="selected"></option>
498                                 [% FOREACH pickup_location IN multi_pickup_locations %]
499                                     <option value="[% pickup_location.branchcode | html %]">[% pickup_location.branchname | html %]</option>
500                                 [% END %]
501                             [% END %]
502                                 </select>
503                             </li>
504
505                             [% UNLESS ( multi_hold ) %]
506                                 [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
507                                     <li>
508                                         <label for="itemtype">Request specific item type:</label>
509                                         <select name="itemtype" id="itemtype">
510                                             <option value="">Any item type</option>
511                                             [%- FOREACH itemtype IN available_itemtypes %]
512                                                 <option value="[% itemtype | html %]">[% ItemTypes.GetDescription( itemtype ) | html %]</option>
513                                             [%- END %]
514                                         </select>
515                                     </li>
516                                 [% END %]
517                             [% END # /UNLESS multi_hold %]
518
519                             [% IF ( reserve_in_future ) %]
520                                 <li>
521                                     <label for="from">Hold starts on date:</label>
522                                     <input id="reserve_date" name="reserve_date" id="from" size="10" type="text" data-date_to="expiration_date" class="flatpickr" data-flatpickr-futuredate="true" />
523                                 </li>
524                             [% END %]
525
526                             <li>
527                                 <label for="to">Hold expires on date:</label>
528                                 <input id="expiration_date" name="expiration_date" id="to" size="10" type="text" class="flatpickr" data-flatpickr-futuredate="true" />
529                             </li>
530
531                             [% UNLESS ( multi_hold ) %]
532                                 <li>
533                                     <label for="requestany">Hold next available item </label>
534                                     [% IF force_hold_level == 'item' %]
535                                         <input type="checkbox" id="requestany" name="request" disabled="true" />
536                                     [% ELSIF force_hold_level == 'record' %]
537                                         <input type="checkbox" id="requestany" checked="checked" value="Any" disabled="true"/>
538                                         <input type="hidden" name="request" value="Any"/>
539                                     [% ELSE %]
540                                         <input type="checkbox" id="requestany" name="request" checked="checked" value="Any" />
541                                     [% END %]
542                                     <input type="hidden" name="biblioitem" value="[% biblioitemnumber | html %]" />
543                                     <input type="hidden" name="alreadyreserved" value="[% alreadyreserved | html %]" />
544                                 </li>
545
546                                 [% IF remaining_holds_for_record > 1 %]
547                                     <li>
548                                         <label for="holds_to_place_count">Holds to place (count)</label>
549                                         <input type="text" inputmode="numeric" pattern="[0-9]*" id="holds_to_place_count" name="holds_to_place_count" maxlength="[% remaining_holds_for_record | html %]" value="1" />
550                                     </li>
551                                 [% ELSE %]
552                                     <input type="hidden" name="holds_to_place_count" value="1" />
553                                 [% END %]
554                             [% END # /UNLESS multi_hold %]
555
556                             <li id="non_priority_list_item">
557                                 <label for="non_priority">Non priority hold:</label>
558                                 <input name="non_priority" id="non_priority" type="checkbox" />
559                                 <span class="hint">A non priority hold doesn't prevent a current checkout from renewing</span>
560                             </li>
561                         </ol>
562
563                         [% UNLESS ( multi_hold ) %]
564                             <fieldset class="action">
565                                 [% IF ( patron.borrowernumber ) %]
566                                     [% IF ( override_required ) %]
567                                         <button type="submit" class="btn btn-default warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
568                                     [% ELSIF ( none_available ) %]
569                                         <button type="submit" disabled="disabled" class="btn btn-default btn-disabled">Place hold</button>
570                                     [% ELSE %]
571                                         <button type="submit" class="btn btn-default">Place hold</button>
572                                     [% END %]
573                                 [% END %]
574                             </fieldset>
575
576                             [% FOREACH bibitemloo IN bibitemloop %]
577                                 <ol>
578                                     [% UNLESS ( item_level_itypes ) %]
579                                         <li>
580                                             <span class="label">Item type:</span>
581                                             [% bibitemloo.description | html %]
582                                         </li>
583                                     [% END %]
584
585                                     [% IF ( bibitemloo.publicationyear ) %]
586                                         <li>
587                                             <span class="label">Publication year:</span>
588                                             [% bibitemloo.publicationyear | html %]
589                                         </li>
590                                     [% END %]
591                                 </ol>
592
593                                 <h2 style="padding: 0 1em;">
594                                     Place a hold on a specific item
595                                     [% IF bibitemloo.force_hold_level == 'item' %]
596                                          <span class="error"><em>(Required)</em></span>
597                                     [% END %]
598                                 </h2>
599
600                                 <table id="requestspecific">
601                                     <thead>
602                                         <tr>
603                                             <th>Hold</th>
604                                             [% IF ( item_level_itypes ) %]
605                                                 <th>Item type</th>
606                                             [% END %]
607                                             <th>Barcode</th>
608                                             <th>Home library</th>
609                                             <th>Last location</th>
610                                             [% IF itemdata_ccode %]
611                                                 <th>Collection</th>
612                                             [% END %]
613                                             <th>Call number</th>
614                                             <th>Copy number</th>
615                                             [% IF itemdata_enumchron %]
616                                                 <th>Vol no.</th>
617                                             [% END %]
618                                             <th>Information</th>
619                                             <th>Allowed pickup locations</th>
620                                         </tr>
621                                     </thead>
622                                     <tbody>
623                                         [% SET selected = 0 %]
624                                         [% FOREACH itemloo IN bibitemloo.itemloop %]
625                                             [% UNLESS ( itemloo.hide ) %]
626                                                 <tr class="[% itemloo.backgroundcolor | html %]">
627                                                     <td>
628                                                         [% IF itemloo.force_hold_level == 'record' # Patron has placed a record level hold previously for this record %]
629                                                             <span class="error">
630                                                                 <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i>
631                                                                 Hold must be record level
632                                                             </span>
633                                                         [% ELSIF ( itemloo.available ) %]
634                                                             <input type="radio" name="checkitem" value="[% itemloo.itemnumber | html %]" />
635                                                         [% ELSIF ( itemloo.override ) %]
636                                                             <input type="radio" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber | html %]" />
637                                                             <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" title="Requires override of hold policy"/></i>
638                                                         [% ELSE %]
639                                                             <span class="error">
640                                                                 <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i>
641                                                                 [% IF itemloo.not_holdable %]
642                                                                     [% IF itemloo.not_holdable == 'damaged' %]
643                                                                         Item damaged
644                                                                     [% ELSIF itemloo.not_holdable == 'ageRestricted' %]
645                                                                         Age restricted
646                                                                     [% ELSIF itemloo.not_holdable == 'tooManyHoldsForThisRecord' %]
647                                                                         Exceeded max holds per record
648                                                                     [% ELSIF itemloo.not_holdable == 'tooManyReservesToday' %]
649                                                                         Daily hold limit reached for patron
650                                                                     [% ELSIF itemloo.not_holdable == 'tooManyReserves' %]
651                                                                         Too many holds
652                                                                     [% ELSIF itemloo.not_holdable == 'notReservable' %]
653                                                                         Not holdable
654                                                                     [% ELSIF itemloo.not_holdable == 'cannotReserveFromOtherBranches' %]
655                                                                         Patron is from different library
656                                                                     [% ELSIF itemloo.not_holdable == 'branchNotInHoldGroup' %]
657                                                                         Cannot place hold from patron's library
658                                                                     [% ELSIF itemloo.not_holdable == 'itemAlreadyOnHold' %]
659                                                                         Patron already has hold for this item
660                                                                     [% ELSIF itemloo.not_holdable == 'cannotBeTransferred' %]
661                                                                         Cannot be transferred to pickup library
662                                                                     [% ELSIF itemloo.not_holdable == 'pickupNotInHoldGroup' %]
663                                                                         Only pickup locations within the same hold group are allowed
664                                                                     [% ELSIF itemloo.not_holdable == 'noReservesAllowed' %]
665                                                                         No reserves are allowed on this item
666                                                                     [% ELSIF itemloo.not_holdable == 'libraryNotPickupLocation' %]
667                                                                         Library is not a pickup location
668                                                                     [% ELSIF itemloo.not_holdable == 'no_valid_pickup_location' %]
669                                                                         No valid pickup location
670                                                                     [% ELSE %]
671                                                                         [% itemloo.not_holdable | html %]
672                                                                     [% END %]
673                                                                 [% END %]
674                                                             </span>
675                                                         [% END # /IF itemloo.force_hold_level %]
676                                                     </td>
677                                                     [% IF ( item_level_itypes ) %]
678                                                         <td>
679                                                             [% UNLESS ( noItemTypeImages ) %]
680                                                                 [% IF ( itemloo.imageurl ) %]<img src="[% itemloo.imageurl | html %]" alt="" /> <br /> [% END %]
681                                                             [% END %]
682                                                             [% itemloo.itypename | html %]
683                                                         </td>
684                                                     [% END %]
685                                                     <td>
686                                                         [% itemloo.barcode | html %]
687                                                     </td>
688                                                     <td>
689                                                         [% Branches.GetName( itemloo.homebranch ) | html %]
690                                                     </td>
691                                                     <td>
692                                                         [% Branches.GetName( itemloo.holdingbranch ) | html %]
693                                                     </td>
694                                                     [% IF itemdata_ccode %]
695                                                         <td>
696                                                             [% IF ( itemloo.ccode ) %][% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => itemloo.ccode ) | html %][% END %]
697                                                         </td>
698                                                     [% END %]
699                                                     <td>
700                                                         [% itemloo.itemcallnumber | html %]
701                                                     </td>
702                                                     <td>
703                                                         [% IF ( itemloo.copynumber ) %][% itemloo.copynumber | html %][% ELSE %]&nbsp;[% END %]
704                                                     </td>
705                                                     [% IF itemdata_enumchron %]
706                                                         <td>
707                                                             [% itemloo.enumchron | html %]
708                                                         </td>
709                                                     [% END %]
710                                                     [% IF ( itemloo.onloan ) %]
711                                                         <td data-order="[% itemloo.date_due | html %]">
712                                                             <span class="checkedout">Due [% itemloo.date_due | $KohaDates  as_due_date => 1 %]</span>
713                                                     [% ELSE %]
714                                                         <td>
715                                                             [% IF ( itemloo.transfertwhen ) %]
716                                                                 In transit from [% Branches.GetName( itemloo.transfertfrom ) | html %],
717                                                                 to [% Branches.GetName( itemloo.transfertto ) | html %], since [% itemloo.transfertwhen | html %]
718                                                             [% END %]
719                                                     [% END %]
720
721                                                         [% IF ( itemloo.reservedate ) %]
722                                                             [% IF ( itemloo.nocancel ) %]
723                                                                     Can't be cancelled when item is in transit
724                                                             [% ELSE %]
725                                                                 [% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
726                                                                 [% IF ( itemloo.canreservefromotherbranches ) %]
727                                                                     for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedFor.borrowernumber | uri %]">[% itemloo.ReservedFor.firstname | html %] [% itemloo.ReservedFor.surname | html %]</a>
728                                                                 [% END %]
729                                                                 [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %]
730                                                                 [% Branches.GetName( itemloo.ExpectedAtLibrary ) | html %] since
731                                                                 [% IF ( itemloo.waitingdate ) %]
732                                                                     [% itemloo.waitingdate | $KohaDates %]
733                                                                 [% ELSE %]
734                                                                     [% IF ( itemloo.reservedate ) %]
735                                                                         [% itemloo.reservedate | html %]
736                                                                     [% END %]
737                                                                 [% END %].
738                                                                 <a class="info cancel-hold" href="modrequest.pl?CancelBiblioNumber=[% itemloo.biblionumber | html %]&amp;CancelBorrowerNumber=[% itemloo.ReservedFor.borrowernumber | html %]&amp;CancelItemnumber=[% itemloo.itemnumber | html %]">Cancel hold</a>
739                                                             [% END # /IF itemloo.nocancel %]
740                                                         [% ELSE %]
741                                                             Not on hold
742                                                         [% END # /IF itemloo.reservedate %]
743
744                                                         [% IF itemloo.item_level_holds == "N" %]
745                                                             <br/>Item level hold not allowed from OPAC
746                                                         [% ELSIF itemloo.item_level_holds == "F" %]
747                                                             <br/>Item level hold forced from OPAC
748                                                         [% END %]
749
750                                                         [% IF ( itemloo.itemlost ) %]
751                                                            <span class="lost">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => itemloo.itemlost ) | html %]</span>
752                                                         [% END %]
753
754                                                         [% IF ( itemloo.damaged ) %]
755                                                             <span class="dmg">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.damaged', authorised_value => itemloo.damaged ) | html %]</span>
756                                                         [% END %]
757
758                                                         [% IF ( itemloo.withdrawn ) %]
759                                                            <span class="wdn">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => itemloo.withdrawn ) | html %]</span>
760                                                         [% END %]
761
762                                                         [% IF ( itemloo.notforloan ) %]
763                                                            <span class="nfl">Not for loan ([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => itemloo.notforloan ) | html %])</span>
764                                                         [% END %]
765                                                     </td>
766                                                     <td>
767                                                     [% IF (itemloo.pickup_locations_count > 0) %]
768                                                         <select name="item_pickup_[% itemloo.itemnumber | html %]" class="pickup_locations" style="width:100%;"
769                                                                 data-item-id="[% itemloo.itemnumber | html %]"
770                                                                 data-patron-id="[% patron.borrowernumber | html %]"
771                                                                 data-pickup-location-source="item">
772                                                         [% IF (itemloo.default_pickup_location) %]
773                                                             <option value="[% itemloo.default_pickup_location.branchcode | html %]" selected="selected">[% itemloo.default_pickup_location.branchname | html %]</option>
774                                                         [% END %]
775                                                         </select>
776                                                     [% END %]
777                                                     </td>
778                                                 </tr>
779                                             [% END # / UNLESS itemloo.hide %]
780                                         [% END # /FOREACH itemloo %]
781                                     </tbody>
782                                 </table> <!-- /#requestspecific -->
783
784                                 [% IF ( bibitemloo.hiddencount ) %]
785                                     <form>
786                                         <p class="hiddencount">
787                                             <a href="request.pl?biblionumber=[% bibitemloo.biblionumber | uri %]&amp;borrowernumber=[% bibitemloo.borrowernumber | uri %]&amp;showallitems=1">Show all items ([% bibitemloo.hiddencount | html %] hidden)</a>
788                                         </p>
789                                     </form>
790                                 [% END # /IF bibitemloo.hiddencount %]
791                             [% END # /FOREACH bibitemloo %]
792
793                         [% ELSE # /UNLESS multi_hold %]
794
795                             <table id="requesttitles">
796                                 <tr>
797                                     <th>&nbsp;</th>
798                                     <th>Title</th>
799                                     [% UNLESS ( item_level_itypes ) %]
800                                         <th>Item type</th>
801                                     [% END %]
802                                     <th>Priority</th>
803                                     <th>Information</th>
804                                     <th>Pickup location</th>
805                                 </tr>
806                                 [% FOREACH biblioloo IN biblioloop %]
807                                     [% IF ( biblioloo.warn ) %]
808                                         <tr class="onissue">
809                                     [% ELSE %]
810                                         <tr>
811                                     [% END %]
812                                         <td>
813                                             [% UNLESS ( biblioloo.warn ) %]
814                                                     <input class="multi_hold_item_checkbox" type="checkbox" checked="checked" title="[% biblioloo.biblionumber | html %]"/>
815                                                 </td>
816                                             [% END %]
817                                         <td>
818                                             <ul>
819                                                 <li>
820                                                     <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">[% biblioloo.title | html %]</a>
821                                                 </li>
822                                                 [% IF ( biblioloo.publicationyear ) %]
823                                                     <li>
824                                                         <span class="label">Publication year:</span> [% biblioloo.publicationyear | html %]
825                                                     </li>
826                                                 [% END %]
827                                             </ul>
828                                             [% IF ( biblioloo.warn ) %]
829                                                 <span class="not_holdable" title="[% biblioloo.biblionumber | html %]"></span>
830                                             [% END %]
831                                         </td>
832                                         [% UNLESS ( item_level_itypes ) %]
833                                             <td>
834                                                 <img src="[% biblioloo.imageurl | html %]" alt="[% biblioloo.itypename | html %]" title="[% biblioloo.itypename | html %]" />
835                                             </td>
836                                         [% END %]
837                                         <td>[% biblioloo.rank | html %]</td>
838                                         <td>
839                                             [% IF ( biblioloo.checked_previously ) %]
840                                                 <span>Patron has previously checked out this title</span><br/>
841                                             [% END %]
842                                             [% IF ( biblioloo.alreadyres ) %]
843                                                 <ul>
844                                             [% ELSE %]
845                                                 [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
846                                                     <ul>
847                                                 [% END %]
848                                             [% END %]
849
850                                             [% IF ( biblioloo.alreadyres ) %]
851                                                 <li>
852                                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>
853                                                     <strong>already has a hold</strong> on this item
854                                                 </li>
855                                             [% END %]
856                                             [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
857                                                 <li> <strong>No items are available</strong> to be placed on hold</li>
858                                             [% END %]
859
860                                             [% IF ( biblioloo.alreadyres ) %]
861                                                 </ul>
862                                             [% ELSE %]
863                                                 [% IF ( biblioloo.none_avail || biblioloo.noitems ) %]
864                                                     </ul>
865                                                 [% END %]
866                                             [% END %]
867                                         </td>
868                                         <td>
869                                             [% UNLESS ( biblioloo.none_avail || biblioloo.noitems ) %]
870                                                 <select name="pickup_[% biblioloo.biblionumber | html %]"
871                                                         class="multi_pickup_select"
872                                                         data-biblio-id="[% biblioloo.biblionumber | html %]"
873                                                         data-patron-id="[% patron.borrowernumber | html %]"
874                                                         data-pickup-locations='[% biblioloo.pickup_locations_codes.json | $raw %]'>
875                                                     <option value=""></option>
876                                                     [% FOREACH pickup_location IN biblioloo.pickup_locations %]
877                                                         <option value="[% pickup_location.branchcode | html %]">[% pickup_location.branchname | html %]</option>
878                                                     [% END %]
879                                                 </select>
880                                             [% END %]
881                                         </td>
882                                     </tr>
883                                 [% END # /FOREACH biblioloo %]
884                             </table> <!-- /#requesttitles -->
885
886                         [% END # /UNLESS multi_hold %]
887
888                         <fieldset class="action">
889                             [% IF ( patron AND patron.borrowernumber ) %]
890                                 [% IF ( override_required ) %]
891                                     <button type="submit" class="btn btn-default warning"><i class="fa fa-exclamation-triangle "></i> Place holds</button>
892                                 [% ELSIF ( none_available ) %]
893                                     <button class="btn btn-default" type="submit">Place holds</button>
894                                 [% ELSE %]
895                                     [% IF ( multi_hold ) %]
896                                         <button type="submit" class="btn btn-default" id="multi_hold_submit">Place holds</button>
897                                     [% ELSE %]
898                                         <button type="submit" class="btn btn-default">Place hold</button>
899                                     [% END %]
900                                 [% END %]
901                             [% END # /IF patron %]
902                         </fieldset> <!-- /.action -->
903                     </form> <!-- /#hold-request-form -->
904                 </fieldset> <!-- /.rows -->
905             [% END %]
906
907             [% UNLESS ( patron ) %]
908                 [% UNLESS borrowers %]
909                     [% SET hold_count = Biblio.HoldsCount( biblio.biblionumber ) | html %]
910                     [% IF hold_count %]
911                         <label for ="always_show_holds">Always show holds</label>
912                         [% IF always_show_holds == 'DONT' %]
913                             <input type="checkbox" name="always_show_holds" id="always_show_holds" value="DO">
914                             [% UNLESS reserveloop %]
915                                 <a class="btn btn-default" value="Show holds" id="show_holds_now" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblio.biblionumber | uri %]&show_holds_now=1">Show holds ([% hold_count | html %])</a>
916                             [% END %]
917                         [% ELSE %]
918                             <input type="checkbox" name="always_show_holds" value="DO" id="always_show_holds" checked="checked">
919                         [% END %]
920                     [% END %]
921                 [% END %]
922                 [% IF ( reserveloop ) %]
923                     <form id="existing_holds" name="T[% time | html %]" action="modrequest.pl" method="post" style="display:block">
924                         [% IF ( multi_hold ) %]
925                             <input type = "hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
926                         [% END %]
927
928                         [% IF enqueued %]
929                             <div class="dialog message">
930                                 <p>The job has been enqueued! It will be processed as soon as possible.</p>
931                                 <p><a href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job_id | uri %]" title="View detail of the enqueued job">View detail of the enqueued job</a></p>
932                             </div>
933                         [% END %]
934
935                         <h2>Existing holds</h2>
936                         <div id="toolbar" class="btn-toolbar">
937                             <input type="submit" name="submit" value="Update hold(s)" /> <button class="cancel_selected_holds" data-bulk="true"></button>
938                         <fieldset id="cancellation-reason-fieldset" class="action">
939                             [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
940                             [% IF hold_cancellation %]
941                                 <label for="cancellation-reason">Cancellation reason: </label>
942                                 <select class="cancellation-reason" name="cancellation-reason" id="cancellation-reason">
943                                     <option value="">No reason given</option>
944                                     [% FOREACH reason IN hold_cancellation %]
945                                         <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
946                                     [% END %]
947                                 </select>
948                             [% END %]
949                         </fieldset>
950                         </div>
951
952                         [% FOREACH biblioloo IN biblioloop %]
953                             [% IF ( biblioloo.reserveloop ) %]
954                                 <div class="hold_title" id="hold_title_[% biblioloo.biblionumber | html %]">
955                                     [% IF ( multi_hold ) %]
956                                         <h3>
957                                             <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">
958                                                 [% biblioloo.title | html %]
959                                             </a> <span class="number_box"><span>[% biblioloo.reserveloop.size | html %] [% tn('Hold', 'Holds', biblioloo.reserveloop.size) | $raw %]</span></span>
960                                         </h3>
961                                     [% END %]
962
963                                     [% IF Koha.Preference('HoldsSplitQueue') == 'branch' %]
964
965                                         [% SET branchcodes = [] %]
966
967                                         [% FOREACH h IN biblioloo.reserveloop %]
968                                             [% branchcodes.push( h.branchcode ) %]
969                                         [% END %]
970                                         [% branchcodes = branchcodes.unique %]
971                                         [% IF ( branchcodes.empty ) %]
972                                             <div class="note">
973                                                 There are no holds on this title.
974                                             </div>
975                                         [% ELSE %]
976
977                                             [% FOREACH b IN branchcodes.sort %]
978                                                 [% SET holds_by_branch = [] %]
979                                                 [% FOREACH h IN biblioloo.reserveloop %]
980                                                     [% IF h.branchcode == b %]
981                                                         [% holds_by_branch.push( h ) %]
982                                                     [% END %]
983                                                 [% END %]
984                                                 <div class="holds_by_library">
985                                                     <h4>[% Branches.GetName( b ) | html %]</h4>
986
987                                                     [% INCLUDE holds_table.inc holds=holds_by_branch %]
988                                                 </div>
989                                             [% END # /FOREACh b %]
990                                         [% END # /IF ( branchcodes.empty ) %]
991
992                                     [% ELSIF Koha.Preference('HoldsSplitQueue') == 'itemtype' %]
993
994                                         [% SET itemtypes = [] %]
995
996                                         [% FOREACH h IN biblioloo.reserveloop %]
997                                             [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
998                                             [% itemtypes.push( hold_itemtype ) %]
999                                         [% END %]
1000                                         [% itemtypes = itemtypes.unique %]
1001                                         [% IF ( itemtypes.empty ) %]
1002                                             <div class="note">
1003                                                 There are no holds on this title.
1004                                             </div>
1005                                         [% ELSE %]
1006
1007                                             [% FOREACH i IN itemtypes.sort %]
1008                                                 [% SET holds_by_itemtype = [] %]
1009                                                 [% FOREACH h IN biblioloo.reserveloop %]
1010                                                     [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
1011                                                     [% IF hold_itemtype == i %]
1012                                                         [% holds_by_itemtype.push( h ) %]
1013                                                     [% END %]
1014                                                 [% END %]
1015
1016                                                 <div class="holds_by_itemtype">
1017                                                     [% IF i %]
1018                                                         <h4>[% ItemTypes.GetDescription( i ) | html %]</h4>
1019                                                     [% ELSE %]
1020                                                         <h4>Any item type</h4>
1021                                                     [% END %]
1022                                                     [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
1023                                                 </div>
1024                                             [% END # /FOREACH i %]
1025                                         [% END # /IF ( itemtypes.empty ) %]
1026
1027                                     [% ELSIF Koha.Preference('HoldsSplitQueue') == 'branch_itemtype' %]
1028                                         [% SET branchcodes = [] %]
1029
1030                                         [% FOREACH h IN biblioloo.reserveloop %]
1031                                             [% branchcodes.push( h.branchcode ) %]
1032                                         [% END %]
1033                                         [% branchcodes = branchcodes.unique %]
1034                                         [% IF ( branchcodes.empty ) %]
1035                                             <div class="note">
1036                                                 There are no holds on this title.
1037                                             </div>
1038                                         [% ELSE %]
1039
1040                                             [% FOREACH b IN branchcodes.sort %]
1041                                                 <div class="holds_by_library">
1042                                                     <h4 class="library_holds">[% Branches.GetName( b ) | html %]</h4>
1043                                                     [% SET holds_by_branch = [] %]
1044                                                     [% FOREACH h IN biblioloo.reserveloop %]
1045                                                         [% IF h.branchcode == b %]
1046                                                             [% holds_by_branch.push( h ) %]
1047                                                         [% END %]
1048                                                     [% END %]
1049
1050                                                     [% SET itemtypes = [] %]
1051                                                     [% FOREACH h IN holds_by_branch %]
1052                                                         [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
1053                                                         [% itemtypes.push( hold_itemtype ) %]
1054                                                     [% END %]
1055                                                     [% itemtypes = itemtypes.unique %]
1056
1057                                                     [% FOREACH i IN itemtypes.sort %]
1058                                                         <div class="holds_by_itemtype">
1059                                                             <h5 class="itemtype_holds">
1060                                                                 [% IF i %]
1061                                                                     [% ItemTypes.GetDescription( i ) | html %]
1062                                                                 [% ELSE %]
1063                                                                     Any item type
1064                                                                 [% END %]
1065                                                             </h5>
1066
1067                                                             [% SET holds_by_itemtype = [] %]
1068                                                             [% FOREACH h IN holds_by_branch %]
1069                                                                 [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
1070                                                                 [% IF hold_itemtype == i %]
1071                                                                     [% holds_by_itemtype.push( h ) %]
1072                                                                 [% END %]
1073                                                             [% END %]
1074                                                             [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
1075                                                         </div> <!-- /.holds_by_itemtype -->
1076                                                     [% END %]
1077                                                 </div> <!-- /.holds_by_library -->
1078                                             [% END # /FOREACH b %]
1079                                         [% END # /IF ( branchcodes.empty ) %]
1080
1081                                     [% ELSE %]
1082
1083                                         [% IF ( biblioloo.reserveloop.size ) %]
1084                                             [% INCLUDE holds_table.inc holds=biblioloo.reserveloop %]
1085                                         [% ELSE %]
1086                                             <div class="note">
1087                                                 There are no holds on this title.
1088                                             </div>
1089                                         [% END %]
1090
1091                                     [% END # /IF HoldsSplitQueue %]
1092                                 </div> <!-- /hold_title -->
1093                             [% END # /IF biblioloo.reserveloop %]
1094                         [% END # FOREACH biblioloo %]
1095                     </form> <!-- /#existing_holds -->
1096                 [% END # IF reserveloop %]
1097             [% END # UNLESS patron %]
1098
1099         </main>
1100
1101         [% IF ( multi_hold || nobiblio ) # No sidebar menu when placing multiple holds or biblio not found %]
1102             </div> <!-- /.col-md-10.col-md-offset-1 -->
1103         [% ELSE %]
1104             </div> <!-- /.col-sm-10.col-sm-push-2 -->
1105                 <div class="col-sm-2 col-sm-pull-10">
1106                     <aside>
1107                         [% INCLUDE 'biblio-view-menu.inc' %]
1108                     </aside>
1109                 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1110         [% END %]
1111     </div> <!-- /.row -->
1112
1113     <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
1114         <div class="modal-dialog" role="document">
1115             <div class="modal-content">
1116                 <div class="modal-header">
1117                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1118                     <h3>Confirm deletion</h3>
1119                 </div>
1120
1121                 <div class="modal-body">
1122                     <p>Are you sure you want to cancel this hold?</p>
1123
1124                     <fieldset class="action">
1125                         [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
1126                         [% IF hold_cancellation %]
1127                             <label for="cancellation-reason">Cancellation reason: </label>
1128                             <select class="cancellation-reason" name="modal-cancellation-reason" id="modal-cancellation-reason">
1129                                 <option value="">No reason given</option>
1130                                 [% FOREACH reason IN hold_cancellation %]
1131                                     <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
1132                                 [% END %]
1133                             </select>
1134                         [% END %]
1135                     </fieldset>
1136                 </div>
1137
1138                 <div class="modal-footer">
1139                     <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger">Confirm cancellation</button>
1140                     <a href="#" data-dismiss="modal">Cancel</a>
1141                 </div>
1142             </div>
1143         </div>
1144     </div>
1145
1146 [% MACRO jsinclude BLOCK %]
1147     [% INCLUDE 'datatables.inc' %]
1148     [% INCLUDE 'columns_settings.inc' %]
1149     [% Asset.js("lib/hc-sticky.js") | $raw %]
1150     [% Asset.js("js/circ-patron-search-results.js") | $raw %]
1151     [% INCLUDE 'select2.inc' %]
1152     [% Asset.js("js/holds.js") | $raw%]
1153     [% INCLUDE 'calendar.inc' %]
1154     <script>
1155         var Sticky;
1156         var biblionumber = "[% biblionumber | $raw %]";
1157         var borrowernumber = "[% patron.borrowernumber | $raw %]";
1158         var patron_homebranch = "[% To.json( Branches.GetName( patron.branchcode ) ) | $raw %]";
1159         var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
1160         [% itemloo.itemnumber | html %]: {
1161             homebranch: "[% To.json( Branches.GetName( itemloo.homebranch ) ) | $raw %]",
1162             holdallowed: "[% itemloo.holdallowed | html %]"
1163             },
1164             [% END %][% END %][% END %]
1165         };
1166         var ERROR_MAP = {
1167             damaged: _("Item damaged"),
1168             ageRestricted: _("Age restricted"),
1169             tooManyHoldsForThisRecord: _("Exceeded max holds per record"),
1170             tooManyReservesToday: _("Daily hold limit reached for patron"),
1171             tooManyReserves: _("Too many holds"),
1172             notReservable: _("Not holdable"),
1173             noReservesAllowed: _("No reserves allowed"),
1174             cannotReserveFromOtherBranches: _("Patron is from different library"),
1175             itemAlreadyOnHold: _("Patron already has hold for this item"),
1176             cannotBeTransferred: _("Cannot be transferred to pickup library"),
1177             pickupNotInHoldGroup: _("Only pickup locations within the same hold group are allowed")
1178         }
1179
1180         var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
1181         columns_settings_borrowers_table = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
1182         $.fn.select2.defaults.set("width", "100%" );
1183         $.fn.select2.defaults.set("dropdownAutoWidth", true );
1184
1185         $(document).ready(function() {
1186             $('#cancellation-reason-fieldset').hide();
1187             $('.rank-request').on('change', function() {
1188                 if ( $(".rank-request option:selected[value='del']").length ) {
1189                     $('#cancellation-reason-fieldset').show();
1190                 } else {
1191                     $('#cancellation-reason-fieldset').hide();
1192                 }
1193             });
1194
1195             [% SET active = clubs ? 1 : 0 %]
1196             $('#circ_holds_select').tabs({
1197                 active: [% active | $raw %],
1198                 activate: function(){
1199                     $(this).find("input.focus").focus();
1200                 },
1201                 create: function(){
1202                     $(this).find("input.focus").focus();
1203                 }
1204             });
1205             function ToggleHoldsToPlace() {
1206                 if ( $("#requestany").prop('checked') ) {
1207                     $("#holds_to_place_count").prop('disabled', false);
1208                 } else {
1209                     $("#holds_to_place_count").prop('disabled', true);
1210                 }
1211             }
1212             ToggleHoldsToPlace();
1213             $("#requestany").on('change', function(){
1214                 ToggleHoldsToPlace();
1215             });
1216
1217             [% IF Koha.Preference('UseBranchTransferLimits') %]
1218                 $("#pickup").on('change', function(){
1219                     var pickup = $("#pickup").val();
1220                     var url = "?pickup=" + pickup;
1221                     url += "&borrowernumber=" + borrowernumber;
1222                     url += "&biblionumber=" + biblionumber;
1223                     window.location.replace(url);
1224                 });
1225             [% END %]
1226
1227             var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
1228                 'bPaginate': false,
1229                 "sDom": '<"top pager"ilf>t',
1230             }));
1231
1232             //Override fieldset styling for dataTables search box
1233             $("div.top.pager").css("margin-left","1em");
1234             $(".dataTables_filter label").css({
1235                 "width":"auto",
1236                 "margin-right":"0em"
1237             });
1238
1239             $("#club-request-form").on("submit", function() {
1240                 let $t = $(this);
1241                 $('.clubalert, .holdalert').addClass('hide');
1242                 let biblionumbers = [biblionumber];
1243                 let biblionumbers_text;
1244                 const data = {
1245                     pickup_library_id: $('select[name="pickup"]').val()
1246                 };
1247                 if($('input[name="checkitem"]:checked').length)
1248                     data.item_id = $('input[name="checkitem"]:checked').val();
1249                 if($('input[name="borrowernumber"]').length)
1250                     data.patron_id = $('input[name="borrowernumber"]').val();
1251                 if($('textarea[name="notes"]').length)
1252                     data.notes = $('textarea[name="notes"]').val()||null;
1253                 if($('input[name="itemtype"]').length) {
1254                     data.item_type = $('input[name="itemtype"]').val()||null;
1255                 }
1256                 if($('input[name="default_patron_home"]:checked').length) {
1257                     data.default_patron_home = 1;
1258                 }
1259                 if($('input[name="biblionumbers"]').length) {
1260                     biblionumbers_text = $('input[name="biblionumbers"]').val();
1261                     biblionumbers = biblionumbers_text.replace(/\/$/, '').split('/')
1262                 }
1263
1264                 const count = $('input[name="holds_to_place_count"]').length?$('input[name="holds_to_place_count"]').val():1;
1265                 biblionumbers.forEach(function(biblionumber) {
1266                     data.biblio_id = biblionumber;
1267                     let options = {
1268                         url: $t.attr('action'),
1269                         method: $t.attr('method').toUpperCase(),
1270                         contentType: 'application/json',
1271                         data: JSON.stringify(data)
1272                     };
1273                     for(let i = 0; i < count; i++) {
1274                         $.ajax(options)
1275                         .then(function(result) {
1276                             let url = 'request.pl?biblionumber='+biblionumber;
1277                             if(biblionumbers_text) {
1278                                 url = 'request.pl?biblionumbers='+biblionumbers_text;
1279                             }
1280                             document.location = url;
1281                         })
1282                         .fail(function(err) {
1283                             var message = err.responseJSON.error;
1284                             var match = err.responseJSON.error.match(/Reason: (\w+)\s*$/);
1285                             if(match && ERROR_MAP[match[1]]) {
1286                                 message = '<div><strong>'+_("Cannot place hold")+'</strong></div><div>'+ERROR_MAP[match[1]]+'</div>'
1287                             }
1288                             $('.clubalert, .holdalert').removeClass('hide').html(message);
1289                         });
1290                     }
1291                 });
1292
1293                 return false;
1294             });
1295
1296             [% UNLESS ( multi_hold ) %]
1297                 $("#hold-request-form").on("submit", function(){
1298                     return check($(this));
1299                 });
1300             [% ELSE %]
1301                 $("#hold-request-form").on("submit", function(){
1302                     return checkMultiHold();
1303                 });
1304             [% END %]
1305
1306             $(".pickup_location_dropdown").each( function () {
1307                 $(this).pickup_locations_dropdown();
1308             });
1309
1310             $("#pickup_multi").select2({
1311                 width: '30%',
1312                 allowClear: true
1313             });
1314
1315             $('.multi_pickup_select').select2({
1316                 width: '100%',
1317                 allowClear: true
1318             });
1319
1320             $("#pickup_multi").on("change", function() {
1321                 var selection = $(this).val();
1322                 if ( selection != '' ) {
1323                     $(".multi_pickup_select").each(function() {
1324                         var valid_pickup_locations = $(this).data('pickup-locations');
1325                         if ( valid_pickup_locations.includes(selection) ) {
1326                             $(this).val(selection);
1327                             $(this).trigger("change");
1328                         }
1329                     });
1330                 }
1331             });
1332
1333             $("#pickup").each( function () {
1334                 $(this).pickup_locations_dropdown();
1335             });
1336
1337             $(".pickup_locations").each(function () {
1338                 $(this).pickup_locations_dropdown();
1339             });
1340         });
1341
1342         function check( table ) {
1343
1344             var msg = "";
1345
1346             if ( $("#requestany").attr("checked") !== "checked" ) {
1347                 // requestany not selected, go through the item-specific cases
1348                 if ( $('input[type="radio"]:checked').length > 0 ) {
1349                     // got item-specific hold requests in the form!
1350                     // verify they have a pickup location selected
1351
1352                     if (table.find('input[type="radio"]:checked')
1353                                 .closest('tr')
1354                                 .find(".pickup_locations").val() === null) {
1355
1356                         msg = _("- Please select a pickup location for the item" + "\n")
1357                     }
1358                 }
1359                 else {
1360                     msg = (_("- Please select an item to place a hold") + "\n");
1361                 }
1362             }
1363
1364             if (msg == "") {
1365                 $('#hold-request-form').preventDoubleFormSubmit();
1366                 return(true);
1367             } else {
1368                 alert(msg);
1369                 return(false);
1370             }
1371         }
1372
1373         function checkMultiHold() {
1374
1375             var biblionumbers = "";
1376             var selected_bibs = $(".multi_hold_item_checkbox:checked");
1377             if ( selected_bibs.length > 0 ) {
1378                 // there are biblios selected in the form!
1379                 // verify they have a pickup location selected
1380
1381                 var pickup_not_set = 0;
1382                 selected_bibs.each(function() {
1383                     if ( $(this).closest('tr').find(".multi_pickup_select").val() === "" ) {
1384                         pickup_not_set++;
1385                     }
1386                     else {
1387                         var bibnum = $(this).attr("title");
1388                         biblionumbers += bibnum + "/";
1389                     }
1390                 });
1391                 if ( pickup_not_set > 0 ) {
1392                     alert( _("Please make sure all selected titles have a pickup location set" + "\n") );
1393                     return false;
1394                 }
1395             }
1396             else {
1397                 alert( _("Please select at least one title" + "\n") );
1398                 return false;
1399             }
1400
1401             var badSpans = $(".not_holdable");
1402             var badBibs = "";
1403             $(badSpans).each(function() {
1404                 var bibnum = $(this).attr("title");
1405                 badBibs += bibnum + "/";
1406             });
1407
1408             $("#multi_hold_bibs").val(biblionumbers);
1409             $("#bad_bibs").val(badBibs);
1410
1411             $('#hold-request-form').preventDoubleFormSubmit();
1412
1413             return true;
1414         }
1415
1416          $(document).ready(function() {
1417             $("#always_show_holds").change(function(){
1418                 if( $(this).prop('checked') ){
1419                     document.cookie = 'always_show_holds=DO';
1420                 } else {
1421                     document.cookie = 'always_show_holds=DONT';
1422                 }
1423             });
1424             $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
1425                 var itemnumber = this.value;
1426                 var msg = '';
1427
1428                 switch (override_items[itemnumber].holdallowed) {
1429                     case "not_allowed": msg = _("This item normally cannot be put on hold."); break;
1430                     case "from_home_library": msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
1431                 }
1432
1433                 msg += "\n\n" + _("Place hold on this item?");
1434
1435                 return confirm(msg);
1436             });
1437             $("button.warning").click(function() {
1438                 return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
1439             });
1440             $("#requestany").click(function() {
1441                 if(this.checked){
1442                     $("input[name=checkitem]").each(function() {
1443                         $(this).prop("checked", false);
1444                     });
1445                 }
1446             });
1447             $("input[name=checkitem]").click(function() {
1448                 onechecked = 0;
1449                 $("input[name=checkitem]").each(function() {
1450                     if(this.checked){
1451                         onechecked = 1;
1452                     }
1453                 });
1454                 if(onechecked == 1){
1455                     $("#requestany").prop("checked", false);
1456                     $("#holds_to_place_count").prop('disabled', true);
1457                 } else {
1458                     $("#requestany").prop("checked",true);
1459                     $("#holds_to_place_count").prop('disabled', false);
1460                 }
1461             });
1462             var prev_rank_request;
1463             $("select[name=rank-request]").on("focus", function() {
1464                 prev_rank_request = $(this).val();
1465                 var row = $(this).parents("tr:first");
1466             }).change(function() {
1467                 var row = $(this).parents("tr:first");
1468                 var value = parseInt($(this).val());
1469                 var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found
1470                 if( !isNaN(value) ) {  //If moved to 'del'
1471                     var after = row.parent().find("tr:nth-child("+(value+1+found_holds )+")"); //Go to the row 1 after the new value (and skip found holds)
1472                     if (prev_rank_request > value) {
1473                         row.insertBefore(after);
1474                     } else {
1475                         row.insertAfter(after);
1476                     }
1477                 }
1478
1479                 var next_priority = 1;
1480                 $("select[name=rank-request]").each(function () {
1481                     if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds
1482                     $(this).val(next_priority);
1483                     next_priority++;
1484                 });
1485             });
1486
1487             $(".clear-date").on("click",function(e){
1488                 e.preventDefault();
1489                 var fieldID = this.id.replace("clear-date-","");
1490                 $("#" + fieldID).val("");
1491             });
1492
1493             // Confirm cancellation of hold
1494             let cancel_link;
1495             $(".cancel-hold").on("click",function(e) {
1496                 e.preventDefault;
1497                 cancel_link = $(this);
1498                 $('#cancelModal').modal();
1499                 return false;
1500             });
1501             $("#cancelModalConfirmBtn").on("click",function(e) {
1502                 let link;
1503                 if(cancel_link.data('bulk')) {
1504                     [% IF biblionumbers %]
1505                         link = `request.pl?biblionumbers=[% biblionumbers | url %]&amp;action=cancelBulk&amp;ids=${$('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')).join(',')}`;
1506                     [% ELSE %]
1507                         link = `request.pl?biblionumber=[% biblionumber | url %]&amp;action=cancelBulk&amp;ids=${$('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')).join(',')}`;
1508                     [% END %]
1509                 } else {
1510                     let borrowernumber = cancel_link.data('borrowernumber');
1511                     let biblionumber = cancel_link.data('biblionumber');
1512                     let reserve_id = cancel_link.data('id');
1513                     link = `request.pl?action=cancel&amp;borrowernumber=${ borrowernumber }&amp;biblionumber=${ biblionumber }&amp;reserve_id=${ reserve_id }`;
1514                 }
1515                 let reason = $("#modal-cancellation-reason").val();
1516                 if ( reason ) {
1517                     link += "&amp;cancellation-reason=" + reason
1518                 }
1519                 window.location.href = link;
1520                 return false;
1521             });
1522
1523             [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) %]
1524                 [% IF ( PatronAutoComplete ) %]
1525                 $( "#patron" ).autocomplete({
1526                     source: "/cgi-bin/koha/circ/ysearch.pl",
1527                     minLength: 3,
1528                     select: function( event, ui ) {
1529                         $( "#patron" ).val( ui.item.cardnumber );
1530                         $( "#holds_patronsearch" ).submit();
1531                         return false;
1532                     }
1533                 })
1534                 .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
1535                     return $( "<li></li>" )
1536                     .data( "ui-autocomplete-item", item )
1537                     .append(
1538                         "<a>"
1539                             + ( item.surname ? item.surname.escapeHtml() : "" )
1540                             + ", "
1541                             + ( item.firstname ? item.firstname.escapeHtml() : "" )
1542                             + " (" + ( item.cardnumber ? item.cardnumber.escapeHtml() : "" ) + ")"
1543                             + " "
1544                             + "<small>"
1545                                 + ( item.address ? item.address.escapeHtml() : "" )
1546                                 + " "
1547                                 + ( item.city ? item.city.escapeHtml() : "" )
1548                                 + " "
1549                                 + ( item.zipcode ? item.zipcode.escapeHtml() : "" )
1550                                 + " "
1551                                 + ( item.country ? item.country.escapeHtml() : "" )
1552                             + "</small>"
1553                         + "</a>" )
1554                     .appendTo( ul );
1555                 };
1556                 [% END %]
1557             [% END %]
1558             Sticky = $("#toolbar");
1559             Sticky.hcSticky({
1560                 stickTo: "#existing_holds",
1561                 stickyClass: "floating"
1562             });
1563
1564             if(!localStorage.selectedHolds  || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) {
1565                 localStorage.selectedHolds = [];
1566             }
1567
1568             $('.holds_table .select_hold').each(function() {
1569                 if(localStorage.selectedHolds.includes($(this).data('id'))) {
1570                     $(this).prop('checked', true);
1571                 }
1572             });
1573
1574             $('.holds_table .select_hold_all').each(function() {
1575                 var table = $(this).parents('.holds_table');
1576                 var count = $('.select_hold:not(:checked)', table).length;
1577                 $('.select_hold_all', table).prop('checked', !count);
1578             });
1579
1580             $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1581
1582             $('.holds_table .select_hold_all').click(function() {
1583                 var table = $(this).parents('.holds_table');
1584                 var count = $('.select_hold:checked', table).length;
1585                 $('.select_hold', table).prop('checked', !count);
1586                 $(this).prop('checked', !count);
1587                 $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1588                 localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
1589             });
1590
1591             $('.holds_table .select_hold').click(function() {
1592                 var table = $(this).parents('.holds_table');
1593                 var count = $('.select_hold:not(:checked)', table).length;
1594                 $('.select_hold_all', table).prop('checked', !count);
1595                 $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1596                 localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
1597             });
1598
1599             $('.cancel_selected_holds').click(function(e) {
1600                 e.preventDefault();
1601                 if($('.holds_table .select_hold:checked').length) {
1602                     cancel_link = $(this);
1603                     delete localStorage.selectedHolds;
1604                     $('#cancelModal').modal();
1605                 }
1606                 return false;
1607             });
1608
1609         });
1610     </script>
1611 [% END %]
1612
1613 [% INCLUDE 'intranet-bottom.inc' %]