5abe9d6b5e87824cddc0d3b799881eddaf79ee12
[freeside.git] / httemplate / edit / svc_domain.cgi
1 <% include('/elements/header.html', "$action $svc", '') %>
2
3 <% include('/elements/error.html') %>
4
5 <FORM ACTION="<% $p1 %>process/svc_domain.cgi" METHOD=POST>
6 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
7 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
8 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
9
10 <% ntable("#cccccc",2) %>
11
12 <TR>
13   <TD ALIGN="right">Domain</TD>
14   <TD>
15 %   if ( !$svcnum || $conf->exists('svc_domain-edit_domain') ) {
16       <INPUT TYPE="text" NAME="domain" VALUE="<% $domain %>" SIZE=28 MAXLENGTH=63>
17 %   } else {
18       <B><% $domain %></B>
19 %   }
20
21 % if ($export) {
22 <BR>
23 Available top-level domains: <% $export->option('tlds') %>
24 </TR>
25
26 <TR>
27 <INPUT TYPE="radio" NAME="action" VALUE="N"<% $kludge_action eq 'N' ? ' CHECKED' : '' %>>Register at <% $registrar->{'name'} %>
28 <BR>
29
30 <INPUT TYPE="radio" NAME="action" VALUE="M"<% $kludge_action eq 'M' ? ' CHECKED' : '' %>>Transfer to <% $registrar->{'name'} %>
31 <BR>
32
33 <INPUT TYPE="radio" NAME="action" VALUE="I"<% $kludge_action eq 'I' ? ' CHECKED' : '' %>>Registered elsewhere
34
35 </TR>
36
37 % }
38   </TD>
39 </TR>
40
41 % if ( $communigate ) {
42   <TR>
43     <TD ALIGN="right">Administrator domain</TD>
44     <TD>
45       <% include('/elements/select-domain.html',
46                    'element_name' => 'parent_svcnum',
47                    'curr_value'   => $svc_domain->parent_svcnum,
48                    'empty_label'  => '(none)',
49                 )
50       %>
51     </TD>
52   </TR>
53 % } else {
54   <INPUT TYPE="hidden" NAME="parent_svcnum" VALUE="<% $svc_domain->parent_svcnum %>">
55 % }
56
57 % if ( $communigate
58 %      && $part_svc->part_svc_column('cgp_aliases')->columnflag !~ /^[FA]$/ ) {
59
60     <TR>
61       <TD ALIGN="right">Aliases</TD>
62       <TD><INPUT TYPE="text" NAME="cgp_aliases" VALUE="<% $svc_domain->cgp_aliases %>"></TD>
63     </TR>
64
65 % } else {
66     <INPUT TYPE="hidden" NAME="cgp_aliases" VALUE="<% $svc_domain->cgp_aliases %>">
67 % }
68
69 % if ( $part_svc->part_svc_column('max_accounts')->columnflag =~ /^[FA]$/ ) {
70     <INPUT TYPE="hidden" NAME="max_accounts" VALUE="<% $svc_domain->max_accounts %>">
71 % } else {
72     <TR>
73       <TD ALIGN="right">Maximum number of accounts</TD>
74       <TD>
75         <INPUT TYPE="text" NAME="max_accounts" SIZE=5 MAXLENGTH=6 VALUE="<% $svc_domain->max_accounts %>">
76       </TD>
77     </TR>
78 % }
79
80 % if ( $communigate
81 %      && $part_svc->part_svc_column('cgp_accessmodes')->columnflag ne 'F' )
82 % {
83
84   <TR>
85     <TD ALIGN="right">Enabled services</TD>
86     <TD>
87       <% include( '/elements/communigate_pro-accessmodes.html',
88                     'curr_value' => $svc_domain->cgp_accessmodes,
89                 )
90       %>
91     </TD>
92   </TR>
93
94 % } else {
95     <INPUT TYPE="hidden" NAME="cgp_accessmodes" VALUE="<% $svc_domain->cgp_accessmodes() |h %>">
96 % }
97
98 % if ( $communigate
99 %      && $part_svc->part_svc_column('trailer')->columnflag ne 'F' )
100 % {
101
102   <TR>
103     <TD ALIGN="right">Mail trailer</TD>
104     <TD>
105       <TEXTAREA NAME="trailer" ROWS=5 COLS=60><% $svc_domain->trailer() |h %></TEXTAREA>
106     </TD>
107   </TR>
108
109 % } else {
110     <INPUT TYPE="hidden" NAME="trailer" VALUE="<% $svc_domain->trailer() |h %>">
111 % }
112
113
114 </TABLE>
115 <BR>
116
117 % if ( $communigate ) {
118
119 Account defaults
120 <% ntable("#cccccc",2) %>
121
122   <% include('/elements/tr-checkbox.html',
123                'label'      => 'Password modification',
124                'field'      => 'acct_def_password_selfchange',
125                'curr_value' => $svc_domain->acct_def_password_selfchange,
126                'value'      => 'Y',
127             )
128   %>
129
130   <% include('/elements/tr-checkbox.html',
131                'label'      => 'Password recovery',
132                'field'      => 'acct_def_password_recover',
133                'curr_value' => $svc_domain->acct_def_password_recover,
134                'value'      => 'Y',
135             )
136   %>
137
138   <TR>
139     <TD ALIGN="right">Enabled services
140     </TD>
141     <TD><% include('/elements/communigate_pro-accessmodes.html',
142                      'element_name_prefix' => 'acct_def_cgp_accessmodes_',
143                      'curr_value' => $svc_domain->acct_def_cgp_accessmodes,
144                   )
145         %>
146     </TD>
147   </TR>
148
149   <% include('/elements/tr-input-text.html',
150                'label'      => 'Mail storage limit',
151                'field'      => 'acct_def_quota',
152                'curr_value' => $svc_domain->acct_def_quota,
153             )
154   %>
155   <% include('/elements/tr-input-text.html',
156                'label'      => 'File storage limit',
157                'field'      => 'acct_def_file_quota',
158                'curr_value' => $svc_domain->acct_def_file_quota,
159             )
160   %>
161   <% include('/elements/tr-input-text.html',
162                'label'      => 'Files limit',
163                'field'      => 'acct_def_file_maxnum',
164                'curr_value' => $svc_domain->acct_def_file_maxnum,
165             )
166   %>
167   <% include('/elements/tr-input-text.html',
168                'label'      => 'File size limit',
169                'field'      => 'acct_def_file_maxsize',
170                'curr_value' => $svc_domain->acct_def_file_maxsize,
171             )
172   %>
173
174   <% include('/elements/tr-select.html',
175                'label'      => 'Allowed mail rules',
176                'field'      => 'acct_def_cgp_rulesallowed',
177                'options'    => [ '', 'No', 'Filter Only', 'All But Exec', 'Any' ],
178                'labels'     => {
179                                  '' => 'default (No)', #No always the default?
180                                },
181                'curr_value' => $svc_domain->acct_def_cgp_rulesallowed,
182             )
183   %>
184
185   <% include('/elements/tr-checkbox.html',
186                'label'      => 'RPOP modifications',
187                'field'      => 'acct_def_cgp_rpopallowed',
188                'curr_value' => $svc_domain->acct_def_cgp_rpopallowed,
189                'value'      => 'Y',
190             )
191   %>
192
193   <% include('/elements/tr-checkbox.html',
194                'label'      => 'Accepts mail to "all"',
195                'field'      => 'acct_def_cgp_mailtoall',
196                'curr_value' => $svc_domain->acct_def_cgp_mailtoall,
197                'value'      => 'Y',
198             )
199   %>
200
201   <% include('/elements/tr-checkbox.html',
202                'label'      => 'Add trailer to sent mail',
203                'field'      => 'acct_def_cgp_addmailtrailer',
204                'curr_value' => $svc_domain->acct_def_cgp_addmailtrailer,
205                'value'      => 'Y',
206             )
207   %>
208
209 %# false laziness w/svc_acct acct_def
210   <TR>
211     <TD ALIGN="right">Message delete method</TD>
212     <TD>
213       <SELECT NAME="acct_def_cgp_deletemode">
214 %       for ( 'Move To Trash', 'Immediately', 'Mark' ) {
215           <OPTION VALUE="<% $_ %>"
216                   <% $_ eq $svc_domain->acct_def_cgp_deletemode ? 'SELECTED' : '' %>
217           ><% $_ %>
218 %       }
219       </SELECT>
220     </TD>
221   </TR>
222
223   <% include('/elements/tr-select.html',
224                'label'      => 'On logout remove trash',
225                'field'      => 'acct_def_cgp_emptytrash',
226                'options'    => $svc_domain->cgp_emptytrash_values,
227                'labels'     => {
228                                  '' => 'default (92 days)', #right?
229                                },
230                'curr_value' => $svc_domain->acct_def_cgp_emptytrash,
231             )
232   %>
233
234   <% include('/elements/tr-select.html',
235                'label'      => 'Language',
236                'field'      => 'acct_def_cgp_language',
237                'options'    => [ '', qw( English Arabic Chinese Dutch French German Hebrew Italian Japanese Portuguese Russian Slovak Spanish Thai ) ],
238                'labels'     => {
239                                  '' => 'default (English)',
240                                },
241                'curr_value' => $svc_domain->acct_def_cgp_language,
242             )
243   %>
244
245   <% include('/elements/tr-select.html',
246                'label'      => 'Time zone',
247                'field'      => 'acct_def_cgp_timezone',
248                'options'    => $svc_domain->cgp_timezone_values,
249                'labels'     => {
250                                  '' => 'default (HostOS)',
251                                },
252                'curr_value' => $svc_domain->acct_def_cgp_timezone,
253             )
254   %>
255
256   <% include('/elements/tr-select.html',
257                'label'      => 'Layout',
258                'field'      => 'acct_def_cgp_skinname',
259                'options'    => [ '', '***', 'GoldFleece', 'Skin2' ],
260                'labels'     => {
261                                  '' => 'default (***)',
262                                },
263                'curr_value' => $svc_domain->acct_def_cgp_skinname,
264             )
265   %>
266
267   <% include('/elements/tr-select.html',
268                'label'      => 'Pronto style',
269                'field'      => 'acct_def_cgp_prontoskinname',
270                'options'    =>  [ '', 'Pronto', 'Pronto-darkflame', 'Pronto-steel', 'Pronto-twilight', ],
271                'curr_value' => $svc_domain->acct_def_cgp_prontoskinname,
272             )
273   %>
274
275   <% include('/elements/tr-select.html',
276                'label'      => 'Send read receipts',
277                'field'      => 'acct_def_cgp_sendmdnmode',
278                'options'    => [ '', 'Never', 'Manually', 'Automatically' ],
279                'labels'     => {
280                                  '' => 'default (Automatically)',
281                                },
282                'curr_value' => $svc_domain->acct_def_cgp_language,
283             )
284   %>
285
286 %              #XXX rules, archive rule, spam foldering rule(s)
287
288 </TABLE>
289 <BR>
290
291 % } else {
292
293 %   foreach my $f (qw( password_selfchange password_recover cgp_accessmodes
294 %                      quota file_quota file_maxnum file_maxsize
295 %                      cgp_rulesallowed cgp_rpopallowed cgp_mailtoall
296 %                      cgp_addmailtrailer
297 %                      cgp_deletemode cgp_emptytrash cgp_language
298 %                      cgp_timezone cgp_skinname cgp_sendmdnmode
299 %                 )) {
300       <INPUT TYPE="hidden" NAME="acct_def_<%$f%>" VALUE="<% $svc_domain->get("acct_def_$f") %>">
301 %   }
302
303 % }
304
305 <INPUT TYPE="submit" VALUE="Submit">
306
307 </FORM>
308
309 <% include('/elements/footer.html') %>
310
311 <%init>
312
313 die "access denied"
314   unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
315
316 my $conf = new FS::Conf;
317
318 my($svcnum, $pkgnum, $svcpart, $kludge_action, $part_svc,
319    $svc_domain);
320 if ( $cgi->param('error') ) {
321
322   $svc_domain = new FS::svc_domain ( {
323     map { $_, scalar($cgi->param($_)) } fields('svc_domain')
324   } );
325   $svcnum = $svc_domain->svcnum;
326   $pkgnum = $cgi->param('pkgnum');
327   $svcpart = $cgi->param('svcpart');
328   $kludge_action = $cgi->param('action');
329   $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } );
330   die "No part_svc entry!" unless $part_svc;
331
332 } elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
333
334   $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
335   $pkgnum = $1;
336   $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
337   $svcpart = $1;
338
339   $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
340   die "No part_svc entry!" unless $part_svc;
341
342   $svc_domain = new FS::svc_domain({});
343
344   $svcnum='';
345
346   $svc_domain->set_default_and_fixed;
347
348 } else { #editing
349
350   $kludge_action = '';
351   my($query) = $cgi->keywords;
352   $query =~ /^(\d+)$/ or die "unparsable svcnum";
353   $svcnum=$1;
354   $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum})
355     or die "Unknown (svc_domain) svcnum!";
356
357   my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
358     or die "Unknown (cust_svc) svcnum!";
359
360   $pkgnum=$cust_svc->pkgnum;
361   $svcpart=$cust_svc->svcpart;
362
363   $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
364   die "No part_svc entry!" unless $part_svc;
365
366 }
367 my $action = $svcnum ? 'Edit' : 'Add';
368
369 my $svc = $part_svc->getfield('svc');
370
371 my $communigate = scalar($part_svc->part_export('communigate_pro'));
372                 # || scalar($part_svc->part_export('communigate_pro_singledomain'));
373
374 # Find the first export that does domain registration
375 my @exports = grep $_->can('registrar'), $part_svc->part_export;
376 my $export = $exports[0];
377 # If we have a domain registration export, get the registrar object
378 my $registrar = $export ? $export->registrar : '';
379
380 my $otaker = getotaker;
381
382 my $domain = $svc_domain->domain;
383
384 my $p1 = popurl(1);
385
386 </%init>