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