";
echo "\n\n";
echo "\n\n";
if (strlen($group[0]) < 1)
{
echo "\n\n";
echo "PLEASE SELECT A CAMPAIGN AND DATE ABOVE AND CLICK SUBMIT\n";
}
else
{
if ($shift == 'AM')
{
$time_BEGIN=$AM_shift_BEGIN;
$time_END=$AM_shift_END;
if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}
if (strlen($time_END) < 6) {$time_END = "15:15:00";}
}
if ($shift == 'PM')
{
$time_BEGIN=$PM_shift_BEGIN;
$time_END=$PM_shift_END;
if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
if (strlen($time_END) < 6) {$time_END = "23:15:00";}
}
if ($shift == 'ALL')
{
if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
if (strlen($time_END) < 6) {$time_END = "23:59:59";}
}
$query_date_BEGIN = "$query_date $time_BEGIN";
$query_date_END = "$end_date $time_END";
$OUToutput = '';
$OUToutput .= "Outbound Calling Stats $NOW_TIME\n";
$OUToutput .= "\n";
$OUToutput .= "Time range: $query_date_BEGIN to $query_date_END\n\n";
$OUToutput .= "---------- TOTALS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {$OUToutput .= "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALcallsRAW = $row[0];
$TOTALsec = $row[1];
$inTOTALcallsRAW=0;
if (eregi("YES",$include_rollover))
{
$length_in_secZ=0;
$queue_secondsZ=0;
$agent_alert_delayZ=0;
$stmt="select length_in_sec,queue_seconds,agent_alert_delay from vicidial_closer_log,vicidial_inbound_groups where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and group_id=campaign_id $group_drop_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$INallcalls_to_printZ = mysql_num_rows($rslt);
$y=0;
while ($y < $INallcalls_to_printZ)
{
$row=mysql_fetch_row($rslt);
$length_in_secZ = $row[0];
$queue_secondsZ = $row[1];
$agent_alert_delayZ = $row[2];
$TOTALdelay = round($agent_alert_delayZ / 1000);
$thiscallsec = (($length_in_secZ - $queue_secondsZ) - $TOTALdelay);
if ($thiscallsec < 0)
{$thiscallsec = 0;}
$inTOTALsec = ($inTOTALsec + $thiscallsec);
$y++;
}
$inTOTALcallsRAW = $y;
$TOTALsec = ($TOTALsec + $inTOTALsec);
$inTOTALcalls = sprintf("%10s", $inTOTALcallsRAW);
}
$TOTALcalls = sprintf("%10s", $TOTALcallsRAW);
if ( ($row[0] < 1) or ($TOTALsec < 1) )
{$average_call_seconds = ' 0';}
else
{
$average_call_seconds = ($TOTALsec / $TOTALcallsRAW);
$average_call_seconds = round($average_call_seconds, 2);
$average_call_seconds = sprintf("%10s", $average_call_seconds);
}
$OUToutput .= "Total Calls placed from this Campaign: $TOTALcalls\n";
$OUToutput .= "Average Call Length for all Calls in seconds: $average_call_seconds\n";
if (eregi("YES",$include_rollover))
{$OUToutput .= "Calls that went to rollover In-Group: $inTOTALcalls\n";}
$OUToutput .= "\n";
$OUToutput .= "---------- HUMAN ANSWERS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and status IN($customer_interactive_statuses) $group_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {$OUToutput .= "$stmt\n";}
$row=mysql_fetch_row($rslt);
$CIcallsRAW = $row[0];
$CIsec = $row[1];
if (eregi("YES",$include_rollover))
{
$length_in_secZ=0;
$queue_secondsZ=0;
$agent_alert_delayZ=0;
$stmt="select length_in_sec,queue_seconds,agent_alert_delay from vicidial_closer_log,vicidial_inbound_groups where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and group_id=campaign_id and vicidial_closer_log.status IN($customer_interactive_statuses) $group_drop_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$INallcalls_to_printZ = mysql_num_rows($rslt);
$y=0;
while ($y < $INallcalls_to_printZ)
{
$row=mysql_fetch_row($rslt);
$length_in_secZ = $row[0];
$queue_secondsZ = $row[1];
$agent_alert_delayZ = $row[2];
$CIdelay = round($agent_alert_delayZ / 1000);
$thiscallsec = (($length_in_secZ - $queue_secondsZ) - $CIdelay);
if ($thiscallsec < 0)
{$thiscallsec = 0;}
$inCIsec = ($inCIsec + $thiscallsec);
$y++;
}
$inCIcallsRAW = $y;
$CIsec = ($CIsec + $inCIsec);
$CIcallsRAW = ($CIcallsRAW + $inCIcallsRAW);
}
$CIcalls = sprintf("%10s", $CIcallsRAW);
if ( ($CIcallsRAW < 1) or ($CIsec < 1) )
{$average_ci_seconds = ' 0';}
else
{
$average_ci_seconds = ($CIsec / $CIcallsRAW);
$average_ci_seconds = round($average_ci_seconds, 2);
$average_ci_seconds = sprintf("%10s", $average_ci_seconds);
}
$CIsec = sec_convert($CIsec,'H');
$OUToutput .= "Total Human Answered calls for this Campaign: $CIcalls\n";
$OUToutput .= "Average Call Length for all HA in seconds: $average_ci_seconds Total Time: $CIsec\n";
$OUToutput .= "\n";
$OUToutput .= "---------- DROPS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and status='DROP' and (length_in_sec <= 6000 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {$OUToutput .= "$stmt\n";}
$row=mysql_fetch_row($rslt);
$DROPcalls = sprintf("%10s", $row[0]);
$DROPcallsRAW = $row[0];
$DROPseconds = $row[1];
# GET LIST OF ALL STATUSES and create SQL from human_answered statuses
$q=0;
$stmt = "SELECT status,status_name,human_answered,category from vicidial_statuses;";
$rslt=mysql_query($stmt, $link);
if ($DB) {$OUToutput .= "$stmt\n";}
$statuses_to_print = mysql_num_rows($rslt);
$p=0;
while ($p < $statuses_to_print)
{
$row=mysql_fetch_row($rslt);
$status[$q] = $row[0];
$status_name[$q] = $row[1];
$human_answered[$q] = $row[2];
$category[$q] = $row[3];
$statname_list["$status[$q]"] = "$status_name[$q]";
$statcat_list["$status[$q]"] = "$category[$q]";
if ($human_answered[$q]=='Y')
{$camp_ANS_STAT_SQL .= "'$row[0]',";}
$q++;
$p++;
}
$stmt = "SELECT distinct status,status_name,human_answered,category from vicidial_campaign_statuses $group_SQL;";
$rslt=mysql_query($stmt, $link);
if ($DB) {$OUToutput .= "$stmt\n";}
$statuses_to_print = mysql_num_rows($rslt);
$p=0;
while ($p < $statuses_to_print)
{
$row=mysql_fetch_row($rslt);
$status[$q] = $row[0];
$status_name[$q] = $row[1];
$human_answered[$q] = $row[2];
$category[$q] = $row[3];
$statname_list["$status[$q]"] = "$status_name[$q]";
$statcat_list["$status[$q]"] = "$category[$q]";
if ($human_answered[$q]=='Y')
{$camp_ANS_STAT_SQL .= "'$row[0]',";}
$q++;
$p++;
}
$camp_ANS_STAT_SQL = eregi_replace(",$",'',$camp_ANS_STAT_SQL);
$stmt="select count(*) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and status IN($camp_ANS_STAT_SQL);";
$rslt=mysql_query($stmt, $link);
if ($DB) {$OUToutput .= "$stmt\n";}
$row=mysql_fetch_row($rslt);
$ANSWERcalls = $row[0];
if ( ($DROPcalls < 1) or ($TOTALcalls < 1) )
{$DROPpercent = '0';}
else
{
$DROPpercent = (($DROPcallsRAW / $TOTALcalls) * 100);
$DROPpercent = round($DROPpercent, 2);
}
if ( ($DROPcalls < 1) or ($ANSWERcalls < 1) )
{$DROPANSWERpercent = '0';}
else
{
$DROPANSWERpercent = (($DROPcallsRAW / $ANSWERcalls) * 100);
$DROPANSWERpercent = round($DROPANSWERpercent, 2);
}
if ( ($DROPseconds < 1) or ($DROPcallsRAW < 1) )
{$average_hold_seconds = ' 0';}
else
{
$average_hold_seconds = ($DROPseconds / $DROPcallsRAW);
$average_hold_seconds = round($average_hold_seconds, 2);
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
}
$OUToutput .= "Total Outbound DROP Calls: $DROPcalls $DROPpercent%\n";
$OUToutput .= "Percent of DROP Calls taken out of Answers: $DROPcalls / $ANSWERcalls $DROPANSWERpercent%\n";
if (eregi("YES",$include_rollover))
{
if ( ($DROPcalls < 1) or ($CIcallsRAW < 1) )
{$inDROPANSWERpercent = '0';}
else
{
$inDROPANSWERpercent = (($DROPcallsRAW / $CIcallsRAW) * 100);
$inDROPANSWERpercent = round($inDROPANSWERpercent, 2);
}
$OUToutput .= "Percent of DROP/Answer Calls with Rollover: $DROPcalls / $CIcallsRAW $inDROPANSWERpercent%\n";
}
$OUToutput .= "Average Length for DROP Calls in seconds: $average_hold_seconds\n";
$stmt = "select closer_campaigns from vicidial_campaigns $group_SQL;";
$rslt=mysql_query($stmt, $link);
$ccamps_to_print = mysql_num_rows($rslt);
$c=0;
while ($ccamps_to_print > $c)
{
$row=mysql_fetch_row($rslt);
$closer_campaigns = $row[0];
$closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns);
$closer_campaigns = preg_replace("/ /","','",$closer_campaigns);
$closer_campaignsSQL .= "'$closer_campaigns',";
$c++;
}
$closer_campaignsSQL = eregi_replace(",$",'',$closer_campaignsSQL);
$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($closer_campaignsSQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE');";
$rslt=mysql_query($stmt, $link);
if ($DB) {$OUToutput .= "$stmt\n";}
$row=mysql_fetch_row($rslt);
$TOTALanswers = ($row[0] + $ANSWERcalls);
$stmt = "SELECT sum(wait_sec + talk_sec + dispo_sec) from vicidial_agent_log where event_time >= '$query_date_BEGIN' and event_time <= '$query_date_END' and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 $group_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {$OUToutput .= "$stmt\n";}
$row=mysql_fetch_row($rslt);
$agent_non_pause_sec = $row[0];
if ($agent_non_pause_sec > 0)
{
$AVG_ANSWERagent_non_pause_sec = (($TOTALanswers / $agent_non_pause_sec) * 60);
$AVG_ANSWERagent_non_pause_sec = round($AVG_ANSWERagent_non_pause_sec, 2);
}
else
{$AVG_ANSWERagent_non_pause_sec=0;}
$AVG_ANSWERagent_non_pause_sec = sprintf("%10s", $AVG_ANSWERagent_non_pause_sec);
$OUToutput .= "Productivity Rating: $AVG_ANSWERagent_non_pause_sec\n";
$OUToutput .= "\n";
$OUToutput .= "---------- NO ANSWERS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and status IN('NA','ADC','AB','CPDB','CPDUK','CPDATB','CPDNA','CPDREJ','CPDINV','CPDSUA','CPDSI','CPDSNC','CPDSR','CPDSUK','CPDSV','CPDERR') and (length_in_sec <= 60 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {$OUToutput .= "$stmt\n";}
$row=mysql_fetch_row($rslt);
$autoNAcalls = sprintf("%10s", $row[0]);
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and status IN('B','DC','N') and (length_in_sec <= 60 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {$OUToutput .= "$stmt\n";}
$row=mysql_fetch_row($rslt);
$manualNAcalls = sprintf("%10s", $row[0]);
$totalNAcalls = ($autoNAcalls + $manualNAcalls);
$totalNAcalls = sprintf("%10s", $totalNAcalls);
if ( ($totalNAcalls < 1) or ($TOTALcalls < 1) )
{$NApercent = '0';}
else
{
$NApercent = (($totalNAcalls / $TOTALcalls) * 100);
$NApercent = round($NApercent, 2);
}
if ( ($row[0] < 1) or ($row[1] < 1) )
{$average_na_seconds = ' 0';}
else
{
$average_na_seconds = ($row[1] / $row[0]);
$average_na_seconds = round($average_na_seconds, 2);
$average_na_seconds = sprintf("%10s", $average_na_seconds);
}
$OUToutput .= "Total NA calls -Busy,Disconnect,RingNoAnswer: $totalNAcalls $NApercent%\n";
$OUToutput .= "Total auto NA calls -system-set: $autoNAcalls\n";
$OUToutput .= "Total manual NA calls -agent-set: $manualNAcalls\n";
$OUToutput .= "Average Call Length for NA Calls in seconds: $average_na_seconds\n";
##############################
######### CALL HANGUP REASON STATS
$TOTALcalls = 0;
$ASCII_text .= "\n";
$ASCII_text .= "---------- CALL HANGUP REASON STATS\n";
$ASCII_text .= "+----------------------+------------+\n";
$ASCII_text .= "| HANGUP REASON | CALLS |\n";
$ASCII_text .= "+----------------------+------------+\n";
$GRAPH.="
\n";
$GRAPH.="CALL HANGUP REASON STATS";
$GRAPH.="\n";
$GRAPH.="| DID | \n";
$GRAPH.="CALLS | \n";
$GRAPH.=" \n";
$stmt="select count(*),term_reason from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand group by term_reason;";
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
if ($DB) {$ASCII_text .= "$stmt\n";}
$reasons_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $reasons_to_print)
{
$row=mysql_fetch_row($rslt);
$TOTALcalls = ($TOTALcalls + $row[0]);
$REASONcount = sprintf("%10s", $row[0]);while(strlen($REASONcount)>10) {$REASONcount = substr("$REASONcount", 0, -1);}
$reason = sprintf("%-20s", $row[1]);while(strlen($reason)>20) {$reason = substr("$reason", 0, -1);}
if (ereg("NONE",$reason)) {$reason = 'NO ANSWER ';}
if (ereg("CALLER",$reason)) {$reason = 'CUSTOMER ';}
$ASCII_text .= "| $reason | $REASONcount |\n";
if ($row[0]>$max_calls) {$max_calls=$row[0];}
$graph_stats[$i][0]=$row[0];
$graph_stats[$i][1]=$row[1];
$i++;
}
$TOTALcalls = sprintf("%10s", $TOTALcalls);
$ASCII_text .= "+----------------------+------------+\n";
$ASCII_text .= "| TOTAL: | $TOTALcalls |\n";
$ASCII_text .= "+----------------------+------------+\n";
for ($d=0; $d\n";
$GRAPH.=" ".$graph_stats[$d][1]." | \n";
$GRAPH.=" ".$graph_stats[$d][0]." | \n";
$GRAPH.=" \n";
}
$GRAPH.=" \n";
$GRAPH.=" | TOTAL: | \n";
$GRAPH.=" ".trim($TOTALcalls)." | \n";
$GRAPH.=" \n";
$GRAPH.=" \n";
$GRAPH_text.=$GRAPH;
##############################
######### CALL STATUS STATS
$TOTALcalls = 0;
$ASCII_text .= "\n";
$ASCII_text .= "---------- CALL STATUS STATS\n";
$ASCII_text .= "+--------+----------------------+----------------------+------------+----------------------------------+----------+\n";
$ASCII_text .= "| | | | | CALL TIME |AGENT TIME|\n";
$ASCII_text .= "| STATUS | DESCRIPTION | CATEGORY | CALLS | TOTAL TIME | AVG TIME |CALLS/HOUR|CALLS/HOUR|\n";
$ASCII_text .= "+--------+----------------------+----------------------+------------+------------+----------+----------+----------+\n";
######## GRAPHING #########
$GRAPH="
";
$graph_stats=array();
$max_calls=1;
$max_total_time=1;
$max_avg_time=1;
$max_callshr=1;
$max_agentcallshr=1;
$graph_header="CALL STATUS STATS| STATUS | ";
$CALLS_graph=$graph_header."CALLS | ";
$TOTALTIME_graph=$graph_header."TOTAL TIME | ";
$AVGTIME_graph=$graph_header."AVG TIME | ";
$CALLSHOUR_graph=$graph_header."CALLS/HR | ";
$CALLSHOUR_agent_graph=$graph_header."AGENT CALLS/HR | ";
###########################
$campaignSQL = "$group_SQLand";
if (eregi("YES",$include_rollover))
{$campaignSQL = "$both_group_SQLand";}
## Pull the count of agent seconds for the total tally
$stmt="SELECT sum(pause_sec + wait_sec + talk_sec + dispo_sec) from vicidial_agent_log where event_time >= '$query_date_BEGIN' and event_time <= '$query_date_END' $campaignSQL and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000;";
$rslt=mysql_query($stmt, $link);
$Ctally_to_print = mysql_num_rows($rslt);
if ($Ctally_to_print > 0)
{
$rowx=mysql_fetch_row($rslt);
$AGENTsec = "$rowx[0]";
}
if ($DB) {$ASCII_text .= "$AGENTsec|$Ctally_to_print|$stmt\n";}
## get counts and time totals for all statuses in this campaign
$rollover_exclude_dropSQL='';
if (eregi("YES",$include_rollover))
{$rollover_exclude_dropSQL = "and status NOT IN('DROP')";}
$stmt="select count(*),status,sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $rollover_exclude_dropSQL $group_SQLand group by status;";
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
if ($DB) {$ASCII_text .= "$stmt\n";}
$statuses_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $statuses_to_print)
{
$row=mysql_fetch_row($rslt);
$STATUScountARY[$i] = $row[0];
$RAWstatusARY[$i] = $row[1];
$RAWhoursARY[$i] = $row[2];
$statusSQL .= "'$row[1]',";
$i++;
}
if (eregi("YES",$include_rollover))
{
if (strlen($statusSQL) < 2)
{$statusSQL = "''";}
else
{
$statusSQL = eregi_replace(",$",'',$statusSQL);
}
$stmt="select distinct status from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and status NOT IN($statusSQL) $group_drop_SQLand;";
$rslt=mysql_query($stmt, $link);
$inS_statuses_to_print = mysql_num_rows($rslt);
$n=0;
while ($inS_statuses_to_print > $n)
{
$rowx=mysql_fetch_row($rslt);
$STATUScountARY[$i] = 0;
$RAWstatusARY[$i] = $rowx[0];
$RAWhoursARY[$i] = 0;
$i++;
$n++;
$statuses_to_print++;
}
}
$i=0;
while ($i < $statuses_to_print)
{
$STATUScount = $STATUScountARY[$i];
$RAWstatus = $RAWstatusARY[$i];
$RAWhours = $RAWhoursARY[$i];
if (eregi("YES",$include_rollover))
{
$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and status='$RAWstatus' $group_drop_SQLand;";
$rslt=mysql_query($stmt, $link);
$in_statuses_to_print = mysql_num_rows($rslt);
if ($in_statuses_to_print > 0)
{
$rowx=mysql_fetch_row($rslt);
$inSTATUScount = $rowx[0];
$inRAWhours = $rowx[1];
$STATUScount = ($STATUScount + $inSTATUScount);
$RAWhours = ($RAWhours + $inRAWhours);
}
}
$r=0;
while ($r < $statcats_to_print)
{
if ($statcat_list[$RAWstatus] == "$vsc_id[$r]")
{
$vsc_count[$r] = ($vsc_count[$r] + $STATUScount);
}
$r++;
}
if ($AGENTsec < 1) {$AGENTsec=1;}
$TOTALcalls = ($TOTALcalls + $STATUScount);
$TOTALtimeS = ($TOTALtimeS + $RAWhours);
$STATUSrate = ($STATUScount / ($TOTALsec / 3600) );
$STATUSrate = sprintf("%.2f", $STATUSrate);
$AGENTrate = ($STATUScount / ($AGENTsec / 3600) );
$AGENTrate = sprintf("%.2f", $AGENTrate);
if ($STATUScount>$max_calls) {$max_calls=$STATUScount;}
if ($RAWhours>$max_total_time) {$max_total_time=$RAWhours;}
if ($STATUSavg_sec>$max_avg_time) {$max_avg_time=$STATUSavg_sec;}
if ($STATUSrate>$max_callshr) {$max_callshr=$STATUSrate;}
if ($AGENTrate>$max_agentcallshr) {$max_agentcallshr=$AGENTrate;}
$graph_stats[$i][1]=$STATUScount;
$graph_stats[$i][2]=$RAWhours;
$graph_stats[$i][3]=($RAWhours / $STATUScount);
$graph_stats[$i][4]=$STATUSrate;
$graph_stats[$i][5]=$AGENTrate;
$STATUShours = sec_convert($RAWhours,'H');
$STATUSavg_sec = ($RAWhours / $STATUScount);
$STATUSavg = sec_convert($STATUSavg_sec,'H');
$STATUScount = sprintf("%10s", $STATUScount);while(strlen($STATUScount)>10) {$STATUScount = substr("$STATUScount", 0, -1);}
$status = sprintf("%-6s", $RAWstatus);while(strlen($status)>6) {$status = substr("$status", 0, -1);}
$STATUShours = sprintf("%10s", $STATUShours);while(strlen($STATUShours)>10) {$STATUShours = substr("$STATUShours", 0, -1);}
$STATUSavg = sprintf("%8s", $STATUSavg);while(strlen($STATUSavg)>8) {$STATUSavg = substr("$STATUSavg", 0, -1);}
$STATUSrate = sprintf("%8s", $STATUSrate);while(strlen($STATUSrate)>8) {$STATUSrate = substr("$STATUSrate", 0, -1);}
$AGENTrate = sprintf("%8s", $AGENTrate);while(strlen($AGENTrate)>8) {$AGENTrate = substr("$AGENTrate", 0, -1);}
if ($non_latin < 1)
{
$status_name = sprintf("%-20s", $statname_list[$RAWstatus]);
while(strlen($status_name)>20) {$status_name = substr("$status_name", 0, -1);}
$statcat = sprintf("%-20s", $statcat_list[$RAWstatus]);
while(strlen($statcat)>20) {$statcat = substr("$statcat", 0, -1);}
}
else
{
$status_name = sprintf("%-60s", $statname_list[$RAWstatus]);
while(mb_strlen($status_name,'utf-8')>20) {$status_name = mb_substr("$status_name", 0, -1,'utf-8');}
$statcat = sprintf("%-60s", $statcat_list[$RAWstatus]);
while(mb_strlen($statcat,'utf-8')>20) {$statcat = mb_substr("$statcat", 0, -1,'utf-8');}
}
$graph_stats[$i][0]="$status - $status_name - $statcat";
$ASCII_text .= "| $status | $status_name | $statcat | $STATUScount | $STATUShours | $STATUSavg | $STATUSrate | $AGENTrate |\n";
$i++;
}
if ($TOTALcalls < 1)
{
$TOTALhours = '0:00:00';
$TOTALavg = '0:00:00';
$TOTALrate = '0.00';
}
else
{
$TOTALrate = ($TOTALcalls / ($TOTALsec / 3600) );
$TOTALrate = sprintf("%.2f", $TOTALrate);
$aTOTALrate = ($TOTALcalls / ($AGENTsec / 3600) );
$aTOTALrate = sprintf("%.2f", $aTOTALrate);
$aTOTALhours = sec_convert($AGENTsec,'H');
$TOTALhours = sec_convert($TOTALtimeS,'H');
$TOTALavg_sec = ($TOTALtimeS / $TOTALcalls);
$TOTALavg = sec_convert($TOTALavg_sec,'H');
}
$TOTALcalls = sprintf("%10s", $TOTALcalls);
$TOTALhours = sprintf("%10s", $TOTALhours);while(strlen($TOTALhours)>10) {$TOTALhours = substr("$TOTALhours", 0, -1);}
$aTOTALhours = sprintf("%10s", $aTOTALhours);while(strlen($aTOTALhours)>10) {$aTOTALhours = substr("$aTOTALhours", 0, -1);}
$TOTALavg = sprintf("%8s", $TOTALavg);while(strlen($TOTALavg)>8) {$TOTALavg = substr("$TOTALavg", 0, -1);}
$TOTALrate = sprintf("%8s", $TOTALrate);while(strlen($TOTALrate)>8) {$TOTALrate = substr("$TOTALrate", 0, -1);}
$aTOTALrate = sprintf("%8s", $aTOTALrate);while(strlen($aTOTALrate)>8) {$aTOTALrate = substr("$aTOTALrate", 0, -1);}
$ASCII_text .= "+--------+----------------------+----------------------+------------+------------+----------+----------+----------+\n";
$ASCII_text .= "| TOTAL: | $TOTALcalls | $TOTALhours | $TOTALavg | $TOTALrate | |\n";
# $ASCII_text .= "| AGENT TIME | $aTOTALhours | | $aTOTALrate |\n";
$ASCII_text .= "+------------------------------------------------------+------------+------------+---------------------+----------+\n";
for ($d=0; $d".$graph_stats[$d][0]." | ".$graph_stats[$d][1]." | ";
$TOTALTIME_graph.=" | ".$graph_stats[$d][0]." | ".sec_convert($graph_stats[$d][2], 'H')." | ";
$AVGTIME_graph.=" | ".$graph_stats[$d][0]." | ".sec_convert($graph_stats[$d][3], 'H')." | ";
$CALLSHOUR_graph.=" | ".$graph_stats[$d][0]." | ".$graph_stats[$d][4]." | ";
$CALLSHOUR_agent_graph.=" | ".$graph_stats[$d][0]." | ".$graph_stats[$d][5]." | ";
}
$CALLS_graph.="| TOTAL: | ".trim($TOTALcalls)." |
|---|
";
$TOTALTIME_graph.="| TOTAL: | ".trim($TOTALhours)." |
|---|
|