Bug 34155: Hide 'Next available' at OPAC when item-level hold is forced
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-reserve.tt
1 [% USE Koha %]
2 [% USE Branches %]
3 [% USE KohaDates %]
4 [% USE Price %]
5 [% USE ItemTypes %]
6 [% USE AuthorisedValues %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Placing a hold &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% BLOCK cssinclude %][% END %]
11 </head>
12
13 [% INCLUDE 'bodytag.inc' bodyid='opac-holds' %]
14 [% INCLUDE 'masthead.inc' %]
15
16 <div class="main">
17     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumbs">
18         <ol class="breadcrumb">
19             <li class="breadcrumb-item">
20                 <a href="/cgi-bin/koha/opac-main.pl">Home</a>
21             </li>
22             <li class="breadcrumb-item active">
23                 <a href="#" aria-current="page">Placing a hold</a>
24             </li>
25         </ol>
26     </nav> <!-- /#breadcrumbs -->
27
28     <div class="container">
29         <div id="holds" class="maincontent">
30             <h1>Placing a hold</h1>
31             [% IF ( message ) %]
32                 <div id="holdmessages" class="alert">
33                     <p>Sorry, you cannot place holds.</p>
34                     <ul>
35                         [% IF ( GNA ) %]
36                             <li id="gna">
37                                 According to our records, we don't have up-to-date contact information. Please contact the library.
38                                 <a href="/cgi-bin/koha/opac-memberentry.pl">[% IF ( Koha.Preference('OPACPatronDetails') ) %]<span>Update your contact information</span>[% ELSE %]<span>Go to your contact information</span>[% 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 ( new_reserves_allowed ) %]
145                     <div id="new_reserves_allowed" class="alert">
146                         <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.
147                     </div>
148                 [% END %]
149
150             <form action="/cgi-bin/koha/opac-reserve.pl" method="post" id="hold-request-form">
151                 <legend class="sr-only">Hold requests</legend>
152                 <input type="hidden" name="place_reserve" value="1"/>
153                 <!-- These values are set dynamically by js -->
154                     <input type="hidden" name="biblionumbers" id="biblionumbers"/>
155                     <input type="hidden" name="selecteditems" id="selections"/>
156                     <div id="bigloop">
157
158                         [% FOREACH bibitemloo IN bibitemloop %]
159                             <div class="holdrow">
160                                 [% IF bibitemloo.forced_hold_level %]
161                                     <div class="alert alert-info forced_hold_level">
162                                         [% IF bibitemloo.forced_hold_level == 'item' %]
163                                             <span>You already have at least one item level hold on this title.
164                                             All further holds must be item level.</span>
165                                         [% ELSE %]
166                                             <span>You already have at least one record level hold on this title.
167                                             All further holds must be record level.</span>
168                                         [% END %]
169                                     </div>
170                                 [% END %]
171
172                                 [% IF ( bibitemloo.reserve_charge ) %]
173                                     <div class="alert" id="reserve_fee">
174                                         [% IF Koha.Preference('HoldFeeMode') == 'any_time_is_collected' %]
175                                             <span>You will be charged a hold fee of [% bibitemloo.reserve_charge | $Price %] when you collect this item</span>
176                                         [% ELSE %]
177                                             <span>You will be charged a hold fee of [% bibitemloo.reserve_charge | $Price %] for placing this hold</span>
178                                         [% END %]
179                                     </div>
180                                 [% END %]
181
182                                 <p>
183                                     [% IF ( bibitemloo.holdable ) %]
184                                         <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
185                                         <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber | html %]"/>
186                                         <span class="confirmjs_hold" title="[% bibitemloo.biblionumber | html %]" style="padding:.3em"></span>
187                                         <span class="confirm_nonjs">
188                                             <input type="radio" class="confirmbox checkitem [% bibitemloo.biblionumber | html %]" name="[% bibitemloo.biblionumber | html %]" checked="checked" id="single_[% bibitemloo.biblionumber | html %]" value="any" />
189                                             <label class="confirm_label" for="single_[% bibitemloo.biblionumber | html %]">Place a hold on </label>
190                                         </span>
191                                     [% END # / bibitemloo.holdable %]
192
193                                     [% INCLUDE 'biblio-title.inc' biblio=bibitemloo link=> 1%]
194
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 place a hold for this item.</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.alreadypossession %]
208                                             <div class="alert alert-warning">This title cannot be requested because it's already in your possession.</div>
209                                         [% ELSIF bibitemloo.tooManyReserves %]
210                                             <div class="alert alert-warning">This title cannot be requested because you reached the maximum number of holds.</div>
211                                         [% ELSIF bibitemloo.tooManyHoldsForThisRecord %]
212                                             <div class="alert alert-warning">This title cannot be requested because you exceeded max holds per record.</div>
213                                         [% ELSIF bibitemloo.tooManyReservesToday %]
214                                             <div class="alert alert-warning">This title cannot be requested because you reached the daily hold limit.</div>
215                                         [% ELSIF bibitemloo.itemAlreadyOnHold %]
216                                             <div class="alert alert-warning">This title cannot be requested because you already have hold for this item.</div>
217                                         [% ELSE %]
218                                             [% UNLESS ( bibitemloo.bib_available ) %]
219                                                 <div class="alert">There are no items that can be placed on hold.</div>
220                                             [% ELSE %]
221                                                 <div class="alert">This title cannot be requested.</div>
222                                             [% END %]
223                                         [% END # / UNLESS bibitemloo.already_patron_possession %]
224                                     [% END # / IF bibitemloo.already_reserved %]
225                                 [% END # / UNLESS bibitemloo.holdable %]
226
227                                 [% IF ( bibitemloo.holdable ) %]
228                                     <fieldset class="rows">
229                                         <ul>
230                                             <!-- HOLDABLE -->
231                                             [% UNLESS ( item_level_itypes ) %]
232                                                 <li class="itype">
233                                                     <span class="label">Item type: </span>
234                                                     [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl | html %]" alt="" />[% END %]
235                                                     <span class="itypetext">[% bibitemloo.translated_description | html %]</span>
236                                                 </li>
237                                             [% END %]
238
239                                             [% SET OPACShowHoldQueueDetails = Koha.Preference('OPACShowHoldQueueDetails') %]
240                                             [% IF OPACShowHoldQueueDetails == 'holds_priority' || OPACShowHoldQueueDetails == 'priority' %]
241                                                 <li class="priority">
242                                                     <span class="label">Your priority: </span>
243                                                     [% bibitemloo.rank | html %]
244                                                 </li>
245                                             [% END %]
246
247                                             [% IF OPACShowHoldQueueDetails == 'holds_priority' || OPACShowHoldQueueDetails == 'holds' %]
248                                                 <li class="holds-count">
249                                                     <span class="label">Number of holds: </span>
250                                                     [% bibitemloo.reservecount | html %]
251                                                 </li>
252                                             [% END %]
253
254                                             [% UNLESS ( singleBranchMode ) %]
255                                                 [% IF ( bibitemloo.holdable && Koha.Preference('OPACAllowUserToChooseBranch')) %]
256                                                     <li class="branch">
257                                                         <label for="branch_[% bibitemloo.biblionumber | html %]">Pick up location:</label>
258                                                         [% UNLESS ( bibitemloo.holdable ) %]
259                                                             <select name="branch" id="branch_[% bibitemloo.biblionumber | html %]" disabled="disabled">
260                                                                 [% PROCESS options_for_libraries libraries => Branches.pickup_locations({ search_params => { biblio => bibitemloo.biblionumber, patron => logged_in_user }, selected => branch }) %]
261                                                             </select>
262                                                         [% ELSE %]
263                                                             [% SET at_least_one_library_not_available_for_pickup = 0 %]
264                                                             <select name="branch" id="branch_[% bibitemloo.biblionumber | html %]">
265                                                                 [% FOREACH library IN Branches.pickup_locations({ search_params => { biblio => bibitemloo.biblionumber, patron => logged_in_user }, selected => branch }) %]
266                                                                     [% SET pickup_available_at = bibitemloo.not_available_at.grep('^' _ library.branchcode _ '$').size ? 0 : 1 %]
267                                                                     [% IF library.selected AND pickup_available_at %]
268                                                                         <option value="[% library.branchcode | html %]" selected="selected" >[% library.branchname | html %]</option>
269                                                                     [% ELSIF pickup_available_at %]
270                                                                         <option value="[% library.branchcode | html %]">[% library.branchname | html %]</option>
271                                                                     [% ELSE %]
272                                                                         [% SET at_least_one_library_not_available_for_pickup = 1 %]
273                                                                         <option value="[% library.branchcode | html %]" disabled="disabled" title="At least one item is available at this library">[% library.branchname | html %]</option>
274                                                                     [% END %]
275                                                                 [% END %]
276                                                             </select>
277                                                             [% IF at_least_one_library_not_available_for_pickup %]
278                                                                 <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>
279                                                             [% END %]
280                                                         [% END # / UNLESS bibitemloo.holdable %]
281                                                     </li>
282                                                 [% END # / IF bibitemloo.holdable && Koha.Preference('OPACAllowUserToChooseBranch') %]
283                                             [% END # / UNLESS singleBranchMode %]
284                                         </ul>
285
286                                         <a class="toggle-hold-options" id="toggle-hold-options-[% bibitemloo.biblionumber | html %]" style="display:none;" href="#">Show more options</a>
287
288                                         <div id="hold-options-[% bibitemloo.biblionumber | html %]" class="hold-options">
289
290                                             <ul>
291                                                 [% IF ( reserve_in_future ) %]
292                                                     <li>
293                                                         <label for="from[% bibitemloo.biblionumber | html %]">Hold starts on date:</label>
294                                                         <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 holddatefrom" />
295                                                         <span class="date-format from" data-biblionumber="[% bibitemloo.biblionumber | html %]">[% INCLUDE 'date-format.inc' %]</span>
296                                                     </li>
297                                                 [% END %]
298
299                                                 <li>
300                                                     <label for="to[% bibitemloo.biblionumber | html %]">Hold not needed after:</label>
301                                                     <input type="text" name="expiration_date_[% bibitemloo.biblionumber | html %]" id="to[% bibitemloo.biblionumber | html %]" size="10" class="flatpickr futuredate" />
302                                                     <span class="date-format to" data-biblionumber="[% bibitemloo.biblionumber | html %]">[% INCLUDE 'date-format.inc' %]</span>
303                                                 </li>
304
305                                                 [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
306                                                     <li>
307                                                         <label for="itemtype">Request specific item type:</label>
308                                                         <select name="itemtype" id="itemtype">
309                                                             <option value="">Any item type</option>
310                                                             [% FOREACH i IN bibitemloo.allowed_item_types %]
311                                                                 <option value="[% i | html %]">[% ItemTypes.GetDescription( i ) | html %]</option>
312                                                             [%- END %]
313                                                         </select>
314                                                     </li>
315                                                 [% END %]
316
317                                                 [% UNLESS bibitemloo.forced_hold_level && ( bibitemloo.forced_hold_level == 'item' || bibitemloo.forced_hold_level == 'record' ) %]
318                                                     [% IF Koha.Preference('EnableItemGroupHolds') && bibitemloo.object.item_groups %]
319                                                         <li>
320                                                             <label for="itemtype">Request specific item group:</label>
321                                                             <select name="item_group_id_[% bibitemloo.biblionumber | html %]" id="item_group_id_[% bibitemloo.biblionumber | html %]">
322                                                                 <option value="">Any item group</option>
323                                                                 [% FOREACH g IN bibitemloo.object.item_groups.search({}, { order_by => ['display_order'] }) %]
324                                                                     <option value="[% g.id | html %]">[% g.description | html %]</option>
325                                                                 [% END %]
326                                                             </select>
327                                                         </li>
328                                                     [% END %]
329                                                 [% END %]
330
331                                                 [% IF ( OpacHoldNotes ) %]
332                                                     <li>
333                                                         <div class="notesrow" id="notesrow_[% bibitemloo.biblionumber | html %]">
334                                                             <label for="holdnotes_[% bibitemloo.biblionumber | html %]">Hold notes:</label>
335                                                             <textarea id="holdnotes_[% bibitemloo.biblionumber | html %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber | html %]" >[% bibitemloo.holdnotes | html %]</textarea>
336                                                         </div>
337                                                     </li>
338                                                 [% END # / IF OpacHoldNotes %]
339
340                                                 [% IF bibitemloo.itemholdable %]
341                                                     <!-- ITEM HOLDS -->
342                                                     <li class="lradio place_on_type" style="display:none;">
343                                                         [% UNLESS bibitemloo.forced_hold_level == 'item' || bibitemloo.forced_hold_level == 'item_group' || bibitemloo.force_hold %]
344                                                             <label class="radio inline" for="reqany_[% bibitemloo.biblionumber | html %]">Next available item</label>
345                                                             <input type="radio" name="reqtype_[% bibitemloo.biblionumber | html %]"
346                                                                     id="reqany_[% bibitemloo.biblionumber | html %]"
347                                                                     class="selectany"
348                                                                     value="Any"
349                                                                     checked="checked"
350                                                             />
351                                                         [% END %]
352                                                         <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber | html %]">A specific item</label>
353                                                         <input type="radio" name="reqtype_[% bibitemloo.biblionumber | html %]"
354                                                                id="reqspecific_[% bibitemloo.biblionumber | html %]"
355                                                                class="selectspecific"
356                                                                value="Specific"
357                                                         />
358                                                     </li>
359                                                 [% END # / IF bibitemloo.itemholdable %]
360                                             </ul>
361
362                                             [% IF bibitemloo.itemholdable %]
363                                                 <div id="copiesrow_[% bibitemloo.biblionumber | html %]" class="copiesrow">
364                                                 <table class="table table-bordered table-striped itemstable">
365                                                     <caption>Select a specific item:</caption>
366                                                     <thead>
367                                                         <tr>
368                                                         <th>Copy number</th>
369                                                         [% IF ( item_level_itypes ) %]
370                                                             <th>Item type</th>
371                                                         [% END %]
372                                                         <th>Barcode</th>
373                                                         [% UNLESS ( singleBranchMode ) %]
374                                                             <th>Home library</th>
375                                                             <th>Last location</th>
376                                                         [% END %]
377                                                         [% IF ( itemdata_ccode ) %]
378                                                             <th>Collection</th>
379                                                         [% END %]
380                                                         <th>Call number</th>
381                                                         [% IF ( itemdata_enumchron ) %]
382                                                             <th>Vol info</th>
383                                                         [% END %]
384                                                         <th>Notes</th>
385                                                         <th>Information</th>
386                                                         </tr>
387                                                     </thead>
388                                                     <tbody>
389
390                                                     [% SET unholdable_items = 0 %]
391                                                     [% FOREACH itemLoo IN bibitemloo.itemLoop %]
392                                                         [% IF ( itemLoo.available ) %]
393                                                             [% IF ( itemLoo.checkout ) %]
394                                                                 <tr class="holdable onloan">
395                                                             [% ELSE %]
396                                                                 <tr class="holdable">
397                                                             [% END %]
398                                                                     <td class="copynumber" data-order="[% itemLoo.copynumber | html %]">
399                                                                         <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber | html %]" name="checkitem_[% bibitemloo.biblionumber | html %]" value="[% itemLoo.itemnumber | html %]" />
400                                                         [% ELSE %]
401                                                             [% SET unholdable_items = 1 %]
402                                                             [% IF ( itemLoo.checkout ) %]
403                                                                 <tr class="unholdable onloan" style="display:none;">
404                                                             [% ELSE %]
405                                                                 <tr class="unholdable" style="display:none;">
406                                                             [% END %]
407                                                                     <td class="copynumber">
408                                                                         <input disabled="disabled" type="radio" aria-label="Cannot be put on hold" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber | html %]"
409                                                                            style="display:none;" />
410                                                                     <i class="fa fa-remove danger" aria-hidden="true" title="Cannot be put on hold"></i>
411                                                         [% END %]
412                                                                 [% IF ( itemLoo.copynumber ) %]
413                                                                     [% itemLoo.copynumber | html %]
414                                                                 [% END %]
415                                                             </td> [%# copynumber %]
416
417                                                             [% IF ( item_level_itypes ) %]
418                                                                 <td class="itype">
419                                                                     [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
420                                                                         [% IF ( itemLoo.imageurl ) %]
421                                                                             <img src="[% itemLoo.imageurl | html %]" alt="" />
422                                                                         [% END %]
423                                                                     [% END %]
424                                                                     <span class="itypetext">[% itemLoo.translated_description | html %]</span>
425                                                                 </td>
426                                                             [% END %]
427
428                                                             <td class="barcode">[% itemLoo.barcode | html %]</td>
429                                                             [% UNLESS ( singleBranchMode ) %]
430                                                                 <td class="homebranch">[% Branches.GetName( itemLoo.homebranch) | html %]</td>
431                                                                 <td class="holdingbranch">[% Branches.GetName( itemLoo.holdingbranch ) | html %]</td>
432                                                             [% END %]
433                                                             [% IF ( itemdata_ccode ) %]
434                                                                 <td class="ccode"> [% IF ( itemLoo.ccode ) %][% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => itemLoo.ccode, opac => 1 ) | html %][% END %]</td>
435                                                             [% END %]
436                                                             <td class="call_no">[% itemLoo.itemcallnumber | html %]</td>
437                                                             [% IF ( itemdata_enumchron ) %]
438                                                                 <td class="vol_info">[% itemLoo.enumchron | html %]</td>
439                                                             [% END %]
440                                                             <td class="itemnotes">
441                                                                 [% itemLoo.itemnotes | html %]
442                                                             </td>
443                                                             <td class="information">
444                                                                 [% IF ( itemLoo.checkout.date_due) %]
445                                                                     <span class="checkedout">Due [% itemLoo.checkout.date_due| $KohaDates as_due_date => 1 %]</span>
446                                                                 [% ELSIF ( itemLoo.transfertwhen ) %]
447                                                                     <span class="intransit">In transit from [% Branches.GetName( itemLoo.transfertfrom ) | html %] to [% Branches.GetName( itemLoo.transfertto ) | html %] since [% itemLoo.transfertwhen | $KohaDates %]</span>
448                                                                 [% END %]
449
450                                                                 [% IF ( itemLoo.itemlost == 1 || itemLoo.itemlost == 2 ) %] [%# FIXME Why only for 1 or 2? Shouldn't we test for withdrawn as well? %]
451                                                                     <span class="lost">Unavailable (lost or missing)</span>
452                                                                 [% END %]
453
454                                                                 [% IF ( itemLoo.notforloan ) %]
455                                                                     <span class="notforloan">Not for loan ([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => itemLoo.notforloan ) %])</span>
456                                                                 [% END %]
457
458                                                                 [% IF ( itemLoo.first_hold ) %]
459                                                                     <span class="waiting">
460                                                                         [% IF ( itemLoo.waitingdate ) %]
461                                                                             <span>Waiting for patron at [% Branches.GetName( itemLoo.ExpectedAtLibrary ) | html %] since [% itemLoo.waitingdate | $KohaDates %]</span>
462                                                                         [% ELSIF ( itemLoo.reservedate ) %]
463                                                                             <span>On hold for patron expected at [% Branches.GetName( itemLoo.ExpectedAtLibrary ) | html %] since [% itemLoo.reservedate | $KohaDates %]</span>
464                                                                         [% ELSE %]
465                                                                             <span>On hold for patron expected at [% Branches.GetName( itemLoo.ExpectedAtLibrary ) | html %]</span>
466                                                                         [% END %]
467                                                                     </span>
468                                                                 [% ELSE %]
469                                                                     <span class="notonhold">Not on hold</span>
470                                                                 [% END # / IF ( itemLoo.first_hold )%]
471                                                             </td>
472                                                         </tr>
473                                                     [% END # / FOREACH itemLoo IN bibitemloo.itemLoop%]
474                                                     </tbody>
475                                                 </table> <!-- / #copiesrow_[% bibitemloo.biblionumber | html %] -->
476                                                 [% IF unholdable_items %]
477                                                 <button id="show_unholdable" class="btn btn-primary toggle_unholdable unholdable">Show unholdable items</button>
478                                                 <button id="hide_unholdable" class="btn btn-primary toggle_unholdable unholdable" style="display:none;">Hide unholdable items</button>
479                                                 [% END %]
480                                                 </div>
481                                             [% END # / IF ( bibitemloo.itemholdable )%]
482                                         </div> <!-- / #hold-options-[% bibitemloo.biblionumber | html %] -->
483                                     </fieldset>
484                                 [% END # / IF ( bibitemloo.holdable ) %]
485                             </div> <!-- / .holdrow -->
486                         [% END # / FOREACH bibitemloo IN bibitemloop %]
487                     </div><!-- #bigloop -->
488
489                     [% UNLESS ( none_available ) %]
490                         <input type="submit" value="Confirm hold" class="btn btn-primary placehold" />
491                     [% END %]
492
493                 </form>
494             [% END # / UNLESS message %]
495         </div> <!-- / #holds -->
496     </div> <!-- / .container -->
497 </div> <!-- / .main -->
498 [% INCLUDE 'opac-bottom.inc' %]
499 [% BLOCK jsinclude %]
500 [% INCLUDE 'calendar.inc' %]
501 [% INCLUDE 'datatables.inc' %]
502 <script>
503     var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
504     var MSG_EMPTY_START_DATE = _("Hold start date should be filled.");
505     var MSG_EMPTY_END_DATE   = _("Hold expiration date should be filled.");
506
507     $(document).ready(function() {
508
509         $(".toggle_unholdable").click(function(e){
510             e.preventDefault();
511             $(this).parent('div').find(".unholdable").toggle();
512         });
513
514         $("#hold-request-form").preventDoubleFormSubmit();
515         var copiesRowId = null;
516         var wasSpecific = false;
517         var lastCopiesRowId = null;
518
519         $(".toggle-hold-options").show();
520         $(".hold-options").hide();
521         var OPACMandatoryHoldDates = "[% Koha.Preference('OPACMandatoryHoldDates') | html %]";
522         var requiredDiv = "<div class=\"required_label required\">" + _("Required") + "</div>";
523         if( OPACMandatoryHoldDates ) {
524             if( OPACMandatoryHoldDates == "start" || OPACMandatoryHoldDates == "both" ) {
525                 $(".holddatefrom").prop( 'required', true );
526                 $(".holddatefrom").parent().append(requiredDiv);
527             }
528             if( OPACMandatoryHoldDates == "end"   || OPACMandatoryHoldDates == "both" ) {
529                 $(".futuredate").prop( 'required', true );
530                 $(".futuredate").parent().append(requiredDiv);
531             }
532         }
533         $(".holddatefrom,.futuredate").prop("readOnly", true);
534
535         $(".checkitem").parent().click(function(e){
536             if(e.target.tagName.toLowerCase() == 'td'){
537                 $(this).find("input.checkitem").each( function() {
538                     $(this).attr('checked', 'checked');
539                 });
540             }
541         });
542
543         // click on a first td check the confirmjs checkbox
544         $("td.hold").click(function(e){
545           if(e.target.tagName.toLowerCase() == 'td'){
546             $(this).find("input.confirmjs").each( function() {
547                $(this).attr('checked', !$(this).attr('checked'));
548                $(this).change();
549             });
550           }
551         });
552
553         $(".toggle-hold-options").on("click",function(e){
554             e.preventDefault();
555             toggleLink = $(this);
556             var optionsID = this.id.replace("toggle-hold-options-","");
557             $("#hold-options-"+optionsID).toggle(0, function() {
558                 toggleLink.text($(this).is(':visible') ? _("Hide options") : _("Show more options"));
559             });
560         });
561         if( $(".holddatefrom").prop('required') || $(".futuredate").prop('required') ) $(".toggle-hold-options").click();
562
563         // Hides all 'specific copy' table rows on load.
564         $(".copiesrow").hide();
565
566         [% FOREACH bibitemloo IN bibitemloop %]
567           [% IF bibitemloo.force_hold %]
568             if( $("#to[% bibitemloo.biblionumber | html %]:hidden").length )
569                 $("#toggle-hold-options-[% bibitemloo.biblionumber | html %]").click();
570             $("#reqspecific_[% bibitemloo.biblionumber | html %]").click();
571             $("#copiesrow_[% bibitemloo.biblionumber | html %]").show();
572           [% END %]
573         [% END %]
574
575         // Replace non-JS single-selection with multi-selection capability.
576         $(".reserve_mode").val("multi");
577         $(".confirm_nonjs").remove();
578         $(".confirmjs_hold").each(function(){
579             var bib = $(this).attr("title");
580             var html = "<label><input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
581             html += "value=\"" + bib + "\" id=\"" + bib + "\" /> " + _("Place a hold on") + " </label> ";
582             $(this).html(html);
583         });
584         $(".confirmjs_nohold").each(function(){
585             var bib = $(this).attr("title");
586             var html = "<label><input type =\"checkbox\" class=\"confirmjs\" disabled=\"disabled\"";
587             html += "value=\"" + bib + "\" id=\"" + bib + "\" />" + _("Place a hold on: ") + "</label>";
588             $(this).html(html);
589         });
590
591         // expand or collapse the copiesrow tr
592         function toggle_copiesrow(biblioNum) {
593             var checkbox = $("input:checkbox[value='"+biblioNum+"']");
594             newCopiesRowId = "#copiesrow_" + biblioNum;
595             var select_specific = $("#reqspecific_"+biblioNum).is(":checked");
596             // If the checkbox is checked AND we want a specific item, we display the items block
597             if ( $(checkbox).is(":checked") && select_specific ) {
598                 if ( $(`#item_group_id_${biblioNum}`).length ) {
599                     $(`#item_group_id_${biblioNum}`).val("").attr('disabled', 'disabled');
600                 }
601                 $(newCopiesRowId).show();
602             } else {
603                 if ( $(`#item_group_id_${biblioNum}`).length ) {
604                     $(`#item_group_id_${biblioNum}`).removeAttr('disabled');
605                 }
606                 $(newCopiesRowId).hide();
607             }
608         };
609
610         $("#place_on_hdr").show();
611
612         $(".place_on_type").show();
613         // onload, selectany is checked
614         $(".selectany").attr("checked", "checked");
615
616
617         // On confirmsjs change
618         $(".confirmjs").change(function(){
619             var id = suffixOf($(this).attr("id"), "_");
620             // If I m checked, I enable radio buttons
621             if ( $(this).is(":checked") ) {
622                 $("#reqspecific_" + id).attr("disabled", false);
623                 $("#reqany_" + id).attr("disabled", false);
624             }
625             // Else its are disabled
626             else {
627                 $("#reqspecific_" + id).attr("disabled", "disabled");
628                 $("#reqany_" + id).attr("disabled", "disabled");
629             }
630             // expand or collaspe the items block
631             toggle_copiesrow(id);
632         });
633
634         // When 'specific copy' or 'first available' radio button is clicked
635         $(".selectspecific, .selectany").click(function() {
636             var id = suffixOf($(this).attr("id"), "_");
637             toggle_copiesrow(id);
638         });
639
640         // Show or hide holds notes
641         $(".shownotes").click(function(){
642             biblioNum = suffixOf($(this).attr("id"), "_");
643             $("#notesrow_"+biblioNum).toggle();
644         });
645
646         // When 'Place Hold' button is clicked
647         $(".placehold").click(function(){
648             var biblionumbers = "";
649             var selections = "";
650
651             [% IF new_reserves_allowed %]
652                 if ($(".confirmjs:checked").size() > [% new_reserves_allowed | html %] ) {
653                     alert(MSG_MAX_HOLDS_EXCEEDED);
654                     return false;
655                 }
656             [% END %]
657
658             if ($(".confirmjs:checked").size() == 0) {
659                 alert( __("No item was selected") );
660                 return false;
661             }
662
663             // Find the items with the 'Hold' box checked
664             var badBib = null;
665             $(".confirmjs:checked").each(function() {
666                 var biblioNum = $(this).val();
667                 biblionumbers += biblioNum + "/";
668                 selections += biblioNum + "/";
669
670                 // If required hold note is empty, make it visible
671                 if( $("#holdnotes_"+biblioNum).attr( 'required' ) && $("#holdnotes_"+biblioNum).val() == '' ) {
672                     if( !$("#hold-options-"+biblioNum).is(':visible')) {
673                         $("#toggle-hold-options-"+biblioNum).click();
674                     }
675                 }
676
677                 if( $(".holddatefrom").prop('required') && $("#from"+ biblioNum).val() == '' ) {
678                     alert(MSG_EMPTY_START_DATE);
679                     badBib = biblioNum;
680                     if( $("#from"+biblioNum+":hidden").length ) $("#toggle-hold-options-"+biblioNum).click();
681                     $("#from"+ biblioNum).focus();
682                     return false;
683                 } else if( $(".futuredate").prop('required') && $("#to"+ biblioNum).val() == '' ) {
684                     alert(MSG_EMPTY_END_DATE);
685                     badBib = biblioNum;
686                     if( $("#to"+biblioNum+":hidden").length ) $("#toggle-hold-options-"+biblioNum).click();
687                     $("#to"+ biblioNum).focus();
688                     return false;
689                 }
690
691                 // If the 'specific copy' radio button is checked
692                 if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
693                     // Find the selected copy
694                     var item = $(".checkitem_" + biblioNum + ":checked");
695                     if ($(item).size() == 0) {
696                         alert(MSG_NO_ITEM_SELECTED);
697                         badBib = biblioNum;
698                         return false;
699                     } else {
700                       selections += $(item).val();
701                     }
702                 }
703                 selections += "/";
704
705                 // Add the pickup location
706                 var branchSel = $("#branch_" + biblioNum);
707                 if (branchSel.size() > 0) {
708                     selections += $(branchSel).val();
709                 }
710                 selections += "/";
711                 return true;
712             });
713
714             if (badBib) { // alert has been raised already
715                 return false;
716             }
717
718             $("#selections").val(selections);
719             $("#biblionumbers").val(biblionumbers);
720
721             return true;
722         });
723         $(".itemstable").each(function(){
724             $(this).DataTable({
725                 dom: "t",
726                 initComplete: function() {
727                     this.find("input:radio").first().prop("checked", true );
728                 },
729                 paging: false
730             });
731         });
732     });
733 </script>
734 [% END %]