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