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