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