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