This commit was generated by cvs2svn to compensate for changes in r6252,
[freeside.git] / httemplate / graph / money_time.cgi
1 <% include('elements/monthly.html',
2                 'title'        => $agentname.
3                                   'Sales, Credits and Receipts Summary',
4                 'items'        => \@items,
5                 'labels'       => \%label,
6                 'graph_labels' => \%graph_label,
7                 'colors'       => \%color,
8                 'links'        => \%link,
9                 'agentnum'     => $agentnum,
10                 'nototal'      => scalar($cgi->param('12mo')),
11              )
12 %>
13 <%init>
14
15 die "access denied"
16   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
17
18 #XXX or virtual
19 my( $agentnum, $agent ) = ('', '');
20 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
21   $agentnum = $1;
22   $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
23   die "agentnum $agentnum not found!" unless $agent;
24 }
25
26 my $agentname = $agent ? $agent->agent.' ' : '';
27
28 my @items = qw( invoiced netsales credits payments receipts );
29 if ( $cgi->param('12mo') == 1 ) {
30   @items = map $_.'_12mo', @items;
31 }
32
33 my %label = (
34   'invoiced' => 'Gross Sales',
35   'netsales' => 'Net Sales',
36   'credits'  => 'Credits',
37   'payments' => 'Gross Receipts',
38   'receipts' => 'Net Receipts',
39 );
40
41 my %graph_suffix = (
42  'invoiced' => ' (invoiced)', 
43  'netsales' => ' (invoiced - applied credits)',
44  'credits'  => '',
45  'payments' => ' (payments)',
46  'receipts' => '/Cashflow (payments - refunds)',
47 );
48 my %graph_label = map { $_ => $label{$_}.$graph_suffix{$_} } keys %label;
49
50 $label{$_.'_12mo'} = $label{$_}. " (previous 12 months)"
51   foreach keys %label;
52
53 $graph_label{$_.'_12mo'} = $graph_label{$_}. " (previous 12 months)"
54   foreach keys %graph_label;
55
56 my %color = (
57   'invoiced' => '9999ff', #light blue
58   'netsales' => '0000cc', #blue
59   'credits'  => 'cc0000', #red
60   'payments' => '99cc99', #light green
61   'receipts' => '00cc00', #green
62 );
63 $color{$_.'_12mo'} = $color{$_}
64   foreach keys %color;
65
66 my %link = (
67   'invoiced' => "${p}search/cust_bill.html?agentnum=$agentnum;",
68   'netsales' => "${p}search/cust_bill.html?agentnum=$agentnum;net=1;",
69   'credits'  => "${p}search/cust_credit.html?agentnum=$agentnum;",
70   'payments' => "${p}search/cust_pay.cgi?magic=_date;agentnum=$agentnum;",
71 );
72 # XXX link 12mo?
73
74 </%init>