X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcustomer_accounting_summary.html;h=c9cfa40883f63f704d9104afd1ed11649db69b3e;hb=af167dc766fad944b32ca7dc431b2549943b94dd;hp=5575283252db2cd806928e374b30d8e3e4a92c60;hpb=226fffec6fd0154ea8798b58321d4d119341879f;p=freeside.git
diff --git a/httemplate/search/customer_accounting_summary.html b/httemplate/search/customer_accounting_summary.html
index 557528325..c9cfa4088 100644
--- a/httemplate/search/customer_accounting_summary.html
+++ b/httemplate/search/customer_accounting_summary.html
@@ -9,8 +9,7 @@
http_header('Content-Disposition' => qq!attachment;filename="$filename"!);
my $output = '';
- use IO::String;
- my $XLS = IO::String->new($output);;
+ my $XLS = IO::String->new($output);
my $workbook = $format->{class}->new($XLS)
or die "Error opening .xls file: $!";
@@ -108,7 +107,7 @@ as ">Excel spreadsheet
% my $style = '';
% $style .= " rowspan=".$cell->{rowspan} if $cell->{rowspan} > 1;
% $style .= " colspan=".$cell->{colspan} if $cell->{colspan} > 1;
- <<%$td%><%$style%>><% $cell->{value} %><%$td%>>
+ <<%$td%><%$style%>><% $cell->{value} |h %><%$td%>>
% }
% }
@@ -122,10 +121,7 @@ die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
my ($agentnum,$sel_agent);
-if ( $cgi->param('agentnum') eq 'all' ) {
- $agentnum = 0;
-}
-elsif ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
+if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
$agentnum = $1;
$sel_agent = qsearchs('agent', { 'agentnum' => $agentnum } );
die "agentnum $agentnum not found!" unless $sel_agent;
@@ -143,9 +139,6 @@ $title .= $sel_part_referral->referral.' '
$title .= 'Customer Accounting Summary Report';
-my @custs = ();
-@custs = qsearch('cust_main', {} );
-
my @items = ('netsales', 'cashflow');
my @params = ( [], [] );
my $setuprecur = '';
@@ -168,11 +161,19 @@ my @custnames = ();
my $status = $cgi->param('status');
die "invalid status" unless $status =~ /^\w+|$/;
+my %search_hash;
+foreach (qw(agentnum refnum status)) {
+ if ( defined $cgi->param($_) ) {
+ $search_hash{$_} = $cgi->param($_);
+ }
+}
+$search_hash{'classnum'} = [ $cgi->param('cust_classnum') ]
+ if grep { $_ eq 'cust_classnum' } $cgi->param;
+
+my $query = FS::cust_main::Search->search(\%search_hash);
+my @custs = qsearch($query);
+
foreach my $cust_main ( @custs ) {
- # XXX should do this in the qsearch
- next unless ($status eq '' || $status eq $cust_main->status);
- next unless ($agentnum == 0 || $cust_main->agentnum eq $agentnum);
- next unless ($refnum == 0 || $cust_main->refnum eq $refnum);
push @custnames, $cust_main->name;