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