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 <FORM NAME="OneTrueForm" ACTION="<% $p1 %>process/svc_acct.cgi" METHOD=POST>
13 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
14 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
15 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
18 % my $svclabel = emt("Service #[_1]",$svcnum);
19 % $svclabel =~ s/$svcnum/<B>$svcnum<\/B>/;
22 <% mt("Service # (NEW)") |h %>
26 <% ntable("#cccccc",2) %>
29 <TD ALIGN="right"><% mt('Service') |h %></TD>
30 <TD BGCOLOR="#eeeeee"><% $part_svc->svc %></TD>
33 <% include('/elements/tr-td-label.html',
34 'label' => mt('Username'),
35 'required' => $part_svc->part_svc_column('username')->required ) %>
36 % if ( $svcnum && $conf->exists('svc_acct-no_edit_username') ) {
37 <TD BGCOLOR="#eeeeee"><% $svc_acct->username() %></TD>
38 <INPUT TYPE="hidden" NAME="username" VALUE="<% $username %>">
41 <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
46 %if ( $part_svc->part_svc_column('_password')->columnflag ne 'F' ) {
47 % #XXX eventually should require "Edit Password" ACL
48 <% include('/elements/tr-td-label.html',
49 'label' => mt('Password'),
50 'required' => $part_svc->part_svc_column('_password')->required ) %>
52 <INPUT TYPE="text" ID="clear_password" NAME="clear_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $pmax %>>
53 <& /elements/random_pass.html, 'clear_password' &><BR>
54 <DIV ID="clear_password_result" STYLE="font-size: smaller"></DIV>
55 <& /elements/validate_password.html,
56 'fieldid' => 'clear_password',
63 <INPUT TYPE="hidden" NAME="clear_password" VALUE="<% $password %>">
65 <INPUT TYPE="hidden" NAME="_password_encoding" VALUE="<% $svc_acct->_password_encoding %>">
67 %my $sec_phrase = $svc_acct->sec_phrase;
68 %if ( $conf->exists('security_phrase')
69 % && $part_svc->part_svc_column('sec_phrase')->columnflag ne 'F' ) {
71 <% include('/elements/tr-td-label.html',
72 'label' => mt('Security phrase'),
73 'required' => $part_svc->part_svc_column('sec_phrase')->required ) %>
75 <INPUT TYPE="text" NAME="sec_phrase" VALUE="<% $sec_phrase %>" SIZE=32>
76 (<% mt('for forgotten passwords') |h %>)
81 <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="<% $sec_phrase %>">
85 %my $domsvc = $svc_acct->domsvc || 0;
86 %if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
89 <INPUT TYPE="hidden" NAME="domsvc" VALUE="<% $domsvc %>">
92 % my %svc_domain = ();
95 % my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $domsvc, } );
96 % if ( $svc_domain ) {
97 % $svc_domain{$svc_domain->svcnum} = $svc_domain->domain;
99 % warn "unknown svc_domain.svcnum for svc_acct.domsvc: $domsvc";
103 % %svc_domain = (%svc_domain,
104 % domain_select_hash FS::svc_acct('svcpart' => $svcpart,
105 % 'pkgnum' => $pkgnum,
109 <% include('/elements/tr-td-label.html',
110 'label' => mt('Domain'),
111 'required' => $part_svc->part_svc_column('domsvc')->required ) %>
113 <SELECT NAME="domsvc" SIZE=1>
114 % foreach my $svcnum (
115 % sort { $svc_domain{$a} cmp $svc_domain{$b} }
118 % my $svc_domain = $svc_domain{$svcnum};
121 <OPTION VALUE="<% $svcnum %>" <% $svcnum == $domsvc ? ' SELECTED' : '' %>><% $svc_domain{$svcnum} %>
130 % if ( $communigate ) {
133 <TD ALIGN="right"><% mt('Aliases') |h %></TD>
134 <TD><INPUT TYPE="text" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>"></TD>
138 <INPUT TYPE="hidden" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>">
142 <& /elements/tr-select-svc_pbx.html,
143 'curr_value' => $svc_acct->pbxsvc,
144 'part_svc' => $part_svc,
145 'cust_pkg' => $cust_pkg,
149 %my $popnum = $svc_acct->popnum || 0;
150 %if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
153 <INPUT TYPE="hidden" NAME="popnum" VALUE="<% $popnum %>">
156 <% include('/elements/tr-td-label.html',
157 'label' => mt('Access number'),
158 'required' => $part_svc->part_svc_column('popnum')->required ) %>
159 <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
164 %if ( $conf->exists('svc_acct-tower_sector')
165 % && $part_svc->part_svc_column('sectornum')->columnflag ne 'F' ) {
166 <& /elements/tr-select-tower_sector.html,
167 'curr_value' => $svc_acct->sectornum,
168 #'part_svc' => $part_svc,
169 #'cust_pkg' => $cust_pkg,
170 'required' => $part_svc->part_svc_column('sectornum')->required,
173 <INPUT TYPE="hidden" NAME="sectornum" VALUE="<% $svc_acct->sectornum %>">
176 <& /elements/tr-svc_export_machine.html,
178 'part_svc' => $part_svc,
183 % foreach my $xid (qw( uid gid )) {
185 % if ( $part_svc->part_svc_column($xid)->columnflag =~ /^[FA]$/
186 % || ! $conf->exists("svc_acct-edit_$xid")
189 % if ( length($svc_acct->$xid()) ) {
191 <% include('/elements/tr-td-label.html',
193 'required' => $part_svc->part_svc_column($xid)->required ) %>
195 <TD ALIGN="right"><% uc($xid) %></TD>
196 <TD BGCOLOR="#eeeeee"><% $svc_acct->$xid() %></TD>
202 <INPUT TYPE="hidden" NAME="<% $xid %>" VALUE="<% $svc_acct->$xid() %>">
205 <% include('/elements/tr-td-label.html',
207 'required' => $part_svc->part_svc_column($xid)->required ) %>
209 <INPUT TYPE="text" NAME="<% $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<% $svc_acct->$xid() %>">
216 %if ( $part_svc->part_svc_column('uid')->columnflag eq 'F'
217 % && ! $svc_acct->finger ) {
220 <INPUT TYPE="hidden" NAME="finger" VALUE="">
224 <% include('/elements/tr-td-label.html',
225 'label' => mt('Real Name'),
226 'required' => $part_svc->part_svc_column('finger')->required ) %>
228 <INPUT TYPE="text" NAME="finger" VALUE="<% $svc_acct->finger %>">
234 %if ( $part_svc->part_svc_column('dir')->columnflag eq 'F'
235 % || !$curuser->access_right('Edit home dir')
239 <INPUT TYPE="hidden" NAME="dir" VALUE="<% $svc_acct->dir %>">
243 <% include('/elements/tr-td-label.html',
244 'label' => mt('Home directory'),
245 'required' => $part_svc->part_svc_column('dir')->required ) %>
246 <TD><INPUT TYPE="text" NAME="dir" VALUE="<% $svc_acct->dir %>"></TD>
251 %my $shell = $svc_acct->shell;
252 %if ( $part_svc->part_svc_column('shell')->columnflag eq 'F'
253 % || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' )
257 <INPUT TYPE="hidden" NAME="shell" VALUE="<% $shell %>">
261 <% include('/elements/tr-td-label.html',
262 'label' => mt('Shell'),
263 'required' => $part_svc->part_svc_column('shell')->required ) %>
265 <SELECT NAME="shell" SIZE=1>
268 % foreach $etc_shell (@shells) {
271 <OPTION<% $etc_shell eq $shell ? ' SELECTED' : '' %>><% $etc_shell %>
280 <& svc_acct/communigate.html,
281 'svc_acct' => $svc_acct,
282 'part_svc' => $part_svc,
283 'communigate' => $communigate,
286 % if ( $conf->exists('svc_acct-ip_addr') ) {
287 % # router/block selection UI
288 % # (should we show this if slipip is fixed?)
289 <& /elements/tr-select-router_block_ip.html,
290 'object' => $svc_acct,
291 'ip_field' => 'slipip',
292 'required' => $part_svc->part_svc_column('routernum')->required,
293 'ip_addr_required' => $part_svc->part_svc_column('slipip')->required,
296 % # don't expose these to the user--they're only useful in the other case
297 <INPUT TYPE="hidden" NAME="routernum" VALUE="<% $svc_acct->routernum %>">
298 <INPUT TYPE="hidden" NAME="blocknum" VALUE="<% $svc_acct->blocknum %>">
299 % if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) {
300 <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>">
302 <% include('/elements/tr-td-label.html',
304 'required' => $part_svc->part_svc_column('slipip')->required ) %>
305 <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD>
310 % my %label = ( seconds => 'Time',
311 % upbytes => 'Upload bytes',
312 % downbytes => 'Download bytes',
313 % totalbytes => 'Total bytes',
315 % foreach my $uf (keys %label) {
316 % my $tf = $uf . "_threshold";
317 % if ( $curuser->access_right('Edit usage') ) {
319 <TD ALIGN="right"><% mt("[_1] remaining",$label{$uf}) |h %> </TD>
320 <TD><INPUT TYPE="text" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">(<% mt('blank disables') |h %>)</TD>
323 <TD ALIGN="right"><% mt("[_1] threshold",$label{$uf}) |h %> </TD>
324 <TD><INPUT TYPE="text" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">(<% mt('blank disables') |h %>)</TD>
327 <INPUT TYPE="hidden" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">
328 <INPUT TYPE="hidden" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">
332 %foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
333 % $r =~ /^^r(adius|[cr])_(.+)$/ or next; #?
336 % if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) {
338 <INPUT TYPE="hidden" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>">
342 <TD ALIGN="right"><% $FS::raddb::attrib{$a} %></TD>
343 <TD><INPUT TYPE="text" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>"></TD>
349 <% include('/elements/tr-td-label.html',
350 'label' => mt('RADIUS groups'),
351 'required' => $part_svc->part_svc_column('usergroup')->required ) %>
352 % if ( $part_svc_usergroup->columnflag eq 'F' ) {
353 <TD BGCOLOR="#eeeeee"><% join('<BR>', @groupnames) %></TD>
355 % my $radius_group_selected = '';
356 % if ( $svc_acct->svcnum ) {
357 % $radius_group_selected = join(',',$svc_acct->radius_groups('groupnum'));
359 % elsif ( !$svc_acct->svcnum && $part_svc_usergroup->columnflag eq 'D' ) {
360 % $radius_group_selected = $part_svc_usergroup->columnvalue;
362 <TD><& /elements/select-radius_group.html,
363 curr_value => $radius_group_selected,
364 element_name => 'radius_usergroup',
372 % if ( $part_svc->has_router ) {
373 <& /elements/hidden.html,
374 field => 'router_routernum',
375 curr_value => $svc_acct->router_routernum
377 <& /elements/tr-input-text.html,
378 label => 'Attached router name',
379 field => 'router_routername',
381 curr_value => $svc_acct->router_routername
383 <& /elements/tr-select-table.html,
384 label => 'Attached address block',
385 field => 'router_blocknum',
386 table => 'addr_block',
387 hashref => { 'routernum' => '0' },
388 extra_sql => ($svc_acct->router_routernum ?
389 ' OR routernum = '.$svc_acct->router_routernum : ''),
393 order_by => 'ORDER BY ip_gateway, ip_netmask',
394 empty_label => '(none)',
396 curr_value => $svc_acct->router_blocknum
400 % foreach my $field ($svc_acct->virtual_fields) {
401 % # If the flag is X, it won't even show up in $svc_acct->virtual_fields.
402 % if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) {
404 <% $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %>
411 % if ( $captcha_url ) {
412 <IMG SRC="<% $captcha_url %>"><BR>
413 <% mt('Enter the word shown above:') |h %> <INPUT TYPE="text" NAME="captcha_response"><BR>
417 <INPUT TYPE="submit" VALUE="Submit">
421 <& /elements/footer.html &>
426 unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
428 my $conf = new FS::Conf;
429 my @shells = $conf->config('shells');
431 my $curuser = $FS::CurrentUser::CurrentUser;
433 my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups);
434 if ( $cgi->param('error') ) {
436 $svc_acct = new FS::svc_acct ( {
437 map { $_, scalar($cgi->param($_)) } fields('svc_acct')
439 $svcnum = $svc_acct->svcnum;
440 $pkgnum = $cgi->param('pkgnum');
441 $svcpart = $cgi->param('svcpart');
442 $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
443 die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
444 @groups = $cgi->param('radius_usergroup');
446 } elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
448 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
450 $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
453 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
454 die "No part_svc entry!" unless $part_svc;
456 $svc_acct = new FS::svc_acct({svcpart => $svcpart});
460 $svc_acct->password_recover('Y'); #default. hmm.
464 my($query) = $cgi->keywords;
465 $query =~ /^(\d+)$/ or die "unparsable svcnum";
467 $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
468 or die "Unknown (svc_acct) svcnum!";
470 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
471 or die "Unknown (cust_svc) svcnum!";
473 $pkgnum=$cust_svc->pkgnum;
474 $svcpart=$cust_svc->svcpart;
476 $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
477 die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
479 @groups = $svc_acct->radius_groups;
483 my $communigate = scalar($part_svc->part_export('communigate_pro'));
484 # || scalar($part_svc->part_export('communigate_pro_singledomain'));
486 my( $cust_pkg, $cust_main ) = ( '', '' );
488 $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
489 $cust_main = $cust_pkg->cust_main;
492 unless ( $svcnum || $cgi->param('error') ) { #adding
496 unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
497 $svc_acct->setfield('finger',
498 $cust_main->getfield('first') . " " . $cust_main->getfield('last')
503 $svc_acct->set_default_and_fixed( {
504 #false laziness w/svc-acct::_fieldhandlers
506 my( $self, $groups ) = @_;
507 if ( ref($groups) eq 'ARRAY' ) {
510 } elsif ( length($groups) ) {
511 @groups = split(/\s*,\s*/, $groups);
522 my $part_svc_usergroup = $part_svc->part_svc_column('usergroup');
523 #fixed radius groups always override & display
524 my @groupnames; # only used for display of Fixed RADIUS groups
525 if ( $part_svc_usergroup->columnflag eq 'F' ) {
526 @groups = split(',',$part_svc_usergroup->columnvalue);
527 @groupnames = map { $_->long_description }
528 qsearch({ 'table' => 'radius_group',
529 'extra_sql' => "where groupnum in (".$part_svc_usergroup->columnvalue.")",
530 }) if length($part_svc_usergroup->columnvalue);
533 my $action = $svcnum ? 'Edit' : 'Add';
535 my $svc = $part_svc->getfield('svc');
537 my $otaker = getotaker;
539 my $username = $svc_acct->username;
542 if ( $cgi->param('error') ) {
543 $password = $cgi->param('clear_password');
544 } elsif ( $svcnum ) {
545 my $password_encryption = $svc_acct->_password_encryption;
546 if ( $password = $svc_acct->get_cleartext_password ) {
547 $password = '*HIDDEN*' unless $conf->exists('showpasswords');
548 } elsif( $svc_acct->_password and $password_encryption ne 'plain' ) {
549 $password = "(".uc($password_encryption)." encrypted)";
554 $conf->exists('usernamemax')
555 ? $conf->config('usernamemax')
556 : dbdef->table('svc_acct')->column('username')->length;
559 my $pmax = max($conf->config('passwordmax') || 13);
569 my ($export_google) = $part_svc->part_export('acct_google');
570 if ( $export_google ) {
571 my $error = $export_google->auth_error;
573 if ( $error->{'captcha_url'} ) {
574 $captcha_url = $error->{'captcha_url'};
577 $cgi->param('error', $error->{'message'});
582 if ( $part_svc->has_router ) { # duplicates the one in elements/svc_Common
584 my $router = qsearchs('router', {svcnum => $svc_acct->svcnum});
586 $svc_acct->set("router_$_", $router->get($_))
587 foreach ('routername', 'routernum');
588 my ($block) = $router->addr_block;
589 $svc_acct->set('router_blocknum', $block->blocknum) if ( $block );
592 foreach (qw(router_routername router_routernum router_blocknum)) {
593 if ( $cgi->param($_) =~ /^(\w+)$/ ) {
594 $svc_acct->set($_, $1);