LICENSE: AGPLv2 # # CHANGES # # 70813-1526 - First Build # 71008-1436 - Added shift to be defined in dbconnect_mysqli.php # 71217-1128 - Changed method for calculating stats # 71228-1140 - added percentages, cross-day start/stop # 80328-1139 - adapted for basic fronter/closer stats # 90310-2132 - Added admin header # 90508-0644 - Changed to PHP long tags # 100214-1421 - Sort menu alphabetically # 100216-0042 - Added popup date selector # 100712-1324 - Added system setting slave server option # 100802-2347 - Added User Group Allowed Reports option validation # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1828 - Added download option # 111104-1213 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs # 120705-2007 - Changed SALES to use sales status flag # 130414-0126 - Added report logging # 130610-0948 - Finalized changing of all ereg instances to preg # 130619-2339 - Added filtering of input to prevent SQL injection attacks and new user auth # 130901-1930 - Changed to mysqli PHP functions # 140108-0725 - Added webserver and hostname to report logging # 140328-0005 - Converted division calculations to use MathZDC function # 141114-0017 - Finalized adding QXZ translation to all admin files # 141230-1345 - Added code for on-the-fly language translations display # 150516-1317 - Fixed Javascript element problem, Issue #857 # 151125-1642 - Added search archive option # 160211-2249 - Overhauled report calculations and labeling to make the report more accurate and "universal" # 160227-1131 - Uniform form format # 160714-2348 - Added and tested ChartJS features for more aesthetically appealing graphs # 170227-1717 - Fix for default HTML report format, issue #997 # 170409-1555 - Added IP List validation code # 170829-0040 - Added screen color settings # 171012-2015 - Fixed javascript/apache errors with graphs # 180508-2215 - Added new help display # 190216-0807 - Fix for user-group, in-group and campaign allowed/permissions matching issues # 191013-0821 - Fixes for PHP7 # 220228-2044 - Added allow_web_debug system setting # $startMS = microtime(); require("dbconnect_mysqli.php"); require("functions.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; $PHP_SELF = preg_replace('/\.php.*/i','.php',$PHP_SELF); if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} if (isset($_GET["group"])) {$group=$_GET["group"];} elseif (isset($_POST["group"])) {$group=$_POST["group"];} if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} if (isset($_GET["shift"])) {$shift=$_GET["shift"];} elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} if (isset($_GET["submit"])) {$submit=$_GET["submit"];} elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];} elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} $DB=preg_replace("/[^0-9a-zA-Z]/","",$DB); $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); if (!isset($group)) {$group = "CL_TEST_L";} if (!isset($query_date)) {$query_date = $NOW_DATE;} if (strlen($shift)<2) {$shift='ALL';} $report_name = 'Fronter - Closer Report'; $db_source = 'M'; $JS_text="\n"; $HTML_head.="
"; $HTML_head.="\n"; $HTML_head.="\n"; $HTML_head.="\n"; require("chart_button.php"); $HTML_head.="\n"; $HTML_head.="\n"; $HTML_head.="\n"; $HTML_head.="| "; $HTML_text.="\n\n"; $HTML_text.=" |
\n\n";
if (!$group)
{
$HTML_text.="\n\n";
$HTML_text.=_QXZ("PLEASE SELECT AN IN-GROUP AND DATE ABOVE THEN CLICK SUBMIT")."\n";
}
else
{
# $time_BEGIN=$AM_shift_BEGIN;
# $time_END=$AM_shift_END;
#$query_date_BEGIN = "$query_date $time_BEGIN";
#$query_date_END = "$query_date $time_END";
$Cqdate = explode('-',$query_date);
if ($shift == 'AM')
{
$query_date_BEGIN = date("Y-m-d H:i:s", mktime(1, 0, 0, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
$query_date_END = date("Y-m-d H:i:s", mktime(17, 45, 0, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
}
if ($shift == 'PM')
{
$query_date_BEGIN = date("Y-m-d H:i:s", mktime(17, 45, 1, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
$query_date_END = date("Y-m-d H:i:s", mktime(24, 59, 59, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
}
if ($shift == 'ALL')
{
$query_date_BEGIN = date("Y-m-d H:i:s", mktime(1, 0, 0, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
$query_date_END = date("Y-m-d H:i:s", mktime(24, 59, 59, $Cqdate[1], $Cqdate[2], $Cqdate[0]));
}
$HTML_text.=_QXZ("In-Group Fronter-Closer Stats Report",57)." $NOW_TIME\n";
$HTML_text.="\n";
$HTML_text.="---------- "._QXZ("TOTALS FOR")." $query_date_BEGIN "._QXZ("to")." $query_date_END\n";
$SQL_group_id = preg_replace("/_/",'\\_',$group);
$sale_dispo_stmt="select distinct status from vicidial_campaign_statuses where sale='Y' and campaign_id in (SELECT campaign_id from vicidial_campaigns where closer_campaigns LIKE \"% $SQL_group_id %\" $LOGallowed_campaignsSQL) UNION select distinct status from vicidial_statuses where sale='Y'";
if ($DB) {$HTML_text.="$sale_dispo_stmt\n";}
$sale_dispo_rslt=mysql_to_mysqli($sale_dispo_stmt, $link);
$sale_dispos="'SALE'"; $sale_dispo_str="|SALE";
while ($ssrow=mysqli_fetch_row($sale_dispo_rslt)) {
$sale_dispos.=",'$ssrow[0]'";
$sale_dispo_str.="|$ssrow[0]";
}
$sale_dispo_str.="|";
if ($DB) {$HTML_text.=_QXZ("Sale dispo string").": $sale_dispo_str\n";}
$stmt="select count(*) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "' and status in ($sale_dispos);";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$HTML_text.="$stmt\n";}
$row=mysqli_fetch_row($rslt);
$HTML_text.=_QXZ("STATUS",8)." "._QXZ("CUSTOMERS")."\n";
$HTML_text.=_QXZ("SALES").": $A1_tally\n";
$HTML_text.="\n";
##############################
######### FRONTER STATS
$TOTagents=0;
$TOTcalls=0;
$TOTsales=0;
$totDROP=0;
$totOTHER=0;
$CSV_fronter_header="\""._QXZ("TOTALS FOR")." $query_date_BEGIN "._QXZ("to")." $query_date_END\"\n";
$CSV_fronter_header.="\""._QXZ("STATUS CUSTOMERS")."\"\n";
$CSV_fronter_header.="\""._QXZ("SALES").": $A1_tally\"\n\n";
$CSV_fronter_header.="\""._QXZ("FRONTER STATS")."\"\n";
$CSV_fronter_header.="\""._QXZ("AGENT")."\",\""._QXZ("XFERS")."\",\""._QXZ("SALE")."%\",\""._QXZ("SALE")."\",\""._QXZ("DROP")."\",\""._QXZ("OTHER")."\"\n";
$CSV_fronter_lines="";
$CSV_fronter_footer="";
$ASCII_text="\n";
$ASCII_text.="---------- "._QXZ("FRONTER STATS")."\n";
$ASCII_text.="+--------------------------+--------+--------+------+------+------+\n";
$ASCII_text.="| "._QXZ("AGENT",24)." | "._QXZ("XFERS",6)." |"._QXZ("SALE",7)."%| "._QXZ("SALE",4)." | "._QXZ("DROP",4)." |"._QXZ("OTHER",5)." |\n";
$ASCII_text.="+--------------------------+--------+--------+------+------+------+\n";
######## GRAPHING #########
$graph_stats=array();
$max_success=1;
$max_xfers=1;
$max_success_pct=1;
$max_sales=1;
$max_drops=1;
$max_other=1;
###########################
$stmt="select user,count(*) from ".$vicidial_xfer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "' and user is not null group by user;";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$ASCII_text.="$stmt\n";}
$users_to_print = mysqli_num_rows($rslt);
$i=0;
$userRAW=array();
$user=array();
$USERcallsRAW=array();
$USERcalls=array();
while ($i < $users_to_print)
{
$row=mysqli_fetch_row($rslt);
$TOTcalls = ($TOTcalls + $row[1]);
$userRAW[$i]=$row[0];
$user[$i] = sprintf("%-6s", $row[0]);while(strlen($user[$i])>6) {$user[$i] = substr("$user[$i]", 0, -1);}
$USERcallsRAW[$i] = $row[1];
$USERcalls[$i] = sprintf("%6s", $row[1]);
$i++;
}
$i=0;
$full_name=array();
while ($i < $users_to_print)
{
$stmt="select full_name from vicidial_users where user='$userRAW[$i]' $LOGadmin_viewable_groupsSQL;";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$ASCII_text.="$stmt\n";}
$names_to_print = mysqli_num_rows($rslt);
if ($names_to_print > 0)
{
$row=mysqli_fetch_row($rslt);
if ($non_latin < 1)
{
$full_name[$i] = sprintf("%-15s", $row[0]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
}
else
{
$full_name[$i] = sprintf("%-45s", $row[0]); while(mb_strlen($full_name[$i],'utf-8')>15) {$full_name[$i] = mb_substr("$full_name[$i]", 0, -1,'utf-8');}
}
}
else
{$full_name[$i] = ' ';}
$DROP=0; $OTHER=0; $sales=0;
$stmt="select vc.status,count(*) from ".$vicidial_xfer_log_table." vx, ".$vicidial_closer_log_table." vc where vx.call_date >= '$query_date_BEGIN' and vx.call_date <= '$query_date_END' and vc.call_date >= '$query_date_BEGIN' and vc.call_date <= '$query_date_END' and vc.campaign_id='" . mysqli_real_escape_string($link, $group) . "' and vx.campaign_id='" . mysqli_real_escape_string($link, $group) . "' and vx.user='$userRAW[$i]' and vc.lead_id=vx.lead_id and vc.xfercallid=vx.xfercallid group by vc.status;";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$ASCII_text.="$stmt\n";}
$lead_ids_to_print = mysqli_num_rows($rslt);
$j=0;
while ($j < $lead_ids_to_print)
{
$row=mysqli_fetch_row($rslt);
$recL=0;
if ( (preg_match("/\|$row[0]\|/", $sale_dispo_str)) and ($recL < 1) ) {$A1=$row[1]; $recL++; $sales=($sales + $row[1]);}
if ( ($row[0]=='DROP' || $row[0]=='TIMEOT') and ($recL < 1) ) {$DROP=($DROP+$row[1]); $recL++;}
if ($recL < 1) {$OTHER=($row[1] + $OTHER); $recL++;}
$j++;
}
$totDROP = ($totDROP + $DROP);
$totOTHER = ($totOTHER + $OTHER);
$TOTsales = ($TOTsales + $sales);
$Spct = MathZDC($sales, $USERcallsRAW[$i])*100;
$Spct = round($Spct, 2);
$Spct = sprintf("%01.2f", $Spct);
if ($sales>$max_success) {$max_success=$sales;}
if ($USERcalls[$i]>$max_xfers) {$max_xfers=$USERcalls[$i];}
if ($Spct>$max_success_pct) {$max_success_pct=$Spct;}
if ($DROP>$max_drops) {$max_drops=$DROP;}
if ($OTHER>$max_other) {$max_other=$OTHER;}
$graph_stats[$i][0]="$user[$i] - $full_name[$i]";
$graph_stats[$i][1]=$USERcalls[$i];
$graph_stats[$i][2]=$Spct;
$graph_stats[$i][3]=$sales;
$graph_stats[$i][4]=$DROP;
$graph_stats[$i][5]=$OTHER;
$DROP = sprintf("%4s", $DROP);
$OTHER = sprintf("%4s", $OTHER);
$sales = sprintf("%4s", $sales);
$Spct = sprintf("%6s", $Spct);
$ASCII_text.="| $user[$i] - $full_name[$i] | $USERcalls[$i] | $Spct%| $sales | $DROP | $OTHER |\n";
$CSV_fronter_lines.="\"$user[$i] - $full_name[$i]\",\"$USERcalls[$i]\",\"$Spct%\",\"$sales\",\"$DROP\",\"$OTHER\"\n";
$i++;
}
$totSpct = MathZDC($TOTsales, $TOTcalls)*100;
$totSpct = round($totSpct, 2);
$totSpct = sprintf("%01.2f", $totSpct);
$totSpct = sprintf("%6s", $totSpct);
$TOTagents = sprintf("%6s", $i);
$TOTcalls = sprintf("%6s", $TOTcalls);
$TOTsales = sprintf("%5s", $TOTsales);
$totDROP = sprintf("%5s", $totDROP);
$totOTHER = sprintf("%5s", $totOTHER);
$stmt="select avg(queue_seconds) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$ASCII_text.="$stmt\n";}
$row=mysqli_fetch_row($rslt);
$AVGwait = $row[0];
$AVGwait_M = MathZDC($AVGwait, 60);
$AVGwait_M = round($AVGwait_M, 2);
$AVGwait_M_int = intval("$AVGwait_M");
$AVGwait_S = ($AVGwait_M - $AVGwait_M_int);
$AVGwait_S = ($AVGwait_S * 60);
$AVGwait_S = round($AVGwait_S, 0);
if ($AVGwait_S < 10) {$AVGwait_S = "0$AVGwait_S";}
$AVGwait_MS = "$AVGwait_M_int:$AVGwait_S";
$AVGwait = sprintf("%6s", $AVGwait_MS);
$ASCII_text.="+--------------------------+--------+--------+------+------+------+\n";
$ASCII_text.="| "._QXZ("TOTAL FRONTERS",14).": $TOTagents | $TOTcalls | $totSpct%|$TOTsales |$totDROP |$totOTHER |\n";
$ASCII_text.="+--------------------------+--------+--------+------+------+------+\n";
$ASCII_text.="| "._QXZ("Average time in Queue for customers",52,"r").": $AVGwait |\n";
$ASCII_text.="+--------------------------+--------+--------+------+------+------+\n";
$CSV_fronter_footer.="\""._QXZ("TOTAL FRONTERS").": $TOTagents\",\"$TOTcalls\",\"$totSpct%\",\"$TOTsales\",\"$totDROP\",\"$totOTHER\"\n";
$CSV_fronter_footer.="\""._QXZ("Average time in Queue for customers").": $AVGwait\"\n\n\n";
# USE THIS FOR multiple graphs, use pipe-delimited array elements, dataset_name|index|link_name
$multigraph_text="";
$graph_id++;
$graph_array=array("FCSF_XFERSdata|1|XFERS|integer|", "FCSF_SALEPCTdata|2|SALE %|percent|", "FCSF_SALESdata|3|SALES|integer|", "FCSF_DROPSdata|4|DROPS|integer|", "FCSF_OTHERdata|5|OTHER|integer|");
$default_graph="bar"; # Graph that is initally displayed when page loads
include("graph_color_schemas.inc");
$graph_totals_array=array();
$graph_totals_rawdata=array();
for ($q=0; $q"._QXZ("TOTAL")." - ".sec_convert($current_graph_total, 'H')." \n";
$chart_options="options: {tooltips: {callbacks: {label: function(tooltipItem, data) {var value = Math.round(data.datasets[0].data[tooltipItem.index]); return value.toHHMMSS();}}}, legend: { display: false }},";
break;
case "percent":
$graph_totals_array[$q]="";
$chart_options="options: {tooltips: {callbacks: {label: function(tooltipItem, data) {var value = data.datasets[0].data[tooltipItem.index]; return value + '%';}}}, legend: { display: false }},";
break;
default:
$graph_totals_array[$q]=" "._QXZ("TOTAL").": $current_graph_total \n";
$chart_options="options: { legend: { display: false }},";
break;
}
$datasets.=$data;
$datasets.=$graphConstantsA.$graphConstantsB.$graphConstantsC.$graphConstants; # SEE TOP OF SCRIPT
$datasets.="\t\t\t}\n";
$datasets.="\t\t]\n";
$datasets.="\t}\n";
$JS_text.=$labels.$datasets;
# $JS_text.="}\n";
# $JS_text.="prepChart('$default_graph', $graph_id, $q, $dataset_name);\n";
$JS_text.="var main_ctx = document.getElementById(\"CanvasID".$graph_id."_".$q."\");\n";
$JS_text.="var GraphID".$graph_id."_".$q." = new Chart(main_ctx, {type: '$default_graph', $chart_options data: $dataset_name});\n";
}
$graph_count=count($graph_array);
$graph_title=_QXZ("FRONTER STATS");
include("graphcanvas.inc");
$HTML_head.=$HTML_graph_head;
$GRAPH_text.=$graphCanvas;
##############################
######### CLOSER STATS
$graph_stats=array();
$TOTagents=0;
$TOTcalls=0;
$totDROP=0;
$totOTHER=0;
$TOTsales=0;
$CSV_closer_header="";
$CSV_closer_lines="";
$CSV_closer_footer="";
$ASCII_text.="\n";
$ASCII_text.="---------- "._QXZ("CLOSER STATS")."\n";
$ASCII_text.="+--------------------------+--------+------+------+------+-------+\n";
$ASCII_text.="| "._QXZ("AGENT",24)." | "._QXZ("CALLS",6)." | "._QXZ("SALE",4)." | "._QXZ("DROP",4)." |"._QXZ("OTHER",5)." | "._QXZ("CONV",4)." %|\n";
$ASCII_text.="+--------------------------+--------+------+------+------+-------+\n";
$CSV_closer_header="\""._QXZ("CLOSER STATS")."\"\n";
$CSV_closer_header.="\""._QXZ("AGENT")."\",\""._QXZ("CALLS")."\",\""._QXZ("SALE")."\",\""._QXZ("DROP")."\",\""._QXZ("OTHER")."\",\""._QXZ("CONV")." %\"\n";
######## GRAPHING #########
$max_calls=1;
$max_sales=1;
$max_drops=1;
$max_other=1;
$max_sales2=1;
$max_conv_pct=1;
###########################
$stmt="select user,count(*) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "' and user is not null group by user;";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$ASCII_text.="$stmt\n";}
$users_to_print = mysqli_num_rows($rslt);
$i=0;
$userRAW=array();
$user=array();
$USERcallsRAW=array();
$USERcalls=array();
while ($i < $users_to_print)
{
$row=mysqli_fetch_row($rslt);
$TOTcalls = ($TOTcalls + $row[1]);
$userRAW[$i]=$row[0];
$user[$i] = sprintf("%-6s", $row[0]);while(strlen($user[$i])>6) {$user[$i] = substr("$user[$i]", 0, -1);}
$USERcalls[$i] = sprintf("%6s", $row[1]);
$USERcallsRAW[$i] = $row[1];
$i++;
}
$i=0;
$full_name=array();
while ($i < $users_to_print)
{
$stmt="select full_name from vicidial_users where user='$userRAW[$i]' $LOGadmin_viewable_groupsSQL;";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$ASCII_text.="$stmt\n";}
$names_to_print = mysqli_num_rows($rslt);
if ($names_to_print > 0)
{
$row=mysqli_fetch_row($rslt);
if ($non_latin < 1)
{
$full_name[$i] = sprintf("%-15s", $row[0]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
}
else
{
$full_name[$i] = sprintf("%-45s", $row[0]); while(mb_strlen($full_name[$i],'utf-8')>15) {$full_name[$i] = mb_substr("$full_name[$i]", 0, -1,'utf-8');}
}
}
else
{$full_name[$i] = ' ';}
$DROP=0; $OTHER=0; $sales=0; $uTOP=0; $uBOT=0; $points=0;
$stmt="select status,count(*) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "' and user='$userRAW[$i]' group by status;";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {$ASCII_text.="$stmt\n";}
$lead_ids_to_print = mysqli_num_rows($rslt);
$j=0;
while ($j < $lead_ids_to_print)
{
$row=mysqli_fetch_row($rslt);
$recL=0;
if ( preg_match("/\|$row[0]\|/", $sale_dispo_str) and ($recL < 1) )
{
$A1=$row[1]; $recL++;
$sales=($sales + $row[1]);
$points = ($points + ($row[1] * 1) );
}
if ( ($row[0]=='DROP') and ($recL < 1) ) {$DROP=$row[1]; $recL++;}
if ($recL < 1) {$OTHER=($row[1] + $OTHER); $recL++;}
$j++;
}
$TOTsales = ($TOTsales + $sales);
$totDROP = ($totDROP + $DROP);
$totOTHER = ($totOTHER + $OTHER);
$totPOINTS = ($totPOINTS + $points);
$Cpct = MathZDC($sales, ( ($USERcallsRAW[$i] - 0) - $DROP) )*100;
$Cpct = round($Cpct, 2);
$Cpct = sprintf("%01.2f", $Cpct);
$Cpct = sprintf("%6s", $Cpct);
$TOP = MathZDC($uTOP, $sales)*100;
$TOP = round($TOP, 0);
$TOP = sprintf("%01.0f", $TOP);
$TOP = sprintf("%3s", $TOP);
$BOT = MathZDC($uBOT, $sales)*100;
$BOT = round($BOT, 0);
$BOT = sprintf("%01.0f", $BOT);
$BOT = sprintf("%3s", $BOT);
$ppc = MathZDC($points, ( ($USERcallsRAW[$i] - 0) - $DROP) );
$ppc = round($ppc, 2);
$ppc = sprintf("%01.2f", $ppc);
$ppc = sprintf("%4s", $ppc);
if ($USERcalls[$i]>$max_calls) {$max_calls=$USERcalls[$i];}
if ($A1>$max_sales) {$max_sales=$A1;}
if ($DROP>$max_drops) {$max_drops=$DROP;}
if ($OTHER>$max_other) {$max_other=$OTHER;}
if ($sales>$max_sales2) {$max_sales2=$sales;}
if ($Cpct>$max_conv_pct) {$max_conv_pct=$Cpct;}
$graph_stats[$i][0]="$user[$i] - $full_name[$i]";
$graph_stats[$i][1]=$USERcalls[$i];
$graph_stats[$i][2]=$sales;
$graph_stats[$i][3]=$DROP;
$graph_stats[$i][4]=$OTHER;
$graph_stats[$i][5]=$Cpct;
$DROP = sprintf("%4s", $DROP);
$OTHER = sprintf("%4s", $OTHER);
$sales = sprintf("%4s", $sales);
$ASCII_text.="| $user[$i] - $full_name[$i] | $USERcalls[$i] | $sales | $DROP | $OTHER |$Cpct%|\n";
$CSV_closer_lines.="\"$user[$i] - $full_name[$i]\",\"$USERcalls[$i]\",\"$sales\",\"$DROP\",\"$OTHER\",\"$Cpct%\"\n";
$i++;
}
$totCpct = MathZDC($TOTsales, ( ($TOTcalls - 0) - $totDROP) )*100;
$totCpct = round($totCpct, 2);
$totCpct = sprintf("%01.2f", $totCpct);
$totCpct = sprintf("%6s", $totCpct);
$ppc = MathZDC($totPOINTS, ( ($TOTcalls - $totOTHER) - $totDROP) );
$ppc = round($ppc, 2);
$ppc = sprintf("%01.2f", $ppc);
$ppc = sprintf("%4s", $ppc);
$TOP = MathZDC($totTOP, $TOTsales)*100;
$TOP = round($TOP, 0);
$TOP = sprintf("%01.0f", $TOP);
$TOP = sprintf("%3s", $TOP);
$BOT = MathZDC($totBOT, $TOTsales)*100;
$BOT = round($BOT, 0);
$BOT = sprintf("%01.0f", $BOT);
$BOT = sprintf("%3s", $BOT);
$TOTagents = sprintf("%6s", $i);
$TOTcalls = sprintf("%6s", $TOTcalls);
$totDROP = sprintf("%5s", $totDROP);
$totOTHER = sprintf("%5s", $totOTHER);
$TOTsales = sprintf("%5s", $TOTsales);
$ASCII_text.="+--------------------------+--------+------+------+------+-------+\n";
$ASCII_text.="| "._QXZ("TOTAL CLOSERS",13).": $TOTagents | $TOTcalls |$TOTsales |$totDROP |$totOTHER |$totCpct%|\n";
$ASCII_text.="+--------------------------+--------+------+------+------+-------+\n";
$CSV_closer_footer.="\""._QXZ("TOTAL CLOSERS").": $TOTagents\",\"$TOTcalls\",\"$totA1\",\"$totDROP\",\"$totOTHER\",\"$TOTsales\",\"$totCpct%\"\n";
# USE THIS FOR multiple graphs, use pipe-delimited array elements, dataset_name|index|link_name
$multigraph_text="";
$graph_id++;
$graph_array=array("FCSC_CALLSdata|1|CALLS|integer|", "FCSC_SALESdata|2|SALES|integer|", "FCSC_DROPSdata|3|DROPS|integer|", "FCSC_OTHERdata|4|OTHER|integer|", "FCSC_CONVPCTdata|5|CONV %|percent|");
$default_graph="bar"; # Graph that is initally displayed when page loads
include("graph_color_schemas.inc");
$graph_totals_array=array();
$graph_totals_rawdata=array();
for ($q=0; $q"._QXZ("TOTAL")." - ".sec_convert($current_graph_total, 'H')." \n";
$chart_options="options: {tooltips: {callbacks: {label: function(tooltipItem, data) {var value = Math.round(data.datasets[0].data[tooltipItem.index]); return value.toHHMMSS();}}}, legend: { display: false }},";
break;
case "percent":
$graph_totals_array[$q]="";
$chart_options="options: {tooltips: {callbacks: {label: function(tooltipItem, data) {var value = data.datasets[0].data[tooltipItem.index]; return value + '%';}}}, legend: { display: false }},";
break;
default:
$graph_totals_array[$q]=" "._QXZ("TOTAL").": $current_graph_total \n";
$chart_options="options: { legend: { display: false }},";
break;
}
$datasets.=$data;
$datasets.=$graphConstantsA.$graphConstantsB.$graphConstantsC.$graphConstants; # SEE TOP OF SCRIPT
$datasets.="\t\t\t}\n";
$datasets.="\t\t]\n";
$datasets.="\t}\n";
$JS_text.=$labels.$datasets;
# $JS_text.="}\n";
# $JS_text.="prepChart('$default_graph', $graph_id, $q, $dataset_name);\n";
$JS_text.="var main_ctx = document.getElementById(\"CanvasID".$graph_id."_".$q."\");\n";
$JS_text.="var GraphID".$graph_id."_".$q." = new Chart(main_ctx, {type: '$default_graph', $chart_options data: $dataset_name});\n";
}
$graph_count=count($graph_array);
$graph_title=_QXZ("CLOSER STATS");
include("graphcanvas.inc");
$HTML_head.=$HTML_graph_head;
$GRAPH_text.=$graphCanvas;
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
if ($report_display_type=="HTML") {
$HTML_text.=$GRAPH_text;
}
else
{
$HTML_text.=$ASCII_text;
}
if ($DB) {$HTML_text.="\n"._QXZ("Run Time").": $RUNtime "._QXZ("seconds")."|$db_source\n";}
$HTML_text.=" \n";
$HTML_text.="