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>
10 my $today = timelocal(0, 0, 0, (localtime(time))[3..5] );
12 tie %after, 'Tie::IxHash',
14 'Yesterday' => 86400, # 60sec * 60min * 24hrs
15 'Past week' => 518400, # 60sec * 60min * 24hrs * 6days
16 'Past 30 days' => 2505600, # 60sec * 60min * 24hrs * 29days
17 'Past 60 days' => 5097600, # 60sec * 60min * 24hrs * 59days
18 'Past 90 days' => 7689600, # 60sec * 60min * 24hrs * 89days
19 'Past 6 months' => 15724800, # 60sec * 60min * 24hrs * 182days
20 'Past year' => 31486000, # 60sec * 60min * 24hrs * 364days
24 'Today' => 86400, # 60sec * 60min * 24hrs
26 'Past week' => 86400, # 60sec * 60min * 24hrs
27 'Past 30 days' => 86400, # 60sec * 60min * 24hrs
28 'Past 60 days' => 86400, # 60sec * 60min * 24hrs
29 'Past 90 days' => 86400, # 60sec * 60min * 24hrs
30 'Past 6 months' => 86400, # 60sec * 60min * 24hrs
31 'Past year' => 86400, # 60sec * 60min * 24hrs
32 'Total' => 86400, # 60sec * 60min * 24hrs
35 my $curuser = $FS::CurrentUser::CurrentUser;
37 my $statement = "SELECT COUNT(*) FROM h_cust_main
38 WHERE history_action = 'insert'
42 AND ". $curuser->agentnums_sql;
43 my $sth = dbh->prepare($statement)
46 my $show_agentnums = scalar($curuser->agentnums);
50 <%= include('/elements/table-grid.html') %>
52 <% my $bgcolor1 = '#eeeeee';
53 my $bgcolor2 = '#ffffff';
58 <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2 ROWSPAN=2>Advertising source</TH>
59 <% if ( $show_agentnums ) { %>
60 <TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Agent</TH>
62 <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<%= scalar(keys %after) %>>Customers</TH>
64 <% for my $period ( keys %after ) { %>
65 <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1><%= $period %></FONT></TH>
70 foreach my $part_referral ( FS::part_referral->all_part_referral(1) ) {
72 if ( $bgcolor eq $bgcolor1 ) {
83 <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
84 <% if ( $part_referral->agentnum || $curuser->access_right('Edit global advertising sources') ) {
87 <A HREF="<%= $p %>edit/part_referral.html?<%= $part_referral->refnum %>">
89 <%= $part_referral->refnum %><%= $a ? '</A>' : '' %></TD>
90 <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>">
92 <A HREF="<%= $p %>edit/part_referral.html?<%= $part_referral->refnum %>">
94 <%= $part_referral->referral %><%= $a ? '</A>' : '' %></TD>
96 <% if ( $show_agentnums ) { %>
97 <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>"><%= $part_referral->agentnum ? $part_referral->agent->agent : '(global)' %></TD>
100 <% for my $period ( keys %after ) {
101 $sth->execute( $part_referral->refnum,
102 $today-$after{$period},
103 $today+$before{$period},
104 ) or die $sth->errstr;
105 my $number = $sth->fetchrow_arrayref->[0];
107 <TD CLASS="grid" BGCOLOR="<%= $bgcolor %>" ALIGN="right"><%= $number %></TD>
113 $statement =~ s/AND refnum = \?//;
114 $sth = dbh->prepare($statement)
118 <TD BGCOLOR="#dddddd" ALIGN="center" COLSPAN=3><B>Total</B></TD>
119 <% for my $period ( keys %after ) {
120 $sth->execute( $today-$after{$period},
121 $today+$before{$period},
122 ) or die $sth->errstr;
123 my $number = $sth->fetchrow_arrayref->[0];
125 <TD BGCOLOR="#dddddd" ALIGN="right"><B><%= $number %><B></TD>