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>
83 <% foreach my $row (@items) { %>
84 <TR><TH><FONT COLOR="#<%= $color{$row} %>"><%= $label{$row} %></FONT></TH>
85 <% my $link = exists($link{$row})
86 ? qq(<A HREF="$link{$row})
88 my @speriod = @{$data->{speriod}};
89 my @eperiod = @{$data->{eperiod}};
92 <% foreach my $column ( @{$data->{$row}} ) { %>
93 <TD ALIGN="right" BGCOLOR="#ffffff">
94 <%= $link ? $link. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' %><FONT COLOR="#<%= $color{$row} %>">$<%= sprintf("%.2f", $column) %></FONT><%= $link ? '</A>' : '' %>
96 <% $total += $column; %>
98 <TD><%= sprintf("%.2f", $total) %>
106 <INPUT TYPE="checkbox" NAME="ar">
107 Accounts receivable (invoices - applied credits)<BR>
108 <INPUT TYPE="checkbox" NAME="charged">
110 <INPUT TYPE="checkbox" NAME="defer">
111 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>
112 <INPUT TYPE="checkbox" NAME="cash">
113 Cashflow (payments - refunds)<BR>
116 From <SELECT NAME="smonth">
117 <% foreach my $mon ( 1..12 ) { %>
118 <OPTION VALUE="<%= $mon %>"<%= $mon == $smonth ? ' SELECTED' : '' %>><%= $mon[$mon-1] %>
121 <SELECT NAME="syear">
122 <% foreach my $y ( 1999 .. 2010 ) { %>
123 <OPTION VALUE="<%= $y %>"<%= $y == $syear ? ' SELECTED' : '' %>><%= $y %>
126 to <SELECT NAME="emonth">
127 <% foreach my $mon ( 1..12 ) { %>
128 <OPTION VALUE="<%= $mon %>"<%= $mon == $emonth ? ' SELECTED' : '' %>><%= $mon[$mon-1] %>
131 <SELECT NAME="eyear">
132 <% foreach my $y ( 1999 .. 2010 ) { %>
133 <OPTION VALUE="<%= $y %>"<%= $y == $eyear ? ' SELECTED' : '' %>><%= $y %>
137 for agent: <%= include('/elements/select-agent.html', $agentnum) %>
139 <INPUT TYPE="submit" VALUE="Redisplay">