lost bits of reason
[freeside.git] / httemplate / graph / cust_pkg.cgi
1 <% include('elements/monthly.html',
2                 'title'         => $agentname. 'Package Churn',
3                 'items'         => \@items,
4                 'labels'        => \%label,
5                 'graph_labels'  => \%graph_label,
6                 'colors'        => \%color,
7                 'links'         => \%link,
8                 'agentnum'      => $agentnum,
9                 'sprintf'       => '%u',
10                 'disable_money' => 1,
11              )
12 %>
13 <%init>
14
15 #XXX use a different ACL for package churn?
16 die "access denied"
17   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
18
19 #false laziness w/money_time.cgi, cust_bill_pkg.cgi
20
21 #XXX or virtual
22 my( $agentnum, $agent ) = ('', '');
23 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
24   $agentnum = $1;
25   $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
26   die "agentnum $agentnum not found!" unless $agent;
27 }
28
29 my $agentname = $agent ? $agent->agent.' ' : '';
30
31 my @items = qw( setup_pkg susp_pkg cancel_pkg );
32
33 my %label = (
34   'setup_pkg'  => 'New orders',
35   'susp_pkg'   => 'Suspensions',
36 #  'unsusp' => 'Unsuspensions',
37   'cancel_pkg' => 'Cancellations',
38 );
39 my %graph_label = %label;
40
41 my %color = (
42   'setup_pkg'   => '00cc00', #green
43   'susp_pkg'    => 'ff9900', #yellow
44   #'unsusp'  => '', #light green?
45   'cancel_pkg'  => 'cc0000', #red ? 'ff0000'
46 );
47
48 my %link = (
49   'setup_pkg'  => { 'link' => "${p}search/cust_pkg.cgi?agentnum=$agentnum;",
50                     'fromparam' => 'setup_begin',
51                     'toparam'   => 'setup_end',
52                   },
53   'susp_pkg'   => { 'link' => "${p}search/cust_pkg.cgi?agentnum=$agentnum;",
54                     'fromparam' => 'susp_begin',
55                     'toparam'   => 'susp_end',
56                   },
57   'cancel_pkg' => { 'link' => "${p}search/cust_pkg.cgi?agentnum=$agentnum;",
58                     'fromparam' => 'cancel_begin',
59                     'toparam'   => 'cancel_end',
60                   },
61 );
62
63 </%init>