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