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