Bug 22111: Format amount shown on place holds when maxoutstanding is reached (staff)
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reserve / request.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% USE Categories %]
7 [% USE ItemTypes %]
8 [% USE AuthorisedValues %]
9 [% USE Price %]
10 [% SET footerjs = 1 %]
11 [% INCLUDE 'doc-head-open.inc' %]
12 [% UNLESS ( multi_hold ) %]
13     <title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Place a hold on [% title | html %]</title>
14 [% ELSE %]
15     <title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Confirm holds</title>
16 [% END %]
17 [% INCLUDE 'doc-head-close.inc' %]
18 [% Asset.css("css/datatables.css") | $raw %]
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"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | html %]">[% title | html %]</a> &rsaquo; Place a hold on [% title | html %]</div>
27 [% ELSE %]
28     <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo; Confirm holds</div>
29 [% END %]
30
31  <div id="doc3" class="yui-t2">
32
33    <div id="bd">
34         <div id="yui-main">
35         <div class="yui-b">
36 [% IF ( noitems ) %]
37     <div class="dialog alert">
38     [%IF (multi_hold) %]
39         <strong>Cannot place hold:</strong> one or more records without items attached.
40     [% ELSE %]
41         <strong>Cannot place hold:</strong> this record has no items attached.
42     [% END %]
43     </div>
44 [% END %]
45
46   [% IF ( messagetransfert ) %]
47                 <div class="dialog message">
48                                 <h2>Hold found for ([% nextreservtitle | html %]), please transfer</h2>
49                         <p>Hold placed by : <strong> [% nextreservsurname | html %] [% nextreservfirstname | html %]</strong> at : <strong> [% branchname | html %] </strong>, Please transfer this item.
50                         </p>
51                         <form name="cancelReservewithtransfert" action="branchreserves.pl" method="post">
52                                 <input type="submit" class="button" />
53                         </form>
54                 </div>
55   [% END %]
56
57   [% UNLESS ( multi_hold ) %]
58     <h1>Place a hold on [% INCLUDE 'biblio-default-view.inc' %][% title | html %]</a></h1>
59   [% ELSE %]
60     <h1>Confirm holds</h1>
61   [% END %]
62
63   [% UNLESS patron OR patron.borrowernumber OR noitems %]
64     [% IF ( messageborrower ) %]
65       <div class="dialog alert"><h3>Patron not found</h3><p>No patron with this name, please, try another</p> </div>
66     [% END %]
67     <form  id="holds_patronsearch" action="request.pl?biblionumber=[% biblionumber | html %]" method="post">
68         <fieldset id="circ_holds_selectborrower" class="brief">
69
70         [% UNLESS borrowers %]
71                 <label for="patron">Patron: </label>
72                 <div class="hint">Enter patron card number or partial name:</div>
73                 <input type="text" size="40" id="patron" class="focus" name="findborrower" />
74                 <input type="submit" value="Search" />
75             [% IF multi_hold %]
76                 <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
77                 <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
78             [% ELSE %]
79                 <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
80             [% END %]
81             </fieldset>
82         [% ELSE %]
83             [% INCLUDE 'circ-patron-search-results.inc' destination = "holds" %]
84           </fieldset>
85
86         [% END %]
87         [% IF ( multi_hold ) %]
88             <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
89             <input type="hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
90         [% END %]
91     </form>
92   [% ELSIF NOT noitems %]
93
94 [% IF ( exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %]
95     <div class="dialog alert">
96
97     [% UNLESS ( multi_hold ) %]
98       <h3>Cannot place hold</h3>
99       <ul>
100         [% IF ( exceeded_maxreserves ) %]
101           <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>
102         [% ELSIF ( exceeded_holds_per_record ) %]
103           <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>
104         [% ELSIF ( alreadypossession ) %]
105           <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>
106         [% ELSIF ( alreadyreserved ) %]
107           <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>
108         [% ELSIF ( ageRestricted ) %]
109           <li><strong>Age restricted</strong></li>
110         [% ELSIF ( none_available ) %]
111           <li> <strong>No items are available</strong> to be placed on hold.</li>
112         [% ELSIF ( maxreserves ) %]
113           <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>
114         [% END %]
115       </ul>
116     [% ELSE %]
117         <h3>Cannot place hold on some items</h3>
118         [% IF ( exceeded_maxreserves ) %]
119           <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>
120         [% ELSIF ( exceeded_holds_per_record ) %]
121             [% FOREACH biblioloo IN biblioloop %]
122                 [% IF (biblioloo.tooManyHoldsForThisRecord) %]
123                     <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>
124                 [% END %]
125             [% END %]
126         [% END %]
127     [% END %]
128
129     </div>
130 [% END %]
131
132 [% IF ( expiry || diffbranch || patron.is_debarred || ( amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') ) ) %]
133 <div class="dialog message"><ul>
134     [% IF ( expiry ) %]
135     <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>
136     [% END %]
137
138     [% IF patron.is_debarred %]
139     <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>
140     [% END %]
141
142     [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
143     <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>
144     [% END %]
145
146     [% IF ( diffbranch ) %]
147     <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>
148     [% END %]
149
150 </ul></div>
151 [% END %]
152
153   [% IF ( messageborrower ) %]
154    <div class="dialog alert"><h3>Patron not found:</h3> <p>Name or barcode not found. Please try an other </p></div>
155   [% END %]
156
157   <fieldset class="rows left">
158     <legend>Hold details</legend>
159         [% UNLESS ( multi_hold ) %]
160             <form action="placerequest.pl" method="post" onsubmit="return check();" name="form" id="hold-request-form">
161         [% ELSE %]
162             <form action="placerequest.pl" method="post" onsubmit="return checkMultiHold();" name="form">
163         [% END %]
164
165         <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
166         <input type="hidden" name="type" value="str8" />
167
168         [% IF ( multi_hold ) %]
169             <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
170             <input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="[% biblionumbers | html %]"/>
171             <input type="hidden" name="bad_bibs" id="bad_bibs" value=""/>
172             <input type="hidden" name="request" value="any"/>
173             [% FOREACH biblioloo IN biblioloop %]
174               <input type="hidden" name="title_[% biblioloo.biblionumber | html %]" value="[% biblioloo.title | html %]"/>
175               <input type="hidden" name="rank_[% biblioloo.biblionumber | html %]" value="[% biblioloo.rank | html %]"/>
176             [% END %]
177         [% ELSE %]
178             <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
179             <input type="hidden" name="title" value="[% title | html %]" />
180             <input type="hidden" name="rank-request" value="[% fixedRank | html %]" />
181         [% END %]
182
183        <ol> <li><span class="label">Patron:</span>
184             [% IF ( patron.borrowernumber ) %]
185                 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %] ([% patron.cardnumber | html %])</a>
186             [% ELSE %]
187                 Not defined yet
188             [% END %]
189         </li>
190         [% UNLESS ( multi_hold ) %]
191           <li>
192               <span class="label">Estimated priority:</span>
193               <strong>[% fixedRank | html %]</strong>
194           </li>
195         [% END %]
196         <li>
197             <label for="holdnotes">Notes:</label>
198             <textarea id="holdnotes" name="notes" cols="30" rows="1"></textarea>
199         </li>
200         <li>
201             <label for="pickup">Pickup at:</label>
202             <select name="pickup" size="1" id="pickup">
203                 [% PROCESS options_for_libraries libraries => Branches.all({ search_params => { pickup_location => 1 } }) %]
204             </select>
205         </li>
206
207         [% UNLESS ( multi_hold ) %]
208             [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
209                 <li>
210                     <label for="itemtype">Request specific item type:</label>
211                     <select name="itemtype" size="1" id="itemtype">
212                         <option value="">Any item type</option>
213                         [%- FOREACH itemtype IN available_itemtypes %]
214                             <option value="[% itemtype | html %]">[% ItemTypes.GetDescription( itemtype ) | html %]</option>
215                         [%- END %]
216                     </select>
217                 </li>
218             [% END %]
219         [% END %]
220
221         [% IF ( reserve_in_future ) %]
222         <li>
223         <label for="from">Hold starts on date:</label>
224         <input name="reserve_date" id="from" size="10" class="datepickerfrom" type="text" >
225         <a href="#" id="clear-date-from" class="clear-date">Clear date</a>
226         </li>
227         [% END %]
228
229         <li>
230         <label for="to">Hold expires on date:</label>
231         <input name="expiration_date" id="to" size="10" class="datepickerto" type="text" />
232         <a href="#" id="clear-date-to" class="clear-date">Clear date</a>
233         </li>
234
235         [% UNLESS ( multi_hold ) %]
236           <li> <label for="requestany">Hold next available item </label>
237                [% IF force_hold_level == 'item' %]
238                    <input type="checkbox" id="requestany" name="request" disabled="true" />
239                [% ELSIF force_hold_level == 'record' %]
240                    <input type="checkbox" id="requestany" checked="checked" value="Any" disabled="true"/>
241                    <input type="hidden" name="request" value="Any"/>
242                [% ELSE %]
243                    <input type="checkbox" id="requestany" name="request" checked="checked" value="Any" />
244                 [% END %]
245                <input type="hidden" name="biblioitem" value="[% biblioitemnumber | html %]" />
246                <input type="hidden" name="alreadyreserved" value="[% alreadyreserved | html %]" />
247           </li>
248
249           [% IF remaining_holds_for_record > 1 %]
250               <li>
251                    <label for="holds_to_place_count">Holds to place (count)</label>
252                    <input type="number" name="holds_to_place_count" min="1" max="[% remaining_holds_for_record | html %]" step="1" value="1" />
253               </li>
254             [% ELSE %]
255                 <input type="hidden" name="holds_to_place_count" value="1" />
256             [% END %]
257         [% END %]
258
259 </ol>
260    [% UNLESS ( multi_hold ) %]
261         <fieldset class="action">
262             [% IF ( patron.borrowernumber ) %]
263                 [% IF ( override_required ) %]
264                     <input type="submit" class="warning" value="Place hold" />
265                 [% ELSIF ( none_available ) %]
266                     <input type="submit" disabled="disabled" value="Place hold" />
267                 [% ELSE %]
268                     <input type="submit" value="Place hold" />
269                 [% END %]
270             [% END %]
271         </fieldset>
272         [% FOREACH bibitemloo IN bibitemloop %]
273           <ol>
274             [% UNLESS ( item_level_itypes ) %]
275               <li><span class="label">Item type:</span> [% bibitemloo.description | html %]</li>
276             [% END %]
277
278             [% IF ( bibitemloo.publicationyear ) %]<li><span class="label">Publication year:</span> [% bibitemloo.publicationyear | html %]</li>[% END %]
279           </ol>
280
281         <h2 style="padding: 0 1em;">
282             Place a hold on a specific item
283             [% IF bibitemloo.force_hold_level == 'item' %]
284                 <span class="error"><i>(Required)</i></span>
285             [% END %]
286         </h2>
287         <table id="requestspecific">
288             <thead>
289                 <tr>
290                     <th>Hold</th>
291                 [% IF ( item_level_itypes ) %]
292                     <th>Item type</th>
293                 [% END %]
294                     <th>Barcode</th>
295                     <th>Home library</th>
296                     <th>Last location</th>
297                 [% IF itemdata_ccode %]
298                     <th>Collection</th>
299                 [% END %]
300                     <th>Call no.</th>
301                     <th>Copy number</th>
302                 [% IF itemdata_enumchron %]
303                     <th>Vol no.</th>
304                 [% END %]
305                     <th class="title-string">Information</th>
306                 </tr>
307             </thead>
308             <tbody>
309             [% SET selected = 0 %]
310             [% FOREACH itemloo IN bibitemloo.itemloop %]
311             [% UNLESS ( itemloo.hide ) %]
312                 <tr class="[% itemloo.backgroundcolor | html %]">
313                     <td>
314                 [% IF itemloo.force_hold_level == 'record' # Patron has placed a record level hold previously for this record %]
315                     <span class="error">
316                         <i class="fa fa-times fa-lg" alt="Cannot be put on hold"></i>
317                         Hold must be record level
318                     </span>
319                 [% ELSIF ( itemloo.available ) %]
320                     <input type="radio" name="checkitem" value="[% itemloo.itemnumber | html %]" />
321                 [% ELSIF ( itemloo.override ) %]
322                     <input type="radio" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber | html %]" />
323                     <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" alt="Requires override of hold policy"/></i>
324                 [% ELSE %]
325                     <span class="error">
326                         <i class="fa fa-times fa-lg" alt="Cannot be put on hold"></i>
327                         [% IF itemloo.not_holdable %]
328                             [% IF itemloo.not_holdable == 'damaged' %]
329                                 Item damaged
330                             [% ELSIF itemloo.not_holdable == 'ageRestricted' %]
331                                 Age restricted
332                             [% ELSIF itemloo.not_holdable == 'tooManyHoldsForThisRecord' %]
333                                 Exceeded max holds per record
334                             [% ELSIF itemloo.not_holdable == 'tooManyReservesToday' %]
335                                 Daily hold limit reached for patron
336                             [% ELSIF itemloo.not_holdable == 'tooManyReserves' %]
337                                 Too many holds
338                             [% ELSIF itemloo.not_holdable == 'notReservable' %]
339                                 Not holdable
340                             [% ELSIF itemloo.not_holdable == 'cannotReserveFromOtherBranches' %]
341                                 Patron is from different library
342                             [% ELSIF itemloo.not_holdable == 'itemAlreadyOnHold' %]
343                                 Patron already has hold for this item
344                             [% ELSE %]
345                                 [% itemloo.not_holdable | html %]
346                             [% END %]
347                         [% END %]
348                     </span>
349                 [% END %]
350                     </td>
351                 [% IF ( item_level_itypes ) %]
352                     <td>
353                     [% UNLESS ( noItemTypeImages ) %]
354                         [% IF ( itemloo.imageurl ) %]<img src="[% itemloo.imageurl | html %]" alt="" /> <br /> [% END %]
355                     [% END %]
356                         [% itemloo.itypename | html %]
357                     </td>
358                 [% END %]
359
360                     <td>
361                         [% itemloo.barcode | html %]
362                     </td>
363                     <td>
364                         [% Branches.GetName( itemloo.homebranch ) | html %]
365                     </td>
366                     <td>
367                         [% Branches.GetName( itemloo.holdingbranch ) | html %]
368                     </td>
369                 [% IF itemdata_ccode %]
370                     <td>
371                         [% IF ( itemloo.ccode ) %][% AuthorisedValues.GetByCode( 'CCODE', itemloo.ccode ) | html %][% END %]
372                     </td>
373                 [% END %]
374                     <td>
375                         [% itemloo.itemcallnumber | html %]
376                     </td>
377                     <td>
378                         [% IF ( itemloo.copynumber ) %][% itemloo.copynumber | html %][% ELSE %]&nbsp;[% END %]
379                     </td>
380                 [% IF itemdata_enumchron %]
381                     <td>
382                         [% itemloo.enumchron | html %]
383                     </td>
384                 [% END %]
385                     <td>
386                 [% IF ( itemloo.onloan ) %]
387                     <span title="[% itemloo.date_due | html %]" class="checkedout">Due [% itemloo.date_due | $KohaDates  as_due_date => 1 %]</span>
388                 [% ELSE %]
389                     <span title="0000-00-00">
390                         [% IF ( itemloo.transfertwhen ) %]
391                             In transit from [% Branches.GetName( itemloo.transfertfrom ) | html %],
392                             to [% Branches.GetName( itemloo.transfertto ) | html %], since [% itemloo.transfertwhen | html %]
393                         [% END %]
394                     </span>
395                 [% END %]
396                 [% IF ( itemloo.message ) %]
397                    Unavailable (lost or missing)
398                 [% END %]
399
400                 [% IF ( itemloo.notforloan ) %]
401                    Not for loan ([% itemloo.notforloanvalue | html %])
402                 [% END %]
403
404                 [% IF ( itemloo.reservedate ) %]
405                     [% IF ( itemloo.nocancel ) %]
406                             Can't be cancelled when item is in transit
407                     [% ELSE %]
408                     [% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
409                     [% IF ( itemloo.canreservefromotherbranches ) %]for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedFor.borrowernumber | uri %]">[% itemloo.ReservedFor.firstname | html %] [% itemloo.ReservedFor.surname | html %]</a>[% END %] [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %] [% Branches.GetName( itemloo.ExpectedAtLibrary ) | html %]
410                     since
411                     [% IF ( itemloo.waitingdate ) %][% itemloo.waitingdate | $KohaDates %][% ELSE %][% IF ( itemloo.reservedate ) %][% itemloo.reservedate | html %][% END %][% END %]. <a class="info" href="modrequest.pl?CancelBiblioNumber=[% itemloo.biblionumber | html %]&amp;CancelBorrowerNumber=[% itemloo.ReservedFor.borrowernumber | html %]&amp;CancelItemnumber=[% itemloo.itemnumber | html %]"  onclick="return confirmDelete(MSG_CONFIRM_DELETE_HOLD);">Cancel hold</a>
412
413                     [% END %]
414                 [% ELSE %]
415                     Not on hold
416                 [% END %]
417
418                 [% IF itemloo.item_level_holds == "N" %]
419                     <br/>Item level hold not allowed from OPAC
420                 [% ELSIF itemloo.item_level_holds == "F" %]
421                     <br/>Item level hold forced from OPAC
422                 [% END %]
423                 [% IF ( itemloo.damaged ) %]
424                     <br />Damaged
425                 [% END %]
426                     </td>
427                 </tr>
428             [% END %] <!--UNLESS item hide-->
429             [% END %] <!-- itemloop -->
430             </tbody>
431         </table>
432     [% IF ( bibitemloo.hiddencount ) %]
433         <form>
434         <p class="hiddencount"><a href="request.pl?biblionumber=[% bibitemloo.biblionumber | uri %]&amp;borrowernumber=[% bibitemloo.borrowernumber | uri %]&amp;showallitems=1">Show all items ([% bibitemloo.hiddencount | html %] hidden)</a></p>
435         </form>
436     [% END %] <!-- hiddencount -->
437     [% END %] <!-- bibitemloop -->
438
439   [% ELSE %]<!-- UNLESS multi_hold -->
440
441     <table id="requesttitles">
442       <tr>
443         <th>Title</th>
444         [% UNLESS ( item_level_itypes ) %]
445           <th>Item type</th>
446         [% END %]
447         <th>Priority</th>
448         <th>Information</th>
449       </tr>
450       [% FOREACH biblioloo IN biblioloop %]
451         [% IF ( biblioloo.warn ) %]
452           <tr class="onissue">
453         [% ELSE %]
454           <tr>
455         [% END %]
456           <td>
457             <ul>
458               <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">[% biblioloo.title | html %]</a></li>
459               [% IF ( biblioloo.publicationyear ) %]
460                 <li><span class="label">Publication year:</span> [% biblioloo.publicationyear | html %]</li>
461               [% END %]
462             </ul>
463             [% UNLESS ( biblioloo.warn ) %]
464               <span class="multi_hold_item" title="[% biblioloo.biblionumber | html %]"></span>
465             [% ELSE %]
466               <span class="not_holdable" title="[% biblioloo.biblionumber | html %]"></span>
467             [% END %]
468           </td>
469           [% UNLESS ( item_level_itypes ) %]
470             <td>
471               <img src="[% biblioloo.imageurl | html %]" alt="[% biblioloo.itypename | html %]" title="[% biblioloo.itypename | html %]" />
472             </td>
473           [% END %]
474             <td>[% biblioloo.rank | html %]</td>
475           <td>
476             [% IF ( biblioloo.alreadyres ) %]
477               <ul>
478             [% ELSE %]
479               [% IF ( biblioloo.none_avail ) %]
480                 <ul>
481               [% END %]
482             [% END %]
483
484           [% IF ( biblioloo.alreadyres ) %]
485               <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>
486           [% END %]
487           [% IF ( biblioloo.none_avail ) %]
488               <li> <strong>No items are available</strong> to be placed on hold</li>
489           [% END %]
490
491             [% IF ( biblioloo.alreadyres ) %]
492               </ul>
493             [% ELSE %]
494               [% IF ( biblioloo.none_avail ) %]
495                 </ul>
496               [% END %]
497             [% END %]
498
499           </td>
500         </tr>
501       [% END %]
502     </table>
503
504   [% END %]<!-- /multi_hold -->
505
506     <fieldset class="action">
507         [% IF ( patron AND patron.borrowernumber ) %]
508             [% IF ( override_required ) %]
509                 <input type="submit" class="warning" value="Place hold" />
510             [% ELSIF ( none_available ) %]
511                 <input type="submit" disabled="disabled" value="Place hold" />
512             [% ELSE %]
513                 <input type="submit" value="Place hold" />
514             [% END %]
515         [% END %]
516     </fieldset>
517     </form>
518         </fieldset>
519 [% END %]
520
521 [% UNLESS ( patron ) %]
522     [% IF ( reserveloop ) %]
523         <form name="T[% time | html %]" action="modrequest.pl" method="post">
524             [% IF ( multi_hold ) %]
525                 <input type = "hidden" name="multi_hold" value="1"/>
526                 <input type = "hidden" name="biblionumbers" value="[% biblionumbers | html %]"/>
527             [% END %]
528
529             <fieldset class="rows left">
530                 <legend>Existing holds</legend>
531
532                 [% FOREACH biblioloo IN biblioloop %]
533                     [% IF ( biblioloo.reserveloop ) %]
534                         [% IF ( multi_hold ) %]
535                             <h3>
536                                 <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]">
537                                     [% biblioloo.title | html %]
538                                 </a>
539                             </h3>
540                         [% END %]
541
542                         [% IF Koha.Preference('HoldsSplitQueue') == 'branch' %]
543                             [% SET branchcodes = [] %]
544
545                             [% FOREACH h IN biblioloo.reserveloop %]
546                                 [% branchcodes.push( h.branchcode ) | $raw %]
547                             [% END %]
548                             [% branchcodes = branchcodes.unique %]
549
550                             [% FOREACH b IN branchcodes.sort %]
551                                 [% SET holds_by_branch = [] %]
552                                 [% FOREACH h IN biblioloo.reserveloop %]
553                                     [% IF h.branchcode == b %]
554                                         [% holds_by_branch.push( h ) | $raw %]
555                                     [% END %]
556                                 [% END %]
557                                 <fieldset>
558                                     <legend>[% Branches.GetName( b ) | html %]</legend>
559                                     [% INCLUDE holds_table.inc holds=holds_by_branch %]
560                                 </fieldset>
561                             [% END %]
562                         [% ELSIF Koha.Preference('HoldsSplitQueue') == 'itemtype' %]
563                             [% SET itemtypes = [] %]
564
565                             [% FOREACH h IN biblioloo.reserveloop %]
566                                 [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
567                                 [% itemtypes.push( hold_itemtype ) | $raw %]
568                             [% END %]
569                             [% itemtypes = itemtypes.unique %]
570
571                             [% FOREACH i IN itemtypes.sort %]
572                                 [% SET holds_by_itemtype = [] %]
573                                 [% FOREACH h IN biblioloo.reserveloop %]
574                                     [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
575                                     [% IF hold_itemtype == i %]
576                                         [% holds_by_itemtype.push( h ) | $raw %]
577                                     [% END %]
578                                 [% END %]
579
580                                 <fieldset>
581                                     [% IF i %]
582                                         <legend>[% ItemTypes.GetDescription( i ) | html %]</legend>
583                                     [% ELSE %]
584                                         <legend>Any item type</legend>
585                                     [% END %]
586                                     [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
587                                 </fieldset>
588                             [% END %]
589                         [% ELSIF Koha.Preference('HoldsSplitQueue') == 'branch_itemtype' %]
590                             [% SET branchcodes = [] %]
591
592                             [% FOREACH h IN biblioloo.reserveloop %]
593                                 [% branchcodes.push( h.branchcode ) | $raw %]
594                             [% END %]
595                             [% branchcodes = branchcodes.unique %]
596
597                             [% FOREACH b IN branchcodes.sort %]
598                                 <fieldset class="contrast">
599                                     <legend>[% Branches.GetName( b ) | html %]</legend>
600                                     [% SET holds_by_branch = [] %]
601                                     [% FOREACH h IN biblioloo.reserveloop %]
602                                         [% IF h.branchcode == b %]
603                                             [% holds_by_branch.push( h ) | $raw %]
604                                         [% END %]
605                                     [% END %]
606
607                                     [% SET itemtypes = [] %]
608                                     [% FOREACH h IN holds_by_branch %]
609                                         [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
610                                         [% itemtypes.push( hold_itemtype ) | $raw %]
611                                     [% END %]
612                                     [% itemtypes = itemtypes.unique %]
613
614                                     [% FOREACH i IN itemtypes.sort %]
615                                         <fieldset class="standard">
616                                             [% IF i %]
617                                                 <legend>[% ItemTypes.GetDescription( i ) | html %]</legend>
618                                             [% ELSE %]
619                                                 <legend>Any item type</legend>
620                                             [% END %]
621
622                                             [% SET holds_by_itemtype = [] %]
623                                             [% FOREACH h IN holds_by_branch %]
624                                                 [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
625                                                 [% IF hold_itemtype == i %]
626                                                     [% holds_by_itemtype.push( h ) | $raw %]
627                                                 [% END %]
628                                             [% END %]
629                                             [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
630                                         </fieldset>
631                                     [% END %]
632                                 </fieldset>
633                             [% END %]
634                         [% ELSE %]
635                             [% INCLUDE holds_table.inc holds=biblioloo.reserveloop %]
636                         [% END %]
637
638                     [% END %]<!-- /reserveloop -->
639                 [% END %]<!-- /biblioloop -->
640
641                 <fieldset class="action">
642                     <input type="submit" name="submit" value="Update hold(s)" />
643                 </fieldset>
644             </fieldset>
645         </form>
646     [% END %]
647 [% END %]
648 </div>
649 </div>
650
651 <div class="yui-b">
652 [% UNLESS ( multi_hold ) %]
653   [% INCLUDE 'biblio-view-menu.inc' %]
654 [% END %]
655
656 </div>
657 </div>
658
659 [% MACRO jsinclude BLOCK %]
660     [% INCLUDE 'datatables.inc' %]
661     [% INCLUDE 'calendar.inc' %]
662     [% Asset.js("js/circ-patron-search-results.js") | $raw %]
663     <script>
664         var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
665         var patron_homebranch = "[% Branches.GetName( patron.branchcode ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html %]";
666         var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
667         [% itemloo.itemnumber | html %]: {
668             homebranch: "[% Branches.GetName( itemloo.homebranch ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html %]",
669             holdallowed: [% itemloo.holdallowed | html %]
670             },
671             [% END %][% END %][% END %]
672         };
673         var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
674
675         $(document).ready(function() {
676             function ToggleHoldsToPlace() {
677                 if ( $("#requestany").prop('checked') ) {
678                     $("#holds_to_place_count").prop('disabled', false);
679                 } else {
680                     $("#holds_to_place_count").prop('disabled', true);
681                 }
682             }
683             ToggleHoldsToPlace();
684             $("#requestany").on('change', function(){
685                 ToggleHoldsToPlace();
686             });
687
688             [% IF AutoResumeSuspendedHolds %]
689                 $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
690             [% END %]
691
692             var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
693                 'bPaginate': false,
694                 "sDom": '<"top pager"ilf>t',
695                 "aoColumnDefs": [
696                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
697                 ]
698             }));
699
700             //Override fieldset styling for dataTables search box
701             $("div.top.pager").css("margin-left","1em");
702             $(".dataTables_filter label").css({
703                 "width":"auto",
704                 "margin-right":"0em"
705             });
706
707         });
708
709         function check() {
710             var msg = "";
711             var count_reserv = 0;
712
713             // check if we have checkitem form
714             if (document.form.checkitem){
715                 for (i=0;i<document.form.checkitem.length;i++){
716                     if (document.form.checkitem[i].checked == true) {
717                         count_reserv++ ;
718                     }
719                 }
720                 // for only one item, check the checkitem without consider the loop checkitem
721                 if (i==0){
722                     if (document.form.checkitem.checked == true) {
723                         count_reserv++;
724                     }
725                 }
726             }
727
728             if (document.form.requestany.checked == true){
729                 count_reserv++ ;
730             }
731
732             if (count_reserv == "0"){
733                 msg += (_("- Please select an item to place a hold") + "\n");
734             }
735
736             if (msg == "") {
737                 $('#hold-request-form').preventDoubleFormSubmit();
738                 return(true);
739             } else {
740                 alert(msg);
741                 return(false);
742             }
743         }
744
745         function checkMultiHold() {
746             var spans = $(".multi_hold_item");
747             if ($(spans).size() == 0) {
748                 alert(MSG_NO_ITEMS_AVAILABLE);
749                 return false;
750             }
751
752             var biblionumbers = "";
753             $(spans).each(function() {
754                 var bibnum = $(this).attr("title");
755                 biblionumbers += bibnum + "/";
756             });
757
758             var badSpans = $(".not_holdable");
759             var badBibs = "";
760             $(badSpans).each(function() {
761                 var bibnum = $(this).attr("title");
762                 badBibs += bibnum + "/";
763             });
764
765             $("#multi_hold_bibs").val(biblionumbers);
766             $("#bad_bibs").val(badBibs);
767
768             $('#hold-request-form').preventDoubleFormSubmit();
769
770             return true;
771         }
772
773          $(document).ready(function() {
774             $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
775                 var itemnumber = this.value;
776                 var msg = '';
777
778                 switch (override_items[itemnumber].holdallowed) {
779                     case 0: msg = _("This item normally cannot be put on hold."); break;
780                     case 1: msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
781                 }
782
783                 msg += "\n\n" + _("Place hold on this item?");
784
785                 return confirm(msg);
786             });
787             $("input.warning").click(function() {
788                 return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
789             });
790             $("#requestany").click(function() {
791                 if(this.checked){
792                     $("input[name=checkitem]").each(function() {
793                         $(this).prop("checked", false);
794                     });
795                 }
796             });
797             $("input[name=checkitem]").click(function() {
798                 onechecked = 0;
799                 $("input[name=checkitem]").each(function() {
800                     if(this.checked){
801                         onechecked = 1;
802                     }
803                 });
804                 if(onechecked == 1){
805                     $("#requestany").prop("checked", false);
806                 } else {
807                     $("#requestany").prop("checked",true);
808                 }
809             });
810             var prev_rank_request;
811             $("select[name=rank-request]").on("focus", function() {
812                 prev_rank_request = $(this).val();
813                 var row = $(this).parents("tr:first");
814             }).change(function() {
815                 var row = $(this).parents("tr:first");
816                 var value = parseInt($(this).val());
817                 var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found
818                 if( !isNaN(value) ) {  //If moved to 'del'
819                     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)
820                     if (prev_rank_request > value) {
821                         row.insertBefore(after);
822                     } else {
823                         row.insertAfter(after);
824                     }
825                 }
826
827                 var next_priority = 1;
828                 $("select[name=rank-request]").each(function () {
829                     if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds
830                     $(this).val(next_priority);
831                     next_priority++;
832                 });
833             });
834
835             $(".clear-date").on("click",function(e){
836                 e.preventDefault();
837                 var fieldID = this.id.replace("clear-date-","");
838                 $("#" + fieldID).val("");
839             });
840
841             // Confirm cancelation of hold
842             $(".cancel-hold").on("click",function(e) {
843                 return confirmDelete(MSG_CONFIRM_DELETE_HOLD);
844             });
845
846             [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems ) %]
847                 [% IF ( CircAutocompl ) %]
848                 $( "#patron" ).autocomplete({
849                     source: "/cgi-bin/koha/circ/ysearch.pl",
850                     minLength: 3,
851                     select: function( event, ui ) {
852                         $( "#patron" ).val( ui.item.cardnumber );
853                         $( "#holds_patronsearch" ).submit();
854                         return false;
855                     }
856                 })
857                 .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
858                     return $( "<li></li>" )
859                     .data( "ui-autocomplete-item", item )
860                     .append( "<a>" + item.surname + ", " + item.firstname +
861                              " (" + item.cardnumber + ") <small>" + item.address +
862                              " " + item.city + " " + item.zipcode + " " +
863                              item.country + "</small></a>" )
864                     .appendTo( ul );
865                 };
866                 [% END %]
867             [% END %]
868
869         });
870     </script>
871 [% END %]
872
873 [% INCLUDE 'intranet-bottom.inc' %]