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