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' => $part_svc->part_svc_column('username')->columnlabel || 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' => $part_svc->part_svc_column('_password')->columnlabel || 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',
62 <INPUT TYPE="hidden" NAME="clear_password" VALUE="<% $password %>">
64 <INPUT TYPE="hidden" NAME="_password_encoding" VALUE="<% $svc_acct->_password_encoding %>">
66 %my $sec_phrase = $svc_acct->sec_phrase;
67 %if ( $conf->exists('security_phrase')
68 % && $part_svc->part_svc_column('sec_phrase')->columnflag ne 'F' ) {
70 <% include('/elements/tr-td-label.html',
71 'label' => $part_svc->part_svc_column('sec_phrase')->columnlabel || mt('Security phrase'),
72 'required' => $part_svc->part_svc_column('sec_phrase')->required ) %>
74 <INPUT TYPE="text" NAME="sec_phrase" VALUE="<% $sec_phrase %>" SIZE=32>
75 (<% mt('for forgotten passwords') |h %>)
80 <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="<% $sec_phrase %>">
84 %my $domsvc = $svc_acct->domsvc || 0;
85 %if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
88 <INPUT TYPE="hidden" NAME="domsvc" VALUE="<% $domsvc %>">
91 % my %svc_domain = ();
94 % my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $domsvc, } );
95 % if ( $svc_domain ) {
96 % $svc_domain{$svc_domain->svcnum} = $svc_domain->domain;
98 % warn "unknown svc_domain.svcnum for svc_acct.domsvc: $domsvc";
102 % %svc_domain = (%svc_domain,
103 % domain_select_hash FS::svc_acct('svcpart' => $svcpart,
104 % 'pkgnum' => $pkgnum,
108 <% include('/elements/tr-td-label.html',
109 'label' => $part_svc->part_svc_column('domsvc')->columnlabel || mt('Domain'),
110 'required' => $part_svc->part_svc_column('domsvc')->required ) %>
112 <SELECT NAME="domsvc" SIZE=1>
113 % foreach my $svcnum (
114 % sort { $svc_domain{$a} cmp $svc_domain{$b} }
117 % my $svc_domain = $svc_domain{$svcnum};
120 <OPTION VALUE="<% $svcnum %>" <% $svcnum == $domsvc ? ' SELECTED' : '' %>><% $svc_domain{$svcnum} %>
129 % if ( $communigate ) {
132 <TD ALIGN="right"><% mt('Aliases') |h %></TD>
133 <TD><INPUT TYPE="text" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>"></TD>
137 <INPUT TYPE="hidden" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>">
141 <& /elements/tr-select-svc_pbx.html,
142 'curr_value' => $svc_acct->pbxsvc,
143 'part_svc' => $part_svc,
144 'cust_pkg' => $cust_pkg,
145 'label' => $part_svc->part_svc_column('pbxsvc')->columnlabel || 'PBX',
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' => $part_svc->part_svc_column('popnum')->columnlabel || 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,
171 'label' => $part_svc->part_svc_column('sectornum')->columnlabel || mt('Tower sector'),
174 <INPUT TYPE="hidden" NAME="sectornum" VALUE="<% $svc_acct->sectornum %>">
177 <& /elements/tr-svc_export_machine.html,
179 'part_svc' => $part_svc,
184 % foreach my $xid (qw( uid gid )) {
186 % if ( $part_svc->part_svc_column($xid)->columnflag =~ /^[FA]$/
187 % || ! $conf->exists("svc_acct-edit_$xid")
190 % if ( length($svc_acct->$xid()) ) {
192 <% include('/elements/tr-td-label.html',
193 'label' => $part_svc->part_svc_column($xid)->columnlabel || uc($xid),
194 'required' => $part_svc->part_svc_column($xid)->required ) %>
196 %# <TD ALIGN="right"><% uc($xid) %></TD>
197 <TD BGCOLOR="#eeeeee"><% $svc_acct->$xid() %></TD>
203 <INPUT TYPE="hidden" NAME="<% $xid %>" VALUE="<% $svc_acct->$xid() %>">
206 <% include('/elements/tr-td-label.html',
207 'label' => $part_svc->part_svc_column($xid)->columnlabel || uc($xid),
208 'required' => $part_svc->part_svc_column($xid)->required ) %>
210 <INPUT TYPE="text" NAME="<% $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<% $svc_acct->$xid() %>">
217 %if ( $part_svc->part_svc_column('uid')->columnflag eq 'F'
218 % && ! $svc_acct->finger ) {
221 <INPUT TYPE="hidden" NAME="finger" VALUE="">
225 <% include('/elements/tr-td-label.html',
226 'label' => $part_svc->part_svc_column('finger')->columnlabel || mt('Real Name'),
227 'required' => $part_svc->part_svc_column('finger')->required ) %>
229 <INPUT TYPE="text" NAME="finger" VALUE="<% $svc_acct->finger %>">
235 %if ( $part_svc->part_svc_column('dir')->columnflag eq 'F'
236 % || !$curuser->access_right('Edit home dir')
240 <INPUT TYPE="hidden" NAME="dir" VALUE="<% $svc_acct->dir %>">
244 <% include('/elements/tr-td-label.html',
245 'label' => $part_svc->part_svc_column('dir')->columnlabel || mt('Home directory'),
246 'required' => $part_svc->part_svc_column('dir')->required ) %>
247 <TD><INPUT TYPE="text" NAME="dir" VALUE="<% $svc_acct->dir %>"></TD>
252 %my $shell = $svc_acct->shell;
253 %if ( $part_svc->part_svc_column('shell')->columnflag eq 'F'
254 % || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' )
258 <INPUT TYPE="hidden" NAME="shell" VALUE="<% $shell %>">
262 <% include('/elements/tr-td-label.html',
263 'label' => $part_svc->part_svc_column('shell')->columnlabel || mt('Shell'),
264 'required' => $part_svc->part_svc_column('shell')->required ) %>
266 <SELECT NAME="shell" SIZE=1>
269 % foreach $etc_shell (@shells) {
272 <OPTION<% $etc_shell eq $shell ? ' SELECTED' : '' %>><% $etc_shell %>
281 <& svc_acct/communigate.html,
282 'svc_acct' => $svc_acct,
283 'part_svc' => $part_svc,
284 'communigate' => $communigate,
287 % if ( $conf->exists('svc_acct-ip_addr') ) {
288 % # router/block selection UI
289 % # (should we show this if slipip is fixed?)
290 <& /elements/tr-select-router_block_ip.html,
291 'object' => $svc_acct,
292 'ip_field' => 'slipip',
293 'required' => $part_svc->part_svc_column('routernum')->required,
294 'label' => $part_svc->part_svc_column('routernum')->columnlabel,
295 'ip_addr_required' => $part_svc->part_svc_column('slipip')->required,
296 'ip_addr_label' => $part_svc->part_svc_column('slipip')->columnlabel,
299 % # don't expose these to the user--they're only useful in the other case
300 <INPUT TYPE="hidden" NAME="routernum" VALUE="<% $svc_acct->routernum %>">
301 <INPUT TYPE="hidden" NAME="blocknum" VALUE="<% $svc_acct->blocknum %>">
302 % if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) {
303 <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>">
305 <% include('/elements/tr-td-label.html',
306 'label' => $part_svc->part_svc_column('slipip')->columnlabel || mt('IP'),
307 'required' => $part_svc->part_svc_column('slipip')->required ) %>
308 <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD>
313 % my %label = ( seconds => 'Time',
314 % upbytes => 'Upload bytes',
315 % downbytes => 'Download bytes',
316 % totalbytes => 'Total bytes',
318 % foreach my $uf (keys %label) {
319 % my $tf = $uf . "_threshold";
320 % if ( $curuser->access_right('Edit usage') ) {
322 <TD ALIGN="right"><% mt("[_1] remaining",$label{$uf}) |h %> </TD>
323 <TD><INPUT TYPE="text" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">(<% mt('blank disables') |h %>)</TD>
326 <TD ALIGN="right"><% mt("[_1] threshold",$label{$uf}) |h %> </TD>
327 <TD><INPUT TYPE="text" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">(<% mt('blank disables') |h %>)</TD>
330 <INPUT TYPE="hidden" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">
331 <INPUT TYPE="hidden" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">
335 %foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
336 % $r =~ /^^r(adius|[cr])_(.+)$/ or next; #?
339 % if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) {
341 <INPUT TYPE="hidden" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>">
345 <TD ALIGN="right"><% $FS::raddb::attrib{$a} %></TD>
346 <TD><INPUT TYPE="text" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>"></TD>
352 <% include('/elements/tr-td-label.html',
353 'label' => $part_svc->part_svc_column('usergroup')->columnlabel || mt('RADIUS groups'),
354 'required' => $part_svc->part_svc_column('usergroup')->required ) %>
355 % if ( $part_svc_usergroup->columnflag eq 'F' ) {
356 <TD BGCOLOR="#eeeeee"><% join('<BR>', @groupnames) %></TD>
358 % my $radius_group_selected = '';
359 % if ( $svc_acct->svcnum ) {
360 % $radius_group_selected = join(',',$svc_acct->radius_groups('groupnum'));
362 % elsif ( !$svc_acct->svcnum && $part_svc_usergroup->columnflag eq 'D' ) {
363 % $radius_group_selected = $part_svc_usergroup->columnvalue;
365 <TD><& /elements/select-radius_group.html,
366 curr_value => $radius_group_selected,
367 element_name => 'radius_usergroup',
375 % if ( $part_svc->has_router ) {
376 <& /elements/hidden.html,
377 field => 'router_routernum',
378 curr_value => $svc_acct->router_routernum
380 <& /elements/tr-input-text.html,
381 label => 'Attached router name',
382 field => 'router_routername',
384 curr_value => $svc_acct->router_routername
386 <& /elements/tr-select-table.html,
387 label => 'Attached address block',
388 field => 'router_blocknum',
389 table => 'addr_block',
390 hashref => { 'routernum' => '0' },
391 extra_sql => ($svc_acct->router_routernum ?
392 ' OR routernum = '.$svc_acct->router_routernum : ''),
396 order_by => 'ORDER BY ip_gateway, ip_netmask',
397 empty_label => '(none)',
399 curr_value => $svc_acct->router_blocknum
403 % foreach my $field ($svc_acct->virtual_fields) {
404 % # If the flag is X, it won't even show up in $svc_acct->virtual_fields.
405 % if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) {
407 <% $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %>
414 % if ( $captcha_url ) {
415 <IMG SRC="<% $captcha_url %>"><BR>
416 <% mt('Enter the word shown above:') |h %> <INPUT TYPE="text" NAME="captcha_response"><BR>
420 <INPUT TYPE="submit" VALUE="Submit">
424 <& /elements/footer.html &>
429 unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
431 my $conf = new FS::Conf;
432 my @shells = $conf->config('shells');
434 my $curuser = $FS::CurrentUser::CurrentUser;
436 my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups);
437 if ( $cgi->param('error') ) {
439 $svc_acct = new FS::svc_acct ( {
440 map { $_, scalar($cgi->param($_)) } fields('svc_acct')
442 $svcnum = $svc_acct->svcnum;
443 $pkgnum = $cgi->param('pkgnum');
444 $svcpart = $cgi->param('svcpart');
445 $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
446 die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
447 @groups = $cgi->param('radius_usergroup');
449 } elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
451 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
453 $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
456 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
457 die "No part_svc entry!" unless $part_svc;
459 $svc_acct = new FS::svc_acct({svcpart => $svcpart});
463 $svc_acct->password_recover('Y'); #default. hmm.
467 my($query) = $cgi->keywords;
468 $query =~ /^(\d+)$/ or die "unparsable svcnum";
470 $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
471 or die "Unknown (svc_acct) svcnum!";
473 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
474 or die "Unknown (cust_svc) svcnum!";
476 $pkgnum=$cust_svc->pkgnum;
477 $svcpart=$cust_svc->svcpart;
479 $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
480 die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
482 @groups = $svc_acct->radius_groups;
486 my $communigate = scalar($part_svc->part_export('communigate_pro'));
487 # || scalar($part_svc->part_export('communigate_pro_singledomain'));
489 my( $cust_pkg, $cust_main ) = ( '', '' );
491 $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
492 $cust_main = $cust_pkg->cust_main;
495 unless ( $svcnum || $cgi->param('error') ) { #adding
499 unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
500 $svc_acct->setfield('finger',
501 $cust_main->getfield('first') . " " . $cust_main->getfield('last')
506 $svc_acct->set_default_and_fixed( {
507 #false laziness w/svc-acct::_fieldhandlers
509 my( $self, $groups ) = @_;
510 if ( ref($groups) eq 'ARRAY' ) {
513 } elsif ( length($groups) ) {
514 @groups = split(/\s*,\s*/, $groups);
525 my $part_svc_usergroup = $part_svc->part_svc_column('usergroup');
526 #fixed radius groups always override & display
527 my @groupnames; # only used for display of Fixed RADIUS groups
528 if ( $part_svc_usergroup->columnflag eq 'F' ) {
529 @groups = split(',',$part_svc_usergroup->columnvalue);
530 @groupnames = map { $_->long_description }
531 qsearch({ 'table' => 'radius_group',
532 'extra_sql' => "where groupnum in (".$part_svc_usergroup->columnvalue.")",
533 }) if length($part_svc_usergroup->columnvalue);
536 my $action = $svcnum ? 'Edit' : 'Add';
538 my $svc = $part_svc->getfield('svc');
540 my $username = $svc_acct->username;
543 if ( $cgi->param('error') ) {
544 $password = $cgi->param('clear_password');
545 } elsif ( $svcnum ) {
546 my $password_encryption = $svc_acct->_password_encryption;
547 if ( $password = $svc_acct->get_cleartext_password ) {
548 $password = '*HIDDEN*' unless $conf->exists('showpasswords');
549 } elsif( $svc_acct->_password and $password_encryption ne 'plain' ) {
550 $password = "(".uc($password_encryption)." encrypted)";
555 $conf->exists('usernamemax')
556 ? $conf->config('usernamemax')
557 : dbdef->table('svc_acct')->column('username')->length;
560 my $pmax = max($conf->config('passwordmax') || 12);
570 my ($export_google) = $part_svc->part_export('acct_google');
571 if ( $export_google ) {
572 my $error = $export_google->auth_error;
574 if ( $error->{'captcha_url'} ) {
575 $captcha_url = $error->{'captcha_url'};
578 $cgi->param('error', $error->{'message'});
583 if ( $part_svc->has_router ) { # duplicates the one in elements/svc_Common
585 my $router = qsearchs('router', {svcnum => $svc_acct->svcnum});
587 $svc_acct->set("router_$_", $router->get($_))
588 foreach ('routername', 'routernum');
589 my ($block) = $router->addr_block;
590 $svc_acct->set('router_blocknum', $block->blocknum) if ( $block );
593 foreach (qw(router_routername router_routernum router_blocknum)) {
594 if ( $cgi->param($_) =~ /^(\w+)$/ ) {
595 $svc_acct->set($_, $1);