% # use strict; use vars qw( $conf $cgi $action $svcnum $svc_domain $pkgnum $svcpart $part_svc $query %email $p1 $domain $catchall ); 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_acct; use FS::svc_domain; use FS::svc_forward; use FS::Conf; $cgi = new CGI; &cgisuidsetup($cgi); $conf = new FS::Conf; if ( $cgi->param('error') ) { $svc_domain = new FS::svc_domain ( { map { $_, scalar($cgi->param($_)) } fields('svc_domain') } ); $svcnum = $svc_domain->svcnum; $pkgnum = $cgi->param('pkgnum'); $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_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum}) or die "Unknown (svc_domain) 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; } else { die "Invalid (svc_domain) svcnum!"; } } if ($pkgnum) { #find all possible user svcnums (and emails) #starting with that currently attached if ($svc_domain->catchall) { my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_domain->catchall}); $email{$svc_domain->catchall} = $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'}) ) { push @u_acct_svcparts,$u_part_svc->getfield('svcpart'); } my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); my($custnum)=$cust_pkg->getfield('custnum'); my($i_cust_pkg); foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) { my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum'); my($acct_svcpart); 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}) ) { my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$i_cust_svc->getfield('svcnum')}); $email{$svc_acct->getfield('svcnum')}=$svc_acct->email; } } } } else { my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_domain->catchall}); $email{$svc_domain->catchall} = $svc_acct->email; } # add an absence of a catchall $email{0} = "(none)"; $p1 = popurl(1); print header("Domain Catchall Edit", ''); print qq!Error: !, $cgi->param('error'), "" if $cgi->param('error'); print qq!