summaryrefslogtreecommitdiff
path: root/httemplate/search
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/search')
-rwxr-xr-xhttemplate/search/cust_main.cgi111
-rwxr-xr-xhttemplate/search/cust_pkg.cgi13
-rw-r--r--httemplate/search/elements/search.html9
-rwxr-xr-xhttemplate/search/report_receivables.cgi80
4 files changed, 121 insertions, 92 deletions
diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi
index 7d5941a16..f6841a099 100755
--- a/httemplate/search/cust_main.cgi
+++ b/httemplate/search/cust_main.cgi
@@ -109,6 +109,7 @@ if ( $cgi->param('browse')
push @qual, FS::cust_main->cancel_sql if $cgi->param('cancelled');
push @qual, FS::cust_main->prospect_sql if $cgi->param('prospect');
push @qual, FS::cust_main->active_sql if $cgi->param('active');
+ push @qual, FS::cust_main->inactive_sql if $cgi->param('inactive');
push @qual, FS::cust_main->susp_sql if $cgi->param('suspended');
#EWWWWWW
@@ -415,48 +416,78 @@ END
foreach my $addl_col ( @addl_cols ) { %>
- <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
-
- <% if ( $addl_col eq 'tickets' ) {
- if ( @custom_priorities ) {
- print &itable('', 0);
- foreach my $priority ( @custom_priorities, '' ) {
-
- my $num =
- FS::TicketSystem->num_customer_tickets($custnum,$priority);
- my $ahref = '';
- $ahref= '<A HREF="'.
- FS::TicketSystem->href_customer_tickets($custnum,$priority).
- '">'
- if $num;
-
- print '<TR>'.
- " <TD ALIGN=right><FONT SIZE=-1>$ahref$num</A></FONT></TD>".
- "<TD ALIGN=left><FONT SIZE=-1>$ahref".
- ( $priority || '<i>(none)</i>' ).
- "</A></FONT></TD></TR>";
-
- }
- print '<TR><TD BGCOLOR="#000000" COLSPAN=2></TD></TR>'.
- '<TR><TD ALIGN=right><FONT SIZE=-1>';
- }
-
- my $ahref = '';
- $ahref = '<A HREF="'.
- FS::TicketSystem->href_customer_tickets($custnum).
- '">'
- if $cust_main->get($addl_col);
-
- print $ahref. $cust_main->get($addl_col). '</A>';
- print "</FONT></TD><TD ALIGN=left>".
- "<FONT SIZE=-1>${ahref}Total</A><FONT>".
- "</TD></TR></TABLE>"
- if @custom_priorities;
+ <% if ( $addl_col eq 'tickets' ) { %>
- } else {
- print $cust_main->get($addl_col);
+ <% if ( @custom_priorities ) { %>
+
+ <TD CLASS="inv" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
+
+ <TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
+
+ <% foreach my $priority ( @custom_priorities, '' ) { %>
+
+ <%
+ my $num =
+ FS::TicketSystem->num_customer_tickets($custnum,$priority);
+ my $ahref = '';
+ $ahref= '<A HREF="'.
+ FS::TicketSystem->href_customer_tickets($custnum,$priority).
+ '">'
+ if $num;
+ %>
+
+ <TR>
+ <TD ALIGN=right>
+ <FONT SIZE=-1><%= $ahref.$num %></A></FONT>
+ </TD>
+ <TD ALIGN=left>
+ <FONT SIZE=-1><%= $ahref %><%= $priority || '<i>(none)</i>' %></A></FONT>
+ </TD>
+ </TR>
+
+ <% } %>
+
+ <TR>
+ <TH ALIGN=right STYLE="border-top: dashed 1px black">
+ <FONT SIZE=-1>
+
+ <% } else { %>
+
+ <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
+
+ <% } %>
+
+ <%
+ my $ahref = '';
+ $ahref = '<A HREF="'.
+ FS::TicketSystem->href_customer_tickets($custnum).
+ '">'
+ if $cust_main->get($addl_col);
+ %>
+
+ <%= $ahref %><%= $cust_main->get($addl_col) %></A>
+
+ <% if ( @custom_priorities ) { %>
+
+ </FONT></TH>
+ <TH ALIGN=left STYLE="border-top: dashed 1px black">
+ <FONT SIZE=-1><%= ${ahref} %>Total</A><FONT>
+ </TH>
+ </TR>
+ </TABLE>
+
+ <% } %>
+
+ </FONT></TD>
+
+ <% } else { %>
+
+ <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ROWSPAN=<%= $rowspan || 1 %> ALIGN=right><FONT SIZE=-1>
+ <%= $cust_main->get($addl_col) %>
+ </FONT></TD>
+
+<%
}
- print "</FONT></TD>";
}
my($n1)='';
diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi
index e8b3f490d..614e9b509 100755
--- a/httemplate/search/cust_pkg.cgi
+++ b/httemplate/search/cust_pkg.cgi
@@ -24,6 +24,12 @@ if ( $cgi->param('magic') eq 'active'
push @where, FS::cust_pkg->active_sql();
+} elsif ( $cgi->param('magic') eq 'inactive'
+ || $cgi->param('status') eq 'inactive' ) {
+
+ push @where, FS::cust_pkg->inactive_sql();
+
+
} elsif ( $cgi->param('magic') eq 'suspended'
|| $cgi->param('status') eq 'suspended' ) {
@@ -47,7 +53,10 @@ if ( $cgi->param('magic') eq 'active'
#false lazinessish w/graph/cust_bill_pkg.cgi
my $classnum = 0;
my @pkg_class = ();
-if ( $cgi->param('classnum') =~ /^(\d*)$/ ) {
+if ( exists($cgi->Vars->{'classnum'})
+ && $cgi->param('classnum') =~ /^(\d*)$/
+ )
+{
$classnum = $1;
if ( $classnum ) { #a specific class
push @where, "classnum = $classnum";
@@ -90,7 +99,7 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) {
} else {
if ( $cgi->param('magic') &&
- $cgi->param('magic') =~ /^(active|suspended|cancell?ed)$/
+ $cgi->param('magic') =~ /^(active|inactive|suspended|cancell?ed)$/
) {
$orderby = 'ORDER BY pkgnum';
diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index 6cf574164..3e689eba1 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -380,8 +380,7 @@
my $tableref = $_;
- '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0'.
- ' STYLE="border:none">'.
+ '<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>'.
join('', map {
@@ -393,7 +392,7 @@
my $element = $_;
- '<TD STYLE="border:none"'.
+ '<TD'.
( $element->{'align'}
? ' ALIGN="'. $element->{'align'}. '"'
: ''
@@ -432,6 +431,8 @@
) {
+ my $class = ( $field =~ /^<TABLE/i ) ? 'inv' : 'grid';
+
my $align = $aligns ? shift @$aligns : '';
$align = " ALIGN=$align" if $align;
@@ -471,7 +472,7 @@
}
%>
- <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $font %><%= $a %><%= $s %><%= $field %><%= $es %><%= $a ? '</A>' : '' %><%= $font ? '</FONT>' : '' %></TD>
+ <TD CLASS="<%= $class %>" BGCOLOR="<%= $bgcolor %>"<%= $align %>><%= $font %><%= $a %><%= $s %><%= $field %><%= $es %><%= $a ? '</A>' : '' %><%= $font ? '</FONT>' : '' %></TD>
<% } %>
<% } else { %>
<% foreach ( @$row ) { %>
diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi
index c1a239fd2..3052ea93c 100755
--- a/httemplate/search/report_receivables.cgi
+++ b/httemplate/search/report_receivables.cgi
@@ -62,26 +62,19 @@ END
my $owed_cols = join(',', map owed( @$_, 'cust'=>1 ), @ranges );
- my $recurring = <<END;
- '0' != ( select freq from part_pkg
- where cust_pkg.pkgpart = part_pkg.pkgpart )
-END
-
- my $packages_cols = <<END;
+ my $select_count_pkgs = FS::cust_main->select_count_pkgs_sql;
- ( select count(*) from cust_pkg
- where cust_main.custnum = cust_pkg.custnum
- and $recurring
- and ( cancel = 0 or cancel is null )
- ) as uncancelled_pkgs,
-
- ( select count(*) from cust_pkg
- where cust_main.custnum = cust_pkg.custnum
- and $recurring
- and ( cancel = 0 or cancel is null )
- and ( susp = 0 or susp is null )
- ) as active_pkgs
+ my $active_sql = FS::cust_pkg->active_sql;
+ my $inactive_sql = FS::cust_pkg->inactive_sql;
+ my $suspended_sql = FS::cust_pkg->inactive_sql;
+ my $cancelled_sql = FS::cust_pkg->inactive_sql;
+ my $packages_cols = <<END;
+ ( $select_count_pkgs ) AS num_pkgs_sql,
+ ( $select_count_pkgs AND $active_sql ) AS active_pkgs,
+ ( $select_count_pkgs AND $inactive_sql ) AS inactive_pkgs,
+ ( $select_count_pkgs AND $suspended_sql ) AS suspended_pkgs,
+ ( $select_count_pkgs AND $cancelled_sql ) AS cancelled_pkgs
END
my $where = "where ". owed(0, 0, 'cust'=>1, 'noas'=>1). " > 0";
@@ -119,6 +112,27 @@ END
my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
+ my $status_statuscol = sub {
+ #conceptual false laziness with cust_main::status...
+ my $row = shift;
+
+ my $status = 'unknown';
+ if ( $row->num_pkgs_sql == 0 ) {
+ $status = 'prospect';
+ } elsif ( $row->active_pkgs > 0 ) {
+ $status = 'active';
+ } elsif ( $row->inactive_pkgs > 0 ) {
+ $status = 'inactive';
+ } elsif ( $row->suspended_pkgs > 0 ) {
+ $status = 'suspended';
+ } elsif ( $row->cancelled_pkgs > 0 ) {
+ $status = 'cancelled'
+ }
+
+ ( ucfirst($status), $FS::cust_main::statuscolor{$status} );
+ };
+
+
%><%= include( 'elements/search.html',
'title' => 'Accounts Receivable Aging Summary',
'name' => 'customers',
@@ -156,20 +170,7 @@ END
],
'fields' => [
\&FS::UI::Web::cust_fields,
- sub {
- my $row = shift;
- my $status = 'Cancelled';
- my $statuscol = 'FF0000';
- if ( $row->uncancelled_pkgs ) {
- $status = 'Suspended';
- $statuscol = 'FF9900';
- if ( $row->active_pkgs ) {
- $status = 'Active';
- $statuscol = '00CC00';
- }
- }
- $status;
- },
+ sub { ( &{$status_statuscol}(shift) )[0] },
#sub { ucfirst(shift->status) },
sub { sprintf( $money_char.'%.2f',
shift->get('owed_0_30') ) },
@@ -202,20 +203,7 @@ END
'b', '', '', '', '', 'b', ],
'color' => [
( map '', FS::UI::Web::cust_header() ),
- sub {
- my $row = shift;
- my $status = 'Cancelled';
- my $statuscol = 'FF0000';
- if ( $row->uncancelled_pkgs ) {
- $status = 'Suspended';
- $statuscol = 'FF9900';
- if ( $row->active_pkgs ) {
- $status = 'Active';
- $statuscol = '00CC00';
- }
- }
- $statuscol;
- },
+ sub { ( &{$status_statuscol}(shift) )[1] },
#sub { shift->statuscolor; },
'',
'',