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