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