X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fgraph%2Fmoney_time.cgi;h=874f58b095de8b52677dfbf6358af48b02a30a78;hb=02ffd747f8cbc05815c0d96f437c507cfac04ba6;hp=de8f6ee0cd5ab50feda64dd5d218c4d9f1b01610;hpb=ef7bb336cc67f127fb1d77532ad3da1369c0ae36;p=freeside.git diff --git a/httemplate/graph/money_time.cgi b/httemplate/graph/money_time.cgi index de8f6ee0c..874f58b09 100644 --- a/httemplate/graph/money_time.cgi +++ b/httemplate/graph/money_time.cgi @@ -12,16 +12,93 @@ my $smonth = $cgi->param('smonth') || $curmon+1; my $eyear = $cgi->param('eyear') || 1900+$curyear; my $emonth = $cgi->param('emonth') || $curmon+1; +#XXX or virtual +my( $agentnum, $agent ) = ('', ''); +if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { + $agentnum = $1; + $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); + die "agentnum $agentnum not found!" unless $agent; +} +my $agentname = $agent ? $agent->agent.' ' : ''; +warn $agentname; + +%> + +<%= include('/elements/header.html', + $agentname. 'Sales, Credits and Receipts Summary' + ) %> - - - Graphing monetary values over time - - - + +
+ +<%= table('e8e8e8') %> +<% + +my @items = qw( invoiced netsales credits payments receipts ); +my %label = ( + 'invoiced' => 'Gross Sales', + 'netsales' => 'Net Sales', + 'credits' => 'Credits', + 'payments' => 'Gross Receipts', + 'receipts' => 'Net Receipts', +); +my %color = ( + 'invoiced' => '9999ff', #light blue + 'netsales' => '0000cc', #blue + 'credits' => 'cc0000', #red + 'payments' => '99cc99', #light green + 'receipts' => '00cc00', #green +); +my %link = ( + 'invoiced' => "${p}search/cust_bill.html?agentnum=$agentnum;", + 'credits' => "${p}search/cust_credit.html?agentnum=$agentnum;", + 'payments' => "${p}search/cust_pay.cgi?magic=_date;agentnum=$agentnum;", +); + +my $report = new FS::Report::Table::Monthly ( + 'items' => \@items, + 'start_month' => $smonth, + 'start_year' => $syear, + 'end_month' => $emonth, + 'end_year' => $eyear, + 'agentnum' => $agentnum, +); +my $data = $report->data; + +my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); + +%> + + +<% foreach my $column ( @{$data->{label}} ) { + #$column =~ s/^(\d+)\//$mon[$1-1]
/e; + $column =~ s/^(\d+)\//$mon[$1-1]
/; + %> + <%= $column %> +<% } %> + + +<% foreach my $row (@items) { %> + <%= $label{$row} %> + <% my $link = exists($link{$row}) + ? qq( + <%= $link ? $link. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' %>$<%= sprintf("%.2f", $column) %><%= $link ? '' : '' %> + + <% } %> + +<% } %> + +
+ From <% } %> - +for agent: <%= include('/elements/select-agent.html', $agentnum) %> + +