add customer class to A/R report, fix "(none)" selection in other reports, RT#22540
[freeside.git] / httemplate / search / customer_accounting_summary.html
index 5ce2e3a..b48ff21 100644 (file)
@@ -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: $!";
 
   $r++;
   } #$row
   $workbook->close;
+
+  http_header('Content-Length' => length($output));
+  $m->print($output);
 </%perl>
-<% $output %>
-% } else { 
+% } else {
 <& /elements/header.html, $title &>
 % my $myself = $cgi->self_url;
 <P ALIGN="right" CLASS="noprint">
@@ -106,7 +107,7 @@ as <A HREF="<% "$myself;_type=xls" %>">Excel spreadsheet</A><BR>
 %     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%>>
 %   }
   </tr>
 % }
@@ -141,9 +142,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 = '';
@@ -166,6 +164,18 @@ 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);