added vicidial_sales_viewer web page and spreadsheet viewing scripts
git-svn-id: svn://192.168.202.10@625 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -10375,6 +10375,7 @@ if ($ADD==999999)
|
||||
<LI><a href="AST_CLOSERstats.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>CLOSER REPORT</a></FONT>
|
||||
<LI><a href="AST_agent_performance.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>AGENT PERFORMANCE</a></FONT>
|
||||
<LI><a href="AST_agent_performance_detail.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>AGENT PERFORMANCE DETAIL</a></FONT>
|
||||
<LI><a href="vicidial_sales_viewer.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>AGENT SPREADSHEET PERFORMANCE</a></FONT>
|
||||
<LI><a href="AST_server_performance.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=2>SERVER PERFORMANCE</a></FONT>
|
||||
<?
|
||||
if ($enable_queuemetrics_logging_LU > 0)
|
||||
|
||||
@@ -0,0 +1,385 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
### spreadsheet_sales_viewer.pl version 2.0.4 *DBI-version*
|
||||
###
|
||||
### Copyright (C) 2007 Joe Johnson,Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
###
|
||||
#
|
||||
#
|
||||
# CHANGES
|
||||
# 70521-1734 - First build
|
||||
# 70522-1554 - Changed to use DBI instead of Net::MySQL
|
||||
#
|
||||
|
||||
use Spreadsheet::WriteExcel;
|
||||
use Time::Local;
|
||||
use DBI;
|
||||
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
|
||||
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
||||
@conf = <conf>;
|
||||
close(conf);
|
||||
$i=0;
|
||||
foreach(@conf)
|
||||
{
|
||||
$line = $conf[$i];
|
||||
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
|
||||
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
|
||||
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
|
||||
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
|
||||
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
|
||||
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
|
||||
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
|
||||
{$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
|
||||
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
|
||||
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
|
||||
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
|
||||
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
|
||||
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
|
||||
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
|
||||
$i++;
|
||||
}
|
||||
|
||||
# Customized Variables
|
||||
$server_ip = $VARserver_ip; # Asterisk server IP
|
||||
|
||||
if (!$VARDB_port) {$VARDB_port='3306';}
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$list_ids=$ARGV[0];
|
||||
$sales_number=$ARGV[1];
|
||||
$timestamp=$ARGV[2];
|
||||
$forc=$ARGV[3];
|
||||
$now=$ARGV[4];
|
||||
$dcampaign=$ARGV[5];
|
||||
|
||||
$list_id_clause="and v.list_id in (";
|
||||
@lists=split(/\,/, $list_ids);
|
||||
for ($i=0; $i<scalar(@lists); $i++) {
|
||||
if (length($lists[$i]>0)) { $list_id_clause.="$lists[$i], "; }
|
||||
}
|
||||
$list_id_clause=substr($list_id_clause, 0, -2);
|
||||
$list_id_clause.=")";
|
||||
|
||||
|
||||
if ($sales_number==0) {undef $sales_number;}
|
||||
|
||||
|
||||
$xl = Spreadsheet::WriteExcel->new("$PATHweb/vicidial/vicidial_closer_report_$now.xls");
|
||||
$xlsheet = $xl->add_worksheet();
|
||||
$xlsheet->set_landscape();
|
||||
$rptheader = $xl->add_format(); # Add a format
|
||||
$rptheader->set_bold();
|
||||
$rptheader->set_size('8');
|
||||
$rptheader->set_color('10');
|
||||
$rptheader->set_align('center');
|
||||
|
||||
$rptheaderLEFT = $xl->add_format(); # Add a format
|
||||
$rptheaderLEFT->set_bold();
|
||||
$rptheaderLEFT->set_size('8');
|
||||
$rptheaderLEFT->set_color('10');
|
||||
$rptheaderLEFT->set_align('left');
|
||||
|
||||
$normcell = $xl->add_format(); # Add a format
|
||||
$normcell->set_size('8');
|
||||
$normcell->set_align('center');
|
||||
$normcell->set_bg_color('22');
|
||||
|
||||
$boldcell = $xl->add_format(); # Add a format
|
||||
$boldcell->set_bold();
|
||||
$boldcell->set_size('8');
|
||||
$boldcell->set_align('center');
|
||||
$boldcell->set_bg_color('22');
|
||||
|
||||
$dollarformat = $xl->add_format(); # Add a format
|
||||
$dollarformat->set_size('8');
|
||||
$dollarformat->set_num_format('$0.00');
|
||||
|
||||
$intformat = $xl->add_format(); # Add a format
|
||||
$intformat->set_size('8');
|
||||
$intformat->set_num_format('0');
|
||||
|
||||
$numberformat = $xl->add_format(); # Add a format
|
||||
$numberformat->set_size('8');
|
||||
$numberformat->set_num_format('0.00');
|
||||
|
||||
$pformat = $xl->add_format(); # Add a format
|
||||
$pformat->set_size('8');
|
||||
$pformat->set_num_format('0.00%');
|
||||
|
||||
$p2format = $xl->add_format(); # Add a format
|
||||
$p2format->set_size('8');
|
||||
$p2format->set_num_format('0%');
|
||||
|
||||
$statcell = $xl->add_format(num_format => '@'); # Add a format
|
||||
$statcell->set_size('8');
|
||||
|
||||
$countcell = $xl->add_format(); # Add a format
|
||||
$countcell->set_size('8');
|
||||
$countcell->set_bg_color('35');
|
||||
|
||||
$terminateheader = $xl->add_format(); # Add a format
|
||||
$terminateheader->set_bold();
|
||||
$terminateheader->set_size('8');
|
||||
$terminateheader->set_color('10');
|
||||
$terminateheader->set_num_format('0.00');
|
||||
|
||||
$xlsheet->write("B1", "Closer stats", $rptheader);
|
||||
$xlsheet->write("D1", "$dcampaign", $rptheaderLEFT);
|
||||
$xlsheet->write("F1", "$list_ids", $rptheaderLEFT);
|
||||
$xlsheet->write("A2", "Closer Name", $rptheader);
|
||||
$xlsheet->write("B2", "# of calls", $rptheader);
|
||||
$xlsheet->write("C2", "# of sales", $rptheader);
|
||||
$xlsheet->write("D2", "Sales percentage", $rptheader);
|
||||
$xlsheet->write("E2", "Calls per hour", $rptheader);
|
||||
$xlsheet->write("F2", "Sales per hour", $rptheader);
|
||||
$xlsheet->write("G2", "Total time in system", $rptheader);
|
||||
|
||||
%closers=();
|
||||
%fronters=();
|
||||
|
||||
|
||||
|
||||
# Non-transfer
|
||||
$sales=0;
|
||||
$stmtA = "select v.status, u.full_name, u.user from vicidial_users u, vicidial_list v, vicidial_log vl where vl.call_date>='$timestamp' and vl.call_date<='$now' and vl.lead_id=v.lead_id $list_id_clause and vl.user=u.user;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
if (length($sales_number)==0 || $sales<$sales_number)
|
||||
{
|
||||
$closers{"$aryA[1]"}[0]++;
|
||||
$fronters{"$aryA[1]"}[0]++;
|
||||
if ($aryA[0] eq "SALE")
|
||||
{
|
||||
$sales++;
|
||||
$closers{"$aryA[1]"}[1]++;
|
||||
$fronters{"$aryA[1]"}[1]++;
|
||||
}
|
||||
}
|
||||
$closers{"$aryA[1]"}[2]=$aryA[2];
|
||||
$fronters{"$aryA[1]"}[2]=$aryA[2];
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
|
||||
if ($forc eq "F") {
|
||||
%closers=();
|
||||
|
||||
$sales=0;
|
||||
$stmtA = "select v.status, u.full_name, u.user from vicidial_list v, vicidial_users u, vicidial_xfer_log vl where vl.call_date>='$timestamp' and vl.call_date<='$now' and vl.lead_id=v.lead_id $list_id_clause and vl.closer=u.user;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
if (!$sales_number || $sales<$sales_number)
|
||||
{
|
||||
$closers{"$aryA[1]"}[0]++;
|
||||
if ($aryA[0] eq "SALE")
|
||||
{
|
||||
$sales++;
|
||||
$closers{"$aryA[1]"}[1]++;
|
||||
}
|
||||
}
|
||||
$closers{"$aryA[1]"}[2]=$aryA[2];
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
}
|
||||
|
||||
|
||||
$x=3;
|
||||
$grand_total_time=0;
|
||||
foreach $closername (sort(keys(%closers)))
|
||||
{
|
||||
$closers{$closername}[0]+=0;
|
||||
$closers{$closername}[1]+=0;
|
||||
|
||||
$stmtA = "select sum(pause_sec+wait_sec+talk_sec), sec_to_time(sum(pause_sec+wait_sec+talk_sec)) from vicidial_agent_log where user=".$closers{$closername}[2]." and event_time>='$timestamp' and event_time<='$now' and pause_sec<28800 and wait_sec<28800 and talk_sec<28800;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$hours=($aryA[0]/3600);
|
||||
$grand_total_time+=$aryA[0];
|
||||
$total_time=$aryA[1];
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
$xlsheet->write("A$x", "$closername", $normcell);
|
||||
$xlsheet->write("B$x", "=$closers{$closername}[0]+0", $intformat);
|
||||
$xlsheet->write("C$x", "=$closers{$closername}[1]+0", $intformat);
|
||||
$xlsheet->write("D$x", "=C$x/B$x", $pformat);
|
||||
$xlsheet->write("E$x", "=B$x/$hours", $numberformat);
|
||||
$xlsheet->write("F$x", "=C$x/$hours", $numberformat);
|
||||
$xlsheet->write("G$x", "$total_time", $normcell);
|
||||
$x++;
|
||||
}
|
||||
$hours=($grand_total_time/3600);
|
||||
|
||||
$stmtA = "select sec_to_time($grand_total_time)";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$grand_total_time=$aryA[0];
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
|
||||
$y=($x+1);
|
||||
$xlsheet->write("A$y", "Grand Total", $boldcell);
|
||||
$xlsheet->write("B$y", "=SUM(B3:B$x)", $intformat);
|
||||
$xlsheet->write("C$y", "=SUM(C3:C$x)", $intformat);
|
||||
$xlsheet->write("D$y", "=C$y/B$y", $pformat);
|
||||
$xlsheet->write("E$y", "=B$y/$hours", $numberformat);
|
||||
$xlsheet->write("F$y", "=C$y/$hours", $numberformat);
|
||||
$xlsheet->write("G$y", "$grand_total_time", $normcell);
|
||||
$xl->close();
|
||||
|
||||
|
||||
if ($forc eq "F") {
|
||||
$xl = Spreadsheet::WriteExcel->new("$PATHweb/vicidial/vicidial_fronter_report_$now.xls");
|
||||
$xlsheet = $xl->add_worksheet();
|
||||
$xlsheet->set_landscape();
|
||||
$rptheader = $xl->add_format(); # Add a format
|
||||
$rptheader->set_bold();
|
||||
$rptheader->set_size('8');
|
||||
$rptheader->set_color('10');
|
||||
$rptheader->set_align('center');
|
||||
|
||||
$normcell = $xl->add_format(); # Add a format
|
||||
$normcell->set_size('8');
|
||||
$normcell->set_align('center');
|
||||
$normcell->set_bg_color('22');
|
||||
|
||||
$boldcell = $xl->add_format(); # Add a format
|
||||
$boldcell->set_bold();
|
||||
$boldcell->set_size('8');
|
||||
$boldcell->set_align('center');
|
||||
$boldcell->set_bg_color('22');
|
||||
|
||||
$dollarformat = $xl->add_format(); # Add a format
|
||||
$dollarformat->set_size('8');
|
||||
$dollarformat->set_num_format('$0.00');
|
||||
|
||||
$intformat = $xl->add_format(); # Add a format
|
||||
$intformat->set_size('8');
|
||||
$intformat->set_num_format('0');
|
||||
|
||||
$numberformat = $xl->add_format(); # Add a format
|
||||
$numberformat->set_size('8');
|
||||
$numberformat->set_num_format('0.00');
|
||||
|
||||
$pformat = $xl->add_format(); # Add a format
|
||||
$pformat->set_size('8');
|
||||
$pformat->set_num_format('0.00%');
|
||||
|
||||
$statcell = $xl->add_format(num_format => '@'); # Add a format
|
||||
$statcell->set_size('8');
|
||||
|
||||
$countcell = $xl->add_format(); # Add a format
|
||||
$countcell->set_size('8');
|
||||
$countcell->set_bg_color('35');
|
||||
|
||||
$terminateheader = $xl->add_format(); # Add a format
|
||||
$terminateheader->set_bold();
|
||||
$terminateheader->set_size('8');
|
||||
$terminateheader->set_color('10');
|
||||
$terminateheader->set_num_format('0.00');
|
||||
|
||||
$xlsheet->write("D1", "Fronter stats", $rptheader);
|
||||
$xlsheet->write("A2", "Fronter Name", $rptheader);
|
||||
$xlsheet->write("B2", "# of calls", $rptheader);
|
||||
$xlsheet->write("C2", "# of sales", $rptheader);
|
||||
$xlsheet->write("D2", "Sales percentage", $rptheader);
|
||||
$xlsheet->write("E2", "Calls per hour", $rptheader);
|
||||
$xlsheet->write("F2", "Sales per hour", $rptheader);
|
||||
$xlsheet->write("G2", "Total time in system", $rptheader);
|
||||
|
||||
$x=3;
|
||||
$grand_total_time=0;
|
||||
foreach $tsrname (sort(keys(%fronters))) {
|
||||
$fronters{$tsrname}[0]+=0;
|
||||
$fronters{$tsrname}[1]+=0;
|
||||
$stmtA = "select sum(pause_sec+wait_sec+talk_sec), sec_to_time(sum(pause_sec+wait_sec+talk_sec)) from vicidial_agent_log where user=".$fronters{$tsrname}[2]." and event_time>='$timestamp' and event_time<='$now' and pause_sec<28800 and wait_sec<28800 and talk_sec<28800;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$hours=($aryA[0]/3600);
|
||||
$grand_total_time+=$aryA[0];
|
||||
$total_time=$aryA[1];
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
$xlsheet->write("A$x", "$tsrname", $normcell);
|
||||
$xlsheet->write("B$x", "=$fronters{$tsrname}[0]+0", $intformat);
|
||||
$xlsheet->write("C$x", "=$fronters{$tsrname}[1]+0", $intformat);
|
||||
$xlsheet->write("D$x", "=C$x/B$x", $pformat);
|
||||
$xlsheet->write("E$x", "=B$x/$hours", $numberformat);
|
||||
$xlsheet->write("F$x", "=C$x/$hours", $numberformat);
|
||||
$xlsheet->write("G$x", "$total_time", $normcell);
|
||||
$x++;
|
||||
}
|
||||
$hours=($grand_total_time/3600);
|
||||
|
||||
$stmtA = "select sec_to_time($grand_total_time)";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$grand_total_time=$aryA[0];
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
$y=($x+1);
|
||||
$xlsheet->write("A$y", "Grand Total", $boldcell);
|
||||
$xlsheet->write("B$y", "=SUM(B3:B$x)", $intformat);
|
||||
$xlsheet->write("C$y", "=SUM(C3:C$x)", $intformat);
|
||||
$xlsheet->write("D$y", "=C$y/B$y", $pformat);
|
||||
$xlsheet->write("E$y", "=B$y/$hours", $numberformat);
|
||||
$xlsheet->write("F$y", "=C$y/$hours", $numberformat);
|
||||
$xlsheet->write("G$y", "$grand_total_time", $normcell);
|
||||
|
||||
$xl->close();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
<? header("Pragma: no-cache");
|
||||
|
||||
# vicidial_sales_viewer.php - VICIDIAL administration page
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2007 Joe Johnson,Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
|
||||
if (isset($_GET["dcampaign"])) {$dcampaign=$_GET["dcampaign"];}
|
||||
elseif (isset($_POST["dcampaign"])) {$dcampaign=$_POST["dcampaign"];}
|
||||
if (isset($_GET["submit_report"])) {$submit_report=$_GET["submit_report"];}
|
||||
elseif (isset($_POST["submit_report"])) {$submit_report=$_POST["submit_report"];}
|
||||
if (isset($_GET["list_ids"])) {$list_ids=$_GET["list_ids"];}
|
||||
elseif (isset($_POST["list_ids"])) {$list_ids=$_POST["list_ids"];}
|
||||
if (isset($_GET["sales_number"])) {$sales_number=$_GET["sales_number"];}
|
||||
elseif (isset($_POST["sales_number"])) {$sales_number=$_POST["sales_number"];}
|
||||
if (isset($_GET["sales_time_frame"])) {$sales_time_frame=$_GET["sales_time_frame"];}
|
||||
elseif (isset($_POST["sales_time_frame"])) {$sales_time_frame=$_POST["sales_time_frame"];}
|
||||
if (isset($_GET["forc"])) {$forc=$_GET["forc"];}
|
||||
elseif (isset($_POST["forc"])) {$forc=$_POST["forc"];}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>VICIDIAL recent sales lookup</title>
|
||||
</head>
|
||||
<?
|
||||
include("dbconnect.php");
|
||||
#include("/home/www/phpsubs/stylesheet.inc");
|
||||
?>
|
||||
<script language="JavaScript1.2">
|
||||
function GatherListIDs() {
|
||||
var ListIDstr="";
|
||||
var ListIDstr2="";
|
||||
for (var i=0; i<document.forms[0].list_id.options.length; i++) {
|
||||
ListIDstr2+=document.forms[0].list_id.options[i].value;
|
||||
ListIDstr2+=",";
|
||||
if (document.forms[0].list_id.options[i].selected) {
|
||||
ListIDstr+=document.forms[0].list_id.options[i].value;
|
||||
ListIDstr+=",";
|
||||
}
|
||||
}
|
||||
if (ListIDstr.length>0) {
|
||||
document.forms[0].list_ids.value=ListIDstr;
|
||||
} else {
|
||||
document.forms[0].list_ids.value=ListIDstr2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
<form action="<?=$PHP_SELF ?>" method=post onSubmit="return GatherListIDs()">
|
||||
<input type="hidden" name="list_ids">
|
||||
<table border=0 cellpadding=5 cellspacing=0 align=center width=600>
|
||||
<tr>
|
||||
<th colspan=3><font class="standard_bold">Vicidial OUTBOUND recent sales report </font><font class="standard"><a href="admin.php?ADD=999999">Back to Admin</a></font>
|
||||
<BR></th>
|
||||
</tr>
|
||||
<tr bgcolor='#CCCCCC'>
|
||||
<td colspan=3>
|
||||
<table width=100%>
|
||||
<td align=right width=200 nowrap><font class='standard_bold'>Select a VICIDIAL campaign:</td>
|
||||
<td align=left><select name="dcampaign" onChange="this.form.submit();">
|
||||
<?
|
||||
if ($dcampaign) {
|
||||
$stmt="select campaign_id, campaign_name from vicidial_campaigns where campaign_id='$dcampaign'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
while ($row=mysql_fetch_array($rslt)) {
|
||||
print "\t\t<option value='$row[campaign_id]' selected>$row[campaign_id] - $row[campaign_name]</option>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<option value=''>---------------------------------</option>
|
||||
<?
|
||||
$stmt="select distinct vc.campaign_id, vc.campaign_name from vicidial_campaigns vc, vicidial_lists vl where vc.campaign_id=vl.campaign_id order by vc.campaign_name asc";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
while ($row=mysql_fetch_array($rslt)) {
|
||||
print "\t\t<option value='$row[campaign_id]'>$row[campaign_id] - $row[campaign_name]</option>\n";
|
||||
}
|
||||
?>
|
||||
</select></td>
|
||||
</tr>
|
||||
<?
|
||||
if ($dcampaign) {
|
||||
?>
|
||||
<tr bgcolor='#CCCCCC'>
|
||||
<td align=right width=200 nowrap><font class='standard_bold'>Select list ID(s) # (optional):</td>
|
||||
<td align=left><select name="list_id" multiple size="4">
|
||||
<?
|
||||
$stmt="select list_id, list_name from vicidial_lists where campaign_id='$dcampaign' order by list_id asc";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
while ($row=mysql_fetch_array($rslt)) {
|
||||
print "\t\t<option value='$row[list_id]'>$row[list_id] - $row[list_name]</option>\n";
|
||||
}
|
||||
?>
|
||||
</select></td>
|
||||
</tr>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr bgcolor='#EEEEEE'>
|
||||
<th align=left width=350><font class='standard_bold'>View sales made within the last <select name="sales_time_frame">
|
||||
<option value=''>----------</option>
|
||||
<option value='15'>15 minutes</option>
|
||||
<option value='30'>30 minutes</option>
|
||||
<option value='45'>45 minutes</option>
|
||||
<option value='60'>1 hour</option>
|
||||
<option value='120'>2 hours</option>
|
||||
<option value='180'>3 hours</option>
|
||||
<option value='240'>4 hours</option>
|
||||
<option value='360'>6 hours</option>
|
||||
<option value='480'>8 hours</option>
|
||||
</select></th>
|
||||
<th width=50>OR...</th>
|
||||
<th align=right width=200><font class='standard_bold'>View the last <input type=text size=5 maxlength=5 name="sales_number"> sales**</font></th>
|
||||
</tr>
|
||||
<tr bgcolor='#EEEEEE'><th colspan=3><font class="small_standard">(If you enter values in both fields, the results will be limited by the first criteria met)</font></th></tr>
|
||||
<tr bgcolor='#CCCCCC'>
|
||||
<td align=right><font class="standard_bold">Campaign is: <input type=radio name="forc" value="F">Transfer</font></td>
|
||||
<td colspan=2 align=left><font class="standard_bold"> <input type=radio name="forc" value="C" checked>Non-transfer</font></td>
|
||||
</tr>
|
||||
<tr><th colspan=3><input type=submit name="submit_report" value="SUBMIT"></th></tr>
|
||||
<!-- <tr><th colspan=3><input type=checkbox name="weekly_report" value="WEEKLY_REPORT"><font class="small_standard">Generate weekly report</font></th></tr> //-->
|
||||
<tr><td colspan=3 align=center><font class="small_standard">** - sorted by call date</font></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<?
|
||||
if ($submit_report && $list_ids) {
|
||||
|
||||
$now=date("YmdHis");
|
||||
$list_id_clause="and v.list_id in (";
|
||||
$lists=explode(",", $list_ids);
|
||||
for ($i=0; $i<count($lists); $i++) {
|
||||
if (strlen($lists[$i]>0)) { $list_id_clause.="$lists[$i], "; }
|
||||
}
|
||||
$list_id_clause=substr($list_id_clause, 0, -2);
|
||||
$list_id_clause.=")";
|
||||
|
||||
if ($sales_number && $sales_number>0) {
|
||||
$sales_number=eregi_replace("[^0-9]", "", $sales_number);
|
||||
$limit_clause="limit $sales_number";
|
||||
} else {
|
||||
$sales_number=0;
|
||||
$limit_clause="";
|
||||
}
|
||||
if ($sales_time_frame && $sales_time_frame>0) {
|
||||
$hours=$sales_time_frame/60;
|
||||
$timestamp=date("YmdHis", mktime(date("H"),(date("i")-$sales_time_frame),date("s"),date("m"),date("d"),date("Y")));
|
||||
} else {
|
||||
$timestamp=date("YmdHis", mktime(date("H"),date("i"),date("s"),date("m"),(date("d")-1),date("Y")));
|
||||
$hours=24;
|
||||
}
|
||||
print "<HR>";
|
||||
print "<table border=0 cellpadding=5 cellspacing=0 align=center>";
|
||||
$i=0;
|
||||
|
||||
$dfile=fopen("discover_stmts.txt", "w");
|
||||
if ($forc=="C") {
|
||||
$stmt="select v.first_name, v.last_name, v.phone_number, vl.call_date, v.lead_id, u.full_name from vicidial_users u, vicidial_list v, vicidial_log vl where vl.call_date>='$timestamp' and vl.lead_id=v.lead_id and v.status='SALE' $list_id_clause and vl.user=u.user order by call_date desc $limit_clause";
|
||||
} else {
|
||||
$stmt="select v.first_name, v.last_name, v.phone_number, vl.call_date, v.lead_id, vl.user, vl.closer from vicidial_list v, vicidial_xfer_log vl where vl.call_date>='$timestamp' and vl.lead_id=v.lead_id and v.status='SALE' $list_id_clause order by call_date desc $limit_clause";
|
||||
}
|
||||
fwrite($dfile, "$stmt\n");
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$q=0;
|
||||
print "<tr bgcolor='#000000'><th colspan=8><font class='standard_bold' color='white'>Last ".mysql_num_rows($rslt)." sales made</font></th></tr>\n";
|
||||
print "<tr bgcolor='#000000'>\n";
|
||||
print "\t<th><font class='standard_bold' color='white'>Sales Rep(s)</font></th>\n";
|
||||
print "\t<th><font class='standard_bold' color='white'>Customer Name</font></th>\n";
|
||||
print "\t<th><font class='standard_bold' color='white'>Phone</font></th>\n";
|
||||
print "\t<th><font class='standard_bold' color='white'>Recording ID</font></th>\n";
|
||||
print "\t<th><font class='standard_bold' color='white'>Timestamp</font></th>\n";
|
||||
print "</tr>\n";
|
||||
while ($row=mysql_fetch_row($rslt)) {
|
||||
$rec_stmt="select max(recording_id) from recording_log where lead_id='$row[4]'";
|
||||
$rec_rslt=mysql_query($rec_stmt, $link);
|
||||
$rec_row=mysql_fetch_row($rec_rslt);
|
||||
|
||||
if ($forc=="F") {
|
||||
$rep_stmt="select full_name from vicidial_users where user='$row[5]'";
|
||||
$rep_rslt=mysql_query($rep_stmt, $link);
|
||||
$fr_row=mysql_fetch_array($rep_rslt);
|
||||
|
||||
$rep_stmt="select full_name from vicidial_users where user='$row[6]'";
|
||||
$rep_rslt=mysql_query($rep_stmt, $link);
|
||||
$cl_row=mysql_fetch_array($rep_rslt);
|
||||
|
||||
$rep_name="$fr_row[full_name]/$cl_row[full_name]";
|
||||
} else {
|
||||
$rep_name=$row[5];
|
||||
}
|
||||
|
||||
if ($i%2==0) {$bgcolor="#999999";} else {$bgcolor="#CCCCCC";}
|
||||
print "<tr bgcolor='$bgcolor'>\n";
|
||||
print "\t<th><font class='standard_bold'>$rep_name</font></th>\n";
|
||||
print "\t<th><font class='standard_bold'>$row[0] $row[1]</font></th>\n";
|
||||
print "\t<th><font class='standard_bold'>$row[2]</font></th>\n";
|
||||
print "\t<th><font class='standard_bold'>$rec_row[0]</font></th>\n";
|
||||
print "\t<th><font class='standard_bold'>$row[3]</font></th>\n";
|
||||
print "</tr>\n";
|
||||
flush();
|
||||
}
|
||||
print "</table>";
|
||||
passthru("$WeBServeRRooT/vicidial/spreadsheet_sales_viewer.pl $list_ids $sales_number $timestamp $forc $now $dcampaign");
|
||||
# print "\n\n<BR>$WeBServeRRooT/vicidial/spreadsheet_sales_viewer.pl $list_ids $sales_number $timestamp $forc $now $dcampaign<BR>\n";
|
||||
flush();
|
||||
print "<table align=center border=0 cellpadding=3 cellspacing=5 width=700><tr bgcolor='#CCCCCC'>";
|
||||
if ($forc=="F") {
|
||||
print "<th width='50%'><font class='standard_bold'><a href='vicidial_fronter_report_$now.xls'>View complete Excel fronter report for this shift</a></font></th>";
|
||||
}
|
||||
print "<th width='50%'><font class='standard_bold'><a href='vicidial_closer_report_$now.xls'>View complete Excel sales report for this shift</a></font></th>";
|
||||
print "</tr></table>";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user