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