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