1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
<& elements/monthly.html,
'title' => $title,
'items' => \@items,
'labels' => \@labels,
'graph_labels' => \@labels,
'params' => \@params,
'colors' => \@colors,
'links' => \@links,
'agentnum' => $agentnum,
'sprintf' => '%u',
'disable_money' => 1,
'bottom_total' => (scalar @items > 1 && !$indirect ? 1 : 0),
'bottom_link' => $bottom_link,
'link_fromparam' => 'signupdate_begin',
'link_toparam' => 'signupdate_end',
'chart_options' => { precision => 0 },
&>
<%init>
#XXX use a different ACL for package churn?
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
#false laziness w/money_time.cgi, cust_bill_pkg.cgi
my $title = 'Customer Signup',
#XXX or virtual
my( $agentnum, $agent ) = ('', '');
if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
$agentnum = $1;
$agent = qsearchs('agent', { 'agentnum' => $agentnum } );
die "agentnum $agentnum not found!" unless $agent;
}
my $agentname = $agent ? $agent->agent.' ' : '';
$title = "$agentname $title" if $agentname;
my $link = $p.'search/cust_main.html?';
$link .= "agentnum=$agentnum;" if $agentnum;
my $bottom_link = $link;
my @referral;
my $all_referral = 0;
if ( $cgi->param('refnum') eq 'all' ) {
@referral = ('');
$all_referral = 1;
}
elsif ( $cgi->param('refnum') =~ /^(\d*)$/ ) {
if ( $1 ) {
@referral = ( qsearchs('part_referral', { 'refnum' => $1 } ) );
die "refnum $1 not found!" unless @referral;
$title .= ' - '.$referral[0]->referral;
$bottom_link .= ";refnum=$1";
}
else { #refnum = ''
@referral = qsearch('part_referral', {});
$title .= ' by Advertising Source';
}
}
my $indirect = ($cgi->param('indirect') eq 'Y' ? 1 : 0);
my (@items, @labels, @colors, @params, @links);
my $hue = 0;
my $hue_increment = 75;
my @signup_colors;
foreach my $referral (@referral) {
my %params = ('refnum' => $referral->refnum) unless $all_referral;
push @items, 'signups';
push @labels, ( $all_referral ? 'Signups' : $referral->referral );
push @params, [ %params ];
push @links, $link . ($all_referral ? '' : "refnum=".$referral->refnum.';');
# rotate hue for each referral type
@signup_colors = Color::Scheme->new->from_hue($hue)->colors;
$hue += $hue_increment;
push @colors, $signup_colors[0];
if ( $indirect ) {
push @items, 'signups';
push @labels, $all_referral ?
'Referrals' :
$referral->referral . ' referrals';
push @params, [ %params, 'indirect' => 1 ];
push @links, '';
push @colors, $signup_colors[1];
}
}
</%init>
|