]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates-bootstrap/opac/parts/place_hold.tt2
LP1903594 Bootstrap opac: suspend hold not working
[Evergreen.git] / Open-ILS / src / templates-bootstrap / opac / parts / place_hold.tt2
1 [%  PROCESS "opac/parts/misc_util.tt2";
2     PROCESS "opac/parts/hold_error_messages.tt2";
3     PROCESS "opac/parts/metarecord_hold_filters.tt2";
4 %]
5 <script>
6 // Toggle the activation date input and check the suspend checkbox.
7 // If JavaScript is disabled, the CSS will handle the former, but
8 // the latter will not happen.
9 function toggleActivationDate() {
10     var cb = document.getElementById("hold_suspend");
11     var block = document.getElementById("toggled-block-suspend");
12     var anchor = document.getElementById("actDateToggle");
13     var actText = "[%- l('Hide activation date') -%]";
14     var inActText = "[%- l('Set activation date') -%]";
15     // Check for not equal to block so it works on first click.
16     if (block.style.display != "block") {
17         block.style.display = "block";
18         anchor.innerHTML = "<i class='fas fa-calendar' aria-hidden='true'></i> " + actText;
19         if (cb.checked != true) cb.checked = true;
20     } else {
21         block.style.display = "none";
22         anchor.innerHTML = "<i class='fas fa-calendar' aria-hidden='true'></i> " + inActText;
23     }
24     // Prevent the href from being followed, thus overriding the CSS.
25     return false;
26 }
27
28 // Maybe enable or disable the num_copies select when the user selects
29 // or deselects a part.
30 function maybeToggleNumCopies(obj) {
31     var numCopies = document.getElementById("num_copies");
32     // Only if numCopies exists.
33     if (numCopies) {
34         var objValue;
35         if (obj.type == 'radio') {
36             if (obj.checked) objValue = obj.value;
37             else return;
38         } else {
39             objValue = obj.value;
40         }
41         if (objValue && objValue != '') {
42             if (numCopies.value != '1') numCopies.value = '1';
43             if (!numCopies.disabled) numCopies.disabled = true;
44         } else {
45             if (numCopies.disabled) numCopies.disabled = false;
46         }
47     }
48 }
49 </script>
50 <div class='container'>
51 <hr>
52    <h3>[% l('Place Hold') %]</h3>
53
54     [% some_holds_allowed = -1 %]
55
56     <!-- loop through the holds and display status of request where appropriate -->
57         [% FOR hdata IN ctx.hold_data;
58             attrs = {marc_xml => hdata.marc_xml};
59             PROCESS get_marc_attrs args=attrs;
60             this_hold_disallowed = 0;
61
62             IF CGI.param('hold_type') == 'M';
63               IF hdata.metarecord_filters.formats.size == 0;
64                 this_hold_disallowed = 1;
65                 # if this is the first hold and it's disallowed,
66                 # assume all holds are, until we proven otherwise
67                 SET some_holds_allowed = 0 IF some_holds_allowed == -1;
68               ELSE; some_holds_allowed = 1; END;
69             END %]
70
71        [% IF loop.first %]
72     <form method="post" name="PlaceHold" onsubmit="return validateHoldForm()" >
73         <input type="hidden" name="hold_type" value="[% CGI.param('hold_type') | html %]" />
74         [%
75             redirect = CGI.param('hold_source_page') || CGI.param('redirect_to') || CGI.referer;
76             # since we have to be logged in to get this far, return to a secure page
77             redirect = redirect.replace('^http:', 'https:')
78         %]
79         <input type="hidden" name="redirect_to" value="[% redirect | html %]" />
80         <input type="hidden" name="hold_source_page" value="[% CGI.param('hold_source_page') | html %]" />
81
82         <!-- Adding hidden fields so that parameters are maintained in
83         searchbar throughout the place hold process. -->
84         <input type="hidden" name="locg" value="[% CGI.param('locg') | html %]" />
85         <input type="hidden" name="qtype" value="[% CGI.param('qtype') | html %]" />
86         <input type="hidden" name="query" value="[% CGI.param('query') | html %]" />
87         [%
88             usr_barcode = CGI.param('usr_barcode') | html;
89             is_requestor = CGI.param('is_requestor');
90
91            IF is_requestor == '';
92                is_requestor = '0';
93            END;
94
95            IF is_requestor == '0' && usr_barcode == ctx.staff_recipient.card.barcode;
96                usr_barcode = '';
97            END;
98         %]
99
100         [% IF ctx.is_staff %]
101         <p class="staff-hold">
102             <input type="radio" id="hold_usr_is_requestor_not"
103                 onchange="staff_hold_usr_input_disabler(this);"
104                 name="hold_usr_is_requestor" value="0"
105                 />
106             <label for="hold_usr_is_requestor_not">
107                 [% l("Place hold for patron by barcode:") %]
108             </label>
109             <input type="text" name="hold_usr" id="hold_usr_input"
110               aria-label="[% l('Barcode') %]"
111               value="[% usr_barcode | html %]"
112               onpaste="return debounce_barcode_change(event)"
113               onkeydown="return debounce_barcode_change(event)" autofocus />
114             <span id="patron_name"></span>
115             <span id="patron_usr_barcode_not_found" style="display: none">
116               [% l('Patron barcode was not found') %]
117             </span>
118             [% IF ctx.is_browser_staff %]
119             <button id="hold_usr_search" type="button" class="opac-button" style="display: none;">[% l('Patron Search') %]</button>
120             [% END %]
121             <br />
122             <input type="hidden" id="staff_barcode"
123               value="[% ctx.staff_recipient.card.barcode | html %]"/>
124             <span>
125                 <input type="radio" id="hold_usr_is_requestor"
126                     onchange="staff_hold_usr_input_disabler(this);"
127                     name="hold_usr_is_requestor" value="1" />
128                 <label for="hold_usr_is_requestor">
129                     [% l("Place this hold for me ([_1] [_2])", ctx.user.first_given_name, ctx.user.family_name) | html %]
130                 </label>
131             </span>
132         </p>
133         [% END %]
134         [% END %]
135
136         <table>
137             <tr>
138                 <td>
139                     [% IF !this_hold_disallowed %]
140                     <input type="hidden" name="hold_target" value="[% hdata.target.id | html %]" />
141                     [% END %]
142                     <div class='hold-items-list-title'>
143                         <!-- If hold is for grouped formats/editions (metarecord), show short title - else, show complete title -->
144                         [% IF CGI.param('hold_type') == 'M' %]
145                             [% attrs.title | html %]
146                         [% ELSE %]
147                             [% attrs.title_extended | html %]
148                         [% END %]
149                     </div>
150                     [% IF hdata.parts AND !this_hold_disallowed %]
151                         [% IF hdata.parts.size > 0 %]
152                         <div class='hold-div'>
153                             [% IF enable.radio.parts == 'true' %]
154                                 <span class='hold-span'><label for='select_hold_part'>[%
155                                l('Select a Part:')
156                                %]</label></span>
157                              <div class='radio-parts-selection'>
158                              [% IF !hdata.part_required %]
159                                 <span class='parts-radio-option'>
160                                  <input type='radio' name='part' value='' onchange='maybeToggleNumCopies(this);' required>[% l('All Parts') %]</span>
161                               [% END %]
162                                [% FOR part IN hdata.parts %]
163                                  <span class='parts-radio-option'><input type='radio' name='part' id=[% part.id %] value=[% part.id %] onchange='maybeToggleNumCopies(this);' required>
164                                   <label for=[% part.id %]>[% part.label | html %]</label></span>
165                               [% END %]
166                               </div>
167                           [% ELSE %]
168                             <span style='font-weight: bold;'><label for='select_hold_part'>[%
169                                 hdata.part_required ? l('Select a Part:') : l('Select a Part (optional):')
170                             %]</label></span>
171                             <select id='select_hold_part' name='part' onchange='maybeToggleNumCopies(this);'>
172                                 [% IF !hdata.part_required %]
173                                 <option selected='selected' value=''>[% l('- All Parts -') %]</option>
174                                 [% END %]
175                                 [% FOR part IN hdata.parts %]
176                                 <option value='[% part.id %]'>[% part.label | html %]</option>
177                                 [% END %]
178                             </select>
179                           [% END %]
180                         </div>
181                         [% ELSE %]
182                         <input type='hidden' name='part' value=''/>
183                         [% END %]
184                     [% END %]
185             [% INCLUDE "opac/parts/multi_hold_select.tt2" IF NOT (this_hold_disallowed AND hdata.part_required); %]
186
187                 </td>
188             </tr>
189
190             [% IF this_hold_disallowed %]
191               <tr><td>
192                 <div class="mr_holds_no_formats">
193                 [% l('This item does not have any formats available for holds placement') %]
194                 </div>
195               </td></tr>
196             [% END %]
197
198             [%  IF !loop.last AND ctx.hold_data.size > 1 %]
199             <tr class="holds_item_row_separator"><td> </td></tr>
200             [% END %]
201 </table>
202         [% END %]
203
204
205         [% IF some_holds_allowed %]
206
207         <p class="w-50">
208             [%- org_select_id = 'pickup_lib'; -%]
209             <label for="[% org_select_id %]" class="font-weight-bold">[%l('Pickup location:') %]</label>
210             [% PROCESS "opac/parts/org_selector.tt2";
211                 INCLUDE build_org_selector name='pickup_lib'
212                     value=ctx.default_pickup_lib id=org_select_id
213                     can_have_vols_only=1 hold_pickup_lib=1 %]
214         </p>
215
216             <span class="font-weight-bold">[% l('Notify when hold is ready for pickup?') %]</span>
217             <p>
218              <div class="form-check m-2">
219                 <input class="form-check-input" type="checkbox" value="t" id="email_notify" name="email_notify" [% IF !ctx.user.email %]disabled="true"[% ELSIF ctx.default_email_notify %]checked="checked"[% END %]>
220                 <label class="form-check-label" for="email_notify">
221                    [% l('Yes, by Email') %]
222
223                      [% IF !ctx.user.email and !ctx.is_staff; l('<br>No configured Email address. See "My Account" for setting your Email address.'); ELSE; %] : <span id="email_address"><b>[% ctx.user.email %]</b></span>[% END %]
224                 </label>
225             </div>
226
227
228                 <p>
229
230                 </p>
231                 [%- IF allow_phone_notifications == 'true' %]
232                 <div class="form-check m-2">
233                     <input class="form-check-input" type="checkbox" id="phone_notify_checkbox" name="phone_notify_checkbox" [% IF ctx.default_phone_notify %]checked="checked"[% END %]>
234                     <label class="form-check-label" for="phone_notify_checkbox">
235                     [% l('Yes, by Phone') %]
236                     </label>
237                 </div>
238
239                 <p>
240                     <label>[% l('Phone Number:') %]<input type="text" class="form-control" name="phone_notify" [% setting = 'opac.default_phone';
241                     IF ctx.user_setting_map.$setting; %] value='[% ctx.user_setting_map.$setting | html %]'
242                     [%- ELSIF ctx.user.day_phone; %] value='[% ctx.user.day_phone | html %]' [% END %]/></label>
243                 </p>
244                 [%- END -%]
245                 [% IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1 %]
246                 <input class="hold-alert-method" type="checkbox" id="sms_notify_checkbox" name="sms_notify_checkbox"
247                     [% IF ctx.default_sms_notify %]checked="checked"[% END %]/>
248                     <label for="sms_notify_checkbox">[% l('Yes, by Text Messaging') %]</label><br/>
249                 <p>
250                     [% INCLUDE "opac/parts/sms_carrier_selector.tt2" %]<br/>
251                     [% INCLUDE "opac/parts/sms_number_textbox.tt2" %]<br/>
252                 </p>
253                 [% END %]
254             </p>
255             <div>
256
257              [% IF ctx.hold_data.size > 0; %]
258             <div class="form-check m-2">
259                 <input class="form-check-input" type="checkbox" value="t" id="hold_suspend" name="hold_suspend">
260                 <label class="form-check-label" for="hold_suspend">
261                 [% IF ctx.hold_data.size == 1;
262                     l('Suspend this hold?');
263                 ELSE;
264                     l('Suspend these holds?');
265                 END %]
266                   <a href="#" aria-label="[% l('A suspended hold will retain its place in the queue, but will not be fulfilled until it has been activated.') %]" title="[% l('A suspended hold will retain its place in the queue, but will not be fulfilled until it has been activated.') %]" data-toggle="tooltip">
267                     <i class="fas fa-question-circle" aria-hidden="true"></i>
268                 </a>
269                 </label>
270             </div>
271                 [% END %]
272
273
274
275
276                 <a class="btn btn-sm btn-action m-2" id="actDateToggle" href="#toggled-block-suspend" onclick="return toggleActivationDate();"><i class="fas fa-calendar" aria-hidden="true"></i> [% l('Set activation date') %]</a>
277             </div>
278             <blockquote id="toggled-block-suspend">
279             <label for="thaw_date">[% l('Activate on') %]
280               <div class="input-group date" data-provide="datepicker">
281                 <input type="text" class="form-control" name="thaw_date" id="thaw_date" value="[% thaw_date | html %]" data-date-format="mm/dd/yyyy" />
282                 <div class="input-group-addon">
283                     <span class="glyphicon glyphicon-th"></span>
284                 </div>
285             </div>
286             </blockquote>
287
288          [% IF CGI.param('from_basket') %]
289
290            <div class="form-check m-2">
291                     <input class="form-check-input" type="checkbox" value="" id="clear_cart" />
292                     <label class="form-check-label" for="clear_cart">
293                         [% l('Clear basket after holds are requested?') %]
294                     </label>
295                 </div>
296         [% END %]
297                  [% IF NOT metarecords.disabled AND ctx.hold_data.size == 1 %]
298                         [% IF CGI.param('hold_type') == 'T' AND hdata.record.metarecord AND !hdata.part_required %]
299                         <!-- Grab the bre_id so that we can restore it if user accidentally clicks advanced options -->
300                            [% bre_id = hdata.target.id %]
301                             <a  id='advanced_hold_link' class="btn btn-sm btn-link"
302                                 href="[% mkurl('', {hold_type => 'M', hold_target => hdata.record.metarecord.id, bre_id => bre_id}) %]"><i class="fas fa-cog" aria-hidden="true"></i>
303                                 [% l('Advanced Hold Options') %]</a>
304                         [% END %]
305                         [% IF CGI.param('hold_type') == 'M' AND CGI.param('bre_id') %]
306                             <input type="hidden" name="bre_id" value="[% CGI.param('bre_id') %]" />
307                             <a id='basic_hold_link' class="btn btn-sm btn-link"
308                                href="[% mkurl('', {hold_target => CGI.param('bre_id'), hold_type => 'T'}) %]"><i class="fas fa-cog" aria-hidden="true"></i>
309                                 [% l('Basic Hold Options') %]</a>
310                         [% END %]
311                         [% IF hdata.metarecord_filters.formats.size OR # should this be size > 1
312                             (hdata.metarecord_filters.langs.size && hdata.metarecord_filters.langs.size > 1);
313                             PROCESS metarecord_hold_filters_selector hold_data=hdata;
314                         END;
315                     END %]
316         <div class="py-3">
317         <button id="place_hold_submit" type="submit" name="submit"  class="btn btn-confirm" ><i class="fas fa-check"></i> [% l('Submit') %]</button>
318         [% END # some_holds_allowed %]
319         <button type="reset" name="cancel" onclick="window.location='[% redirect | html %]'" id="holds_cancel" class="btn btn-deny"><i class="fas fa-ban" aria-hidden="true"></i> [% l('Cancel') %]</button>
320         </div>
321     </form>
322 </div>
323