Added download to CSV option to agent status and days reports

Added multi-campaign option to VDAD outbound report
Added AST_email_web_report.pl script

git-svn-id: svn://192.168.202.10@1062 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2009-02-25 18:38:52 +00:00
parent a3c727e157
commit 25a194b67c
6 changed files with 1010 additions and 569 deletions
+248
View File
@@ -0,0 +1,248 @@
#!/usr/bin/perl
#
# AST_email_web_report.pl version: 2.0.5
#
# This script is designed to wget a web report and then email it as an attachment
# this script should be run from the web server
#
# /usr/share/astguiclient/AST_VDlist_summary_export.pl --email-list=test@gmail.com --email-sender=test@test.com
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 90225-1247 - First version
#
$txt = '.txt';
$html = '.html';
$US = '_';
$MT[0] = '';
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
$i=0;
while ($#ARGV >= $i)
{
$args = "$args $ARGV[$i]";
$i++;
}
if ($args =~ /--help/i)
{
print "allowed run time options:\n";
print " [-q] = quiet\n";
print " [-t] = test\n";
print " [--debug] = debugging messages\n";
print " [--debugX] = Super debugging messages\n";
print " [--email-list=test@test.com:test2@test.com] = send email results to these addresses\n";
print " [--email-sender=vicidial@localhost] = sender for the email results\n";
print "\n";
exit;
}
else
{
if ($args =~ /--debug/i)
{
$DB=1;
print "\n----- DEBUG MODE -----\n\n";
}
if ($args =~ /--debugX/i)
{
$DBX=1;
print "\n----- SUPER DEBUG MODE -----\n\n";
}
if ($args =~ /-q/i)
{
$q=1; $Q=1;
}
if ($args =~ /--test/i)
{
$T=1; $TEST=1;
print "\n----- TESTING -----\n\n";
}
if ($args =~ /--email-list=/i)
{
@data_in = split(/--email-list=/,$args);
$email_list = $data_in[1];
$email_list =~ s/ .*//gi;
$email_list =~ s/:/,/gi;
print "\n----- EMAIL NOTIFICATION: $email_list -----\n\n";
}
else
{$email_list = '';}
if ($args =~ /--email-sender=/i)
{
@data_in = split(/--email-sender=/,$args);
$email_sender = $data_in[1];
$email_sender =~ s/ .*//gi;
$email_sender =~ s/:/,/gi;
print "\n----- EMAIL NOTIFICATION SENDER: $email_sender -----\n\n";
}
else
{$email_sender = 'vicidial@localhost';}
}
}
else
{
print "no command line options set, using defaults.\n";
}
### end parsing run-time options ###
$secX = time();
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = ($year + 1900);
$mon++;
# # rerun override - Use this to override the day manually
# $year='2007';
# $mon='5';
# $mday='18';
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$timestamp = "$year-$mon-$mday $hour:$min:$sec";
$filedate = "$year$mon$mday";
$shipdate = "$year-$mon-$mday";
$datestamp = "$year/$mon/$mday $hour:$min";
# 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;}
if ( ($line =~ /^VARREPORT_host/) && ($CLIREPORT_host < 1) )
{$VARREPORT_host = $line; $VARREPORT_host =~ s/.*=//gi;}
if ( ($line =~ /^VARREPORT_user/) && ($CLIREPORT_user < 1) )
{$VARREPORT_user = $line; $VARREPORT_user =~ s/.*=//gi;}
if ( ($line =~ /^VARREPORT_pass/) && ($CLIREPORT_pass < 1) )
{$VARREPORT_pass = $line; $VARREPORT_pass =~ s/.*=//gi;}
if ( ($line =~ /^VARREPORT_port/) && ($CLIREPORT_port < 1) )
{$VARREPORT_port = $line; $VARREPORT_port =~ s/.*=//gi;}
if ( ($line =~ /^VARREPORT_dir/) && ($CLIREPORT_dir < 1) )
{$VARREPORT_dir = $line; $VARREPORT_dir =~ s/.*=//gi;}
$i++;
}
# Customized Variables
$server_ip = $VARserver_ip; # Asterisk server IP
if ($output_format =~ /^pipe-standard$/)
{$DLT = '|'; $txt='.txt'; print "---- pipe-standard ----\n";}
if ($output_format =~ /^csv-standard$/)
{$DLT = "','"; $txt='.csv'; print "---- csv-standard ----\n";}
if ($output_format =~ /^tab-standard$/)
{$DLT = "\t"; $txt='.txt'; print "---- tab-standard ----\n";}
if ($output_format =~ /^pipe-triplep$/)
{$DLT = ''; $txt='.txt'; print "---- pipe-triplep ----\n";}
if ($output_format =~ /^pipe-vici$/)
{$DLT = '|'; $txt='.txt'; print "---- pipe-vici ----\n";}
if ($output_format =~ /^html-rec$/)
{$DLT = ' '; $txt='.html'; print "---- html-rec ----\n";}
if (!$Q)
{
print "\n\n\n\n\n\n\n\n\n\n\n\n-- AST_email_web_report.pl --\n\n";
print "This program is designed to wget a web report and email it. \n";
print "\n";
}
$HTMLfile = "Outbound_Report_ALL_$shipdate$html";
#$location = "http://6666:1234\@127.0.0.1/vicidial/fcstats.php?db_log=1\\&query_date=$shipdate\\&group=$group\\&shift=$shift\\&archive=1";
#$location = "http://6666:1234\@192.168.1.101/vicidial/AST_VDADstats.php?query_date=$shipdate\\&end_date=$shipdate\\&group[]=--ALL--\\&shift=ALL";
$location = "http://8888:8888\@127.0.0.1/vicidial/AST_VDADstats.php?query_date=$shipdate\\&end_date=$shipdate\\&group[]=--ALL--\\&shift=ALL";
print "Running Report $ship_date\n$location\n";
`/usr/bin/wget --output-document=/tmp/$HTMLfile $location `;
###### EMAIL SECTION
if (length($email_list) > 3)
{
print "Sending email: $email_list\n";
use MIME::QuotedPrint;
use MIME::Base64;
use Mail::Sendmail;
$mailsubject = "VICIDIAL Outbound Report $shipdate";
%mail = ( To => "$email_list",
From => "$email_sender",
Subject => "$mailsubject",
);
$boundary = "====" . time() . "====";
$mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
$message = encode_qp( "VICIDIAL Outbound Report for $shipdate:\n\n Attachment: $HTMLfile" );
$Zfile = "/tmp/$HTMLfile";
open (F, $Zfile) or die "Cannot read $Zfile: $!";
binmode F; undef $/;
$attachment = encode_base64(<F>);
close F;
$boundary = '--'.$boundary;
$mail{body} .= "$boundary\n";
$mail{body} .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$mail{body} .= "Content-Transfer-Encoding: quoted-printable\n\n";
$mail{body} .= "$message\n";
$mail{body} .= "$boundary\n";
$mail{body} .= "Content-Type: application/octet-stream; name=\"$HTMLfile\"\n";
$mail{body} .= "Content-Transfer-Encoding: base64\n";
$mail{body} .= "Content-Disposition: attachment; filename=\"$HTMLfile\"\n\n";
$mail{body} .= "$attachment\n";
$mail{body} .= "$boundary";
$mail{body} .= "--\n";
sendmail(%mail) or die $mail::Sendmail::error;
print "ok. log says:\n", $mail::sendmail::log; ### print mail log for status
}
exit;
@@ -462,6 +462,15 @@ Conf Override Settings -<\/B> If populated, and the Template ID is set to --NONE
Template ID -<\/B> This is the conf file template ID that this phone entry will use for its Asterisk settings. Default is --NONE--||
If you will be taking in inbound calls from this carrier trunk you might want to set the context=trunkinbound within this field so that you can use the DID handling process within VICIDIAL||
There is a reserved default DID that you can use which is just the word -default- without the dashes, that will allos you to send any call that does not match any other existing patterns to the default DID||
Campaign VDAD extension||
This field allows for a custom VDAD transfer extension. This allows you to use different call handling methods depending upon your campaign.||
- 8364 - same as 8368||
- 8365 - Will send the call only to an agent on the same server as the call is on||
- 8366 - Used for press-1 and survey campaigns||
- 8367 - Will try to first send the call to an agent on the local server, then it will look on other servers||
- 8368 - DEFAULT Will send the call to the next available agent no matter what server they are on||
- 8369 - Used for Answering Machine Detection after that, same behavior as 8368||
- 8373 - Used for Answering Machine Detection after that same behavior as 8366||
############################################################ CLIENT
+84 -40
View File
@@ -1,7 +1,7 @@
<?
# AST_VDADstats.php
#
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 60619-1718 - Added variable filtering to eliminate SQL injection attack threat
@@ -15,6 +15,7 @@
# 80717-2118 - Added calls/hour out of agent login time in status summary
# 80722-2049 - Added Status Category stats
# 81109-2341 - Added Productivity Rating
# 90225-1140 - Changed to multi-campaign capability
#
header ("Content-type: text/html; charset=utf-8");
@@ -88,15 +89,34 @@ if (!isset($end_date)) {$end_date = $NOW_DATE;}
$stmt="select campaign_id from vicidial_campaigns;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
$campaigns_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $groups_to_print)
while ($i < $campaigns_to_print)
{
$row=mysql_fetch_row($rslt);
$groups[$i] =$row[0];
$i++;
}
$i=0;
$group_string='|';
$group_ct = count($group);
while($i < $group_ct)
{
$group_string .= "$group[$i]|";
$group_SQL .= "'$group[$i]',";
$groupQS .= "&group[]=$group[$i]";
$i++;
}
if ( (ereg("--ALL--",$group_string) ) or ($group_ct < 1) )
{$group_SQL = "";}
else
{
$group_SQL = eregi_replace(",$",'',$group_SQL);
$group_SQLand = "and campaign_id IN($group_SQL)";
$group_SQL = "where campaign_id IN($group_SQL)";
}
$stmt="select vsc_id,vsc_name from vicidial_status_categories;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
@@ -127,33 +147,53 @@ while ($i < $statcats_to_print)
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
echo "<TITLE>VICIDIAL: VDAD Stats</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
echo "<TABLE CELLSPACING=3><TR><TD VALIGN=TOP> Dates:<BR>";
echo "<INPUT TYPE=HIDDEN NAME=agent_hours VALUE=\"$agent_hours\">\n";
echo "<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
echo " to <INPUT TYPE=TEXT NAME=end_date SIZE=10 MAXLENGTH=10 VALUE=\"$end_date\">\n";
echo "<SELECT SIZE=1 NAME=group>\n";
$o=0;
while ($groups_to_print > $o)
{
if ($groups[$o] == $group) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "<BR> to <BR><INPUT TYPE=TEXT NAME=end_date SIZE=10 MAXLENGTH=10 VALUE=\"$end_date\">\n";
echo "</TD><TD VALIGN=TOP> Campaigns:<BR>";
echo "<SELECT SIZE=5 NAME=group[] multiple>\n";
if (eregi("--ALL--",$group_string))
{echo "<option value=\"--ALL--\" selected>-- ALL CAMPAIGNS --</option>\n";}
else
{echo "<option value=\"--ALL--\">-- ALL CAMPAIGNS --</option>\n";}
$o=0;
while ($campaigns_to_print > $o)
{
if (eregi("$groups[$o]\|",$group_string)) {echo "<option selected value=\"$groups[$o]\">$groups[$o]</option>\n";}
else {echo "<option value=\"$groups[$o]\">$groups[$o]</option>\n";}
$o++;
}
echo "</SELECT>\n";
echo "</TD><TD VALIGN=TOP>Shift:<BR>";
echo "<SELECT SIZE=1 NAME=shift>\n";
echo "<option selected value=\"$shift\">$shift</option>\n";
echo "<option value=\"\">--</option>\n";
echo "<option value=\"AM\">AM</option>\n";
echo "<option value=\"PM\">PM</option>\n";
echo "<option value=\"ALL\">ALL</option>\n";
echo "</SELECT>\n";
echo "</SELECT><BR><BR>\n";
echo "<INPUT type=submit NAME=SUBMIT VALUE=SUBMIT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=34&campaign_id=$group\">MODIFY</a> | <a href=\"./admin.php?ADD=999999\">REPORTS</a> </FONT>\n";
echo "</TD><TD VALIGN=TOP> &nbsp; &nbsp; &nbsp; &nbsp; ";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
if (strlen($group[0]) > 1)
{
echo " <a href=\"./admin.php?ADD=34&campaign_id=$group[0]\">MODIFY</a> | \n";
echo " <a href=\"./admin.php?ADD=999999\">REPORTS</a> </FONT>\n";
}
else
{
echo " <a href=\"./admin.php?ADD=10\">CAMPAIGNS</a> | \n";
echo " <a href=\"./admin.php?ADD=999999\">REPORTS</a> </FONT>\n";
}
echo "</TD></TR></TABLE>";
echo "</FORM>\n\n";
echo "<PRE><FONT SIZE=2>\n\n";
if (!$group)
if (strlen($group[0]) < 1)
{
echo "\n\n";
echo "PLEASE SELECT A CAMPAIGN AND DATE ABOVE AND CLICK SUBMIT\n";
@@ -191,7 +231,7 @@ echo "\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- TOTALS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysql_real_escape_string($group) . "';";
$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) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
@@ -213,7 +253,7 @@ echo "Average Call Length for all Calls in seconds: $average_hold_seconds\n";
echo "\n";
echo "---------- DROPS\n";
$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 60 or length_in_sec is null);";
$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 <= 60 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
@@ -243,7 +283,8 @@ while ($p < $statuses_to_print)
$q++;
$p++;
}
$stmt = "SELECT status,status_name,human_answered,category from vicidial_campaign_statuses where campaign_id='" . mysql_real_escape_string($group) . "';";
$stmt = "SELECT distinct status,status_name,human_answered,category from vicidial_campaign_statuses $group_SQL;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$statuses_to_print = mysql_num_rows($rslt);
@@ -265,7 +306,7 @@ while ($p < $statuses_to_print)
$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' and campaign_id='" . mysql_real_escape_string($group) . "' and status IN($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) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
@@ -301,17 +342,20 @@ echo "Percent of DROP Calls taken out of Answers: $DROPcalls / $ANSWERcalls $
echo "Average Length for DROP Calls in seconds: $average_hold_seconds\n";
$stmt = "select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';";
$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'";
if ($DB > 0) {echo "\n|$closer_campaigns|$closer_campaignsSQL|$stmt|\n";}
$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);
@@ -320,7 +364,7 @@ $row=mysql_fetch_row($rslt);
$TOTALanswers = ($row[0] + $ANSWERcalls);
$stmt = "SELECT sum(wait_sec + talk_sec + dispo_sec) from vicidial_agent_log where campaign_id='" . mysql_real_escape_string($group) . "' and event_time >= '$query_date_BEGIN' and event_time <= '$query_date_END';";
$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' $group_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
@@ -343,7 +387,7 @@ echo "Productivity Rating: $AVG_ANSWERagent_non_pause_s
echo "\n";
echo "---------- AUTO-DIAL 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' and campaign_id='" . mysql_real_escape_string($group) . "' and status IN('NA','B') and (length_in_sec <= 60 or length_in_sec is null);";
$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','B') and (length_in_sec <= 60 or length_in_sec is null);";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
@@ -381,7 +425,7 @@ echo "+----------------------+------------+\n";
echo "| HANGUP REASON | CALLS |\n";
echo "+----------------------+------------+\n";
$stmt="select count(*),term_reason from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysql_real_escape_string($group) . "' group by term_reason;";
$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) {echo "$stmt\n";}
@@ -427,7 +471,7 @@ echo "+--------+----------------------+----------------------+------------+-----
## 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' and campaign_id='" . mysql_real_escape_string($group) . "' and pause_sec<36000 and wait_sec<36000 and talk_sec<36000 and dispo_sec<36000;";
$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' $group_SQLand and pause_sec<36000 and wait_sec<36000 and talk_sec<36000 and dispo_sec<36000;";
$rslt=mysql_query($stmt, $link);
$Ctally_to_print = mysql_num_rows($rslt);
if ($Ctally_to_print > 0)
@@ -438,7 +482,7 @@ if ($Ctally_to_print > 0)
## get counts and time totals for all statuses in this campaign
$stmt="select count(*),status,sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
$stmt="select count(*),status,sum(length_in_sec) from vicidial_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand group by status;";
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
@@ -638,7 +682,7 @@ echo "+--------------------------+------------+----------+--------+\n";
echo "| AGENT | CALLS | TIME M | AVRG M |\n";
echo "+--------------------------+------------+----------+--------+\n";
$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 0 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' $group_SQLand and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 0 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
@@ -717,7 +761,7 @@ $TOTcalls = sprintf("%10s", $TOTcalls);
$TOTtime = sprintf("%8s", $TOTtime);
$TOTavg = sprintf("%6s", $TOTavg);
$stmt="select avg(wait_sec) from vicidial_agent_log where event_time >= '$query_date_BEGIN' and event_time <= '$query_date_END' and campaign_id='" . mysql_real_escape_string($group) . "';";
$stmt="select avg(wait_sec) from vicidial_agent_log where event_time >= '$query_date_BEGIN' and event_time <= '$query_date_END' $group_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
@@ -753,14 +797,14 @@ $i=0;
$h=0;
while ($i <= 96)
{
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' $group_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' $group_SQLand and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
@@ -768,42 +812,42 @@ while ($i <= 96)
$i++;
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' $group_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' $group_SQLand and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' $group_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' $group_SQLand and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$drop_count[$i] = $row[0];
$i++;
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' $group_SQLand;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$hour_count[$i] = $row[0];
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
if ($hour_count[$i] > 0) {$last_full_record = $i;}
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' $group_SQLand and status='DROP';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
+317 -250
View File
@@ -6,6 +6,7 @@
# CHANGES
#
# 90206-2202 - First build
# 90225-1051 - Added CSV download option
#
@@ -26,6 +27,8 @@ if (isset($_GET["shift"])) {$shift=$_GET["shift"];}
elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];}
elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
@@ -138,308 +141,371 @@ if (strlen($customer_interactive_statuses)>0)
$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date&shift=$shift&DB=$DB&user=$user$groupQS";
?>
if ($file_download < 1)
{
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.yellow {color: white; background-color: yellow}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<span style=\"position:absolute;left:3px;top:3px;z-index:19;\" id=agent_status_stats>\n";
echo "<PRE><FONT SIZE=2>\n";
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.yellow {color: white; background-color: yellow}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<span style=\"position:absolute;left:3px;top:3px;z-index:19;\" id=agent_status_stats>\n";
echo "<PRE><FONT SIZE=2>\n";
}
if (strlen($group[0]) < 1)
{
echo "\n";
echo "PLEASE SELECT A USER AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from shift specified\n";
}
{
echo "\n";
echo "PLEASE SELECT A USER AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from shift specified\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";
if (strlen($user_group)>0) {$ugSQL="and vicidial_agent_log.user_group='$user_group'";}
else {$ugSQL='';}
echo "VICIDIAL: Agent Status Detail: $user $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- AGENT Details -------------\n\n";
$statuses='-';
$statusesTXT='';
$statusesHEAD='';
$statusesHTML='';
$statusesARY[0]='';
$j=0;
$dates='-';
$datesARY[0]='';
$date_namesARY[0]='';
$k=0;
$stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls,status from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and vicidial_agent_log.user='$user' $group_SQL $user_group_SQL group by date,status order by date,status desc limit 500000;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
if ( ($row[1] > 0) and (strlen($row[2]) > 0) )
if ($shift == 'AM')
{
$date[$i] = $row[0];
$calls[$i] = $row[1];
$status[$i] = $row[2];
if ( (!eregi("-$status[$i]-", $statuses)) and (strlen($status[$i])>0) )
$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";
if (strlen($user_group)>0) {$ugSQL="and vicidial_agent_log.user_group='$user_group'";}
else {$ugSQL='';}
if ($file_download < 1)
{
echo "VICIDIAL: Agent Days Detail: $user $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- AGENT Details -------------\n\n";
}
else
{
$file_output .= "VICIDIAL: Agent Days Detail: $user $NOW_TIME\n";
$file_output .= "Time range: $query_date_BEGIN to $query_date_END\n\n";
}
$statuses='-';
$statusesTXT='';
$statusesHEAD='';
$statusesHTML='';
$statusesFILE='';
$statusesARY[0]='';
$j=0;
$dates='-';
$datesARY[0]='';
$date_namesARY[0]='';
$k=0;
$stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls,status from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and vicidial_agent_log.user='$user' $group_SQL $user_group_SQL group by date,status order by date,status desc limit 500000;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
if ( ($row[1] > 0) and (strlen($row[2]) > 0) )
{
$statusesTXT = sprintf("%8s", $status[$i]);
$statusesHEAD .= "----------+";
$statusesHTML .= " $statusesTXT |";
$statuses .= "$status[$i]-";
$statusesARY[$j] = $status[$i];
$j++;
$date[$i] = $row[0];
$calls[$i] = $row[1];
$status[$i] = $row[2];
if ( (!eregi("-$status[$i]-", $statuses)) and (strlen($status[$i])>0) )
{
$statusesTXT = sprintf("%8s", $status[$i]);
$statusesHEAD .= "----------+";
$statusesHTML .= " $statusesTXT |";
$statusesFILE .= "$statusesTXT,";
$statuses .= "$status[$i]-";
$statusesARY[$j] = $status[$i];
$j++;
}
if (!eregi("-$date[$i]-", $dates))
{
$dates .= "$date[$i]-";
$datesARY[$k] = $date[$i];
$k++;
}
}
if (!eregi("-$date[$i]-", $dates))
$i++;
}
if ($file_download < 1)
{
echo "CALL STATS BREAKDOWN:\n";
echo "+------------+--------+--------+--------+$statusesHEAD\n";
echo "| <a href=\"$LINKbase\">DATE</a> | <a href=\"$LINKbase&stage=CALLS\">CALLS</a> | <a href=\"$LINKbase&stage=CI\">CIcalls</a>| <a href=\"$LINKbase&stage=DNCCI\">DNC/CI%</a>|$statusesHTML\n";
echo "+------------+--------+--------+--------+$statusesHEAD\n";
}
else
{
$file_output .= "DATE,CALLS,CIcalls,DNC-CI%,$statusesFILE\n";
}
### BEGIN loop through each user ###
$m=0;
$CIScountTOT=0;
$DNCcountTOT=0;
while ($m < $k)
{
$Sdate=$datesARY[$m];
$Scalls=$calls[$m];
$SstatusesHTML='';
$SstatusesFILE='';
$CIScount=0;
$DNCcount=0;
### BEGIN loop through each status ###
$n=0;
while ($n < $j)
{
$dates .= "$date[$i]-";
$datesARY[$k] = $date[$i];
$k++;
$Sstatus=$statusesARY[$n];
$SstatusTXT='';
### BEGIN loop through each stat line ###
$i=0; $status_found=0;
while ($i < $rows_to_print)
{
# if ( (eregi("$date[$i]", $Sdate)) and ($Sstatus=="$status[$i]") )
if ( ($Sdate=="$date[$i]") and ($Sstatus=="$status[$i]") )
{
$Scalls = ($Scalls + $calls[$i]);
if (eregi("\|$status[$i]\|",$customer_interactive_statuses))
{
$CIScount = ($CIScount + $calls[$i]);
$CIScountTOT = ($CIScountTOT + $calls[$i]);
}
if (eregi("DNC", $status[$i]))
{
$DNCcount = ($DNCcount + $calls[$i]);
$DNCcountTOT = ($DNCcountTOT + $calls[$i]);
}
$SstatusTXT = sprintf("%8s", $calls[$i]);
$SstatusesHTML .= " $SstatusTXT |";
$SstatusesFILE .= "$SstatusTXT,";
$status_found++;
}
$i++;
}
if ($status_found < 1)
{
$SstatusesHTML .= " 0 |";
}
### END loop through each stat line ###
$n++;
}
### END loop through each status ###
$TOTcalls=($TOTcalls + $Scalls);
$RAWdate = $Sdate;
$RAWcalls = $Scalls;
$RAWcis = $CIScount;
$Scalls = sprintf("%6s", $Scalls);
$CIScount = sprintf("%6s", $CIScount);
$Sdate = sprintf("%-10s", $Sdate);
while(strlen($Suser)>10) {$Suser = substr("$Sdate", 0, -1);}
if ( ($DNCcount < 1) or ($CIScount < 1) )
{$DNCcountPCTs=0;}
else
{
$DNCcountPCTs = ( ($DNCcount / $CIScount) * 100);
}
$RAWdncPCT = $DNCcountPCTs;
# $DNCcountPCTs = round($DNCcountPCTs,2);
$DNCcountPCTs = round($DNCcountPCTs);
$rawDNCcountPCTs = $DNCcountPCTs;
# $DNCcountPCTs = sprintf("%3.2f", $DNCcountPCTs);
$DNCcountPCTs = sprintf("%6s", $DNCcountPCTs);
if ($file_download < 1)
{
$Toutput = "| <a href=\"./user_stats.php?user=$user&start_date=$RAWdate\">$Sdate</a> | $Scalls | $CIScount | $DNCcountPCTs%|$SstatusesHTML\n";
}
else
{
$fileToutput = "$RAWdate,$RAWcalls,$RAWcis,$rawDNCcountPCTs%,$SstatusesFILE\n";
}
$TOPsorted_output[$m] = $Toutput;
$TOPsorted_outputFILE[$m] = $fileToutput;
if ($stage == 'ID')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWdate) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'CALLS')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWcalls) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'TIME')
{
$TOPsort[$m] = '' . sprintf("%08s", $Stime) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
$TOPsortTALLY[$m]=$Stime;
}
if ($stage == 'CI')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWcis) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
$TOPsortTALLY[$m]=$RAWcis;
}
if ($stage == 'DNCCI')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWdncPCT) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
$TOPsortTALLY[$m]=$RAWdncPCT;
}
if (!ereg("ID|TIME|CALLS|CI|DNCCI",$stage))
{
if ($file_download < 1)
{echo "$Toutput";}
else
{$file_output .= "$fileToutput";}
}
if ($TOPsortMAX < $TOPsortTALLY[$m]) {$TOPsortMAX = $TOPsortTALLY[$m];}
$m++;
}
### END loop through each user ###
$TOT_AGENTS = sprintf("%4s", $m);
### BEGIN sort through output to display properly ###
if (ereg("ID|TIME|CALLS|CI|DNCCI",$stage))
{
if (ereg("ID",$stage))
{sort($TOPsort, SORT_NUMERIC);}
if (ereg("TIME|CALLS|CI|DNCCI",$stage))
{rsort($TOPsort, SORT_NUMERIC);}
$m=0;
while ($m < $k)
{
$sort_split = explode("-----",$TOPsort[$m]);
$i = $sort_split[1];
$sort_order[$m] = "$i";
if ($file_download < 1)
{echo "$TOPsorted_output[$i]";}
else
{$file_output .= "$TOPsorted_outputFILE[$i]";}
$m++;
}
}
$i++;
}
echo "CALL STATS BREAKDOWN:\n";
echo "+------------+--------+--------+--------+$statusesHEAD\n";
echo "| <a href=\"$LINKbase\">DATE</a> | <a href=\"$LINKbase&stage=CALLS\">CALLS</a> | <a href=\"$LINKbase&stage=CI\">CIcalls</a>| <a href=\"$LINKbase&stage=DNCCI\">DNC/CI%</a>|$statusesHTML\n";
echo "+------------+--------+--------+--------+$statusesHEAD\n";
### END sort through output to display properly ###
### BEGIN loop through each user ###
$m=0;
$CIScountTOT=0;
$DNCcountTOT=0;
while ($m < $k)
{
$Sdate=$datesARY[$m];
$Scalls=$calls[$m];
$SstatusesHTML='';
$CIScount=0;
$DNCcount=0;
###### LAST LINE FORMATTING ##########
### BEGIN loop through each status ###
$SUMstatusesHTML='';
$n=0;
while ($n < $j)
{
$Scalls=0;
$Sstatus=$statusesARY[$n];
$SstatusTXT='';
$SUMstatusTXT='';
### BEGIN loop through each stat line ###
$i=0; $status_found=0;
while ($i < $rows_to_print)
{
# if ( (eregi("$date[$i]", $Sdate)) and ($Sstatus=="$status[$i]") )
if ( ($Sdate=="$date[$i]") and ($Sstatus=="$status[$i]") )
if ($Sstatus=="$status[$i]")
{
$Scalls = ($Scalls + $calls[$i]);
if (eregi("\|$status[$i]\|",$customer_interactive_statuses))
{
$CIScount = ($CIScount + $calls[$i]);
$CIScountTOT = ($CIScountTOT + $calls[$i]);
}
if (eregi("DNC", $status[$i]))
{
$DNCcount = ($DNCcount + $calls[$i]);
$DNCcountTOT = ($DNCcountTOT + $calls[$i]);
}
$SstatusTXT = sprintf("%8s", $calls[$i]);
$SstatusesHTML .= " $SstatusTXT |";
$status_found++;
}
$i++;
}
### END loop through each stat line ###
if ($status_found < 1)
{
$SstatusesHTML .= " 0 |";
$SUMstatusesHTML .= " 0 |";
}
else
{
$SUMstatusTXT = sprintf("%8s", $Scalls);
$SUMstatusesHTML .= " $SUMstatusTXT |";
$SUMstatusesFILE .= "$SUMstatusTXT,";
}
### END loop through each stat line ###
$n++;
}
### END loop through each status ###
$TOTcalls=($TOTcalls + $Scalls);
$RAWdate = $Sdate;
$RAWcalls = $Scalls;
$RAWcis = $CIScount;
$Scalls = sprintf("%6s", $Scalls);
$CIScount = sprintf("%6s", $CIScount);
$Sdate = sprintf("%-10s", $Sdate);
while(strlen($Suser)>10) {$Suser = substr("$Sdate", 0, -1);}
if ( ($DNCcount < 1) or ($CIScount < 1) )
{$DNCcountPCTs=0;}
$TOTcalls = sprintf("%7s", $TOTcalls);
$CIScountTOT = sprintf("%7s", $CIScountTOT);
if ( ($DNCcountTOT < 1) or ($CIScountTOT < 1) )
{$DNCcountPCT=0;}
else
{
$DNCcountPCTs = ( ($DNCcount / $CIScount) * 100);
$DNCcountPCT = ( ($DNCcountTOT / $CIScountTOT) * 100);
}
$RAWdncPCT = $DNCcountPCTs;
# $DNCcountPCTs = round($DNCcountPCTs,2);
$DNCcountPCTs = round($DNCcountPCTs);
# $DNCcountPCTs = sprintf("%3.2f", $DNCcountPCTs);
$DNCcountPCTs = sprintf("%6s", $DNCcountPCTs);
#$DNCcountPCT = round($DNCcountPCT,2);
$DNCcountPCT = round($DNCcountPCT);
#$DNCcountPCT = sprintf("%3.2f", $DNCcountPCT);
$DNCcountPCT = sprintf("%6s", $DNCcountPCT);
$Toutput = "| <a href=\"./user_stats.php?user=$user&start_date=$RAWdate\">$Sdate</a> | $Scalls | $CIScount | $DNCcountPCTs%|$SstatusesHTML\n";
$TOPsorted_output[$m] = $Toutput;
if ($stage == 'ID')
if ($file_download < 1)
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWdate) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'CALLS')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWcalls) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'TIME')
{
$TOPsort[$m] = '' . sprintf("%08s", $Stime) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
$TOPsortTALLY[$m]=$Stime;
}
if ($stage == 'CI')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWcis) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
$TOPsortTALLY[$m]=$RAWcis;
}
if ($stage == 'DNCCI')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWdncPCT) . '-----' . $m . '-----' . sprintf("%020s", $RAWdate);
$TOPsortTALLY[$m]=$RAWdncPCT;
}
if (!ereg("ID|TIME|CALLS|CI|DNCCI",$stage))
{echo "$Toutput";}
echo "+------------+--------+--------+--------+$statusesHEAD\n";
echo "| TOTALS | $TOTcalls| $CIScountTOT| $DNCcountPCT%|$SUMstatusesHTML\n";
echo "+------------+--------+--------+--------+$statusesHEAD\n";
if ($TOPsortMAX < $TOPsortTALLY[$m]) {$TOPsortMAX = $TOPsortTALLY[$m];}
$m++;
}
### END loop through each user ###
$TOT_AGENTS = sprintf("%4s", $m);
### BEGIN sort through output to display properly ###
if (ereg("ID|TIME|CALLS|CI|DNCCI",$stage))
{
if (ereg("ID",$stage))
{sort($TOPsort, SORT_NUMERIC);}
if (ereg("TIME|CALLS|CI|DNCCI",$stage))
{rsort($TOPsort, SORT_NUMERIC);}
$m=0;
while ($m < $k)
{
$sort_split = explode("-----",$TOPsort[$m]);
$i = $sort_split[1];
$sort_order[$m] = "$i";
echo "$TOPsorted_output[$i]";
$m++;
}
}
### END sort through output to display properly ###
###### LAST LINE FORMATTING ##########
### BEGIN loop through each status ###
$SUMstatusesHTML='';
$n=0;
while ($n < $j)
{
$Scalls=0;
$Sstatus=$statusesARY[$n];
$SUMstatusTXT='';
### BEGIN loop through each stat line ###
$i=0; $status_found=0;
while ($i < $rows_to_print)
{
if ($Sstatus=="$status[$i]")
{
$Scalls = ($Scalls + $calls[$i]);
$status_found++;
}
$i++;
}
### END loop through each stat line ###
if ($status_found < 1)
{
$SUMstatusesHTML .= " 0 |";
echo "\n\n</PRE>";
}
else
{
$SUMstatusTXT = sprintf("%8s", $Scalls);
$SUMstatusesHTML .= " $SUMstatusTXT |";
$file_output .= "TOTALS,$TOTcalls,$CIScountTOT,$DNCcountPCT%,$SUMstatusesFILE\n";
}
$n++;
}
### END loop through each status ###
$TOTcalls = sprintf("%7s", $TOTcalls);
$CIScountTOT = sprintf("%7s", $CIScountTOT);
if ( ($DNCcountTOT < 1) or ($CIScountTOT < 1) )
{$DNCcountPCT=0;}
else
if ($file_download > 0)
{
$DNCcountPCT = ( ($DNCcountTOT / $CIScountTOT) * 100);
$US='_';
$FILE_TIME = date("Ymd-His");
$CSVfilename = "AGENT_DAYS_$user$US$FILE_TIME.csv";
// We'll be outputting a TXT file
header('Content-type: application/octet-stream');
// It will be called LIST_101_20090209-121212.txt
header("Content-Disposition: attachment; filename=\"$CSVfilename\"");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
ob_clean();
flush();
echo "$file_output";
exit;
}
#$DNCcountPCT = round($DNCcountPCT,2);
$DNCcountPCT = round($DNCcountPCT);
#$DNCcountPCT = sprintf("%3.2f", $DNCcountPCT);
$DNCcountPCT = sprintf("%6s", $DNCcountPCT);
echo "+------------+--------+--------+--------+$statusesHEAD\n";
echo "| TOTALS | $TOTcalls| $CIScountTOT| $DNCcountPCT%|$SUMstatusesHTML\n";
echo "+------------+--------+--------+--------+$statusesHEAD\n";
echo "\n\n</PRE>";
}
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
@@ -478,6 +544,7 @@ echo "</TD><TD VALIGN=TOP> &nbsp; &nbsp; &nbsp; &nbsp; ";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
if (strlen($user) > 1)
{
echo " <a href=\"$LINKbase&stage=$stage&file_download=1\">DOWNLOAD</a> | \n";
echo " <a href=\"./admin.php?ADD=3&user=$user\">USER</a> | \n";
echo " <a href=\"./user_stats.php?user=$user&begin_date=$query_date&end_date=$end_date\">USER STATS</a> | \n";
}
@@ -520,4 +587,4 @@ echo "</span>\n";
?>
</BODY></HTML>
</BODY></HTML>
+343 -277
View File
@@ -6,6 +6,7 @@
# CHANGES
#
# 90206-1554 - First build
# 90225-2252 - Added CSV download option
#
@@ -26,6 +27,8 @@ if (isset($_GET["shift"])) {$shift=$_GET["shift"];}
elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];}
elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
@@ -183,326 +186,385 @@ if (strlen($customer_interactive_statuses)>0)
$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date$groupQS$user_groupQS&shift=$shift&DB=$DB";
?>
if ($file_download < 1)
{
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.yellow {color: white; background-color: yellow}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<span style=\"position:absolute;left:3px;top:3px;z-index:19;\" id=agent_status_stats>\n";
echo "<PRE><FONT SIZE=2>\n";
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
.yellow {color: white; background-color: yellow}
.red {color: white; background-color: red}
.blue {color: white; background-color: blue}
.purple {color: white; background-color: purple}
-->
</STYLE>
<?
echo "<span style=\"position:absolute;left:3px;top:3px;z-index:19;\" id=agent_status_stats>\n";
echo "<PRE><FONT SIZE=2>\n";
}
if ( (strlen($group[0]) < 1) or (strlen($user_group[0]) < 1) )
{
echo "\n";
echo "PLEASE SELECT A CAMPAIGN OR USER GROUP AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from shift specified\n";
}
{
echo "\n";
echo "PLEASE SELECT A CAMPAIGN OR USER GROUP AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
echo " NOTE: stats taken from shift specified\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";
if (strlen($user_group)>0) {$ugSQL="and vicidial_agent_log.user_group='$user_group'";}
else {$ugSQL='';}
echo "VICIDIAL: Agent Status Detail $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- AGENTS Details -------------\n\n";
$statuses='-';
$statusesTXT='';
$statusesHEAD='';
$statusesHTML='';
$statusesARY[0]='';
$j=0;
$users='-';
$usersARY[0]='';
$user_namesARY[0]='';
$k=0;
$stmt="select count(*) as calls,full_name,vicidial_users.user,status from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user $group_SQL $user_group_SQL group by user,full_name,status order by full_name,user,status desc limit 500000;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
if ( ($row[0] > 0) and (strlen($row[3]) > 0) )
if ($shift == 'AM')
{
$calls[$i] = $row[0];
$full_name[$i] = $row[1];
$user[$i] = $row[2];
$status[$i] = $row[3];
if ( (!eregi("-$status[$i]-", $statuses)) and (strlen($status[$i])>0) )
$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";
if (strlen($user_group)>0) {$ugSQL="and vicidial_agent_log.user_group='$user_group'";}
else {$ugSQL='';}
if ($file_download < 1)
{
echo "VICIDIAL: Agent Status Detail $NOW_TIME\n";
echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
echo "---------- AGENT Details -------------\n\n";
}
else
{
$file_output .= "VICIDIAL: Agent Status Detail $NOW_TIME\n";
$file_output .= "Time range: $query_date_BEGIN to $query_date_END\n\n";
}
$statuses='-';
$statusesTXT='';
$statusesHEAD='';
$statusesHTML='';
$statusesFILE='';
$statusesARY[0]='';
$j=0;
$users='-';
$usersARY[0]='';
$user_namesARY[0]='';
$k=0;
$stmt="select count(*) as calls,full_name,vicidial_users.user,status from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user $group_SQL $user_group_SQL group by user,full_name,status order by full_name,user,status desc limit 500000;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rows_to_print = mysql_num_rows($rslt);
$i=0;
while ($i < $rows_to_print)
{
$row=mysql_fetch_row($rslt);
if ( ($row[0] > 0) and (strlen($row[3]) > 0) )
{
$statusesTXT = sprintf("%8s", $status[$i]);
$statusesHEAD .= "----------+";
$statusesHTML .= " $statusesTXT |";
$statuses .= "$status[$i]-";
$statusesARY[$j] = $status[$i];
$j++;
$calls[$i] = $row[0];
$full_name[$i] = $row[1];
$user[$i] = $row[2];
$status[$i] = $row[3];
if ( (!eregi("-$status[$i]-", $statuses)) and (strlen($status[$i])>0) )
{
$statusesTXT = sprintf("%8s", $status[$i]);
$statusesHEAD .= "----------+";
$statusesHTML .= " $statusesTXT |";
$statusesFILE .= "$statusesTXT,";
$statuses .= "$status[$i]-";
$statusesARY[$j] = $status[$i];
$j++;
}
if (!eregi("-$user[$i]-", $users))
{
$users .= "$user[$i]-";
$usersARY[$k] = $user[$i];
$user_namesARY[$k] = $full_name[$i];
$k++;
}
}
if (!eregi("-$user[$i]-", $users))
$i++;
}
if ($file_download < 1)
{
echo "CALL STATS BREAKDOWN:\n";
echo "+-----------------+----------+--------+--------+--------+$statusesHEAD\n";
echo "| <a href=\"$LINKbase\">USER NAME</a> | <a href=\"$LINKbase&stage=ID\">ID</a> | <a href=\"$LINKbase&stage=CALLS\">CALLS</a> | <a href=\"$LINKbase&stage=CI\">CIcalls</a>| <a href=\"$LINKbase&stage=DNCCI\">DNC/CI%</a>|$statusesHTML\n";
echo "+-----------------+----------+--------+--------+--------+$statusesHEAD\n";
}
else
{
$file_output .= "USER,ID,CALLS,CIcalls,DNC-CI%,$statusesFILE\n";
}
### BEGIN loop through each user ###
$m=0;
$CIScountTOT=0;
$DNCcountTOT=0;
while ($m < $k)
{
$Suser=$usersARY[$m];
$Sfull_name=$user_namesARY[$m];
$Scalls=$calls[$m];
$SstatusesHTML='';
$SstatusesFILE='';
$CIScount=0;
$DNCcount=0;
### BEGIN loop through each status ###
$n=0;
while ($n < $j)
{
$users .= "$user[$i]-";
$usersARY[$k] = $user[$i];
$user_namesARY[$k] = $full_name[$i];
$k++;
$Sstatus=$statusesARY[$n];
$SstatusTXT='';
### BEGIN loop through each stat line ###
$i=0; $status_found=0;
while ($i < $rows_to_print)
{
if ( ($Suser=="$user[$i]") and ($Sstatus=="$status[$i]") )
{
$Scalls = ($Scalls + $calls[$i]);
if (eregi("\|$status[$i]\|",$customer_interactive_statuses))
{
$CIScount = ($CIScount + $calls[$i]);
$CIScountTOT = ($CIScountTOT + $calls[$i]);
}
if (eregi("DNC", $status[$i]))
{
$DNCcount = ($DNCcount + $calls[$i]);
$DNCcountTOT = ($DNCcountTOT + $calls[$i]);
}
$SstatusTXT = sprintf("%8s", $calls[$i]);
$SstatusesHTML .= " $SstatusTXT |";
$SstatusesFILE .= "$SstatusTXT,";
$status_found++;
}
$i++;
}
if ($status_found < 1)
{
$SstatusesHTML .= " 0 |";
}
### END loop through each stat line ###
$n++;
}
### END loop through each status ###
$TOTcalls=($TOTcalls + $Scalls);
$RAWuser = $Suser;
$RAWcalls = $Scalls;
$RAWcis = $CIScount;
$Scalls = sprintf("%6s", $Scalls);
$CIScount = sprintf("%6s", $CIScount);
if ($non_latin < 1)
{
$Sfull_name= sprintf("%-15s", $Sfull_name);
while(strlen($Sfull_name)>15) {$Sfull_name = substr("$Sfull_name", 0, -1);}
$Suser = sprintf("%-8s", $Suser);
while(strlen($Suser)>8) {$Suser = substr("$Suser", 0, -1);}
}
else
{
$Sfull_name= sprintf("%-45s", $Sfull_name);
while(mb_strlen($Sfull_name,'utf-8')>15) {$Sfull_name = mb_substr("$Sfull_name", 0, -1,'utf-8');}
$Suser = sprintf("%-24s", $Suser);
while(mb_strlen($Suser,'utf-8')>8) {$Suser = mb_substr("$Suser", 0, -1,'utf-8');}
}
if ( ($DNCcount < 1) or ($CIScount < 1) )
{$DNCcountPCTs=0;}
else
{
$DNCcountPCTs = ( ($DNCcount / $CIScount) * 100);
}
$RAWdncPCT = $DNCcountPCTs;
# $DNCcountPCTs = round($DNCcountPCTs,2);
$DNCcountPCTs = round($DNCcountPCTs);
$rawDNCcountPCTs = $DNCcountPCTs;
# $DNCcountPCTs = sprintf("%3.2f", $DNCcountPCTs);
$DNCcountPCTs = sprintf("%6s", $DNCcountPCTs);
if ($file_download < 1)
{
$Toutput = "| $Sfull_name | <a href=\"./user_stats.php?user=$RAWuser\">$Suser</a> | $Scalls | $CIScount | $DNCcountPCTs%|$SstatusesHTML\n";
}
else
{
$fileToutput = "$Sfull_name,$RAWuser,$RAWcalls,$RAWcis,$rawDNCcountPCTs%,$SstatusesFILE\n";
}
$TOPsorted_output[$m] = $Toutput;
$TOPsorted_outputFILE[$m] = $fileToutput;
if ($stage == 'ID')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWuser) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'CALLS')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWcalls) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'TIME')
{
$TOPsort[$m] = '' . sprintf("%08s", $Stime) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$Stime;
}
if ($stage == 'CI')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWcis) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWcis;
}
if ($stage == 'DNCCI')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWdncPCT) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWdncPCT;
}
if (!ereg("ID|TIME|CALLS|CI|DNCCI",$stage))
if ($file_download < 1)
{echo "$Toutput";}
else
{$file_output .= "$fileToutput";}
if ($TOPsortMAX < $TOPsortTALLY[$m]) {$TOPsortMAX = $TOPsortTALLY[$m];}
$m++;
}
### END loop through each user ###
$TOT_AGENTS = sprintf("%4s", $m);
### BEGIN sort through output to display properly ###
if (ereg("ID|TIME|CALLS|CI|DNCCI",$stage))
{
if (ereg("ID",$stage))
{sort($TOPsort, SORT_NUMERIC);}
if (ereg("TIME|CALLS|CI|DNCCI",$stage))
{rsort($TOPsort, SORT_NUMERIC);}
$m=0;
while ($m < $k)
{
$sort_split = explode("-----",$TOPsort[$m]);
$i = $sort_split[1];
$sort_order[$m] = "$i";
if ($file_download < 1)
{echo "$TOPsorted_output[$i]";}
else
{$file_output .= "$TOPsorted_outputFILE[$i]";}
$m++;
}
}
$i++;
}
echo "CALL STATS BREAKDOWN:\n";
echo "+-----------------+----------+--------+--------+--------+$statusesHEAD\n";
echo "| <a href=\"$LINKbase\">USER NAME</a> | <a href=\"$LINKbase&stage=ID\">ID</a> | <a href=\"$LINKbase&stage=CALLS\">CALLS</a> | <a href=\"$LINKbase&stage=CI\">CIcalls</a>| <a href=\"$LINKbase&stage=DNCCI\">DNC/CI%</a>|$statusesHTML\n";
echo "+-----------------+----------+--------+--------+--------+$statusesHEAD\n";
### END sort through output to display properly ###
### BEGIN loop through each user ###
$m=0;
$CIScountTOT=0;
$DNCcountTOT=0;
while ($m < $k)
{
$Suser=$usersARY[$m];
$Sfull_name=$user_namesARY[$m];
$Scalls=$calls[$m];
$SstatusesHTML='';
$CIScount=0;
$DNCcount=0;
###### LAST LINE FORMATTING ##########
### BEGIN loop through each status ###
$SUMstatusesHTML='';
$n=0;
while ($n < $j)
{
$Scalls=0;
$Sstatus=$statusesARY[$n];
$SstatusTXT='';
$SUMstatusTXT='';
### BEGIN loop through each stat line ###
$i=0; $status_found=0;
while ($i < $rows_to_print)
{
if ( ($Suser=="$user[$i]") and ($Sstatus=="$status[$i]") )
if ($Sstatus=="$status[$i]")
{
$Scalls = ($Scalls + $calls[$i]);
if (eregi("\|$status[$i]\|",$customer_interactive_statuses))
{
$CIScount = ($CIScount + $calls[$i]);
$CIScountTOT = ($CIScountTOT + $calls[$i]);
}
if (eregi("DNC", $status[$i]))
{
$DNCcount = ($DNCcount + $calls[$i]);
$DNCcountTOT = ($DNCcountTOT + $calls[$i]);
}
$SstatusTXT = sprintf("%8s", $calls[$i]);
$SstatusesHTML .= " $SstatusTXT |";
$status_found++;
}
$i++;
}
### END loop through each stat line ###
if ($status_found < 1)
{
$SstatusesHTML .= " 0 |";
$SUMstatusesHTML .= " 0 |";
}
else
{
$SUMstatusTXT = sprintf("%8s", $Scalls);
$SUMstatusesHTML .= " $SUMstatusTXT |";
$SUMstatusesFILE .= "$SUMstatusTXT,";
}
### END loop through each stat line ###
$n++;
}
### END loop through each status ###
$TOTcalls=($TOTcalls + $Scalls);
$RAWuser = $Suser;
$RAWcalls = $Scalls;
$RAWcis = $CIScount;
$Scalls = sprintf("%6s", $Scalls);
$CIScount = sprintf("%6s", $CIScount);
if ($non_latin < 1)
{
$Sfull_name= sprintf("%-15s", $Sfull_name);
while(strlen($Sfull_name)>15) {$Sfull_name = substr("$Sfull_name", 0, -1);}
$Suser = sprintf("%-8s", $Suser);
while(strlen($Suser)>8) {$Suser = substr("$Suser", 0, -1);}
}
else
{
$Sfull_name= sprintf("%-45s", $Sfull_name);
while(mb_strlen($Sfull_name,'utf-8')>15) {$Sfull_name = mb_substr("$Sfull_name", 0, -1,'utf-8');}
$Suser = sprintf("%-24s", $Suser);
while(mb_strlen($Suser,'utf-8')>8) {$Suser = mb_substr("$Suser", 0, -1,'utf-8');}
}
if ( ($DNCcount < 1) or ($CIScount < 1) )
{$DNCcountPCTs=0;}
else
{
$DNCcountPCTs = ( ($DNCcount / $CIScount) * 100);
}
$RAWdncPCT = $DNCcountPCTs;
# $DNCcountPCTs = round($DNCcountPCTs,2);
$DNCcountPCTs = round($DNCcountPCTs);
# $DNCcountPCTs = sprintf("%3.2f", $DNCcountPCTs);
$DNCcountPCTs = sprintf("%6s", $DNCcountPCTs);
$Toutput = "| $Sfull_name | <a href=\"./user_stats.php?user=$RAWuser\">$Suser</a> | $Scalls | $CIScount | $DNCcountPCTs%|$SstatusesHTML\n";
$TOPsorted_output[$m] = $Toutput;
if ($stage == 'ID')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWuser) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'CALLS')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWcalls) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWcalls;
}
if ($stage == 'TIME')
{
$TOPsort[$m] = '' . sprintf("%08s", $Stime) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$Stime;
}
if ($stage == 'CI')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWcis) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWcis;
}
if ($stage == 'DNCCI')
{
$TOPsort[$m] = '' . sprintf("%08s", $RAWdncPCT) . '-----' . $m . '-----' . sprintf("%020s", $RAWuser);
$TOPsortTALLY[$m]=$RAWdncPCT;
}
if (!ereg("ID|TIME|CALLS|CI|DNCCI",$stage))
{echo "$Toutput";}
if ($TOPsortMAX < $TOPsortTALLY[$m]) {$TOPsortMAX = $TOPsortTALLY[$m];}
$m++;
}
### END loop through each user ###
$TOT_AGENTS = sprintf("%4s", $m);
### BEGIN sort through output to display properly ###
if (ereg("ID|TIME|CALLS|CI|DNCCI",$stage))
{
if (ereg("ID",$stage))
{sort($TOPsort, SORT_NUMERIC);}
if (ereg("TIME|CALLS|CI|DNCCI",$stage))
{rsort($TOPsort, SORT_NUMERIC);}
$m=0;
while ($m < $k)
{
$sort_split = explode("-----",$TOPsort[$m]);
$i = $sort_split[1];
$sort_order[$m] = "$i";
echo "$TOPsorted_output[$i]";
$m++;
}
}
### END sort through output to display properly ###
###### LAST LINE FORMATTING ##########
### BEGIN loop through each status ###
$SUMstatusesHTML='';
$n=0;
while ($n < $j)
{
$Scalls=0;
$Sstatus=$statusesARY[$n];
$SUMstatusTXT='';
### BEGIN loop through each stat line ###
$i=0; $status_found=0;
while ($i < $rows_to_print)
{
if ($Sstatus=="$status[$i]")
{
$Scalls = ($Scalls + $calls[$i]);
$status_found++;
}
$i++;
}
### END loop through each stat line ###
if ($status_found < 1)
{
$SUMstatusesHTML .= " 0 |";
}
else
{
$SUMstatusTXT = sprintf("%8s", $Scalls);
$SUMstatusesHTML .= " $SUMstatusTXT |";
}
$n++;
}
### END loop through each status ###
$TOTcalls = sprintf("%7s", $TOTcalls);
$CIScountTOT = sprintf("%7s", $CIScountTOT);
$DNCcountPCT = ( ($DNCcountTOT / $CIScountTOT) * 100);
$DNCcountPCT = round($DNCcountPCT,2);
$DNCcountPCT = sprintf("%3.2f", $DNCcountPCT);
if ( ($DNCcountTOT < 1) or ($CIScountTOT < 1) )
{$DNCcountPCT=0;}
else
{
$TOTcalls = sprintf("%7s", $TOTcalls);
$CIScountTOT = sprintf("%7s", $CIScountTOT);
$DNCcountPCT = ( ($DNCcountTOT / $CIScountTOT) * 100);
$DNCcountPCT = round($DNCcountPCT,2);
$DNCcountPCT = sprintf("%3.2f", $DNCcountPCT);
if ( ($DNCcountTOT < 1) or ($CIScountTOT < 1) )
{$DNCcountPCT=0;}
else
{
$DNCcountPCT = ( ($DNCcountTOT / $CIScountTOT) * 100);
}
#$DNCcountPCT = round($DNCcountPCT,2);
$DNCcountPCT = round($DNCcountPCT);
#$DNCcountPCT = sprintf("%3.2f", $DNCcountPCT);
$DNCcountPCT = sprintf("%6s", $DNCcountPCT);
if ($file_download < 1)
{
echo "+-----------------+----------+--------+--------+--------+$statusesHEAD\n";
echo "| TOTALS AGENTS:$TOT_AGENTS | $TOTcalls| $CIScountTOT| $DNCcountPCT%|$SUMstatusesHTML\n";
echo "+----------------------------+--------+--------+--------+$statusesHEAD\n";
echo "\n\n</PRE>";
}
else
{
$file_output .= "TOTALS,$TOT_AGENTS,$TOTcalls,$CIScountTOT,$DNCcountPCT%,$SUMstatusesFILE\n";
}
}
#$DNCcountPCT = round($DNCcountPCT,2);
$DNCcountPCT = round($DNCcountPCT);
#$DNCcountPCT = sprintf("%3.2f", $DNCcountPCT);
$DNCcountPCT = sprintf("%6s", $DNCcountPCT);
if ($file_download > 0)
{
$FILE_TIME = date("Ymd-His");
$CSVfilename = "AGENT_STATUS$US$FILE_TIME.csv";
echo "+-----------------+----------+--------+--------+--------+$statusesHEAD\n";
echo "| TOTALS AGENTS:$TOT_AGENTS | $TOTcalls| $CIScountTOT| $DNCcountPCT%|$SUMstatusesHTML\n";
echo "+----------------------------+--------+--------+--------+$statusesHEAD\n";
// We'll be outputting a TXT file
header('Content-type: application/octet-stream');
echo "\n\n</PRE>";
// It will be called LIST_101_20090209-121212.txt
header("Content-Disposition: attachment; filename=\"$CSVfilename\"");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
ob_clean();
flush();
}
echo "$file_output";
exit;
}
echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
@@ -551,7 +613,11 @@ echo "<option value=\"ALL\">ALL</option>\n";
echo "</SELECT><BR><BR>\n";
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
echo "</TD><TD VALIGN=TOP> &nbsp; &nbsp; &nbsp; &nbsp; ";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"./admin.php?ADD=999999\">REPORTS</a> </FONT>\n";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\n";
echo " <a href=\"$LINKbase&stage=$stage&file_download=1\">DOWNLOAD</a> | \n";
echo " <a href=\"./admin.php?ADD=999999\">REPORTS</a> </FONT>\n";
echo "</FONT>\n";
echo "</TD></TR></TABLE>";
echo "</FORM>\n\n";
+9 -2
View File
@@ -2917,7 +2917,14 @@ if ($SSoutbound_autodial_active > 0)
<BR>
<A NAME="vicidial_campaigns-campaign_vdad_exten">
<BR>
<B>Campaign VDAD extension -</B> This field allows for a custom VDAD transfer extension. This allows you to use different VDADtransfer...agi scripts depending upon your campaign. The default transfer AGI - exten 8365 agi-VDADtransfer.agi - just immediately sends the calls on to agents as soon as they are picked up. An additional sample political survey AGI is also now included - 8366 agi-VDADtransferSURVEY.agi - that plays a message to the called person and allows them to make a choice by pressing buttons - effectively pre-screening the lead - . Please note that except for surveys, political calls and charities this form of calling is illegal in the United States.
<B>Campaign VDAD extension -</B> This field allows for a custom VDAD transfer extension. This allows you to use different call handling methods depending upon your campaign.
- 8364 - same as 8368
- 8365 - Will send the call only to an agent on the same server as the call is on
- 8366 - Used for press-1 and survey campaigns
- 8367 - Will try to first send the call to an agent on the local server, then it will look on other servers
- 8368 - DEFAULT Will send the call to the next available agent no matter what server they are on
- 8369 - Used for Answering Machine Detection after that, same behavior as 8368
- 8373 - Used for Answering Machine Detection after that same behavior as 8366
<BR>
<A NAME="vicidial_campaigns-am_message_exten">
@@ -2947,7 +2954,7 @@ if ($SSoutbound_autodial_active > 0)
<BR>
<A NAME="vicidial_campaigns-drop_action">
<BR>
<B>Drop Action -</B> This menu allows you to choose what happens to a call when it has been waiting for longer than what is set in the Drop Call Seconds field. HANGUP will simply hang up the call, MESSAGE will send the call the Drop Exten that you have defined below, VOICEMAIL will send the call to the voicemail box that you have defined below and IN_GROUP will send the call to the Inbound Group that is defined below||
<B>Drop Action -</B> This menu allows you to choose what happens to a call when it has been waiting for longer than what is set in the Drop Call Seconds field. HANGUP will simply hang up the call, MESSAGE will send the call the Drop Exten that you have defined below, VOICEMAIL will send the call to the voicemail box that you have defined below and IN_GROUP will send the call to the Inbound Group that is defined below
<BR>
<A NAME="vicidial_campaigns-safe_harbor_exten">