X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fsvc_forward.cgi;h=73f6465b931977d7587ca516cb17dd687d48609a;hb=c5e31619e5a3071506cff19578e9e377753a96f4;hp=de4c8cbc93fd9edf32d7ed9e760be0a03f47be0c;hpb=06d6c58f29564e0cbf92c6df01c7c0409a5c3097;p=freeside.git diff --git a/httemplate/edit/svc_forward.cgi b/httemplate/edit/svc_forward.cgi index de4c8cbc9..73f6465b9 100755 --- a/httemplate/edit/svc_forward.cgi +++ b/httemplate/edit/svc_forward.cgi @@ -1,23 +1,92 @@ -<% -# - -use strict; -use vars qw( $conf $cgi $mydomain $action $svcnum $svc_forward $pkgnum $svcpart - $part_svc $query %email $p1 $srcsvc $dstsvc $dst ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::CGI qw(header popurl); -use FS::Record qw(qsearch qsearchs fields); -use FS::svc_forward; -use FS::Conf; - -$cgi = new CGI; -&cgisuidsetup($cgi); - -$conf = new FS::Conf; -$mydomain = $conf->config('domain'); +<% include('/elements/header.html', "Mail Forward $action") %> + +<% include('/elements/error.html') %> + +Service #<% $svcnum ? "$svcnum" : " (NEW)" %>
+Service: <% $part_svc->svc %>

+ +
+ + + + + + +<% ntable("#cccccc",2) %> + + + Email to + +% if ( $conf->exists('svc_forward-no_srcsvc') ) { + +% } else { + +% } + +% my $src_disabled = $src +% || $conf->exists('svc_forward-no_srcsvc') +% || !scalar(%email); + + > + + + + +Forwards to + +> + + +
+
+ +<% 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($svcnum, $pkgnum, $svcpart, $part_svc, $svc_forward); if ( $cgi->param('error') ) { $svc_forward = new FS::svc_forward ( { map { $_, scalar($cgi->param($_)) } fields('svc_forward') @@ -27,61 +96,56 @@ if ( $cgi->param('error') ) { $svcpart = $cgi->param('svcpart'); $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_forward=qsearchs('svc_forward',{'svcnum'=>$svcnum}) - or die "Unknown (svc_forward) svcnum!"; - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; +} elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; + $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum'; + $pkgnum = $1; + $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart'; + $svcpart = $1; - } else { #adding + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; - $svc_forward = new FS::svc_forward({}); + $svc_forward = new FS::svc_forward({}); - foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart - $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; + $svcnum=''; - $svcnum=''; + $svc_forward->set_default_and_fixed; - #set fixed and default fields from part_svc - my($field); - foreach $field ( fields('svc_forward') ) { - if ( $part_svc->getfield('svc_forward__'. $field. '_flag') ne '' ) { - $svc_forward->setfield($field,$part_svc->getfield('svc_forward__'. $field) ); - } - } +} else { #editing + + my($query) = $cgi->keywords; + + $query =~ /^(\d+)$/ or die "unparsable svcnum"; + $svcnum=$1; + $svc_forward=qsearchs('svc_forward',{'svcnum'=>$svcnum}) + or die "Unknown (svc_forward) svcnum!"; + + my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) + or die "Unknown (cust_svc) svcnum!"; + + $pkgnum=$cust_svc->pkgnum; + $svcpart=$cust_svc->svcpart; + + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; - } } -$action = $svc_forward->svcnum ? 'Edit' : 'Add'; +my $action = $svc_forward->svcnum ? 'Edit' : 'Add'; + +my %email; + +#starting with those currently attached +foreach my $method (qw( srcsvc_acct dstsvc_acct )) { + my $svc_acct = $svc_forward->$method(); + $email{$svc_acct->svcnum} = $svc_acct->email if $svc_acct; +} if ($pkgnum) { #find all possible user svcnums (and emails) - #starting with those currently attached - if ( $svc_forward->srcsvc ) { - my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $svc_forward->srcsvc } ); - $email{$svc_forward->srcsvc} = $svc_acct->email; - } - if ( $svc_forward->dstsvc ) { - my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $svc_forward->dstsvc } ); - $email{$svc_forward->dstsvc} = $svc_acct->email; - } - #and including the rest for this customer my($u_part_svc,@u_acct_svcparts); foreach $u_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_acct'}) ) { @@ -97,133 +161,26 @@ if ($pkgnum) { foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding #record(s) in cust_svc ( for this #pkgnum ! ) - my($i_cust_svc); - foreach $i_cust_svc ( qsearch('cust_svc',{'pkgnum'=>$cust_pkgnum,'svcpart'=>$acct_svcpart}) ) { - $svc_acct=qsearchs('svc_acct',{'svcnum'=>$i_cust_svc->getfield('svcnum')}); - $email{$svc_acct->getfield('svcnum')}=$svc_acct->email; + foreach my $i_cust_svc ( + qsearch( 'cust_svc', { 'pkgnum' => $cust_pkgnum, + 'svcpart' => $acct_svcpart } ) + ) { + my $svc_acct = + qsearchs( 'svc_acct', { 'svcnum' => $i_cust_svc->svcnum } ); + $email{$svc_acct->svcnum} = $svc_acct->email; } } } -} elsif ( $action eq 'Edit' ) { - - my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_forward->srcsvc}); - $email{$svc_forward->srcsvc} = $svc_acct->email; - - $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svc_forward->dstsvc}); - $email{$svc_forward->dstsvc} = $svc_acct->email; - -} else { +} elsif ( $action eq 'Add' ) { die "\$action eq Add, but \$pkgnum is null!\n"; } -($srcsvc,$dstsvc,$dst)=( +my($srcsvc,$dstsvc,$dst)=( $svc_forward->srcsvc, $svc_forward->dstsvc, $svc_forward->dst, ); +my $src = $svc_forward->dbdef_table->column('src') ? $svc_forward->src : ''; -#display - -$p1 = popurl(1); -print $cgi->header( '-expires' => 'now' ), header("Mail Forward $action", '', - " onLoad=\"visualize()\""); - -%> - - - -<% - -print qq!Error: !, $cgi->param('error'), - "" - if $cgi->param('error'); - -print qq!
!; - -#svcnum -print qq!!; -print qq!Service #!, $svcnum ? $svcnum : " (NEW)", ""; -print qq!
!; - -#pkgnum -print qq!!; - -#svcpart -print qq!!; - -#srcsvc -print qq!\n\nMail to "; - -#dstsvc -print qq! forwards to mailbox."; - -%> - - - -<% -print qq! Other destination: !; -%> - - - -
-
- - - - - - +