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