Bug 12162 - Add class="branchcode" to body tag to make OPAC CSS-styleable per branch
[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 [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Placing a hold
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.already_reserved ) %]
147                                                 <div class="alert">You have already requested this title.</div>
148                                             [% ELSE %]
149                                                 [% UNLESS ( bibitemloo.bib_available ) %]
150                                                     <div class="alert">No available items.</div>
151                                                 [% ELSE %]
152                                                     [% IF ( bibitemloo.already_patron_possession ) %]
153                                                         <div class="alert">This title cannot be requested because it's already in your possession.</div>
154                                                     [% ELSE %]
155                                                         <div class="alert">This title cannot be requested.</div>
156                                                     [% END %]
157                                                 [% END # / UNLESS bibitemloo.bib_available %]
158                                             [% END # / IF bibitemloo.already_reserved %]
159                                         [% END # / UNLESS bibitemloo.holdable %]
160
161                                         [% IF ( bibitemloo.holdable ) %]
162                                             <fieldset class="rows">
163                                                 <ul>
164                                                     <!-- HOLDABLE -->
165                                                     [% UNLESS ( item_level_itypes ) %]
166                                                         <li class="itype">
167                                                             <span class="label">Item type: </span>
168                                                             [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl %]" alt="" />[% END %]
169                                                             [% bibitemloo.description %]
170                                                         </li>
171                                                     [% END %]
172
173                                                     [% IF showholds || showpriority %]
174                                                         <li class="priority">
175                                                             <span class="label">Holds and priority: </span>
176                                                             [% IF showpriority %] [% bibitemloo.rank %] [% END %]
177                                                             [% IF showholds && showpriority %] out of [% END %]
178                                                             [% IF showholds %] [% bibitemloo.reservecount %] [% END %]
179                                                         </li>
180                                                     [% END %]
181
182
183                                                     [% UNLESS ( singleBranchMode ) %]
184                                                         [% IF ( bibitemloo.holdable && choose_branch ) %]
185                                                             <li class="branch">
186                                                                 <label for="branch_[% bibitemloo.biblionumber %]">Pick up location:</label>
187                                                                 [% UNLESS ( bibitemloo.holdable ) %]
188                                                                     <select name="branch" id="branch_[% bibitemloo.biblionumber %]" disabled="disabled">
189                                                                         [% FOREACH branchloo IN bibitemloo.branchloop %]
190                                                                             [% IF ( branchloo.selected ) %]
191                                                                                 <option value="[% branchloo.branchcode %]" selected="selected">[% branchloo.branchname %]</option>
192                                                                             [% ELSE %]
193                                                                                 <option value="[% branchloo.branchcode %]">[% branchloo.branchname %]</option>
194                                                                             [% END %]
195                                                                         [% END %]
196                                                                     </select>
197                                                                 [% ELSE %]
198                                                                     <select name="branch" id="branch_[% bibitemloo.biblionumber %]">
199                                                                         [% FOREACH branchloo IN bibitemloo.branchloop %]
200                                                                             [% IF ( branchloo.selected ) %]
201                                                                                 <option value="[% branchloo.branchcode %]" selected="selected">[% branchloo.branchname %]</option>
202                                                                             [% ELSE %]
203                                                                                 <option value="[% branchloo.branchcode %]">[% branchloo.branchname %]</option>
204                                                                             [% END %]
205                                                                         [% END %]
206                                                                     </select>
207                                                                 [% END # / UNLESS bibitemloo.holdable %]
208                                                             </li>
209                                                         [% END # / IF bibitemloo.holdable && choose_branch %]
210                                                     [% END # / UNLESS singleBranchMode %]
211                                                 </ul>
212
213                                                 <a class="toggle-hold-options" id="toggle-hold-options-[% bibitemloo.biblionumber %]" style="display:none;" href="#">Show more options</a>
214
215                                                 <div id="hold-options-[% bibitemloo.biblionumber %]" class="hold-options">
216
217                                                     <ul>
218                                                         [% IF ( reserve_in_future ) %]
219                                                             <li>
220                                                                 <label for="from[% bibitemloo.biblionumber %]">Hold starts on date:</label>
221                                                                 <input name="reserve_date_[% bibitemloo.biblionumber %]" id="from[% bibitemloo.biblionumber %]" size="10" class="holddatefrom"/>
222                                                                 <span class="date-format from" data-biblionumber="[% bibitemloo.biblionumber %]">[% INCLUDE 'date-format.inc' %]</span>
223                                                             </li>
224                                                         [% END %]
225
226                                                         <li>
227                                                             <label for="to[% bibitemloo.biblionumber %]">Hold not needed after:</label>
228                                                             <input name="expiration_date_[% bibitemloo.biblionumber %]" id="to[% bibitemloo.biblionumber %]" size="10" class="holddateto" />
229                                                             <span class="date-format to" data-biblionumber="[% bibitemloo.biblionumber %]">[% INCLUDE 'date-format.inc' %]</span>
230                                                         </li>
231
232                                                         [% IF ( OpacHoldNotes ) %]
233                                                             <li>
234                                                                 <div class="notesrow" id="notesrow_[% bibitemloo.biblionumber %]">
235                                                                     <label for="holdnotes[% bibitemloo.biblionumber %]">Hold notes:</label>
236                                                                     <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span>
237                                                                     <textarea id="holdnotes[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea>
238                                                                     <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/>
239                                                                 </div>
240                                                             </li>
241                                                         [% END # / IF OpacHoldNotes %]
242
243                                                         [% IF OPACItemHolds == '1' or OPACItemHolds == 'force' %]
244                                                             <!-- ITEM HOLDS -->
245                                                             <li class="lradio place_on_type" style="display:none;">
246                                                                 <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
247                                                                 [% IF OPACItemHolds == "1" %]
248                                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
249                                                                             id="reqany_[% bibitemloo.biblionumber %]"
250                                                                             class="selectany"
251                                                                             value="Any"
252                                                                             checked="checked"
253                                                                     />
254                                                                 [% ELSE %]
255                                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
256                                                                             id="reqany_[% bibitemloo.biblionumber %]"
257                                                                             class="selectany"
258                                                                             value="Any"
259                                                                      />
260                                                                 [% END %]
261                                                                 <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label>
262                                                                 [% IF OPACItemHolds == "force" %]
263                                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
264                                                                            id="reqspecific_[% bibitemloo.biblionumber %]"
265                                                                            class="selectspecific"
266                                                                            value="Specific"
267                                                                            checked="checked"
268                                                                     />
269                                                                 [% ELSE %]
270                                                                     <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
271                                                                            id="reqspecific_[% bibitemloo.biblionumber %]"
272                                                                            class="selectspecific"
273                                                                            value="Specific"
274                                                                     />
275                                                                 [% END %]
276                                                             </li>
277                                                         [% END # / IF OPACItemHolds %]
278                                                     </ul>
279
280                                                     [% IF OPACItemHolds == '1' || OPACItemHolds == 'force' %]
281                                                         <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]">
282                                                             <caption>Select a specific item:</caption>
283                                                             <tr>
284                                                                 <th>Copy number</th>
285                                                                 [% IF ( item_level_itypes ) %]
286                                                                     <th>Item type</th>
287                                                                 [% END %]
288                                                                 <th>Barcode</th>
289                                                                 [% UNLESS ( singleBranchMode ) %]
290                                                                     <th>Home library</th>
291                                                                     <th>Last location</th>
292                                                                 [% END %]
293                                                                 <th>Call number</th>
294                                                                 [% IF ( itemdata_enumchron ) %]
295                                                                     <th>Vol info</th>
296                                                                 [% END %]
297                                                                 <th>Information</th>
298                                                             </tr>
299
300                                                             [% FOREACH itemLoo IN bibitemloo.itemLoop %]
301                                                                 <tr class="[% itemLoo.backgroundcolor %]">
302                                                                     <td class="copynumber">
303                                                                         [% IF ( itemLoo.available ) %]
304                                                                             <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber %]" name="checkitem_[% bibitemloo.biblionumber %]" value="[% itemLoo.itemnumber %]" />
305                                                                         [% ELSE %]
306                                                                             <input disabled="disabled" type="radio" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber %]"
307                                                                                    style="display:none;" />
308                                                                             <img src="[% interface %]/lib/famfamfam/silk/cross.png" alt="Cannot be put on hold" title="Cannot be put on hold" />
309                                                                         [% END %]
310
311                                                                         [% IF ( itemLoo.copynumber ) %]
312                                                                             [% itemLoo.copynumber %]
313                                                                         [% END %]
314                                                                     </td>
315
316                                                                     [% IF ( item_level_itypes ) %]
317                                                                         <td class="itype">
318                                                                             [% UNLESS ( noItemTypeImages ) %]
319                                                                                 [% IF ( itemLoo.imageurl ) %]
320                                                                                     <img src="[% itemLoo.imageurl %]" alt="" />
321                                                                                 [% END %]
322                                                                             [% END %]
323                                                                             [% itemLoo.description %]
324                                                                         </td>
325                                                                     [% END %]
326
327                                                                     <td class="barcode">[% itemLoo.barcode %]</td>
328                                                                     [% UNLESS ( singleBranchMode ) %]
329                                                                         <td class="homebranch">[% itemLoo.homeBranchName %]</td>
330                                                                         <td class="holdingbranch">[% itemLoo.holdingBranchName %]</td>
331                                                                     [% END %]
332                                                                     <td class="call_no">[% itemLoo.callNumber %]</td>
333                                                                     [% IF ( itemdata_enumchron ) %]
334                                                                         <td class="vol_info">[% itemLoo.enumchron %]</td>
335                                                                     [% END %]
336                                                                     <td class="information">
337                                                                         [% IF ( itemLoo.dateDue ) %]
338                                                                             <span class="checkedout">Due [% itemLoo.dateDue %]</span>
339                                                                         [% ELSIF ( itemLoo.transfertwhen ) %]
340                                                                             <span class="intransit">In transit from [% itemLoo.transfertfrom %] to [% itemLoo.transfertto %] since [% itemLoo.transfertwhen %]</span>
341                                                                         [% END %]
342
343                                                                         [% IF ( itemLoo.message ) %]
344                                                                             <span class="lost">Unavailable (lost or missing)</span>
345                                                                         [% END %]
346
347                                                                         [% IF ( itemLoo.notforloan ) %]
348                                                                             <span class="notforloan">Not for loan ([% itemLoo.notforloanvalue %])</span>
349                                                                         [% END %]
350
351                                                                         [% IF ( itemLoo.reservedate ) %]
352                                                                             <span class="waiting">
353                                                                                 [% IF ( itemLoo.waitingdate ) %]
354                                                                                     Waiting
355                                                                                 [% ELSE %]
356                                                                                     On hold
357                                                                                 [% END %]
358                                                                                 for patron
359                                                                                 [% IF ( itemLoo.waitingdate ) %]
360                                                                                     at
361                                                                                 [% ELSE %]
362                                                                                     expected at
363                                                                                 [% END %]
364                                                                                 [% itemLoo.ExpectedAtLibrary %] since
365                                                                                 [% IF ( itemLoo.waitingdate ) %]
366                                                                                     [% itemLoo.waitingdate | $KohaDates %]
367                                                                                 [% ELSE %]
368                                                                                     [% IF ( itemLoo.reservedate ) %]
369                                                                                         [% itemLoo.reservedate %]
370                                                                                     [% END %]
371                                                                                 [% END %].
372                                                                             </span>
373                                                                         [% ELSE %]
374                                                                             <span class="notonhold">Not on hold</span>
375                                                                         [% END # / IF ( itemLoo.reservedate )%]
376                                                                     </td>
377                                                                 </tr>
378                                                             [% END # / FOREACH itemLoo IN bibitemloo.itemLoop%]
379                                                         </table> <!-- / #copiesrow_[% bibitemloo.biblionumber %] -->
380                                                     [% END # / IF ( OPACItemHolds )%]
381                                                 </div> <!-- / #hold-options-[% bibitemloo.biblionumber %] -->
382                                             </fieldset>
383                                         [% END # / IF ( bibitemloo.holdable ) %]
384                                     </div> <!-- / .holdrow -->
385                                 [% END # / FOREACH bibitemloo IN bibitemloop %]
386                             </div><!-- #bigloop -->
387
388                             [% UNLESS ( none_available ) %]
389                                 <input type="submit" value="Place hold" class="btn placehold" />
390                             [% END %]
391
392                         </form>
393                     [% END # / UNLESS message %]
394                 </div> <!-- / #holds -->
395     </div> <!-- / .container -->
396 </div> <!-- / .main -->
397 [% INCLUDE 'opac-bottom.inc' %]
398 [% BLOCK jsinclude %]
399 [% INCLUDE 'calendar.inc' %]
400 <script type="text/javascript">
401 // <![CDATA[
402     var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
403     var ForceHoldNotesReasons=new Array(
404        _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific item information may be helpful."),
405        "*** Add a new reason above this line ***" );
406        // NOTE: Do not renumber reasons; this will affect use of existing ones.
407
408         // Clear the contents of an input field
409         $(".clearfield").on("click",function(e){
410             $(this).closest("td").find("input").val("");
411             e.preventDefault();
412         });
413
414     // Select the first item available
415     function select_first_available(id){
416         var radios = $("input:radio[name='checkitem_" + id + "']");
417         $(radios).first().attr("checked", "checked");
418     }
419
420     $(document).ready(function() {
421         $("#hold-request-form").preventDoubleFormSubmit();
422         var copiesRowId = null;
423         var wasSpecific = false;
424         var lastCopiesRowId = null;
425
426         $(".toggle-hold-options").show();
427         $(".hold-options").hide();
428         $(".holddatefrom,.holddateto").prop("readOnly", true);
429
430         $(".checkitem").parent().click(function(e){
431             if(e.target.tagName.toLowerCase() == 'td'){
432                 $(this).find("input.checkitem").each( function() {
433                     $(this).attr('checked', 'checked');
434                 });
435             }
436         });
437
438         // click on a first td check the confirmjs checkbox
439         $("td.hold").click(function(e){
440           if(e.target.tagName.toLowerCase() == 'td'){
441             $(this).find("input.confirmjs").each( function() {
442                $(this).attr('checked', !$(this).attr('checked'));
443                $(this).change();
444             });
445           }
446         });
447
448         $(".toggle-hold-options").on("click",function(e){
449             e.preventDefault();
450             toggleLink = $(this);
451             var optionsID = this.id.replace("toggle-hold-options-","");
452             $("#hold-options-"+optionsID).toggle(0, function() {
453                 toggleLink.text($(this).is(':visible') ? _("Hide options") : _("Show more options"));
454             });
455         });
456
457         // Hides all 'specific copy' table rows on load.
458         $(".copiesrow").hide();
459
460         [% IF OPACItemHolds == 'force' %]
461           [% FOREACH bibitemloo IN bibitemloop %]
462             [% IF bibitemloo.holdable %]
463               $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
464               $("#copiesrow_[% bibitemloo.biblionumber %]").show();
465             [% END %]
466           [% END %]
467         [% END %]
468
469         // Insert reasons for forced hold notes
470         $(".forcenotesreason").each(function(){
471             biblioNum = suffixOf($(this).attr("id"), "_");
472             var j=$("#notesmandatory_"+biblioNum).val();
473             if(j>0) {
474                 $(this).html(ForceHoldNotesReasons[j-1]);
475             }
476         });
477
478         $(".date-format").each(function(){
479             if($(this).hasClass("to")){ var op = "to"; }
480             if($(this).hasClass("from")){ var op = "from"; }
481             var bibNum = $(this).data("biblionumber");
482             $(this).html("<a href=\"#\" class=\"clear-date\" data-op=\"" + op + "\" id=\"clear" + bibNum + "\">" + _("Clear date") + "</a>");
483         });
484
485         $(".clear-date").on("click",function(e){
486             e.preventDefault();
487             var fieldID = this.id.replace("clear","");
488             var op = $(this).data("op");
489             $("#" + op + fieldID).val("");
490         });
491
492         // Replace non-JS single-selection with multi-selection capability.
493         $(".reserve_mode").val("multi");
494         $(".confirm_nonjs").remove();
495         $(".confirmjs_hold").each(function(){
496             var bib = $(this).attr("title");
497             var html = "<label><input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
498             html += "value=\"" + bib + "\" id=\"" + bib + "\" /> " + _("Place a hold on") + " </label> ";
499             $(this).html(html);
500         });
501         $(".confirmjs_nohold").each(function(){
502             var bib = $(this).attr("title");
503             var html = "<label><input type =\"checkbox\" class=\"confirmjs\" disabled=\"disabled\"";
504             html += "value=\"" + bib + "\" id=\"" + bib + "\" />" + _("Place a hold on: ") + "</label>";
505             $(this).html(html);
506         });
507
508         // expand or collapse the copiesrow tr
509         function toggle_copiesrow(biblioNum) {
510             var checkbox = $("input:checkbox[value='"+biblioNum+"']");
511             newCopiesRowId = "#copiesrow_" + biblioNum;
512             var select_specific = $("#reqspecific_"+biblioNum).is(":checked");
513             // If the checkbox is checked AND we want a specific item, we display the items block
514             if ( $(checkbox).is(":checked") && select_specific ) {
515                 $(newCopiesRowId).show();
516             } else {
517                 $(newCopiesRowId).hide();
518              }
519         };
520
521         $("#place_on_hdr").show();
522
523         [% IF OPACItemHolds == '1' %]
524             $(".place_on_type").show();
525             // onload, selectany is checked
526             $(".selectany").attr("checked", "checked");
527         [% END %]
528
529         // If the user is *allowed* to choose a specific item
530         // The first one is preselected
531         [% IF OPACItemHolds =="1" %]
532             $("table.copiesrow").each(function(){
533                 var id = suffixOf($(this).attr("id"), "_");
534                 select_first_available(id);
535             });
536         [% END %]
537
538         // On confirmsjs change
539         $(".confirmjs").change(function(){
540             var id = suffixOf($(this).attr("id"), "_");
541             // If I m checked, I enable radio buttons
542             if ( $(this).is(":checked") ) {
543                 $("#reqspecific_" + id).attr("disabled", false);
544                 $("#reqany_" + id).attr("disabled", false);
545             }
546             // Else its are disabled
547             else {
548                 $("#reqspecific_" + id).attr("disabled", "disabled");
549                 $("#reqany_" + id).attr("disabled", "disabled");
550             }
551             // expand or collaspe the items block
552             toggle_copiesrow(id);
553         });
554
555         // When 'specific copy' or 'first available' radio button is clicked
556         $(".selectspecific, .selectany").click(function() {
557             var id = suffixOf($(this).attr("id"), "_");
558             toggle_copiesrow(id);
559         });
560
561         // Show or hide holds notes
562         $(".shownotes").click(function(){
563             biblioNum = suffixOf($(this).attr("id"), "_");
564             $("#notesrow_"+biblioNum).toggle();
565         });
566
567         // When 'Place Hold' button is clicked
568         $(".placehold").click(function(){
569             var biblionumbers = "";
570             var selections = "";
571
572             [% IF new_reserves_allowed %]
573                 if ($(".confirmjs:checked").size() > [% new_reserves_allowed %] ) {
574                     alert(MSG_MAX_HOLDS_EXCEEDED);
575                     return false;
576                 }
577             [% END %]
578
579             if ($(".confirmjs:checked").size() == 0) {
580                 alert(MSG_NO_RECORD_SELECTED);
581                 return false;
582             }
583
584             // Find the items with the 'Hold' box checked
585             var badBib = null;
586             $(".confirmjs:checked").each(function() {
587                 var biblioNum = $(this).val();
588                 biblionumbers += biblioNum + "/";
589                 selections += biblioNum + "/";
590
591                 // If the 'specific copy' radio button is checked
592                 if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
593                     // Find the selected copy
594                     var item = $(".checkitem_" + biblioNum + ":checked");
595                     if ($(item).size() == 0) {
596                         badBib = biblioNum;
597                         return false;
598                     } else {
599                       selections += $(item).val();
600                     }
601                 }
602                 selections += "/";
603
604                 // Add the pickup location
605                 var branchSel = $("#branch_" + biblioNum);
606                 if (branchSel.size() > 0) {
607                     selections += $(branchSel).val();
608                 }
609                 selections += "/";
610                 return true;
611             });
612
613             if (badBib) {
614                 alert(MSG_NO_ITEM_SELECTED);
615                 return false;
616             }
617
618             $("#selections").val(selections);
619             $("#biblionumbers").val(biblionumbers);
620
621             return true;
622         });
623
624         [% FOREACH bibitemloo IN bibitemloop %]
625             [% IF ( bibitemloo.holdable ) %]
626                 // http://jqueryui.com/demos/datepicker/#date-range
627                 var dates[% bibitemloo.biblionumber %] = $( "#from[% bibitemloo.biblionumber %], #to[% bibitemloo.biblionumber %]" ).datepicker({
628                     minDate: 1,
629                     changeMonth: true,
630                     numberOfMonths: 1,
631                     onSelect: function( selectedDate ) {
632                         var option = this.id == "from[% bibitemloo.biblionumber %]" ? "minDate" : "maxDate",
633                             instance = $( this ).data( "datepicker" );
634                             date = $.datepicker.parseDate(
635                                 instance.settings.dateFormat ||
636                                 $.datepicker._defaults.dateFormat,
637                                 selectedDate, instance.settings );
638                         dates[% bibitemloo.biblionumber %].not( this ).datepicker( "option", option, date );
639                     }
640                 });
641             [% END %]
642         [% END %]
643
644  });
645 // ]]>
646 </script>
647 [% END %]