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