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