-<% include("/elements/header.html","Advertising source Listing" ) %>
+<& /elements/header.html, "Advertising source Listing" &>
Where a customer heard about your service. Tracked for informational purposes.
<BR><BR>
<A HREF="<% $p %>edit/part_referral.html"><I>Add a new advertising source</I></A>
<BR><BR>
-<% include('/elements/table-grid.html') %>
+<% $cgi->param('showdisabled')
+ ? do { $cgi->param('showdisabled', 0);
+ '( <a href="'. $cgi->self_url. '">hide disabled advertising sources</a> )'; }
+ : do { $cgi->param('showdisabled', 1);
+ '( <a href="'. $cgi->self_url. '">show disabled advertising sources</a> )'; }
+%>
+
+% ###
+% # Header
+% ###
+
+<& /elements/table-grid.html &>
% my $bgcolor1 = '#eeeeee';
% my $bgcolor2 = '#ffffff';
% my $bgcolor = '';
<TR>
<TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2 ROWSPAN=2>Advertising source</TH>
-% if ( $show_agentnums ) {
+% if ( ! $cgi->param('showdisabled') ) {
+ <TH CLASS="grid" BGCOLOR="#cccccc" ALIGN="center" ROWSPAN=2></TH>
+% }
+
+% if ( $show_agentnums ) {
<TH CLASS="grid" BGCOLOR="#cccccc" ROWSPAN=2>Agent</TH>
% }
- <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% scalar(keys %after) %>>Customers and Packages</TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% scalar(keys %after) %>>Prospects, Customers and Packages</TH>
</TR>
% for my $period ( keys %after ) {
</TR>
-%foreach my $part_referral ( FS::part_referral->all_part_referral(1) ) {
+% ###
+% # Rows
+% ###
+
+%foreach my $part_referral ( FS::part_referral->all_part_referral(1,!scalar($cgi->param('showdisabled'))) ) {
%
% if ( $bgcolor eq $bgcolor1 ) {
% $bgcolor = $bgcolor2;
% }
<% $part_referral->referral %><% $a ? '</A>' : '' %></TD>
+
+% if ( ! $cgi->param('showdisabled') ) {
+ <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="center">
+ <% $part_referral->disabled
+ ? '<FONT COLOR="#FF0000"><B>DISABLED</B></FONT>'
+ : '<FONT COLOR="#00CC00"><B>Active</B></FONT>'
+ %>
+ </TD>
+% }
+
% if ( $show_agentnums ) {
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $part_referral->agentnum ? $part_referral->agent->agent : '(global)' %></TD>
% $today-$after{$period},
% $today+$before{$period},
% );
+% $prospect_sth->execute(@param) or die $prospect_sth->errstr;
+% my $num_prospect = $prospect_sth->fetchrow_arrayref->[0];
% $cust_sth->execute(@param) or die $cust_sth->errstr;
% my $num_cust = $cust_sth->fetchrow_arrayref->[0];
% $pkg_sth->execute(@param) or die $pkg_sth->errstr;
<TD CLASS="inv" BGCOLOR="<% $bgcolor %>" ALIGN="right">
<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
+ <TR>
+ <TD ALIGN="right"><B><% $num_prospect %></B></TD>
+ <TD ALIGN="left"> prospects </TD>
+ </TR>
<TR>
<TD ALIGN="right"><B><% $num_cust %></B></TD>
- <TD ALIGN="left">customers</TD>
+ <TD ALIGN="left"> customers </TD>
</TR>
<TR>
<TD ALIGN="right"><B><% $num_pkg %></B></TD>
- <TD ALIGN="left">packages</TD>
+ <TD ALIGN="left"> packages </TD>
</TR>
</TABLE>
</TD>
</TR>
% }
+
+
+% ###
+% # Bottom Totals
+% ###
+
+% $prospect_statement =~ s/AND refnum = \?//;
+% $prospect_sth = dbh->prepare($prospect_statement)
+% or die dbh->errstr;
%
% $cust_statement =~ s/AND refnum = \?//;
% $cust_sth = dbh->prepare($cust_statement)
% or die dbh->errstr;
+%
% $pkg_statement =~ s/AND h_pkg_referral\.refnum = \?//;
% $pkg_sth = dbh->prepare($pkg_statement)
% or die dbh->errstr;
<TR>
- <TD BGCOLOR="#dddddd" ALIGN="center" COLSPAN=3><B>Total</B></TD>
+ <TD BGCOLOR="#dddddd" ALIGN="center" COLSPAN=<% 2 + $show_agentnums + ! $cgi->param('showdisabled') %><B>Total</B></TD>
% for my $period ( keys %after ) {
% my @param = ( $today-$after{$period},
% $today+$before{$period},
% );
+% $prospect_sth->execute(@param) or die $prospect_sth->errstr;
+% my $num_prospect = $prospect_sth->fetchrow_arrayref->[0];
% $cust_sth->execute( @param ) or die $cust_sth->errstr;
% my $num_cust = $cust_sth->fetchrow_arrayref->[0];
% $pkg_sth->execute(@param) or die $pkg_sth->errstr;
<TD CLASS="inv" BGCOLOR="#dddddd" ALIGN="right">
<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
+ <TR>
+ <TD ALIGN="right"><B><% $num_prospect %></B></TD>
+ <TD ALIGN="left"> prospects </TD>
+ </TR>
<TR>
<TD ALIGN="right"><B><% $num_cust %></B></TD>
- <TD ALIGN="left">customers</TD>
+ <TD ALIGN="left"> customers </TD>
</TR>
<TR>
<TD ALIGN="right"><B><% $num_pkg %></B></TD>
- <TD ALIGN="left">packages</TD>
+ <TD ALIGN="left"> packages </TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
- </BODY>
-</HTML>
+
+<& /elements/footer.html &>
<%init>
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration')
- || $FS::CurrentUser::CurrentUser->access_right('Edit advertising sources')
+ unless $FS::CurrentUser::CurrentUser->access_right('Edit advertising sources')
|| $FS::CurrentUser::CurrentUser->access_right('Edit global advertising sources');
my $today = timelocal(0, 0, 0, (localtime(time))[3..5] );
my $show_agentnums = ( scalar($curuser->agentnums) > 1 );
+my $prospect_statement = "SELECT COUNT(*) FROM h_prospect_main
+ WHERE history_action = 'insert'
+ AND refnum = ?
+ AND history_date >= ?
+ AND history_date < ?
+ AND ". $curuser->agentnums_sql;
+my $prospect_sth = dbh->prepare($prospect_statement)
+ or die dbh->errstr;
+
my $cust_statement = "SELECT COUNT(*) FROM h_cust_main
WHERE history_action = 'insert'
AND refnum = ?