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' &>
57 <INPUT TYPE="hidden" NAME="clear_password" VALUE="<% $password %>">
59 <INPUT TYPE="hidden" NAME="_password_encoding" VALUE="<% $svc_acct->_password_encoding %>">
61 %my $sec_phrase = $svc_acct->sec_phrase;
62 %if ( $conf->exists('security_phrase')
63 % && $part_svc->part_svc_column('sec_phrase')->columnflag ne 'F' ) {
65 <% include('/elements/tr-td-label.html',
66 'label' => mt('Security phrase'),
67 'required' => $part_svc->part_svc_column('sec_phrase')->required ) %>
69 <INPUT TYPE="text" NAME="sec_phrase" VALUE="<% $sec_phrase %>" SIZE=32>
70 (<% mt('for forgotten passwords') |h %>)
75 <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="<% $sec_phrase %>">
79 %my $domsvc = $svc_acct->domsvc || 0;
80 %if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
83 <INPUT TYPE="hidden" NAME="domsvc" VALUE="<% $domsvc %>">
86 % my %svc_domain = ();
89 % my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $domsvc, } );
90 % if ( $svc_domain ) {
91 % $svc_domain{$svc_domain->svcnum} = $svc_domain->domain;
93 % warn "unknown svc_domain.svcnum for svc_acct.domsvc: $domsvc";
97 % %svc_domain = (%svc_domain,
98 % domain_select_hash FS::svc_acct('svcpart' => $svcpart,
99 % 'pkgnum' => $pkgnum,
103 <% include('/elements/tr-td-label.html',
104 'label' => mt('Domain'),
105 'required' => $part_svc->part_svc_column('domsvc')->required ) %>
107 <SELECT NAME="domsvc" SIZE=1>
108 % foreach my $svcnum (
109 % sort { $svc_domain{$a} cmp $svc_domain{$b} }
112 % my $svc_domain = $svc_domain{$svcnum};
115 <OPTION VALUE="<% $svcnum %>" <% $svcnum == $domsvc ? ' SELECTED' : '' %>><% $svc_domain{$svcnum} %>
124 % if ( $communigate ) {
127 <TD ALIGN="right"><% mt('Aliases') |h %></TD>
128 <TD><INPUT TYPE="text" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>"></TD>
132 <INPUT TYPE="hidden" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>">
136 <& /elements/tr-select-svc_pbx.html,
137 'curr_value' => $svc_acct->pbxsvc,
138 'part_svc' => $part_svc,
139 'cust_pkg' => $cust_pkg,
143 %my $popnum = $svc_acct->popnum || 0;
144 %if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
147 <INPUT TYPE="hidden" NAME="popnum" VALUE="<% $popnum %>">
150 <% include('/elements/tr-td-label.html',
151 'label' => mt('Access number'),
152 'required' => $part_svc->part_svc_column('popnum')->required ) %>
153 <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
158 %if ( $conf->exists('svc_acct-tower_sector')
159 % && $part_svc->part_svc_column('sectornum')->columnflag ne 'F' ) {
160 <& /elements/tr-select-tower_sector.html,
161 'curr_value' => $svc_acct->sectornum,
162 #'part_svc' => $part_svc,
163 #'cust_pkg' => $cust_pkg,
164 'required' => $part_svc->part_svc_column('sectornum')->required,
167 <INPUT TYPE="hidden" NAME="sectornum" VALUE="<% $svc_acct->sectornum %>">
170 <& /elements/tr-svc_export_machine.html,
172 'part_svc' => $part_svc,
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()) ) {
185 <% include('/elements/tr-td-label.html',
187 'required' => $part_svc->part_svc_column($xid)->required ) %>
189 <TD ALIGN="right"><% uc($xid) %></TD>
190 <TD BGCOLOR="#eeeeee"><% $svc_acct->$xid() %></TD>
196 <INPUT TYPE="hidden" NAME="<% $xid %>" VALUE="<% $svc_acct->$xid() %>">
199 <% include('/elements/tr-td-label.html',
201 'required' => $part_svc->part_svc_column($xid)->required ) %>
203 <INPUT TYPE="text" NAME="<% $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<% $svc_acct->$xid() %>">
210 %if ( $part_svc->part_svc_column('uid')->columnflag eq 'F'
211 % && ! $svc_acct->finger ) {
214 <INPUT TYPE="hidden" NAME="finger" VALUE="">
218 <% include('/elements/tr-td-label.html',
219 'label' => mt('Real Name'),
220 'required' => $part_svc->part_svc_column('finger')->required ) %>
222 <INPUT TYPE="text" NAME="finger" VALUE="<% $svc_acct->finger %>">
228 %if ( $part_svc->part_svc_column('dir')->columnflag eq 'F'
229 % || !$curuser->access_right('Edit home dir')
233 <INPUT TYPE="hidden" NAME="dir" VALUE="<% $svc_acct->dir %>">
237 <% include('/elements/tr-td-label.html',
238 'label' => mt('Home directory'),
239 'required' => $part_svc->part_svc_column('dir')->required ) %>
240 <TD><INPUT TYPE="text" NAME="dir" VALUE="<% $svc_acct->dir %>"></TD>
245 %my $shell = $svc_acct->shell;
246 %if ( $part_svc->part_svc_column('shell')->columnflag eq 'F'
247 % || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' )
251 <INPUT TYPE="hidden" NAME="shell" VALUE="<% $shell %>">
255 <% include('/elements/tr-td-label.html',
256 'label' => mt('Shell'),
257 'required' => $part_svc->part_svc_column('shell')->required ) %>
259 <SELECT NAME="shell" SIZE=1>
262 % foreach $etc_shell (@shells) {
265 <OPTION<% $etc_shell eq $shell ? ' SELECTED' : '' %>><% $etc_shell %>
274 <& svc_acct/communigate.html,
275 'svc_acct' => $svc_acct,
276 'part_svc' => $part_svc,
277 'communigate' => $communigate,
280 % if ( $conf->exists('svc_acct-ip_addr') ) {
281 % # router/block selection UI
282 % # (should we show this if slipip is fixed?)
283 <& /elements/tr-select-router_block_ip.html,
284 'object' => $svc_acct,
285 'ip_field' => 'slipip',
286 'required' => $part_svc->part_svc_column('routernum')->required,
287 'ip_addr_required' => $part_svc->part_svc_column('slipip')->required,
290 % # don't expose these to the user--they're only useful in the other case
291 <INPUT TYPE="hidden" NAME="routernum" VALUE="<% $svc_acct->routernum %>">
292 <INPUT TYPE="hidden" NAME="blocknum" VALUE="<% $svc_acct->blocknum %>">
293 % if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) {
294 <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>">
296 <% include('/elements/tr-td-label.html',
298 'required' => $part_svc->part_svc_column('slipip')->required ) %>
299 <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD>
304 % my %label = ( seconds => 'Time',
305 % upbytes => 'Upload bytes',
306 % downbytes => 'Download bytes',
307 % totalbytes => 'Total bytes',
309 % foreach my $uf (keys %label) {
310 % my $tf = $uf . "_threshold";
311 % if ( $curuser->access_right('Edit usage') ) {
313 <TD ALIGN="right"><% mt("[_1] remaining",$label{$uf}) |h %> </TD>
314 <TD><INPUT TYPE="text" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">(<% mt('blank disables') |h %>)</TD>
317 <TD ALIGN="right"><% mt("[_1] threshold",$label{$uf}) |h %> </TD>
318 <TD><INPUT TYPE="text" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">(<% mt('blank disables') |h %>)</TD>
321 <INPUT TYPE="hidden" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">
322 <INPUT TYPE="hidden" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">
326 %foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
327 % $r =~ /^^r(adius|[cr])_(.+)$/ or next; #?
330 % if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) {
332 <INPUT TYPE="hidden" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>">
336 <TD ALIGN="right"><% $FS::raddb::attrib{$a} %></TD>
337 <TD><INPUT TYPE="text" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>"></TD>
343 <% include('/elements/tr-td-label.html',
344 'label' => mt('RADIUS groups'),
345 'required' => $part_svc->part_svc_column('usergroup')->required ) %>
346 % if ( $part_svc_usergroup->columnflag eq 'F' ) {
347 <TD BGCOLOR="#eeeeee"><% join('<BR>', @groupnames) %></TD>
349 % my $radius_group_selected = '';
350 % if ( $svc_acct->svcnum ) {
351 % $radius_group_selected = join(',',$svc_acct->radius_groups('groupnum'));
353 % elsif ( !$svc_acct->svcnum && $part_svc_usergroup->columnflag eq 'D' ) {
354 % $radius_group_selected = $part_svc_usergroup->columnvalue;
356 <TD><& /elements/select-radius_group.html,
357 curr_value => $radius_group_selected,
358 element_name => 'radius_usergroup',
366 % if ( $part_svc->has_router ) {
367 <& /elements/hidden.html,
368 field => 'router_routernum',
369 curr_value => $svc_acct->router_routernum
371 <& /elements/tr-input-text.html,
372 label => 'Attached router name',
373 field => 'router_routername',
375 curr_value => $svc_acct->router_routername
377 <& /elements/tr-select-table.html,
378 label => 'Attached address block',
379 field => 'router_blocknum',
380 table => 'addr_block',
381 hashref => { 'routernum' => '0' },
382 extra_sql => ($svc_acct->router_routernum ?
383 ' OR routernum = '.$svc_acct->router_routernum : ''),
387 order_by => 'ORDER BY ip_gateway, ip_netmask',
388 empty_label => '(none)',
390 curr_value => $svc_acct->router_blocknum
394 % foreach my $field ($svc_acct->virtual_fields) {
395 % # If the flag is X, it won't even show up in $svc_acct->virtual_fields.
396 % if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) {
398 <% $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %>
405 % if ( $captcha_url ) {
406 <IMG SRC="<% $captcha_url %>"><BR>
407 <% mt('Enter the word shown above:') |h %> <INPUT TYPE="text" NAME="captcha_response"><BR>
411 <INPUT TYPE="submit" VALUE="Submit">
415 <& /elements/footer.html &>
420 unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
422 my $conf = new FS::Conf;
423 my @shells = $conf->config('shells');
425 my $curuser = $FS::CurrentUser::CurrentUser;
427 my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups);
428 if ( $cgi->param('error') ) {
430 $svc_acct = new FS::svc_acct ( {
431 map { $_, scalar($cgi->param($_)) } fields('svc_acct')
433 $svcnum = $svc_acct->svcnum;
434 $pkgnum = $cgi->param('pkgnum');
435 $svcpart = $cgi->param('svcpart');
436 $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
437 die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
438 @groups = $cgi->param('radius_usergroup');
440 } elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
442 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
444 $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
447 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
448 die "No part_svc entry!" unless $part_svc;
450 $svc_acct = new FS::svc_acct({svcpart => $svcpart});
454 $svc_acct->password_recover('Y'); #default. hmm.
458 my($query) = $cgi->keywords;
459 $query =~ /^(\d+)$/ or die "unparsable svcnum";
461 $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
462 or die "Unknown (svc_acct) svcnum!";
464 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
465 or die "Unknown (cust_svc) svcnum!";
467 $pkgnum=$cust_svc->pkgnum;
468 $svcpart=$cust_svc->svcpart;
470 $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
471 die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
473 @groups = $svc_acct->radius_groups;
477 my $communigate = scalar($part_svc->part_export('communigate_pro'));
478 # || scalar($part_svc->part_export('communigate_pro_singledomain'));
480 my( $cust_pkg, $cust_main ) = ( '', '' );
482 $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
483 $cust_main = $cust_pkg->cust_main;
486 unless ( $svcnum || $cgi->param('error') ) { #adding
490 unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
491 $svc_acct->setfield('finger',
492 $cust_main->getfield('first') . " " . $cust_main->getfield('last')
497 $svc_acct->set_default_and_fixed( {
498 #false laziness w/svc-acct::_fieldhandlers
500 my( $self, $groups ) = @_;
501 if ( ref($groups) eq 'ARRAY' ) {
504 } elsif ( length($groups) ) {
505 @groups = split(/\s*,\s*/, $groups);
516 my $part_svc_usergroup = $part_svc->part_svc_column('usergroup');
517 #fixed radius groups always override & display
518 my @groupnames; # only used for display of Fixed RADIUS groups
519 if ( $part_svc_usergroup->columnflag eq 'F' ) {
520 @groups = split(',',$part_svc_usergroup->columnvalue);
521 @groupnames = map { $_->long_description }
522 qsearch({ 'table' => 'radius_group',
523 'extra_sql' => "where groupnum in (".$part_svc_usergroup->columnvalue.")",
524 }) if length($part_svc_usergroup->columnvalue);
527 my $action = $svcnum ? 'Edit' : 'Add';
529 my $svc = $part_svc->getfield('svc');
531 my $username = $svc_acct->username;
534 if ( $cgi->param('error') ) {
535 $password = $cgi->param('clear_password');
536 } elsif ( $svcnum ) {
537 my $password_encryption = $svc_acct->_password_encryption;
538 if ( $password = $svc_acct->get_cleartext_password ) {
539 $password = '*HIDDEN*' unless $conf->exists('showpasswords');
540 } elsif( $svc_acct->_password and $password_encryption ne 'plain' ) {
541 $password = "(".uc($password_encryption)." encrypted)";
546 $conf->exists('usernamemax')
547 ? $conf->config('usernamemax')
548 : dbdef->table('svc_acct')->column('username')->length;
551 my $pmax = max($conf->config('passwordmax') || 13);
561 my ($export_google) = $part_svc->part_export('acct_google');
562 if ( $export_google ) {
563 my $error = $export_google->auth_error;
565 if ( $error->{'captcha_url'} ) {
566 $captcha_url = $error->{'captcha_url'};
569 $cgi->param('error', $error->{'message'});
574 if ( $part_svc->has_router ) { # duplicates the one in elements/svc_Common
576 my $router = qsearchs('router', {svcnum => $svc_acct->svcnum});
578 $svc_acct->set("router_$_", $router->get($_))
579 foreach ('routername', 'routernum');
580 my ($block) = $router->addr_block;
581 $svc_acct->set('router_blocknum', $block->blocknum) if ( $block );
584 foreach (qw(router_routername router_routernum router_blocknum)) {
585 if ( $cgi->param($_) =~ /^(\w+)$/ ) {
586 $svc_acct->set($_, $1);