Bug 20708: Add Withdrawn status when placing a request in staff
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reserve / request.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% USE Categories %]
7 [% USE ItemTypes %]
8 [% USE AuthorisedValues %]
9 [% USE Price %]
10 [% SET footerjs = 1 %]
11 [% INCLUDE 'doc-head-open.inc' %]
12 [% UNLESS ( multi_hold ) %]
13     <title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Place a hold on [% INCLUDE 'biblio-title-head.inc' %]</title>
14 [% ELSE %]
15     <title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Confirm holds</title>
16 [% END %]
17 [% INCLUDE 'doc-head-close.inc' %]
18 </head>
19
20 <body id="circ_request" class="catalog">
21 [% INCLUDE 'header.inc' %]
22 [% INCLUDE 'circ-search.inc' %]
23
24 [% UNLESS ( multi_hold ) %]
25     <div id="breadcrumbs">
26         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
27         <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo;
28         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">[% biblio.title | html %]</a> &rsaquo;
29         Place a hold on [% INCLUDE 'biblio-title.inc' %]
30     </div>
31 [% ELSE %]
32     <div id="breadcrumbs">
33         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
34         <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo;
35         Confirm holds
36     </div>
37 [% END # UNLESS multi_hold %]
38
39 <div class="main container-fluid">
40     <div class="row">
41         [% IF ( multi_hold ) # No sidebar menu when placing multiple holds %]
42             <div class="col-md-10 col-md-offset-1">
43         [% ELSE %]
44             <div class="col-sm-10 col-sm-push-2">
45         [% END %]
46
47         <main>
48
49             [% IF ( noitems ) %]
50                 <div class="dialog alert">
51                 [%IF (multi_hold) %]
52                     <strong>Cannot place hold:</strong> one or more records without items attached.
53                 [% ELSE %]
54                     <strong>Cannot place hold:</strong> this record has no items attached.
55                 [% END %]
56                 </div>
57             [% END %]
58
59             [% IF ( messagetransfert ) %]
60                 <div class="dialog message">
61                     <h2>Hold found for ([% nextreservtitle | html %]), please transfer</h2>
62                     <p>Hold placed by : <strong> [% nextreservsurname | html %] [% nextreservfirstname | html %]</strong> at : <strong> [% branchname | html %] </strong>, Please transfer this item.
63                     </p>
64                     <form name="cancelReservewithtransfert" action="branchreserves.pl" method="post">
65                         <input type="submit" class="button" />
66                     </form>
67                 </div>
68             [% END %]
69
70             [% UNLESS ( multi_hold ) %]
71                 <h1>Place a hold on [% INCLUDE 'biblio-default-view.inc' %][% INCLUDE 'biblio-title.inc' %]</a></h1>
72             [% ELSE %]
73                 <h1>Confirm holds</h1>
74             [% END %]
75
76             [% UNLESS club OR patron OR patron.borrowernumber OR noitems %]
77                 [% IF ( messageborrower ) %]
78                     <div class="dialog alert">
79                         <h3>Patron not found</h3>
80                         <p>No patron with this name, please, try another</p>
81                     </div>
82                 [% END %]
83
84                 [% IF ( messageclub ) %]
85                     <div class="dialog alert">
86                         <h3>Club not found</h3>
87                         <p>No club with this name, please, try another</p>
88                     </div>
89                 [% END %]
90                 <fieldset class="brief">
91                     <label>Search Patrons or clubs</label>
92                     <div id="circ_holds_select">
93                         <ul class="nav nav-tabs" role="tablist">
94                             <li role="presentation"><a href="#holds_patronsearch_pane" aria-controls="holds_patronsearch_pane" role="tab" data-toggle="tab">Patrons</a></li>
95                             <li role="presentation"><a href="#holds_clubsearch_pane" aria-controls="holds_clubsearch_pane" role="tab" data-toggle="tab">Clubs</a></li>
96                         </ul>
97                         <div class="tab-content">
98                             <div role="tabpanel" class="tab-pane" id="holds_patronsearch_pane">
99                                 <form  id="holds_patronsearch" action="request.pl?biblionumber=[% biblionumber | html %]" method="post">
100                                     <div class="hint">Enter patron card number or partial name:</div>
101                                     <input type="text" size="40" id="patron" class="focus" name="findborrower" autocomplete="off" />
102                                     <input type="submit" value="Search" />
103                                     [% IF multi_hold %]
104                                         <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
105                                         <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
106                                     [% ELSE %]
107                                         <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
108                                     [% END %]
109
110                                     [% IF ( multi_hold ) %]
111                                         <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
112                                         <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
113                                     [% END %]
114                                 </form> <!-- /#holds_patronsearch -->
115                             </div>
116                             <div role="tabpanel" class="tab-pane" id="holds_clubsearch_pane">
117                                 <form  id="holds_clubsearch" action="request.pl?biblionumber=[% biblionumber | html %]" method="post">
118                                     <div class="hint">Enter club id or partial name:</div>
119                                     <input type="text" size="40" id="club" class="focus" name="findclub" autocomplete="off" />
120                                     <input type="submit" value="Search" />
121                                     [% IF multi_hold %]
122                                         <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
123                                         <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
124                                     [% ELSE %]
125                                         <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
126                                     [% END %]
127
128                                     [% IF ( multi_hold ) %]
129                                         <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
130                                         <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
131                                     [% END %]
132                                 </form> <!-- /#holds_patronsearch -->
133                             </div>
134                         </div>
135                     </div>
136                     <p>
137                         [% IF borrowers %]
138                             [% INCLUDE 'circ-patron-search-results.inc' destination = "holds" %]
139                         [% ELSIF clubs %]
140                             [% INCLUDE 'clubs-table.inc' destination = "holds" %]
141                         [% END %]
142                     </p>
143                 </fieldset>
144             [% ELSIF club %]
145                 <div class="dialog alert hide clubalert">
146                 </div>
147                 <fieldset class="rows">
148                     <legend>Hold details</legend>
149                     <form action="/api/v1/clubs/[% club.id | html %]/holds" method="post" name="form" id="club-request-form">
150
151                         [% IF ( multi_hold ) %]
152                             <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
153                             <input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="[% biblionumbers | html %]"/>
154                             <input type="hidden" name="bad_bibs" id="bad_bibs" value=""/>
155                             <input type="hidden" name="request" value="any"/>
156                             [% FOREACH biblioloo IN biblioloop %]
157                                 <input type="hidden" name="title_[% biblioloo.biblionumber | html %]" value="[% biblioloo.title | html %]"/>
158                                 <input type="hidden" name="rank_[% biblioloo.biblionumber | html %]" value="[% biblioloo.rank | html %]"/>
159                             [% END %]
160                         [% ELSE %]
161                             <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
162                             <input type="hidden" name="title" value="[% biblio.title | html %]" />
163                             <input type="hidden" name="rank-request" value="[% fixedRank | html %]" />
164                         [% END # /IF multi_hold %]
165                         <ol>
166                             <li>
167                                 <span class="label">Club: </span> [% club.name | html %]
168                             </li>
169                             <li>
170                                 <span class="label">Description: </span> [% club.description | html %]
171                             </li>
172                             <li>
173                                 <label for="pickup">Pickup at:</label>
174                                 <select name="pickup" size="1" id="pickup">
175                                     [% PROCESS options_for_libraries libraries => Branches.all({ selected => club.branchcode, search_params => { pickup_location => 1 } }) %]
176                                 </select>
177                             </li>
178                         </ol>
179                         <h2 style="padding: 0 1em;">Members</h2>
180                         <ol>
181                             [% FOREACH member IN members %]
182                                 [% SET patron = member.patron %]
183                                 <li style="padding: 0.5em 1em;">
184                                     <div><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] ([% patron.cardnumber | html %])</a></div>
185                                     [% IF member.exceeded_maxreserves %]
186                                         <div>
187                                             <i class="fa fa-error"></i>
188                                             <strong>Too many holds: </strong> Patron can only place a maximum of [% maxreserves | html %] total holds.
189                                         </div>
190                                     [% END %]
191                                     [% IF ( member.expiry ) %]
192                                         <div>
193                                             <i class="fa fa-warning"></i>
194                                             <strong>Account has expired</strong>
195                                         </div>
196                                     [% END %]
197                                     [% IF patron.is_debarred %]
198                                         <div>
199                                             <i class="fa fa-warning"></i>
200                                             <strong>Patron has restrictions</strong>
201                                         </div>
202                                     [% END %]
203                                     [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
204                                         <div>
205                                             <i class="fa fa-warning"></i>
206                                             <strong>Patron has outstanding fines: [% member.amount_outstanding | $Price %]</strong>
207                                         </div>
208                                     [% END %]
209
210                                     [% IF ( member.diffbranch ) %]
211                                         <div>
212                                             <i class="fa fa-warning"></i>
213                                             <strong>Pickup library is different.</strong> Patron's home library: ([% Branches.GetName(patron.branchcode) | html %] / [% patron.branchcode | html %] )
214                                         </div>
215                                     [% END %]
216                                 </li>
217                             [% END %]
218                         </ol>
219                         [% UNLESS ( multi_hold ) %]
220                             <fieldset class="action">
221                                 <input type="submit" value="Place hold" />
222                             </fieldset>
223                         [% ELSE %]
224                             <table id="requesttitles">
225                                 <tr>
226                                     <th>&nbsp;</th>
227                                     <th>Title</th>
228                                     [% UNLESS ( item_level_itypes ) %]
229                                         <th>Item type</th>
230                                     [% END %]
231                                     <th>Priority</th>
232                                     <th>Information</th>
233                                 </tr>
234                                 [% FOREACH biblioloo IN biblioloop %]
235                                     [% IF ( biblioloo.warn ) %]
236                                         <tr class="onissue">
237                                     [% ELSE %]
238                                         <tr>
239                                     [% END %]
240                                         <td>
241                                             [% UNLESS ( biblioloo.warn ) %]
242                                                     <input class="multi_hold_item_checkbox" type="checkbox" checked="checked" title="[% biblioloo.biblionumber | html %]"/>
243                                                 </td>
244                                             [% END %]
245                                         <td>
246                                             <ul>
247                                                 <li>
248                                                     <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">[% biblioloo.title | html %]</a>
249                                                 </li>
250                                                 [% IF ( biblioloo.publicationyear ) %]
251                                                     <li>
252                                                         <span class="label">Publication year:</span> [% biblioloo.publicationyear | html %]
253                                                     </li>
254                                                 [% END %]
255                                             </ul>
256                                             [% IF ( biblioloo.warn ) %]
257                                                 <span class="not_holdable" title="[% biblioloo.biblionumber | html %]"></span>
258                                             [% END %]
259                                         </td>
260                                         [% UNLESS ( item_level_itypes ) %]
261                                             <td>
262                                                 <img src="[% biblioloo.imageurl | html %]" alt="[% biblioloo.itypename | html %]" title="[% biblioloo.itypename | html %]" />
263                                             </td>
264                                         [% END %]
265                                         <td>[% biblioloo.rank | html %]</td>
266                                         <td>
267                                             [% IF ( biblioloo.checked_previously ) %]
268                                                 <span>Patron has previously checked out this title</span><br/>
269                                             [% END %]
270                                             [% IF ( biblioloo.alreadyres ) %]
271                                                 <ul>
272                                             [% ELSE %]
273                                                 [% IF ( biblioloo.none_avail ) %]
274                                                     <ul>
275                                                 [% END %]
276                                             [% END %]
277
278                                             [% IF ( biblioloo.alreadyres ) %]
279                                                 <li>
280                                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>
281                                                     <strong>already has a hold</strong> on this item
282                                                 </li>
283                                             [% END %]
284                                             [% IF ( biblioloo.none_avail ) %]
285                                                 <li> <strong>No items are available</strong> to be placed on hold</li>
286                                             [% END %]
287
288                                             [% IF ( biblioloo.alreadyres ) %]
289                                                 </ul>
290                                             [% ELSE %]
291                                                 [% IF ( biblioloo.none_avail ) %]
292                                                     </ul>
293                                                 [% END %]
294                                             [% END %]
295                                         </td>
296                                     </tr>
297                                 [% END # /FOREACH biblioloo %]
298                             </table> <!-- /#requesttitles -->
299                         [% END %]
300                     </form>
301                 </fieldset>
302             [% ELSIF NOT noitems # /UNLESS patron %]
303
304                 [% IF ( checked_previously && !multi_hold ) %]
305                     <div class="dialog alert">
306                         <ul>
307                             <li>Patron has previously checked out this title</li>
308                         </ul>
309                     </div>
310                 [% END %]
311
312                 [% IF ( exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %]
313                     <div class="dialog alert">
314
315                         [% UNLESS ( multi_hold ) %]
316                             <h3>Cannot place hold</h3>
317                             <ul>
318                                 [% IF ( exceeded_maxreserves ) %]
319                                     <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>
320                                 [% ELSIF ( exceeded_holds_per_record ) %]
321                                     <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>
322                                 [% ELSIF ( alreadypossession ) %]
323                                     <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>
324                                 [% ELSIF ( alreadyreserved ) %]
325                                     <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>
326                                 [% ELSIF ( ageRestricted ) %]
327                                     <li><strong>Age restricted</strong></li>
328                                 [% ELSIF ( none_available ) %]
329                                     <li> <strong>No items are available</strong> to be placed on hold.</li>
330                                 [% ELSIF ( maxreserves ) %]
331                                     <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>
332                                 [% END # /IF exceeded_maxreserves %]
333                             </ul>
334                         [% ELSE # UNLESS multi_hold %]
335                             <h3>Cannot place hold on some items</h3>
336                             [% IF ( exceeded_maxreserves ) %]
337                                 <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>
338                             [% ELSIF ( exceeded_holds_per_record ) %]
339                                 [% FOREACH biblioloo IN biblioloop %]
340                                     [% IF (biblioloo.tooManyHoldsForThisRecord) %]
341                                         <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>
342                                     [% END %]
343                                 [% END %]
344                             [% END # /IF exceeded_maxreserves %]
345                         [% END # /UNLESS multi_hold %]
346                     </div>
347                 [% END # /IF ( exceeded_maxreserves || ... %]
348
349                 [% IF ( expiry || diffbranch || patron.is_debarred || ( amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') ) ) %]
350                     <div class="dialog message">
351                         <ul>
352                             [% IF ( expiry ) %]
353                                 <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>
354                             [% END %]
355
356                             [% IF patron.is_debarred %]
357                                 <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>
358                             [% END %]
359
360                             [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
361                                 <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>
362                             [% END %]
363
364                             [% IF ( diffbranch ) %]
365                                 <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>
366                             [% END %]
367                         </ul> <!-- /.dialog.message -->
368                     </div>
369                 [% END # /IF expiry || diffbranch ... %]
370
371                 [% IF ( messageborrower ) %]
372                     <div class="dialog alert">
373                         <h3>Patron not found:</h3>
374                         <p>Name or barcode not found. Please try an other </p>
375                     </div>
376                 [% END %]
377
378                 <div class="dialog alert hide holdalert">
379                 </div>
380
381                 <fieldset class="rows">
382                     <legend>Hold details</legend>
383                     <form action="/api/v1/holds" method="post" name="form" id="hold-request-form">
384
385                         <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
386                         <input type="hidden" name="type" value="str8" />
387
388                         [% IF ( multi_hold ) %]
389                             <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
390                             <input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="[% biblionumbers | html %]"/>
391                             <input type="hidden" name="bad_bibs" id="bad_bibs" value=""/>
392                             <input type="hidden" name="request" value="any"/>
393                             [% FOREACH biblioloo IN biblioloop %]
394                                 <input type="hidden" name="title_[% biblioloo.biblionumber | html %]" value="[% biblioloo.title | html %]"/>
395                                 <input type="hidden" name="rank_[% biblioloo.biblionumber | html %]" value="[% biblioloo.rank | html %]"/>
396                             [% END %]
397                         [% ELSE %]
398                             <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
399                             <input type="hidden" name="title" value="[% biblio.title | html %]" />
400                             <input type="hidden" name="rank-request" value="[% fixedRank | html %]" />
401                         [% END # /IF multi_hold %]
402
403                         <ol>
404                             <li>
405                                 <span class="label">Patron:</span>
406                                 [% IF ( patron.borrowernumber ) %]
407                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] ([% patron.cardnumber | html %])</a>
408                                 [% ELSE %]
409                                     Not defined yet
410                                 [% END %]
411                             </li>
412
413                             [% UNLESS ( multi_hold ) %]
414                                 <li>
415                                     <span class="label">Estimated priority:</span>
416                                     <strong>[% fixedRank | html %]</strong>
417                                 </li>
418                             [% END %]
419
420                             <li>
421                                 <label for="holdnotes">Notes:</label>
422                                 <textarea id="holdnotes" name="notes" cols="30" rows="1"></textarea>
423                             </li>
424                             <li>
425                                 <label for="pickup">Pickup at:</label>
426                                 <select name="pickup" size="1" id="pickup">
427                                     [% UNLESS ( multi_hold ) %]
428                                         [% PROCESS options_for_libraries libraries => Branches.pickup_locations({ search_params => { biblio => biblionumber, patron => patron }, selected => pickup }) %]
429                                     [% ELSE %]
430                                         [% PROCESS options_for_libraries libraries => Branches.all({ selected => pickup, search_params => { pickup_location => 1 } }) %]
431                                     [% END %]
432                                 </select>
433                             </li>
434
435                             [% UNLESS ( multi_hold ) %]
436                                 [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
437                                     <li>
438                                         <label for="itemtype">Request specific item type:</label>
439                                         <select name="itemtype" size="1" id="itemtype">
440                                             <option value="">Any item type</option>
441                                             [%- FOREACH itemtype IN available_itemtypes %]
442                                                 <option value="[% itemtype | html %]">[% ItemTypes.GetDescription( itemtype ) | html %]</option>
443                                             [%- END %]
444                                         </select>
445                                     </li>
446                                 [% END %]
447                             [% END # /UNLESS multi_hold %]
448
449                             [% IF ( reserve_in_future ) %]
450                                 <li>
451                                     <label for="from">Hold starts on date:</label>
452                                     <input name="reserve_date" id="from" size="10" class="datepickerfrom" type="text" >
453                                     <input type="hidden" class="datepickerfrom_hidden" />
454                                     <a href="#" id="clear-date-from" class="clear-date">Clear date</a>
455                                 </li>
456                             [% END %]
457
458                             <li>
459                                 <label for="to">Hold expires on date:</label>
460                                 <input name="expiration_date" id="to" size="10" class="datepickerto" type="text" />
461                                 <input type="hidden" class="datepickerto_hidden" />
462                                 <a href="#" id="clear-date-to" class="clear-date">Clear date</a>
463                             </li>
464
465                             [% UNLESS ( multi_hold ) %]
466                                 <li>
467                                     <label for="requestany">Hold next available item </label>
468                                     [% IF force_hold_level == 'item' %]
469                                         <input type="checkbox" id="requestany" name="request" disabled="true" />
470                                     [% ELSIF force_hold_level == 'record' %]
471                                         <input type="checkbox" id="requestany" checked="checked" value="Any" disabled="true"/>
472                                         <input type="hidden" name="request" value="Any"/>
473                                     [% ELSE %]
474                                         <input type="checkbox" id="requestany" name="request" checked="checked" value="Any" />
475                                     [% END %]
476                                     <input type="hidden" name="biblioitem" value="[% biblioitemnumber | html %]" />
477                                     <input type="hidden" name="alreadyreserved" value="[% alreadyreserved | html %]" />
478                                 </li>
479
480                                 [% IF remaining_holds_for_record > 1 %]
481                                     <li>
482                                         <label for="holds_to_place_count">Holds to place (count)</label>
483                                         <input id="holds_to_place_count" type="number" name="holds_to_place_count" min="1" max="[% remaining_holds_for_record | html %]" step="1" value="1" />
484                                     </li>
485                                 [% ELSE %]
486                                     <input type="hidden" name="holds_to_place_count" value="1" />
487                                 [% END %]
488                             [% END # /UNLESS multi_hold %]
489                         </ol>
490
491                         [% UNLESS ( multi_hold ) %]
492                             <fieldset class="action">
493                                 [% IF ( patron.borrowernumber ) %]
494                                     [% IF ( override_required ) %]
495                                         <button type="submit" class="btn btn-default warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
496                                     [% ELSIF ( none_available ) %]
497                                         <button type="submit" disabled="disabled" class="btn btn-default btn-disabled">Place hold</button>
498                                     [% ELSE %]
499                                         <button type="submit" class="btn btn-default">Place hold</button>
500                                     [% END %]
501                                 [% END %]
502                             </fieldset>
503
504                             [% FOREACH bibitemloo IN bibitemloop %]
505                                 <ol>
506                                     [% UNLESS ( item_level_itypes ) %]
507                                         <li>
508                                             <span class="label">Item type:</span>
509                                             [% bibitemloo.description | html %]
510                                         </li>
511                                     [% END %]
512
513                                     [% IF ( bibitemloo.publicationyear ) %]
514                                         <li>
515                                             <span class="label">Publication year:</span>
516                                             [% bibitemloo.publicationyear | html %]
517                                         </li>
518                                     [% END %]
519                                 </ol>
520
521                                 <h2 style="padding: 0 1em;">
522                                     Place a hold on a specific item
523                                     [% IF bibitemloo.force_hold_level == 'item' %]
524                                          <span class="error"><i>(Required)</i></span>
525                                     [% END %]
526                                 </h2>
527
528                                 <table id="requestspecific">
529                                     <thead>
530                                         <tr>
531                                             <th>Hold</th>
532                                             [% IF ( item_level_itypes ) %]
533                                                 <th>Item type</th>
534                                             [% END %]
535                                             <th>Barcode</th>
536                                             <th>Home library</th>
537                                             <th>Last location</th>
538                                             [% IF itemdata_ccode %]
539                                                 <th>Collection</th>
540                                             [% END %]
541                                             <th>Call no.</th>
542                                             <th>Copy number</th>
543                                             [% IF itemdata_enumchron %]
544                                                 <th>Vol no.</th>
545                                             [% END %]
546                                             <th class="title-string">Information</th>
547                                             <th class="title-string">Allowed pickup locations</th>
548                                         </tr>
549                                     </thead>
550                                     <tbody>
551                                         [% SET selected = 0 %]
552                                         [% FOREACH itemloo IN bibitemloo.itemloop %]
553                                             [% UNLESS ( itemloo.hide ) %]
554                                                 <tr class="[% itemloo.backgroundcolor | html %]">
555                                                     <td>
556                                                         [% IF itemloo.force_hold_level == 'record' # Patron has placed a record level hold previously for this record %]
557                                                             <span class="error">
558                                                                 <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i>
559                                                                 Hold must be record level
560                                                             </span>
561                                                         [% ELSIF ( itemloo.available ) %]
562                                                             <input type="radio" name="checkitem" value="[% itemloo.itemnumber | html %]" />
563                                                         [% ELSIF ( itemloo.override ) %]
564                                                             <input type="radio" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber | html %]" />
565                                                             <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" title="Requires override of hold policy"/></i>
566                                                         [% ELSE %]
567                                                             <span class="error">
568                                                                 <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i>
569                                                                 [% IF itemloo.not_holdable %]
570                                                                     [% IF itemloo.not_holdable == 'damaged' %]
571                                                                         Item damaged
572                                                                     [% ELSIF itemloo.not_holdable == 'ageRestricted' %]
573                                                                         Age restricted
574                                                                     [% ELSIF itemloo.not_holdable == 'tooManyHoldsForThisRecord' %]
575                                                                         Exceeded max holds per record
576                                                                     [% ELSIF itemloo.not_holdable == 'tooManyReservesToday' %]
577                                                                         Daily hold limit reached for patron
578                                                                     [% ELSIF itemloo.not_holdable == 'tooManyReserves' %]
579                                                                         Too many holds
580                                                                     [% ELSIF itemloo.not_holdable == 'notReservable' %]
581                                                                         Not holdable
582                                                                     [% ELSIF itemloo.not_holdable == 'cannotReserveFromOtherBranches' %]
583                                                                         Patron is from different library
584                                                                     [% ELSIF itemloo.not_holdable == 'branchNotInHoldGroup' %]
585                                                                         Cannot place hold from patron's library
586                                                                     [% ELSIF itemloo.not_holdable == 'itemAlreadyOnHold' %]
587                                                                         Patron already has hold for this item
588                                                                     [% ELSIF itemloo.not_holdable == 'cannotBeTransferred' %]
589                                                                         Cannot be transferred to pickup library
590                                                                     [% ELSE %]
591                                                                         [% itemloo.not_holdable | html %]
592                                                                     [% END %]
593                                                                 [% END %]
594                                                             </span>
595                                                         [% END # /IF itemloo.force_hold_level %]
596                                                     </td>
597                                                     [% IF ( item_level_itypes ) %]
598                                                         <td>
599                                                             [% UNLESS ( noItemTypeImages ) %]
600                                                                 [% IF ( itemloo.imageurl ) %]<img src="[% itemloo.imageurl | html %]" alt="" /> <br /> [% END %]
601                                                             [% END %]
602                                                             [% itemloo.itypename | html %]
603                                                         </td>
604                                                     [% END %]
605                                                     <td>
606                                                         [% itemloo.barcode | html %]
607                                                     </td>
608                                                     <td>
609                                                         [% Branches.GetName( itemloo.homebranch ) | html %]
610                                                     </td>
611                                                     <td>
612                                                         [% Branches.GetName( itemloo.holdingbranch ) | html %]
613                                                     </td>
614                                                     [% IF itemdata_ccode %]
615                                                         <td>
616                                                             [% IF ( itemloo.ccode ) %][% AuthorisedValues.GetByCode( 'CCODE', itemloo.ccode ) | html %][% END %]
617                                                         </td>
618                                                     [% END %]
619                                                     <td>
620                                                         [% itemloo.itemcallnumber | html %]
621                                                     </td>
622                                                     <td>
623                                                         [% IF ( itemloo.copynumber ) %][% itemloo.copynumber | html %][% ELSE %]&nbsp;[% END %]
624                                                     </td>
625                                                     [% IF itemdata_enumchron %]
626                                                         <td>
627                                                             [% itemloo.enumchron | html %]
628                                                         </td>
629                                                     [% END %]
630                                                     <td>
631                                                         [% IF ( itemloo.onloan ) %]
632                                                             <span title="[% itemloo.date_due | html %]" class="checkedout">Due [% itemloo.date_due | $KohaDates  as_due_date => 1 %]</span>
633                                                         [% ELSE %]
634                                                             <span title="0000-00-00">
635                                                                 [% IF ( itemloo.transfertwhen ) %]
636                                                                     In transit from [% Branches.GetName( itemloo.transfertfrom ) | html %],
637                                                                     to [% Branches.GetName( itemloo.transfertto ) | html %], since [% itemloo.transfertwhen | html %]
638                                                                 [% END %]
639                                                             </span>
640                                                         [% END %]
641
642                                                         [% IF ( itemloo.reservedate ) %]
643                                                             [% IF ( itemloo.nocancel ) %]
644                                                                     Can't be cancelled when item is in transit
645                                                             [% ELSE %]
646                                                                 [% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
647                                                                 [% IF ( itemloo.canreservefromotherbranches ) %]
648                                                                     for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedFor.borrowernumber | uri %]">[% itemloo.ReservedFor.firstname | html %] [% itemloo.ReservedFor.surname | html %]</a>
649                                                                 [% END %]
650                                                                 [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %]
651                                                                 [% Branches.GetName( itemloo.ExpectedAtLibrary ) | html %] since
652                                                                 [% IF ( itemloo.waitingdate ) %]
653                                                                     [% itemloo.waitingdate | $KohaDates %]
654                                                                 [% ELSE %]
655                                                                     [% IF ( itemloo.reservedate ) %]
656                                                                         [% itemloo.reservedate | html %]
657                                                                     [% END %]
658                                                                 [% END %].
659                                                                 <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>
660                                                             [% END # /IF itemloo.nocancel %]
661                                                         [% ELSE %]
662                                                             Not on hold
663                                                         [% END # /IF itemloo.reservedate %]
664
665                                                         [% IF itemloo.item_level_holds == "N" %]
666                                                             <br/>Item level hold not allowed from OPAC
667                                                         [% ELSIF itemloo.item_level_holds == "F" %]
668                                                             <br/>Item level hold forced from OPAC
669                                                         [% END %]
670
671                                                         [% IF ( itemloo.itemlost ) %]
672                                                            <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', itemloo.itemlost ) | html %]</span>
673                                                         [% END %]
674
675                                                         [% IF ( itemloo.damaged ) %]
676                                                             <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', itemloo.damaged ) | html %]</span>
677                                                         [% END %]
678
679                                                         [% IF ( itemloo.withdrawn ) %]
680                                                            <span class="wdn">[% AuthorisedValues.GetByCode( 'WITHDRAWN', itemloo.withdrawn ) | html %]</span>
681                                                         [% END %]
682
683                                                         [% IF ( itemloo.notforloan ) %]
684                                                            <span class="nfl">Not for loan ([% AuthorisedValues.GetByCode( 'NOT_LOAN', itemloo.notforloan ) | html %])</span>
685                                                         [% END %]
686                                                     </td>
687                                                     <td>
688                                                         [% itemloo.pickup_locations | html %]
689                                                     </td>
690                                                 </tr>
691                                             [% END # / UNLESS itemloo.hide %]
692                                         [% END # /FOREACH itemloo %]
693                                     </tbody>
694                                 </table> <!-- /#requestspecific -->
695
696                                 [% IF ( bibitemloo.hiddencount ) %]
697                                     <form>
698                                         <p class="hiddencount">
699                                             <a href="request.pl?biblionumber=[% bibitemloo.biblionumber | uri %]&amp;borrowernumber=[% bibitemloo.borrowernumber | uri %]&amp;showallitems=1">Show all items ([% bibitemloo.hiddencount | html %] hidden)</a>
700                                         </p>
701                                     </form>
702                                 [% END # /IF bibitemloo.hiddencount %]
703                             [% END # /FOREACH bibitemloo %]
704
705                         [% ELSE # /UNLESS multi_hold %]
706
707                             <table id="requesttitles">
708                                 <tr>
709                                     <th>&nbsp;</th>
710                                     <th>Title</th>
711                                     [% UNLESS ( item_level_itypes ) %]
712                                         <th>Item type</th>
713                                     [% END %]
714                                     <th>Priority</th>
715                                     <th>Information</th>
716                                 </tr>
717                                 [% FOREACH biblioloo IN biblioloop %]
718                                     [% IF ( biblioloo.warn ) %]
719                                         <tr class="onissue">
720                                     [% ELSE %]
721                                         <tr>
722                                     [% END %]
723                                         <td>
724                                             [% UNLESS ( biblioloo.warn ) %]
725                                                     <input class="multi_hold_item_checkbox" type="checkbox" checked="checked" title="[% biblioloo.biblionumber | html %]"/>
726                                                 </td>
727                                             [% END %]
728                                         <td>
729                                             <ul>
730                                                 <li>
731                                                     <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">[% biblioloo.title | html %]</a>
732                                                 </li>
733                                                 [% IF ( biblioloo.publicationyear ) %]
734                                                     <li>
735                                                         <span class="label">Publication year:</span> [% biblioloo.publicationyear | html %]
736                                                     </li>
737                                                 [% END %]
738                                             </ul>
739                                             [% IF ( biblioloo.warn ) %]
740                                                 <span class="not_holdable" title="[% biblioloo.biblionumber | html %]"></span>
741                                             [% END %]
742                                         </td>
743                                         [% UNLESS ( item_level_itypes ) %]
744                                             <td>
745                                                 <img src="[% biblioloo.imageurl | html %]" alt="[% biblioloo.itypename | html %]" title="[% biblioloo.itypename | html %]" />
746                                             </td>
747                                         [% END %]
748                                         <td>[% biblioloo.rank | html %]</td>
749                                         <td>
750                                             [% IF ( biblioloo.checked_previously ) %]
751                                                 <span>Patron has previously checked out this title</span><br/>
752                                             [% END %]
753                                             [% IF ( biblioloo.alreadyres ) %]
754                                                 <ul>
755                                             [% ELSE %]
756                                                 [% IF ( biblioloo.none_avail ) %]
757                                                     <ul>
758                                                 [% END %]
759                                             [% END %]
760
761                                             [% IF ( biblioloo.alreadyres ) %]
762                                                 <li>
763                                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>
764                                                     <strong>already has a hold</strong> on this item
765                                                 </li>
766                                             [% END %]
767                                             [% IF ( biblioloo.none_avail ) %]
768                                                 <li> <strong>No items are available</strong> to be placed on hold</li>
769                                             [% END %]
770
771                                             [% IF ( biblioloo.alreadyres ) %]
772                                                 </ul>
773                                             [% ELSE %]
774                                                 [% IF ( biblioloo.none_avail ) %]
775                                                     </ul>
776                                                 [% END %]
777                                             [% END %]
778                                         </td>
779                                     </tr>
780                                 [% END # /FOREACH biblioloo %]
781                             </table> <!-- /#requesttitles -->
782
783                         [% END # /UNLESS multi_hold %]
784
785                         <fieldset class="action">
786                             [% IF ( patron AND patron.borrowernumber ) %]
787                                 [% IF ( override_required ) %]
788                                     <button type="submit" class="btn btn-default warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
789                                 [% ELSIF ( none_available ) %]
790                                     <button type="submit" disabled="disabled" class="btn btn-default btn-disabled">Place hold</button>
791                                 [% ELSE %]
792                                     [% IF ( multi_hold ) %]
793                                         <button type="submit" class="btn btn-default" id="multi_hold_submit">Place hold</button>
794                                     [% ELSE %]
795                                         <button type="submit" class="btn btn-default">Place hold</button>
796                                     [% END %]
797                                 [% END %]
798                             [% END # /IF patron %]
799                         </fieldset> <!-- /.action -->
800                     </form> <!-- /#hold-request-form -->
801                 </fieldset> <!-- /.rows -->
802             [% END %]
803
804             [% UNLESS ( patron ) %]
805                 [% IF ( reserveloop ) %]
806                     <form name="T[% time | html %]" action="modrequest.pl" method="post">
807                         [% IF ( multi_hold ) %]
808                             <input type = "hidden" name="multi_hold" value="1"/>
809                             <input type = "hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
810                         [% END %]
811
812                         <fieldset class="rows">
813                             <legend>Existing holds</legend>
814
815                             [% FOREACH biblioloo IN biblioloop %]
816                                 [% IF ( biblioloo.reserveloop ) %]
817                                     [% IF ( multi_hold ) %]
818                                         <h3>
819                                             <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">
820                                                 [% biblioloo.title | html %]
821                                             </a>
822                                         </h3>
823                                     [% END %]
824
825                                     [% IF Koha.Preference('HoldsSplitQueue') == 'branch' %]
826                                         [% SET branchcodes = [] %]
827
828                                         [% FOREACH h IN biblioloo.reserveloop %]
829                                             [% branchcodes.push( h.branchcode ) %]
830                                         [% END %]
831                                         [% branchcodes = branchcodes.unique %]
832
833                                         [% FOREACH b IN branchcodes.sort %]
834                                             [% SET holds_by_branch = [] %]
835                                             [% FOREACH h IN biblioloo.reserveloop %]
836                                                 [% IF h.branchcode == b %]
837                                                     [% holds_by_branch.push( h ) %]
838                                                 [% END %]
839                                             [% END %]
840                                             <fieldset>
841                                                 <legend>[% Branches.GetName( b ) | html %]</legend>
842                                                 [% INCLUDE holds_table.inc holds=holds_by_branch %]
843                                             </fieldset>
844                                         [% END # /FOREACh b %]
845                                     [% ELSIF Koha.Preference('HoldsSplitQueue') == 'itemtype' %]
846                                         [% SET itemtypes = [] %]
847
848                                         [% FOREACH h IN biblioloo.reserveloop %]
849                                             [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
850                                             [% itemtypes.push( hold_itemtype ) %]
851                                         [% END %]
852                                         [% itemtypes = itemtypes.unique %]
853
854                                         [% FOREACH i IN itemtypes.sort %]
855                                             [% SET holds_by_itemtype = [] %]
856                                             [% FOREACH h IN biblioloo.reserveloop %]
857                                                 [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
858                                                 [% IF hold_itemtype == i %]
859                                                     [% holds_by_itemtype.push( h ) %]
860                                                 [% END %]
861                                             [% END %]
862
863                                             <fieldset>
864                                                 [% IF i %]
865                                                     <legend>[% ItemTypes.GetDescription( i ) | html %]</legend>
866                                                 [% ELSE %]
867                                                     <legend>Any item type</legend>
868                                                 [% END %]
869                                                 [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
870                                             </fieldset>
871                                         [% END # /FOREACH i %]
872                                     [% ELSIF Koha.Preference('HoldsSplitQueue') == 'branch_itemtype' %]
873                                         [% SET branchcodes = [] %]
874
875                                         [% FOREACH h IN biblioloo.reserveloop %]
876                                             [% branchcodes.push( h.branchcode ) %]
877                                         [% END %]
878                                         [% branchcodes = branchcodes.unique %]
879
880                                         [% FOREACH b IN branchcodes.sort %]
881                                             <fieldset class="contrast">
882                                                 <legend>[% Branches.GetName( b ) | html %]</legend>
883                                                 [% SET holds_by_branch = [] %]
884                                                 [% FOREACH h IN biblioloo.reserveloop %]
885                                                     [% IF h.branchcode == b %]
886                                                         [% holds_by_branch.push( h ) %]
887                                                     [% END %]
888                                                 [% END %]
889
890                                                 [% SET itemtypes = [] %]
891                                                 [% FOREACH h IN holds_by_branch %]
892                                                     [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
893                                                     [% itemtypes.push( hold_itemtype ) %]
894                                                 [% END %]
895                                                 [% itemtypes = itemtypes.unique %]
896
897                                                 [% FOREACH i IN itemtypes.sort %]
898                                                     <fieldset class="standard">
899                                                         [% IF i %]
900                                                             <legend>[% ItemTypes.GetDescription( i ) | html %]</legend>
901                                                         [% ELSE %]
902                                                             <legend>Any item type</legend>
903                                                         [% END %]
904
905                                                         [% SET holds_by_itemtype = [] %]
906                                                         [% FOREACH h IN holds_by_branch %]
907                                                             [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
908                                                             [% IF hold_itemtype == i %]
909                                                                 [% holds_by_itemtype.push( h ) %]
910                                                             [% END %]
911                                                         [% END %]
912                                                         [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
913                                                     </fieldset>
914                                                 [% END %]
915                                             </fieldset>
916                                         [% END # /FOREACH b %]
917                                     [% ELSE %]
918                                         [% INCLUDE holds_table.inc holds=biblioloo.reserveloop %]
919                                     [% END # /IF HoldsSplitQueue %]
920
921                                 [% END # /IF biblioloo.reserveloop %]
922                             [% END # FOREACH biblioloo %]
923
924                             <fieldset class="action">
925                                 <input type="submit" name="submit" value="Update hold(s)" />
926                             </fieldset>
927                         </fieldset> <!-- /.rows -->
928                     </form> <!-- /name=TTime -->
929                 [% END # IF reserveloop %]
930             [% END # UNLESS patron %]
931
932         </main>
933
934         [% IF ( multi_hold ) # No sidebar menu when placing multiple holds %]
935             </div> <!-- /.col-md-10.col-md-offset-1 -->
936         [% ELSE %]
937             </div> <!-- /.col-sm-10.col-sm-push-2 -->
938                 <div class="col-sm-2 col-sm-pull-10">
939                     <aside>
940                         [% INCLUDE 'biblio-view-menu.inc' %]
941                     </aside>
942                 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
943         [% END %]
944     </div> <!-- /.row -->
945
946
947 [% MACRO jsinclude BLOCK %]
948     [% INCLUDE 'datatables.inc' %]
949     [% INCLUDE 'calendar.inc' %]
950     [% INCLUDE 'columns_settings.inc' %]
951     [% Asset.js("js/circ-patron-search-results.js") | $raw %]
952     <script>
953         var biblionumber = "[% biblionumber | $raw %]";
954         var borrowernumber = "[% patron.borrowernumber | $raw %]";
955         var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
956         var patron_homebranch = "[% Branches.GetName( patron.branchcode ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html %]";
957         var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
958         [% itemloo.itemnumber | html %]: {
959             homebranch: "[% Branches.GetName( itemloo.homebranch ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html %]",
960             holdallowed: [% itemloo.holdallowed | html %]
961             },
962             [% END %][% END %][% END %]
963         };
964         var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
965         var ERROR_MAP = {
966             damaged: _("Item damaged"),
967             ageRestricted: _("Age restricted"),
968             tooManyHoldsForThisRecord: _("Exceeded max holds per record"),
969             tooManyReservesToday: _("Daily hold limit reached for patron"),
970             tooManyReserves: _("Too many holds"),
971             notReservable: _("Not holdable"),
972             cannotReserveFromOtherBranches: _("Patron is from different library"),
973             itemAlreadyOnHold: _("Patron already has hold for this item"),
974             cannotBeTransferred: _("Cannot be transferred to pickup library")
975         }
976         columns_settings_borrowers_table = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]
977
978         $(document).ready(function() {
979             [% UNLESS clubs %]
980                 $('#circ_holds_select').tabs({active: 0});
981             [% ELSE %]
982                 $('#circ_holds_select').tabs({active: 1});
983             [% END %]
984             function ToggleHoldsToPlace() {
985                 if ( $("#requestany").prop('checked') ) {
986                     $("#holds_to_place_count").prop('disabled', false);
987                 } else {
988                     $("#holds_to_place_count").prop('disabled', true);
989                 }
990             }
991             ToggleHoldsToPlace();
992             $("#requestany").on('change', function(){
993                 ToggleHoldsToPlace();
994             });
995
996             [% IF Koha.Preference('UseBranchTransferLimits') %]
997                 $("#pickup").on('change', function(){
998                     var pickup = $("#pickup").val();
999                     var url = "?pickup=" + pickup;
1000                     url += "&borrowernumber=" + borrowernumber;
1001                     url += "&biblionumber=" + biblionumber;
1002                     window.location.replace(url);
1003                 });
1004             [% END %]
1005
1006             [% IF AutoResumeSuspendedHolds %]
1007                 $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
1008             [% END %]
1009
1010             $(".datepickerto").datepicker("option", "altField", ".datepickerto_hidden");
1011             $(".datepickerto").datepicker("option", "altFormat", "yy-mm-dd");
1012
1013             $(".datepickerfrom").datepicker("option", "altField", ".datepickerfrom_hidden");
1014             $(".datepickerfrom").datepicker("option", "altFormat", "yy-mm-dd");
1015
1016             var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
1017                 'bPaginate': false,
1018                 "sDom": '<"top pager"ilf>t',
1019                 "aoColumnDefs": [
1020                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
1021                 ]
1022             }));
1023
1024             //Override fieldset styling for dataTables search box
1025             $("div.top.pager").css("margin-left","1em");
1026             $(".dataTables_filter label").css({
1027                 "width":"auto",
1028                 "margin-right":"0em"
1029             });
1030
1031             $("#club-request-form, #hold-request-form").on("submit", function() {
1032                 let $t = $(this);
1033                 $('.clubalert, .holdalert').addClass('hide');
1034                 let biblionumbers = [biblionumber];
1035                 let biblionumbers_text;
1036                 const data = {
1037                     pickup_library_id: $('select[name="pickup"]').val()
1038                 };
1039                 if($('input[name="checkitem"]:checked').length)
1040                     data.item_id = $('input[name="checkitem"]:checked').val();
1041                 if($('input[name="borrowernumber"]').length)
1042                     data.patron_id = $('input[name="borrowernumber"]').val();
1043                 if($('textarea[name="notes"]').length)
1044                     data.notes = $('textarea[name="notes"]').val()||null;
1045                 if($('.datepickerto_hidden').length)
1046                     data.expiration_date = $('.datepickerto_hidden').val()||null;
1047                 if($('.datepickerfrom_hidden').length)
1048                     data.hold_date = $('.datepickerfrom_hidden').val()||null;
1049                 if($('input[name="itemtype"]').length) {
1050                     data.item_type = $('input[name="itemtype"]').val()||null;
1051                 }
1052                 if($('input[name="biblionumbers"]').length) {
1053                     biblionumbers_text = $('input[name="biblionumbers"]').val();
1054                     biblionumbers = biblionumbers_text.replace(/\/$/, '').split('/')
1055                 }
1056
1057                 const count = $('input[name="holds_to_place_count"]').length?$('input[name="holds_to_place_count"]').val():1;
1058                 biblionumbers.forEach(function(biblionumber) {
1059                     data.biblio_id = biblionumber;
1060                     let options = {
1061                         url: $t.attr('action'),
1062                         method: $t.attr('method').toUpperCase(),
1063                         contentType: 'application/json',
1064                         data: JSON.stringify(data)
1065                     };
1066                     for(let i = 0; i < count; i++) {
1067                         $.ajax(options)
1068                         .then(function(result) {
1069                             let url = 'request.pl?biblionumber='+biblionumber;
1070                             if(biblionumbers_text) {
1071                                 url = 'request.pl?biblionumbers='+biblionumbers_text+'&multi_hold=1';
1072                             }
1073                             document.location = url;
1074                         })
1075                         .fail(function(err) {
1076                             var message = err.responseJSON.error;
1077                             var match = err.responseJSON.error.match(/Reason: (\w+)\s*$/);
1078                             if(match && ERROR_MAP[match[1]]) {
1079                                 message = '<div><strong>'+_("Cannot place hold")+'</strong></div><div>'+ERROR_MAP[match[1]]+'</div>'
1080                             }
1081                             $('.clubalert, .holdalert').removeClass('hide').html(message);
1082                         });
1083                     }
1084                 });
1085
1086                 return false;
1087             });
1088
1089             [% UNLESS ( multi_hold ) %]
1090                 $("#hold-request-form").on("submit", function(){
1091                     return check();
1092                 });
1093             [% ELSE %]
1094                 $("#hold-request-form").on("submit", function(){
1095                     return checkMultiHold();
1096                 });
1097             [% END %]
1098
1099         });
1100
1101         function check() {
1102             var msg = "";
1103             var count_reserv = 0;
1104
1105             // check if we have checkitem form
1106             if (document.form.checkitem){
1107                 for (i=0;i<document.form.checkitem.length;i++){
1108                     if (document.form.checkitem[i].checked == true) {
1109                         count_reserv++ ;
1110                     }
1111                 }
1112                 // for only one item, check the checkitem without consider the loop checkitem
1113                 if (i==0){
1114                     if (document.form.checkitem.checked == true) {
1115                         count_reserv++;
1116                     }
1117                 }
1118             }
1119
1120             if (document.form.requestany.checked == true){
1121                 count_reserv++ ;
1122             }
1123
1124             if (count_reserv == "0"){
1125                 msg += (_("- Please select an item to place a hold") + "\n");
1126             }
1127
1128             if (msg == "") {
1129                 $('#hold-request-form').preventDoubleFormSubmit();
1130                 return(true);
1131             } else {
1132                 alert(msg);
1133                 return(false);
1134             }
1135         }
1136
1137         function checkMultiHold() {
1138             var spans = $(".multi_hold_item_checkbox:checked");
1139             if ($(spans).size() == 0) {
1140                 alert(MSG_NO_ITEMS_AVAILABLE);
1141                 return false;
1142             }
1143
1144             var biblionumbers = "";
1145             $(spans).each(function() {
1146                 var bibnum = $(this).attr("title");
1147                 biblionumbers += bibnum + "/";
1148             });
1149
1150             var badSpans = $(".not_holdable");
1151             var badBibs = "";
1152             $(badSpans).each(function() {
1153                 var bibnum = $(this).attr("title");
1154                 badBibs += bibnum + "/";
1155             });
1156
1157             $("#multi_hold_bibs").val(biblionumbers);
1158             $("#bad_bibs").val(badBibs);
1159
1160             $('#hold-request-form').preventDoubleFormSubmit();
1161
1162             return true;
1163         }
1164
1165          $(document).ready(function() {
1166             $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
1167                 var itemnumber = this.value;
1168                 var msg = '';
1169
1170                 switch (override_items[itemnumber].holdallowed) {
1171                     case 0: msg = _("This item normally cannot be put on hold."); break;
1172                     case 1: msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
1173                 }
1174
1175                 msg += "\n\n" + _("Place hold on this item?");
1176
1177                 return confirm(msg);
1178             });
1179             $("button.warning").click(function() {
1180                 return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
1181             });
1182             $("#requestany").click(function() {
1183                 if(this.checked){
1184                     $("input[name=checkitem]").each(function() {
1185                         $(this).prop("checked", false);
1186                     });
1187                 }
1188             });
1189             $("input[name=checkitem]").click(function() {
1190                 onechecked = 0;
1191                 $("input[name=checkitem]").each(function() {
1192                     if(this.checked){
1193                         onechecked = 1;
1194                     }
1195                 });
1196                 if(onechecked == 1){
1197                     $("#requestany").prop("checked", false);
1198                     $("#holds_to_place_count").prop('disabled', true);
1199                 } else {
1200                     $("#requestany").prop("checked",true);
1201                     $("#holds_to_place_count").prop('disabled', false);
1202                 }
1203             });
1204             var prev_rank_request;
1205             $("select[name=rank-request]").on("focus", function() {
1206                 prev_rank_request = $(this).val();
1207                 var row = $(this).parents("tr:first");
1208             }).change(function() {
1209                 var row = $(this).parents("tr:first");
1210                 var value = parseInt($(this).val());
1211                 var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found
1212                 if( !isNaN(value) ) {  //If moved to 'del'
1213                     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)
1214                     if (prev_rank_request > value) {
1215                         row.insertBefore(after);
1216                     } else {
1217                         row.insertAfter(after);
1218                     }
1219                 }
1220
1221                 var next_priority = 1;
1222                 $("select[name=rank-request]").each(function () {
1223                     if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds
1224                     $(this).val(next_priority);
1225                     next_priority++;
1226                 });
1227             });
1228
1229             $(".clear-date").on("click",function(e){
1230                 e.preventDefault();
1231                 var fieldID = this.id.replace("clear-date-","");
1232                 $("#" + fieldID).val("");
1233             });
1234
1235             // Confirm cancelation of hold
1236             $(".cancel-hold").on("click",function(e) {
1237                 return confirmDelete(MSG_CONFIRM_DELETE_HOLD);
1238             });
1239
1240             [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems ) %]
1241                 [% IF ( PatronAutoComplete ) %]
1242                 $( "#patron" ).autocomplete({
1243                     source: "/cgi-bin/koha/circ/ysearch.pl",
1244                     minLength: 3,
1245                     select: function( event, ui ) {
1246                         $( "#patron" ).val( ui.item.cardnumber );
1247                         $( "#holds_patronsearch" ).submit();
1248                         return false;
1249                     }
1250                 })
1251                 .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
1252                     return $( "<li></li>" )
1253                     .data( "ui-autocomplete-item", item )
1254                     .append( "<a>" + item.surname + ", " + item.firstname +
1255                              " (" + item.cardnumber + ") <small>" + item.address +
1256                              " " + item.city + " " + item.zipcode + " " +
1257                              item.country + "</small></a>" )
1258                     .appendTo( ul );
1259                 };
1260                 [% END %]
1261             [% END %]
1262
1263         });
1264     </script>
1265 [% END %]
1266
1267 [% INCLUDE 'intranet-bottom.inc' %]