adding export to read mailbox status information, RT#15987
[freeside.git] / httemplate / search / customer_accounting_summary.html
1 <% include('/graph/elements/monthly.html',
2    #Dumper(
3                 'title'        => $title,
4                 'graph_type'   => 'none',
5                 'items'        => \@items,
6                 'params'       => \@params,
7                 'labels'       => \@labels,
8                 'graph_labels' => \@labels,
9                 'remove_empty' => 1,
10                 'bottom_total' => 1,
11                 'agentnum'     => $agentnum,
12                 'doublemonths' => \@doublemonths,
13                 'nototal'       => 1,
14              )
15 %>
16 <%init>
17
18 die "access denied"
19   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
20
21 my @doublemonths = ( 'Billed', 'Paid' );
22
23 my ($agentnum,$sel_agent);
24 if ( $cgi->param('agentnum') eq 'all' ) {
25   $agentnum = 0;
26 }
27 elsif ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
28   $agentnum = $1;
29   $sel_agent = qsearchs('agent', { 'agentnum' => $agentnum } );
30   die "agentnum $agentnum not found!" unless $sel_agent;
31 }
32 my $title = $sel_agent ? $sel_agent->agent.' ' : '';
33 $title .= 'Customer Accounting Summary Report';
34
35 my @custs = ();
36 @custs = qsearch('cust_main', {} ); 
37
38 my @items  = ();
39 my @params = ();
40 my @labels = ();
41
42 my $status = $cgi->param('status');
43 die "invalid status" unless $status =~ /^\w+|$/;
44
45 foreach my $cust_main ( @custs ) {
46   next unless ($status eq '' || $status eq $cust_main->status); 
47   next unless ($agentnum == 0 || $cust_main->agentnum eq $agentnum);
48
49   push @items, 'netsales', 'cashflow';
50
51   push @labels, $cust_main->name;
52
53   push @params, [ ('custnum' => $cust_main->custnum),
54                 ],
55                 [ ('custnum' => $cust_main->custnum),
56                 ];
57 }
58
59 </%init>