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