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