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