Bug 15533 [QA Followup] - All itemtypes for all items showing in OPAC multi-hold
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-reserve.tt
1 [% USE Koha %]
2 [% USE KohaDates %]
3 [% USE Price %]
4 [% USE ItemTypes %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Placing a hold</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 [% BLOCK cssinclude %][% END %]
9 </head>
10
11 [% INCLUDE 'bodytag.inc' bodyid='opac-holds' %]
12 [% INCLUDE 'masthead.inc' %]
13
14 <div class="main">
15     <ul class="breadcrumb">
16         <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
17         <li><a href="#">Placing a hold</a></li>
18     </ul>
19
20     <div class="container">
21         <div id="holds">
22             [% IF ( message ) %]
23                 <div id="holdmessages" class="alert">
24                     <p><strong>Sorry</strong>, you cannot place holds.</strong></p>
25                     <ul>
26                         [% IF ( GNA ) %]
27                             <li id="gna">
28                                 According to our records, we don't have up-to-date contact information. Please contact the library.
29                                 <a href="/cgi-bin/koha/opac-memberentry.pl">[% IF ( Koha.Preference('OPACPatronDetails') ) %]Update your contact information[% ELSE %]Go to your contact information[% END %]</a>
30                                 [% IF ( Koha.Preference('OPACPatronDetails') ) %]<em>(Please note: there may be a delay in restoring your account if you submit online.)</em>[% END %]
31                             </li>
32                         [% END %]
33
34                         [% IF ( lost ) %]
35                             <li id="lost">
36                                 Your library card has been marked as lost or stolen.<br />
37                                 <em>If this is an error, please take your card to the circulation desk at your local library and the error will be corrected.</em>
38                             </li>
39                         [% END %]
40
41                         [% IF ( debarred ) %]
42                             <li id="debarred">
43                                 Your account has been frozen.
44                                 [% IF debarred_comment %] Comment: <span id="userdebarred_comment">"[% debarred_comment %]"</span>[% END %]
45                                 [% IF debarred_date && debarred_date != '9999-12-31' %] End date: <span id="userdebarred_date">[% debarred_date | $KohaDates %]</span>[% END %]
46                                 <br /><em>Usually the reason for freezing an account is old overdues or damage fees. If shows your account to be clear, please contact the library.</em> <a href="/cgi-bin/koha/opac-account.pl">Go to your account page</a>
47                             </li>
48                         [% END %]
49
50                         [% IF ( too_much_oweing ) %]
51                             <li id="too_much_oweing">
52                                 You have unpaid fines. Amount: [% too_much_oweing | $Price %].
53                             </li>
54                         [% END %]
55
56                         [% IF ( too_many_reserves ) %]
57                             <li id="too_many_reserves">
58                                 Sorry, you cannot place more than [% too_many_reserves %] holds.
59                             </li>
60                         [% END %]
61
62                         [% IF ( bad_biblionumber ) %]
63                             <li id="bad_biblionumber">
64                                 ERROR: No record found for record id [% bad_biblionumber %].
65                             </li>
66                         [% END %]
67
68                         [% IF ( no_items_selected ) %]
69                             <li id="no_items_selected">
70                                 You must select at least one item.
71                             </li>
72                         [% END %]
73
74                         [% IF ( no_branch_selected ) %]
75                             <li id="no_branch_selected">
76                                 You must select a library for pickup.
77                             </li>
78                         [% END %]
79
80                         [% IF ( no_biblionumber ) %]
81                             <li id="no_biblionumber">
82                                ERROR: No record id specified.
83                            </li>
84                         [% END %]
85
86                         [% IF ( bad_data ) %]
87                             <li id="bad_data">
88                                 ERROR: Internal error: incomplete hold request.
89                             </li>
90                         [% END %]
91
92                         [% IF ( expired_patron ) %]
93                             <li id="expired_patron">
94                                 Your library card has expired. Please contact your librarian if you wish to renew your card.
95                             </li>
96                         [% END %]
97
98                     [% ELSE %]
99
100                         [% IF ( none_available ) %]
101                             <div id="none_available" class="alert">
102                                 <strong>Sorry</strong>, none of these items can be placed on hold.
103                             </div>
104                         [% END %]
105                 </div>
106             [% END # / IF message %]
107
108                     [% UNLESS ( message ) %]
109                         [% UNLESS ( none_available ) %]
110                             <h3>Confirm holds for:[% USER_INFO.firstname %] [% USER_INFO.surname %] ([% USER_INFO.cardnumber %])</h3>
111                         [% END # / UNLESS none_available %]
112
113                         [% IF (RESERVE_CHARGE) %]
114                             <div class="alert" id="reserve_fee">
115                                 There is a charge of [% RESERVE_CHARGE %] for placing this hold
116                             </div>
117                         [% END %]
118
119                         [% IF ( new_reserves_allowed ) %]
120                             <div id="new_reserves_allowed" class="alert">
121                                 <strong>Sorry,</strong> you can only place [% new_reserves_allowed %] more holds. Please uncheck the checkboxes for the items you wish to not place holds on.
122                             </div>
123                         [% END %]
124
125                         <form action="/cgi-bin/koha/opac-reserve.pl" method="post" id="hold-request-form">
126                             <input type="hidden" name="place_reserve" value="1"/>
127                             <!-- These values are set dynamically by js -->
128                             <input type="hidden" name="biblionumbers" id="biblionumbers"/>
129                             <input type="hidden" name="selecteditems" id="selections"/>
130                             <div id="bigloop">
131
132                                 [% FOREACH bibitemloo IN bibitemloop %]
133                                     <div class="holdrow">
134                                         <p>
135                                             [% IF ( bibitemloo.holdable ) %]
136                                                 <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
137                                                 <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber %]"/>
138                                                 <span class="confirmjs_hold" title="[% bibitemloo.biblionumber %]" style="padding:.3em"></span>
139                                                 <span class="confirm_nonjs">
140                                                     <input type="radio" class="confirmbox checkitem [% bibitemloo.biblionumber %]" name="[% bibitemloo.biblionumber %]" checked="checked" id="single_[% bibitemloo.biblionumber %]" value="any" />
141                                                     <label class="confirm_label" for="single_[% bibitemloo.biblionumber %]">Place a hold on </label>
142                                                 </span>
143                                             [% END # / bibitemloo.holdable %]
144
145                                             <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% bibitemloo.biblionumber %]">
146                                                 [% bibitemloo.title |html %]
147                                                 [% IF ( bibitemloo.subtitle ) %]
148                                                     [% FOREACH subtitl IN bibitemloo.subtitle %]
149                                                         [% subtitl.subfield %]
150                                                     [% END %]
151                                                 [% END %]
152                                             </a>
153                                             [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author %][% END %]
154                                         </p>
155
156                                         [% UNLESS ( bibitemloo.holdable ) %]
157                                             [% IF ( bibitemloo.ageRestricted ) %]
158                                                 <div class="alert">Sorry, you are too young to reserve this material.</div>
159                                             [% END %]
160                                             [% IF ( bibitemloo.already_reserved ) %]
161                                                 <div class="alert">You have already requested this title.</div>
162                                             [% ELSE %]
163                                                 [% UNLESS ( bibitemloo.bib_available ) %]
164                                                     <div class="alert">No available items.</div>
165                                                 [% ELSE %]
166                                                     [% IF ( bibitemloo.already_patron_possession ) %]
167                                                         <div class="alert">This title cannot be requested because it's already in your possession.</div>
168                                                     [% ELSE %]
169                                                         <div class="alert">This title cannot be requested.</div>
170                                                     [% END %]
171                                                 [% END # / UNLESS bibitemloo.bib_available %]
172                                             [% END # / IF bibitemloo.already_reserved %]
173                                         [% END # / UNLESS bibitemloo.holdable %]
174
175                                         [% IF ( bibitemloo.holdable ) %]
176                                             <fieldset class="rows">
177                                                 <ul>
178                                                     <!-- HOLDABLE -->
179                                                     [% UNLESS ( item_level_itypes ) %]
180                                                         <li class="itype">
181                                                             <span class="label">Item type: </span>
182                                                             [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl %]" alt="" />[% END %]
183                                                             [% bibitemloo.translated_description %]
184                                                         </li>
185                                                     [% END %]
186
187                                                     [% SET OPACShowHoldQueueDetails = Koha.Preference('OPACShowHoldQueueDetails') %]
188                                                     [% IF OPACShowHoldQueueDetails == 'holds_priority' || OPACShowHoldQueueDetails == 'priority' %]
189                                                         <li class="priority">
190                                                             <span class="label">Your priority: </span>
191                                                             [% bibitemloo.rank %]
192                                                         </li>
193                                                     [% END %]
194
195                                                     [% IF OPACShowHoldQueueDetails == 'holds_priority' || OPACShowHoldQueueDetails == 'holds' %]
196                                                         <li class="holds-count">
197                                                             <span class="label">Number of holds: </span>
198                                                             [% bibitemloo.reservecount %]
199                                                         </li>
200                                                     [% END %]
201
202
203                                                     [% UNLESS ( singleBranchMode ) %]
204                                                         [% IF ( bibitemloo.holdable && choose_branch ) %]
205                                                             <li class="branch">
206                                                                 <label for="branch_[% bibitemloo.biblionumber %]">Pick up location:</label>
207                                                                 [% UNLESS ( bibitemloo.holdable ) %]
208                                                                     <select name="branch" id="branch_[% bibitemloo.biblionumber %]" disabled="disabled">
209                                                                         [% FOREACH branchloo IN bibitemloo.branchloop %]
210                                                                             [% IF ( branchloo.selected ) %]
211                                                                                 <option value="[% branchloo.branchcode %]" selected="selected">[% branchloo.branchname %]</option>
212                                                                             [% ELSE %]
213                                                                                 <option value="[% branchloo.branchcode %]">[% branchloo.branchname %]</option>
214                                                                             [% END %]
215                                                                         [% END %]
216                                                                     </select>
217                                                                 [% ELSE %]
218                                                                     <select name="branch" id="branch_[% bibitemloo.biblionumber %]">
219                                                                         [% FOREACH branchloo IN bibitemloo.branchloop %]
220                                                                             [% IF ( branchloo.selected ) %]
221                                                                                 <option value="[% branchloo.branchcode %]" selected="selected">[% branchloo.branchname %]</option>
222                                                                             [% ELSE %]
223                                                                                 <option value="[% branchloo.branchcode %]">[% branchloo.branchname %]</option>
224                                                                             [% END %]
225                                                                         [% END %]
226                                                                     </select>
227                                                                 [% END # / UNLESS bibitemloo.holdable %]
228                                                             </li>
229                                                         [% END # / IF bibitemloo.holdable && choose_branch %]
230                                                     [% END # / UNLESS singleBranchMode %]
231                                                 </ul>
232
233                                                 <a class="toggle-hold-options" id="toggle-hold-options-[% bibitemloo.biblionumber %]" style="display:none;" href="#">Show more options</a>
234
235                                                 <div id="hold-options-[% bibitemloo.biblionumber %]" class="hold-options">
236
237                                                     <ul>
238                                                         [% IF ( reserve_in_future ) %]
239                                                             <li>
240                                                                 <label for="from[% bibitemloo.biblionumber %]">Hold starts on date:</label>
241                                                                 <input name="reserve_date_[% bibitemloo.biblionumber %]" id="from[% bibitemloo.biblionumber %]" size="10" class="holddatefrom"/>
242                                                                 <span class="date-format from" data-biblionumber="[% bibitemloo.biblionumber %]">[% INCLUDE 'date-format.inc' %]</span>
243                                                             </li>
244                                                         [% END %]
245
246                                                         <li>
247                                                             <label for="to[% bibitemloo.biblionumber %]">Hold not needed after:</label>
248                                                             <input name="expiration_date_[% bibitemloo.biblionumber %]" id="to[% bibitemloo.biblionumber %]" size="10" class="holddateto" />
249                                                             <span class="date-format to" data-biblionumber="[% bibitemloo.biblionumber %]">[% INCLUDE 'date-format.inc' %]</span>
250                                                         </li>
251
252                                                         [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
253                                                             [% itemtypes = [] %]
254                                                             [% FOREACH item IN bibitemloo.itemLoop %]
255                                                                 [% itemtypes.push( item.itype ) %]
256                                                             [%- END %]
257                                                             <li>
258                                                                 <label for="itemtype">Request specific item type:</label>
259                                                                 <select name="itemtype" size="1" id="itemtype">
260                                                                     <option value="">Any item type</option>
261                                                                     [% FOREACH i IN itemtypes.unique.sort %]
262                                                                         <option value="[% i %]">[% ItemTypes.GetDescription( i ) %]</option>
263                                                                     [%- END %]
264                                                                 </select>
265                                                             </li>
266                                                         [% END %]
267
268                                                         [% IF ( OpacHoldNotes ) %]
269                                                             <li>
270                                                                 <div class="notesrow" id="notesrow_[% bibitemloo.biblionumber %]">
271                                                                     <label for="holdnotes[% bibitemloo.biblionumber %]">Hold notes:</label>
272                                                                     <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span>
273                                                                     <textarea id="holdnotes[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea>
274                                                                     <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/>
275                                                                 </div>
276                                                             </li>
277                                                         [% END # / IF OpacHoldNotes %]
278
279                                                         <li>
280                                                         </li>
281                                                         [% IF bibitemloo.itemholdable %]
282                                                             <!-- ITEM HOLDS -->
283                                                             <li class="lradio place_on_type" style="display:none;">
284                                                                 [% IF NOT bibitemloo.force_hold %]
285                                                                     <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
286                                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
287                                                                             id="reqany_[% bibitemloo.biblionumber %]"
288                                                                             class="selectany"
289                                                                             value="Any"
290                                                                             checked="checked"
291                                                                     />
292                                                                 [% END %]
293                                                                 <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label>
294                                                                 <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
295                                                                        id="reqspecific_[% bibitemloo.biblionumber %]"
296                                                                        class="selectspecific"
297                                                                        value="Specific"
298                                                                 />
299                                                             </li>
300                                                         [% END # / IF bibitemloo.itemholdable %]
301                                                     </ul>
302
303                                                     [% IF bibitemloo.itemholdable %]
304                                                         <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]">
305                                                             <caption>Select a specific item:</caption>
306                                                             <tr>
307                                                                 <th>Copy number</th>
308                                                                 [% IF ( item_level_itypes ) %]
309                                                                     <th>Item type</th>
310                                                                 [% END %]
311                                                                 <th>Barcode</th>
312                                                                 [% UNLESS ( singleBranchMode ) %]
313                                                                     <th>Home library</th>
314                                                                     <th>Last location</th>
315                                                                 [% END %]
316                                                                 <th>Call number</th>
317                                                                 [% IF ( itemdata_enumchron ) %]
318                                                                     <th>Vol info</th>
319                                                                 [% END %]
320                                                                 <th>Information</th>
321                                                             </tr>
322
323                                                             [% FOREACH itemLoo IN bibitemloo.itemLoop %]
324                                                                 <tr class="[% itemLoo.backgroundcolor %]">
325                                                                     <td class="copynumber">
326                                                                         [% IF ( itemLoo.available ) %]
327                                                                             <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber %]" name="checkitem_[% bibitemloo.biblionumber %]" value="[% itemLoo.itemnumber %]" />
328                                                                         [% ELSE %]
329                                                                             <input disabled="disabled" type="radio" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber %]"
330                                                                                    style="display:none;" />
331                                                                             <img src="[% interface %]/lib/famfamfam/silk/cross.png" alt="Cannot be put on hold" title="Cannot be put on hold" />
332                                                                         [% END %]
333
334                                                                         [% IF ( itemLoo.copynumber ) %]
335                                                                             [% itemLoo.copynumber %]
336                                                                         [% END %]
337                                                                     </td>
338
339                                                                     [% IF ( item_level_itypes ) %]
340                                                                         <td class="itype">
341                                                                             [% UNLESS ( noItemTypeImages ) %]
342                                                                                 [% IF ( itemLoo.imageurl ) %]
343                                                                                     <img src="[% itemLoo.imageurl %]" alt="" />
344                                                                                 [% END %]
345                                                                             [% END %]
346                                                                             [% itemLoo.translated_description %]
347                                                                         </td>
348                                                                     [% END %]
349
350                                                                     <td class="barcode">[% itemLoo.barcode %]</td>
351                                                                     [% UNLESS ( singleBranchMode ) %]
352                                                                         <td class="homebranch">[% itemLoo.homeBranchName %]</td>
353                                                                         <td class="holdingbranch">[% itemLoo.holdingBranchName %]</td>
354                                                                     [% END %]
355                                                                     <td class="call_no">[% itemLoo.callNumber %]</td>
356                                                                     [% IF ( itemdata_enumchron ) %]
357                                                                         <td class="vol_info">[% itemLoo.enumchron %]</td>
358                                                                     [% END %]
359                                                                     <td class="information">
360                                                                         [% IF ( itemLoo.dateDue ) %]
361                                                                             <span class="checkedout">Due [% itemLoo.dateDue %]</span>
362                                                                         [% ELSIF ( itemLoo.transfertwhen ) %]
363                                                                             <span class="intransit">In transit from [% itemLoo.transfertfrom %] to [% itemLoo.transfertto %] since [% itemLoo.transfertwhen %]</span>
364                                                                         [% END %]
365
366                                                                         [% IF ( itemLoo.message ) %]
367                                                                             <span class="lost">Unavailable (lost or missing)</span>
368                                                                         [% END %]
369
370                                                                         [% IF ( itemLoo.notforloan ) %]
371                                                                             <span class="notforloan">Not for loan ([% itemLoo.notforloanvalue %])</span>
372                                                                         [% END %]
373
374                                                                         [% IF ( itemLoo.reservedate ) %]
375                                                                             <span class="waiting">
376                                                                                 [% IF ( itemLoo.waitingdate ) %]
377                                                                                     Waiting
378                                                                                 [% ELSE %]
379                                                                                     On hold
380                                                                                 [% END %]
381                                                                                 for patron
382                                                                                 [% IF ( itemLoo.waitingdate ) %]
383                                                                                     at
384                                                                                 [% ELSE %]
385                                                                                     expected at
386                                                                                 [% END %]
387                                                                                 [% itemLoo.ExpectedAtLibrary %] since
388                                                                                 [% IF ( itemLoo.waitingdate ) %]
389                                                                                     [% itemLoo.waitingdate | $KohaDates %]
390                                                                                 [% ELSE %]
391                                                                                     [% IF ( itemLoo.reservedate ) %]
392                                                                                         [% itemLoo.reservedate %]
393                                                                                     [% END %]
394                                                                                 [% END %].
395                                                                             </span>
396                                                                         [% ELSE %]
397                                                                             <span class="notonhold">Not on hold</span>
398                                                                         [% END # / IF ( itemLoo.reservedate )%]
399                                                                     </td>
400                                                                 </tr>
401                                                             [% END # / FOREACH itemLoo IN bibitemloo.itemLoop%]
402                                                         </table> <!-- / #copiesrow_[% bibitemloo.biblionumber %] -->
403                                                     [% END # / IF ( bibitemloo.itemholdable )%]
404                                                 </div> <!-- / #hold-options-[% bibitemloo.biblionumber %] -->
405                                             </fieldset>
406                                         [% END # / IF ( bibitemloo.holdable ) %]
407                                     </div> <!-- / .holdrow -->
408                                 [% END # / FOREACH bibitemloo IN bibitemloop %]
409                             </div><!-- #bigloop -->
410
411                             [% UNLESS ( none_available ) %]
412                                 <input type="submit" value="Place hold" class="btn placehold" />
413                             [% END %]
414
415                         </form>
416                     [% END # / UNLESS message %]
417                 </div> <!-- / #holds -->
418     </div> <!-- / .container -->
419 </div> <!-- / .main -->
420 [% INCLUDE 'opac-bottom.inc' %]
421 [% BLOCK jsinclude %]
422 [% INCLUDE 'calendar.inc' %]
423 <script type="text/javascript">
424 // <![CDATA[
425     var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
426     var ForceHoldNotesReasons=new Array(
427        _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific item information may be helpful."),
428        "*** Add a new reason above this line ***" );
429        // NOTE: Do not renumber reasons; this will affect use of existing ones.
430
431         // Clear the contents of an input field
432         $(".clearfield").on("click",function(e){
433             $(this).closest("td").find("input").val("");
434             e.preventDefault();
435         });
436
437     // Select the first item available
438     function select_first_available(id){
439         var radios = $("input:radio[name='checkitem_" + id + "']");
440         $(radios).first().attr("checked", "checked");
441     }
442
443     $(document).ready(function() {
444         $("#hold-request-form").preventDoubleFormSubmit();
445         var copiesRowId = null;
446         var wasSpecific = false;
447         var lastCopiesRowId = null;
448
449         $(".toggle-hold-options").show();
450         $(".hold-options").hide();
451         $(".holddatefrom,.holddateto").prop("readOnly", true);
452
453         $(".checkitem").parent().click(function(e){
454             if(e.target.tagName.toLowerCase() == 'td'){
455                 $(this).find("input.checkitem").each( function() {
456                     $(this).attr('checked', 'checked');
457                 });
458             }
459         });
460
461         // click on a first td check the confirmjs checkbox
462         $("td.hold").click(function(e){
463           if(e.target.tagName.toLowerCase() == 'td'){
464             $(this).find("input.confirmjs").each( function() {
465                $(this).attr('checked', !$(this).attr('checked'));
466                $(this).change();
467             });
468           }
469         });
470
471         $(".toggle-hold-options").on("click",function(e){
472             e.preventDefault();
473             toggleLink = $(this);
474             var optionsID = this.id.replace("toggle-hold-options-","");
475             $("#hold-options-"+optionsID).toggle(0, function() {
476                 toggleLink.text($(this).is(':visible') ? _("Hide options") : _("Show more options"));
477             });
478         });
479
480         // Hides all 'specific copy' table rows on load.
481         $(".copiesrow").hide();
482
483         [% FOREACH bibitemloo IN bibitemloop %]
484           [% IF bibitemloo.force_hold %]
485             $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
486             $("#reqspecific_[% bibitemloo.biblionumber %]").click();
487             $("#copiesrow_[% bibitemloo.biblionumber %]").show();
488           [% END %]
489         [% END %]
490
491         // Insert reasons for forced hold notes
492         $(".forcenotesreason").each(function(){
493             biblioNum = suffixOf($(this).attr("id"), "_");
494             var j=$("#notesmandatory_"+biblioNum).val();
495             if(j>0) {
496                 $(this).html(ForceHoldNotesReasons[j-1]);
497             }
498         });
499
500         $(".date-format").each(function(){
501             if($(this).hasClass("to")){ var op = "to"; }
502             if($(this).hasClass("from")){ var op = "from"; }
503             var bibNum = $(this).data("biblionumber");
504             $(this).html("<a href=\"#\" class=\"clear-date\" data-op=\"" + op + "\" id=\"clear" + bibNum + "\">" + _("Clear date") + "</a>");
505         });
506
507         $(".clear-date").on("click",function(e){
508             e.preventDefault();
509             var fieldID = this.id.replace("clear","");
510             var op = $(this).data("op");
511             $("#" + op + fieldID).val("");
512         });
513
514         // Replace non-JS single-selection with multi-selection capability.
515         $(".reserve_mode").val("multi");
516         $(".confirm_nonjs").remove();
517         $(".confirmjs_hold").each(function(){
518             var bib = $(this).attr("title");
519             var html = "<label><input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
520             html += "value=\"" + bib + "\" id=\"" + bib + "\" /> " + _("Place a hold on") + " </label> ";
521             $(this).html(html);
522         });
523         $(".confirmjs_nohold").each(function(){
524             var bib = $(this).attr("title");
525             var html = "<label><input type =\"checkbox\" class=\"confirmjs\" disabled=\"disabled\"";
526             html += "value=\"" + bib + "\" id=\"" + bib + "\" />" + _("Place a hold on: ") + "</label>";
527             $(this).html(html);
528         });
529
530         // expand or collapse the copiesrow tr
531         function toggle_copiesrow(biblioNum) {
532             var checkbox = $("input:checkbox[value='"+biblioNum+"']");
533             newCopiesRowId = "#copiesrow_" + biblioNum;
534             var select_specific = $("#reqspecific_"+biblioNum).is(":checked");
535             // If the checkbox is checked AND we want a specific item, we display the items block
536             if ( $(checkbox).is(":checked") && select_specific ) {
537                 $(newCopiesRowId).show();
538             } else {
539                 $(newCopiesRowId).hide();
540              }
541         };
542
543         $("#place_on_hdr").show();
544
545         $(".place_on_type").show();
546         // onload, selectany is checked
547         $(".selectany").attr("checked", "checked");
548
549         // If the user is *allowed* to choose a specific item
550         // The first one is preselected
551         $("table.copiesrow").each(function(){
552             var id = suffixOf($(this).attr("id"), "_");
553             select_first_available(id);
554         });
555
556         // On confirmsjs change
557         $(".confirmjs").change(function(){
558             var id = suffixOf($(this).attr("id"), "_");
559             // If I m checked, I enable radio buttons
560             if ( $(this).is(":checked") ) {
561                 $("#reqspecific_" + id).attr("disabled", false);
562                 $("#reqany_" + id).attr("disabled", false);
563             }
564             // Else its are disabled
565             else {
566                 $("#reqspecific_" + id).attr("disabled", "disabled");
567                 $("#reqany_" + id).attr("disabled", "disabled");
568             }
569             // expand or collaspe the items block
570             toggle_copiesrow(id);
571         });
572
573         // When 'specific copy' or 'first available' radio button is clicked
574         $(".selectspecific, .selectany").click(function() {
575             var id = suffixOf($(this).attr("id"), "_");
576             toggle_copiesrow(id);
577         });
578
579         // Show or hide holds notes
580         $(".shownotes").click(function(){
581             biblioNum = suffixOf($(this).attr("id"), "_");
582             $("#notesrow_"+biblioNum).toggle();
583         });
584
585         // When 'Place Hold' button is clicked
586         $(".placehold").click(function(){
587             var biblionumbers = "";
588             var selections = "";
589
590             [% IF new_reserves_allowed %]
591                 if ($(".confirmjs:checked").size() > [% new_reserves_allowed %] ) {
592                     alert(MSG_MAX_HOLDS_EXCEEDED);
593                     return false;
594                 }
595             [% END %]
596
597             if ($(".confirmjs:checked").size() == 0) {
598                 alert(MSG_NO_RECORD_SELECTED);
599                 return false;
600             }
601
602             // Find the items with the 'Hold' box checked
603             var badBib = null;
604             $(".confirmjs:checked").each(function() {
605                 var biblioNum = $(this).val();
606                 biblionumbers += biblioNum + "/";
607                 selections += biblioNum + "/";
608
609                 // If the 'specific copy' radio button is checked
610                 if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
611                     // Find the selected copy
612                     var item = $(".checkitem_" + biblioNum + ":checked");
613                     if ($(item).size() == 0) {
614                         badBib = biblioNum;
615                         return false;
616                     } else {
617                       selections += $(item).val();
618                     }
619                 }
620                 selections += "/";
621
622                 // Add the pickup location
623                 var branchSel = $("#branch_" + biblioNum);
624                 if (branchSel.size() > 0) {
625                     selections += $(branchSel).val();
626                 }
627                 selections += "/";
628                 return true;
629             });
630
631             if (badBib) {
632                 alert(MSG_NO_ITEM_SELECTED);
633                 return false;
634             }
635
636             $("#selections").val(selections);
637             $("#biblionumbers").val(biblionumbers);
638
639             return true;
640         });
641
642         [% FOREACH bibitemloo IN bibitemloop %]
643             [% IF ( bibitemloo.holdable ) %]
644                 // http://jqueryui.com/demos/datepicker/#date-range
645                 var dates[% bibitemloo.biblionumber %] = $( "#from[% bibitemloo.biblionumber %], #to[% bibitemloo.biblionumber %]" ).datepicker({
646                     minDate: 0,
647                     changeMonth: true,
648                     numberOfMonths: 1,
649                     onSelect: function( selectedDate ) {
650                         var option = this.id == "from[% bibitemloo.biblionumber %]" ? "minDate" : "maxDate",
651                             instance = $( this ).data( "datepicker" );
652                             date = $.datepicker.parseDate(
653                                 instance.settings.dateFormat ||
654                                 $.datepicker._defaults.dateFormat,
655                                 selectedDate, instance.settings );
656                         dates[% bibitemloo.biblionumber %].not( this ).datepicker( "option", option, date );
657                     }
658                 });
659             [% END %]
660         [% END %]
661
662  });
663 // ]]>
664 </script>
665 [% END %]