1 <& /elements/header.html, mt("$action [_1] account",$svc) &>
3 <& /elements/error.html &>
7 <& /elements/small_custview.html, $cust_main, '', 1,
8 popurl(2) . "view/cust_main.cgi" &>
12 <SCRIPT TYPE="text/javascript">
13 function randomPass() {
15 var pw_set='<% join('', 'a'..'z', 'A'..'Z', '0'..'9' ) %>';
19 pass += pw_set.charAt(Math.floor(Math.random() * pw_set.length));
21 document.OneTrueForm.clear_password.value = pass;
25 <FORM NAME="OneTrueForm" ACTION="<% $p1 %>process/svc_acct.cgi" METHOD=POST>
26 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
27 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
28 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
31 % my $svclabel = emt("Service #[_1]",$svcnum);
32 % $svclabel =~ s/$svcnum/<B>$svcnum<\/B>/;
35 <% mt("Service # (NEW)") |h %>
39 <% ntable("#cccccc",2) %>
42 <TD ALIGN="right"><% mt('Service') |h %></TD>
43 <TD BGCOLOR="#eeeeee"><% $part_svc->svc %></TD>
47 <TD ALIGN="right"><% mt('Username') |h %></TD>
48 % if ( $svcnum && $conf->exists('svc_acct-no_edit_username') ) {
49 <TD BGCOLOR="#eeeeee"><% $svc_acct->username() %></TD>
50 <INPUT TYPE="hidden" NAME="username" VALUE="<% $username %>">
53 <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
58 %if ( $part_svc->part_svc_column('_password')->columnflag ne 'F' ) {
60 <TD ALIGN="right"><% mt('Password') |h %></TD>
62 <INPUT TYPE="text" NAME="clear_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $pmax %>>
63 <INPUT TYPE="button" VALUE="<% mt('Generate') |h %>" onclick="randomPass();">
67 <INPUT TYPE="hidden" NAME="clear_password" VALUE="<% $password %>">
69 <INPUT TYPE="hidden" NAME="_password_encoding" VALUE="<% $svc_acct->_password_encoding %>">
71 %my $sec_phrase = $svc_acct->sec_phrase;
72 %if ( $conf->exists('security_phrase')
73 % && $part_svc->part_svc_column('sec_phrase')->columnflag ne 'F' ) {
76 <TD ALIGN="right"><% mt('Security phrase') |h %></TD>
78 <INPUT TYPE="text" NAME="sec_phrase" VALUE="<% $sec_phrase %>" SIZE=32>
79 (<% mt('for forgotten passwords') |h %>)
84 <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="<% $sec_phrase %>">
88 %my $domsvc = $svc_acct->domsvc || 0;
89 %if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
92 <INPUT TYPE="hidden" NAME="domsvc" VALUE="<% $domsvc %>">
95 % my %svc_domain = ();
98 % my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $domsvc, } );
99 % if ( $svc_domain ) {
100 % $svc_domain{$svc_domain->svcnum} = $svc_domain->domain;
102 % warn "unknown svc_domain.svcnum for svc_acct.domsvc: $domsvc";
106 % %svc_domain = (%svc_domain,
107 % domain_select_hash FS::svc_acct('svcpart' => $svcpart,
108 % 'pkgnum' => $pkgnum,
113 <TD ALIGN="right"><% mt('Domain') |h %></TD>
115 <SELECT NAME="domsvc" SIZE=1>
116 % foreach my $svcnum (
117 % sort { $svc_domain{$a} cmp $svc_domain{$b} }
120 % my $svc_domain = $svc_domain{$svcnum};
123 <OPTION VALUE="<% $svcnum %>" <% $svcnum == $domsvc ? ' SELECTED' : '' %>><% $svc_domain{$svcnum} %>
132 % if ( $communigate ) {
135 <TD ALIGN="right"><% mt('Aliases') |h %></TD>
136 <TD><INPUT TYPE="text" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>"></TD>
140 <INPUT TYPE="hidden" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>">
144 <& /elements/tr-select-svc_pbx.html,
145 'curr_value' => $svc_acct->pbxsvc,
146 'part_svc' => $part_svc,
147 'cust_pkg' => $cust_pkg,
151 %my $popnum = $svc_acct->popnum || 0;
152 %if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
155 <INPUT TYPE="hidden" NAME="popnum" VALUE="<% $popnum %>">
159 <TD ALIGN="right"><% mt('Access number') |h %></TD>
160 <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
165 %if ( $conf->exists('svc_acct-tower_sector')
166 % && $part_svc->part_svc_column('sectornum')->columnflag ne 'F' ) {
167 <& /elements/tr-select-tower_sector.html,
168 'curr_value' => $svc_acct->sectornum,
169 #'part_svc' => $part_svc,
170 #'cust_pkg' => $cust_pkg,
173 <INPUT TYPE="hidden" NAME="sectornum" VALUE="<% $svc_acct->sectornum %>">
177 % foreach my $xid (qw( uid gid )) {
179 % if ( $part_svc->part_svc_column($xid)->columnflag =~ /^[FA]$/
180 % || ! $conf->exists("svc_acct-edit_$xid")
183 % if ( length($svc_acct->$xid()) ) {
186 <TD ALIGN="right"><% uc($xid) %></TD>
187 <TD BGCOLOR="#eeeeee"><% $svc_acct->$xid() %></TD>
193 <INPUT TYPE="hidden" NAME="<% $xid %>" VALUE="<% $svc_acct->$xid() %>">
197 <TD ALIGN="right"><% uc($xid) %></TD>
199 <INPUT TYPE="text" NAME="<% $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<% $svc_acct->$xid() %>">
206 %if ( $part_svc->part_svc_column('uid')->columnflag eq 'F'
207 % && ! $svc_acct->finger ) {
210 <INPUT TYPE="hidden" NAME="finger" VALUE="">
215 <TD ALIGN="right"><% mt('Real Name') |h %></TD>
217 <INPUT TYPE="text" NAME="finger" VALUE="<% $svc_acct->finger %>">
223 %if ( $part_svc->part_svc_column('dir')->columnflag eq 'F'
224 % || !$curuser->access_right('Edit home dir')
228 <INPUT TYPE="hidden" NAME="dir" VALUE="<% $svc_acct->dir %>">
233 <TD ALIGN="right"><% mt('Home directory') |h %></TD>
234 <TD><INPUT TYPE="text" NAME="dir" VALUE="<% $svc_acct->dir %>"></TD>
239 %my $shell = $svc_acct->shell;
240 %if ( $part_svc->part_svc_column('shell')->columnflag eq 'F'
241 % || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' )
245 <INPUT TYPE="hidden" NAME="shell" VALUE="<% $shell %>">
250 <TD ALIGN="right"><% mt('Shell') |h %></TD>
252 <SELECT NAME="shell" SIZE=1>
255 % foreach $etc_shell (@shells) {
258 <OPTION<% $etc_shell eq $shell ? ' SELECTED' : '' %>><% $etc_shell %>
267 <& svc_acct/communigate.html,
268 'svc_acct' => $svc_acct,
269 'part_svc' => $part_svc,
270 'communigate' => $communigate,
273 % if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) {
274 <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>">
277 <TD ALIGN="right"><% mt('IP') |h %></TD>
278 <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD>
282 % my %label = ( seconds => 'Time',
283 % upbytes => 'Upload bytes',
284 % downbytes => 'Download bytes',
285 % totalbytes => 'Total bytes',
287 % foreach my $uf (keys %label) {
288 % my $tf = $uf . "_threshold";
289 % if ( $curuser->access_right('Edit usage') ) {
291 <TD ALIGN="right"><% mt("[_1] remaining",$label{$uf}) |h %> </TD>
292 <TD><INPUT TYPE="text" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">(<% mt('blank disables') |h %>)</TD>
295 <TD ALIGN="right"><% mt("[_1] threshold",$label{$uf}) |h %> </TD>
296 <TD><INPUT TYPE="text" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">(<% mt('blank disables') |h %>)</TD>
299 <INPUT TYPE="hidden" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">
300 <INPUT TYPE="hidden" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">
304 %foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
305 % $r =~ /^^r(adius|[cr])_(.+)$/ or next; #?
308 % if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) {
310 <INPUT TYPE="hidden" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>">
314 <TD ALIGN="right"><% $FS::raddb::attrib{$a} %></TD>
315 <TD><INPUT TYPE="text" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>"></TD>
322 <TD ALIGN="right"><% mt('RADIUS groups') |h %></TD>
323 % if ( $part_svc_usergroup->columnflag eq 'F' ) {
324 <TD BGCOLOR="#eeeeee"><% join('<BR>', @groupnames) %></TD>
326 % my $radius_group_selected = '';
327 % if ( $svc_acct->svcnum ) {
328 % $radius_group_selected = join(',',$svc_acct->radius_groups('groupnum'));
330 % elsif ( !$svc_acct->svcnum && $part_svc_usergroup->columnflag eq 'D' ) {
331 % $radius_group_selected = $part_svc_usergroup->columnvalue;
333 <TD><& /elements/select-radius_group.html,
334 curr_value => $radius_group_selected,
335 element_name => 'radius_usergroup',
342 % foreach my $field ($svc_acct->virtual_fields) {
343 % # If the flag is X, it won't even show up in $svc_acct->virtual_fields.
344 % if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) {
346 <% $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %>
353 % if ( $captcha_url ) {
354 <IMG SRC="<% $captcha_url %>"><BR>
355 <% mt('Enter the word shown above:') |h %> <INPUT TYPE="text" NAME="captcha_response"><BR>
359 <INPUT TYPE="submit" VALUE="Submit">
363 <& /elements/footer.html &>
368 unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
370 my $conf = new FS::Conf;
371 my @shells = $conf->config('shells');
373 my $curuser = $FS::CurrentUser::CurrentUser;
375 my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups);
376 if ( $cgi->param('error') ) {
378 $svc_acct = new FS::svc_acct ( {
379 map { $_, scalar($cgi->param($_)) } fields('svc_acct')
381 $svcnum = $svc_acct->svcnum;
382 $pkgnum = $cgi->param('pkgnum');
383 $svcpart = $cgi->param('svcpart');
384 $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
385 die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
386 @groups = $cgi->param('radius_usergroup');
388 } elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
390 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
392 $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
395 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
396 die "No part_svc entry!" unless $part_svc;
398 $svc_acct = new FS::svc_acct({svcpart => $svcpart});
402 $svc_acct->password_recover('Y'); #default. hmm.
406 my($query) = $cgi->keywords;
407 $query =~ /^(\d+)$/ or die "unparsable svcnum";
409 $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
410 or die "Unknown (svc_acct) svcnum!";
412 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
413 or die "Unknown (cust_svc) svcnum!";
415 $pkgnum=$cust_svc->pkgnum;
416 $svcpart=$cust_svc->svcpart;
418 $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
419 die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
421 @groups = $svc_acct->radius_groups;
425 my $communigate = scalar($part_svc->part_export('communigate_pro'));
426 # || scalar($part_svc->part_export('communigate_pro_singledomain'));
428 my( $cust_pkg, $cust_main ) = ( '', '' );
430 $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
431 $cust_main = $cust_pkg->cust_main;
434 unless ( $svcnum || $cgi->param('error') ) { #adding
438 unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
439 $svc_acct->setfield('finger',
440 $cust_main->getfield('first') . " " . $cust_main->getfield('last')
445 $svc_acct->set_default_and_fixed( {
446 #false laziness w/svc-acct::_fieldhandlers
448 my( $self, $groups ) = @_;
449 if ( ref($groups) eq 'ARRAY' ) {
452 } elsif ( length($groups) ) {
453 @groups = split(/\s*,\s*/, $groups);
464 my $part_svc_usergroup = $part_svc->part_svc_column('usergroup');
465 #fixed radius groups always override & display
466 my @groupnames; # only used for display of Fixed RADIUS groups
467 if ( $part_svc_usergroup->columnflag eq 'F' ) {
468 @groups = split(',',$part_svc_usergroup->columnvalue);
469 @groupnames = map { $_->long_description }
470 qsearch({ 'table' => 'radius_group',
471 'extra_sql' => "where groupnum in (".$part_svc_usergroup->columnvalue.")",
472 }) if length($part_svc_usergroup->columnvalue);
475 my $action = $svcnum ? 'Edit' : 'Add';
477 my $svc = $part_svc->getfield('svc');
479 my $otaker = getotaker;
481 my $username = $svc_acct->username;
484 if ( $cgi->param('error') ) {
485 $password = $cgi->param('clear_password');
486 } elsif ( $svcnum ) {
487 my $password_encryption = $svc_acct->_password_encryption;
488 if ( $password = $svc_acct->get_cleartext_password ) {
489 $password = '*HIDDEN*' unless $conf->exists('showpasswords');
490 } elsif( $svc_acct->_password and $password_encryption ne 'plain' ) {
491 $password = "(".uc($password_encryption)." encrypted)";
496 $conf->exists('usernamemax')
497 ? $conf->config('usernamemax')
498 : dbdef->table('svc_acct')->column('username')->length;
501 my $pmax = max($conf->config('passwordmax') || 13);
511 my ($export_google) = $part_svc->part_export('acct_google');
512 if ( $export_google ) {
513 my $error = $export_google->auth_error;
515 if ( $error->{'captcha_url'} ) {
516 $captcha_url = $error->{'captcha_url'};
519 $cgi->param('error', $error->{'message'});