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