diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE
index 0f537e46..ea245198 100644
--- a/agc_2-X/trunk/UPGRADE
+++ b/agc_2-X/trunk/UPGRADE
@@ -179,6 +179,10 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom
call_log, vicidial_log, vicidial_closer_log, vicidial_xfer_log and
vicidial_agent_log
+45. Added new Inbound Summary Hourly Report to show stats by in-group and broken
+ down per in-group in hourly increments. This report also allows
+ filtering of the stats by call time scheme.
+
diff --git a/agc_2-X/trunk/bin/AST_VDhopper.pl b/agc_2-X/trunk/bin/AST_VDhopper.pl
index 7b9f53b2..bd01c903 100644
--- a/agc_2-X/trunk/bin/AST_VDhopper.pl
+++ b/agc_2-X/trunk/bin/AST_VDhopper.pl
@@ -531,7 +531,7 @@ foreach(@campaign_id)
}
if ($DBX) {print "\n";}
- $stmtA = "SELECT * FROM vicidial_call_times where call_time_id='$local_call_time[$i]';";
+ $stmtA = "SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$local_call_time[$i]';";
if ($DBX) {print " |$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
diff --git a/agc_2-X/trunk/bin/AST_VDsales_export.pl b/agc_2-X/trunk/bin/AST_VDsales_export.pl
index 4ffd760a..99e9a7c9 100644
--- a/agc_2-X/trunk/bin/AST_VDsales_export.pl
+++ b/agc_2-X/trunk/bin/AST_VDsales_export.pl
@@ -21,6 +21,7 @@
# 90627-0757 - Added time addition when transfer recordings is enabled
# 90710-0514 - Fixes for data output formatting changes
# 90721-1314 - Added rank and owner as vicidial_list fields
+# 90731-0555 - Added call time scheme restriction
#
$txt = '.txt';
@@ -98,6 +99,7 @@ if (length($ARGV[0])>1)
print " NOTE: To include all statuses in the export, use \"--sale-statuses=---ALL---\"\n";
print " [--output-format=XXX] = Format of file. Default \"pipe-standard\"\n";
print " [--with-inbound=XXX-XXY] = include the following inbound groups\n";
+ print " [--calltime=XXX] = filter results to only include those calls during this call time\n";
print " [--ftp-transfer] = Send results file by FTP to another server\n";
print " [--ftp-audio-transfer] = Send associated audio files to FTP server, dated directories\n";
print " [--with-transfer-audio] = Different method for finding audio, also grabs transfer audio filenames\n";
@@ -211,6 +213,13 @@ if (length($ARGV[0])>1)
$with_inbound = $data_in[1];
$with_inbound =~ s/ .*$//gi;
}
+ if ($args =~ /--calltime=/i)
+ {
+ # print "\n|$ARGS|\n\n";
+ @data_in = split(/--calltime=/,$args);
+ $call_time = $data_in[1];
+ $call_time =~ s/ .*$//gi;
+ }
if ($args =~ /-ftp-transfer/i)
{
if (!$Q)
@@ -392,6 +401,11 @@ $with_inboundSQL = $with_inbound;
$with_inboundSQL =~ s/-/','/gi;
$with_inboundSQL = "'$with_inboundSQL'";
+if (length($campaignSQL) < 2)
+ {$campaignSQL = "vicidial_log.campaign_id NOT IN('')";}
+else
+ {$campaignSQL = "vicidial_log.campaign_id IN($campaignSQL)";}
+
if (!$Q)
{
print "\n\n\n\n\n\n\n\n\n\n\n\n-- AST_VDsales_export.pl --\n\n";
@@ -426,16 +440,68 @@ $dbhB = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
$TOTAL_SALES=0;
+
+$stmtA = "SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$call_time';";
+$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+$sthArows=$sthA->rows;
+ if ($DBX) {print " $sthArows|$stmtA|\n";}
+if ($sthArows > 0)
+ {
+ @aryA = $sthA->fetchrow_array;
+ $Gct_default_start = "$aryA[3]";
+ $Gct_default_stop = "$aryA[4]";
+ $Gct_sunday_start = "$aryA[5]";
+ $Gct_sunday_stop = "$aryA[6]";
+ $Gct_monday_start = "$aryA[7]";
+ $Gct_monday_stop = "$aryA[8]";
+ $Gct_tuesday_start = "$aryA[9]";
+ $Gct_tuesday_stop = "$aryA[10]";
+ $Gct_wednesday_start = "$aryA[11]";
+ $Gct_wednesday_stop = "$aryA[12]";
+ $Gct_thursday_start = "$aryA[13]";
+ $Gct_thursday_stop = "$aryA[14]";
+ $Gct_friday_start = "$aryA[15]";
+ $Gct_friday_stop = "$aryA[16]";
+ $Gct_saturday_start = "$aryA[17]";
+ $Gct_saturday_stop = "$aryA[18]";
+ $sthA->finish();
+
+ $CTstart = $Gct_default_start;
+ $CTstop = $Gct_default_stop;
+
+ if ( ($Cwday == 0) && ( ($Gct_sunday_start > 0) && ($Gct_sunday_stop > 0) ) )
+ {$CTstart = $Gct_sunday_start; $CTstop = $Gct_sunday_stop;}
+ if ( ($Cwday == 1) && ( ($Gct_monday_start > 0) && ($Gct_monday_stop > 0) ) )
+ {$CTstart = $Gct_monday_start; $CTstop = $Gct_monday_stop;}
+ if ( ($Cwday == 2) && ( ($Gct_tuesday_start > 0) && ($Gct_tuesday_stop > 0) ) )
+ {$CTstart = $Gct_tuesday_start; $CTstop = $Gct_tuesday_stop;}
+ if ( ($Cwday == 3) && ( ($Gct_wednesday_start > 0) && ($Gct_wednesday_stop > 0) ) )
+ {$CTstart = $Gct_wednesday_start; $CTstop = $Gct_wednesday_stop;}
+ if ( ($Cwday == 4) && ( ($Gct_thursday_start > 0) && ($Gct_thursday_stop > 0) ) )
+ {$CTstart = $Gct_thursday_start; $CTstop = $Gct_thursday_stop;}
+ if ( ($Cwday == 5) && ( ($Gct_friday_start > 0) && ($Gct_friday_stop > 0) ) )
+ {$CTstart = $Gct_friday_start; $CTstop = $Gct_friday_stop;}
+ if ( ($Cwday == 6) && ( ($Gct_saturday_start > 0) && ($Gct_saturday_stop > 0) ) )
+ {$CTstart = $Gct_saturday_start; $CTstop = $Gct_saturday_stop;}
+ }
+else
+ {
+ if ($DB > 0) {print "CALL TIME NOT FOUND: $call_time\n";}
+ $call_time='';
+ }
+
+
###########################################################################
########### CURRENT DAY SALES GATHERING outbound-only: vicidial_log ######
###########################################################################
-$stmtA = "select vicidial_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,vicidial_list.email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_log.list_id,title,address3,last_local_call_time,uniqueid,length_in_sec,vicidial_list.rank,vicidial_list.owner from vicidial_list,vicidial_log,vicidial_users where campaign_id IN($campaignSQL) $sale_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_log.user order by call_date;";
+$stmtA = "select vicidial_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,vicidial_list.email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_log.list_id,title,address3,last_local_call_time,uniqueid,length_in_sec,vicidial_list.list_id,vicidial_list.list_id,UNIX_TIMESTAMP(vicidial_log.call_date),vicidial_campaigns.campaign_name from vicidial_list,vicidial_log,vicidial_users,vicidial_campaigns where $campaignSQL $sale_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_log.user and vicidial_log.campaign_id=vicidial_campaigns.campaign_id order by call_date;";
#$stmtA = "select vicidial_users.user,first_name,last_name,address1,address2,city,state,postal_code,phone_number,email,security_phrase,comments,last_local_call_time,lead_id,vicidial_users.full_name,status,vendor_lead_code,source_id,list_id,title,address3,last_local_call_time from vicidial_list,vicidial_users where list_id NOT IN('999','998') $sale_statusesSQL and called_count > 0 and vicidial_users.user=vicidial_list.user;";
-if ($DB) {print "|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
+ if ($DB) {print "$sthArows|$stmtA|\n";}
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
@@ -466,7 +532,11 @@ while ($sthArows > $rec_count)
$length_in_sec = $aryA[23];
$rank = $aryA[24];
$owner = $aryA[25];
+ $epoch = $aryA[26];
+ $did_name = $aryA[27];
+ $outbound = 'Y';
+ $domestic = 'N';
$queue_seconds = '0';
$closer='';
@@ -481,11 +551,11 @@ if (length($with_inboundSQL)>3)
###########################################################################
########### CURRENT DAY SALES GATHERING inbound-only: vicidial_closer_log ######
###########################################################################
- $stmtA = "select vicidial_closer_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,vicidial_list.email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_closer_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_closer_log.list_id,campaign_id,title,address3,last_local_call_time,xfercallid,closecallid,uniqueid,length_in_sec,queue_seconds,vicidial_list.rank,vicidial_list.owner from vicidial_list,vicidial_closer_log,vicidial_users where campaign_id IN($with_inboundSQL) $close_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_closer_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_closer_log.user order by call_date;";
- if ($DB) {print "|$stmtA|\n";}
+ $stmtA = "select vicidial_closer_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,vicidial_list.email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_closer_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_closer_log.list_id,campaign_id,title,address3,last_local_call_time,xfercallid,closecallid,uniqueid,length_in_sec,queue_seconds,vicidial_list.list_id,vicidial_list.list_id,UNIX_TIMESTAMP(vicidial_closer_log.call_date) from vicidial_list,vicidial_closer_log,vicidial_users where campaign_id IN($with_inboundSQL) $close_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_closer_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_closer_log.user order by call_date;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
+ if ($DB) {print "$sthArows|$stmtA|\n";}
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -520,7 +590,10 @@ if (length($with_inboundSQL)>3)
$queue_seconds = $aryA[27];
$rank = $aryA[28];
$owner = $aryA[29];
+ $epoch = $aryA[30];
+ $outbound = 'N';
+ $domestic = 'N';
$user = '';
$agent_name='';
@@ -600,6 +673,11 @@ if ( (length($Ealert)>5) && (length($email_list) > 3) )
# $VARREPORT_user = 'cron';
# $VARREPORT_pass = 'test';
# $VARREPORT_dir = '';
+ $VARREPORT_host = 'ftp.aats-inc.com';
+ $VARREPORT_port = '21';
+ $VARREPORT_user = 'aats-inc.com';
+ $VARREPORT_pass = '_dMujnvf_';
+ $VARREPORT_dir = '';
$NODATEDIR = 0; # Don't use dated directories for audio
$YEARDIR = 1; # put dated directories in a year directory first
@@ -659,6 +737,7 @@ $secZm = ($secZ /60);
if (!$Q) {print "SALES EXPORT FOR $shipdate: $outfile\n";}
if (!$Q) {print "TOTAL SALES: $TOTAL_SALES\n";}
+if (!$Q) {print "TOTAL EXCLUDED BY CALLTIME: $CALLTIME_KICK\n";}
if (!$Q) {print "script execution time in seconds: $secZ minutes: $secZm\n";}
exit;
@@ -670,43 +749,45 @@ exit;
### Subroutine for formatting of the output ###
sub select_format_loop
{
- $str='';
- if ($T)
- {
- # $user = '1234';
- $agent_name = 'Joe Agent';
- # $closer = '4321';
- $closer_name = 'Jane Closer';
- $security = '4111111111111111';
- $comments = 'VISA';
- $phone_number =~ s/^\d\d\d\d\d/23456/gi;
- $address1 =~ s/^..../1234 /gi
- }
+ $within_calltime = 1;
- ##### BEGIN standard audio lookup #####
- if ($with_transfer_audio < 1)
+ if (length($call_time) > 0)
{
- $ivr_id = '0';
- $ivr_filename = '';
+ $CTtarget = ($secX - 10);
+ ($Csec,$Cmin,$Chour,$Cmday,$Cmon,$Cyear,$Cwday,$Cyday,$Cisdst) = localtime($epoch);
+ if ($Chour < 10) {$Chour = "0$Chour";}
+ if ($Cmin < 10) {$Cmin = "0$Cmin";}
+ $CThourminute = "$Chour$Cmin";
- $stmtB = "select recording_id,filename,location from recording_log where lead_id='$lead_id' and start_time > '$shipdate 00:00:01' and start_time < '$shipdate 23:59:59' order by length_in_sec desc limit 1;";
- $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
- $sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
- $sthBrows=$sthB->rows;
- $rec_countB=0;
- while ($sthBrows > $rec_countB)
+ if ( ($CThourminute < $CTstart) || ($CThourminute > $CTstop) )
{
- @aryB = $sthB->fetchrow_array;
- $ivr_id = $aryB[0];
- $ivr_filename = $aryB[1];
- $ivr_location = $aryB[2];
- $rec_countB++;
+ if ($DB > 0) {print "Call is outside of defined call time: $CThourminute|$Cwday| |$CTstart|$CTstop| \n";}
+ $within_calltime=0;
}
- $sthB->finish();
-
- if (length($ivr_id)<3)
+ }
+
+ if ($within_calltime > 0)
+ {
+ $str='';
+ if ($T)
{
- $stmtB = "select recording_id,filename,location from recording_log where lead_id='$lead_id' order by length_in_sec desc limit 1;";
+ # $user = '1234';
+ $agent_name = 'Joe Agent';
+ # $closer = '4321';
+ $closer_name = 'Jane Closer';
+ $security = '4111111111111111';
+ $comments = 'VISA';
+ $phone_number =~ s/^\d\d\d\d\d/23456/gi;
+ $address1 =~ s/^..../1234 /gi
+ }
+
+ ##### BEGIN standard audio lookup #####
+ if ($with_transfer_audio < 1)
+ {
+ $ivr_id = '0';
+ $ivr_filename = '';
+
+ $stmtB = "select recording_id,filename,location from recording_log where lead_id='$lead_id' and start_time > '$shipdate 00:00:01' and start_time < '$shipdate 23:59:59' order by length_in_sec desc limit 1;";
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
$sthBrows=$sthB->rows;
@@ -723,7 +804,7 @@ sub select_format_loop
if (length($ivr_id)<3)
{
- $stmtB = "select recording_id,filename,location from recording_log where filename LIKE \"%$phone_number%\" order by length_in_sec desc limit 1;";
+ $stmtB = "select recording_id,filename,location from recording_log where lead_id='$lead_id' order by length_in_sec desc limit 1;";
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
$sthBrows=$sthB->rows;
@@ -737,82 +818,51 @@ sub select_format_loop
$rec_countB++;
}
$sthB->finish();
+
+ if (length($ivr_id)<3)
+ {
+ $stmtB = "select recording_id,filename,location from recording_log where filename LIKE \"%$phone_number%\" order by length_in_sec desc limit 1;";
+ $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
+ $sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
+ $sthBrows=$sthB->rows;
+ $rec_countB=0;
+ while ($sthBrows > $rec_countB)
+ {
+ @aryB = $sthB->fetchrow_array;
+ $ivr_id = $aryB[0];
+ $ivr_filename = $aryB[1];
+ $ivr_location = $aryB[2];
+ $rec_countB++;
+ }
+ $sthB->finish();
+ }
}
- }
- if ( ($ftp_audio_transfer > 0) && (length($ivr_filename) > 3) && (length($ivr_location) > 5) )
- {
- @ivr_path = split(/\//,$ivr_location);
- $path_file = $ivr_path[$#ivr_path];
- `$wgetbin -q --output-document=$tempdir/$path_file $ivr_location `;
- }
- }
- ##### END standard audio lookup #####
-
- ##### BEGIN transfer audio lookup #####
- else
- {
- $ivr_id = '0';
- $ivr_filename = '';
- $ivr_location = '';
-
- $stmtB = "select recording_id,filename,location from recording_log where vicidial_id='$vicidial_id' and start_time > '$shipdate 00:00:01' and start_time < '$shipdate 23:59:59' order by start_time limit 10;";
- $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
- $sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
- $sthBrows=$sthB->rows;
- $rec_countB=0;
- while ($sthBrows > $rec_countB)
- {
- @aryB = $sthB->fetchrow_array;
- if ($rec_countB > 0)
+ if ( ($ftp_audio_transfer > 0) && (length($ivr_filename) > 3) && (length($ivr_location) > 5) )
{
- $ivr_id .= "|";
- $ivr_filename .= "|";
- }
- $ivr_id .= "$aryB[0]";
- $ivr_location = "$aryB[2]";
- @ivr_path = split(/\//,$ivr_location);
- $path_file = $ivr_path[$#ivr_path];
- $ivr_filename .= "$path_file";
- $rec_countB++;
- if ($ftp_audio_transfer > 0)
- {
- `$wgetbin -q --output-document=$tempdir/$path_file $aryB[2] `;
+ @ivr_path = split(/\//,$ivr_location);
+ $path_file = $ivr_path[$#ivr_path];
+ `$wgetbin -q --output-document=$tempdir/$path_file $ivr_location `;
}
}
- $sthB->finish();
+ ##### END standard audio lookup #####
- ### Look for other closer calls after this call
- $more_calls[0]='';
- $stmtB = "select closecallid,length_in_sec,queue_seconds from vicidial_closer_log where lead_id='$lead_id' and call_date > '$call_date' and call_date < '$shipdate 23:59:59' order by call_date limit 10;";
- $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
- $sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
- $sthBrows=$sthB->rows;
- $rec_countB=0;
- while ($sthBrows > $rec_countB)
+ ##### BEGIN transfer audio lookup #####
+ else
{
- @aryB = $sthB->fetchrow_array;
- $more_calls[$rec_countB] = "$aryB[0]";
- $length_in_sec = ($length_in_sec + $aryB[1]);
- $queue_seconds = ($queue_seconds + $aryB[2]);
- $rec_countB++;
- }
- $sthB->finish();
+ $ivr_id = '0';
+ $ivr_filename = '';
+ $ivr_location = '';
- $u=0;
- while ($sthBrows > $u)
- {
- $closecallid = $more_calls[$u];
-
- $stmtB = "select recording_id,filename,location from recording_log where vicidial_id='$closecallid' and start_time > '$shipdate 00:00:01' and start_time < '$shipdate 23:59:59' order by start_time limit 10;";
+ $stmtB = "select recording_id,filename,location from recording_log where vicidial_id='$vicidial_id' and start_time > '$shipdate 00:00:01' and start_time < '$shipdate 23:59:59' order by start_time limit 10;";
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
- $sthBrowsR=$sthB->rows;
- $rec_countBR=0;
- while ($sthBrowsR > $rec_countBR)
+ $sthBrows=$sthB->rows;
+ $rec_countB=0;
+ while ($sthBrows > $rec_countB)
{
@aryB = $sthB->fetchrow_array;
- if (length($ivr_id) > 1)
+ if ($rec_countB > 0)
{
$ivr_id .= "|";
$ivr_filename .= "|";
@@ -822,7 +872,7 @@ sub select_format_loop
@ivr_path = split(/\//,$ivr_location);
$path_file = $ivr_path[$#ivr_path];
$ivr_filename .= "$path_file";
- $rec_countBR++;
+ $rec_countB++;
if ($ftp_audio_transfer > 0)
{
`$wgetbin -q --output-document=$tempdir/$path_file $aryB[2] `;
@@ -830,160 +880,225 @@ sub select_format_loop
}
$sthB->finish();
- $u++;
+ ### Look for other closer calls after this call
+ $more_calls[0]='';
+ $stmtB = "select closecallid,length_in_sec,queue_seconds from vicidial_closer_log where lead_id='$lead_id' and call_date > '$call_date' and call_date < '$shipdate 23:59:59' order by call_date limit 10;";
+ $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
+ $sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
+ $sthBrows=$sthB->rows;
+ $rec_countB=0;
+ while ($sthBrows > $rec_countB)
+ {
+ @aryB = $sthB->fetchrow_array;
+ $more_calls[$rec_countB] = "$aryB[0]";
+ $length_in_sec = ($length_in_sec + $aryB[1]);
+ $queue_seconds = ($queue_seconds + $aryB[2]);
+ $rec_countB++;
+ }
+ $sthB->finish();
+
+ $u=0;
+ while ($sthBrows > $u)
+ {
+ $closecallid = $more_calls[$u];
+
+ $stmtB = "select recording_id,filename,location from recording_log where vicidial_id='$closecallid' and start_time > '$shipdate 00:00:01' and start_time < '$shipdate 23:59:59' order by start_time limit 10;";
+ $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
+ $sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
+ $sthBrowsR=$sthB->rows;
+ $rec_countBR=0;
+ while ($sthBrowsR > $rec_countBR)
+ {
+ @aryB = $sthB->fetchrow_array;
+ if (length($ivr_id) > 1)
+ {
+ $ivr_id .= "|";
+ $ivr_filename .= "|";
+ }
+ $ivr_id .= "$aryB[0]";
+ $ivr_location = "$aryB[2]";
+ @ivr_path = split(/\//,$ivr_location);
+ $path_file = $ivr_path[$#ivr_path];
+ $ivr_filename .= "$path_file";
+ $rec_countBR++;
+ if ($ftp_audio_transfer > 0)
+ {
+ `$wgetbin -q --output-document=$tempdir/$path_file $aryB[2] `;
+ }
+ }
+ $sthB->finish();
+
+ $u++;
+ }
}
- }
- ##### END transfer audio lookup #####
+ ##### END transfer audio lookup #####
- ##### BEGIN DID lookup #####
- if ($with_did_lookup > 0)
- {
- $did_pattern = '';
- $did_name = '';
- $did_date = '';
-
- $stmtB = "select did_pattern,did_description,call_date from vicidial_inbound_dids vid,vicidial_did_log vdl where uniqueid='$uniqueid' and call_date > '$shipdate 00:00:01' and call_date <= '$call_date' and vid.did_id=vdl.did_id order by call_date desc limit 1;";
- if ($DB > 0) {print "$stmtB\n";}
- $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
- $sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
- $sthBrows=$sthB->rows;
- if ($sthBrows > 0)
+ ##### BEGIN DID lookup #####
+ if ( ($with_did_lookup > 0) && ($outbound =~ /N/) )
{
- @aryB = $sthB->fetchrow_array;
- $did_pattern = "$aryB[0]";
- $did_name = "$aryB[1]";
- $did_date = "$aryB[2]";
+ $did_pattern = '';
+ $did_name = '';
+ $did_date = '';
+
+ $stmtB = "select did_pattern,did_description,call_date from vicidial_inbound_dids vid,vicidial_did_log vdl where uniqueid='$uniqueid' and call_date > '$shipdate 00:00:01' and call_date <= '$call_date' and vid.did_id=vdl.did_id order by call_date desc limit 1;";
+ if ($DBX > 0) {print "$stmtB\n";}
+ $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
+ $sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
+ $sthBrows=$sthB->rows;
+ if ($sthBrows > 0)
+ {
+ @aryB = $sthB->fetchrow_array;
+ $did_pattern = "$aryB[0]";
+ $did_name = "$aryB[1]";
+ $did_date = "$aryB[2]";
+ $sthB->finish();
+ }
}
- $sthB->finish();
- }
- ##### BEGIN DID lookup #####
+ ##### BEGIN DID lookup #####
- if ($status =~ /UPSELL/) {$UPSELL='L5';}
- else {$UPSELL='N';}
+ if ($status =~ /UPSELL/) {$UPSELL='L5';}
+ else {$UPSELL='N';}
- if ($output_format =~ /^pipe-standard$/)
- {
- $str = "$first_name|$last_name|$address1|$address2|$city|$state|$postal_code|$phone_number|$email|$security|$comments|$call_date|$lead_id|$list_id|$user|$agent_name|$status|$vendor_id|$source_id|$campaign|$campaign_id|$ivr_id|$closer|$closer_name|$rank|$owner|\n";
- }
-
- if ($output_format =~ /^csv-standard$/)
- {
- $str = "\"$first_name\",\"$last_name\",\"$address1\",\"$address2\",\"$city\",\"$state\",\"$postal_code\",\"$phone_number\",\"$email\",\"$security\",\"$comments\",\"$call_date\",\"$lead_id\",\"$list_id\",\"$user\",\"$agent_name\",\"$status\",\"$vendor_id\",\"$source_id\",\"$campaign\",\"$campaign_id\",\"$ivr_id\",\"$closer\",\"$closer_name\",\"$rank\",\"$owner\"\r\n";
- }
-
- if ($output_format =~ /^tab-standard$/)
- {
- $str = "$first_name\t$last_name\t$address1\t$address2\t$city\t$state\t$postal_code\t$phone_number\t$email\t$security\t$comments\t$call_date\t$lead_id\t$list_id\t$user\t$agent_name\t$status\t$vendor_id\t$source_id\t$campaign\t$campaign_id\t$ivr_id\t$closer\t$closer_name\t$rank\t$owner\t\n";
- }
-
- if ($output_format =~ /^pipe-triplep$/)
- {
- $str = "$user|$agent_name|$closer|$closer_name|$call_date|$status|$first_name|$last_name|$phone_number|$address1|$address2|$city|$state|$postal_code|$comments|$security|$email|$vendor_id|$source_id|$lead_id|$list_id|$campaign|$campaign_id|$ivr_id|\n";
- }
-
- if ($output_format =~ /^pipe-vici$/)
- {
- $str = "VDAD|$agent_name|$first_name|$last_name|$address1|$address2|$city|$state|$postal_code|$phone_number|$ivr_id|DU|$UPSELL|N|||$security|$comments||||||$call_date|CBDISC|$email\r\n";
- }
-
- if ($output_format =~ /^html-rec$/)
- {
- $str = "$user|$agent_name|$closer|$closer_name|$call_date|$status|$first_name|$last_name|$phone_number|$address1|$address2|$city|$state|$postal_code|$comments|$security|$email|$vendor_id|$source_id|$lead_id|$list_id|$campaign|$campaign_id|$ivr_id|\n";
- }
-
- if ($output_format =~ /^fixed-as400$/)
- {
- # 16884259 MRS. JEAN BROWN RISALPUR BROMSBERROW HEATYH LEDBURY HEREFORDSHIRE ENGLAND HR8 1PQ 01531650052 1209200809:52NI 3205UK
- $vendor_id = sprintf("%-10s",$vendor_id); while(length($vendor_id)>10) {$vendor_id =~ s/.$//gi;}
- $title = sprintf("%-10s",$title); while(length($title)>10) {$title =~ s/.$//gi;}
- $first_name = sprintf("%-15s",$first_name); while(length($first_name)>15) {$first_name =~ s/.$//gi;}
- $last_name = sprintf("%-20s",$last_name); while(length($last_name)>20) {$last_name =~ s/.$//gi;}
- $address1 = sprintf("%-30s",$address1); while(length($address1)>30) {$address1 =~ s/.$//gi;}
- $address2 = sprintf("%-30s",$address2); while(length($address2)>30) {$address2 =~ s/.$//gi;}
- $address3 = sprintf("%-30s",$address3); while(length($address3)>30) {$address3 =~ s/.$//gi;}
- $city = sprintf("%-50s",$city); while(length($city)>50) {$city =~ s/.$//gi;}
- $postal_code = sprintf("%-9s",$postal_code); while(length($postal_code)>9) {$postal_code =~ s/.$//gi;}
- $phone_number = sprintf("%-20s",$phone_number); while(length($phone_number)>20) {$phone_number =~ s/.$//gi;}
- @dtsplit = split(" ",$last_local_call_time);
- @datesplit = split("-",$dtsplit[0]);
- $timesplit = substr($dtsplit[1], 0, 5);
- $formatted_date = "$datesplit[1]$datesplit[2]$datesplit[0]$timesplit";
- $user = sprintf("%-4s",$user);
- if ($status =~ /^AA$/) {$status = 'A';}
- if ($status =~ /^A$/) {$status = 'A';}
- if ($status =~ /^B$/) {$status = 'B';}
- if ($status =~ /^N$/) {$status = 'N';}
- if ($status =~ /^NA$/) {$status = 'N';}
- if ($status =~ /^NP$/) {$status = 'N';}
- if ($status =~ /^PU$/) {$status = 'N';}
- if ($status =~ /^DROP$/) {$status = 'N';}
- if ($status =~ /^SALE$/) {$status = 'AP';}
- if ($status =~ /^A6$/) {$status = 'A6';}
- if ($status =~ /^DC$/) {$status = 'D';}
- if ($status =~ /^DNC$/) {$status = 'DC';}
- if ($status =~ /^DNCL$/) {$status = 'DC';}
- if ($status =~ /^DIED$/) {$status = 'DD';}
- if ($status =~ /^COMP$/) {$status = 'DD';}
- if ($status =~ /^DEC$/) {$status = 'DD';}
- if ($status =~ /^ERI$/) {$status = 'DD';}
- if ($status =~ /^INCALL$/) {$status = 'DD';}
- if ($status =~ /^SP$/) {$status = 'DD';}
- if ($status =~ /^WRON$/) {$status = 'DD';}
- if ($status =~ /^HBED$/) {$status = 'DD';}
- if ($status =~ /^CALLBK$/) {$status = 'A6';}
- if ($status =~ /^HAP1$/) {$status = 'NI';}
- if ($status =~ /^HAP2$/) {$status = 'NI';}
- if ($status =~ /^NI$/) {$status = 'NI';}
-
- $status = sprintf("%-16s",$status); while(length($status)>16) {$status =~ s/.$//gi;}
- $user =~ s/VDAD/ /gi;
- $UK = 'UK';
-
- $str = "$vendor_id$title$first_name$last_name$address1$address2$address3$city$postal_code$phone_number$formatted_date$status$user$UK\r\n";
- }
-
- if ($output_format =~ /^tab-QMcustomUSA$/)
- {
- # 1245328655100219 2009-06-18 05:37:35 937 9375551212 8185551223 8106 35 255 0 DSAW - q8187-20090618-053939-1245328655.100219.WAV|q8186-20090618-053735-1245328655.100219.WAV
- # 1- unique number (digits only)
- # 2- date
- # 3- time
- # 4- CID arecode
- # 5- CID full
- # 6- DID
- # 7- user
- # 8- hold time (seconds)
- # 9- talk time (seconds)
- # 10- after call work time (seconds)
- # 11- application name, 4 characters
- # 12- order number (just a dash for now '-')
- # 13- call recording filenames
-
- $uniqueid =~ s/\D//gi;
- @call_date_array = split(/ /,$call_date);
- while (length($phone_number)>10) {$phone_number =~ s/^.//gi;}
- $phone_areacode = substr($phone_number, 0, 3);
- if (length($closer) < 1) {$closer = $user;}
- $application = substr($did_name, 0, 4);
- $queue_seconds = int($queue_seconds + .5);
- $talk_seconds = ($length_in_sec - $queue_seconds);
- $dispo_time = 0;
-
- if ($uniqueidLIST !~ /\|$uniqueid\|/)
+ if ($output_format =~ /^pipe-standard$/)
{
- $str = "$uniqueid\t$call_date_array[0]\t$call_date_array[1]\t$phone_areacode\t$phone_number\t$did_pattern\t$closer\t$queue_seconds\t$talk_seconds\t$dispo_time\t$application\t-\t$ivr_filename\t\n";
-
- $uniqueidLIST .= "$uniqueid|";
- if ($DB > 0) {print "UNIQUE: -----$uniqueidLIST-----$uniqueid";}
+ $str = "$first_name|$last_name|$address1|$address2|$city|$state|$postal_code|$phone_number|$email|$security|$comments|$call_date|$lead_id|$list_id|$user|$agent_name|$status|$vendor_id|$source_id|$campaign|$campaign_id|$ivr_id|$closer|$closer_name|$rank|$owner|\n";
}
+ if ($output_format =~ /^csv-standard$/)
+ {
+ $str = "\"$first_name\",\"$last_name\",\"$address1\",\"$address2\",\"$city\",\"$state\",\"$postal_code\",\"$phone_number\",\"$email\",\"$security\",\"$comments\",\"$call_date\",\"$lead_id\",\"$list_id\",\"$user\",\"$agent_name\",\"$status\",\"$vendor_id\",\"$source_id\",\"$campaign\",\"$campaign_id\",\"$ivr_id\",\"$closer\",\"$closer_name\",\"$rank\",\"$owner\"\r\n";
+ }
+
+ if ($output_format =~ /^tab-standard$/)
+ {
+ $str = "$first_name\t$last_name\t$address1\t$address2\t$city\t$state\t$postal_code\t$phone_number\t$email\t$security\t$comments\t$call_date\t$lead_id\t$list_id\t$user\t$agent_name\t$status\t$vendor_id\t$source_id\t$campaign\t$campaign_id\t$ivr_id\t$closer\t$closer_name\t$rank\t$owner\t\n";
+ }
+
+ if ($output_format =~ /^pipe-triplep$/)
+ {
+ $str = "$user|$agent_name|$closer|$closer_name|$call_date|$status|$first_name|$last_name|$phone_number|$address1|$address2|$city|$state|$postal_code|$comments|$security|$email|$vendor_id|$source_id|$lead_id|$list_id|$campaign|$campaign_id|$ivr_id|\n";
+ }
+
+ if ($output_format =~ /^pipe-vici$/)
+ {
+ $str = "VDAD|$agent_name|$first_name|$last_name|$address1|$address2|$city|$state|$postal_code|$phone_number|$ivr_id|DU|$UPSELL|N|||$security|$comments||||||$call_date|CBDISC|$email\r\n";
+ }
+
+ if ($output_format =~ /^html-rec$/)
+ {
+ $str = "$user|$agent_name|$closer|$closer_name|$call_date|$status|$first_name|$last_name|$phone_number|$address1|$address2|$city|$state|$postal_code|$comments|$security|$email|$vendor_id|$source_id|$lead_id|$list_id|$campaign|$campaign_id|$ivr_id|\n";
+ }
+
+ if ($output_format =~ /^fixed-as400$/)
+ {
+ # 16884259 MRS. JEAN BROWN RISALPUR BROMSBERROW HEATYH LEDBURY HEREFORDSHIRE ENGLAND HR8 1PQ 01531650052 1209200809:52NI 3205UK
+ $vendor_id = sprintf("%-10s",$vendor_id); while(length($vendor_id)>10) {$vendor_id =~ s/.$//gi;}
+ $title = sprintf("%-10s",$title); while(length($title)>10) {$title =~ s/.$//gi;}
+ $first_name = sprintf("%-15s",$first_name); while(length($first_name)>15) {$first_name =~ s/.$//gi;}
+ $last_name = sprintf("%-20s",$last_name); while(length($last_name)>20) {$last_name =~ s/.$//gi;}
+ $address1 = sprintf("%-30s",$address1); while(length($address1)>30) {$address1 =~ s/.$//gi;}
+ $address2 = sprintf("%-30s",$address2); while(length($address2)>30) {$address2 =~ s/.$//gi;}
+ $address3 = sprintf("%-30s",$address3); while(length($address3)>30) {$address3 =~ s/.$//gi;}
+ $city = sprintf("%-50s",$city); while(length($city)>50) {$city =~ s/.$//gi;}
+ $postal_code = sprintf("%-9s",$postal_code); while(length($postal_code)>9) {$postal_code =~ s/.$//gi;}
+ $phone_number = sprintf("%-20s",$phone_number); while(length($phone_number)>20) {$phone_number =~ s/.$//gi;}
+ @dtsplit = split(" ",$last_local_call_time);
+ @datesplit = split("-",$dtsplit[0]);
+ $timesplit = substr($dtsplit[1], 0, 5);
+ $formatted_date = "$datesplit[1]$datesplit[2]$datesplit[0]$timesplit";
+ $user = sprintf("%-4s",$user);
+ if ($status =~ /^AA$/) {$status = 'A';}
+ if ($status =~ /^A$/) {$status = 'A';}
+ if ($status =~ /^B$/) {$status = 'B';}
+ if ($status =~ /^N$/) {$status = 'N';}
+ if ($status =~ /^NA$/) {$status = 'N';}
+ if ($status =~ /^NP$/) {$status = 'N';}
+ if ($status =~ /^PU$/) {$status = 'N';}
+ if ($status =~ /^DROP$/) {$status = 'N';}
+ if ($status =~ /^SALE$/) {$status = 'AP';}
+ if ($status =~ /^A6$/) {$status = 'A6';}
+ if ($status =~ /^DC$/) {$status = 'D';}
+ if ($status =~ /^DNC$/) {$status = 'DC';}
+ if ($status =~ /^DNCL$/) {$status = 'DC';}
+ if ($status =~ /^DIED$/) {$status = 'DD';}
+ if ($status =~ /^COMP$/) {$status = 'DD';}
+ if ($status =~ /^DEC$/) {$status = 'DD';}
+ if ($status =~ /^ERI$/) {$status = 'DD';}
+ if ($status =~ /^INCALL$/) {$status = 'DD';}
+ if ($status =~ /^SP$/) {$status = 'DD';}
+ if ($status =~ /^WRON$/) {$status = 'DD';}
+ if ($status =~ /^HBED$/) {$status = 'DD';}
+ if ($status =~ /^CALLBK$/) {$status = 'A6';}
+ if ($status =~ /^HAP1$/) {$status = 'NI';}
+ if ($status =~ /^HAP2$/) {$status = 'NI';}
+ if ($status =~ /^NI$/) {$status = 'NI';}
+
+ $status = sprintf("%-16s",$status); while(length($status)>16) {$status =~ s/.$//gi;}
+ $user =~ s/VDAD/ /gi;
+ $UK = 'UK';
+
+ $str = "$vendor_id$title$first_name$last_name$address1$address2$address3$city$postal_code$phone_number$formatted_date$status$user$UK\r\n";
+ }
+
+ if ($output_format =~ /^tab-QMcustomUSA$/)
+ {
+ # 1245328655100219 2009-06-18 05:37:35 937 9375551212 8185551223 8106 35 255 0 DSAW - q8187-20090618-053939-1245328655.100219.WAV|q8186-20090618-053735-1245328655.100219.WAV
+ # 1- unique number (digits only)
+ # 2- date
+ # 3- time
+ # 4- CID arecode
+ # 5- CID full
+ # 6- DID
+ # 7- user
+ # 8- hold time (seconds)
+ # 9- talk time (seconds)
+ # 10- after call work time (seconds)
+ # 11- application name, 4 characters
+ # 12- order number (just a dash for now '-')
+ # 13- call recording filenames
+
+ $uniqueid =~ s/\D//gi;
+ @call_date_array = split(/ /,$call_date);
+ while (length($phone_number)>10) {$phone_number =~ s/^.//gi;}
+ $phone_areacode = substr($phone_number, 0, 3);
+ if (length($closer) < 1) {$closer = $user;}
+ if ($closer =~ /VDCL|VDAD/) {$closer='-';}
+ $application = substr($did_name, 0, 4);
+ $queue_seconds = int($queue_seconds + .5);
+ $talk_seconds = ($length_in_sec - $queue_seconds);
+ $dispo_time = 0;
+
+ if ($uniqueidLIST !~ /\|$uniqueid\|/)
+ {
+ $str = "$uniqueid\t$call_date_array[0]\t$call_date_array[1]\t$phone_areacode\t$phone_number\t$did_pattern\t$closer\t$queue_seconds\t$talk_seconds\t$dispo_time\t$application\t-\t$ivr_filename\t$outbound\t$domestic\t\n";
+
+ $uniqueidLIST .= "$uniqueid|";
+ if ($DBX > 0) {print "UNIQUE: -----$uniqueidLIST-----$uniqueid";}
+ }
+
+ }
+
+ $Ealert .= "$str";
+
+ print out "$str";
+ if ($DBX) {print "$str\n";}
}
+ else
+ {$CALLTIME_KICK++;}
- $Ealert .= "$str";
-
- print out "$str";
- if ($DBX) {print "$str\n";}
-
+ if ($DB > 0)
+ {
+ if ($rec_count =~ /10$/i) {print STDERR "0 $rec_count\r";}
+ if ($rec_count =~ /20$/i) {print STDERR "+ $rec_count\r";}
+ if ($rec_count =~ /30$/i) {print STDERR "| $rec_count\r";}
+ if ($rec_count =~ /40$/i) {print STDERR "\\ $rec_count\r";}
+ if ($rec_count =~ /50$/i) {print STDERR "- $rec_count\r";}
+ if ($rec_count =~ /60$/i) {print STDERR "/ $rec_count\r";}
+ if ($rec_count =~ /70$/i) {print STDERR "| $rec_count\r";}
+ if ($rec_count =~ /80$/i) {print STDERR "+ $rec_count\r";}
+ if ($rec_count =~ /90$/i) {print STDERR "0 $rec_count\r";}
+ if ($rec_count =~ /00$/i) {print "$rec_count|$TOTAL_SALES|$CALLTIME_KICK| |$phone_number|\n";}
+ }
$rec_count++;
}
diff --git a/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl b/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl
index 93fe076c..2df5f9e4 100644
--- a/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl
+++ b/agc_2-X/trunk/bin/VICIDIAL_IN_new_leads_file.pl
@@ -35,6 +35,7 @@
# 90401-1340 - Fixed quiet flag functionality
# 90721-1315 - Added rank and owner as vicidial_list fields, stdrankowner format
# 90728-1255 - Added fixed254 file format
+# 90802-0758 - Added sctab08 file format
#
$secX = time();
@@ -154,7 +155,9 @@ if (length($ARGV[0])>1)
print "fixed254:\n";
print "fixed width(without the quotes)\n";
print "\"9185551212ROSE SMITHS 155 TIGER MOUNTAIN RD. RR 1 BOX 107 HENRYETTA OK74437-941DEMG 226555 0 \"\n\n";
-
+ print "sctab08:\n"
+ print "STATE\tNAME\tPHONE\tFAX\tADDRESS\tADDRESS2\tCITY\tZIP\n";
+ print "AL\tTom Wilson\t205 5551212\t\t 1689 15th Ave\t\tBESSEMER\t35020\n\n";
exit;
}
@@ -568,6 +571,43 @@ foreach(@FILES)
$format_set++;
}
+ # This is the format for the sctab08 lead files
+ # STATE\tNAME\tPHONE\tFAX\tADDRESS\tADDRESS2\tCITY\tZIP\n";
+ # AL\tTom Wilson\t205 5551212\t\t 1689 15th Ave\t\tBESSEMER\t35020
+ if ( ($format =~ /sctab08/) && ($format_set < 1) )
+ {
+ @name=@MT;
+ $vendor_lead_code = '';
+ $source_code = '';
+ $list_id = '995';
+ $phone_code = '1';
+ $phone_number = $m[2]; chomp($phone_number); $phone_number =~ s/\D//gi;
+ $USarea = substr($phone_number, 0, 3);
+ $title = '';
+ $full_name = $m[1]; @name = split(/ /, $full_name);
+ $first_name = $name[1]; chomp($first_name);
+ $last_name = "$name[0] $name[2]"; chomp($first_name);
+ $middle_initial = '';
+ $address1 = $m[4]; chomp($address1);
+ $address2 = $m[5]; chomp($address1);
+ $address3 = '';
+ $city = $m[6]; chomp($city);
+ $state = $m[0]; chomp($state);
+ $province = '';
+ $postal_code = $m[7]; chomp($postal_code);
+ $country = 'USA';
+ $gender = 'U';
+ $date_of_birth = '0000-00-00';
+ $alt_phone = $m[3]; chomp($alt_phone); $alt_phone =~ s/\D//gi;
+ $email = '';
+ $security_phrase = '';
+ $comments = '';
+ $called_count = 0;
+ $status = 'NEW';
+
+ $format_set++;
+ }
+
# This is the format for the stdrankowner lead files (standard plus rank and owner )
#3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS|COUNT|STATUS|INS-DATE|RANK|OWNER
if ( ($format =~ /stdrankowner/) && ($format_set < 1) )
diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt
index 42c8d1fc..0d0233a3 100644
--- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt
+++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt
@@ -257,6 +257,7 @@ Agent Display Dialable Leads||
This option if enabled will show the number of dialable leads available in the campaign in the agent screen. This number is updated in the system once a minute and will be refreshed on the agent screen every few seconds||
VICIDIAL Balance Rank||
This field allows you to set the order in which this server is to be used for balance dialing, if balance dialing is enabled. The server with the highest rank will be used first in placing Balance fill calls. Default is 0||
+Inbound Summary Hourly Report||
add-file: user_territories.php
diff --git a/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php b/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php
index 145901e1..ae53c78d 100644
--- a/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php
+++ b/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php
@@ -11,6 +11,7 @@
# 80528-2320 - fixed small calculation bugs and display bugs, added more shifts
# 90310-2117 - Added admin header
# 90508-0644 - Changed to PHP long tags
+# 90801-0923 - Added in-group name to pulldown
#
require("dbconnect.php");
@@ -60,7 +61,7 @@ $row=mysql_fetch_row($rslt);
$auth=$row[0];
- if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
@@ -75,7 +76,7 @@ if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($end_date)) {$end_date = $NOW_DATE;}
-$stmt="select group_id from vicidial_inbound_groups;";
+$stmt="select group_id,group_name from vicidial_inbound_groups;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$groups_to_print = mysql_num_rows($rslt);
@@ -83,7 +84,8 @@ $i=0;
while ($i < $groups_to_print)
{
$row=mysql_fetch_row($rslt);
- $groups[$i] =$row[0];
+ $groups[$i] = $row[0];
+ $group_names[$i] = $row[1];
$i++;
}
?>
@@ -102,9 +104,9 @@ while ($i < $groups_to_print)
echo "\n";
echo "
Inbound Service Level Report\n";
- $short_header=1;
+$short_header=1;
- require("admin_header.php");
+require("admin_header.php");
echo "";
@@ -113,11 +115,11 @@ echo "\n";
echo "\n";
echo "\n";
diff --git a/agc_2-X/trunk/www/vicidial/AST_CLOSERsummary_hourly.php b/agc_2-X/trunk/www/vicidial/AST_CLOSERsummary_hourly.php
new file mode 100644
index 00000000..a1338bee
--- /dev/null
+++ b/agc_2-X/trunk/www/vicidial/AST_CLOSERsummary_hourly.php
@@ -0,0 +1,628 @@
+ LICENSE: AGPLv2
+#
+# CHANGES
+#
+# 90801-0910 - First build
+#
+
+require("dbconnect.php");
+require("functions.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+
+if (isset($_GET["inbound_rate"])) {$inbound_rate=$_GET["inbound_rate"];}
+ elseif (isset($_POST["inbound_rate"])) {$inbound_rate=$_POST["inbound_rate"];}
+if (isset($_GET["outbound_rate"])) {$outbound_rate=$_GET["outbound_rate"];}
+ elseif (isset($_POST["outbound_rate"])) {$outbound_rate=$_POST["outbound_rate"];}
+if (isset($_GET["bareformat"])) {$bareformat=$_GET["bareformat"];}
+ elseif (isset($_POST["bareformat"])) {$bareformat=$_POST["bareformat"];}
+if (isset($_GET["costformat"])) {$costformat=$_GET["costformat"];}
+ elseif (isset($_POST["costformat"])) {$costformat=$_POST["costformat"];}
+if (isset($_GET["group"])) {$group=$_GET["group"];}
+ elseif (isset($_POST["group"])) {$group=$_POST["group"];}
+if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
+ elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
+if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
+ elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
+if (isset($_GET["shift"])) {$shift=$_GET["shift"];}
+ elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];}
+if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
+ elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
+ elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
+if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
+ elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+$MT[0]='0';
+if (strlen($shift)<2) {$shift='ALL';}
+
+#############################################
+##### START SYSTEM_SETTINGS LOOKUP #####
+$stmt = "SELECT use_non_latin FROM system_settings;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$qm_conf_ct = mysql_num_rows($rslt);
+$i=0;
+while ($i < $qm_conf_ct)
+ {
+ $row=mysql_fetch_row($rslt);
+ $non_latin = $row[0];
+ $i++;
+ }
+##### END SETTINGS LOOKUP #####
+###########################################
+
+$stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$gmt_conf_ct = mysql_num_rows($rslt);
+$dst = date("I");
+if ($gmt_conf_ct > 0)
+ {
+ $row=mysql_fetch_row($rslt);
+ $local_gmt = $row[0];
+ $epoch_offset = (($local_gmt + $dst) * 3600);
+ }
+
+$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1';";
+if ($DB) {echo "|$stmt|\n";}
+if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
+$rslt=mysql_query($stmt, $link);
+$row=mysql_fetch_row($rslt);
+$auth=$row[0];
+
+if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+ {
+ Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+ Header("HTTP/1.0 401 Unauthorized");
+ echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+ exit;
+ }
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($group)) {$group = '';}
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+if (!isset($end_date)) {$end_date = $NOW_DATE;}
+
+$stmt="select group_id,group_name from vicidial_inbound_groups;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$groups_to_print = mysql_num_rows($rslt);
+$i=0;
+$LISTgroups[$i]='---NONE---';
+$i++;
+$groups_to_print++;
+while ($i < $groups_to_print)
+ {
+ $row=mysql_fetch_row($rslt);
+ $LISTgroups[$i] = $row[0];
+ $LISTgroup_names[$i] = $row[1];
+ $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("--NONE--",$group_string) ) or ($group_ct < 1) )
+ {
+ $group_SQL = "''";
+# $group_SQL = "group_id IN('')";
+ }
+else
+ {
+ $group_SQL = eregi_replace(",$",'',$group_SQL);
+# $group_SQL = "group_id IN($group_SQL)";
+ }
+
+
+$stmt="select vsc_id,vsc_name from vicidial_status_categories;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$statcats_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $statcats_to_print)
+ {
+ $row=mysql_fetch_row($rslt);
+ $vsc_id[$i] = $row[0];
+ $vsc_name[$i] = $row[1];
+ $vsc_count[$i] = 0;
+ $i++;
+ }
+
+$stmt="select call_time_id,call_time_name from vicidial_call_times;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$times_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $times_to_print)
+ {
+ $row=mysql_fetch_row($rslt);
+ $call_times[$i] = $row[0];
+ $call_time_names[$i] = $row[1];
+ $i++;
+ }
+
+?>
+
+
+
+
+
+\n";
+echo "Inbound Summary Hourly Report\n";
+
+if ($bareformat < 1)
+ {
+ $short_header=1;
+
+ require("admin_header.php");
+
+ echo "";
+
+ if ($DB > 0)
+ {
+ echo " \n";
+ echo "$group_ct|$group_string|$group_SQL\n";
+ echo " \n";
+ echo "$shift|$query_date|$end_date\n";
+ echo " \n";
+ }
+
+ echo "\n\n";
+
+ echo "\n\n";
+ }
+
+if ($groups_to_print < 1)
+ {
+ echo "\n\n";
+ echo "PLEASE SELECT AN IN-GROUP AND DATE RANGE ABOVE AND CLICK SUBMIT\n";
+ }
+
+else
+ {
+ if ($shift == 'ALL')
+ {
+ $Gct_default_start = "0";
+ $Gct_default_stop = "2400";
+ }
+ else
+ {
+ $stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$shift';";
+ $rslt=mysql_query($stmt, $link);
+ if ($DB) {echo "$stmt\n";}
+ $calltimes_to_print = mysql_num_rows($rslt);
+ if ($calltimes_to_print > 0)
+ {
+ $row=mysql_fetch_row($rslt);
+ $Gct_default_start = $row[3];
+ $Gct_default_stop = $row[4];
+ $Gct_sunday_start = $row[5];
+ $Gct_sunday_stop = $row[6];
+ $Gct_monday_start = $row[7];
+ $Gct_monday_stop = $row[8];
+ $Gct_tuesday_start = $row[9];
+ $Gct_tuesday_stop = $row[10];
+ $Gct_wednesday_start = $row[11];
+ $Gct_wednesday_stop = $row[12];
+ $Gct_thursday_start = $row[13];
+ $Gct_thursday_stop = $row[14];
+ $Gct_friday_start = $row[15];
+ $Gct_friday_stop = $row[16];
+ $Gct_saturday_start = $row[17];
+ $Gct_saturday_stop = $row[18];
+ }
+ else
+ {
+ $Gct_default_start = "0";
+ $Gct_default_stop = "2400";
+ }
+ }
+ $h=0;
+ while ($h < 24)
+ {
+ $H_test = $h . "00";
+ if ( ($H_test >= $Gct_default_start) and ($H_test <= $Gct_default_stop) )
+ {
+ $Hcalltime[$h]++;
+ }
+ $h++;
+ }
+
+ $query_date_BEGIN = "$query_date 00:00:00";
+ $query_date_END = "$end_date 23:59:59";
+
+
+ $MAIN .= "Inbound Summary Hourly Report: $group_string $NOW_TIME\n";
+
+
+ if ($group_ct > 1)
+ {
+ $MAIN .= "\n";
+ $MAIN .= "---------- MULTI-GROUP BREAKDOWN:\n";
+ $MAIN .= "+------------------------------------------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+ $MAIN .= "| | | | | | TOTAL | AVERAGE | MAXIMUM | TOTAL |\n";
+ $MAIN .= "| | TOTAL | TOTAL | TOTAL | AVERAGE | QUEUE | QUEUE | QUEUE | ABANDON|\n";
+ $MAIN .= "| IN-GROUP | CALLS | ANSWER | TALK | TALK | TIME | TIME | TIME | CALLS |\n";
+ $MAIN .= "+------------------------------------------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+
+ $i=0;
+ $TOTcalls_count=0;
+ $TOTanswer_count=0;
+ $TOTtalk_sec=0;
+ $TOTtalk_avg=0;
+ $TOTqueue_seconds=0;
+ $TOTqueue_avg=0;
+ $TOTmax_queue_seconds=0;
+ $TOTdrop_count=0;
+ $SUBoutput='';
+
+ while($i < $group_ct)
+ {
+ $stmt="select group_name from vicidial_inbound_groups where group_id='$group[$i]';";
+ $rslt=mysql_query($stmt, $link);
+ if ($DB) {echo "$stmt\n";}
+ $row=mysql_fetch_row($rslt);
+ $group_name[$i] = $row[0];
+
+ $out_of_call_time=0;
+ $length_in_sec[$i]=0;
+ $queue_seconds[$i]=0;
+ $talk_sec[$i]=0;
+ $calls_count[$i]=0;
+ $drop_count[$i]=0;
+ $answer_count[$i]=0;
+ $max_queue_seconds[$i]=0;
+ $Hlength_in_sec=$MT;
+ $Hqueue_seconds=$MT;
+ $Htalk_sec=$MT;
+ $Hcalls_count=$MT;
+ $Hdrop_count=$MT;
+ $Hanswer_count=$MT;
+ $Hmax_queue_seconds=$MT;
+ $hTOTALcalls = 0;
+ $hANSWERcalls = 0;
+ $hSUMtalk = 0;
+ $hAVGtalk = 0;
+ $hSUMqueue = 0;
+ $hAVGqueue = 0;
+ $hMAXqueue = 0;
+ $hDROPcalls = 0;
+ $hPRINT = 0;
+ $hTOTcalls_count = 0;
+ $hTOTanswer_count = 0;
+ $hTOTtalk_sec = 0;
+ $hTOTtalk_avg = 0;
+ $hTOTqueue_seconds = 0;
+ $hTOTqueue_avg = 0;
+ $hTOTmax_queue_seconds = 0;
+ $hTOTdrop_count = 0;
+
+ $stmt = "SELECT status,length_in_sec,queue_seconds,call_date,UNIX_TIMESTAMP(call_date) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='$group[$i]';";
+ $rslt=mysql_query($stmt, $link);
+ if ($DB) {echo "$stmt\n";}
+ $calls_to_parse = mysql_num_rows($rslt);
+ $p=0;
+ while ($p < $calls_to_parse)
+ {
+ $row=mysql_fetch_row($rslt);
+ $call_date = explode(" ", $row[3]);
+ $call_time = ereg_replace("[^0-9]","",$call_date[1]);
+ $epoch = $row[4];
+ $Cwday = date("w", $epoch);
+
+ $CTstart = $Gct_default_start . "00";
+ $CTstop = $Gct_default_stop . "59";
+
+ if ( ($Cwday == 0) and ( ($Gct_sunday_start > 0) and ($Gct_sunday_stop > 0) ) )
+ {$CTstart = $Gct_sunday_start . "00"; $CTstop = $Gct_sunday_stop . "59";}
+ if ( ($Cwday == 1) and ( ($Gct_monday_start > 0) and ($Gct_monday_stop > 0) ) )
+ {$CTstart = $Gct_monday_start . "00"; $CTstop = $Gct_monday_stop . "59";}
+ if ( ($Cwday == 2) and ( ($Gct_tuesday_start > 0) and ($Gct_tuesday_stop > 0) ) )
+ {$CTstart = $Gct_tuesday_start . "00"; $CTstop = $Gct_tuesday_stop . "59";}
+ if ( ($Cwday == 3) and ( ($Gct_wednesday_start > 0) and ($Gct_wednesday_stop > 0) ) )
+ {$CTstart = $Gct_wednesday_start . "00"; $CTstop = $Gct_wednesday_stop . "59";}
+ if ( ($Cwday == 4) and ( ($Gct_thursday_start > 0) and ($Gct_thursday_stop > 0) ) )
+ {$CTstart = $Gct_thursday_start . "00"; $CTstop = $Gct_thursday_stop . "59";}
+ if ( ($Cwday == 5) and ( ($Gct_friday_start > 0) and ($Gct_friday_stop > 0) ) )
+ {$CTstart = $Gct_friday_start . "00"; $CTstop = $Gct_friday_stop . "59";}
+ if ( ($Cwday == 6) and ( ($Gct_saturday_start > 0) and ($Gct_saturday_stop > 0) ) )
+ {$CTstart = $Gct_saturday_start . "00"; $CTstop = $Gct_saturday_stop . "59";}
+
+ $Chour = date("G", $epoch);
+ if ( ($call_time > $CTstart) and ($call_time < $CTstop) )
+ {
+ $calls_count[$i]++;
+ $length_in_sec[$i] = ($length_in_sec[$i] + $row[1]);
+ $queue_seconds[$i] = ($queue_seconds[$i] + $row[2]);
+ $TEMPtalk = ($row[1] - $row[2]);
+ if ($TEMPtalk < 0) {$TEMPtalk = 0;}
+ $talk_sec[$i] = ($talk_sec[$i] + $TEMPtalk);
+ if ($max_queue_seconds[$i] < $row[2])
+ {$max_queue_seconds[$i] = $row[2];}
+ if (eregi("DROP",$row[0]))
+ {$drop_count[$i]++;}
+ else
+ {$answer_count[$i]++;}
+
+ $Hcalls_count[$Chour]++;
+ $Hlength_in_sec[$Chour] = ($Hlength_in_sec[$Chour] + $row[1]);
+ $Hqueue_seconds[$Chour] = ($Hqueue_seconds[$Chour] + $row[2]);
+ $Htalk_sec[$Chour] = ($Htalk_sec[$Chour] + $TEMPtalk);
+ if ($Hmax_queue_seconds[$Chour] < $row[2])
+ {$Hmax_queue_seconds[$Chour] = $row[2];}
+ if (eregi("DROP",$row[0]))
+ {$Hdrop_count[$Chour]++;}
+ else
+ {$Hanswer_count[$Chour]++;}
+ $Hcalltime[$Chour]++;
+ $q++;
+ }
+ else
+ {$out_of_call_time++;}
+ if ($DB)
+ {echo "$call_time > $CTstart | $call_time < $CTstop | $Cwday | $Chour | $Hcalltime[$Chour] | $talk_sec[$i]\n";}
+ $p++;
+ }
+ if ( ($answer_count[$i] > 0) and ($talk_sec[$i] > 0) )
+ {$talk_avg[$i] = ($talk_sec[$i] / $answer_count[$i]);}
+ else
+ {$talk_avg[$i] = 0;}
+ if ( ($calls_count[$i] > 0) and ($queue_seconds[$i] > 0) )
+ {$queue_avg[$i] = ($queue_seconds[$i] / $calls_count[$i]);}
+ else
+ {$queue_avg[$i] = 0;}
+
+ $TOTcalls_count = ($TOTcalls_count + $calls_count[$i]);
+ $TOTanswer_count = ($TOTanswer_count + $answer_count[$i]);
+ $TOTtalk_sec = ($TOTtalk_sec + $talk_sec[$i]);
+ $TOTqueue_seconds = ($TOTqueue_seconds + $queue_seconds[$i]);
+ $TOTdrop_count = ($TOTdrop_count + $drop_count[$i]);
+ if ($max_queue_seconds[$i] > $TOTmax_queue_seconds)
+ {$TOTmax_queue_seconds = $max_queue_seconds[$i];}
+
+ $talk_sec[$i] = sec_convert($talk_sec[$i],'H');
+ $talk_avg[$i] = sec_convert($talk_avg[$i],'H');
+ $queue_seconds[$i] = sec_convert($queue_seconds[$i],'H');
+ $queue_avg[$i] = sec_convert($queue_avg[$i],'H');
+ $max_queue_seconds[$i] = sec_convert($max_queue_seconds[$i],'H');
+
+ $groupDISPLAY = sprintf("%-40s", "$group[$i] - $group_name[$i]");
+ $gTOTALcalls = sprintf("%6s", $calls_count[$i]);
+ $gANSWERcalls = sprintf("%6s", $answer_count[$i]);
+ $gSUMtalk = sprintf("%9s", $talk_sec[$i]);
+ $gAVGtalk = sprintf("%7s", $talk_avg[$i]);
+ $gSUMqueue = sprintf("%9s", $queue_seconds[$i]);
+ $gAVGqueue = sprintf("%7s", $queue_avg[$i]);
+ $gMAXqueue = sprintf("%7s", $max_queue_seconds[$i]);
+ $gDROPcalls = sprintf("%6s", $drop_count[$i]);
+
+ while(strlen($groupDISPLAY)>40) {$groupDISPLAY = substr("$groupDISPLAY", 0, -1);}
+
+ $MAIN .= "| $groupDISPLAY | $gTOTALcalls | $gANSWERcalls | $gSUMtalk | $gAVGtalk | $gSUMqueue | $gAVGqueue | $gMAXqueue | $gDROPcalls |";
+ $MAIN .= "\n";
+
+ ### hour by hour sumaries
+ $SUBoutput .= "\n---------- $group[$i] - $group_name[$i] HOURLY BREAKDOWN:\n";
+ $SUBoutput .= "+------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+ $SUBoutput .= "| | | | | | TOTAL | AVERAGE | MAXIMUM | TOTAL |\n";
+ $SUBoutput .= "| | TOTAL | TOTAL | TOTAL | AVERAGE | QUEUE | QUEUE | QUEUE | ABANDON|\n";
+ $SUBoutput .= "| HOUR | CALLS | ANSWER | TALK | TALK | TIME | TIME | TIME | CALLS |\n";
+ $SUBoutput .= "+------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+
+ $h=0;
+ while ($h < 24)
+ {
+ if ($Hcalltime[$h] > 0)
+ {
+ if (strlen($Hcalls_count[$h]) < 1) {$Hcalls_count[$h] = 0;}
+ if (strlen($Hanswer_count[$h]) < 1) {$Hanswer_count[$h] = 0;}
+ if (strlen($Htalk_sec[$h]) < 1) {$Htalk_sec[$h] = 0;}
+ if (strlen($Hqueue_seconds[$h]) < 1) {$Hqueue_seconds[$h] = 0;}
+ if (strlen($Hmax_queue_seconds[$h]) < 1) {$Hmax_queue_seconds[$h] = 0;}
+ if (strlen($Hdrop_count[$h]) < 1) {$Hdrop_count[$h] = 0;}
+
+ $hTOTcalls_count = ($hTOTcalls_count + $Hcalls_count[$h]);
+ $hTOTanswer_count = ($hTOTanswer_count + $Hanswer_count[$h]);
+ $hTOTtalk_sec = ($hTOTtalk_sec + $Htalk_sec[$h]);
+ $hTOTqueue_seconds = ($hTOTqueue_seconds + $Hqueue_seconds[$h]);
+ $hTOTdrop_count = ($hTOTdrop_count + $Hdrop_count[$h]);
+ if ($Hmax_queue_seconds[$h] > $hTOTmax_queue_seconds)
+ {$hTOTmax_queue_seconds = $Hmax_queue_seconds[$h];}
+
+ if ( ($Hanswer_count[$h] > 0) and ($Htalk_sec[$h] > 0) )
+ {$Htalk_avg[$h] = ($Htalk_sec[$h] / $Hanswer_count[$h]);}
+ else
+ {$Htalk_avg[$h] = 0;}
+ if ( ($Hcalls_count[$h] > 0) and ($Hqueue_seconds[$h] > 0) )
+ {$Hqueue_avg[$h] = ($Hqueue_seconds[$h] / $Hcalls_count[$h]);}
+ else
+ {$Hqueue_avg[$h] = 0;}
+
+ $Htalk_sec[$h] = sec_convert($Htalk_sec[$h],'H');
+ $Htalk_avg[$h] = sec_convert($Htalk_avg[$h],'H');
+ $Hqueue_seconds[$h] = sec_convert($Hqueue_seconds[$h],'H');
+ $Hqueue_avg[$h] = sec_convert($Hqueue_avg[$h],'H');
+ $Hmax_queue_seconds[$h] = sec_convert($Hmax_queue_seconds[$h],'H');
+
+ $hTOTALcalls = sprintf("%6s", $Hcalls_count[$h]);
+ $hANSWERcalls = sprintf("%6s", $Hanswer_count[$h]);
+ $hSUMtalk = sprintf("%9s", $Htalk_sec[$h]);
+ $hAVGtalk = sprintf("%7s", $Htalk_avg[$h]);
+ $hSUMqueue = sprintf("%9s", $Hqueue_seconds[$h]);
+ $hAVGqueue = sprintf("%7s", $Hqueue_avg[$h]);
+ $hMAXqueue = sprintf("%7s", $Hmax_queue_seconds[$h]);
+ $hDROPcalls = sprintf("%6s", $Hdrop_count[$h]);
+ $hPRINT = sprintf("%2s", $h);
+
+ $SUBoutput .= "| $hPRINT | $hTOTALcalls | $hANSWERcalls | $hSUMtalk | $hAVGtalk | $hSUMqueue | $hAVGqueue | $hMAXqueue | $hDROPcalls |\n";
+ }
+
+ $h++;
+ }
+
+ if ( ($hTOTanswer_count > 0) and ($hTOTtalk_sec > 0) )
+ {$hTOTtalk_avg = ($hTOTtalk_sec / $hTOTanswer_count);}
+ else
+ {$hTOTtalk_avg = 0;}
+ if ( ($hTOTcalls_count > 0) and ($hTOTqueue_seconds > 0) )
+ {$hTOTqueue_avg = ($hTOTqueue_seconds / $hTOTcalls_count);}
+ else
+ {$hTOTqueue_avg = 0;}
+
+ $hTOTtalk_sec = sec_convert($hTOTtalk_sec,'H');
+ $hTOTtalk_avg = sec_convert($hTOTtalk_avg,'H');
+ $hTOTqueue_seconds = sec_convert($hTOTqueue_seconds,'H');
+ $hTOTqueue_avg = sec_convert($hTOTqueue_avg,'H');
+ $hTOTmax_queue_seconds = sec_convert($hTOTmax_queue_seconds,'H');
+
+ $hTOTcalls_count = sprintf("%6s", $hTOTcalls_count);
+ $hTOTanswer_count = sprintf("%6s", $hTOTanswer_count);
+ $hTOTtalk_sec = sprintf("%9s", $hTOTtalk_sec);
+ $hTOTtalk_avg = sprintf("%7s", $hTOTtalk_avg);
+ $hTOTqueue_seconds = sprintf("%9s", $hTOTqueue_seconds);
+ $hTOTqueue_avg = sprintf("%7s", $hTOTqueue_avg);
+ $hTOTmax_queue_seconds = sprintf("%7s", $hTOTmax_queue_seconds);
+ $hTOTdrop_count = sprintf("%6s", $hTOTdrop_count);
+
+ $SUBoutput .= "+------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+ $SUBoutput .= "|TOTALS| $hTOTcalls_count | $hTOTanswer_count | $hTOTtalk_sec | $hTOTtalk_avg | $hTOTqueue_seconds | $hTOTqueue_avg | $hTOTmax_queue_seconds | $hTOTdrop_count |\n";
+ $SUBoutput .= "+------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+
+ $i++;
+ }
+
+ $rawTOTtalk_sec = $TOTtalk_sec;
+ $rawTOTtalk_min = round($rawTOTtalk_sec / 60);
+
+ if ( ($TOTanswer_count > 0) and ($TOTtalk_sec > 0) )
+ {$TOTtalk_avg = ($TOTtalk_sec / $TOTanswer_count);}
+ else
+ {$TOTtalk_avg = 0;}
+ if ( ($TOTcalls_count > 0) and ($TOTqueue_seconds > 0) )
+ {$TOTqueue_avg = ($TOTqueue_seconds / $TOTcalls_count);}
+ else
+ {$TOTqueue_avg = 0;}
+
+ $TOTtalk_sec = sec_convert($TOTtalk_sec,'H');
+ $TOTtalk_avg = sec_convert($TOTtalk_avg,'H');
+ $TOTqueue_seconds = sec_convert($TOTqueue_seconds,'H');
+ $TOTqueue_avg = sec_convert($TOTqueue_avg,'H');
+ $TOTmax_queue_seconds = sec_convert($TOTmax_queue_seconds,'H');
+
+ $i = sprintf("%4s", $i);
+ $TOTcalls_count = sprintf("%6s", $TOTcalls_count);
+ $TOTanswer_count = sprintf("%6s", $TOTanswer_count);
+ $TOTtalk_sec = sprintf("%9s", $TOTtalk_sec);
+ $TOTtalk_avg = sprintf("%7s", $TOTtalk_avg);
+ $TOTqueue_seconds = sprintf("%9s", $TOTqueue_seconds);
+ $TOTqueue_avg = sprintf("%7s", $TOTqueue_avg);
+ $TOTmax_queue_seconds = sprintf("%7s", $TOTmax_queue_seconds);
+ $TOTdrop_count = sprintf("%6s", $TOTdrop_count);
+
+ $MAIN .= "+------------------------------------------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+ $MAIN .= "| TOTALS In-Groups: $i | $TOTcalls_count | $TOTanswer_count | $TOTtalk_sec | $TOTtalk_avg | $TOTqueue_seconds | $TOTqueue_avg | $TOTmax_queue_seconds | $TOTdrop_count |\n";
+ $MAIN .= "+------------------------------------------+--------+--------+-----------+---------+-----------+---------+---------+--------+\n";
+ }
+
+ if ($costformat > 0)
+ {
+ echo "\n";
+ $inbound_cost = ($rawTOTtalk_min * $inbound_rate);
+ $inbound_cost = sprintf("%8.2f", $inbound_cost);
+
+ echo "$query_date to $end_date, $rawTOTtalk_min minutes at \$0.60 = \$$inbound_cost\n";
+
+ exit;
+ }
+
+
+ echo "$MAIN";
+ echo "$SUBoutput";
+
+
+
+ $ENDtime = date("U");
+ $RUNtime = ($ENDtime - $STARTtime);
+ echo "\n\nRun Time: $RUNtime seconds\n";
+ }
+
+
+
+
+?>
+
+ |
+
+
diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php
index d4253e36..b6d4b01f 100644
--- a/agc_2-X/trunk/www/vicidial/admin.php
+++ b/agc_2-X/trunk/www/vicidial/admin.php
@@ -22906,6 +22906,7 @@ if ($ADD==999999)
|