2006-06-16 snapshot
git-svn-id: svn://192.168.202.10@9 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -35,6 +35,8 @@
|
||||
# 60418-0947 - Added lead filter per campaign
|
||||
# 60509-1416 - Rewrite of local_call_time functions
|
||||
# 60511-1150 - Added inserts into vicidial_campaign_stats table
|
||||
# 60609-1451 - Added ability to filter by DNC list vicidial_dnc
|
||||
# 60614-1159 - Added campaign lead recycling ability
|
||||
#
|
||||
|
||||
# constants
|
||||
@@ -303,6 +305,7 @@ while ($sthArows > $rec_count)
|
||||
{$hopper_level[$rec_count] = "$CLIlevel";}
|
||||
$local_call_time[$rec_count] = "$aryA[16]";
|
||||
$lead_filter_id[$rec_count] = "$aryA[35]";
|
||||
$use_internal_dnc[$rec_count] = "$aryA[43]";
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
@@ -747,7 +750,65 @@ foreach(@campaign_id)
|
||||
|
||||
##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ###
|
||||
|
||||
##### BEGIN lead recycling parsing and prep ###
|
||||
|
||||
$stmtA = "SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id[$i]' and active='Y';";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
@recycle_status=@MT;
|
||||
@recycle_delay=@MT;
|
||||
@recycle_maximum=@MT;
|
||||
@RSQLdate=@MT;
|
||||
$rec_ct=0;
|
||||
while ($sthArows > $rec_ct)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$recycle_status[$rec_ct] = "$aryA[2]";
|
||||
$recycle_delay[$rec_ct] = "$aryA[3]";
|
||||
$recycle_maximum[$rec_ct] = "$aryA[4]";
|
||||
$rec_ct++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
if ($rec_ct > 0)
|
||||
{
|
||||
$rc=0;
|
||||
$recycle_SQL = "( ";
|
||||
while($rc < $rec_ct)
|
||||
{
|
||||
$secX = time();
|
||||
$Rtarget = ($secX - $recycle_delay[$rc]);
|
||||
($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget);
|
||||
$Ryear = ($Ryear + 1900);
|
||||
$Rmon++;
|
||||
if ($Rmon < 10) {$Rmon = "0$Rmon";}
|
||||
if ($Rmday < 10) {$Rmday = "0$Rmday";}
|
||||
if ($Rhour < 10) {$Rhour = "0$Rhour";}
|
||||
if ($Rmin < 10) {$Rmin = "0$Rmin";}
|
||||
if ($Rsec < 10) {$Rsec = "0$Rsec";}
|
||||
$RSQLdate[$rc] = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec";
|
||||
$Y=1;
|
||||
$recycle_Y = "'Y'";
|
||||
while ($Y < $recycle_maximum[$rc])
|
||||
{
|
||||
$recycle_Y .= ",'Y$Y'";
|
||||
$Y++;
|
||||
}
|
||||
|
||||
if ($rc > 0) {$recycle_SQL .= " or ";}
|
||||
|
||||
$recycle_SQL .= "( (called_since_last_reset IN($recycle_Y)) and (status='$recycle_status[$rc]') and (modify_date < \"$RSQLdate[$rc]\") )";
|
||||
|
||||
if ($DBX) {print "RECYCLE: |$campaign_id[$i]|$recycle_status[$rc]|$recycle_delay[$rc]|$recycle_maximum[$rc]|$RSQLdate[$rc]|\n";}
|
||||
$rc++;
|
||||
}
|
||||
|
||||
$recycle_SQL .= " )";
|
||||
|
||||
if ($DBX) {print "RECYCLE SQL: |$recycle_SQL|\n";}
|
||||
}
|
||||
##### END lead recycling parsing and prep ###
|
||||
|
||||
if ($DB) {print "Starting hopper run for $campaign_id[$i] campaign- GMT: $local_call_time[$i] HOPPER: $hopper_level[$i] \n";}
|
||||
|
||||
@@ -928,6 +989,44 @@ foreach(@campaign_id)
|
||||
if ($lead_order[$i] eq "DOWN COUNT 3rd NEW") {$NEW_count = 3;}
|
||||
if ($lead_order[$i] eq "DOWN COUNT 4th NEW") {$NEW_count = 4;}
|
||||
|
||||
### BEGIN recycle grab leads ###
|
||||
if ($rec_ct > 0)
|
||||
{
|
||||
if ($DB) {print " looking for RECYCLE leads, maximum of 100\n";}
|
||||
|
||||
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where $recycle_SQL and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL) $lead_filter_sql[$i] limit 100;";
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
if ($DB) {print " RECYCLE leads to call count: $sthArows\n";}
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
$REC_rec_countLEADS=0;
|
||||
@REC_leads_to_hopper=@MT;
|
||||
@REC_lists_to_hopper=@MT;
|
||||
@REC_phone_to_hopper=@MT;
|
||||
while ($sthArows > $REC_rec_countLEADS)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$REC_leads_to_hopper[$REC_rec_countLEADS] = "$aryA[0]";
|
||||
$REC_lists_to_hopper[$REC_rec_countLEADS] = "$aryA[1]";
|
||||
$REC_gmt_to_hopper[$REC_rec_countLEADS] = "$aryA[2]";
|
||||
$REC_phone_to_hopper[$REC_rec_countLEADS] = "$aryA[3]";
|
||||
$REC_state_to_hopper[$REC_rec_countLEADS] = "$aryA[4]";
|
||||
if ($DB_show_offset) {print "LEAD_ADD: $aryA[2] $aryA[3] $aryA[4]\n";}
|
||||
$REC_rec_countLEADS++;
|
||||
}
|
||||
$sthA->finish();
|
||||
}
|
||||
### END recycle grab leads ###
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($NEW_count > 0)
|
||||
{
|
||||
$NEW_level = int($hopper_level[$i] / $NEW_count);
|
||||
@@ -967,7 +1066,11 @@ foreach(@campaign_id)
|
||||
$rec_countLEADS=0; $NEW_dec=99; $NEW_in=0;
|
||||
@leads_to_hopper=@MT;
|
||||
@lists_to_hopper=@MT;
|
||||
@gmt_to_hopper=@MT;
|
||||
@state_to_hopper=@MT;
|
||||
@phone_to_hopper=@MT;
|
||||
$rec_count=0;
|
||||
$REC_insert_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
@@ -984,16 +1087,28 @@ foreach(@campaign_id)
|
||||
$lists_to_hopper[$rec_countLEADS] = "$NEW_lists_to_hopper[$NEW_in]";
|
||||
$gmt_to_hopper[$rec_countLEADS] = "$NEW_gmt_to_hopper[$NEW_in]";
|
||||
$state_to_hopper[$rec_countLEADS] = "$NEW_state_to_hopper[$NEW_in]";
|
||||
$phone_to_hopper[$rec_countLEADS] = "$NEW_phone_to_hopper[$NEW_in]";
|
||||
if ($DB_show_offset) {print "LEAD_ADD: $NEW_leads_to_hopper[$NEW_in] $NEW_phone_to_hopper[$NEW_in]\n";}
|
||||
$rec_countLEADS++;
|
||||
$NEW_in++;
|
||||
$NEW_dec=2;
|
||||
}
|
||||
}
|
||||
if ($REC_rec_countLEADS > $REC_insert_count)
|
||||
{
|
||||
$leads_to_hopper[$rec_countLEADS] = "$REC_leads_to_hopper[$REC_insert_count]";
|
||||
$lists_to_hopper[$rec_countLEADS] = "$REC_lists_to_hopper[$REC_insert_count]";
|
||||
$gmt_to_hopper[$rec_countLEADS] = "$REC_gmt_to_hopper[$REC_insert_count]";
|
||||
$state_to_hopper[$rec_countLEADS] = "$REC_state_to_hopper[$REC_insert_count]";
|
||||
$phone_to_hopper[$rec_countLEADS] = "$REC_phone_to_hopper[$REC_insert_count]";
|
||||
$rec_countLEADS++;
|
||||
$REC_insert_count++;
|
||||
}
|
||||
$leads_to_hopper[$rec_countLEADS] = "$aryA[0]";
|
||||
$lists_to_hopper[$rec_countLEADS] = "$aryA[1]";
|
||||
$gmt_to_hopper[$rec_countLEADS] = "$aryA[2]";
|
||||
$state_to_hopper[$rec_countLEADS] = "$aryA[4]";
|
||||
$phone_to_hopper[$rec_countLEADS] = "$aryA[3]";
|
||||
if ($DB_show_offset) {print "LEAD_ADD: $aryA[2] $aryA[3] $aryA[4]\n";}
|
||||
$rec_countLEADS++;
|
||||
$rec_count++;
|
||||
@@ -1008,9 +1123,35 @@ foreach(@campaign_id)
|
||||
{
|
||||
if ($leads_to_hopper[$h] != '0')
|
||||
{
|
||||
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]');";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if ($DBX) {print "LEAD INSERTED: $affected_rows|$leads_to_hopper[$h]|\n";}
|
||||
$DNClead=0;
|
||||
if ($use_internal_dnc[$i] =~ /Y/)
|
||||
{
|
||||
if ($DB) {print " Doinbg DNC Check: $phone_to_hopper[$h] - $use_internal_dnc[$i]\n";}
|
||||
$stmtA = "SELECT count(*) from vicidial_dnc where phone_number='$phone_to_hopper[$h]';";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$DNClead = "$aryA[0]";
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
if ($DNClead != '0')
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_list SET status='DNCL' where lead_id='$leads_to_hopper[$h]';";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if ($DBX) {print "Flagging DNC lead: $affected_rows $phone_to_hopper[$h]\n";}
|
||||
}
|
||||
}
|
||||
if ($DNClead == '0')
|
||||
{
|
||||
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]');";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if ($DBX) {print "LEAD INSERTED: $affected_rows|$leads_to_hopper[$h]|\n";}
|
||||
}
|
||||
}
|
||||
$h++;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,336 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# AST_agent_week.pl
|
||||
#
|
||||
# This script is designed to gather stats for all agent activity over the course
|
||||
# of a week(Sunday to Saturday) and print it in an ASCI text file to be placed
|
||||
# on a web server for viewing.
|
||||
#
|
||||
# CHANGES
|
||||
# 60517-1100 - First version
|
||||
#
|
||||
|
||||
$txt = '.txt';
|
||||
$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 [-q] = quiet\n [-t] = test\n\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1;
|
||||
print "\n-----DEBUG MODE-----\n\n";
|
||||
}
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1; $Q=1;
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$T=1; $TEST=1;
|
||||
print "\n-----TESTING-----\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
|
||||
$secX = time();
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||
$year = ($year + 1900);
|
||||
$mon++;
|
||||
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";}
|
||||
$filedate = "$year$mon$mday-$hour$min$sec";
|
||||
$ABIfiledate = "$mon-$mday-$year$us$hour$min$sec";
|
||||
$shipdate = "$year-$mon-$mday";
|
||||
$datestamp = "$year/$mon/$mday $hour:$min";
|
||||
|
||||
$STARTtarget = ($secX - (86400 * $wday));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($STARTtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$START_week = (($Syday/7)+1); $START_week = sprintf("%2d", $START_week);
|
||||
$STARTtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$ENDtarget = ($STARTtarget + (86400 * 6));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($ENDtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$ENDtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$PAST_STARTtarget = ($STARTtarget - (86400 * 7));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_STARTtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_START_week = (($Syday/7)+1); $PAST_START_week = sprintf("%2d", $PAST_START_week);
|
||||
$PAST_STARTtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$PAST_ENDtarget = ($ENDtarget - (86400 * 7));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_ENDtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_ENDtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$PAST_date[0] = $PAST_STARTtarget_date;
|
||||
$PAST_day[0] = 'Sunday ';
|
||||
$PAST_date[6] = $PAST_ENDtarget_date;
|
||||
$PAST_day[6] = 'Saturday ';
|
||||
|
||||
$PAST_Mondaytarget = ($STARTtarget - (86400 * 6));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Mondaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[1] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[1] = 'Monday ';
|
||||
|
||||
$PAST_Tuesdaytarget = ($STARTtarget - (86400 * 5));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Tuesdaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[2] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[2] = 'Tuesday ';
|
||||
|
||||
$PAST_Wednesdaytarget = ($STARTtarget - (86400 * 4));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Wednesdaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[3] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[3] = 'Wednesday';
|
||||
|
||||
$PAST_Thursdaytarget = ($STARTtarget - (86400 * 3));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Thursdaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[4] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[4] = 'Thursday ';
|
||||
|
||||
$PAST_Fridaytarget = ($STARTtarget - (86400 * 2));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Fridaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[5] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[5] = 'Friday ';
|
||||
|
||||
print "\n\n\n\n\n\n\n\n\n\n\n\n-- AST_agent_week.pl --\n\n";
|
||||
print "This program is designed to print stats to a file for agents' activity for the previous week. \n\n";
|
||||
|
||||
$TLoutfile = '';
|
||||
$TLoutfile .= "TODAY: $shipdate\n";
|
||||
$TLoutfile .= "THIS WEEK: week $START_week $STARTtarget_date - $ENDtarget_date\n";
|
||||
$TLoutfile .= "LAST WEEK: week $PAST_START_week $PAST_STARTtarget_date - $PAST_ENDtarget_date\n\n";
|
||||
|
||||
#$h=0;
|
||||
#foreach(@PAST_date)
|
||||
#{
|
||||
#$TLoutfile .= "$PAST_day[$h] $PAST_date[$h]\n";
|
||||
#$h++;
|
||||
#}
|
||||
|
||||
#print "$TLoutfile";
|
||||
|
||||
|
||||
$outfile = "AGENT_HOURS_$PAST_STARTtarget_date$US$PAST_ENDtarget_date$txt";
|
||||
|
||||
#$dir = '/usr/local/apache2/htdocs';
|
||||
$dir = '/home/www/htdocs';
|
||||
|
||||
### open the X out file for writing ###
|
||||
open(out, ">$dir/vicidial/agent_reports/$outfile")
|
||||
|| die "Can't open $outfile: $!\n";
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
use DBI;
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$dbhB = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
#$vicidial_agent_log = 'vicidial_agent_log_archive';
|
||||
$vicidial_agent_log = 'vicidial_agent_log';
|
||||
|
||||
###########################################################################
|
||||
########### PAST WEEK STAT GATHERING LOOP #################################
|
||||
###########################################################################
|
||||
$h=0;
|
||||
foreach(@PAST_date)
|
||||
{
|
||||
print out "\n$PAST_day[$h] $PAST_date[$h]\n\n";
|
||||
print out "AGENT USER CALLS TALK PAUSE WAIT DISPO ACTIVE LOGTIME FIRST LAST \n";
|
||||
print "\n$PAST_day[$h] $PAST_date[$h]\n\n";
|
||||
print "AGENT USER CALLS TALK PAUSE WAIT DISPO ACTIVE LOGTIME FIRST LAST \n";
|
||||
|
||||
$stmtA = "select count(*) as calls, full_name,vicidial_users.user,sum(talk_sec),sum(pause_sec),sum(wait_sec),sum(dispo_sec) from vicidial_users,$vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and vicidial_users.user=$vicidial_agent_log.user and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by vicidial_users.user order by full_name limit 10000;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
|
||||
$calls = sprintf("%7s", $aryA[0]);
|
||||
$name = sprintf("%-20s", $aryA[1]); while(length($name)>20) {chop($name);}
|
||||
$user = sprintf("%-8s", $aryA[2]);
|
||||
|
||||
### TOTAL ACTIVE TIME
|
||||
$active = ($aryA[3] + $aryA[4] + $aryA[5] + $aryA[6]);
|
||||
$TIME_S = $active;
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$active = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL TALK TIME
|
||||
$TIME_S = $aryA[3];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$talk = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL PAUSE TIME
|
||||
$TIME_S = $aryA[4];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$pause = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL WAIT TIME
|
||||
$TIME_S = $aryA[5];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$wait = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL DISPO TIME
|
||||
$TIME_S = $aryA[6];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$dispo = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
$stmtB = "select event_time,UNIX_TIMESTAMP(event_time) from $vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and user='$aryA[2]' order by event_time limit 1;";
|
||||
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
|
||||
$sthB->execute or die "executing: $stmtA ", $dbhB->errstr;
|
||||
@aryB = $sthB->fetchrow_array;
|
||||
$first_time = sprintf("%21s", $aryB[0]);
|
||||
$first_log = $aryB[1];
|
||||
|
||||
$stmtB = "select event_time,UNIX_TIMESTAMP(event_time) from $vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and user='$aryA[2]' order by event_time desc limit 1;";
|
||||
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
|
||||
$sthB->execute or die "executing: $stmtA ", $dbhB->errstr;
|
||||
@aryB = $sthB->fetchrow_array;
|
||||
$last_time = sprintf("%21s", $aryB[0]);
|
||||
$last_log = $aryB[1];
|
||||
|
||||
$TIME_S = ($last_log - $first_log);
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$login_time = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
|
||||
|
||||
print out "$name$user$calls$talk$pause$wait$dispo$active$login_time$first_time$last_time\n";
|
||||
print "$name$user$calls$talk$pause$wait$dispo$active$login_time$first_time$last_time\n";
|
||||
|
||||
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if ($h=='1')
|
||||
# {
|
||||
# exit;
|
||||
# }
|
||||
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
close(out);
|
||||
|
||||
### calculate time to run script ###
|
||||
$secY = time();
|
||||
$secZ = ($secY - $secX);
|
||||
$secZm = ($secZ /60);
|
||||
|
||||
print "script execution time in seconds: $secZ minutes: $secZm\n";
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user