";
$MAIN.="Real-Time All Campaigns Summary \n";
$MAIN.="STOP | ";
$MAIN.="SLOW | ";
$MAIN.="GO ";
$MAIN.=" \n";
if ($adastats<2)
{
$MAIN.="+ VIEW MORE SETTINGS";
}
else
{
$MAIN.="- VIEW LESS SETTINGS";
}
$MAIN.=" DOWNLOAD | REPORTS";
$MAIN.="\n";
$MAIN.="\n";
$MAIN.="\n";
$MAIN.="\n";
$MAIN.=" \n";
$MAIN.="\n";
$MAIN.="
\n\n";
$k=0;
while($k<$groups_to_print)
{
$NFB = '';
$NFE = '';
$F=''; $FG=''; $B=''; $BG='';
$group = $groups[$k];
$MAIN.="$group - ";
$MAIN.="Modify\n";
$CSV_text.="\"$group\"\n";
$stmt = "select count(*) from vicidial_campaigns where campaign_id='$group' and campaign_allow_inbound='Y';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$campaign_allow_inbound = $row[0];
$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level,dial_method,adaptive_maximum_level,adaptive_dropped_percentage,adaptive_dl_diff_target,adaptive_intensity,available_only_ratio_tally,adaptive_latest_server_time,local_call_time,dial_timeout,dial_statuses from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$DIALlev = $row[0];
$DIALstatusA = $row[1];
$DIALstatusB = $row[2];
$DIALstatusC = $row[3];
$DIALstatusD = $row[4];
$DIALstatusE = $row[5];
$DIALorder = $row[6];
$DIALfilter = $row[7];
$HOPlev = $row[8];
$DIALmethod = $row[9];
$maxDIALlev = $row[10];
$DROPmax = $row[11];
$targetDIFF = $row[12];
$ADAintense = $row[13];
$ADAavailonly = $row[14];
$TAPERtime = $row[15];
$CALLtime = $row[16];
$DIALtimeout = $row[17];
$DIALstatuses = $row[18];
$DIALstatuses = (preg_replace("/ -$|^ /","",$DIALstatuses));
$DIALstatuses = (preg_replace('/\s/', ', ', $DIALstatuses));
$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$VDhop = $row[0];
$stmt="select dialable_leads,calls_today,drops_today,drops_answers_today_pct,differential_onemin,agents_average_onemin,balance_trunk_fill,answers_today,status_category_1,status_category_count_1,status_category_2,status_category_count_2,status_category_3,status_category_count_3,status_category_4,status_category_count_4,agent_calls_today,agent_wait_today,agent_custtalk_today,agent_acw_today,agent_pause_today from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$DAleads = $row[0];
$callsTODAY = $row[1];
$dropsTODAY = $row[2];
$drpctTODAY = $row[3];
$diffONEMIN = $row[4];
$agentsONEMIN = $row[5];
$balanceFILL = $row[6];
$answersTODAY = $row[7];
$VSCcat1 = $row[8];
$VSCcat1tally = $row[9];
$VSCcat2 = $row[10];
$VSCcat2tally = $row[11];
$VSCcat3 = $row[12];
$VSCcat3tally = $row[13];
$VSCcat4 = $row[14];
$VSCcat4tally = $row[15];
$VSCagentcalls = $row[16];
$VSCagentwait = $row[17];
$VSCagentcust = $row[18];
$VSCagentacw = $row[19];
$VSCagentpause = $row[20];
if ( ($diffONEMIN != 0) and ($agentsONEMIN > 0) )
{
$diffpctONEMIN = ( ($diffONEMIN / $agentsONEMIN) * 100);
$diffpctONEMIN = sprintf("%01.2f", $diffpctONEMIN);
}
else {$diffpctONEMIN = '0.00';}
$stmt="select sum(local_trunk_shortage) from vicidial_campaign_server_stats where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$balanceSHORT = $row[0];
$MAIN.="
";
$MAIN.="| DIAL LEVEL: | $DIALlev | ";
$MAIN.="TRUNK SHORT/FILL: | $balanceSHORT / $balanceFILL | ";
$MAIN.="FILTER: | $DIALfilter | ";
$MAIN.=" TIME: | $NOW_TIME | ";
$MAIN.="";
$MAIN.=" ";
$CSV_text.="\"DIAL LEVEL:\",\"$DIALlev\",\"TRUNK SHORT/FILL:\",\"$balanceSHORT / $balanceFILL\",\"FILTER:\",\"$DIALfilter\",\"TIME:\",\"$NOW_TIME\"\n";
if ($adastats>1)
{
$MAIN.="";
$MAIN.="| MAX LEVEL: | $maxDIALlev | ";
$MAIN.="DROPPED MAX: | $DROPmax% | ";
$MAIN.="TARGET DIFF: | $targetDIFF | ";
$MAIN.="INTENSITY: | $ADAintense | ";
$MAIN.=" ";
$CSV_text.="\"MAX LEVEL:\",\"$maxDIALlev\",\"DROPPED MAX:\",\"$DROPmax\",\"TARGET DIFF:\",\"$targetDIFF\",\"INTENSITY:\",\"$ADAintense\"\n";
$MAIN.="";
$MAIN.="| DIAL TIMEOUT: | $DIALtimeout | ";
$MAIN.="TAPER TIME: | $TAPERtime | ";
$MAIN.="LOCAL TIME: | $CALLtime | ";
$MAIN.="AVAIL ONLY: | $ADAavailonly | ";
$MAIN.=" ";
$CSV_text.="\"DIAL TIMEOUT:\",\"$DIALtimeout\",\"TAPER TIME:\",\"$TAPERtime\",\"LOCAL TIME:\",\"$CALLtime\",\"AVAIL ONLY:\",\"$ADAavailonly\"\n";
}
$MAIN.="";
$MAIN.="| DIALABLE LEADS: | $DAleads | ";
$MAIN.="CALLS TODAY: | $callsTODAY | ";
$MAIN.="AVG AGENTS: | $agentsONEMIN | ";
$MAIN.="DIAL METHOD: | $DIALmethod | ";
$MAIN.=" ";
$CSV_text.="\"DIALABLE LEADS:\",\"$DAleads\",\"CALLS TODAY:\",\"$callsTODAY\",\"AVG AGENTS:\",\"$agentsONEMIN\",\"DIAL METHOD:\",\"$DIALmethod\"\n";
$MAIN.="";
$MAIN.="| HOPPER LEVEL: | $HOPlev | ";
$MAIN.="DROPPED / ANSWERED: | $dropsTODAY / $answersTODAY | ";
$MAIN.="DL DIFF: | $diffONEMIN | ";
$MAIN.="STATUSES: | $DIALstatuses | ";
$MAIN.=" ";
$CSV_text.="\"HOPPER LEVEL:\",\"$HOPlev\",\"DROPPED / ANSWERED:\",\"$dropsTODAY / $answersTODAY\",\"DL DIFF:\",\"$diffONEMIN\",\"STATUSES:\",\"$DIALstatuses\"\n";
$MAIN.="";
$MAIN.="| LEADS IN HOPPER: | $VDhop | ";
$MAIN.="DROPPED PERCENT: | ";
if ($drpctTODAY >= $DROPmax)
{$MAIN.="$drpctTODAY%";}
else
{$MAIN.="$drpctTODAY%";}
$MAIN.=" | ";
$MAIN.="DIFF: | $diffpctONEMIN% | ";
$MAIN.="ORDER: | $DIALorder | ";
$MAIN.=" ";
$CSV_text.="\"LEADS IN HOPPER:\",\"$VDhop\",\"DROPPED PERCENT:\",\"$drpctTODAY%\",\"DIFF:\",\"$diffpctONEMIN%\",\"ORDER:\",\"$DIALorder\"\n";
$MAIN.="";
$MAIN.="| ";
if ( (!preg_match('/NULL/i',$VSCcat1)) and (strlen($VSCcat1)>0) )
{$MAIN.="$VSCcat1: $VSCcat1tally \n";}
if ( (!preg_match('/NULL/i',$VSCcat2)) and (strlen($VSCcat2)>0) )
{$MAIN.="$VSCcat2: $VSCcat2tally \n";}
if ( (!preg_match('/NULL/i',$VSCcat3)) and (strlen($VSCcat3)>0) )
{$MAIN.="$VSCcat3: $VSCcat3tally \n";}
if ( (!preg_match('/NULL/i',$VSCcat4)) and (strlen($VSCcat4)>0) )
{$MAIN.="$VSCcat4: $VSCcat4tally \n";}
$MAIN.=" | ";
$CSV_text.="\"$VSCcat1:\",\"$VSCcat1tally\",\"$VSCcat2:\",\"$VSCcat2tally\",\"$VSCcat3:\",\"$VSCcat3tally\",\"$VSCcat4:\",\"$VSCcat4tally\"\n";
if ($VSCagentcalls > 0)
{
if ( ($VSCagentcalls > 0) and ($VSCagentpause > 0) )
{
$avgpauseTODAY = ($VSCagentpause / $VSCagentcalls);
$avgpauseTODAY = round($avgpauseTODAY, 0);
$avgpauseTODAY = sprintf("%01.0f", $avgpauseTODAY);
}
else
{$avgpauseTODAY=0;}
if ( ($VSCagentcalls > 0) and ($VSCagentwait > 0) )
{
$avgwaitTODAY = ($VSCagentwait / $VSCagentcalls);
$avgwaitTODAY = round($avgwaitTODAY, 0);
$avgwaitTODAY = sprintf("%01.0f", $avgwaitTODAY);
}
else
{$avgwaitTODAY=0;}
if ( ($VSCagentcalls > 0) and ($VSCagentcust > 0) )
{
$avgcustTODAY = ($VSCagentcust / $VSCagentcalls);
$avgcustTODAY = round($avgcustTODAY, 0);
$avgcustTODAY = sprintf("%01.0f", $avgcustTODAY);
}
else
{$avgcustTODAY=0;}
if ( ($VSCagentcalls > 0) and ($VSCagentacw > 0) )
{
$avgacwTODAY = ($VSCagentacw / $VSCagentcalls);
$avgacwTODAY = round($avgacwTODAY, 0);
$avgacwTODAY = sprintf("%01.0f", $avgacwTODAY);
}
else
{$avgacwTODAY=0;}
$MAIN.="";
$MAIN.="| AGENT AVG WAIT: | $avgwaitTODAY | ";
$MAIN.="AVG CUSTTIME: | $avgcustTODAY | ";
$MAIN.="AVG ACW: | $avgacwTODAY | ";
$MAIN.="AVG PAUSE: | $avgpauseTODAY | ";
$MAIN.=" ";
$CSV_text.="\"AGENT AVG WAIT:\",\"$avgwaitTODAY\",\"AVG CUSTTIME:\",\"$avgcustTODAY\",\"AVG ACW:\",\"$avgacwTODAY\",\"AVG PAUSE:\",\"$avgpauseTODAY\"\n";
}
$MAIN.="";
$MAIN.="";
### Header finish
################################################################################
### START calculating calls/agents
################################################################################
################################################################################
###### OUTBOUND CALLS
################################################################################
if ($campaign_allow_inbound > 0)
{
$stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$closer_campaigns = preg_replace("/^ | -$/","",$row[0]);
$closer_campaigns = preg_replace("/ /","','",$closer_campaigns);
$closer_campaigns = "'$closer_campaigns'";
$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );";
}
else
{
if ($group=='XXXX-ALL-ACTIVE-XXXX') {$groupSQL = '';}
else {$groupSQL = " and campaign_id='" . mysql_real_escape_string($group) . "'";}
$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') $groupSQL;";
}
$rslt=mysql_query($stmt, $link);
if ($DB) {$MAIN.="$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
if ($parked_to_print > 0)
{
$i=0;
$out_total=0;
$out_ring=0;
$out_live=0;
$in_ivr=0;
while ($i < $parked_to_print)
{
$row=mysql_fetch_row($rslt);
if (preg_match("/LIVE/i",$row[0]))
{$out_live++;}
else
{
if (preg_match("/IVR/i",$row[0]))
{$in_ivr++;}
if (preg_match("/CLOSER/i",$row[0]))
{$nothing=1;}
else
{$out_ring++;}
}
$out_total++;
$i++;
}
if ($out_live > 0) {$F=''; $FG='';}
if ($out_live > 4) {$F=''; $FG='';}
if ($out_live > 9) {$F=''; $FG='';}
if ($out_live > 14) {$F=''; $FG='';}
if ($campaign_allow_inbound > 0)
{
$MAIN.="$NFB$out_total$NFE current active calls \n";
$CSV_text.="\"$out_total current active calls\",\"\"\n";
}
else
{
$MAIN.="$NFB$out_total$NFE calls being placed \n";
$CSV_text.="\"$NFB$out_total$NFE calls being placed\",\"\"\n";
}
$MAIN.="$NFB$out_ring$NFE calls ringing \n";
$MAIN.="$NFB$F $out_live $FG$NFE calls waiting for agents \n";
$MAIN.="$NFB $in_ivr$NFE calls in IVR \n";
$CSV_text.="\"$out_ring calls ringing\",\"$out_live calls waiting for agents\",\"$in_ivr calls in IVR\"\n";
}
else
{
$MAIN.=" NO LIVE CALLS WAITING \n";
$CSV_text.="\"NO LIVE CALLS WAITING\"\n";
}
###################################################################################
###### TIME ON SYSTEM
###################################################################################
$agent_incall=0;
$agent_ready=0;
$agent_paused=0;
$agent_total=0;
$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "';";
$rslt=mysql_query($stmt, $link);
if ($DB) {$MAIN.="$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
if ($talking_to_print > 0)
{
$i=0;
$agentcount=0;
while ($i < $talking_to_print)
{
$row=mysql_fetch_row($rslt);
if (preg_match("/READY|PAUSED/i",$row[3]))
{
$row[5]=$row[6];
}
$Lstatus = $row[3];
$status = sprintf("%-6s", $row[3]);
if (!preg_match("/INCALL|QUEUE/i",$row[3]))
{$call_time_S = ($STARTtime - $row[6]);}
else
{$call_time_S = ($STARTtime - $row[5]);}
$call_time_M = ($call_time_S / 60);
$call_time_M = round($call_time_M, 2);
$call_time_M_int = intval("$call_time_M");
$call_time_SEC = ($call_time_M - $call_time_M_int);
$call_time_SEC = ($call_time_SEC * 60);
$call_time_SEC = round($call_time_SEC, 0);
if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
$call_time_MS = "$call_time_M_int:$call_time_SEC";
$call_time_MS = sprintf("%7s", $call_time_MS);
$G = ''; $EG = '';
if (preg_match("/PAUSED/i",$row[3]))
{
if ($call_time_M_int >= 30)
{$i++; continue;}
else
{
$agent_paused++; $agent_total++;
}
}
if ( (preg_match("/INCALL/i",$status)) or (preg_match("/QUEUE/i",$status)) ) {$agent_incall++; $agent_total++;}
if ( (preg_match("/READY/i",$status)) or (preg_match("/CLOSER/i",$status)) ) {$agent_ready++; $agent_total++;}
$agentcount++;
$i++;
}
if ($agent_ready > 0) {$B=''; $BG='';}
if ($agent_ready > 4) {$B=''; $BG='';}
if ($agent_ready > 9) {$B=''; $BG='';}
if ($agent_ready > 14) {$B=''; $BG='';}
$MAIN.="\n \n";
$MAIN.="$NFB$agent_total$NFE agents logged in \n";
$MAIN.="$NFB$agent_incall$NFE agents in calls \n";
$MAIN.="$NFB$B $agent_ready $BG$NFE agents waiting \n";
$MAIN.="$NFB$agent_paused$NFE paused agents \n";
$CSV_text.="\"$agent_total agents logged in\",\"$agent_incall agents in calls\",\"$agent_ready agents waiting\",\"$agent_paused paused agents\"\n\n";
$MAIN.="";
$MAIN.="";
}
else
{
$MAIN.=" NO AGENTS ON CALLS \n";
$CSV_text.="\"NO AGENTS ON CALLS\"\n\n";
}
################################################################################
### END calculating calls/agents
################################################################################
$MAIN.=" | ";
$MAIN.=" ";
$MAIN.=" \n\n ";
$k++;
}
$MAIN.="\n\n ";
$MAIN.="\n";
$MAIN.=" |