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