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