default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / pref / pref.html
1 <& /elements/header.html, mt('Preferences for [_1]', $FS::CurrentUser::CurrentUser->username) &>
2
3 % my $js_form_validate = { 'pref_form' => { 'name' => 'pref_form' } };
4
5 <FORM METHOD="POST" NAME="pref_form" ACTION="pref-process.html">
6
7 <& /elements/error.html &>
8
9 % if ( FS::Auth->auth_class->can('change_password') ) {
10
11     <FONT CLASS="fsinnerbox-title"><% emt('Change password (leave blank for no change)') %></FONT>
12     <TABLE CLASS="fsinnerbox">
13
14       <TR>
15         <TH ALIGN="right"><% emt("Current password:") %> </TH>
16         <TD><INPUT TYPE="password" NAME="_password"></TD>
17       </TR>
18
19       <TR>
20         <TH ALIGN="right"><% emt("New password:") %> </TH>
21         <TD><INPUT TYPE="password" NAME="new_password"></TD>
22       </TR>
23
24       <TR>
25        <TH ALIGN="right"><% emt("Re-enter new password:") %> </TH>
26        <TD><INPUT TYPE="password" NAME="new_password2"></TD>
27       </TR>
28
29     </TABLE>
30     <BR>
31
32     <FONT CLASS="fsinnerbox-title"><% emt('Google Authenticator') %></FONT>
33     <TABLE CLASS="fsinnerbox">
34       <TR>
35 %       if ( $curuser->totp_secret32 ) {
36           <TD><IMG SRC="<% $curuser->totp_qr_code_url %>"</IMG></TD>
37 %       } else {
38           <TD><A HREF="<%$p%>pref/set_totp_secret32.html">Enable</A></TD>
39 %       }
40       </TR>
41     </TABLE>
42     <BR>
43
44 % }
45
46 <FONT CLASS="fsinnerbox-title"><% emt("Interface") %></FONT>
47 <TABLE CLASS="fsinnerbox">
48
49   <TR>
50     <TH ALIGN="right"><% emt("Locale:") %> </TH>
51     <TD COLSPAN=2>
52       <SELECT NAME="locale">
53 %       foreach my $locale ( @locales ) {
54 %         my %info = FS::Locales->locale_info($locale);
55 %         my $selected = ($locale eq $curuser->option('locale'))
56 %                          ? 'SELECTED' : '';
57           <OPTION VALUE="<% $locale %>" <%$selected%>><% $info{name} %> (<% $info{country} %>)
58 %       }
59       </SELECT>
60     </TD>
61   </TR>
62
63   <TR>
64     <TH ALIGN="right" STYLE="vertical-align:top"><% emt("Menu location:") %> </TH>
65     <TD>
66       <INPUT TYPE="radio" NAME="menu_position" VALUE="left" onClick="document.images['menu_example'].src='../images/menu-left-example.png';" <% $menu_position eq 'left' ? ' CHECKED' : ''%>> <% emt("Left") %><BR>
67       <INPUT TYPE="radio" NAME="menu_position" VALUE="top" onClick="document.images['menu_example'].src='../images/menu-top-example.png';" <% $menu_position eq 'top' ? ' CHECKED' : ''%>> <% emt("Top") %> <BR>
68     </TD>
69     <TD><IMG NAME="menu_example" SRC="../images/menu-<% $menu_position %>-example.png"></TD>
70   </TR>
71
72   <TR>
73     <TH ALIGN="right"><% emt("Enable mobile-friendly menu:") %> </TH>
74     <TD COLSPAN=2>
75       <INPUT TYPE="checkbox" NAME="mobile_menu" VALUE="Y"
76 <% $curuser->option('mobile_menu') ? 'CHECKED' : '' %>>
77     </TD>
78   </TR>
79  
80   <TR>
81     <TH ALIGN="right"><% emt("Default customer view:") %> </TH>
82     <TD COLSPAN=2>
83       <SELECT NAME="default_customer_view">
84 %       foreach my $view ( keys %customer_views ) {
85 %         my $selected =
86 %           $customer_views{$view} eq $curuser->option('default_customer_view')
87 %             ? 'SELECTED'
88 %             : '';
89           <OPTION VALUE="<%$customer_views{$view}%>" <%$selected%>><% emt($view) %></OPTION>
90 %       }
91       </SELECT>
92     </TD>
93   </TR>
94
95 % my $history_order = $curuser->option('history_order') || 'oldest';
96   <TR>
97     <TH ALIGN="right"><% emt("Customer history sort order:") %> </TH>
98     <TD COLSPAN=2>
99       <& /elements/select.html,
100         field       => 'history_order',
101         curr_value  => $history_order,
102         options     => [ 'oldest', 'newest' ],
103         labels      => { 'oldest' => mt('Oldest first'),
104                          'newest' => mt('Newest first'),
105                        },
106       &>
107     </TD>
108   </TR>
109   
110   <TR>
111     <TH ALIGN="right"><% emt("Spreadsheet download format:") %> </TH>
112     <TD COLSPAN=2>
113       <SELECT NAME="spreadsheet_format">
114 %       my $xls =  $curuser->option('spreadsheet_format') eq 'XLS';
115 %       my $xlsx = $curuser->option('spreadsheet_format') eq 'XLSX';
116         <OPTION VALUE=""></OPTION>
117         <OPTION VALUE="XLS"<%  $xls ? 'SELECTED' : '' %>>XLS (Excel 97/2000/XP)
118         </OPTION>
119         <OPTION VALUE="XLSX"<% $xlsx ? 'SELECTED' : ''%>>XLSX (Excel 2007+)
120         </OPTION>
121       </SELECT>
122     </TD>
123   </TR>
124
125   <TR>
126     <TH ALIGN="right" COLSPAN=1><% emt("Disable HTML editor for customer notes:") %> </TH>
127     <TD ALIGN="left" COLSPAN=2>
128       <INPUT TYPE="checkbox" NAME="disable_html_editor" VALUE="1" <% $curuser->option('disable_html_editor') ? 'CHECKED' : '' %>>
129     </TD>
130   </TR>
131
132   <TR>
133     <TH ALIGN="right" COLSPAN=1><% emt("Disable submission on Enter key - one-time charges:") %> </TH>
134     <TD ALIGN="left" COLSPAN=2>
135       <INPUT TYPE="checkbox" NAME="disable_enter_submit_onetimecharge" VALUE="1" <% $curuser->option('disable_enter_submit_onetimecharge') ? 'CHECKED' : '' %>>
136     </TD>
137   </TR>
138
139   <TR>
140     <TH ALIGN="right"><% emt("Don't copy MAC address delimiters to clipboard") %></TH>
141     <TD ALIGN="left" COLSPAN=2>
142       <INPUT TYPE="checkbox" NAME="enable_mask_clipboard_hack" VALUE="1" <% $curuser->option('enable_mask_clipboard_hack') ? 'CHECKED' : '' %>>
143     </TD>
144   </TR>
145
146   <TR>
147     <TH ALIGN="right"><% emt("When printing, scale HTML documents to fit on a letter-size page") %></TH>
148     <TD ALIGN="left">
149       <INPUT TYPE="checkbox" NAME="printtofit" VALUE="Y" <% $curuser->option('printtofit') ? 'CHECKED' : '' %>>
150     </TD>
151   </TR>
152
153   <TR>
154     <TH ALIGN="right"><% emt("How many recently-modified customers displayed on dashboard") %></TH>
155     <TD ALIGN="left" COLSPAN=2>
156       <INPUT TYPE="text" NAME="dashboard_customers" VALUE="<% $curuser->option('dashboard_customers') %>"></TD>
157     </TD>
158   </TR>
159
160 % my $validate_field_cve = 'customer_view_emails';
161 % $js_form_validate->{pref_form}->{validate_fields}{$validate_field_cve} = 'digits: true';
162 % $js_form_validate->{pref_form}->{error_message}{$validate_field_cve} = 'Please only enter numbers here.';
163
164   <TR>
165     <TH ALIGN="right"><% emt("How many recent outbound emails to show in customer view") %></TH>
166     <TD ALIGN="left" COLSPAN=2>
167       <INPUT TYPE="text" ID="<% $validate_field_cve %>" NAME="<% $validate_field_cve %>" VALUE="<% $curuser->option('customer_view_emails') %>"></TD>
168     </TD>
169   </TR>
170
171 </TABLE>
172 <BR>
173
174
175 <FONT CLASS="fsinnerbox-title"><% emt("Email Address") %></FONT>
176 <TABLE CLASS="fsinnerbox">
177
178   <TR>
179     <TH><% emt("Email Address(es) (comma separated) ") %></TH>
180     <TD>
181    <TD><INPUT TYPE="text" NAME="email_address" VALUE="<% $email_address %>">
182     </TD>
183   </TR>
184
185 </TABLE>
186 <BR>
187
188
189 <FONT CLASS="fsinnerbox-title"><% emt("Development") %></FONT>
190 <TABLE CLASS="fsinnerbox">
191
192   <TR>
193     <TH><% emt("Show customer package timestamps:") %> </TH>
194     <TD><INPUT TYPE="checkbox" NAME="cust_pkg-display_times" VALUE="1" <% $curuser->option('cust_pkg-display_times') ? 'CHECKED' : '' %>></TD>
195   </TR>
196   <TR>
197     <TH><% emt("Show internal package numbers:") %> </TH>
198     <TD><INPUT TYPE="checkbox" NAME="show_pkgnum" VALUE="1" <% $curuser->option('show_pkgnum') ? 'CHECKED' : '' %>></TD>
199   </TR>
200   <TR>
201     <TH><% emt("Show config item counts:") %> </TH>
202     <TD><INPUT TYPE="checkbox" NAME="show_confitem_counts" VALUE="1" <% $curuser->option('show_confitem_counts') ? 'CHECKED' : '' %>></TD>
203   </TR>
204   <TR>
205     <TH><% emt("Show export data on service view (when available):") %> </TH>
206     <TD><INPUT TYPE="checkbox" NAME="export_getsettings" VALUE="1" <% $curuser->option('export_getsettings') ? 'CHECKED' : '' %>></TD>
207   </TR>
208   <TR>
209     <TH><% emt("Show database profiling (when available):") %> </TH>
210     <TD><INPUT TYPE="checkbox" NAME="show_db_profile" VALUE="1" <% $curuser->option('show_db_profile') ? 'CHECKED' : '' %>></TD>
211   </TR>
212   <TR>
213     <TH><% emt("Save database profiling logs (when available):") %> </TH>
214     <TD><INPUT TYPE="checkbox" NAME="save_db_profile" VALUE="1" <% $curuser->option('save_db_profile') ? 'CHECKED' : '' %>></TD>
215   </TR>
216   <TR>
217     <TH><% emt("Save temporary invoice typesetting files:") %> </TH>
218     <TD><INPUT TYPE="checkbox" NAME="save_tmp_typesetting" VALUE="1" <% $curuser->option('save_tmp_typesetting') ? 'CHECKED' : '' %>></TD>
219   </TR>
220
221 </TABLE>
222 <BR>
223
224 % if ( $curuser->access_right('Employee preference telephony integration') ) {
225
226 <% emt("SNOM integration") %>
227 <% ntable("#cccccc",2) %>
228
229   <TR>
230     <TH ALIGN="right"><% emt("SNOM IP address") %></TH>
231     <TD><INPUT TYPE="text" NAME="snom-ip" VALUE="<% $curuser->option('snom-ip') %>"></TD>
232   </TR>
233
234   <TR>
235     <TH ALIGN="right"><% emt("SNOM HTTP username (if necessary)") %></TH>
236     <TD><INPUT TYPE="text" NAME="snom-username" VALUE="<% $curuser->option('snom-username') %>"></TD>
237   </TR>
238
239   <TR>
240     <TH ALIGN="right"><% emt("SNOM HTTP password (if necessary)") %></TH>
241     <TD><INPUT TYPE="password" NAME="snom-password" VALUE="<% $curuser->option('snom-password') %>"></TD>
242   </TR>
243
244 </TABLE>
245 <BR>
246
247 <% emt("OR")%><BR><BR>
248
249 <% emt("Vonage integration (see") %> <a href="https://secure.click2callu.com/"><% emt("Click2Call") %></a>)
250 <% ntable("#cccccc",2) %>
251
252   <TR>
253     <TH ALIGN="right"><% emt("Vonage phone number") %></TH>
254     <TD><INPUT TYPE="text" NAME="vonage-fromnumber" VALUE="<% $curuser->option('vonage-fromnumber') %>"></TD>
255   </TR>
256
257   <TR>
258     <TH ALIGN="right"><% emt("Vonage username") %></TH>
259     <TD><INPUT TYPE="text" NAME="vonage-username" VALUE="<% $curuser->option('vonage-username') %>"></TD>
260   </TR>
261
262   <TR>
263     <TH ALIGN="right"><% emt("Vonage password") %></TH>
264     <TD><INPUT TYPE="password" NAME="vonage-password" VALUE="<% $curuser->option('vonage-password') %>"></TD>
265   </TR>
266
267 </TABLE>
268 <BR>
269
270 % }
271
272 % foreach my $prop (qw( height width availHeight availWidth colorDepth )) {
273   <INPUT TYPE="hidden" NAME="<% $prop %>" VALUE="">
274   <SCRIPT TYPE="text/javascript">
275   document.pref_form.<% $prop %>.value = screen.<% $prop %>;
276   </script>
277 % }
278
279 <INPUT TYPE="submit" VALUE="<% emt("Update preferences") %>">
280
281 % my %footerdata = (
282 %   'formvalidation' => $js_form_validate,
283 % );
284 <% include("/elements/footer.html", %footerdata) %>
285
286 <%init>
287
288 my $curuser = $FS::CurrentUser::CurrentUser;
289
290 #false laziness w/view/cust_main.cgi and Conf.pm (cust_main-default_view)
291
292 tie my %customer_views, 'Tie::IxHash',
293   'Basics'          => 'basics',
294   'Notes'           => 'notes', #notes and files?
295   'Tickets'         => 'tickets',
296   'Appointments'    => 'appointments',
297   'Quotations'      => 'quotations',
298   'Packages'        => 'packages',
299   'Payment History' => 'payment_history',
300 ;
301 $customer_views{'Change History'} = 'change_history'
302   if $curuser->access_right('View customer history');
303
304 # XSS via your own preferences?  seems unlikely, but nice try anyway...
305 ( $curuser->option('menu_position') || 'top' )
306   =~ /^(\w+)$/ or die "illegal menu_position";
307 my $menu_position = $1;
308 ( $curuser->option('email_address') )
309   =~ /^([,\w\@.\-]*)$/ or die "illegal email_address";  #too late
310 my $email_address = $1;
311
312 my $conf = new FS::Conf;
313
314 my @locales = $conf->config('available-locales');
315
316 if ( ! @locales ) {
317
318         @locales = FS::Locales->locales ;
319
320 }
321
322 </%init>