Bug 36341: Add futureinclusive to future holds
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-reserve.tt
1 [% USE raw %]
2 [% USE Koha %]
3 [% USE Branches %]
4 [% USE KohaDates %]
5 [% USE Price %]
6 [% USE ItemTypes %]
7 [% USE AuthorisedValues %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Placing a hold &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 [% BLOCK cssinclude %][% END %]
12 </head>
13
14 [% INCLUDE 'bodytag.inc' bodyid='opac-holds' %]
15 [% INCLUDE 'masthead.inc' %]
16
17 <div class="main">
18     [% WRAPPER breadcrumbs %]
19         [% WRAPPER breadcrumb_item bc_active= 1 %]
20             <span>Placing a hold</span>
21         [% END %]
22     [% END #/ WRAPPER breadcrumbs %]
23
24     <div class="container">
25         <div id="holds" class="maincontent">
26             <h1>Placing a hold</h1>
27             [% IF ( message ) %]
28                 <div id="holdmessages" class="alert">
29                     <p>Sorry, you cannot place holds.</p>
30                     <ul>
31                         [% IF ( GNA ) %]
32                             <li id="gna">
33                                 According to our records, we don't have up-to-date contact information. Please contact the library.
34                                 <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>
35                                 [% IF ( Koha.Preference('OPACPatronDetails') ) %]<em>(Please note: there may be a delay in restoring your account if you submit online.)</em>[% END %]
36                             </li>
37                         [% END %]
38
39                         [% IF ( lost ) %]
40                             <li id="lost">
41                                 Your library card has been marked as lost or stolen.<br />
42                                 <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>
43                             </li>
44                         [% END %]
45
46                         [% IF ( debarred ) %]
47                             <li id="debarred">
48                                 Your account has been frozen.
49                                 [% IF debarred_comment %]
50                                     Comment:
51                                     <span id="userdebarred_comment">
52                                         <strong>
53                                             [% IF debarred_comment.search('OVERDUES_PROCESS') %]
54                                                 Restriction added by overdues process [% debarred_comment.remove('OVERDUES_PROCESS ') | html_line_break %]
55                                             [% ELSE %]
56                                                 [% debarred_comment | html_line_break %]
57                                             [% END %]
58                                         </strong>
59                                     </span>
60                                 [% END %]
61
62                                 [% IF debarred_date && debarred_date != '9999-12-31' %]
63                                     End date:
64                                     <span id="userdebarred_date">[% debarred_date | $KohaDates %]</span>
65                                 [% END %]
66                                 <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>
67                             </li>
68                         [% END %]
69
70                         [% IF ( too_much_oweing ) %]
71                             <li id="too_much_oweing">
72                                 You have unpaid fines. Amount: [% too_much_oweing | $Price %].
73                             </li>
74                         [% END %]
75
76                         [% IF ( too_many_reserves ) %]
77                             <li id="too_many_reserves">
78                                 Sorry, you cannot place more than [% too_many_reserves | html %] holds.
79                             </li>
80                         [% END %]
81
82                         [% IF ( bad_biblionumber ) %]
83                             <li id="bad_biblionumber">
84                                 ERROR: No record found for record ID [% bad_biblionumber | html %].
85                             </li>
86                         [% END %]
87
88                         [% IF ( no_items_selected ) %]
89                             <li id="no_items_selected">
90                                 You must select at least one item.
91                             </li>
92                         [% END %]
93
94                         [% IF ( no_branch_selected ) %]
95                             <li id="no_branch_selected">
96                                 You must select a library for pickup.
97                             </li>
98                         [% END %]
99
100                         [% IF ( no_biblionumber ) %]
101                             <li id="no_biblionumber">
102                                ERROR: No record ID specified.
103                            </li>
104                         [% END %]
105
106                         [% IF ( bad_data ) %]
107                             <li id="bad_data">
108                                 ERROR: Internal error: incomplete hold request.
109                             </li>
110                         [% END %]
111
112                         [% IF ( expired_patron ) %]
113                             <li id="expired_patron">
114                                 Your library card has expired. Please contact your librarian if you wish to renew your card.
115                             </li>
116                         [% END %]
117
118                         [% IF ( no_pickup_locations ) %]
119                             <li id="no_pickup_locations">
120                                 None of the libraries are available for pickup location.
121                             </li>
122                         [% END %]
123                     </ul>
124                 </div> <!-- /.message -->
125             [% ELSE # /IF message %]
126
127                 [% IF ( none_available && multi_hold ) %]
128                     <div id="none_available" class="alert">
129                         Sorry, none of these titles can be placed on hold.
130                     </div>
131                 [% END %]
132
133             [% END # / IF message %]
134
135             [% UNLESS ( message ) %]
136                 [% UNLESS ( none_available ) %]
137                     <h2>Confirm holds for:[% INCLUDE 'patron-title.inc' patron = logged_in_user %] ([% logged_in_user.cardnumber | html %])</h2>
138                 [% END # / UNLESS none_available %]
139
140                 [% IF ( new_reserves_allowed ) %]
141                     <div id="new_reserves_allowed" class="alert">
142                         <strong>Sorry,</strong> you can only place [% new_reserves_allowed | html %] more holds. Please uncheck the checkboxes for the items you wish to not place holds on.
143                     </div>
144                 [% END %]
145
146             <form action="/cgi-bin/koha/opac-reserve.pl" method="post" id="hold-request-form">
147                 <legend class="sr-only">Hold requests</legend>
148                 <input type="hidden" name="place_reserve" value="1"/>
149                 <!-- These values are set dynamically by js -->
150                     <input type="hidden" name="biblionumbers" id="biblionumbers"/>
151                     <input type="hidden" name="selecteditems" id="selections"/>
152                     <div id="bigloop">
153
154                         [% FOREACH bibitemloo IN bibitemloop %]
155                             <div class="holdrow">
156                                 [% IF bibitemloo.forced_hold_level %]
157                                     <div class="alert alert-info forced_hold_level">
158                                         [% IF bibitemloo.forced_hold_level == 'item' %]
159                                             <span>You already have at least one item level hold on this title.
160                                             All further holds must be item level.</span>
161                                         [% ELSE %]
162                                             <span>You already have at least one record level hold on this title.
163                                             All further holds must be record level.</span>
164                                         [% END %]
165                                     </div>
166                                 [% END %]
167
168                                 [% IF ( bibitemloo.reserve_charge ) %]
169                                     <div class="alert" id="reserve_fee">
170                                         [% IF Koha.Preference('HoldFeeMode') == 'any_time_is_collected' %]
171                                             <span>You will be charged a hold fee of [% bibitemloo.reserve_charge | $Price %] when you collect this item</span>
172                                         [% ELSE %]
173                                             <span>You will be charged a hold fee of [% bibitemloo.reserve_charge | $Price %] for placing this hold</span>
174                                         [% END %]
175                                     </div>
176                                 [% END %]
177
178                                 <p>
179                                     [% IF ( bibitemloo.holdable ) %]
180                                         <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
181                                         <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber | html %]"/>
182                                         <span class="confirmjs_hold" title="[% bibitemloo.biblionumber | html %]" style="padding:.3em"></span>
183                                         <span class="confirm_nonjs">
184                                             <input type="radio" class="confirmbox checkitem [% bibitemloo.biblionumber | html %]" name="[% bibitemloo.biblionumber | html %]" checked="checked" id="single_[% bibitemloo.biblionumber | html %]" value="any" />
185                                             <label class="confirm_label" for="single_[% bibitemloo.biblionumber | html %]">Place a hold on </label>
186                                         </span>
187                                     [% END # / bibitemloo.holdable %]
188
189                                     [% INCLUDE 'biblio-title.inc' biblio=bibitemloo link=> 1%]
190
191                                     [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author | html %][% END %]
192                                 </p>
193
194                                 [% UNLESS ( bibitemloo.holdable ) %]
195                                     [% IF ( bibitemloo.ageRestricted ) %]
196                                         <div class="alert alert-warning">Sorry, you are too young to place a hold for this item.</div>
197                                     [% END %]
198                                     [% IF ( bibitemloo.already_reserved ) %]
199                                         <div class="alert alert-warning">You have already requested this title.</div>
200                                     [% ELSIF ( bibitemloo.recall ) %]
201                                         <div class="alert alert-warning">You have already placed a recall on this title.</div>
202                                     [% ELSE %]
203                                         [% IF bibitemloo.alreadypossession %]
204                                             <div class="alert alert-warning">This title cannot be requested because it's already in your possession.</div>
205                                         [% ELSIF bibitemloo.tooManyReserves %]
206                                             <div class="alert alert-warning">This title cannot be requested because you reached the maximum number of holds.</div>
207                                         [% ELSIF bibitemloo.tooManyHoldsForThisRecord %]
208                                             <div class="alert alert-warning">This title cannot be requested because you exceeded max holds per record.</div>
209                                         [% ELSIF bibitemloo.tooManyReservesToday %]
210                                             <div class="alert alert-warning">This title cannot be requested because you reached the daily hold limit.</div>
211                                         [% ELSIF bibitemloo.itemAlreadyOnHold %]
212                                             <div class="alert alert-warning">This title cannot be requested because you already have hold for this item.</div>
213                                         [% ELSE %]
214                                             [% UNLESS ( bibitemloo.bib_available ) %]
215                                                 <div class="alert">There are no items that can be placed on hold.</div>
216                                             [% ELSE %]
217                                                 <div class="alert">This title cannot be requested.</div>
218                                             [% END %]
219                                         [% END # / UNLESS bibitemloo.already_patron_possession %]
220                                     [% END # / IF bibitemloo.already_reserved %]
221                                 [% END # / UNLESS bibitemloo.holdable %]
222
223                                 [% IF ( bibitemloo.holdable ) %]
224                                     <fieldset class="rows">
225                                         <ul>
226                                             <!-- HOLDABLE -->
227                                             [% UNLESS ( item_level_itypes ) %]
228                                                 <li class="itype">
229                                                     <span class="label">Item type: </span>
230                                                     [% IF ( bibitemloo.imageurl ) %]<img src="[% bibitemloo.imageurl | html %]" alt="" />[% END %]
231                                                     <span class="itypetext">[% bibitemloo.translated_description | html %]</span>
232                                                 </li>
233                                             [% END %]
234
235                                             [% SET OPACShowHoldQueueDetails = Koha.Preference('OPACShowHoldQueueDetails') %]
236                                             [% IF OPACShowHoldQueueDetails == 'holds_priority' || OPACShowHoldQueueDetails == 'priority' %]
237                                                 <li class="priority">
238                                                     <span class="label">Your priority: </span>
239                                                     [% bibitemloo.rank | html %]
240                                                 </li>
241                                             [% END %]
242
243                                             [% IF OPACShowHoldQueueDetails == 'holds_priority' || OPACShowHoldQueueDetails == 'holds' %]
244                                                 <li class="holds-count">
245                                                     <span class="label">Number of holds: </span>
246                                                     [% bibitemloo.reservecount | html %]
247                                                 </li>
248                                             [% END %]
249
250                                             [% UNLESS ( singleBranchMode ) %]
251                                                 [% IF ( bibitemloo.holdable && Koha.Preference('OPACAllowUserToChooseBranch')) %]
252                                                     <li class="branch">
253                                                         <label for="branch_[% bibitemloo.biblionumber | html %]">Pick up location:</label>
254                                                         [% UNLESS ( bibitemloo.holdable ) %]
255                                                             <select name="branch" id="branch_[% bibitemloo.biblionumber | html %]" disabled="disabled">
256                                                                 [% PROCESS options_for_libraries libraries => Branches.pickup_locations({ search_params => { biblio => bibitemloo.biblionumber, patron => logged_in_user }, selected => branch }) %]
257                                                             </select>
258                                                         [% ELSE %]
259                                                             [% SET at_least_one_library_not_available_for_pickup = 0 %]
260                                                             <select name="branch" id="branch_[% bibitemloo.biblionumber | html %]">
261                                                                 [% FOREACH library IN Branches.pickup_locations({ search_params => { biblio => bibitemloo.biblionumber, patron => logged_in_user }, selected => branch }) %]
262                                                                     [% SET pickup_available_at = bibitemloo.not_available_at.grep('^' _ library.branchcode _ '$').size ? 0 : 1 %]
263                                                                     [% IF library.selected AND pickup_available_at %]
264                                                                         <option value="[% library.branchcode | html %]" selected="selected" >[% library.branchname | html %]</option>
265                                                                     [% ELSIF pickup_available_at %]
266                                                                         <option value="[% library.branchcode | html %]">[% library.branchname | html %]</option>
267                                                                     [% ELSE %]
268                                                                         [% SET at_least_one_library_not_available_for_pickup = 1 %]
269                                                                         <option value="[% library.branchcode | html %]" disabled="disabled" title="At least one item is available at this library">[% library.branchname | html %]</option>
270                                                                     [% END %]
271                                                                 [% END %]
272                                                             </select>
273                                                             [% IF at_least_one_library_not_available_for_pickup %]
274                                                                 <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>
275                                                             [% END %]
276                                                         [% END # / UNLESS bibitemloo.holdable %]
277                                                     </li>
278                                                 [% END # / IF bibitemloo.holdable && Koha.Preference('OPACAllowUserToChooseBranch') %]
279                                             [% END # / UNLESS singleBranchMode %]
280                                         </ul>
281
282                                         <a class="toggle-hold-options" id="toggle-hold-options-[% bibitemloo.biblionumber | html %]" style="display:none;" href="#">Show more options</a>
283
284                                         <div id="hold-options-[% bibitemloo.biblionumber | html %]" class="hold-options">
285
286                                             <ul>
287                                                 [% IF ( reserve_in_future ) %]
288                                                     <li>
289                                                         <label for="from[% bibitemloo.biblionumber | html %]">Hold starts on date:</label>
290                                                         <input type="text" name="reserve_date_[% bibitemloo.biblionumber | html %]" id="from[% bibitemloo.biblionumber | html %]" data-start_for="to[% bibitemloo.biblionumber | html %]" data-flatpickr-futureinclusive="true" size="10" class="flatpickr holddatefrom" />
291                                                         <span class="date-format from" data-biblionumber="[% bibitemloo.biblionumber | html %]">[% INCLUDE 'date-format.inc' %]</span>
292                                                         <div class="required_label" style="display:none;">Required</div>
293                                                     </li>
294                                                 [% END %]
295
296                                                 <li>
297                                                     <label for="to[% bibitemloo.biblionumber | html %]">Hold not needed after:</label>
298                                                     <input type="text" name="expiration_date_[% bibitemloo.biblionumber | html %]" id="to[% bibitemloo.biblionumber | html %]" size="10" data-flatpickr-future="true" class="flatpickr futuredate" />
299                                                     <span class="date-format to" data-biblionumber="[% bibitemloo.biblionumber | html %]">[% INCLUDE 'date-format.inc' %]</span>
300                                                     <div class="required_label" style="display:none;">Required</div>
301                                                 </li>
302
303                                                 [% IF Koha.Preference('AllowHoldItemTypeSelection') %]
304                                                     <li>
305                                                         <label for="itemtype">Request specific item type:</label>
306                                                         <select name="itemtype" id="itemtype">
307                                                             <option value="">Any item type</option>
308                                                             [% FOREACH i IN bibitemloo.allowed_item_types %]
309                                                                 <option value="[% i | html %]">[% ItemTypes.GetDescription( i ) | html %]</option>
310                                                             [%- END %]
311                                                         </select>
312                                                     </li>
313                                                 [% END %]
314
315                                                 [% UNLESS bibitemloo.forced_hold_level && ( bibitemloo.forced_hold_level == 'item' || bibitemloo.forced_hold_level == 'record' ) %]
316                                                     [% IF Koha.Preference('EnableItemGroupHolds') && bibitemloo.object.item_groups %]
317                                                         <li>
318                                                             <label for="itemtype">Request specific item group:</label>
319                                                             <select name="item_group_id_[% bibitemloo.biblionumber | html %]" id="item_group_id_[% bibitemloo.biblionumber | html %]">
320                                                                 <option value="">Any item group</option>
321                                                                 [% FOREACH g IN bibitemloo.object.item_groups.search({}, { order_by => ['display_order'] }) %]
322                                                                     [% IF g.items.count %]
323                                                                         <option value="[% g.id | html %]">[% g.description | html %]</option>
324                                                                     [% END %]
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-times 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         if( OPACMandatoryHoldDates == "start" || OPACMandatoryHoldDates == "both" ) {
523             $(".holddatefrom").prop( 'required', true ).siblings(".required_label").addClass('required').show();
524         }
525         if( OPACMandatoryHoldDates == "end"   || OPACMandatoryHoldDates == "both" ) {
526             $(".futuredate").prop( 'required', true ).siblings(".required_label").addClass('required').show();
527         }
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         if( $(".holddatefrom").prop('required') || $(".futuredate").prop('required') ) $(".toggle-hold-options").click();
556
557         // Hides all 'specific copy' table rows on load.
558         $(".copiesrow").hide();
559
560         [% FOREACH bibitemloo IN bibitemloop %]
561           [% IF bibitemloo.force_hold %]
562             if( $("#to[% bibitemloo.biblionumber | html %]").parent(":hidden").length )
563                 $("#toggle-hold-options-[% bibitemloo.biblionumber | html %]").click();
564             $("#reqspecific_[% bibitemloo.biblionumber | html %]").click();
565             $("#copiesrow_[% bibitemloo.biblionumber | html %]").show();
566           [% END %]
567         [% END %]
568
569         // Replace non-JS single-selection with multi-selection capability.
570         $(".reserve_mode").val("multi");
571         $(".confirm_nonjs").remove();
572         $(".confirmjs_hold").each(function(){
573             var bib = $(this).attr("title");
574             var html = "<label><input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
575             html += "value=\"" + bib + "\" id=\"" + bib + "\" /> " + _("Place a hold on") + " </label> ";
576             $(this).html(html);
577         });
578         $(".confirmjs_nohold").each(function(){
579             var bib = $(this).attr("title");
580             var html = "<label><input type =\"checkbox\" class=\"confirmjs\" disabled=\"disabled\"";
581             html += "value=\"" + bib + "\" id=\"" + bib + "\" />" + _("Place a hold on: ") + "</label>";
582             $(this).html(html);
583         });
584
585         // expand or collapse the copiesrow tr
586         function toggle_copiesrow(biblioNum) {
587             var checkbox = $("input:checkbox[value='"+biblioNum+"']");
588             newCopiesRowId = "#copiesrow_" + biblioNum;
589             var select_specific = $("#reqspecific_"+biblioNum).is(":checked");
590             // If the checkbox is checked AND we want a specific item, we display the items block
591             if ( $(checkbox).is(":checked") && select_specific ) {
592                 if ( $(`#item_group_id_${biblioNum}`).length ) {
593                     $(`#item_group_id_${biblioNum}`).val("").attr('disabled', 'disabled');
594                 }
595                 $(newCopiesRowId).show();
596             } else {
597                 if ( $(`#item_group_id_${biblioNum}`).length ) {
598                     $(`#item_group_id_${biblioNum}`).removeAttr('disabled');
599                 }
600                 $(newCopiesRowId).hide();
601             }
602         };
603
604         $("#place_on_hdr").show();
605
606         $(".place_on_type").show();
607         // onload, selectany is checked
608         $(".selectany").attr("checked", "checked");
609
610
611         // On confirmsjs change
612         $(".confirmjs").change(function(){
613             var id = suffixOf($(this).attr("id"), "_");
614             // If I m checked, I enable radio buttons
615             if ( $(this).is(":checked") ) {
616                 $("#reqspecific_" + id).attr("disabled", false);
617                 $("#reqany_" + id).attr("disabled", false);
618             }
619             // Else its are disabled
620             else {
621                 $("#reqspecific_" + id).attr("disabled", "disabled");
622                 $("#reqany_" + id).attr("disabled", "disabled");
623             }
624             // expand or collaspe the items block
625             toggle_copiesrow(id);
626         });
627
628         // When 'specific copy' or 'first available' radio button is clicked
629         $(".selectspecific, .selectany").click(function() {
630             var id = suffixOf($(this).attr("id"), "_");
631             toggle_copiesrow(id);
632         });
633
634         // Show or hide holds notes
635         $(".shownotes").click(function(){
636             biblioNum = suffixOf($(this).attr("id"), "_");
637             $("#notesrow_"+biblioNum).toggle();
638         });
639
640         // When 'Place Hold' button is clicked
641         $(".placehold").click(function(){
642             var biblionumbers = "";
643             var selections = "";
644
645             [% IF new_reserves_allowed %]
646                 if ($(".confirmjs:checked").size() > [% new_reserves_allowed | html %] ) {
647                     alert(MSG_MAX_HOLDS_EXCEEDED);
648                     return false;
649                 }
650             [% END %]
651
652             if ($(".confirmjs:checked").size() == 0) {
653                 alert( _("No item was selected") );
654                 return false;
655             }
656
657             // Find the items with the 'Hold' box checked
658             var badBib = null;
659             $(".confirmjs:checked").each(function() {
660                 var biblioNum = $(this).val();
661                 biblionumbers += biblioNum + "/";
662                 selections += biblioNum + "/";
663
664                 // If required hold note is empty, make it visible
665                 if( $("#holdnotes_"+biblioNum).attr( 'required' ) && $("#holdnotes_"+biblioNum).val() == '' ) {
666                     if( !$("#hold-options-"+biblioNum).is(':visible')) {
667                         $("#toggle-hold-options-"+biblioNum).click();
668                     }
669                 }
670
671                 if( $(".holddatefrom").prop('required') && $("#from"+ biblioNum).val() == '' ) {
672                     alert(MSG_EMPTY_START_DATE);
673                     badBib = biblioNum;
674                     if( $("#from"+biblioNum).parent(":hidden").length ) $("#toggle-hold-options-"+biblioNum).trigger('click');
675                     $("#from"+biblioNum).siblings('.flatpickr_wrapper').find('.flatpickr-input').trigger('focus');
676                     return false;
677                 } else if( $(".futuredate").prop('required') && $("#to"+ biblioNum).val() == '' ) {
678                     alert(MSG_EMPTY_END_DATE);
679                     badBib = biblioNum;
680                     if( $("#to"+biblioNum).parent(":hidden").length ) $("#toggle-hold-options-"+biblioNum).trigger('click');
681                     $("#to"+biblioNum).siblings('.flatpickr_wrapper').find('.flatpickr-input').trigger('focus');
682                     return false;
683                 }
684
685                 // If the 'specific copy' radio button is checked
686                 if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
687                     // Find the selected copy
688                     var item = $(".checkitem_" + biblioNum + ":checked");
689                     if ($(item).size() == 0) {
690                         alert(MSG_NO_ITEM_SELECTED);
691                         badBib = biblioNum;
692                         return false;
693                     } else {
694                       selections += $(item).val();
695                     }
696                 }
697                 selections += "/";
698
699                 // Add the pickup location
700                 var branchSel = $("#branch_" + biblioNum);
701                 if (branchSel.size() > 0) {
702                     selections += $(branchSel).val();
703                 }
704                 selections += "/";
705                 return true;
706             });
707
708             if (badBib) { // alert has been raised already
709                 return false;
710             }
711
712             $("#selections").val(selections);
713             $("#biblionumbers").val(biblionumbers);
714
715             return true;
716         });
717         $(".itemstable").each(function(){
718             $(this).DataTable({
719                 dom: "t",
720                 initComplete: function() {
721                     this.find("input:radio").first().prop("checked", true );
722                 },
723                 paging: false
724             });
725         });
726     });
727 </script>
728 [% END %]