Bug 25534: Use the cancelation reasion for the 'X' hold cancelation links
[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                         </ol>
480
481                         [% UNLESS ( multi_hold ) %]
482                             <fieldset class="action">
483                                 [% IF ( patron.borrowernumber ) %]
484                                     [% IF ( override_required ) %]
485                                         <button type="submit" class="btn btn-default warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
486                                     [% ELSIF ( none_available ) %]
487                                         <button type="submit" disabled="disabled" class="btn btn-default btn-disabled">Place hold</button>
488                                     [% ELSE %]
489                                         <button type="submit" class="btn btn-default">Place hold</button>
490                                     [% END %]
491                                 [% END %]
492                             </fieldset>
493
494                             [% FOREACH bibitemloo IN bibitemloop %]
495                                 <ol>
496                                     [% UNLESS ( item_level_itypes ) %]
497                                         <li>
498                                             <span class="label">Item type:</span>
499                                             [% bibitemloo.description | html %]
500                                         </li>
501                                     [% END %]
502
503                                     [% IF ( bibitemloo.publicationyear ) %]
504                                         <li>
505                                             <span class="label">Publication year:</span>
506                                             [% bibitemloo.publicationyear | html %]
507                                         </li>
508                                     [% END %]
509                                 </ol>
510
511                                 <h2 style="padding: 0 1em;">
512                                     Place a hold on a specific item
513                                     [% IF bibitemloo.force_hold_level == 'item' %]
514                                          <span class="error"><i>(Required)</i></span>
515                                     [% END %]
516                                 </h2>
517
518                                 <table id="requestspecific">
519                                     <thead>
520                                         <tr>
521                                             <th>Hold</th>
522                                             [% IF ( item_level_itypes ) %]
523                                                 <th>Item type</th>
524                                             [% END %]
525                                             <th>Barcode</th>
526                                             <th>Home library</th>
527                                             <th>Last location</th>
528                                             [% IF itemdata_ccode %]
529                                                 <th>Collection</th>
530                                             [% END %]
531                                             <th>Call no.</th>
532                                             <th>Copy number</th>
533                                             [% IF itemdata_enumchron %]
534                                                 <th>Vol no.</th>
535                                             [% END %]
536                                             <th class="title-string">Information</th>
537                                             <th class="title-string">Allowed pickup locations</th>
538                                         </tr>
539                                     </thead>
540                                     <tbody>
541                                         [% SET selected = 0 %]
542                                         [% FOREACH itemloo IN bibitemloo.itemloop %]
543                                             [% UNLESS ( itemloo.hide ) %]
544                                                 <tr class="[% itemloo.backgroundcolor | html %]">
545                                                     <td>
546                                                         [% IF itemloo.force_hold_level == 'record' # Patron has placed a record level hold previously for this record %]
547                                                             <span class="error">
548                                                                 <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i>
549                                                                 Hold must be record level
550                                                             </span>
551                                                         [% ELSIF ( itemloo.available ) %]
552                                                             <input type="radio" name="checkitem" value="[% itemloo.itemnumber | html %]" />
553                                                         [% ELSIF ( itemloo.override ) %]
554                                                             <input type="radio" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber | html %]" />
555                                                             <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" title="Requires override of hold policy"/></i>
556                                                         [% ELSE %]
557                                                             <span class="error">
558                                                                 <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i>
559                                                                 [% IF itemloo.not_holdable %]
560                                                                     [% IF itemloo.not_holdable == 'damaged' %]
561                                                                         Item damaged
562                                                                     [% ELSIF itemloo.not_holdable == 'ageRestricted' %]
563                                                                         Age restricted
564                                                                     [% ELSIF itemloo.not_holdable == 'tooManyHoldsForThisRecord' %]
565                                                                         Exceeded max holds per record
566                                                                     [% ELSIF itemloo.not_holdable == 'tooManyReservesToday' %]
567                                                                         Daily hold limit reached for patron
568                                                                     [% ELSIF itemloo.not_holdable == 'tooManyReserves' %]
569                                                                         Too many holds
570                                                                     [% ELSIF itemloo.not_holdable == 'notReservable' %]
571                                                                         Not holdable
572                                                                     [% ELSIF itemloo.not_holdable == 'cannotReserveFromOtherBranches' %]
573                                                                         Patron is from different library
574                                                                     [% ELSIF itemloo.not_holdable == 'branchNotInHoldGroup' %]
575                                                                         Cannot place hold from patron's library
576                                                                     [% ELSIF itemloo.not_holdable == 'itemAlreadyOnHold' %]
577                                                                         Patron already has hold for this item
578                                                                     [% ELSIF itemloo.not_holdable == 'cannotBeTransferred' %]
579                                                                         Cannot be transferred to pickup library
580                                                                     [% ELSE %]
581                                                                         [% itemloo.not_holdable | html %]
582                                                                     [% END %]
583                                                                 [% END %]
584                                                             </span>
585                                                         [% END # /IF itemloo.force_hold_level %]
586                                                     </td>
587                                                     [% IF ( item_level_itypes ) %]
588                                                         <td>
589                                                             [% UNLESS ( noItemTypeImages ) %]
590                                                                 [% IF ( itemloo.imageurl ) %]<img src="[% itemloo.imageurl | html %]" alt="" /> <br /> [% END %]
591                                                             [% END %]
592                                                             [% itemloo.itypename | html %]
593                                                         </td>
594                                                     [% END %]
595                                                     <td>
596                                                         [% itemloo.barcode | html %]
597                                                     </td>
598                                                     <td>
599                                                         [% Branches.GetName( itemloo.homebranch ) | html %]
600                                                     </td>
601                                                     <td>
602                                                         [% Branches.GetName( itemloo.holdingbranch ) | html %]
603                                                     </td>
604                                                     [% IF itemdata_ccode %]
605                                                         <td>
606                                                             [% IF ( itemloo.ccode ) %][% AuthorisedValues.GetByCode( 'CCODE', itemloo.ccode ) | html %][% END %]
607                                                         </td>
608                                                     [% END %]
609                                                     <td>
610                                                         [% itemloo.itemcallnumber | html %]
611                                                     </td>
612                                                     <td>
613                                                         [% IF ( itemloo.copynumber ) %][% itemloo.copynumber | html %][% ELSE %]&nbsp;[% END %]
614                                                     </td>
615                                                     [% IF itemdata_enumchron %]
616                                                         <td>
617                                                             [% itemloo.enumchron | html %]
618                                                         </td>
619                                                     [% END %]
620                                                     <td>
621                                                         [% IF ( itemloo.onloan ) %]
622                                                             <span title="[% itemloo.date_due | html %]" class="checkedout">Due [% itemloo.date_due | $KohaDates  as_due_date => 1 %]</span>
623                                                         [% ELSE %]
624                                                             <span title="0000-00-00">
625                                                                 [% IF ( itemloo.transfertwhen ) %]
626                                                                     In transit from [% Branches.GetName( itemloo.transfertfrom ) | html %],
627                                                                     to [% Branches.GetName( itemloo.transfertto ) | html %], since [% itemloo.transfertwhen | html %]
628                                                                 [% END %]
629                                                             </span>
630                                                         [% END %]
631
632                                                         [% IF ( itemloo.reservedate ) %]
633                                                             [% IF ( itemloo.nocancel ) %]
634                                                                     Can't be cancelled when item is in transit
635                                                             [% ELSE %]
636                                                                 [% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
637                                                                 [% IF ( itemloo.canreservefromotherbranches ) %]
638                                                                     for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedFor.borrowernumber | uri %]">[% itemloo.ReservedFor.firstname | html %] [% itemloo.ReservedFor.surname | html %]</a>
639                                                                 [% END %]
640                                                                 [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %]
641                                                                 [% Branches.GetName( itemloo.ExpectedAtLibrary ) | html %] since
642                                                                 [% IF ( itemloo.waitingdate ) %]
643                                                                     [% itemloo.waitingdate | $KohaDates %]
644                                                                 [% ELSE %]
645                                                                     [% IF ( itemloo.reservedate ) %]
646                                                                         [% itemloo.reservedate | html %]
647                                                                     [% END %]
648                                                                 [% END %].
649                                                                 <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>
650                                                             [% END # /IF itemloo.nocancel %]
651                                                         [% ELSE %]
652                                                             Not on hold
653                                                         [% END # /IF itemloo.reservedate %]
654
655                                                         [% IF itemloo.item_level_holds == "N" %]
656                                                             <br/>Item level hold not allowed from OPAC
657                                                         [% ELSIF itemloo.item_level_holds == "F" %]
658                                                             <br/>Item level hold forced from OPAC
659                                                         [% END %]
660
661                                                         [% IF ( itemloo.itemlost ) %]
662                                                            <span class="lost">[% AuthorisedValues.GetByCode( 'LOST', itemloo.itemlost ) | html %]</span>
663                                                         [% END %]
664
665                                                         [% IF ( itemloo.damaged ) %]
666                                                             <span class="dmg">[% AuthorisedValues.GetByCode( 'DAMAGED', itemloo.damaged ) | html %]</span>
667                                                         [% END %]
668
669                                                         [% IF ( itemloo.withdrawn ) %]
670                                                            <span class="wdn">[% AuthorisedValues.GetByCode( 'WITHDRAWN', itemloo.withdrawn ) | html %]</span>
671                                                         [% END %]
672
673                                                         [% IF ( itemloo.notforloan ) %]
674                                                            <span class="nfl">Not for loan ([% AuthorisedValues.GetByCode( 'NOT_LOAN', itemloo.notforloan ) | html %])</span>
675                                                         [% END %]
676                                                     </td>
677                                                     <td>
678                                                         [% itemloo.pickup_locations | html %]
679                                                     </td>
680                                                 </tr>
681                                             [% END # / UNLESS itemloo.hide %]
682                                         [% END # /FOREACH itemloo %]
683                                     </tbody>
684                                 </table> <!-- /#requestspecific -->
685
686                                 [% IF ( bibitemloo.hiddencount ) %]
687                                     <form>
688                                         <p class="hiddencount">
689                                             <a href="request.pl?biblionumber=[% bibitemloo.biblionumber | uri %]&amp;borrowernumber=[% bibitemloo.borrowernumber | uri %]&amp;showallitems=1">Show all items ([% bibitemloo.hiddencount | html %] hidden)</a>
690                                         </p>
691                                     </form>
692                                 [% END # /IF bibitemloo.hiddencount %]
693                             [% END # /FOREACH bibitemloo %]
694
695                         [% ELSE # /UNLESS multi_hold %]
696
697                             <table id="requesttitles">
698                                 <tr>
699                                     <th>&nbsp;</th>
700                                     <th>Title</th>
701                                     [% UNLESS ( item_level_itypes ) %]
702                                         <th>Item type</th>
703                                     [% END %]
704                                     <th>Priority</th>
705                                     <th>Information</th>
706                                 </tr>
707                                 [% FOREACH biblioloo IN biblioloop %]
708                                     [% IF ( biblioloo.warn ) %]
709                                         <tr class="onissue">
710                                     [% ELSE %]
711                                         <tr>
712                                     [% END %]
713                                         <td>
714                                             [% UNLESS ( biblioloo.warn ) %]
715                                                     <input class="multi_hold_item_checkbox" type="checkbox" checked="checked" title="[% biblioloo.biblionumber | html %]"/>
716                                                 </td>
717                                             [% END %]
718                                         <td>
719                                             <ul>
720                                                 <li>
721                                                     <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">[% biblioloo.title | html %]</a>
722                                                 </li>
723                                                 [% IF ( biblioloo.publicationyear ) %]
724                                                     <li>
725                                                         <span class="label">Publication year:</span> [% biblioloo.publicationyear | html %]
726                                                     </li>
727                                                 [% END %]
728                                             </ul>
729                                             [% IF ( biblioloo.warn ) %]
730                                                 <span class="not_holdable" title="[% biblioloo.biblionumber | html %]"></span>
731                                             [% END %]
732                                         </td>
733                                         [% UNLESS ( item_level_itypes ) %]
734                                             <td>
735                                                 <img src="[% biblioloo.imageurl | html %]" alt="[% biblioloo.itypename | html %]" title="[% biblioloo.itypename | html %]" />
736                                             </td>
737                                         [% END %]
738                                         <td>[% biblioloo.rank | html %]</td>
739                                         <td>
740                                             [% IF ( biblioloo.checked_previously ) %]
741                                                 <span>Patron has previously checked out this title</span><br/>
742                                             [% END %]
743                                             [% IF ( biblioloo.alreadyres ) %]
744                                                 <ul>
745                                             [% ELSE %]
746                                                 [% IF ( biblioloo.none_avail ) %]
747                                                     <ul>
748                                                 [% END %]
749                                             [% END %]
750
751                                             [% IF ( biblioloo.alreadyres ) %]
752                                                 <li>
753                                                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>
754                                                     <strong>already has a hold</strong> on this item
755                                                 </li>
756                                             [% END %]
757                                             [% IF ( biblioloo.none_avail ) %]
758                                                 <li> <strong>No items are available</strong> to be placed on hold</li>
759                                             [% END %]
760
761                                             [% IF ( biblioloo.alreadyres ) %]
762                                                 </ul>
763                                             [% ELSE %]
764                                                 [% IF ( biblioloo.none_avail ) %]
765                                                     </ul>
766                                                 [% END %]
767                                             [% END %]
768                                         </td>
769                                     </tr>
770                                 [% END # /FOREACH biblioloo %]
771                             </table> <!-- /#requesttitles -->
772
773                         [% END # /UNLESS multi_hold %]
774
775                         <fieldset class="action">
776                             [% IF ( patron AND patron.borrowernumber ) %]
777                                 [% IF ( override_required ) %]
778                                     <button type="submit" class="btn btn-default warning"><i class="fa fa-exclamation-triangle "></i> Place hold</button>
779                                 [% ELSIF ( none_available ) %]
780                                     <button type="submit" disabled="disabled" class="btn btn-default btn-disabled">Place hold</button>
781                                 [% ELSE %]
782                                     [% IF ( multi_hold ) %]
783                                         <button type="submit" class="btn btn-default" id="multi_hold_submit">Place hold</button>
784                                     [% ELSE %]
785                                         <button type="submit" class="btn btn-default">Place hold</button>
786                                     [% END %]
787                                 [% END %]
788                             [% END # /IF patron %]
789                         </fieldset> <!-- /.action -->
790                     </form> <!-- /#hold-request-form -->
791                 </fieldset> <!-- /.rows -->
792             [% END %]
793
794             [% UNLESS ( patron ) %]
795                 [% IF ( reserveloop ) %]
796                     <form id="existing_holds" name="T[% time | html %]" action="modrequest.pl" method="post" style="display:block">
797                         [% IF ( multi_hold ) %]
798                             <input type = "hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
799                         [% END %]
800
801                         <h2>Existing holds</h2>
802                         <div id="toolbar" class="btn-toolbar">
803                             <input type="submit" name="submit" value="Update hold(s)" />
804                         </div>
805
806                         [% FOREACH biblioloo IN biblioloop %]
807                             [% IF ( biblioloo.reserveloop ) %]
808                                 [% IF ( multi_hold ) %]
809                                     <h3>
810                                         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">
811                                             [% biblioloo.title | html %]
812                                         </a>
813                                     </h3>
814                                 [% END %]
815
816                                 [% IF Koha.Preference('HoldsSplitQueue') == 'branch' %]
817                                     [% SET branchcodes = [] %]
818
819                                     [% FOREACH h IN biblioloo.reserveloop %]
820                                         [% branchcodes.push( h.branchcode ) %]
821                                     [% END %]
822                                     [% branchcodes = branchcodes.unique %]
823
824                                     [% FOREACH b IN branchcodes.sort %]
825                                         [% SET holds_by_branch = [] %]
826                                         [% FOREACH h IN biblioloo.reserveloop %]
827                                             [% IF h.branchcode == b %]
828                                                 [% holds_by_branch.push( h ) %]
829                                             [% END %]
830                                         [% END %]
831                                         <fieldset>
832                                             <legend>[% Branches.GetName( b ) | html %]</legend>
833                                             [% INCLUDE holds_table.inc holds=holds_by_branch %]
834                                         </fieldset>
835                                     [% END # /FOREACh b %]
836                                 [% ELSIF Koha.Preference('HoldsSplitQueue') == 'itemtype' %]
837                                     [% SET itemtypes = [] %]
838
839                                     [% FOREACH h IN biblioloo.reserveloop %]
840                                         [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
841                                         [% itemtypes.push( hold_itemtype ) %]
842                                     [% END %]
843                                     [% itemtypes = itemtypes.unique %]
844
845                                     [% FOREACH i IN itemtypes.sort %]
846                                         [% SET holds_by_itemtype = [] %]
847                                         [% FOREACH h IN biblioloo.reserveloop %]
848                                             [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
849                                             [% IF hold_itemtype == i %]
850                                                 [% holds_by_itemtype.push( h ) %]
851                                             [% END %]
852                                         [% END %]
853
854                                         <fieldset>
855                                             [% IF i %]
856                                                 <legend>[% ItemTypes.GetDescription( i ) | html %]</legend>
857                                             [% ELSE %]
858                                                 <legend>Any item type</legend>
859                                             [% END %]
860                                             [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
861                                         </fieldset>
862                                     [% END # /FOREACH i %]
863                                 [% ELSIF Koha.Preference('HoldsSplitQueue') == 'branch_itemtype' %]
864                                     [% SET branchcodes = [] %]
865
866                                     [% FOREACH h IN biblioloo.reserveloop %]
867                                         [% branchcodes.push( h.branchcode ) %]
868                                     [% END %]
869                                     [% branchcodes = branchcodes.unique %]
870
871                                     [% FOREACH b IN branchcodes.sort %]
872                                         <fieldset>
873                                             <legend>[% Branches.GetName( b ) | html %]</legend>
874                                             [% SET holds_by_branch = [] %]
875                                             [% FOREACH h IN biblioloo.reserveloop %]
876                                                 [% IF h.branchcode == b %]
877                                                     [% holds_by_branch.push( h ) %]
878                                                 [% END %]
879                                             [% END %]
880
881                                             [% SET itemtypes = [] %]
882                                             [% FOREACH h IN holds_by_branch %]
883                                                 [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
884                                                 [% itemtypes.push( hold_itemtype ) %]
885                                             [% END %]
886                                             [% itemtypes = itemtypes.unique %]
887
888                                             [% FOREACH i IN itemtypes.sort %]
889                                                 [% IF i %]
890                                                     <h3>[% ItemTypes.GetDescription( i ) | html %]</h3>
891                                                 [% ELSE %]
892                                                     <h3>Any item type</h3>
893                                                 [% END %]
894
895                                                 [% SET holds_by_itemtype = [] %]
896                                                 [% FOREACH h IN holds_by_branch %]
897                                                     [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
898                                                     [% IF hold_itemtype == i %]
899                                                         [% holds_by_itemtype.push( h ) %]
900                                                     [% END %]
901                                                 [% END %]
902                                                 [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
903                                             [% END %]
904                                         </fieldset>
905                                     [% END # /FOREACH b %]
906                                 [% ELSE %]
907                                     [% INCLUDE holds_table.inc holds=biblioloo.reserveloop %]
908                                 [% END # /IF HoldsSplitQueue %]
909
910                             [% END # /IF biblioloo.reserveloop %]
911                         [% END # FOREACH biblioloo %]
912                             <fieldset class="action">
913                                 [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
914                                 [% IF hold_cancellation %]
915                                     <label for="cancellation-reason">Cancellation reason: </label>
916                                     <select class="cancellation-reason" name="cancellation-reason" id="cancellation-reason">
917                                         <option value="">No reason given</option>
918                                         [% FOREACH reason IN hold_cancellation %]
919                                             <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
920                                         [% END %]
921                                     </select>
922                                 [% END %]
923                             </fieldset>
924
925                             <fieldset class="action">
926                                 <input type="submit" name="submit" value="Update hold(s)" />
927                             </fieldset>
928                         </fieldset> <!-- /.rows -->
929                     </form> <!-- /name=TTime -->
930                 [% END # IF reserveloop %]
931             [% END # UNLESS patron %]
932
933         </main>
934
935         [% IF ( multi_hold ) # No sidebar menu when placing multiple holds %]
936             </div> <!-- /.col-md-10.col-md-offset-1 -->
937         [% ELSE %]
938             </div> <!-- /.col-sm-10.col-sm-push-2 -->
939                 <div class="col-sm-2 col-sm-pull-10">
940                     <aside>
941                         [% INCLUDE 'biblio-view-menu.inc' %]
942                     </aside>
943                 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
944         [% END %]
945     </div> <!-- /.row -->
946
947
948 [% MACRO jsinclude BLOCK %]
949     [% INCLUDE 'datatables.inc' %]
950     [% INCLUDE 'calendar.inc' %]
951     [% INCLUDE 'columns_settings.inc' %]
952     [% Asset.js("lib/hc-sticky.js") | $raw %]
953     [% Asset.js("js/circ-patron-search-results.js") | $raw %]
954     <script>
955         var Sticky;
956         var biblionumber = "[% biblionumber | $raw %]";
957         var borrowernumber = "[% patron.borrowernumber | $raw %]";
958         var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
959         var REASON_LABEL = _("Reason: ");
960         var patron_homebranch = "[% To.json( Branches.GetName( patron.branchcode ) ) | $raw %]";
961         var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
962         [% itemloo.itemnumber | html %]: {
963             homebranch: "[% To.json( Branches.GetName( itemloo.homebranch ) ) | $raw %]";
964             holdallowed: [% itemloo.holdallowed | html %]
965             },
966             [% END %][% END %][% END %]
967         };
968         var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
969         var ERROR_MAP = {
970             damaged: _("Item damaged"),
971             ageRestricted: _("Age restricted"),
972             tooManyHoldsForThisRecord: _("Exceeded max holds per record"),
973             tooManyReservesToday: _("Daily hold limit reached for patron"),
974             tooManyReserves: _("Too many holds"),
975             notReservable: _("Not holdable"),
976             cannotReserveFromOtherBranches: _("Patron is from different library"),
977             itemAlreadyOnHold: _("Patron already has hold for this item"),
978             cannotBeTransferred: _("Cannot be transferred to pickup library")
979         }
980         columns_settings_borrowers_table = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]
981
982         $(document).ready(function() {
983             [% SET active = clubs ? 1 : 0 %]
984             $('#circ_holds_select').tabs({
985                 active: [% active | $raw %],
986                 activate: function(){
987                     $(this).find("input.focus").focus();
988                 },
989                 create: function(){
990                     $(this).find("input.focus").focus();
991                 }
992             });
993             function ToggleHoldsToPlace() {
994                 if ( $("#requestany").prop('checked') ) {
995                     $("#holds_to_place_count").prop('disabled', false);
996                 } else {
997                     $("#holds_to_place_count").prop('disabled', true);
998                 }
999             }
1000             ToggleHoldsToPlace();
1001             $("#requestany").on('change', function(){
1002                 ToggleHoldsToPlace();
1003             });
1004
1005             [% IF Koha.Preference('UseBranchTransferLimits') %]
1006                 $("#pickup").on('change', function(){
1007                     var pickup = $("#pickup").val();
1008                     var url = "?pickup=" + pickup;
1009                     url += "&borrowernumber=" + borrowernumber;
1010                     url += "&biblionumber=" + biblionumber;
1011                     window.location.replace(url);
1012                 });
1013             [% END %]
1014
1015             [% IF AutoResumeSuspendedHolds %]
1016                 $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
1017             [% END %]
1018
1019             $(".datepickerto").datepicker("option", "altField", ".datepickerto_hidden");
1020             $(".datepickerto").datepicker("option", "altFormat", "yy-mm-dd");
1021
1022             $(".datepickerfrom").datepicker("option", "altField", ".datepickerfrom_hidden");
1023             $(".datepickerfrom").datepicker("option", "altFormat", "yy-mm-dd");
1024
1025             var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
1026                 'bPaginate': false,
1027                 "sDom": '<"top pager"ilf>t',
1028                 "aoColumnDefs": [
1029                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
1030                 ]
1031             }));
1032
1033             //Override fieldset styling for dataTables search box
1034             $("div.top.pager").css("margin-left","1em");
1035             $(".dataTables_filter label").css({
1036                 "width":"auto",
1037                 "margin-right":"0em"
1038             });
1039
1040             $("#club-request-form").on("submit", function() {
1041                 let $t = $(this);
1042                 $('.clubalert, .holdalert').addClass('hide');
1043                 let biblionumbers = [biblionumber];
1044                 let biblionumbers_text;
1045                 const data = {
1046                     pickup_library_id: $('select[name="pickup"]').val()
1047                 };
1048                 if($('input[name="checkitem"]:checked').length)
1049                     data.item_id = $('input[name="checkitem"]:checked').val();
1050                 if($('input[name="borrowernumber"]').length)
1051                     data.patron_id = $('input[name="borrowernumber"]').val();
1052                 if($('textarea[name="notes"]').length)
1053                     data.notes = $('textarea[name="notes"]').val()||null;
1054                 if($('.datepickerto_hidden').length)
1055                     data.expiration_date = $('.datepickerto_hidden').val()||null;
1056                 if($('.datepickerfrom_hidden').length)
1057                     data.hold_date = $('.datepickerfrom_hidden').val()||null;
1058                 if($('input[name="itemtype"]').length) {
1059                     data.item_type = $('input[name="itemtype"]').val()||null;
1060                 }
1061                 if($('input[name="default_patron_home"]:checked').length) {
1062                     data.default_patron_home = 1;
1063                 }
1064                 if($('input[name="biblionumbers"]').length) {
1065                     biblionumbers_text = $('input[name="biblionumbers"]').val();
1066                     biblionumbers = biblionumbers_text.replace(/\/$/, '').split('/')
1067                 }
1068
1069                 const count = $('input[name="holds_to_place_count"]').length?$('input[name="holds_to_place_count"]').val():1;
1070                 biblionumbers.forEach(function(biblionumber) {
1071                     data.biblio_id = biblionumber;
1072                     let options = {
1073                         url: $t.attr('action'),
1074                         method: $t.attr('method').toUpperCase(),
1075                         contentType: 'application/json',
1076                         data: JSON.stringify(data)
1077                     };
1078                     for(let i = 0; i < count; i++) {
1079                         $.ajax(options)
1080                         .then(function(result) {
1081                             let url = 'request.pl?biblionumber='+biblionumber;
1082                             if(biblionumbers_text) {
1083                                 url = 'request.pl?biblionumbers='+biblionumbers_text;
1084                             }
1085                             document.location = url;
1086                         })
1087                         .fail(function(err) {
1088                             var message = err.responseJSON.error;
1089                             var match = err.responseJSON.error.match(/Reason: (\w+)\s*$/);
1090                             if(match && ERROR_MAP[match[1]]) {
1091                                 message = '<div><strong>'+_("Cannot place hold")+'</strong></div><div>'+ERROR_MAP[match[1]]+'</div>'
1092                             }
1093                             $('.clubalert, .holdalert').removeClass('hide').html(message);
1094                         });
1095                     }
1096                 });
1097
1098                 return false;
1099             });
1100
1101             [% UNLESS ( multi_hold ) %]
1102                 $("#hold-request-form").on("submit", function(){
1103                     return check();
1104                 });
1105             [% ELSE %]
1106                 $("#hold-request-form").on("submit", function(){
1107                     return checkMultiHold();
1108                 });
1109             [% END %]
1110
1111         });
1112
1113         function check() {
1114             var msg = "";
1115             var count_reserv = 0;
1116
1117             // check if we have checkitem form
1118             if (document.form.checkitem){
1119                 for (i=0;i<document.form.checkitem.length;i++){
1120                     if (document.form.checkitem[i].checked == true) {
1121                         count_reserv++ ;
1122                     }
1123                 }
1124                 // for only one item, check the checkitem without consider the loop checkitem
1125                 if (i==0){
1126                     if (document.form.checkitem.checked == true) {
1127                         count_reserv++;
1128                     }
1129                 }
1130             }
1131
1132             if (document.form.requestany.checked == true){
1133                 count_reserv++ ;
1134             }
1135
1136             if (count_reserv == "0"){
1137                 msg += (_("- Please select an item to place a hold") + "\n");
1138             }
1139
1140             if (msg == "") {
1141                 $('#hold-request-form').preventDoubleFormSubmit();
1142                 return(true);
1143             } else {
1144                 alert(msg);
1145                 return(false);
1146             }
1147         }
1148
1149         function checkMultiHold() {
1150             var spans = $(".multi_hold_item_checkbox:checked");
1151             if ($(spans).size() == 0) {
1152                 alert(MSG_NO_ITEMS_AVAILABLE);
1153                 return false;
1154             }
1155
1156             var biblionumbers = "";
1157             $(spans).each(function() {
1158                 var bibnum = $(this).attr("title");
1159                 biblionumbers += bibnum + "/";
1160             });
1161
1162             var badSpans = $(".not_holdable");
1163             var badBibs = "";
1164             $(badSpans).each(function() {
1165                 var bibnum = $(this).attr("title");
1166                 badBibs += bibnum + "/";
1167             });
1168
1169             $("#multi_hold_bibs").val(biblionumbers);
1170             $("#bad_bibs").val(badBibs);
1171
1172             $('#hold-request-form').preventDoubleFormSubmit();
1173
1174             return true;
1175         }
1176
1177          $(document).ready(function() {
1178             $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
1179                 var itemnumber = this.value;
1180                 var msg = '';
1181
1182                 switch (override_items[itemnumber].holdallowed) {
1183                     case 0: msg = _("This item normally cannot be put on hold."); break;
1184                     case 1: msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
1185                 }
1186
1187                 msg += "\n\n" + _("Place hold on this item?");
1188
1189                 return confirm(msg);
1190             });
1191             $("button.warning").click(function() {
1192                 return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
1193             });
1194             $("#requestany").click(function() {
1195                 if(this.checked){
1196                     $("input[name=checkitem]").each(function() {
1197                         $(this).prop("checked", false);
1198                     });
1199                 }
1200             });
1201             $("input[name=checkitem]").click(function() {
1202                 onechecked = 0;
1203                 $("input[name=checkitem]").each(function() {
1204                     if(this.checked){
1205                         onechecked = 1;
1206                     }
1207                 });
1208                 if(onechecked == 1){
1209                     $("#requestany").prop("checked", false);
1210                     $("#holds_to_place_count").prop('disabled', true);
1211                 } else {
1212                     $("#requestany").prop("checked",true);
1213                     $("#holds_to_place_count").prop('disabled', false);
1214                 }
1215             });
1216             var prev_rank_request;
1217             $("select[name=rank-request]").on("focus", function() {
1218                 prev_rank_request = $(this).val();
1219                 var row = $(this).parents("tr:first");
1220             }).change(function() {
1221                 var row = $(this).parents("tr:first");
1222                 var value = parseInt($(this).val());
1223                 var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found
1224                 if( !isNaN(value) ) {  //If moved to 'del'
1225                     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)
1226                     if (prev_rank_request > value) {
1227                         row.insertBefore(after);
1228                     } else {
1229                         row.insertAfter(after);
1230                     }
1231                 }
1232
1233                 var next_priority = 1;
1234                 $("select[name=rank-request]").each(function () {
1235                     if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds
1236                     $(this).val(next_priority);
1237                     next_priority++;
1238                 });
1239             });
1240
1241             $(".clear-date").on("click",function(e){
1242                 e.preventDefault();
1243                 var fieldID = this.id.replace("clear-date-","");
1244                 $("#" + fieldID).val("");
1245             });
1246
1247             // Confirm cancelation of hold
1248             $(".cancel-hold").on("click",function(e) {
1249                 e.preventDefault;
1250                 let msg = MSG_CONFIRM_DELETE_HOLD ;
1251                 if ( $("#cancellation-reason").val() ) {
1252                     const reason = $("#cancellation-reason option:selected").text();
1253                     msg += "\n\n" + REASON_LABEL + reason;
1254                 }
1255                 const confirm = confirmDelete(msg);
1256                 if ( confirm ) {
1257                     let href = $(this).attr('href');
1258                     href += "&cancellation-reason=" + $("#cancellation-reason").val();
1259                     window.location = href;
1260                 }
1261                 return false;
1262             });
1263
1264             [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems ) %]
1265                 [% IF ( PatronAutoComplete ) %]
1266                 $( "#patron" ).autocomplete({
1267                     source: "/cgi-bin/koha/circ/ysearch.pl",
1268                     minLength: 3,
1269                     select: function( event, ui ) {
1270                         $( "#patron" ).val( ui.item.cardnumber );
1271                         $( "#holds_patronsearch" ).submit();
1272                         return false;
1273                     }
1274                 })
1275                 .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
1276                     return $( "<li></li>" )
1277                     .data( "ui-autocomplete-item", item )
1278                     .append( "<a>" + item.surname + ", " + item.firstname +
1279                              " (" + item.cardnumber + ") <small>" + item.address +
1280                              " " + item.city + " " + item.zipcode + " " +
1281                              item.country + "</small></a>" )
1282                     .appendTo( ul );
1283                 };
1284                 [% END %]
1285             [% END %]
1286             Sticky = $("#toolbar");
1287             Sticky.hcSticky({
1288                 stickTo: "#existing_holds",
1289                 stickyClass: "floating"
1290             });
1291         });
1292     </script>
1293 [% END %]
1294
1295 [% INCLUDE 'intranet-bottom.inc' %]