3 my $conf = new FS::Conf;
4 my $mydomain = $conf->config('domain');
6 my($query)=$cgi->keywords;
7 $query ||= ''; #to avoid use of unitialized value errors
8 my(@svc_domain,$sortby);
9 if ( $query eq 'svcnum' ) {
10 $sortby=\*svcnum_sort;
11 @svc_domain=qsearch('svc_domain',{});
12 } elsif ( $query eq 'domain' ) {
13 $sortby=\*domain_sort;
14 @svc_domain=qsearch('svc_domain',{});
15 } elsif ( $query eq 'UN_svcnum' ) {
16 $sortby=\*svcnum_sort;
17 @svc_domain = grep qsearchs('cust_svc',{
18 'svcnum' => $_->svcnum,
20 }), qsearch('svc_domain',{});
21 } elsif ( $query eq 'UN_domain' ) {
22 $sortby=\*domain_sort;
23 @svc_domain = grep qsearchs('cust_svc',{
24 'svcnum' => $_->svcnum,
26 }), qsearch('svc_domain',{});
28 $cgi->param('domain') =~ /^([\w\-\.]+)$/;
30 #push @svc_domain, qsearchs('svc_domain',{'domain'=>$domain});
31 @svc_domain = qsearchs('svc_domain',{'domain'=>$domain});
34 if ( scalar(@svc_domain) == 1 ) {
35 print $cgi->redirect(popurl(2). "view/svc_domain.cgi?". $svc_domain[0]->svcnum);
37 } elsif ( scalar(@svc_domain) == 0 ) {
41 eidiot "No matching domains found!\n";
46 my($total)=scalar(@svc_domain);
47 print header("Domain Search Results",''), <<END;
49 $total matching domains found
50 <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0>
54 <TH>Mail to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
55 <TH>Forwards to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
59 # my(%saw); # if we've multiple domains with the same
60 # svcnum, then we've a corrupt database
62 foreach my $svc_domain (
63 # sort $sortby grep(!$saw{$_->svcnum}++, @svc_domain)
64 sort $sortby (@svc_domain)
71 #if ( qsearch('svc_acct_sm',{'domsvc'=>$svcnum}) ) {
73 # qq|<FORM ACTION="svc_acct_sm.cgi" METHOD="post">|.
74 # qq|<INPUT TYPE="hidden" NAME="domuser" VALUE="">|.
75 # qq|<INPUT TYPE="hidden" NAME="domain" VALUE="$domain">|.
76 # qq|<INPUT TYPE="submit" VALUE="(mail aliases)">|.
83 my @svc_acct=qsearch('svc_acct',{'domsvc' => $svcnum});
89 sort {$b->getfield('username') cmp $a->getfield('username')} (@svc_acct)
94 my($svcnum,$username)=(
99 my @svc_forward = qsearch( 'svc_forward', { 'srcsvc' => $svcnum } );
101 foreach $svc_forward (@svc_forward) {
103 $svc_forward->dstsvc,
107 my $dst_svc_acct=qsearchs( 'svc_acct', { 'svcnum' => $dstsvc } );
108 my $destination=$dst_svc_acct->email;
109 push @forwards, qq!<TD><A HREF="!, popurl(2),
110 qq!view/svc_acct.cgi?$dstsvc">$destination</A>!,
114 push @forwards, qq!<TD>$dst</TD></TR>!
119 push @rows, qq!$n1<TD ROWSPAN=!, (scalar(@svc_forward) || 1),
120 qq!><A HREF="!. popurl(2). qq!view/svc_acct.cgi?$svcnum">!,
121 #print '', ( ($domuser eq '*') ? "<I>(anything)</I>" : $domuser );
122 ( ($username eq '*') ? "<I>(anything)</I>" : $username ),
123 qq!\@$domain</A> </TD>!,
126 push @rows, @forwards;
128 $rowspan += (scalar(@svc_forward) || 1);
131 #end of false laziness
137 <TD ROWSPAN=$rowspan><A HREF="${p}view/svc_domain.cgi?$svcnum"><FONT SIZE=-1>$svcnum</FONT></A></TD>
138 <TD ROWSPAN=$rowspan>$domain</TD>
155 $a->getfield('svcnum') <=> $b->getfield('svcnum');
159 $a->getfield('domain') cmp $b->getfield('domain');