]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/parts/place_hold.tt2
LP#1838995: Hold group buckets
[Evergreen.git] / Open-ILS / src / templates / 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 = actText;
19         if (cb.checked != true) cb.checked = true;
20     } else {
21         block.style.display = "none";
22         anchor.innerHTML = 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 id='holds_box' class='canvas' style='margin-top: 6px;'>
51     <h1>[% l('Place Hold') %]</h1>
52
53     [% some_holds_allowed = -1 %]
54
55     <!-- loop through the holds and display status of request where appropriate -->
56         [% FOR hdata IN ctx.hold_data;
57             attrs = {marc_xml => hdata.marc_xml};
58             PROCESS get_marc_attrs args=attrs;
59             this_hold_disallowed = 0;
60
61             IF CGI.param('hold_type') == 'M';
62               IF hdata.metarecord_filters.formats.size == 0;
63                 this_hold_disallowed = 1;
64                 # if this is the first hold and it's disallowed,
65                 # assume all holds are, until we proven otherwise
66                 SET some_holds_allowed = 0 IF some_holds_allowed == -1;
67               ELSE; some_holds_allowed = 1; END;
68             END %]
69      
70       [% IF loop.first %] 
71     <form method="post" name="PlaceHold" onsubmit="return validateHoldForm()" >
72         <input type="hidden" name="hold_type" value="[% CGI.param('hold_type') | html %]" />
73         [%  
74             redirect = CGI.param('hold_source_page') || CGI.param('redirect_to') || CGI.referer;
75             # since we have to be logged in to get this far, return to a secure page
76             redirect = redirect.replace('^http:', 'https:') 
77         %]
78         <input type="hidden" name="redirect_to" value="[% redirect | html %]" />
79         <input type="hidden" name="hold_source_page" value="[% CGI.param('hold_source_page') | html %]" />
80
81         <!-- Adding hidden fields so that parameters are maintained in
82         searchbar throughout the place hold process. -->
83         <input type="hidden" name="locg" value="[% CGI.param('locg') | html %]" />
84         <input type="hidden" name="qtype" value="[% CGI.param('qtype') | html %]" />
85         <input type="hidden" name="query" value="[% CGI.param('query') | html %]" />
86         [%
87             usr_barcode = CGI.param('usr_barcode') | html;
88             is_requestor = CGI.param('is_requestor');
89
90            IF is_requestor == '';
91                is_requestor = '0';
92            END;
93
94            IF is_requestor == '0' && usr_barcode == ctx.staff_recipient.card.barcode;
95                usr_barcode = '';
96            END;
97         %]
98
99         [% IF ctx.is_staff %]
100         <!-- request for a patron -->
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             [% IF CGI.param('hold_type') == 'T' AND ctx.hold_subscriptions.size > 0 AND NOT CGI.param('from_basket') %]
133               <br />
134               <!-- request for a reading group / subscription -->
135               <input type="radio" id="hold_usr_is_subscription"
136                   onchange="staff_hold_usr_input_disabler(this);"
137                   name="hold_usr_is_requestor" value="2"
138                   />
139               <label for="hold_usr_is_subscription">
140                   [% l("Place hold for patron Hold Group:") %]
141               </label>
142               <select id='select_hold_subscription' name='hold_subscription'>
143                   <option selected='selected' value=''>[% l('- Hold Groups -') %]</option>
144                   [% FOR sub IN ctx.hold_subscriptions %]
145                   <option value='[% sub.id %]'>[% sub.name | html %]</option>
146                   [% END %]
147               </select>
148             [% END %]
149             <br/>
150             <label>
151               <input id="override_blocks_subscription" name="override" type="checkbox" checked="checked"/>
152               [% l("Override all hold-blocking conditions possible?") %]
153             </label>
154         </p>
155         [% END %]
156
157       [% END %]
158
159         <table id='hold-items-list'>
160             <tr>
161                 <td>
162                     [% IF !this_hold_disallowed %]
163                     <input type="hidden" name="hold_target" value="[% hdata.target.id | html %]" />
164                     [% END %]
165                     <div class='hold-items-list-title'>
166                                             <!-- If hold is for grouped formats/editions (metarecord), show short title - else, show complete title --> 
167                                             [% IF CGI.param('hold_type') == 'M' %]
168                                                     [% attrs.title | html %]
169                                                 [% ELSE %]
170                                                     [% attrs.title_extended | html %]
171                                                 [% END %]
172                     </div>
173                     [% IF hdata.parts AND !this_hold_disallowed %]
174                         [% IF hdata.parts.size > 0 %]
175                         <div class='hold-div'>
176                             [% IF enable.radio.parts == 'true' %]
177                                 <span class='hold-span'><label for='select_hold_part'>[%
178                                l('Select a Part:')
179                                %]</label></span>
180                              <div class='radio-parts-selection'>
181                              [% IF !hdata.part_required %]
182                                 <span class='parts-radio-option'>
183                                  <input type='radio' name='part' value='' onchange='maybeToggleNumCopies(this);' required>[% l('All Parts') %]</span>
184                               [% END %]
185                                [% FOR part IN hdata.parts %]
186                                  <span class='parts-radio-option'><input type='radio' name='part' id=[% part.id %] value=[% part.id %] onchange='maybeToggleNumCopies(this);' required>
187                                   <label for=[% part.id %]>[% part.label | html %]</label></span>
188                               [% END %]
189                               </div>
190                           [% ELSE %]
191                             <span style='font-weight: bold;'><label for='select_hold_part'>[%
192                                 hdata.part_required ? l('Select a Part:') : l('Select a Part (optional):')
193                             %]</label></span>
194                             <select id='select_hold_part' name='part' onchange='maybeToggleNumCopies(this);'>
195                                 [% IF !hdata.part_required %]
196                                 <option selected='selected' value=''>[% l('- All Parts -') %]</option>
197                                 [% END %]
198                                 [% FOR part IN hdata.parts %]
199                                 <option value='[% part.id %]'>[% part.label | html %]</option>
200                                 [% END %]
201                             </select>
202                           [% END %]
203                         </div>
204                         [% ELSE %]
205                         <input type='hidden' name='part' value=''/>
206                         [% END %]
207                     [% END %]
208                     [% INCLUDE "opac/parts/multi_hold_select.tt2" IF NOT (this_hold_disallowed AND hdata.part_required); %]
209                     [% IF NOT metarecords.disabled AND ctx.hold_data.size == 1 %]
210                         [% IF CGI.param('hold_type') == 'T' AND hdata.record.metarecord AND !hdata.part_required %]
211                         <!-- Grab the bre_id so that we can restore it if user accidentally clicks advanced options -->
212                            [% bre_id = hdata.target.id %]
213                             <a  id='advanced_hold_link'
214                                 href="[% mkurl('', {hold_type => 'M', hold_target => hdata.record.metarecord.id, bre_id => bre_id}) %]">
215                                 [% l('Advanced Hold Options') %]</a>
216                         [% END %]
217                         [% IF CGI.param('hold_type') == 'M' AND CGI.param('bre_id') %]
218                             <input type="hidden" name="bre_id" value="[% CGI.param('bre_id') | html %]" />
219                             <a id='basic_hold_link'
220                                href="[% mkurl('', {hold_target => CGI.param('bre_id'), hold_type => 'T'}) %]">
221                                 [% l('Basic Hold Options') %]</a>
222                         [% END %]
223                         [% IF hdata.metarecord_filters.formats.size OR # should this be size > 1
224                             (hdata.metarecord_filters.langs.size && hdata.metarecord_filters.langs.size > 1);
225                             PROCESS metarecord_hold_filters_selector hold_data=hdata;
226                         END;
227                     END %]
228                 </td>
229             </tr>
230
231             [% IF this_hold_disallowed %]
232               <tr><td>
233                 <div class="mr_holds_no_formats">
234                 [% l('This item does not have any formats available for holds placement') %]
235                 </div>
236               </td></tr>
237             [% END %]
238
239             [%  IF !loop.last AND ctx.hold_data.size > 1 %]
240             <tr class="holds_item_row_separator"><td> </td></tr>
241             [% END %]
242
243         [% END %]
244         </table>
245
246         [% IF some_holds_allowed %]
247
248         <p>
249             [%- org_select_id = 'pickup_lib'; -%]
250             <label for="[% org_select_id %]">[%l('Pickup location:') %]</label>
251             [% PROCESS "opac/parts/org_selector.tt2";
252                 INCLUDE build_org_selector name='pickup_lib' 
253                     value=ctx.default_pickup_lib id=org_select_id 
254                     can_have_vols_only=1 hold_pickup_lib=1 %]
255         </p>
256         <p>
257             [% l('Notify when hold is ready for pickup?') %]
258             <blockquote>
259                 <input class="hold-alert-method" type="checkbox" id="email_notify" name="email_notify" value="t"
260                     [% IF !ctx.user.email %]disabled="true"[% ELSIF ctx.default_email_notify %]checked="checked"[% END %]/>
261                     <label for="email_notify">[% l('Yes, by Email') %]</label><br/>
262                 <blockquote>
263                     [% IF !ctx.user.email and !ctx.is_staff; l('No configured Email address. See "My Account" for setting your Email address.');
264                      ELSE; l('Email Address:') %] <span name="email_address">[% ctx.user.email %]</span>[% END %]
265                 </blockquote>
266                 [%- IF allow_phone_notifications == 'true' %]
267                 <input class="hold-alert-method" type="checkbox" id="phone_notify_checkbox" name="phone_notify_checkbox"
268                     [% IF ctx.default_phone_notify %]checked="checked"[% END %]/>
269                     <label for="phone_notify_checkbox">[% l('Yes, by Phone') %]</label><br/>
270                 <blockquote>
271                     <label>[% l('Phone Number:') %]<input type="text" id="phone_notify" name="phone_notify" [% setting = 'opac.default_phone';
272                     IF ctx.user_setting_map.$setting; %] value='[% ctx.user_setting_map.$setting | html %]'
273                     [%- ELSIF ctx.user.day_phone; %] value='[% ctx.user.day_phone | html %]' [% END %]/></label>
274                 </blockquote>
275                 [%- END -%]
276                 [% IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1 %]
277                 <input class="hold-alert-method" type="checkbox" id="sms_notify_checkbox" name="sms_notify_checkbox"
278                     [% IF ctx.default_sms_notify %]checked="checked"[% END %]/>
279                     <label for="sms_notify_checkbox">[% l('Yes, by Text Messaging') %]</label><br/>
280                 <blockquote>
281                     [% INCLUDE "opac/parts/sms_carrier_selector.tt2" %]<br/>
282                     [% INCLUDE "opac/parts/sms_number_textbox.tt2" %]<br/>
283                 </blockquote>
284                 [% END %]
285             </blockquote>
286             <blockquote>
287                 <label for="hold_suspend">
288                 [% IF ctx.hold_data.size == 1;
289                        l('Suspend this hold?');
290                    ELSE;
291                        l('Suspend these holds?');
292                    END %]
293                 </label>
294                 <img src="[% ctx.media_prefix %]/images/question-mark.png[% ctx.cache_key %]"
295                      alt="[% l('Suspend Hold Help') %]"
296                      title="[% l('A suspended hold will retain its place in the queue, but will not be fulfilled until it has been activated.') %]" />
297                 <br/>
298                 <input type="checkbox" name="hold_suspend" id="hold_suspend" value="t"/> [% l('Yes') %]
299                 <a id="actDateToggle" href="#toggled-block-suspend" onclick="return toggleActivationDate();">[% l('Set activation date') %]</a>
300             </blockquote>
301             <blockquote id="toggled-block-suspend">
302                 <label for="thaw_date">[% l('Activate on') %]</label>
303                 <input type="text" id="thaw_date" name="thaw_date" />
304                 <em>[% l('Enter date in MM/DD/YYYY format') %]</em>
305             </blockquote>
306         </p>
307         [% IF CGI.param('from_basket') %]
308           <blockquote><input type="checkbox" name="clear_cart" id="clear_cart" /><label for="clear_cart">[% l('Clear basket after holds are requested?') %]</label></blockquote>
309         [% END %]
310         <input id="place_hold_submit" type="submit" name="submit" 
311             value="[% l('Submit') %]" title="[% l('Submit') %]"
312             alt="[% l('Submit') %]" class="opac-button" />
313         [% END # some_holds_allowed %]
314         <input type="reset" name="cancel" onclick="window.location='[% redirect | html %]'" value="[% l('Cancel') %]" id="holds_cancel" class="opac-button" />
315     </form>
316 </div>
317