fix phantom customer links
[freeside.git] / httemplate / graph / cust_pkg_cost.cgi
1 <% include('elements/monthly.html',
2                 'title'        => $agentname.
3                                   'Package Costs Report',
4                 'graph_type'   => 'Lines',
5                 'items'        => \@items,
6                 'labels'       => \%label,
7                 'graph_labels' => \%label,
8                 'colors'       => \%color,
9                 'links'        => \%link,
10                 'agentnum'     => $agentnum,
11                 'nototal'      => scalar($cgi->param('12mo')),
12              )
13 %>
14 <%init>
15
16 die "access denied"
17   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
18
19 #XXX or virtual
20 my( $agentnum, $agent ) = ('', '');
21 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
22   $agentnum = $1;
23   $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
24   die "agentnum $agentnum not found!" unless $agent;
25 }
26
27 my $agentname = $agent ? $agent->agent.' ' : '';
28
29 my @items = qw( cust_pkg_setup_cost cust_pkg_recur_cost );
30 if ( $cgi->param('12mo') == 1 ) {
31   @items = map $_.'_12mo', @items;
32 }
33
34 my %label = (
35   'cust_pkg_setup_cost' => 'Setup Costs',
36   'cust_pkg_recur_cost' => 'Recurring Costs',
37 );
38
39 $label{$_.'_12mo'} = $label{$_}. " (prev 12 months)"
40   foreach keys %label;
41
42 my %color = (
43   'cust_pkg_setup_cost' => '0000cc',
44   'cust_pkg_recur_cost' => '00cc00',
45 );
46 $color{$_.'_12mo'} = $color{$_}
47   foreach keys %color;
48
49 my %link = (
50   'cust_pkg_setup_cost' => { 'link' => "${p}search/cust_pkg.cgi?agentnum=$agentnum;",
51                              'fromparam' => 'setup_begin',
52                              'toparam'   => 'setup_end',
53                            },
54   'cust_pkg_recur_cost' => { 'link' => "${p}search/cust_pkg.cgi?agentnum=$agentnum;",
55                              'fromparam' => 'active_begin',
56                              'toparam'   => 'active_end',
57                            },
58 );
59 # XXX link 12mo?
60
61 </%init>