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