1 <% include('/elements/header.html', 'Domain Catchall Edit') %>
3 <% include('/elements/error.html') %>
5 <FORM ACTION="<%$p1%>process/catchall.cgi" METHOD=POST>
7 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum |h %>">
8 Service #<FONT SIZE=+1><B><% $svcnum ? $svcnum : ' (NEW)' |h %></B></FONT>
11 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum |h %>">
13 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
15 % my $domain = $svc_domain->domain;
16 % my $catchall = $svc_domain->catchall;
18 <INPUT TYPE="hidden" NAME="domain" VALUE="<% $domain |h %>">
20 Mail to <I>(anything)</I>@<B><% $domain |h %></B> forwards to <SELECT NAME="catchall" SIZE=1>
21 % foreach $_ (keys %email) {
22 <OPTION<% $_ eq $catchall ? ' SELECTED' : '' %> VALUE="<% $_ %>"><% $email{$_} %>
27 <INPUT TYPE="submit" VALUE="Submit">
31 <% include('/elements/footer.html') %>
36 unless $FS::CurrentUser::CurrentUser->access_right('Edit domain catchall');
38 my $conf = new FS::Conf;
40 my($svc_domain, $svcnum, $pkgnum, $svcpart, $part_svc);
41 if ( $cgi->param('error') ) {
42 $svc_domain = new FS::svc_domain ( {
43 map { $_, scalar($cgi->param($_)) } fields('svc_domain')
45 $svcnum = $svc_domain->svcnum;
46 $pkgnum = $cgi->param('pkgnum');
47 $svcpart = $cgi->param('svcpart');
48 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
49 die "No part_svc entry!" unless $part_svc;
51 my($query) = $cgi->keywords;
52 if ( $query =~ /^(\d+)$/ ) { #editing
54 $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum})
55 or die "Unknown (svc_domain) svcnum!";
57 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
58 or die "Unknown (cust_svc) svcnum!";
60 $pkgnum=$cust_svc->pkgnum;
61 $svcpart=$cust_svc->svcpart;
63 $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
64 die "No part_svc entry!" unless $part_svc;
68 die "Invalid (svc_domain) svcnum!";
76 #find all possible user svcnums (and emails)
78 #starting with that currently attached
79 if ($svc_domain->catchall) {
80 my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_domain->catchall});
81 $email{$svc_domain->catchall} = $svc_acct->email;
84 #and including the rest for this customer
85 my($u_part_svc,@u_acct_svcparts);
86 foreach $u_part_svc ( qsearch('part_svc',{'svcdb'=>'svc_acct'}) ) {
87 push @u_acct_svcparts,$u_part_svc->getfield('svcpart');
90 my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
91 my($custnum)=$cust_pkg->getfield('custnum');
93 foreach $i_cust_pkg ( qsearch('cust_pkg',{'custnum'=>$custnum}) ) {
94 my($cust_pkgnum)=$i_cust_pkg->getfield('pkgnum');
96 foreach $acct_svcpart (@u_acct_svcparts) { #now find the corresponding
97 #record(s) in cust_svc ( for this
100 foreach $i_cust_svc ( qsearch('cust_svc',{'pkgnum'=>$cust_pkgnum,'svcpart'=>$acct_svcpart}) ) {
101 my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$i_cust_svc->getfield('svcnum')});
102 $email{$svc_acct->getfield('svcnum')}=$svc_acct->email;
109 my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svc_domain->catchall});
110 $email{$svc_domain->catchall} = $svc_acct->email;
113 # add an absence of a catchall
114 $email{''} = "(none)";