1 <& elements/monthly.html,
2 'title' => $agentname. 'Customer Churn',
5 'graph_labels' => \@labels,
9 'agentnum' => $agentnum,
10 'sprintf' => ( $normalize ? '%0.1f%%' : '%u'),
11 'normalize' => ( $normalize ? 0 : undef ),
15 'no_graph' => [ 1, 0, 0, 0, 0 ], # don't graph 'active'
19 my $curuser = $FS::CurrentUser::CurrentUser;
21 unless $curuser->access_right('Customers: Customer churn report');
23 my( $agentnum, $agent ) = ('', '');
24 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
26 $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
28 die "agentnum required"; # UI prevents this
31 my $agentname = $agent ? $agent->agent.' ' : '';
33 my @base_items = qw(active_cust
40 active_cust => 'Active customers',
41 started_cust => 'New',
42 suspended_cust => 'Suspended',
43 resumed_cust => 'Resumed',
44 cancelled_cust => 'Cancelled',
48 active_cust => '000000', #black
49 started_cust => '00cc00', #green
50 suspended_cust => 'ff9900', #yellow
51 resumed_cust => '4444ff', #light blue for some reason
52 cancelled_cust => 'cc0000', #red
56 foreach my $status (qw(active started suspended resumed cancelled)) {
57 $base_links{$status.'_cust'} =
58 "${p}search/cust_main_churn.html?agentnum=$agentnum;status=$status;";
61 # indirection in case at some point we need to add breakdown options
62 my (@items, @labels, @colors, @links, @params);
64 @labels = @base_labels{@base_items};
65 @colors = @base_colors{@base_items};
66 @links = @base_links{@base_items};
68 my $normalize = $cgi->param('normalize');