X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_referral.cgi;h=37eb329911c96eabf7c3a9ad9aef29a74e5f1656;hb=3f0c721ee27ead3504df80addd947057e4fc4c14;hp=ed3b7a0e48e446d16ec3b1fc0f9619583fff846d;hpb=6ef34dda51afba96d8dc6c4dd72427c3d4003945;p=freeside.git
diff --git a/httemplate/browse/part_referral.cgi b/httemplate/browse/part_referral.cgi
index ed3b7a0e4..37eb32991 100755
--- a/httemplate/browse/part_referral.cgi
+++ b/httemplate/browse/part_referral.cgi
@@ -1,53 +1,63 @@
-<%
-#
-
-use strict;
-use vars qw( $cgi $p $part_referral );
-use CGI;
-use CGI::Carp qw(fatalsToBrowser);
-use FS::UID qw(cgisuidsetup);
-use FS::Record qw(qsearch);
-use FS::CGI qw(header menubar popurl table);
-use FS::part_referral;
-
-$cgi = new CGI;
-
-&cgisuidsetup($cgi);
-
-$p = popurl(2);
-
-print $cgi->header( '-expires' => 'now' ), header("Referral Listing", menubar(
+
+<%= header("Advertising source Listing", menubar(
'Main Menu' => $p,
# 'Add new referral' => "../edit/part_referral.cgi",
-)), "Where a customer heard about your service. Tracked for informational purposes.
", &table(), <
- Referral |
-
-END
+)) %>
+Where a customer heard about your service. Tracked for informational purposes.
+
+Add a new advertising source
+
-foreach $part_referral ( sort {
+<%
+ my $today = timelocal(0, 0, 0, (localtime(time))[3..5] );
+ my %past;
+ tie %past, 'Tie::IxHash',
+ 'Today' => 0,
+ 'Past week' => 518400, # 60sec * 60min * 24hrs * 6days
+ 'Past 30 days' => 2505600, # 60sec * 60min * 24hrs * 29days
+ 'Past 60 days' => 5097600, # 60sec * 60min * 24hrs * 29days
+ 'Past 90 days' => 7689600, # 60sec * 60min * 24hrs * 29days
+ 'Past 6 months' => 15724800, # 60sec * 60min * 24hrs * 182days
+ 'Past year' => 31486000, # 60sec * 60min * 24hrs * 364days
+ 'Total' => $today,
+ ;
+
+ my $sth = dbh->prepare("SELECT COUNT(*) FROM h_cust_main
+ WHERE refnum = ?
+ AND history_date > ? ")
+ or die dbh->errstr;
+%>
+
+<%= table() %>
+
+ Advertising source |
+ >Customers |
+
+<% for my $period ( keys %past ) { %>
+ <%= $period %> |
+<% } %>
+
+
+<%
+foreach my $part_referral ( sort {
$a->getfield('refnum') <=> $b->getfield('refnum')
} qsearch('part_referral',{}) ) {
- my($hashref)=$part_referral->hashref;
- print <
- $hashref->{refnum} |
+ <%= $part_referral->refnum %>
- $hashref->{referral} |
+ <%= $part_referral->referral %>
+ <% for my $period ( values %past ) {
+ $sth->execute($part_referral->refnum, $today-$period)
+ or die $sth->errstr;
+ my $number = $sth->fetchrow_arrayref->[0];
+ %>
+ <%= $number %> |
+ <% } %>
-END
-
-}
+<% } %>
-print <
- Add new referral |
-
-