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