\n";
echo " \n";
##### vicidial agent talk time and status #####
echo "AGENT TALK TIME AND STATUS:\n";
echo "\n";
echo "| STATUS | COUNT | HOURS:MM:SS | \n";
$stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status";
$rslt=mysql_query($stmt, $link);
$VLstatuses_to_print = mysql_num_rows($rslt);
$total_calls=0;
$o=0; $p=0;
while ($VLstatuses_to_print > $o)
{
$row=mysql_fetch_row($rslt);
$counts[$p] = $row[0];
$status[$p] = $row[1];
$call_sec[$p] = $row[2];
$p++;
$o++;
}
$stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_closer_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status";
$rslt=mysql_query($stmt, $link);
$VCLstatuses_to_print = mysql_num_rows($rslt);
$o=0;
while ($VCLstatuses_to_print > $o)
{
$status_match=0;
$r=0;
$row=mysql_fetch_row($rslt);
while ($VLstatuses_to_print > $r)
{
if ($status[$r] == $row[1])
{
$counts[$r] = ($counts[$r] + $row[0]);
$call_sec[$r] = ($call_sec[$r] + $row[2]);
$status_match++;
}
$r++;
}
if ($status_match < 1)
{
$counts[$p] = $row[0];
$status[$p] = $row[1];
$call_sec[$p] = $row[2];
$VLstatuses_to_print++;
$p++;
}
$o++;
}
$o=0;
$total_sec=0;
while ($o < $p)
{
if (eregi("1$|3$|5$|7$|9$", $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$call_hours_minutes = sec_convert($call_sec[$o],'H');
echo "| $status[$o] | ";
echo " $counts[$o] | \n";
echo " $call_hours_minutes | \n";
$total_calls = ($total_calls + $counts[$o]);
$total_sec = ($total_sec + $call_sec[$o]);
$call_seconds=0;
$o++;
}
$call_hours_minutes = sec_convert($total_sec,'H');
echo "| TOTAL CALLS | $total_calls | $call_hours_minutes | \n";
echo " \n";
##### Login and Logout time from vicidial agent interface #####
echo "
\n";
echo "\n";
echo "AGENT LOGIN/LOGOUT TIME:\n";
echo "\n";
echo "| EVENT | DATE | CAMPAIGN | GROUP | HOURS:MM:SS | \n";
$stmt="SELECT event,event_epoch,event_date,campaign_id,user_group from vicidial_user_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'";
$rslt=mysql_query($stmt, $link);
$events_to_print = mysql_num_rows($rslt);
$total_calls=0;
$o=0;
$event_start_seconds='';
$event_stop_seconds='';
while ($events_to_print > $o) {
$row=mysql_fetch_row($rslt);
if (eregi("LOGIN", $row[0]))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
if (ereg("LOGIN", $row[0]))
{
$event_start_seconds = $row[1];
echo "| $row[0] | ";
echo " $row[2] | \n";
echo " $row[3] | \n";
echo " $row[4] | \n";
echo " | \n";
}
if (ereg("LOGOUT", $row[0]))
{
if ($event_start_seconds)
{
$event_stop_seconds = $row[1];
$event_seconds = ($event_stop_seconds - $event_start_seconds);
$total_login_time = ($total_login_time + $event_seconds);
$event_hours_minutes = sec_convert($event_seconds,'H');
echo "| $row[0] | ";
echo " $row[2] | \n";
echo " $row[3] | \n";
echo " $row[4] | \n";
echo " $event_hours_minutes | \n";
$event_start_seconds='';
$event_stop_seconds='';
}
else
{
echo "| $row[0] | ";
echo " $row[2] | \n";
echo " $row[3] | \n";
echo " | \n";
}
}
$total_calls = ($total_calls + $row[0]);
$call_seconds=0;
$o++;
}
$total_login_hours_minutes = sec_convert($total_login_time,'H');
echo "| TOTAL | ";
echo " | \n";
echo " | \n";
echo " | \n";
echo " $total_login_hours_minutes | \n";
echo " \n";
##### vicidial_timeclock log records for user #####
$total_login_time=0;
$SQday_ARY = explode('-',$begin_date);
$EQday_ARY = explode('-',$end_date);
$SQepoch = mktime(0, 0, 0, $SQday_ARY[1], $SQday_ARY[2], $SQday_ARY[0]);
$EQepoch = mktime(23, 59, 59, $EQday_ARY[1], $EQday_ARY[2], $EQday_ARY[0]);
echo "
\n";
echo "\n";
echo "TIMECLOCK LOGIN/LOGOUT TIME:\n";
echo "\n";
echo "| ID | EDIT | EVENT | DATE | IP ADDRESS | GROUP | HOURS:MM:SS | \n";
$stmt="SELECT event,event_epoch,user_group,login_sec,ip_address,timeclock_id,manager_user from vicidial_timeclock_log where user='" . mysql_real_escape_string($user) . "' and event_epoch >= '$SQepoch' and event_epoch <= '$EQepoch';";
if ($DB>0) {echo "|$stmt|";}
$rslt=mysql_query($stmt, $link);
$events_to_print = mysql_num_rows($rslt);
$total_logs=0;
$o=0;
while ($events_to_print > $o) {
$row=mysql_fetch_row($rslt);
if ( ($row[0]=='START') or ($row[0]=='LOGIN') )
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$TC_log_date = date("Y-m-d H:i:s", $row[1]);
$manager_edit='';
if (strlen($row[6])>0) {$manager_edit = ' * ';}
if (ereg("LOGIN", $row[0]))
{
$login_sec='';
echo "| $row[5] | ";
echo "$manager_edit | ";
echo "$row[0] | ";
echo " $TC_log_date | \n";
echo " $row[4] | \n";
echo " $row[2] | \n";
echo " | \n";
}
if (ereg("LOGOUT", $row[0]))
{
$login_sec = $row[3];
$total_login_time = ($total_login_time + $login_sec);
$event_hours_minutes = sec_convert($login_sec,'H');
echo "| $row[5] | ";
echo "$manager_edit | ";
echo "$row[0] | ";
echo " $TC_log_date | \n";
echo " $row[4] | \n";
echo " $row[2] | \n";
echo " $event_hours_minutes";
if ($DB) {echo " - $total_login_time - $login_sec";}
echo " | \n";
}
$o++;
}
if (strlen($login_sec)<1)
{
$login_sec = ($STARTtime - $row[1]);
$total_login_time = ($total_login_time + $login_sec);
if ($DB) {echo "LOGIN ONLY - $total_login_time - $login_sec";}
}
$total_login_hours_minutes = sec_convert($total_login_time,'H');
if ($DB) {echo " - $total_login_time - $login_sec";}
echo "| | ";
echo " | \n";
echo " | \n";
echo " | \n";
echo "TOTAL | \n";
echo " $total_login_hours_minutes | \n";
echo " \n";
##### closer in-group selection logs #####
echo "
\n";
echo "\n";
echo "CLOSER IN-GROUP SELECTION LOGS:\n";
echo "\n";
echo "| # | DATE/TIME | CAMPAIGN | BLEND | GROUPS | MANAGER | \n";
$stmt="select user,campaign_id,event_date,blended,closer_campaigns,manager_change from vicidial_user_closer_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by event_date desc limit 1000;";
$rslt=mysql_query($stmt, $link);
$logs_to_print = mysql_num_rows($rslt);
$u=0;
while ($logs_to_print > $u)
{
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$u++;
echo "";
echo "| $u | ";
echo "$row[2] | ";
echo " $row[1] | \n";
echo " $row[3] | \n";
echo " $row[4] | \n";
echo " $row[5] | \n";
echo " \n";
}
echo "
\n";
##### vicidial agent outbound calls for this time period #####
echo "OUTBOUND CALLS FOR THIS TIME PERIOD: (10000 record limit)\n";
echo "\n";
echo "| # | DATE/TIME | LENGTH | STATUS | PHONE | CAMPAIGN | GROUP | LIST | LEAD | HANGUP REASON | \n";
$stmt="select uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,user_group,term_reason,alt_dial from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by call_date desc limit 10000;";
$rslt=mysql_query($stmt, $link);
$logs_to_print = mysql_num_rows($rslt);
$u=0;
while ($logs_to_print > $u)
{
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$u++;
echo "";
echo "| $u | ";
echo "$row[4] | ";
echo " $row[7] | \n";
echo " $row[8] | \n";
echo " $row[10] | \n";
echo " $row[3] | \n";
echo " $row[14] | \n";
echo " $row[2] | \n";
echo " $row[1] | \n";
echo " $row[15] | \n";
}
echo "
\n";
##### vicidial agent inbound calls for this time period #####
echo "INBOUND/CLOSER CALLS FOR THIS TIME PERIOD: (10000 record limit)\n";
echo "\n";
echo "| # | DATE/TIME | LENGTH | STATUS | PHONE | CAMPAIGN | WAIT (S) | AGENT (S) | LIST | LEAD | HANGUP REASON | \n";
$stmt="select call_date,length_in_sec,status,phone_number,campaign_id,queue_seconds,list_id,lead_id,term_reason from vicidial_closer_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by call_date desc limit 10000;";
$rslt=mysql_query($stmt, $link);
$logs_to_print = mysql_num_rows($rslt);
$u=0;
$TOTALinSECONDS=0;
$TOTALagentSECONDS=0;
while ($logs_to_print > $u)
{
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$TOTALinSECONDS = ($TOTALinSECONDS + $row[1]);
$AGENTseconds = ($row[1] - $row[5]);
if ($AGENTseconds < 0)
{$AGENTseconds=0;}
$TOTALagentSECONDS = ($TOTALagentSECONDS + $AGENTseconds);
$u++;
echo "";
echo "| $u | ";
echo "$row[0] | ";
echo " $row[1] | \n";
echo " $row[2] | \n";
echo " $row[3] | \n";
echo " $row[4] | \n";
echo " $row[5] | \n";
echo " $AGENTseconds | \n";
echo " $row[6] | \n";
echo " $row[7] | \n";
echo " $row[8] | \n";
}
echo "";
echo "| TOTALS | ";
echo " $TOTALinSECONDS | \n";
echo " | \n";
echo " $TOTALagentSECONDS | \n";
echo " | \n";
echo "
\n";
##### vicidial agent activity records for this time period #####
echo "AGENT ACTIVITY FOR THIS TIME PERIOD: (10000 record limit)\n";
echo "\n";
echo "| | these fields are in seconds | | \n";
echo "| # | DATE/TIME | PAUSE | WAIT | TALK | DISPO | DEAD | CUSTOMER | STATUS | LEAD | CAMPAIGN | PAUSE CODE | \n";
$stmt="select event_time,lead_id,campaign_id,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec,status,sub_status,user_group from vicidial_agent_log where user='" . mysql_real_escape_string($user) . "' and event_time >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_time <= '" . mysql_real_escape_string($end_date) . " 23:59:59' and ( (pause_sec > 0) or (wait_sec > 0) or (talk_sec > 0) or (dispo_sec > 0) ) order by event_time desc limit 10000;";
$rslt=mysql_query($stmt, $link);
$logs_to_print = mysql_num_rows($rslt);
$u=0;
$TOTALpauseSECONDS=0;
$TOTALwaitSECONDS=0;
$TOTALtalkSECONDS=0;
$TOTALdispoSECONDS=0;
$TOTALdeadSECONDS=0;
$TOTALcustomerSECONDS=0;
while ($logs_to_print > $u)
{
$row=mysql_fetch_row($rslt);
$event_time = $row[0];
$lead_id = $row[1];
$campaign_id = $row[2];
$pause_sec = $row[3];
$wait_sec = $row[4];
$talk_sec = $row[5];
$dispo_sec = $row[6];
$dead_sec = $row[7];
$status = $row[8];
$pause_code = $row[9];
$user_group = $row[10];
$customer_sec = ($talk_sec - $dead_sec);
if ($customer_sec < 0)
{$customer_sec=0;}
if (eregi("1$|3$|5$|7$|9$", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$TOTALpauseSECONDS = ($TOTALpauseSECONDS + $pause_sec);
$TOTALwaitSECONDS = ($TOTALwaitSECONDS + $wait_sec);
$TOTALtalkSECONDS = ($TOTALtalkSECONDS + $talk_sec);
$TOTALdispoSECONDS = ($TOTALdispoSECONDS + $dispo_sec);
$TOTALdeadSECONDS = ($TOTALdeadSECONDS + $dead_sec);
$TOTALcustomerSECONDS = ($TOTALcustomerSECONDS + $customer_sec);
$u++;
echo "";
echo "| $u | ";
echo "$event_time | ";
echo " $pause_sec | \n";
echo " $wait_sec | \n";
echo " $talk_sec | \n";
echo " $dispo_sec | \n";
echo " $dead_sec | \n";
echo " $customer_sec | \n";
echo " $status | \n";
echo " $lead_id | \n";
echo " $campaign_id | \n";
echo " $pause_code | \n";
}
echo "";
echo "| TOTALS | ";
echo " $TOTALpauseSECONDS | \n";
echo " $TOTALwaitSECONDS | \n";
echo " $TOTALtalkSECONDS | \n";
echo " $TOTALdispoSECONDS | \n";
echo " $TOTALdeadSECONDS | \n";
echo " $TOTALcustomerSECONDS | \n";
echo " | \n";
$TOTALpauseSECONDShh = sec_convert($TOTALpauseSECONDS,'H');
$TOTALwaitSECONDShh = sec_convert($TOTALwaitSECONDS,'H');
$TOTALtalkSECONDShh = sec_convert($TOTALtalkSECONDS,'H');
$TOTALdispoSECONDShh = sec_convert($TOTALdispoSECONDS,'H');
$TOTALdeadSECONDShh = sec_convert($TOTALdeadSECONDS,'H');
$TOTALcustomerSECONDShh = sec_convert($TOTALcustomerSECONDS,'H');
echo "";
echo "| (in HH:MM:SS) | ";
echo " $TOTALpauseSECONDShh | \n";
echo " $TOTALwaitSECONDShh | \n";
echo " $TOTALtalkSECONDShh | \n";
echo " $TOTALdispoSECONDShh | \n";
echo " $TOTALdeadSECONDShh | \n";
echo " $TOTALcustomerSECONDShh | \n";
echo " | \n";
echo "
\n";
##### vicidial recordings for this time period #####
echo "RECORDINGS FOR THIS TIME PERIOD: (10000 record limit)\n";
echo "\n";
echo "| # | LEAD | DATE/TIME | SECONDS | RECID | FILENAME | LOCATION | \n";
$stmt="select recording_id,channel,server_ip,extension,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,filename,location,lead_id,user,vicidial_id from recording_log where user='" . mysql_real_escape_string($user) . "' and start_time >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and start_time <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by recording_id desc limit 10000;";
$rslt=mysql_query($stmt, $link);
$logs_to_print = mysql_num_rows($rslt);
$u=0;
while ($logs_to_print > $u)
{
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$location = $row[11];
if (strlen($location)>2)
{
$URLserver_ip = $location;
$URLserver_ip = eregi_replace('http://','',$URLserver_ip);
$URLserver_ip = eregi_replace('https://','',$URLserver_ip);
$URLserver_ip = eregi_replace("\/.*",'',$URLserver_ip);
$stmt="select count(*) from servers where server_ip='$URLserver_ip';";
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
if ($rowx[0] > 0)
{
$stmt="select recording_web_link,alt_server_ip from servers where server_ip='$URLserver_ip';";
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
if (eregi("ALT_IP",$rowx[0]))
{
$location = eregi_replace($URLserver_ip, $rowx[1], $location);
}
}
}
if (strlen($location)>30)
{$locat = substr($location,0,27); $locat = "$locat...";}
else
{$locat = $location;}
if (eregi("http",$location))
{$location = "$locat";}
else
{$location = $locat;}
$u++;
echo "";
echo "| $u | ";
echo " $row[12] | ";
echo " $row[4] | \n";
echo " $row[8] | \n";
echo " $row[0] | \n";
echo " $row[10] | \n";
echo " $location | \n";
echo " \n";
}
echo "
\n";
##### vicidial agent outbound user manual calls for this time period #####
echo "MANUAL OUTBOUND CALLS FOR THIS TIME PERIOD: (10000 record limit)\n";
echo "\n";
echo "| # | DATE/TIME | CALL TYPE | SERVER | PHONE | DIALED | LEAD | CALLERID | ALIAS | \n";
$stmt="select call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id from user_call_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' order by call_date desc limit 10000;";
$rslt=mysql_query($stmt, $link);
$logs_to_print = mysql_num_rows($rslt);
$u=0;
while ($logs_to_print > $u) {
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$u++;
echo "";
echo "| $u | ";
echo "$row[0] | ";
echo " $row[1] | \n";
echo " $row[2] | \n";
echo " $row[3] | \n";
echo " $row[4] | \n";
echo " $row[5] | \n";
echo " $row[6] | \n";
echo " $row[7] | \n";
}
echo "
\n";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $STARTtime);
echo "\n\n\n
\n\n";
echo "\n\n\n
\nscript runtime: $RUNtime seconds";
?>
|