Bug 29058: Add 'Always show holds' checkbox to request.pl
[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 %]</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                 [% SET hold_count = Biblio.HoldsCount( biblio.biblionumber ) | html %]
909                 [% IF hold_count %]
910                     <label for ="always_show_holds">Always show holds</label>
911                     [% IF always_show_holds == 'DONT' %]
912                         <input type="checkbox" name="always_show_holds" id="always_show_holds" value="DO">
913                         <a class="btn btn-default" value="Show holds" id="show_holds_now" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblio.biblionumber %]&show_holds_now=1">Show holds ([% hold_count %])</a>
914                     [% ELSE %]
915                         <input type="checkbox" name="always_show_holds" value="DO" id="always_show_holds" checked="checked">
916                     [% END %]
917                 [% END %]
918                 [% IF ( reserveloop ) %]
919                     <form id="existing_holds" name="T[% time | html %]" action="modrequest.pl" method="post" style="display:block">
920                         [% IF ( multi_hold ) %]
921                             <input type = "hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
922                         [% END %]
923
924                         [% IF enqueued %]
925                             <div class="dialog message">
926                                 <p>The job has been enqueued! It will be processed as soon as possible.</p>
927                                 <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>
928                             </div>
929                         [% END %]
930
931                         <h2>Existing holds</h2>
932                         <div id="toolbar" class="btn-toolbar">
933                             <input type="submit" name="submit" value="Update hold(s)" /> <button class="cancel_selected_holds" data-bulk="true"></button>
934                         <fieldset id="cancellation-reason-fieldset" class="action">
935                             [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
936                             [% IF hold_cancellation %]
937                                 <label for="cancellation-reason">Cancellation reason: </label>
938                                 <select class="cancellation-reason" name="cancellation-reason" id="cancellation-reason">
939                                     <option value="">No reason given</option>
940                                     [% FOREACH reason IN hold_cancellation %]
941                                         <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
942                                     [% END %]
943                                 </select>
944                             [% END %]
945                         </fieldset>
946                         </div>
947
948                         [% FOREACH biblioloo IN biblioloop %]
949                             [% IF ( biblioloo.reserveloop ) %]
950                                 <div class="hold_title" id="hold_title_[% biblioloo.biblionumber | html %]">
951                                     [% IF ( multi_hold ) %]
952                                         <h3>
953                                             <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">
954                                                 [% biblioloo.title | html %]
955                                             </a> <span class="number_box"><span>[% biblioloo.reserveloop.size | html %] [% tn('Hold', 'Holds', biblioloo.reserveloop.size) | $raw %]</span></span>
956                                         </h3>
957                                     [% END %]
958
959                                     [% IF Koha.Preference('HoldsSplitQueue') == 'branch' %]
960
961                                         [% SET branchcodes = [] %]
962
963                                         [% FOREACH h IN biblioloo.reserveloop %]
964                                             [% branchcodes.push( h.branchcode ) %]
965                                         [% END %]
966                                         [% branchcodes = branchcodes.unique %]
967                                         [% IF ( branchcodes.empty ) %]
968                                             <div class="note">
969                                                 There are no holds on this title.
970                                             </div>
971                                         [% ELSE %]
972
973                                             [% FOREACH b IN branchcodes.sort %]
974                                                 [% SET holds_by_branch = [] %]
975                                                 [% FOREACH h IN biblioloo.reserveloop %]
976                                                     [% IF h.branchcode == b %]
977                                                         [% holds_by_branch.push( h ) %]
978                                                     [% END %]
979                                                 [% END %]
980                                                 <div class="holds_by_library">
981                                                     <h4>[% Branches.GetName( b ) | html %]</h4>
982
983                                                     [% INCLUDE holds_table.inc holds=holds_by_branch %]
984                                                 </div>
985                                             [% END # /FOREACh b %]
986                                         [% END # /IF ( branchcodes.empty ) %]
987
988                                     [% ELSIF Koha.Preference('HoldsSplitQueue') == 'itemtype' %]
989
990                                         [% SET itemtypes = [] %]
991
992                                         [% FOREACH h IN biblioloo.reserveloop %]
993                                             [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
994                                             [% itemtypes.push( hold_itemtype ) %]
995                                         [% END %]
996                                         [% itemtypes = itemtypes.unique %]
997                                         [% IF ( itemtypes.empty ) %]
998                                             <div class="note">
999                                                 There are no holds on this title.
1000                                             </div>
1001                                         [% ELSE %]
1002
1003                                             [% FOREACH i IN itemtypes.sort %]
1004                                                 [% SET holds_by_itemtype = [] %]
1005                                                 [% FOREACH h IN biblioloo.reserveloop %]
1006                                                     [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
1007                                                     [% IF hold_itemtype == i %]
1008                                                         [% holds_by_itemtype.push( h ) %]
1009                                                     [% END %]
1010                                                 [% END %]
1011
1012                                                 <div class="holds_by_itemtype">
1013                                                     [% IF i %]
1014                                                         <h4>[% ItemTypes.GetDescription( i ) | html %]</h4>
1015                                                     [% ELSE %]
1016                                                         <h4>Any item type</h4>
1017                                                     [% END %]
1018                                                     [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
1019                                                 </div>
1020                                             [% END # /FOREACH i %]
1021                                         [% END # /IF ( itemtypes.empty ) %]
1022
1023                                     [% ELSIF Koha.Preference('HoldsSplitQueue') == 'branch_itemtype' %]
1024                                         [% SET branchcodes = [] %]
1025
1026                                         [% FOREACH h IN biblioloo.reserveloop %]
1027                                             [% branchcodes.push( h.branchcode ) %]
1028                                         [% END %]
1029                                         [% branchcodes = branchcodes.unique %]
1030                                         [% IF ( branchcodes.empty ) %]
1031                                             <div class="note">
1032                                                 There are no holds on this title.
1033                                             </div>
1034                                         [% ELSE %]
1035
1036                                             [% FOREACH b IN branchcodes.sort %]
1037                                                 <div class="holds_by_library">
1038                                                     <h4 class="library_holds">[% Branches.GetName( b ) | html %]</h4>
1039                                                     [% SET holds_by_branch = [] %]
1040                                                     [% FOREACH h IN biblioloo.reserveloop %]
1041                                                         [% IF h.branchcode == b %]
1042                                                             [% holds_by_branch.push( h ) %]
1043                                                         [% END %]
1044                                                     [% END %]
1045
1046                                                     [% SET itemtypes = [] %]
1047                                                     [% FOREACH h IN holds_by_branch %]
1048                                                         [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
1049                                                         [% itemtypes.push( hold_itemtype ) %]
1050                                                     [% END %]
1051                                                     [% itemtypes = itemtypes.unique %]
1052
1053                                                     [% FOREACH i IN itemtypes.sort %]
1054                                                         <div class="holds_by_itemtype">
1055                                                             <h5 class="itemtype_holds">
1056                                                                 [% IF i %]
1057                                                                     [% ItemTypes.GetDescription( i ) | html %]
1058                                                                 [% ELSE %]
1059                                                                     Any item type
1060                                                                 [% END %]
1061                                                             </h5>
1062
1063                                                             [% SET holds_by_itemtype = [] %]
1064                                                             [% FOREACH h IN holds_by_branch %]
1065                                                                 [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
1066                                                                 [% IF hold_itemtype == i %]
1067                                                                     [% holds_by_itemtype.push( h ) %]
1068                                                                 [% END %]
1069                                                             [% END %]
1070                                                             [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
1071                                                         </div> <!-- /.holds_by_itemtype -->
1072                                                     [% END %]
1073                                                 </div> <!-- /.holds_by_library -->
1074                                             [% END # /FOREACH b %]
1075                                         [% END # /IF ( branchcodes.empty ) %]
1076
1077                                     [% ELSE %]
1078
1079                                         [% IF ( biblioloo.reserveloop.size ) %]
1080                                             [% INCLUDE holds_table.inc holds=biblioloo.reserveloop %]
1081                                         [% ELSE %]
1082                                             <div class="note">
1083                                                 There are no holds on this title.
1084                                             </div>
1085                                         [% END %]
1086
1087                                     [% END # /IF HoldsSplitQueue %]
1088                                 </div> <!-- /hold_title -->
1089                             [% END # /IF biblioloo.reserveloop %]
1090                         [% END # FOREACH biblioloo %]
1091                     </form> <!-- /#existing_holds -->
1092                 [% END # IF reserveloop %]
1093             [% END # UNLESS patron %]
1094
1095         </main>
1096
1097         [% IF ( multi_hold || nobiblio ) # No sidebar menu when placing multiple holds or biblio not found %]
1098             </div> <!-- /.col-md-10.col-md-offset-1 -->
1099         [% ELSE %]
1100             </div> <!-- /.col-sm-10.col-sm-push-2 -->
1101                 <div class="col-sm-2 col-sm-pull-10">
1102                     <aside>
1103                         [% INCLUDE 'biblio-view-menu.inc' %]
1104                     </aside>
1105                 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
1106         [% END %]
1107     </div> <!-- /.row -->
1108
1109     <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
1110         <div class="modal-dialog" role="document">
1111             <div class="modal-content">
1112                 <div class="modal-header">
1113                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1114                     <h3>Confirm deletion</h3>
1115                 </div>
1116
1117                 <div class="modal-body">
1118                     <p>Are you sure you want to cancel this hold?</p>
1119
1120                     <fieldset class="action">
1121                         [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
1122                         [% IF hold_cancellation %]
1123                             <label for="cancellation-reason">Cancellation reason: </label>
1124                             <select class="cancellation-reason" name="modal-cancellation-reason" id="modal-cancellation-reason">
1125                                 <option value="">No reason given</option>
1126                                 [% FOREACH reason IN hold_cancellation %]
1127                                     <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
1128                                 [% END %]
1129                             </select>
1130                         [% END %]
1131                     </fieldset>
1132                 </div>
1133
1134                 <div class="modal-footer">
1135                     <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger">Confirm cancellation</button>
1136                     <a href="#" data-dismiss="modal">Cancel</a>
1137                 </div>
1138             </div>
1139         </div>
1140     </div>
1141
1142 [% MACRO jsinclude BLOCK %]
1143     [% INCLUDE 'datatables.inc' %]
1144     [% INCLUDE 'columns_settings.inc' %]
1145     [% Asset.js("lib/hc-sticky.js") | $raw %]
1146     [% Asset.js("js/circ-patron-search-results.js") | $raw %]
1147     [% INCLUDE 'select2.inc' %]
1148     [% Asset.js("js/holds.js") | $raw%]
1149     [% INCLUDE 'calendar.inc' %]
1150     <script>
1151         var Sticky;
1152         var biblionumber = "[% biblionumber | $raw %]";
1153         var borrowernumber = "[% patron.borrowernumber | $raw %]";
1154         var patron_homebranch = "[% To.json( Branches.GetName( patron.branchcode ) ) | $raw %]";
1155         var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
1156         [% itemloo.itemnumber | html %]: {
1157             homebranch: "[% To.json( Branches.GetName( itemloo.homebranch ) ) | $raw %]",
1158             holdallowed: "[% itemloo.holdallowed | html %]"
1159             },
1160             [% END %][% END %][% END %]
1161         };
1162         var ERROR_MAP = {
1163             damaged: _("Item damaged"),
1164             ageRestricted: _("Age restricted"),
1165             tooManyHoldsForThisRecord: _("Exceeded max holds per record"),
1166             tooManyReservesToday: _("Daily hold limit reached for patron"),
1167             tooManyReserves: _("Too many holds"),
1168             notReservable: _("Not holdable"),
1169             noReservesAllowed: _("No reserves allowed"),
1170             cannotReserveFromOtherBranches: _("Patron is from different library"),
1171             itemAlreadyOnHold: _("Patron already has hold for this item"),
1172             cannotBeTransferred: _("Cannot be transferred to pickup library"),
1173             pickupNotInHoldGroup: _("Only pickup locations within the same hold group are allowed")
1174         }
1175
1176         var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
1177         columns_settings_borrowers_table = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
1178         $.fn.select2.defaults.set("width", "100%" );
1179         $.fn.select2.defaults.set("dropdownAutoWidth", true );
1180
1181         $(document).ready(function() {
1182             $('#cancellation-reason-fieldset').hide();
1183             $('.rank-request').on('change', function() {
1184                 if ( $(".rank-request option:selected[value='del']").length ) {
1185                     $('#cancellation-reason-fieldset').show();
1186                 } else {
1187                     $('#cancellation-reason-fieldset').hide();
1188                 }
1189             });
1190
1191             [% SET active = clubs ? 1 : 0 %]
1192             $('#circ_holds_select').tabs({
1193                 active: [% active | $raw %],
1194                 activate: function(){
1195                     $(this).find("input.focus").focus();
1196                 },
1197                 create: function(){
1198                     $(this).find("input.focus").focus();
1199                 }
1200             });
1201             function ToggleHoldsToPlace() {
1202                 if ( $("#requestany").prop('checked') ) {
1203                     $("#holds_to_place_count").prop('disabled', false);
1204                 } else {
1205                     $("#holds_to_place_count").prop('disabled', true);
1206                 }
1207             }
1208             ToggleHoldsToPlace();
1209             $("#requestany").on('change', function(){
1210                 ToggleHoldsToPlace();
1211             });
1212
1213             [% IF Koha.Preference('UseBranchTransferLimits') %]
1214                 $("#pickup").on('change', function(){
1215                     var pickup = $("#pickup").val();
1216                     var url = "?pickup=" + pickup;
1217                     url += "&borrowernumber=" + borrowernumber;
1218                     url += "&biblionumber=" + biblionumber;
1219                     window.location.replace(url);
1220                 });
1221             [% END %]
1222
1223             var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
1224                 'bPaginate': false,
1225                 "sDom": '<"top pager"ilf>t',
1226             }));
1227
1228             //Override fieldset styling for dataTables search box
1229             $("div.top.pager").css("margin-left","1em");
1230             $(".dataTables_filter label").css({
1231                 "width":"auto",
1232                 "margin-right":"0em"
1233             });
1234
1235             $("#club-request-form").on("submit", function() {
1236                 let $t = $(this);
1237                 $('.clubalert, .holdalert').addClass('hide');
1238                 let biblionumbers = [biblionumber];
1239                 let biblionumbers_text;
1240                 const data = {
1241                     pickup_library_id: $('select[name="pickup"]').val()
1242                 };
1243                 if($('input[name="checkitem"]:checked').length)
1244                     data.item_id = $('input[name="checkitem"]:checked').val();
1245                 if($('input[name="borrowernumber"]').length)
1246                     data.patron_id = $('input[name="borrowernumber"]').val();
1247                 if($('textarea[name="notes"]').length)
1248                     data.notes = $('textarea[name="notes"]').val()||null;
1249                 if($('input[name="itemtype"]').length) {
1250                     data.item_type = $('input[name="itemtype"]').val()||null;
1251                 }
1252                 if($('input[name="default_patron_home"]:checked').length) {
1253                     data.default_patron_home = 1;
1254                 }
1255                 if($('input[name="biblionumbers"]').length) {
1256                     biblionumbers_text = $('input[name="biblionumbers"]').val();
1257                     biblionumbers = biblionumbers_text.replace(/\/$/, '').split('/')
1258                 }
1259
1260                 const count = $('input[name="holds_to_place_count"]').length?$('input[name="holds_to_place_count"]').val():1;
1261                 biblionumbers.forEach(function(biblionumber) {
1262                     data.biblio_id = biblionumber;
1263                     let options = {
1264                         url: $t.attr('action'),
1265                         method: $t.attr('method').toUpperCase(),
1266                         contentType: 'application/json',
1267                         data: JSON.stringify(data)
1268                     };
1269                     for(let i = 0; i < count; i++) {
1270                         $.ajax(options)
1271                         .then(function(result) {
1272                             let url = 'request.pl?biblionumber='+biblionumber;
1273                             if(biblionumbers_text) {
1274                                 url = 'request.pl?biblionumbers='+biblionumbers_text;
1275                             }
1276                             document.location = url;
1277                         })
1278                         .fail(function(err) {
1279                             var message = err.responseJSON.error;
1280                             var match = err.responseJSON.error.match(/Reason: (\w+)\s*$/);
1281                             if(match && ERROR_MAP[match[1]]) {
1282                                 message = '<div><strong>'+_("Cannot place hold")+'</strong></div><div>'+ERROR_MAP[match[1]]+'</div>'
1283                             }
1284                             $('.clubalert, .holdalert').removeClass('hide').html(message);
1285                         });
1286                     }
1287                 });
1288
1289                 return false;
1290             });
1291
1292             [% UNLESS ( multi_hold ) %]
1293                 $("#hold-request-form").on("submit", function(){
1294                     return check($(this));
1295                 });
1296             [% ELSE %]
1297                 $("#hold-request-form").on("submit", function(){
1298                     return checkMultiHold();
1299                 });
1300             [% END %]
1301
1302             $(".pickup_location_dropdown").each( function () {
1303                 $(this).pickup_locations_dropdown();
1304             });
1305
1306             $("#pickup_multi").select2({
1307                 width: '30%',
1308                 allowClear: true
1309             });
1310
1311             $('.multi_pickup_select').select2({
1312                 width: '100%',
1313                 allowClear: true
1314             });
1315
1316             $("#pickup_multi").on("change", function() {
1317                 var selection = $(this).val();
1318                 if ( selection != '' ) {
1319                     $(".multi_pickup_select").each(function() {
1320                         var valid_pickup_locations = $(this).data('pickup-locations');
1321                         if ( valid_pickup_locations.includes(selection) ) {
1322                             $(this).val(selection);
1323                             $(this).trigger("change");
1324                         }
1325                     });
1326                 }
1327             });
1328
1329             $("#pickup").each( function () {
1330                 $(this).pickup_locations_dropdown();
1331             });
1332
1333             $(".pickup_locations").each(function () {
1334                 $(this).pickup_locations_dropdown();
1335             });
1336         });
1337
1338         function check( table ) {
1339
1340             var msg = "";
1341
1342             if ( $("#requestany").attr("checked") !== "checked" ) {
1343                 // requestany not selected, go through the item-specific cases
1344                 if ( $('input[type="radio"]:checked').length > 0 ) {
1345                     // got item-specific hold requests in the form!
1346                     // verify they have a pickup location selected
1347
1348                     if (table.find('input[type="radio"]:checked')
1349                                 .closest('tr')
1350                                 .find(".pickup_locations").val() === null) {
1351
1352                         msg = _("- Please select a pickup location for the item" + "\n")
1353                     }
1354                 }
1355                 else {
1356                     msg = (_("- Please select an item to place a hold") + "\n");
1357                 }
1358             }
1359
1360             if (msg == "") {
1361                 $('#hold-request-form').preventDoubleFormSubmit();
1362                 return(true);
1363             } else {
1364                 alert(msg);
1365                 return(false);
1366             }
1367         }
1368
1369         function checkMultiHold() {
1370
1371             var biblionumbers = "";
1372             var selected_bibs = $(".multi_hold_item_checkbox:checked");
1373             if ( selected_bibs.length > 0 ) {
1374                 // there are biblios selected in the form!
1375                 // verify they have a pickup location selected
1376
1377                 var pickup_not_set = 0;
1378                 selected_bibs.each(function() {
1379                     if ( $(this).closest('tr').find(".multi_pickup_select").val() === "" ) {
1380                         pickup_not_set++;
1381                     }
1382                     else {
1383                         var bibnum = $(this).attr("title");
1384                         biblionumbers += bibnum + "/";
1385                     }
1386                 });
1387                 if ( pickup_not_set > 0 ) {
1388                     alert( _("Please make sure all selected titles have a pickup location set" + "\n") );
1389                     return false;
1390                 }
1391             }
1392             else {
1393                 alert( _("Please select at least one title" + "\n") );
1394                 return false;
1395             }
1396
1397             var badSpans = $(".not_holdable");
1398             var badBibs = "";
1399             $(badSpans).each(function() {
1400                 var bibnum = $(this).attr("title");
1401                 badBibs += bibnum + "/";
1402             });
1403
1404             $("#multi_hold_bibs").val(biblionumbers);
1405             $("#bad_bibs").val(badBibs);
1406
1407             $('#hold-request-form').preventDoubleFormSubmit();
1408
1409             return true;
1410         }
1411
1412          $(document).ready(function() {
1413             $("#always_show_holds").change(function(){
1414                 if( $(this).prop('checked') ){
1415                     document.cookie = 'always_show_holds=DO';
1416                 } else {
1417                     document.cookie = 'always_show_holds=DONT';
1418                 }
1419             });
1420             $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
1421                 var itemnumber = this.value;
1422                 var msg = '';
1423
1424                 switch (override_items[itemnumber].holdallowed) {
1425                     case "not_allowed": msg = _("This item normally cannot be put on hold."); break;
1426                     case "from_home_library": msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
1427                 }
1428
1429                 msg += "\n\n" + _("Place hold on this item?");
1430
1431                 return confirm(msg);
1432             });
1433             $("button.warning").click(function() {
1434                 return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
1435             });
1436             $("#requestany").click(function() {
1437                 if(this.checked){
1438                     $("input[name=checkitem]").each(function() {
1439                         $(this).prop("checked", false);
1440                     });
1441                 }
1442             });
1443             $("input[name=checkitem]").click(function() {
1444                 onechecked = 0;
1445                 $("input[name=checkitem]").each(function() {
1446                     if(this.checked){
1447                         onechecked = 1;
1448                     }
1449                 });
1450                 if(onechecked == 1){
1451                     $("#requestany").prop("checked", false);
1452                     $("#holds_to_place_count").prop('disabled', true);
1453                 } else {
1454                     $("#requestany").prop("checked",true);
1455                     $("#holds_to_place_count").prop('disabled', false);
1456                 }
1457             });
1458             var prev_rank_request;
1459             $("select[name=rank-request]").on("focus", function() {
1460                 prev_rank_request = $(this).val();
1461                 var row = $(this).parents("tr:first");
1462             }).change(function() {
1463                 var row = $(this).parents("tr:first");
1464                 var value = parseInt($(this).val());
1465                 var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found
1466                 if( !isNaN(value) ) {  //If moved to 'del'
1467                     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)
1468                     if (prev_rank_request > value) {
1469                         row.insertBefore(after);
1470                     } else {
1471                         row.insertAfter(after);
1472                     }
1473                 }
1474
1475                 var next_priority = 1;
1476                 $("select[name=rank-request]").each(function () {
1477                     if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds
1478                     $(this).val(next_priority);
1479                     next_priority++;
1480                 });
1481             });
1482
1483             $(".clear-date").on("click",function(e){
1484                 e.preventDefault();
1485                 var fieldID = this.id.replace("clear-date-","");
1486                 $("#" + fieldID).val("");
1487             });
1488
1489             // Confirm cancellation of hold
1490             let cancel_link;
1491             $(".cancel-hold").on("click",function(e) {
1492                 e.preventDefault;
1493                 cancel_link = $(this);
1494                 $('#cancelModal').modal();
1495                 return false;
1496             });
1497             $("#cancelModalConfirmBtn").on("click",function(e) {
1498                 let link;
1499                 if(cancel_link.data('bulk')) {
1500                     [% IF biblionumbers %]
1501                         link = `request.pl?biblionumbers=[% biblionumbers | url %]&amp;action=cancelBulk&amp;ids=${$('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')).join(',')}`;
1502                     [% ELSE %]
1503                         link = `request.pl?biblionumber=[% biblionumber | url %]&amp;action=cancelBulk&amp;ids=${$('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')).join(',')}`;
1504                     [% END %]
1505                 } else {
1506                     let borrowernumber = cancel_link.data('borrowernumber');
1507                     let biblionumber = cancel_link.data('biblionumber');
1508                     let reserve_id = cancel_link.data('id');
1509                     link = `request.pl?action=cancel&amp;borrowernumber=${ borrowernumber }&amp;biblionumber=${ biblionumber }&amp;reserve_id=${ reserve_id }`;
1510                 }
1511                 let reason = $("#modal-cancellation-reason").val();
1512                 if ( reason ) {
1513                     link += "&amp;cancellation-reason=" + reason
1514                 }
1515                 window.location.href = link;
1516                 return false;
1517             });
1518
1519             [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) %]
1520                 [% IF ( PatronAutoComplete ) %]
1521                 $( "#patron" ).autocomplete({
1522                     source: "/cgi-bin/koha/circ/ysearch.pl",
1523                     minLength: 3,
1524                     select: function( event, ui ) {
1525                         $( "#patron" ).val( ui.item.cardnumber );
1526                         $( "#holds_patronsearch" ).submit();
1527                         return false;
1528                     }
1529                 })
1530                 .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
1531                     return $( "<li></li>" )
1532                     .data( "ui-autocomplete-item", item )
1533                     .append(
1534                         "<a>"
1535                             + ( item.surname ? item.surname.escapeHtml() : "" )
1536                             + ", "
1537                             + ( item.firstname ? item.firstname.escapeHtml() : "" )
1538                             + " (" + ( item.cardnumber ? item.cardnumber.escapeHtml() : "" ) + ")"
1539                             + " "
1540                             + "<small>"
1541                                 + ( item.address ? item.address.escapeHtml() : "" )
1542                                 + " "
1543                                 + ( item.city ? item.city.escapeHtml() : "" )
1544                                 + " "
1545                                 + ( item.zipcode ? item.zipcode.escapeHtml() : "" )
1546                                 + " "
1547                                 + ( item.country ? item.country.escapeHtml() : "" )
1548                             + "</small>"
1549                         + "</a>" )
1550                     .appendTo( ul );
1551                 };
1552                 [% END %]
1553             [% END %]
1554             Sticky = $("#toolbar");
1555             Sticky.hcSticky({
1556                 stickTo: "#existing_holds",
1557                 stickyClass: "floating"
1558             });
1559
1560             if(!localStorage.selectedHolds  || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) {
1561                 localStorage.selectedHolds = [];
1562             }
1563
1564             $('.holds_table .select_hold').each(function() {
1565                 if(localStorage.selectedHolds.includes($(this).data('id'))) {
1566                     $(this).prop('checked', true);
1567                 }
1568             });
1569
1570             $('.holds_table .select_hold_all').each(function() {
1571                 var table = $(this).parents('.holds_table');
1572                 var count = $('.select_hold:not(:checked)', table).length;
1573                 $('.select_hold_all', table).prop('checked', !count);
1574             });
1575
1576             $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1577
1578             $('.holds_table .select_hold_all').click(function() {
1579                 var table = $(this).parents('.holds_table');
1580                 var count = $('.select_hold:checked', table).length;
1581                 $('.select_hold', table).prop('checked', !count);
1582                 $(this).prop('checked', !count);
1583                 $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1584                 localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
1585             });
1586
1587             $('.holds_table .select_hold').click(function() {
1588                 var table = $(this).parents('.holds_table');
1589                 var count = $('.select_hold:not(:checked)', table).length;
1590                 $('.select_hold_all', table).prop('checked', !count);
1591                 $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length));
1592                 localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id'));
1593             });
1594
1595             $('.cancel_selected_holds').click(function(e) {
1596                 e.preventDefault();
1597                 if($('.holds_table .select_hold:checked').length) {
1598                     cancel_link = $(this);
1599                     delete localStorage.selectedHolds;
1600                     $('#cancelModal').modal();
1601                 }
1602                 return false;
1603             });
1604
1605         });
1606     </script>
1607 [% END %]
1608
1609 [% INCLUDE 'intranet-bottom.inc' %]