3 # #my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
4 # my ($curmon,$curyear) = (localtime(time))[4,5];
7 my $syear = $cgi->param('syear'); # || 1899+$curyear;
8 my $smonth = $cgi->param('smonth'); # || $curmon+1;
11 my $eyear = $cgi->param('eyear'); # || 1900+$curyear;
12 my $emonth = $cgi->param('emonth'); # || $curmon+1;
15 my( $agentnum, $agent ) = ('', '');
16 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
18 $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
19 die "agentnum $agentnum not found!" unless $agent;
21 my $agentname = $agent ? $agent->agent.' ' : '';
24 <%= include('/elements/header.html',
25 $agentname. 'Sales, Credits and Receipts Summary'
29 <IMG SRC="money_time-graph.cgi?<%= $cgi->query_string %>" WIDTH="976" HEIGHT="384">
32 <%= table('e8e8e8') %>
35 my @items = qw( invoiced netsales credits payments receipts );
36 if ( $cgi->param('12mo') == 1 ) {
37 @items = map $_.'_12mo', @items;
41 'invoiced' => 'Gross Sales',
42 'netsales' => 'Net Sales',
43 'credits' => 'Credits',
44 'payments' => 'Gross Receipts',
45 'receipts' => 'Net Receipts',
47 $label{$_.'_12mo'} = $label{$_}. " (previous 12 months)"
51 'invoiced' => '9999ff', #light blue
52 'netsales' => '0000cc', #blue
53 'credits' => 'cc0000', #red
54 'payments' => '99cc99', #light green
55 'receipts' => '00cc00', #green
57 $color{$_.'_12mo'} = $color{$_}
61 'invoiced' => "${p}search/cust_bill.html?agentnum=$agentnum;",
62 'credits' => "${p}search/cust_credit.html?agentnum=$agentnum;",
63 'payments' => "${p}search/cust_pay.cgi?magic=_date;agentnum=$agentnum;",
67 my $report = new FS::Report::Table::Monthly (
69 'start_month' => $smonth,
70 'start_year' => $syear,
71 'end_month' => $emonth,
73 'agentnum' => $agentnum,
75 my $data = $report->data;
77 my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
82 <% foreach my $column ( @{$data->{label}} ) {
83 #$column =~ s/^(\d+)\//$mon[$1-1]<BR>/e;
84 $column =~ s/^(\d+)\//$mon[$1-1]<BR>/;
86 <TH><%= $column %></TH>
91 <% foreach my $row (@items) { %>
92 <TR><TH><FONT COLOR="#<%= $color{$row} %>"><%= $label{$row} %></FONT></TH>
93 <% my $link = exists($link{$row})
94 ? qq(<A HREF="$link{$row})
96 my @speriod = @{$data->{speriod}};
97 my @eperiod = @{$data->{eperiod}};
100 <% foreach my $column ( @{$data->{$row}} ) { %>
101 <TD ALIGN="right" BGCOLOR="#ffffff">
102 <%= $link ? $link. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' %><FONT COLOR="#<%= $color{$row} %>">$<%= sprintf("%.2f", $column) %></FONT><%= $link ? '</A>' : '' %>
104 <% $total += $column; %>
106 <TD ALIGN="right" BGCOLOR="#f5f6be">
107 <%= $link ? $link. 'begin='. @{$data->{speriod}}[0]. ';end='. @{$data->{eperiod}}[-1]. '">' : '' %><FONT COLOR="#<%= $color{$row} %>">$<%= sprintf("%.2f", $total) %></FONT><%= $link ? '</A>' : '' %>
113 <%= include('/elements/footer.html') %>