4 #my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
5 my ($curmon,$curyear) = (localtime(time))[4,5];
8 my $syear = $cgi->param('syear') || 1899+$curyear;
9 my $smonth = $cgi->param('smonth') || $curmon+1;
12 my $eyear = $cgi->param('eyear') || 1900+$curyear;
13 my $emonth = $cgi->param('emonth') || $curmon+1;
16 my( $agentnum, $agent ) = ('', '');
17 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
19 $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
20 die "agentnum $agentnum not found!" unless $agent;
22 my $agentname = $agent ? $agent->agent.' ' : '';
27 <%= include('/elements/header.html',
28 $agentname. 'Sales, Credits and Receipts Summary'
32 <IMG SRC="money_time-graph.cgi?<%= $cgi->query_string %>" WIDTH="976" HEIGHT="384">
35 <%= table('e8e8e8') %>
38 my @items = qw( invoiced netsales credits payments receipts );
40 'invoiced' => 'Gross Sales',
41 'netsales' => 'Net Sales',
42 'credits' => 'Credits',
43 'payments' => 'Gross Receipts',
44 'receipts' => 'Net Receipts',
47 'invoiced' => '9999ff', #light blue
48 'netsales' => '0000cc', #blue
49 'credits' => 'cc0000', #red
50 'payments' => '99cc99', #light green
51 'receipts' => '00cc00', #green
54 'invoiced' => "${p}search/cust_bill.html?agentnum=$agentnum;",
55 'credits' => "${p}search/cust_credit.html?agentnum=$agentnum;",
56 'payments' => "${p}search/cust_pay.cgi?magic=_date;agentnum=$agentnum;",
59 my $report = new FS::Report::Table::Monthly (
61 'start_month' => $smonth,
62 'start_year' => $syear,
63 'end_month' => $emonth,
65 'agentnum' => $agentnum,
67 my $data = $report->data;
69 my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
74 <% foreach my $column ( @{$data->{label}} ) {
75 #$column =~ s/^(\d+)\//$mon[$1-1]<BR>/e;
76 $column =~ s/^(\d+)\//$mon[$1-1]<BR>/;
78 <TH><%= $column %></TH>
82 <% foreach my $row (@items) { %>
83 <TR><TH><FONT COLOR="#<%= $color{$row} %>"><%= $label{$row} %></FONT></TH>
84 <% my $link = exists($link{$row})
85 ? qq(<A HREF="$link{$row})
87 my @speriod = @{$data->{speriod}};
88 my @eperiod = @{$data->{eperiod}};
90 <% foreach my $column ( @{$data->{$row}} ) { %>
91 <TD ALIGN="right" BGCOLOR="#ffffff">
92 <%= $link ? $link. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' %><FONT COLOR="#<%= $color{$row} %>">$<%= sprintf("%.2f", $column) %></FONT><%= $link ? '</A>' : '' %>
102 <INPUT TYPE="checkbox" NAME="ar">
103 Accounts receivable (invoices - applied credits)<BR>
104 <INPUT TYPE="checkbox" NAME="charged">
106 <INPUT TYPE="checkbox" NAME="defer">
107 Accounts receivable, with deferred revenue (invoices - applied credits, with charges for annual/semi-annual/quarterly/etc. services deferred over applicable time period) (there has got to be a shorter description for this)<BR>
108 <INPUT TYPE="checkbox" NAME="cash">
109 Cashflow (payments - refunds)<BR>
112 From <SELECT NAME="smonth">
113 <% foreach my $mon ( 1..12 ) { %>
114 <OPTION VALUE="<%= $mon %>"<%= $mon == $smonth ? ' SELECTED' : '' %>><%= $mon[$mon-1] %>
117 <SELECT NAME="syear">
118 <% foreach my $y ( 1999 .. 2010 ) { %>
119 <OPTION VALUE="<%= $y %>"<%= $y == $syear ? ' SELECTED' : '' %>><%= $y %>
122 to <SELECT NAME="emonth">
123 <% foreach my $mon ( 1..12 ) { %>
124 <OPTION VALUE="<%= $mon %>"<%= $mon == $emonth ? ' SELECTED' : '' %>><%= $mon[$mon-1] %>
127 <SELECT NAME="eyear">
128 <% foreach my $y ( 1999 .. 2010 ) { %>
129 <OPTION VALUE="<%= $y %>"<%= $y == $eyear ? ' SELECTED' : '' %>><%= $y %>
133 for agent: <%= include('/elements/select-agent.html', $agentnum) %>
135 <INPUT TYPE="submit" VALUE="Redisplay">