freeside/httemplate/search svc_www.cgi,1.2,1.3 svc_forward.cgi,1.1,1.2
ivan
ivan at pouncequick.420.am
Fri Apr 29 06:00:33 PDT 2005
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory pouncequick:/tmp/cvs-serv31555
Modified Files:
svc_www.cgi svc_forward.cgi
Log Message:
template forward search using the standard search template: forwards are now paged
Index: svc_forward.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_forward.cgi,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- svc_forward.cgi 13 Feb 2004 11:28:07 -0000 1.1
+++ svc_forward.cgi 29 Apr 2005 13:00:30 -0000 1.2
@@ -4,76 +4,105 @@
my($query)=$cgi->keywords;
$query ||= ''; #to avoid use of unitialized value errors
-my(@svc_forward,$sortby);
+my($orderby);
if ( $query eq 'svcnum' ) {
- $sortby=\*svcnum_sort;
- @svc_forward=qsearch('svc_forward',{});
+ $orderby = 'ORDER BY svcnum';
} else {
eidiot('unimplemented');
}
-if ( scalar(@svc_forward) == 1 ) {
- print $cgi->redirect(popurl(2). "view/svc_forward.cgi?". $svc_forward[0]->svcnum);
- #exit;
-} elsif ( scalar(@svc_forward) == 0 ) {
-%>
-<!-- mason kludge -->
-<%
- eidiot "No matching forwards found!\n";
-} else {
-%>
-<!-- mason kludge -->
-<%
- my $total = scalar(@svc_forward);
- print header("Mail forward Search Results",''), <<END;
+my $count_query = 'SELECT COUNT(*) FROM svc_forward';
+my $sql_query = {
+ 'table' => 'svc_forward',
+ 'hashref' => {},
+ 'extra_sql' => $orderby,
+};
- $total matching mail forwards found
- <TABLE BORDER=4 CELLSPACING=0 CELLPADDING=0>
- <TR>
- <TH>Service #<BR><FONT SIZE=-1>(click to view forward)</FONT></TH>
- <TH>Mail to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
- <TH>Forwards to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
- </TR>
-END
+# <TH>Service #<BR><FONT SIZE=-1>(click to view forward)</FONT></TH>
+# <TH>Mail to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
+# <TH>Forwards to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
- foreach my $svc_forward (
- sort $sortby (@svc_forward)
- ) {
- my $svcnum = $svc_forward->svcnum;
+my $link = [ "${p}/view/svc_forward.cgi?", 'svcnum' ];
+my $format_src = sub {
+ my $svc_forward = shift;
+ if ( $svc_forward->srcsvc_acct ) {
+ $svc_forward->srcsvc_acct->email;
+ } else {
my $src = $svc_forward->src;
$src = "<I>(anything)</I>$src" if $src =~ /^@/;
- if ( $svc_forward->srcsvc_acct ) {
- $src = qq!<A HREF="${p}view/svc_acct.cgi?!. $svc_forward->srcsvc. '">'.
- $svc_forward->srcsvc_acct->email. '</A>';
- }
+ $src;
+ }
+};
- my $dst = $svc_forward->dst;
- if ( $svc_forward->dstsvc_acct ) {
- $dst = qq!<A HREF="${p}view/svc_acct.cgi?!. $svc_forward->dstsvc. '">'.
- $svc_forward->dstsvc_acct->email. '</A>';
- }
+my $link_src = sub {
+ my $svc_forward = shift;
+ if ( $svc_forward->srcsvc_acct ) {
+ [ "${p}view/svc_acct.cgi?", 'srcsvc' ];
+ } else {
+ '';
+ }
+};
- print <<END;
- <TR>
- <TD><A HREF="${p}view/svc_forward.cgi?$svcnum">$svcnum</A></TD>
- <TD>$src</TD>
- <TD>$dst</TD>
- </TR>
-END
+my $format_dst = sub {
+ my $svc_forward = shift;
+ if ( $svc_forward->dstsvc_acct ) {
+ $svc_forward->dstsvc_acct->email;
+ } else {
+ $svc_forward->dst;
+ }
+};
+my $link_dst = sub {
+ my $svc_forward = shift;
+ if ( $svc_forward->dstsvc_acct ) {
+ [ "${p}view/svc_acct.cgi?", 'dstsvc' ];
+ } else {
+ '';
}
-
- print <<END;
- </TABLE>
- </BODY>
-</HTML>
-END
+};
-}
+#this would quite a bit more efficient as a left join as part of the main query
+my $format_cust = sub {
+ my $svc_forward = shift;
+ my $cust_pkg = $svc_forward->cust_svc->cust_pkg;
+ if ( $cust_pkg ) {
+ $cust_pkg->cust_main->name;
+ } else {
+ '';
+ }
+};
-sub svcnum_sort {
- $a->getfield('svcnum') <=> $b->getfield('svcnum');
-}
+my $link_cust = sub {
+ my $svc_forward = shift;
+ my $cust_pkg = $svc_forward->cust_svc->cust_pkg;
+ if ( $cust_pkg ) {
+ [ "${p}view/cust_main.cgi?", sub { shift->cust_svc->cust_pkg->custnum } ];
+ } else {
+ '';
+ }
+};
+%><%= include ('elements/search.html',
+ 'title' => "Mail forward Search Results",
+ 'name' => 'mail forwards',
+ 'query' => $sql_query,
+ 'count_query' => $count_query,
+ 'redirect' => $link,
+ 'header' => [ '#',
+ 'Mail to',
+ 'Forwards to',
+ 'Customer',
+ ],
+ 'fields' => [ 'svcnum',
+ $format_src,
+ $format_dst,
+ $format_cust,
+ ],
+ 'links' => [ $link,
+ $link_src,
+ $link_dst,
+ $link_cust,
+ ],
+ )
%>
Index: svc_www.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/svc_www.cgi,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- svc_www.cgi 6 Mar 2005 03:04:29 -0000 1.2
+++ svc_www.cgi 29 Apr 2005 13:00:30 -0000 1.3
@@ -4,7 +4,7 @@
my($query)=$cgi->keywords;
$query ||= ''; #to avoid use of unitialized value errors
-my(@svc_www, $orderby);
+my $orderby;
if ( $query eq 'svcnum' ) {
$orderby = 'ORDER BY svcnum';
} else {
More information about the freeside-commits
mailing list