]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/myopac/prefs_notify.tt2
LP#1570072: update hold notification methods upon preference changes
[Evergreen.git] / Open-ILS / src / templates / opac / myopac / prefs_notify.tt2
1 [%  PROCESS "opac/parts/header.tt2";
2     WRAPPER "opac/parts/myopac/prefs_base.tt2";
3     myopac_page = "prefs";
4     prefs_page = 'prefs_notify' %]
5
6 <h3 class="sr-only">[% l('Notification Preferences') %]</h3>
7     [% IF ctx.affectedChgs %]
8
9         [% # get hash of sms carriers keyed by id:
10             temp = ctx.search_csc('active','t');
11             tcos = { '0' => 'None' };
12             FOR o IN temp;
13                 id = o.id;
14                 tcos.$id = o;
15             END;
16         %]
17   <h4 class="">[% l('You have updated notification preferences. Those changes only affect future holds. Would you like to update existing holds to use the new information?') %]</h4>
18     <form id="hold_updates_form" name="hold_updates_form" method='post' action="./prefs_notify_changed_holds" onsubmit='return updateHoldsCheck()'>
19         <table class="full-width data_grid" id="acct_search_main" 
20             title="[% l('Notification Preferences') %]">
21             <tbody>
22         [% SET blnk = l('Blank') %]
23         [% FOR c IN ctx.affectedChgs %]
24             <tr>
25               <td>
26                 [% IF c.2 == 'sms_info' %]
27                 <input type='hidden' name="[% c.2 %][]" value="[% c.0.carrier _ ',' _ c.0.sms | html %]" />
28                 <input type='hidden' name="[% c.2 %][]" value="[% c.1.carrier _ ',' _ c.1.sms | html %]" />
29                 [% ELSE %]
30                 <input type='hidden' name="[% c.2 %][]" value="[% c.0 %]" />
31                 <input type='hidden' name="[% c.2 %][]" value="[% c.1 %]" />
32                 [% END %]
33                 <input type='hidden' name="[% c.2 %][]" value="[% c.2 %]" />
34                 <input type='hidden' name="[% c.2 %][]" value="[% FOREACH i IN c.3 %][% i %],[% END %]" />
35                 <input id="[% c %]" type="checkbox" onchange="canSubmit(event)" name="[% c.2 %][]"/>
36                 [% IF c.2 == 'sms_info' %]
37                     [% SET disp_name = l('SMS carrier/number') %]
38                     <label for="[% c %]">[% c.3.size %] hold(s) currently with [% disp_name %] set to '[% old = c.0.carrier; tcos.$old.name() ? tcos.$old.name() : blnk | html %]/[% c.0.sms ? c.0.sms : blnk | html %]'. Update to '[% new = c.1.carrier; tcos.$new.name()  ? tcos.$new.name() : blnk | html %]/[% c.1.sms ? c.1.sms : blnk | html %]'?</label>
39                 [% ELSIF c.2.match('_notify') %]
40                     [% SET f_name = c.2.replace("_", " "); Y = l('YES'); N = l('NO') %]
41                     <label for="[% c %]">[% c.3.size %] hold(s) currently with [% f_name %] set to [% c.0 == 'false' ? N : Y %]. Update to [% c.1 == 'false' ? N : Y %]?</label>
42                 [% ELSE %]
43                     [% SET f_name = c.2.replace("_", " ") %]
44                     <label for="[% c %]">[% c.3.size %] hold(s) currently with [% f_name %] set to '[% c.0 ? c.0 : blnk %]'. Update to '[% c.1 ? c.1 : blnk %]'?</label>
45                 [% END %]
46               </td>
47             </tr>
48         [% END %]
49             </tbody>
50         </table>
51         <input type='submit' disabled value="[% l('Update') %]" class="opac-button" />
52         <a href='/eg/opac/myopac/prefs_notify'>[% l('Continue without updating') %]</a>
53     </form>
54
55     [% ELSE %]
56         <form id="hold_notify_form" name="hold_notify_form" method='post'>
57             [% setting = 'opac.hold_notify' %]
58             <input name='[% setting %]' type="hidden"
59                 [% IF ctx.user_setting_map.$setting; %] value='[% ctx.user_setting_map.$setting | html %]' [% END %]/>
60
61             <table class="full-width data_grid" id="acct_search_main" 
62                 title="[% l('Notification Preferences') %]">
63                 <tbody>
64
65                     [% IF ctx.updated_user_settings %]
66                     <tr><td colspan='2'>
67                         <div class='renew-summary'>
68                             [% l('Account Successfully Updated') %]
69                         </div>
70                     </td></tr>
71                     [% END %]
72
73                     [% setting = 'opac.hold_notify' %]
74                     <tr>
75                         [%# WCAG insists that labels for checkboxes contain the input
76                             or directly follow the input, which would not look right
77                             with the rest of the table.  As an alternative, we can
78                             repeat the label as a title attr.
79                             http://www.w3.org/TR/WCAG20-TECHS/H44.html %]
80                         [% email_label = l('Notify by Email by default when a hold is ready for pickup?') %]
81
82                         <td><label for='[% setting %].email'>[% email_label %]</label></td>
83                         <td>
84                             <input onchange="record_change(event)" id='[% setting %].email' name='[% setting %].email'
85                                 type="checkbox" title="[% email_label %]"
86                                 [% IF (matches = ctx.user_setting_map.$setting.match('email')); %] checked='checked' [% END %]/>
87                         </td>
88                     </tr>
89                     [%- IF allow_phone_notifications == 'true';
90                         setting = 'opac.hold_notify'; 
91                     -%]
92                     <tr>
93                         [% phone_label = l('Notify by Phone by default when a hold is ready for pickup?') %]
94                         <td><label for='[% setting %].phone'>[% phone_label %]</label></td>
95                         <td>
96                             <input onchange="record_change(event)" id='[% setting %].phone' name='[% setting %].phone'
97                                 type="checkbox" title="[% phone_label %]"
98                                 [% IF (matches = ctx.user_setting_map.$setting.match('phone')); %] checked='checked' [% END %]/>
99                         </td>
100                     </tr>
101                     [% setting = 'opac.default_phone' %]
102                     <tr>
103                         <td><label for='[% setting %]'>[% l('Default Phone Number') %]</label></td>
104                         <td>
105                             <input onchange="record_change(event)" id='[% setting %]' name='[% setting %]' type="text"
106                                 [% IF ctx.user_setting_map.$setting; %] value='[% ctx.user_setting_map.$setting | html %]' [% END %]/>
107                         </td>
108                     </tr>
109                     [%- END %]
110                     [%- IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1;
111                        setting = 'opac.hold_notify';
112                     -%]
113                     <tr>
114                         [% sms_label = l('Notify by Text by default when a hold is ready for pickup?') %]
115                         <td><label for='[% setting %].sms'>[% sms_label %]</label></td>
116                         <td>
117                             <input onchange="record_change(event)" id='[% setting %].sms' name='[% setting %].sms'
118                                 type="checkbox" title="[% sms_label %]"
119                                 [% IF (matches = ctx.user_setting_map.$setting.match('sms')); %] checked='checked' [% END %]/>
120                         </td>
121                     </tr>
122                     <tr>
123                         <td>[% l('Default Mobile Carrier') %]</td>
124                         <td>[% INCLUDE "opac/parts/sms_carrier_selector.tt2" sms_carrier_hide_label="true" %]</td>
125                     </tr>
126                     [% setting = 'opac.default_sms_notify' %]
127                     <tr>
128                         <td><label for='[% setting %]'>[% l('Default Mobile Number') %]</label></td>
129                         <td>
130                             <input onchange="record_change(event)" id='[% setting %]' name='[% setting %]' type="text"
131                                 [% IF ctx.user_setting_map.$setting; %] value='[% ctx.user_setting_map.$setting | html %]' [% END %]/>
132                             [% l('Hint: use the full 10 digits of your phone #, no spaces, no dashes'); %]
133                         </td>
134                     </tr>
135                     [% END %]
136                     [% FOR optin IN ctx.opt_in_settings %]
137                     <tr>
138                         <td><label for='[% optin.cust.name | uri %]'>[% optin.cust.label | html %]</label></td>
139                         <td>
140                             <input type='checkbox' name='setting' 
141                                 value='[% optin.cust.name | uri %]' 
142                                 id='[% optin.cust.name | uri %]' 
143                                 title="[% optin.cust.label | html %]"
144                                 [% IF optin.value %] checked='checked' [% END %]/>
145                         </td>
146                     </tr>
147                     [% END %]
148                 </tbody>
149             </table>
150
151             <input type='submit' value="[% l('Save') %]" class="opac-button" />
152         </form>
153     [% END %]
154 [% END %]
155
156