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