diff options
author | Mark Wells <mark@freeside.biz> | 2014-11-12 17:18:18 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-11-12 17:18:18 -0800 |
commit | 0a5b2467d57cf94a2786bb76a106b14596e30916 (patch) | |
tree | 87f000fa846a8360082d661d7d23fc6fae72bc34 /httemplate/graph | |
parent | 3a41a6e8016f62a1f46830c4fce3fe583b275229 (diff) |
customer churn report, #30132
Diffstat (limited to 'httemplate/graph')
-rw-r--r-- | httemplate/graph/cust_churn.html | 70 | ||||
-rw-r--r-- | httemplate/graph/report_cust_churn.html | 32 |
2 files changed, 102 insertions, 0 deletions
diff --git a/httemplate/graph/cust_churn.html b/httemplate/graph/cust_churn.html new file mode 100644 index 000000000..07193c776 --- /dev/null +++ b/httemplate/graph/cust_churn.html @@ -0,0 +1,70 @@ +<& elements/monthly.html, + 'title' => $agentname. 'Customer Churn', + 'items' => \@items, + 'labels' => \@labels, + 'graph_labels' => \@labels, + 'colors' => \@colors, + 'links' => \@links, + #'params' => \@params, + 'agentnum' => $agentnum, + 'sprintf' => ( $normalize ? '%0.1f%%' : '%u'), + 'normalize' => ( $normalize ? 0 : undef ), + 'disable_money' => 1, + 'remove_empty' => 0, + 'nototal' => 1, + 'no_graph' => [ 1, 0, 0, 0, 0 ], # don't graph 'active' +&> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die "access denied" + unless $curuser->access_right('List customers'); + +my( $agentnum, $agent ) = ('', ''); +if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { + $agentnum = $1; + $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); +} else { + die "agentnum required"; # UI prevents this +} + +my $agentname = $agent ? $agent->agent.' ' : ''; + +my @base_items = qw(active_cust + started_cust + suspended_cust + resumed_cust + cancelled_cust ); + +my %base_labels = ( + active_cust => 'Active customers', + started_cust => 'New', + suspended_cust => 'Suspended', + resumed_cust => 'Resumed', + cancelled_cust => 'Cancelled', +); + +my %base_colors = ( + active_cust => '000000', #black + started_cust => '00cc00', #green + suspended_cust => 'ff9900', #yellow + resumed_cust => '4444ff', #light blue for some reason + cancelled_cust => 'cc0000', #red +); + +my %base_links; +foreach my $status (qw(active started suspended resumed cancelled)) { + $base_links{$status.'_cust'} = + "${p}search/cust_main_churn.html?agentnum=$agentnum;status=$status;"; +} + +# indirection in case at some point we need to add breakdown options +my (@items, @labels, @colors, @links, @params); +@items = @base_items; +@labels = @base_labels{@base_items}; +@colors = @base_colors{@base_items}; +@links = @base_links{@base_items}; + +my $normalize = $cgi->param('normalize'); + +</%init> diff --git a/httemplate/graph/report_cust_churn.html b/httemplate/graph/report_cust_churn.html new file mode 100644 index 000000000..3f942777f --- /dev/null +++ b/httemplate/graph/report_cust_churn.html @@ -0,0 +1,32 @@ +<% include('/elements/header.html', 'Customer Churn Summary' ) %> + +<FORM ACTION="cust_churn.html" METHOD="GET"> + +<TABLE BGCOLOR="#cccccc" CELLSPACING=0> + +<& /elements/tr-select-from_to.html &> + +<& /elements/tr-select-agent.html, + 'curr_value' => scalar($cgi->param('agentnum')), + 'label' => 'For agent: ', + 'disable_empty' => 1, +&> + +<& /elements/tr-checkbox.html, + 'field' => 'normalize', + 'value' => 1, + 'label' => 'Show percentages' +&> + +</TABLE> + +<BR><INPUT TYPE="submit" VALUE="Display"> +</FORM> + +<% include('/elements/footer.html') %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('List customers'); + +</%init> |