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