freeside/httemplate/search svc_broadband.cgi,NONE,1.1
Kristian Hoffmann
khoff at pouncequick.420.am
Wed Nov 24 10:28:11 PST 2004
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory pouncequick:/tmp/cvs-serv28733/search
Added Files:
svc_broadband.cgi
Log Message:
Added IP address search.
--- NEW FILE: svc_broadband.cgi ---
<%
my $conf = new FS::Conf;
my($query)=$cgi->keywords;
$query ||= ''; #to avoid use of unitialized value errors
my(@svc_broadband,$sortby);
if ( $query eq 'svcnum' ) {
$sortby=\*svcnum_sort;
@svc_broadband=qsearch('svc_broadband',{});
} elsif ( $query eq 'blocknum' ) {
$sortby=\*blocknum_sort;
@svc_broadband=qsearch('svc_broadband',{});
} else {
$cgi->param('ip_addr') =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/;
my($ip_addr)=$1;
@svc_broadband = qsearchs('svc_broadband',{'ip_addr'=>$ip_addr});
}
my %routerbyblock = ();
foreach my $router (qsearch('router', {})) {
foreach ($router->addr_block) {
$routerbyblock{$_->blocknum} = $router;
}
}
if ( scalar(@svc_broadband) == 1 ) {
print $cgi->redirect(popurl(2). "view/svc_broadband.cgi?". $svc_broadband[0]->svcnum);
#exit;
} elsif ( scalar(@svc_broadband) == 0 ) {
%>
<!-- mason kludge -->
<%
eidiot "No matching ip address found!\n";
} else {
%>
<!-- mason kludge -->
<%
my($total)=scalar(@svc_broadband);
print header("IP Address Search Results",''), <<END;
$total matching broadband services found
<TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0>
<TR>
<TH>Service #</TH>
<TH>Router</TH>
<TH>IP Address</TH>
</TR>
END
foreach my $svc_broadband (
sort $sortby (@svc_broadband)
) {
my($svcnum,$ip_addr,$routername,$routernum)=(
$svc_broadband->svcnum,
$svc_broadband->ip_addr,
$routerbyblock{$svc_broadband->blocknum}->routername,
$routerbyblock{$svc_broadband->blocknum}->routernum,
);
my $rowspan = 1;
print <<END;
<TR>
<TD ROWSPAN=$rowspan><A HREF="${p}view/svc_broadband.cgi?$svcnum">$svcnum</A></TD>
<TD ROWSPAN=$rowspan><A HREF="${p}view/router.cgi?$routernum">$routername</A></TD>
<TD ROWSPAN=$rowspan><A HREF="${p}view/svc_broadband.cgi?$svcnum">$ip_addr</A></TD>
END
#print @rows;
print "</TR>";
}
print <<END;
</TABLE>
</BODY>
</HTML>
END
}
sub svcnum_sort {
$a->getfield('svcnum') <=> $b->getfield('svcnum');
}
sub blocknum_sort {
if ($a->getfield('blocknum') == $b->getfield('blocknum')) {
$a->getfield('ip_addr') cmp $b->getfield('ip_addr');
} else {
$a->getfield('blocknum') cmp $b->getfield('blocknum');
}
}
%>
More information about the freeside-commits
mailing list