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