X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fsvc_acct.cgi;h=5c2d5f4952ebcfdbc8c7a7f4459f295d721bad89;hb=7b125e587a4d1ee0aca692e23ea7897f671855ae;hp=26266957deeed239901a08acc67ee9eab0128155;hpb=c0806ebf17ec0c4647915d5be09e35034171e2bf;p=freeside.git
diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi
index 26266957d..5c2d5f495 100755
--- a/httemplate/edit/svc_acct.cgi
+++ b/httemplate/edit/svc_acct.cgi
@@ -1,215 +1,754 @@
-<%
-#
-
-use strict;
-use vars qw( $conf $cgi @shells $action $svcnum $svc_acct $pkgnum $svcpart
- $part_svc $svc $otaker $username $password $ulen $ulen2 $p1
- $popnum $domsvc $uid $gid $finger $dir $shell $quota $slipip
- @svc_domain );
-use CGI;
-use CGI::Carp qw(fatalsToBrowser);
-use FS::UID qw(cgisuidsetup getotaker);
-use FS::CGI qw(header popurl);
-use FS::Record qw(qsearch qsearchs fields);
-use FS::svc_acct;
-use FS::Conf;
-
-$cgi = new CGI;
-&cgisuidsetup($cgi);
-
-$conf = new FS::Conf;
-@shells = $conf->config('shells');
+<% include('/elements/header.html', "$action $svc account") %>
+<% include('/elements/error.html') %>
+
+% if ( $cust_main ) {
+
+ <% include( '/elements/small_custview.html', $cust_main, '', 1,
+ popurl(2) . "view/cust_main.cgi") %>
+
+% }
+
+
+
+
+
+<% include('/elements/footer.html') %>
+
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+my $conf = new FS::Conf;
+my @shells = $conf->config('shells');
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups);
if ( $cgi->param('error') ) {
+
$svc_acct = new FS::svc_acct ( {
map { $_, scalar($cgi->param($_)) } fields('svc_acct')
} );
$svcnum = $svc_acct->svcnum;
$pkgnum = $cgi->param('pkgnum');
$svcpart = $cgi->param('svcpart');
+ $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
+ die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
+ @groups = $cgi->param('radius_usergroup');
+
+} elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
+
+ $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
+ $pkgnum = $1;
+ $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
+ $svcpart = $1;
+
$part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
die "No part_svc entry!" unless $part_svc;
-} else {
- my($query) = $cgi->keywords;
- if ( $query =~ /^(\d+)$/ ) { #editing
- $svcnum=$1;
- $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
- or die "Unknown (svc_acct) svcnum!";
- my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
- or die "Unknown (cust_svc) svcnum!";
+ $svc_acct = new FS::svc_acct({svcpart => $svcpart});
- $pkgnum=$cust_svc->pkgnum;
- $svcpart=$cust_svc->svcpart;
+ $svcnum='';
- $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
- die "No part_svc entry!" unless $part_svc;
+ $svc_acct->password_recover('Y'); #default. hmm.
- } else { #adding
+} else { #editing
- $svc_acct = new FS::svc_acct({});
+ my($query) = $cgi->keywords;
+ $query =~ /^(\d+)$/ or die "unparsable svcnum";
+ $svcnum=$1;
+ $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
+ or die "Unknown (svc_acct) svcnum!";
- foreach $_ (split(/-/,$query)) {
- $pkgnum=$1 if /^pkgnum(\d+)$/;
- $svcpart=$1 if /^svcpart(\d+)$/;
- }
- $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
- die "No part_svc entry!" unless $part_svc;
+ my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
+ or die "Unknown (cust_svc) svcnum!";
- $svcnum='';
+ $pkgnum=$cust_svc->pkgnum;
+ $svcpart=$cust_svc->svcpart;
- #set gecos
- my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
- if ($cust_pkg) {
- my($cust_main)=qsearchs('cust_main',{'custnum'=> $cust_pkg->custnum } );
- $svc_acct->setfield('finger',
- $cust_main->getfield('first') . " " . $cust_main->getfield('last')
- ) ;
- }
+ $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
+ die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
- #set fixed and default fields from part_svc
- my($field);
- foreach $field ( fields('svc_acct') ) {
- if ( $part_svc->getfield('svc_acct__'. $field. '_flag') ne '' ) {
- $svc_acct->setfield($field,$part_svc->getfield('svc_acct__'. $field) );
- }
- }
+ @groups = $svc_acct->radius_groups;
- }
}
-$action = $svcnum ? 'Edit' : 'Add';
-$svc = $part_svc->getfield('svc');
+my $communigate = scalar($part_svc->part_export('communigate_pro'));
+ # || scalar($part_svc->part_export('communigate_pro_singledomain'));
-$otaker = getotaker;
-
-$username = $svc_acct->username;
-if ( $svc_acct->_password ) {
- if ( $conf->exists('showpasswords') ) {
- $password = $svc_acct->_password;
- } else {
- $password = "*HIDDEN*";
- }
-} else {
- $password = '';
+my( $cust_pkg, $cust_main ) = ( '', '' );
+if ( $pkgnum ) {
+ $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
+ $cust_main = $cust_pkg->cust_main;
}
-$ulen = $svc_acct->dbdef_table->column('username')->length;
-$ulen2 = $ulen+2;
-
-$p1 = popurl(1);
-print $cgi->header( '-expires' => 'now' ), header("$action $svc account");
-
-print qq!Error: !, $cgi->param('error'),
- ""
- if $cgi->param('error');
-
-print <
-
-
-
-Username:
-
-
Password:
-
-(blank to generate)
-END
-
-#domain
-$domsvc = $svc_acct->domsvc || 0;
-if ( $part_svc->svc_acct__domsvc_flag eq "F" ) {
- print qq!!;
-} else {
- my @svc_domain = ();
- my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
- if ($cust_pkg) {
- my @cust_svc =
- map { qsearch('cust_svc', { 'pkgnum' => $_->pkgnum } ) }
- qsearch('cust_pkg', { 'custnum' => $cust_pkg->custnum } );
- foreach my $cust_svc ( @cust_svc ) {
- $svc_domain = qsearchs('svc_domain', { 'svcnum' => $_->svcnum } );
- push @svc_domain, $svc_domain if $svc_domain;
+unless ( $svcnum || $cgi->param('error') ) { #adding
+
+ #set gecos
+ if ($cust_main) {
+ unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
+ $svc_acct->setfield('finger',
+ $cust_main->getfield('first') . " " . $cust_main->getfield('last')
+ );
}
- } else {
- @svc_domain = qsearch('svc_domain', {} );
}
- print qq!
Domain: ";
-}
-#pop
-$popnum = $svc_acct->popnum || 0;
-if ( $part_svc->svc_acct__popnum_flag eq "F" ) {
- print qq!!;
-} else {
- print qq!
POP: ";
+ $svc_acct->set_default_and_fixed( {
+ #false laziness w/svc-acct::_fieldhandlers
+ 'usergroup' => sub {
+ my( $self, $groups ) = @_;
+ if ( ref($groups) eq 'ARRAY' ) {
+ @groups = @$groups;
+ $groups;
+ } elsif ( length($groups) ) {
+ @groups = split(/\s*,\s*/, $groups);
+ [ @groups ];
+ } else {
+ @groups = ();
+ [];
+ }
+ }
+ } );
+
}
-($uid,$gid,$finger,$dir)=(
- $svc_acct->uid,
- $svc_acct->gid,
- $svc_acct->finger,
- $svc_acct->dir,
-);
-
-print <
-
-
GECOS:
-
-END
-
-$shell = $svc_acct->shell;
-if ( $part_svc->svc_acct__shell_flag eq "F" ) {
- print qq!!;
-} else {
- print qq!
Shell: ";
+#fixed radius groups always override & display
+if ( $part_svc->part_svc_column('usergroup')->columnflag eq 'F' ) {
+ @groups = split(',', $part_svc->part_svc_column('usergroup')->columnvalue);
}
-($quota,$slipip)=(
- $svc_acct->quota,
- $svc_acct->slipip,
-);
+my $action = $svcnum ? 'Edit' : 'Add';
+
+my $svc = $part_svc->getfield('svc');
-print qq!!;
+my $otaker = getotaker;
-if ( $part_svc->svc_acct__slipip_flag eq "F" ) {
- print qq!!;
-} else {
- print qq!
IP: !;
+my $username = $svc_acct->username;
+
+my $password = '';
+if ( $cgi->param('error') ) {
+ $password = $cgi->param('clear_password');
+} elsif ( $svcnum ) {
+ my $password_encryption = $svc_acct->_password_encryption;
+ if ( $password = $svc_acct->get_cleartext_password ) {
+ $password = '*HIDDEN*' unless $conf->exists('showpasswords');
+ } elsif( $svc_acct->_password and $password_encryption ne 'plain' ) {
+ $password = "(".uc($password_encryption)." encrypted)";
+ }
}
-#submit
-print qq!!;
+my $ulen =
+ $conf->exists('usernamemax')
+ ? $conf->config('usernamemax')
+ : dbdef->table('svc_acct')->column('username')->length;
+my $ulen2 = $ulen+2;
-print <
-