b40c34c5d0e9228dab01ad9a9316e15207f91993
[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 </script>
28 <div id='holds_box' class='canvas' style='margin-top: 6px;'>
29     <h1>[% l('Place Hold') %]</h1>
30
31     [% some_holds_allowed = -1 %]
32
33     <!-- loop through the holds and display status of request where appropriate -->
34         [% FOR hdata IN ctx.hold_data;
35             attrs = {marc_xml => hdata.marc_xml};
36             PROCESS get_marc_attrs args=attrs;
37             this_hold_disallowed = 0;
38
39             IF CGI.param('hold_type') == 'M';
40               IF hdata.metarecord_filters.formats.size == 0;
41                 this_hold_disallowed = 1;
42                 # if this is the first hold and it's disallowed,
43                 # assume all holds are, until we proven otherwise
44                 SET some_holds_allowed = 0 IF some_holds_allowed == -1;
45               ELSE; some_holds_allowed = 1; END;
46             END %]
47       
48     <form method="post" name="PlaceHold" onsubmit="return validateHoldForm()" >
49         <input type="hidden" name="hold_type" value="[% CGI.param('hold_type') | html %]" />
50         [%  
51             redirect = CGI.param('hold_source_page') || CGI.param('redirect_to') || CGI.referer;
52             # since we have to be logged in to get this far, return to a secure page
53             redirect = redirect.replace('^http:', 'https:') 
54         %]
55         <input type="hidden" name="redirect_to" value="[% redirect | html %]" />
56         <input type="hidden" name="hold_source_page" value="[% CGI.param('hold_source_page') | html %]" />
57
58         <!-- Adding hidden fields so that parameters are maintained in
59         searchbar throughout the place hold process. -->
60         <input type="hidden" name="locg" value="[% CGI.param('locg') | html %]" />
61         <input type="hidden" name="qtype" value="[% CGI.param('qtype') | html %]" />
62         <input type="hidden" name="query" value="[% CGI.param('query') | html %]" />
63         [%
64             usr_barcode = CGI.param('usr_barcode') | html;
65             is_requestor = CGI.param('is_requestor');
66
67            IF is_requestor == '';
68                is_requestor = '0';
69            END;
70
71            IF is_requestor == '0' && usr_barcode == ctx.staff_recipient.card.barcode;
72                usr_barcode = '';
73            END;
74         %]
75
76         [% IF ctx.is_staff %]
77         <p class="staff-hold">
78             <input type="radio" id="hold_usr_is_requestor_not"
79                 onchange="staff_hold_usr_input_disabler(this);"
80                 name="hold_usr_is_requestor" value="0"
81                 />
82             <label for="hold_usr_is_requestor_not">
83                 [% l("Place hold for patron by barcode:") %]
84             </label>
85             <input type="text" name="hold_usr" id="hold_usr_input" 
86               value="[% usr_barcode | html %]" 
87               onchange="staff_hold_usr_barcode_changed();" 
88               onpaste="setTimeout(staff_hold_usr_barcode_changed,1);" 
89               onkeypress="return no_hold_submit(event)" autofocus /> 
90             <span id="patron_name"></span>
91             <span id="patron_usr_barcode_not_found" style="display: none">
92               [% l('Patron barcode was not found') %]
93             </span>
94             [% IF ctx.is_browser_staff %]
95             <button id="hold_usr_search" type="button" class="opac-button" style="display: none;">[% l('Patron Search') %]</button>
96             [% END %]
97             <br />
98             <input type="hidden" id="staff_barcode" 
99               value="[% ctx.staff_recipient.card.barcode | html %]"/>
100             <span>
101                 <input type="radio" id="hold_usr_is_requestor"
102                     onchange="staff_hold_usr_input_disabler(this);"
103                     name="hold_usr_is_requestor" value="1" />
104                 <label for="hold_usr_is_requestor">
105                     [% l("Place this hold for me ([_1] [_2])", ctx.user.first_given_name, ctx.user.family_name) | html %]
106                 </label>
107             </span>
108         </p>
109         [% END %]
110
111         <table id='hold-items-list'>
112             <tr>
113                 <td>
114                     [% IF !this_hold_disallowed %]
115                     <input type="hidden" name="hold_target" value="[% hdata.target.id | html %]" />
116                     [% END %]
117                     <div class='hold-items-list-title'>
118                                             <!-- If hold is for grouped formats/editions (metarecord), show short title - else, show complete title --> 
119                                             [% IF CGI.param('hold_type') == 'M' %]
120                                                     [% attrs.title | html %]
121                                                 [% ELSE %]
122                                                     [% attrs.title_extended | html %]
123                                                 [% END %]
124                     </div>
125                     [% IF hdata.parts AND !this_hold_disallowed %]
126                         [% IF hdata.parts.size > 0 %]
127                         <div class='hold-div'>
128                             [% IF enable.radio.parts == 'true' %]
129                                 <span class='hold-span'><label for='select_hold_part'>[%
130                                l('Select a Part:')
131                                %]</label></span>
132                              <div class='radio-parts-selection'>
133                              [% IF !hdata.part_required %]
134                                 <span class='parts-radio-option'>
135                                  <input type='radio' name='part' value='' required>[% l('All Parts') %]</span>
136                               [% END %]
137                                [% FOR part IN hdata.parts %]
138                                  <span class='parts-radio-option'><input type='radio' name='part' id=[% part.id %] value=[% part.id %] required>
139                                   <label for=[% part.id %]>[% part.label | html %]</label></span>
140                               [% END %]
141                               </div>
142                           [% ELSE %]
143                             <span style='font-weight: bold;'><label for='select_hold_part'>[%
144                                 hdata.part_required ? l('Select a Part:') : l('Select a Part (optional):')
145                             %]</label></span>
146                             <select id='select_hold_part' name='part'>
147                                 [% IF !hdata.part_required %]
148                                 <option selected='selected' value=''>[% l('- All Parts -') %]</option>
149                                 [% END %]
150                                 [% FOR part IN hdata.parts %]
151                                 <option value='[% part.id %]'>[% part.label | html %]</option>
152                                 [% END %]
153                             </select>
154                           [% END %]
155                         </div>
156                         [% ELSE %]
157                         <input type='hidden' name='part' value=''/>
158                         [% END %]
159                     [% END %]
160                     [% INCLUDE "opac/parts/multi_hold_select.tt2" IF NOT (this_hold_disallowed AND hdata.part_required); %]
161                     [% IF NOT metarecords.disabled %]
162                         [% IF CGI.param('hold_type') == 'T' AND hdata.record.metarecord AND !hdata.part_required %]
163                         <!-- Grab the bre_id so that we can restore it if user accidentally clicks advanced options -->
164                            [% bre_id = hdata.target.id %]
165                             <a  id='advanced_hold_link'
166                                 href="[% mkurl('', {hold_type => 'M', hold_target => hdata.record.metarecord.id, bre_id => bre_id}) %]">
167                                 [% l('Advanced Hold Options') %]</a>
168                         [% END %]
169                         [% IF CGI.param('hold_type') == 'M' AND CGI.param('bre_id') %]
170                             <input type="hidden" name="bre_id" value="[% CGI.param('bre_id') %]" />
171                             <a id='basic_hold_link'
172                                href="[% mkurl('', {hold_target => CGI.param('bre_id'), hold_type => 'T'}) %]">
173                                 [% l('Basic Hold Options') %]</a>
174                         [% END %]
175                         [% IF hdata.metarecord_filters.formats.size OR # should this be size > 1
176                             (hdata.metarecord_filters.langs.size && hdata.metarecord_filters.langs.size > 1);
177                             PROCESS metarecord_hold_filters_selector hold_data=hdata;
178                         END;
179                     END %]
180                 </td>
181             </tr>
182
183             [% IF this_hold_disallowed %]
184               <tr><td>
185                 <div class="mr_holds_no_formats">
186                 [% l('This item does not have any formats available for holds placement') %]
187                 </div>
188               </td></tr>
189             [% END %]
190
191             [%  IF !loop.last AND ctx.hold_data.size > 1 %]
192             <tr class="holds_item_row_separator"><td> </td></tr>
193             [% END %]
194
195         [% END %]
196         </table>
197
198         [% IF some_holds_allowed %]
199
200         <p>
201             [%- org_select_id = 'pickup_lib'; -%]
202             <label for="[% org_select_id %]">[%l('Pickup location:') %]</label>
203             [% PROCESS "opac/parts/org_selector.tt2";
204                 INCLUDE build_org_selector name='pickup_lib' 
205                     value=ctx.default_pickup_lib id=org_select_id 
206                     can_have_vols_only=1 hold_pickup_lib=1 %]
207         </p>
208         <p>
209             [% l('Notify when hold is ready for pickup?') %]
210             <blockquote>
211                 <input class="hold-alert-method" type="checkbox" id="email_notify" name="email_notify" value="t"
212                     [% IF !ctx.user.email %]disabled="true"[% ELSIF ctx.default_email_notify %]checked="checked"[% END %]/>
213                     <label for="email_notify">[% l('Yes, by Email') %]</label><br/>
214                 <blockquote>
215                     [% IF !ctx.user.email and !ctx.is_staff; l('No configured Email address. See "My Account" for setting your Email address.');
216                      ELSE; l('Email Address:') %] <span name="email_address">[% ctx.user.email %]</span>[% END %]
217                 </blockquote>
218                 [%- IF allow_phone_notifications == 'true' %]
219                 <input class="hold-alert-method" type="checkbox" id="phone_notify_checkbox" name="phone_notify_checkbox"
220                     [% IF ctx.default_phone_notify %]checked="checked"[% END %]/>
221                     <label for="phone_notify_checkbox">[% l('Yes, by Phone') %]</label><br/>
222                 <blockquote>
223                     <label>[% l('Phone Number:') %]<input type="text" name="phone_notify" [% setting = 'opac.default_phone';
224                     IF ctx.user_setting_map.$setting; %] value='[% ctx.user_setting_map.$setting | html %]'
225                     [%- ELSIF ctx.user.day_phone; %] value='[% ctx.user.day_phone | html %]' [% END %]/></label>
226                 </blockquote>
227                 [%- END -%]
228                 [% IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1 %]
229                 <input class="hold-alert-method" type="checkbox" id="sms_notify_checkbox" name="sms_notify_checkbox"
230                     [% IF ctx.default_sms_notify %]checked="checked"[% END %]/>
231                     <label for="sms_notify_checkbox">[% l('Yes, by Text Messaging') %]</label><br/>
232                 <blockquote>
233                     [% INCLUDE "opac/parts/sms_carrier_selector.tt2" %]<br/>
234                     [% INCLUDE "opac/parts/sms_number_textbox.tt2" %]<br/>
235                 </blockquote>
236                 [% END %]
237             </blockquote>
238             <blockquote>
239                 [% IF ctx.hold_data.size == 1;
240                        l('Suspend this hold?');
241                    ELSE;
242                        l('Suspend these holds?');
243                    END %]
244                 <img src="[% ctx.media_prefix %]/images/question-mark.png[% ctx.cache_key %]"
245                      alt="[% l('Suspend Hold Help') %]"
246                      title="[% l('A suspended hold will retain its place in the queue, but will not be fulfilled until it has been activated.') %]" />
247                 <br/>
248                 <input type="checkbox" name="hold_suspend" id="hold_suspend" value="t"/> [% l('Yes') %]
249                 <a id="actDateToggle" href="#toggled-block-suspend" onclick="return toggleActivationDate();">[% l('Set activation date') %]</a>
250             </blockquote>
251             <blockquote id="toggled-block-suspend">
252                 <label for="thaw_date">[% l('Activate on') %]</label>
253                 <input type="text" id="thaw_date" name="thaw_date" />
254                 <em>[% l('Enter date in MM/DD/YYYY format') %]</em>
255             </blockquote>
256         </p>
257         <input id="place_hold_submit" type="submit" name="submit" 
258             value="[% l('Submit') %]" title="[% l('Submit') %]"
259             alt="[% l('Submit') %]" class="opac-button" />
260         [% END # some_holds_allowed %]
261         <input type="reset" name="cancel" onclick="window.location='[% redirect | html %]'" value="[% l('Cancel') %]" id="holds_cancel" class="opac-button" />
262     </form>
263 </div>
264