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