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