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