From: ivan Date: Fri, 24 Oct 2003 00:39:50 +0000 (+0000) Subject: referral listing now shows customer signups today and past X-Git-Tag: NET_WHOIS_RAW_0_31~312 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=368bc5c098a47c32db7c575f912683ebe8662f59;hp=952ce66262265a57634240373c18ddb6d8dd57bd referral listing now shows customer signups today and past week/30/60/90/6months/year/total --- diff --git a/httemplate/browse/part_referral.cgi b/httemplate/browse/part_referral.cgi index 084c21bd0..1a57a5b24 100755 --- a/httemplate/browse/part_referral.cgi +++ b/httemplate/browse/part_referral.cgi @@ -8,31 +8,56 @@ Where a customer heard about your service. Tracked for informational purposes. Add a new advertising source

+<% + 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 + 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 < -END - -%>