1 <% include('/elements/header.html', "$action $svc account") %>
3 <% include('/elements/error.html') %>
7 <% include( '/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 %>">
30 Service # <% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR>
32 <% ntable("#cccccc",2) %>
35 <TD ALIGN="right">Service</TD>
36 <TD BGCOLOR="#eeeeee"><% $part_svc->svc %></TD>
40 <TD ALIGN="right">Username</TD>
42 <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
46 %if ( $part_svc->part_svc_column('_password')->columnflag ne 'F' ) {
48 <TD ALIGN="right">Password</TD>
50 <INPUT TYPE="text" NAME="clear_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $pmax %>>
51 <INPUT TYPE="button" VALUE="Generate" onclick="randomPass();">
55 <INPUT TYPE="hidden" NAME="clear_password" VALUE="<% $password %>">
57 <INPUT TYPE="hidden" NAME="_password_encoding" VALUE="<% $svc_acct->_password_encoding %>">
59 %my $sec_phrase = $svc_acct->sec_phrase;
60 %if ( $conf->exists('security_phrase')
61 % && $part_svc->part_svc_column('sec_phrase')->columnflag ne 'F' ) {
66 <TD ALIGN="right">Security phrase</TD>
68 <INPUT TYPE="text" NAME="sec_phrase" VALUE="<% $sec_phrase %>" SIZE=32>
69 (for forgotten passwords)
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' ) {
84 <INPUT TYPE="hidden" NAME="domsvc" VALUE="<% $domsvc %>">
87 % my %svc_domain = ();
90 % my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $domsvc, } );
91 % if ( $svc_domain ) {
92 % $svc_domain{$svc_domain->svcnum} = $svc_domain;
94 % warn "unknown svc_domain.svcnum for svc_acct.domsvc: $domsvc";
98 % %svc_domain = (%svc_domain,
99 % domain_select_hash FS::svc_acct('svcpart' => $svcpart,
100 % 'pkgnum' => $pkgnum,
107 <TD ALIGN="right">Domain</TD>
109 <SELECT NAME="domsvc" SIZE=1>
110 % foreach my $svcnum (
111 % sort { $svc_domain{$a} cmp $svc_domain{$b} }
114 % my $svc_domain = $svc_domain{$svcnum};
118 <OPTION VALUE="<% $svcnum %>" <% $svcnum == $domsvc ? ' SELECTED' : '' %>><% $svc_domain{$svcnum} %>
127 % if ( $communigate ) {
130 <TD ALIGN="right">Aliases</TD>
131 <TD><INPUT TYPE="text" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>"></TD>
135 <INPUT TYPE="hidden" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>">
139 <% include('/elements/tr-select-svc_pbx.html',
140 'curr_value' => $svc_acct->pbxsvc,
141 'part_svc' => $part_svc,
142 'cust_pkg' => $cust_pkg,
147 %my $popnum = $svc_acct->popnum || 0;
148 %if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
152 <INPUT TYPE="hidden" NAME="popnum" VALUE="<% $popnum %>">
157 <TD ALIGN="right">Access number</TD>
158 <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
162 % foreach my $xid (qw( uid gid )) {
164 % if ( $part_svc->part_svc_column($xid)->columnflag =~ /^[FA]$/
165 % || ! $conf->exists("svc_acct-edit_$xid")
168 % if ( length($svc_acct->$xid()) ) {
172 <TD ALIGN="right"><% uc($xid) %></TD>
173 <TD BGCOLOR="#eeeeee"><% $svc_acct->$xid() %></TD>
180 <INPUT TYPE="hidden" NAME="<% $xid %>" VALUE="<% $svc_acct->$xid() %>">
185 <TD ALIGN="right"><% uc($xid) %></TD>
187 <INPUT TYPE="text" NAME="<% $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<% $svc_acct->$xid() %>">
194 %if ( $part_svc->part_svc_column('uid')->columnflag eq 'F'
195 % && ! $svc_acct->finger ) {
199 <INPUT TYPE="hidden" NAME="finger" VALUE="">
204 <TD ALIGN="right">Real Name</TD>
206 <INPUT TYPE="text" NAME="finger" VALUE="<% $svc_acct->finger %>">
212 %if ( $part_svc->part_svc_column('dir')->columnflag eq 'F'
213 % || !$curuser->access_right('Edit home dir')
217 <INPUT TYPE="hidden" NAME="dir" VALUE="<% $svc_acct->dir %>">
222 <TD ALIGN="right">Home directory</TD>
223 <TD><INPUT TYPE="text" NAME="dir" VALUE="<% $svc_acct->dir %>"></TD>
228 %my $shell = $svc_acct->shell;
229 %if ( $part_svc->part_svc_column('shell')->columnflag eq 'F'
230 % || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' )
235 <INPUT TYPE="hidden" NAME="shell" VALUE="<% $shell %>">
240 <TD ALIGN="right">Shell</TD>
242 <SELECT NAME="shell" SIZE=1>
245 % foreach $etc_shell (@shells) {
249 <OPTION<% $etc_shell eq $shell ? ' SELECTED' : '' %>><% $etc_shell %>
258 <% include('svc_acct/communigate.html',
259 'svc_acct' => $svc_acct,
260 'part_svc' => $part_svc,
261 'communigate' => $communigate,
265 % if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) {
266 <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>">
269 <TD ALIGN="right">IP</TD>
270 <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD>
274 % my %label = ( seconds => 'Time',
275 % upbytes => 'Upload bytes',
276 % downbytes => 'Download bytes',
277 % totalbytes => 'Total bytes',
279 % foreach my $uf (keys %label) {
280 % my $tf = $uf . "_threshold";
281 % if ( $curuser->access_right('Edit usage') ) {
283 <TD ALIGN="right"><% $label{$uf} %> remaining</TD>
284 <TD><INPUT TYPE="text" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">(blank disables)</TD>
287 <TD ALIGN="right"><% $label{$uf} %> threshold</TD>
288 <TD><INPUT TYPE="text" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">(blank disables)</TD>
291 <INPUT TYPE="hidden" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">
292 <INPUT TYPE="hidden" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">
296 %foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
297 % $r =~ /^^r(adius|[cr])_(.+)$/ or next; #?
300 % if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) {
303 <INPUT TYPE="hidden" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>">
308 <TD ALIGN="right"><% $FS::raddb::attrib{$a} %></TD>
309 <TD><INPUT TYPE="text" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>"></TD>
317 <TD ALIGN="right">RADIUS groups</TD>
318 % if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) {
321 <TD BGCOLOR="#eeeeee"><% join('<BR>', @groups) %></TD>
325 <TD><% FS::svc_acct::radius_usergroup_selector( \@groups ) %></TD>
330 % foreach my $field ($svc_acct->virtual_fields) {
331 % # If the flag is X, it won't even show up in $svc_acct->virtual_fields.
332 % if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) {
335 <% $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %>
343 <INPUT TYPE="submit" VALUE="Submit">
347 <% include('/elements/footer.html') %>
352 unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
354 my $conf = new FS::Conf;
355 my @shells = $conf->config('shells');
357 my $curuser = $FS::CurrentUser::CurrentUser;
359 my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups);
360 if ( $cgi->param('error') ) {
362 $svc_acct = new FS::svc_acct ( {
363 map { $_, scalar($cgi->param($_)) } fields('svc_acct')
365 $svcnum = $svc_acct->svcnum;
366 $pkgnum = $cgi->param('pkgnum');
367 $svcpart = $cgi->param('svcpart');
368 $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
369 die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
370 @groups = $cgi->param('radius_usergroup');
372 } elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
374 $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
376 $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
379 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
380 die "No part_svc entry!" unless $part_svc;
382 $svc_acct = new FS::svc_acct({svcpart => $svcpart});
386 $svc_acct->password_recover('Y'); #default. hmm.
390 my($query) = $cgi->keywords;
391 $query =~ /^(\d+)$/ or die "unparsable svcnum";
393 $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
394 or die "Unknown (svc_acct) svcnum!";
396 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
397 or die "Unknown (cust_svc) svcnum!";
399 $pkgnum=$cust_svc->pkgnum;
400 $svcpart=$cust_svc->svcpart;
402 $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
403 die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
405 @groups = $svc_acct->radius_groups;
409 my $communigate = scalar($part_svc->part_export('communigate_pro'));
410 # || scalar($part_svc->part_export('communigate_pro_singledomain'));
412 my( $cust_pkg, $cust_main ) = ( '', '' );
414 $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
415 $cust_main = $cust_pkg->cust_main;
418 unless ( $svcnum || $cgi->param('error') ) { #adding
422 unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
423 $svc_acct->setfield('finger',
424 $cust_main->getfield('first') . " " . $cust_main->getfield('last')
429 $svc_acct->set_default_and_fixed( {
430 #false laziness w/svc-acct::_fieldhandlers
432 my( $self, $groups ) = @_;
433 if ( ref($groups) eq 'ARRAY' ) {
436 } elsif ( length($groups) ) {
437 @groups = split(/\s*,\s*/, $groups);
448 #fixed radius groups always override & display
449 if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) {
450 @groups = split(',', $part_svc->part_svc_column('usergroup')->columnvalue);
453 my $action = $svcnum ? 'Edit' : 'Add';
455 my $svc = $part_svc->getfield('svc');
457 my $otaker = getotaker;
459 my $username = $svc_acct->username;
462 if ( $cgi->param('error') ) {
463 $password = $cgi->param('clear_password');
464 } elsif ( $svcnum ) {
465 my $password_encryption = $svc_acct->_password_encryption;
466 if ( $password = $svc_acct->get_cleartext_password ) {
467 $password = '*HIDDEN*' unless $conf->exists('showpasswords');
468 } elsif( $svc_acct->_password and $password_encryption ne 'plain' ) {
469 $password = "(".uc($password_encryption)." encrypted)";
474 $conf->exists('usernamemax')
475 ? $conf->config('usernamemax')
476 : dbdef->table('svc_acct')->column('username')->length;
479 my $pmax = max($conf->config('passwordmax') || 13);