enable CardFortress in test database, #71513
[freeside.git] / httemplate / graph / money_time_daily.cgi
1 <% include('elements/monthly.html', #well, not really, daily flag below
2                 'title'        => $agentname.
3                                   'Daily 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                 'cust_classnum'=> \@classnums,
11                 'daily'        => 1,
12                 'start_day'    => $smday,
13                 'start_month'  => $smon+1,
14                 'start_year'   => $syear,
15                 'end_day'      => $emday,
16                 'end_month'    => $emon+1,
17                 'end_year'     => $eyear,
18              )
19 %>
20 <%init>
21
22 die "access denied"
23   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
24
25 #XXX or virtual
26 my( $agentnum, $agent ) = ('', '');
27 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
28   $agentnum = $1;
29   $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
30   die "agentnum $agentnum not found!" unless $agent;
31 }
32
33 my $agentname = $agent ? $agent->agent.' ' : '';
34
35 my @classnums;
36 if ( $cgi->param('cust_classnum') ) {
37   @classnums = grep /^\d+$/, $cgi->param('cust_classnum');
38 }
39
40 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
41 my ($ssec,$smin,$shour,$smday,$smon,$syear,$swday,$syday,$sisdst) 
42     = localtime($beginning);
43 my ($esec,$emin,$ehour,$emday,$emon,$eyear,$ewday,$eyday,$eisdst) 
44     = localtime($ending);
45
46 my @items = ($cgi->param('exclude_discount') ? 'invoiced' : 'gross');
47 push @items,
48             qw( discounted netsales
49                 credits  netcredits
50                 payments receipts
51                 refunds  netrefunds
52                 cashflow netcashflow
53               );
54
55 my %label = (
56   'gross'       => 'Gross Sales',
57   'invoiced'    => 'Invoiced Sales',
58   'netsales'    =>   'Net Sales',
59   'discounted'  => 'Discounts',
60   'credits'     => 'Gross Credits',
61   'netcredits'  =>   'Net Credits',
62   'payments'    => 'Gross Receipts',
63   'receipts'    =>   'Net Receipts',
64   'refunds'     => 'Gross Refunds',
65   'netrefunds'  =>   'Net Refunds',
66   'cashflow'    => 'Gross Cashflow',
67   'netcashflow' =>   'Net Cashflow',
68 );
69
70 my %graph_suffix = (
71  'gross'       => ' (invoiced + discounts)',
72  'invoiced'    => '',
73  'netsales'    => ' (invoiced - applied credits)',
74  'discounted'  => '',
75  'credits'     => ' (credited)',
76  'netcredits'  => ' (applied credits)',
77  'payments'    => ' (payments)',
78  'receipts'    => ' (applied payments)',
79  'refunds'     => ' (refunds)',
80  'netrefunds'  => ' (applied refunds)',
81  'cashflow'    => ' (payments - refunds)',
82  'netcashflow' => ' (applied payments - applied refunds)',
83 );
84 my %graph_label = map { $_ => $label{$_}.$graph_suffix{$_} } keys %label;
85
86 my %color = (
87   'gross'       => '9999ff', #light blue
88   'invoiced'    => '9999ff', #light blue
89   'netsales'    => '0000cc', #blue
90   'credits'     => 'ff9999', #light red
91   'netcredits'  => 'cc0000', #red
92   'payments'    => '99cc99', #light green
93   'receipts'    => '00cc00', #green
94   'refunds'     => 'ffcc99', #light orange
95   'netrefunds'  => 'ff9900', #orange
96   'cashflow'    => '99cc33', #light olive
97   'netcashflow' => '339900', #olive
98   'discounted'  => 'cc33cc', #purple-ish?
99 );
100
101 my %link = (
102   'gross'      => "${p}search/cust_bill.html?agentnum=$agentnum;",
103   'invoiced'   => "${p}search/cust_bill.html?agentnum=$agentnum;invoiced=1;",
104   'netsales'   => "${p}search/cust_bill.html?agentnum=$agentnum;net=1;",
105   'credits'    => "${p}search/cust_credit.html?agentnum=$agentnum;",
106   'netcredits' => "${p}search/cust_credit_bill.html?agentnum=$agentnum;",
107   'payments'   => "${p}search/cust_pay.html?magic=_date;agentnum=$agentnum;",
108   'receipts'   => "${p}search/cust_bill_pay.html?agentnum=$agentnum;",
109   'refunds'    => "${p}search/cust_refund.html?magic=_date;agentnum=$agentnum;",
110   'netrefunds' => "${p}search/cust_credit_refund.html?agentnum=$agentnum;",
111   'discounted' => "${p}search/cust_bill_pkg_discount.html?agentnum=$agentnum;",
112 );
113
114 </%init>