1 <% include("/elements/header.html","Advertising source Listing" ) %>
3 Where a customer heard about your service. Tracked for informational purposes.
6 <A HREF="<% $p %>edit/part_referral.html"><I>Add a new advertising source</I></A>
9 % my $today = timelocal(0, 0, 0, (localtime(time))[3..5] );
11 % tie %after, 'Tie::IxHash',
13 % 'Yesterday' => 86400, # 60sec * 60min * 24hrs
14 % 'Past week' => 518400, # 60sec * 60min * 24hrs * 6days
15 % 'Past 30 days' => 2505600, # 60sec * 60min * 24hrs * 29days
16 % 'Past 60 days' => 5097600, # 60sec * 60min * 24hrs * 59days
17 % 'Past 90 days' => 7689600, # 60sec * 60min * 24hrs * 89days
18 % 'Past 6 months' => 15724800, # 60sec * 60min * 24hrs * 182days
19 % 'Past year' => 31486000, # 60sec * 60min * 24hrs * 364days
23 % 'Today' => 86400, # 60sec * 60min * 24hrs
25 % 'Past week' => 86400, # 60sec * 60min * 24hrs
26 % 'Past 30 days' => 86400, # 60sec * 60min * 24hrs
27 % 'Past 60 days' => 86400, # 60sec * 60min * 24hrs
28 % 'Past 90 days' => 86400, # 60sec * 60min * 24hrs
29 % 'Past 6 months' => 86400, # 60sec * 60min * 24hrs
30 % 'Past year' => 86400, # 60sec * 60min * 24hrs
31 % 'Total' => 86400, # 60sec * 60min * 24hrs
34 % my $curuser = $FS::CurrentUser::CurrentUser;
36 % my $statement = "SELECT COUNT(*) FROM h_cust_main
37 % WHERE history_action = 'insert'
39 % AND history_date >= ?
40 % AND history_date < ?
41 % AND ". $curuser->agentnums_sql;
42 % my $sth = dbh->prepare($statement)
45 % my $show_agentnums = scalar($curuser->agentnums);
50 <% include('/elements/table-grid.html') %>
51 % my $bgcolor1 = '#eeeeee';
52 % my $bgcolor2 = '#ffffff';
58 <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2 ROWSPAN=2>Advertising source</TH>
59 % if ( $show_agentnums ) {
61 <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Agent</TH>
64 <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% scalar(keys %after) %>>Customers</TH>
66 % for my $period ( keys %after ) {
68 <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1><% $period %></FONT></TH>
73 %foreach my $part_referral ( FS::part_referral->all_part_referral(1) ) {
75 % if ( $bgcolor eq $bgcolor1 ) {
76 % $bgcolor = $bgcolor2;
78 % $bgcolor = $bgcolor1;
87 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
88 % if ( $part_referral->agentnum || $curuser->access_right('Edit global advertising sources') ) {
92 <A HREF="<% $p %>edit/part_referral.html?<% $part_referral->refnum %>">
95 <% $part_referral->refnum %><% $a ? '</A>' : '' %></TD>
96 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
99 <A HREF="<% $p %>edit/part_referral.html?<% $part_referral->refnum %>">
102 <% $part_referral->referral %><% $a ? '</A>' : '' %></TD>
103 % if ( $show_agentnums ) {
105 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $part_referral->agentnum ? $part_referral->agent->agent : '(global)' %></TD>
107 % for my $period ( keys %after ) {
108 % $sth->execute( $part_referral->refnum,
109 % $today-$after{$period},
110 % $today+$before{$period},
111 % ) or die $sth->errstr;
112 % my $number = $sth->fetchrow_arrayref->[0];
115 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right"><% $number %></TD>
121 % $statement =~ s/AND refnum = \?//;
122 % $sth = dbh->prepare($statement)
123 % or die dbh->errstr;
127 <TD BGCOLOR="#dddddd" ALIGN="center" COLSPAN=3><B>Total</B></TD>
128 % for my $period ( keys %after ) {
129 % $sth->execute( $today-$after{$period},
130 % $today+$before{$period},
131 % ) or die $sth->errstr;
132 % my $number = $sth->fetchrow_arrayref->[0];
135 <TD BGCOLOR="#dddddd" ALIGN="right"><B><% $number %><B></TD>