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