From 31e20b5ef98e2be76cb7454a5322a11f3d5ae4f6 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 25 Aug 2006 16:07:07 +0000 Subject: [PATCH] added adaptive_intensity field and continued development of adaptive/predictive dialing git-svn-id: svn://192.168.202.10@219 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/AST_VDadapt.pl | 1138 +++++++++-------- agc_2-X/trunk/bin/AST_VDhopper.pl | 15 - .../trunk/extras/MySQL_AST_CREATE_tables.sql | 3 +- agc_2-X/trunk/extras/upgrade_2.0.1.sql | 1 + .../TO_BE_TRANSLATED_2.0.txt | 2 + agc_2-X/trunk/www/vicidial/admin.php | 37 +- 6 files changed, 627 insertions(+), 569 deletions(-) diff --git a/agc_2-X/trunk/bin/AST_VDadapt.pl b/agc_2-X/trunk/bin/AST_VDadapt.pl index 217e24e4..d7dc0e68 100644 --- a/agc_2-X/trunk/bin/AST_VDadapt.pl +++ b/agc_2-X/trunk/bin/AST_VDadapt.pl @@ -302,6 +302,8 @@ foreach(@campaign_id) $VCScalls_one=0; $VCSdrops_one=0; $VCSdrops_one_pct=0; + $differential_onemin=0; + $agents_average_onemin=0; $stmtA = "SELECT dialable_leads from vicidial_campaign_stats where campaign_id='$campaign_id[$i]';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -316,142 +318,6 @@ foreach(@campaign_id) } $sthA->finish(); - # TODAY CALL AND DROP STATS - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date';"; - $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; - $VCScalls_today = "$aryA[0]"; - $rec_count++; - } - $sthA->finish(); - if ($VCScalls_today > 0) - { - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; - $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; - $VCSdrops_today = "$aryA[0]"; - if ($VCSdrops_today > 0) - { - $VCSdrops_today_pct = ( ($VCSdrops_today / $VCScalls_today) * 100 ); - $VCSdrops_today_pct = sprintf("%.2f", $VCSdrops_today_pct); - } - $rec_count++; - } - $sthA->finish(); - } - - # LAST HOUR CALL AND DROP STATS - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour';"; - $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; - $VCScalls_hour = "$aryA[0]"; - $rec_count++; - } - $sthA->finish(); - if ($VCScalls_hour > 0) - { - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour' and status IN('DROP','XDROP');"; - $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; - $VCSdrops_hour = "$aryA[0]"; - if ($VCSdrops_hour > 0) - { - $VCSdrops_hour_pct = ( ($VCSdrops_hour / $VCScalls_hour) * 100 ); - $VCSdrops_hour_pct = sprintf("%.2f", $VCSdrops_hour_pct); - } - $rec_count++; - } - $sthA->finish(); - } - - # LAST HALFHOUR CALL AND DROP STATS - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour';"; - $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; - $VCScalls_halfhour = "$aryA[0]"; - $rec_count++; - } - $sthA->finish(); - if ($VCScalls_halfhour > 0) - { - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour' and status IN('DROP','XDROP');"; - $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; - $VCSdrops_halfhour = "$aryA[0]"; - if ($VCSdrops_halfhour > 0) - { - $VCSdrops_halfhour_pct = ( ($VCSdrops_halfhour / $VCScalls_halfhour) * 100 ); - $VCSdrops_halfhour_pct = sprintf("%.2f", $VCSdrops_halfhour_pct); - } - $rec_count++; - } - $sthA->finish(); - } - - # LAST FIVE MINUTE CALL AND DROP STATS - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five';"; - $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; - $VCScalls_five = "$aryA[0]"; - $rec_count++; - } - $sthA->finish(); - if ($VCScalls_five > 0) - { - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five' and status IN('DROP','XDROP');"; - $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; - $VCSdrops_five = "$aryA[0]"; - if ($VCSdrops_five > 0) - { - $VCSdrops_five_pct = ( ($VCSdrops_five / $VCScalls_five) * 100 ); - $VCSdrops_five_pct = sprintf("%.2f", $VCSdrops_five_pct); - } - $rec_count++; - } - $sthA->finish(); - } - # LAST ONE MINUTE CALL AND DROP STATS $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_one';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -484,112 +350,23 @@ foreach(@campaign_id) $rec_count++; } $sthA->finish(); - } - $VCSINCALL=0; - $VCSREADY=0; - $VCSCLOSER=0; - $VCSPAUSED=0; - $VCSagents=0; - $VCSagents_calc=0; - $VCSagents_active=0; - - # COUNTS OF STATUSES OF AGENTS IN THIS CAMPAIGN - $stmtA = "SELECT count(*),status from vicidial_live_agents where campaign_id='$campaign_id[$i]' and last_update_time > '$VDL_one' group by status;"; - $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; - $VCSagent_count = "$aryA[0]"; - $VCSagent_status = "$aryA[1]"; - $rec_count++; - if ($VCSagent_status =~ /INCALL|QUEUE/) {$VCSINCALL = ($VCSINCALL + $VCSagent_count);} - if ($VCSagent_status =~ /READY/) {$VCSREADY = ($VCSREADY + $VCSagent_count);} - if ($VCSagent_status =~ /CLOSER/) {$VCSCLOSER = ($VCSCLOSER + $VCSagent_count);} - if ($VCSagent_status =~ /PAUSED/) {$VCSPAUSED = ($VCSPAUSED + $VCSagent_count);} - $VCSagents = ($VCSagents + $VCSagent_count); - } - $sthA->finish(); - - if ($available_only_ratio_tally =~ /Y/) - {$VCSagents_calc = $VCSREADY;} - else - {$VCSagents_calc = ($VCSINCALL + $VCSREADY);} - $VCSagents_active = ($VCSINCALL + $VCSREADY + $VCSCLOSER); - - ### END - GATHER STATS FOR THE vicidial_campaign_stats TABLE ### - - ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### - $g=0; - $p='13'; - $GMT_gmt[0] = ''; - $GMT_hour[0] = ''; - $GMT_day[0] = ''; - if ($DBX) {print "\n |GMT-DAY-HOUR| ";} - while ($p > -13) - { - $pzone = ($GMT_now + ($p * 3600)); - ($psec,$pmin,$phour,$pmday,$pmon,$pyear,$pday,$pyday,$pisdst) = localtime($pzone); - $phour=($phour * 100); - $tz = sprintf("%.2f", $p); - $GMT_gmt[$g] = "$tz"; - $GMT_day[$g] = "$pday"; - $GMT_hour[$g] = ($phour + $pmin); - $p = ($p - 0.25); - if ($DBX) {print "|$GMT_gmt[$g]-$GMT_day[$g]-$GMT_hour[$g]|";} - $g++; - } - if ($DBX) {print "\n";} - - $stmtA = "SELECT * 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; - $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) - { - @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]"; - $Gct_state_call_times = "$aryA[19]"; - $rec_count++; - } - $sthA->finish(); - - $ct_states = ''; - $ct_state_gmt_SQL = ''; - $del_state_gmt_SQL = ''; - $ct_srs=0; - $b=0; - if (length($Gct_state_call_times)>2) - { - @state_rules = split(/\|/,$Gct_state_call_times); - $ct_srs = ($#state_rules - 2); - } - while($ct_srs >= $b) - { - if (length($state_rules[$b])>1) + # TODAY CALL AND DROP STATS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date';"; + $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) { - $stmtA = "SELECT * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; - if ($DBX) {print " |$stmtA|\n";} + @aryA = $sthA->fetchrow_array; + $VCScalls_today = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + if ($VCScalls_today > 0) + { + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -597,321 +374,584 @@ foreach(@campaign_id) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $Gstate_call_time_id = "$aryA[0]"; - $Gstate_call_time_state = "$aryA[1]"; - $Gsct_default_start = "$aryA[4]"; - $Gsct_default_stop = "$aryA[5]"; - $Gsct_sunday_start = "$aryA[6]"; - $Gsct_sunday_stop = "$aryA[7]"; - $Gsct_monday_start = "$aryA[8]"; - $Gsct_monday_stop = "$aryA[9]"; - $Gsct_tuesday_start = "$aryA[10]"; - $Gsct_tuesday_stop = "$aryA[11]"; - $Gsct_wednesday_start = "$aryA[12]"; - $Gsct_wednesday_stop = "$aryA[13]"; - $Gsct_thursday_start = "$aryA[14]"; - $Gsct_thursday_stop = "$aryA[15]"; - $Gsct_friday_start = "$aryA[16]"; - $Gsct_friday_stop = "$aryA[17]"; - $Gsct_saturday_start = "$aryA[18]"; - $Gsct_saturday_stop = "$aryA[19]"; - $ct_states .="'$Gstate_call_time_state',"; + $VCSdrops_today = "$aryA[0]"; + if ($VCSdrops_today > 0) + { + $VCSdrops_today_pct = ( ($VCSdrops_today / $VCScalls_today) * 100 ); + $VCSdrops_today_pct = sprintf("%.2f", $VCSdrops_today_pct); + } $rec_count++; } $sthA->finish(); - - $r=0; - $state_gmt=''; - $del_state_gmt=''; - while($r < $g) - { - if ($GMT_day[$r]==0) #### Sunday local time - { - if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==1) #### Monday local time - { - if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==2) #### Tuesday local time - { - if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==3) #### Wednesday local time - { - if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==4) #### Thursday local time - { - if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==5) #### Friday local time - { - if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==6) #### Saturday local time - { - if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) - {$state_gmt.="'$GMT_gmt[$r]',";} - else - {$del_state_gmt.="'$GMT_gmt[$r]',";} - } - } - $r++; - } - $state_gmt = "$state_gmt'99'"; - $del_state_gmt = "$del_state_gmt'99'"; - $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; - $del_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($del_state_gmt)) "; } - $b++; + # LAST HOUR CALL AND DROP STATS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour';"; + $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; + $VCScalls_hour = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + if ($VCScalls_hour > 0) + { + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour' and status IN('DROP','XDROP');"; + $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; + $VCSdrops_hour = "$aryA[0]"; + if ($VCSdrops_hour > 0) + { + $VCSdrops_hour_pct = ( ($VCSdrops_hour / $VCScalls_hour) * 100 ); + $VCSdrops_hour_pct = sprintf("%.2f", $VCSdrops_hour_pct); + } + $rec_count++; + } + $sthA->finish(); + } + + # LAST HALFHOUR CALL AND DROP STATS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour';"; + $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; + $VCScalls_halfhour = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + if ($VCScalls_halfhour > 0) + { + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour' and status IN('DROP','XDROP');"; + $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; + $VCSdrops_halfhour = "$aryA[0]"; + if ($VCSdrops_halfhour > 0) + { + $VCSdrops_halfhour_pct = ( ($VCSdrops_halfhour / $VCScalls_halfhour) * 100 ); + $VCSdrops_halfhour_pct = sprintf("%.2f", $VCSdrops_halfhour_pct); + } + $rec_count++; + } + $sthA->finish(); + } + + # LAST FIVE MINUTE CALL AND DROP STATS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five';"; + $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; + $VCScalls_five = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + if ($VCScalls_five > 0) + { + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five' and status IN('DROP','XDROP');"; + $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; + $VCSdrops_five = "$aryA[0]"; + if ($VCSdrops_five > 0) + { + $VCSdrops_five_pct = ( ($VCSdrops_five / $VCScalls_five) * 100 ); + $VCSdrops_five_pct = sprintf("%.2f", $VCSdrops_five_pct); + } + $rec_count++; + } + $sthA->finish(); + } + + $VCSINCALL=0; + $VCSREADY=0; + $VCSCLOSER=0; + $VCSPAUSED=0; + $VCSagents=0; + $VCSagents_calc=0; + $VCSagents_active=0; + + # COUNTS OF STATUSES OF AGENTS IN THIS CAMPAIGN + $stmtA = "SELECT count(*),status from vicidial_live_agents where campaign_id='$campaign_id[$i]' and last_update_time > '$VDL_one' group by status;"; + $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; + $VCSagent_count = "$aryA[0]"; + $VCSagent_status = "$aryA[1]"; + $rec_count++; + if ($VCSagent_status =~ /INCALL|QUEUE/) {$VCSINCALL = ($VCSINCALL + $VCSagent_count);} + if ($VCSagent_status =~ /READY/) {$VCSREADY = ($VCSREADY + $VCSagent_count);} + if ($VCSagent_status =~ /CLOSER/) {$VCSCLOSER = ($VCSCLOSER + $VCSagent_count);} + if ($VCSagent_status =~ /PAUSED/) {$VCSPAUSED = ($VCSPAUSED + $VCSagent_count);} + $VCSagents = ($VCSagents + $VCSagent_count); + } + $sthA->finish(); + + if ($available_only_ratio_tally =~ /Y/) + {$VCSagents_calc = $VCSREADY;} + else + {$VCSagents_calc = ($VCSINCALL + $VCSREADY);} + $VCSagents_active = ($VCSINCALL + $VCSREADY + $VCSCLOSER); + + ### END - GATHER STATS FOR THE vicidial_campaign_stats TABLE ### + + # GET AVERAGES FROM THIS CAMPAIGN + $stmtA = "SELECT differential_onemin,agents_average_onemin from vicidial_campaign_stats where campaign_id='$campaign_id[$i]';"; + $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; + $differential_onemin = "$aryA[0]"; + $agents_average_onemin = "$aryA[1]"; + $rec_count++; + } + $sthA->finish(); + + + + + ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + if ($DBX) {print "\n |GMT-DAY-HOUR| ";} + while ($p > -13) + { + $pzone = ($GMT_now + ($p * 3600)); + ($psec,$pmin,$phour,$pmday,$pmon,$pyear,$pday,$pyday,$pisdst) = localtime($pzone); + $phour=($phour * 100); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + if ($DBX) {print "|$GMT_gmt[$g]-$GMT_day[$g]-$GMT_hour[$g]|";} + $g++; + } + if ($DBX) {print "\n";} + + $stmtA = "SELECT * 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; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @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]"; + $Gct_state_call_times = "$aryA[19]"; + $rec_count++; + } + $sthA->finish(); + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $del_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (length($Gct_state_call_times)>2) + { + @state_rules = split(/\|/,$Gct_state_call_times); + $ct_srs = ($#state_rules - 2); + } + while($ct_srs >= $b) + { + if (length($state_rules[$b])>1) + { + $stmtA = "SELECT * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + 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; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $Gstate_call_time_id = "$aryA[0]"; + $Gstate_call_time_state = "$aryA[1]"; + $Gsct_default_start = "$aryA[4]"; + $Gsct_default_stop = "$aryA[5]"; + $Gsct_sunday_start = "$aryA[6]"; + $Gsct_sunday_stop = "$aryA[7]"; + $Gsct_monday_start = "$aryA[8]"; + $Gsct_monday_stop = "$aryA[9]"; + $Gsct_tuesday_start = "$aryA[10]"; + $Gsct_tuesday_stop = "$aryA[11]"; + $Gsct_wednesday_start = "$aryA[12]"; + $Gsct_wednesday_stop = "$aryA[13]"; + $Gsct_thursday_start = "$aryA[14]"; + $Gsct_thursday_stop = "$aryA[15]"; + $Gsct_friday_start = "$aryA[16]"; + $Gsct_friday_stop = "$aryA[17]"; + $Gsct_saturday_start = "$aryA[18]"; + $Gsct_saturday_stop = "$aryA[19]"; + $ct_states .="'$Gstate_call_time_state',"; + $rec_count++; + } + $sthA->finish(); + + $r=0; + $state_gmt=''; + $del_state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $del_state_gmt = "$del_state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + $del_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($del_state_gmt)) "; + } + + $b++; + } + if (length($ct_states)>2) + { + $ct_states =~ s/,$//gi; + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + $del_default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $del_default_gmt = "$del_default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + $del_gmtSQL = "(gmt_offset_now IN($del_default_gmt) $ct_statesSQL) $del_state_gmt_SQL"; + + ##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### + + $stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today',drops_today='$VCSdrops_today',drops_today_pct='$VCSdrops_today_pct',calls_hour='$VCScalls_hour',drops_hour='$VCSdrops_hour',drops_hour_pct='$VCSdrops_hour_pct',calls_halfhour='$VCScalls_halfhour',drops_halfhour='$VCSdrops_halfhour',drops_halfhour_pct='$VCSdrops_halfhour_pct',calls_fivemin='$VCScalls_five',drops_fivemin='$VCSdrops_five',drops_fivemin_pct='$VCSdrops_five_pct',calls_onemin='$VCScalls_one',drops_onemin='$VCSdrops_one',drops_onemin_pct='$VCSdrops_one_pct' where campaign_id='$campaign_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + + $differential_mul = ($differential_onemin / $agents_average_onemin); + $differential_pct = ($differential_mul * 100); + $differential_pct = sprintf("%.2f", $differential_pct); + $suggested_dial_level = ($auto_dial_level[$i] * ($differential_mul + 1) ); + $suggested_dial_level = sprintf("%.3f", $suggested_dial_level); + + $adaptive_string = "\n"; + $adaptive_string .= "CAMPAIGN: $campaign_id[$i]\n"; + $adaptive_string .= "SETTINGS-\n"; + $adaptive_string .= " DIAL_LEVEL: $auto_dial_level[$i]\n"; + $adaptive_string .= " DIALMETHOD: $dial_method[$i]\n"; + $adaptive_string .= " AVAIL ONLY: $available_only_ratio_tally[$i]\n"; + $adaptive_string .= " DROP PCNT: $adaptive_dropped_percentage[$i]\n"; + $adaptive_string .= " MAX LEVEL: $adaptive_maximum_level[$i]\n"; + $adaptive_string .= " LATEST GMT: $adaptive_latest_target_gmt[$i]\n"; + $adaptive_string .= "CURRENT STATS-\n"; + $adaptive_string .= " AVG AGENTS: $agents_average_onemin\n"; + $adaptive_string .= " AGENTS: $VCSagents ACTIVE: $VCSagents_active CALC: $VCSagents_calc INCALL: $VCSINCALL READY: $VCSREADY\n"; + $adaptive_string .= " DL DIFFERENTIAL: $differential_onemin\n"; + $adaptive_string .= " PERCENT DIFF: $differential_pct\n"; + $adaptive_string .= " SUGGEST DL: $suggested_dial_level = ($auto_dial_level[$i] *($differential_mul+1))\n"; + $adaptive_string .= " TODAY DROPS: $VCScalls_today $VCSdrops_today $VCSdrops_today_pct%\n"; + $adaptive_string .= " ONE HOUR DROPS: $VCScalls_hour $VCSdrops_hour $VCSdrops_hour_pct%\n"; + $adaptive_string .= " HALF HOUR DROPS: $VCScalls_halfhour $VCSdrops_halfhour $VCSdrops_halfhour_pct%\n"; + $adaptive_string .= " FIVE MIN DROPS: $VCScalls_five $VCSdrops_five $VCSdrops_five_pct%\n"; + $adaptive_string .= " ONE MIN DROPS: $VCScalls_one $VCSdrops_one $VCSdrops_one_pct%\n"; + + if ($DB) {print "campaign stats updated: $campaign_id[$i] $adaptive_string\n";} + + &adaptive_logger; + } - if (length($ct_states)>2) - { - $ct_states =~ s/,$//gi; - $ct_statesSQL = "and state NOT IN($ct_states)"; - } - else - { - $ct_statesSQL = ""; - } - - $r=0; - $default_gmt=''; - $del_default_gmt=''; - while($r < $g) - { - if ($GMT_day[$r]==0) #### Sunday local time - { - if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==1) #### Monday local time - { - if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==2) #### Tuesday local time - { - if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==3) #### Wednesday local time - { - if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==4) #### Thursday local time - { - if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==5) #### Friday local time - { - if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - } - if ($GMT_day[$r]==6) #### Saturday local time - { - if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) - {$default_gmt.="'$GMT_gmt[$r]',";} - else - {$del_default_gmt.="'$GMT_gmt[$r]',";} - } - } - $r++; - } - - $default_gmt = "$default_gmt'99'"; - $del_default_gmt = "$del_default_gmt'99'"; - $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; - $del_gmtSQL = "(gmt_offset_now IN($del_default_gmt) $ct_statesSQL) $del_state_gmt_SQL"; - - ##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### - - # $auto_dial_level[$rec_count] = "$aryA[14]"; - # $dial_method[$rec_count] = $aryA[46]; - # $available_only_ratio_tally[$rec_count] = $aryA[47]; - # $adaptive_dropped_percentage[$rec_count] = $aryA[48]; - # $adaptive_maximum_level[$rec_count] = $aryA[49]; - # $adaptive_latest_target_gmt[$rec_count] = $aryA[50]; - - $stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today',drops_today='$VCSdrops_today',drops_today_pct='$VCSdrops_today_pct',calls_hour='$VCScalls_hour',drops_hour='$VCSdrops_hour',drops_hour_pct='$VCSdrops_hour_pct',calls_halfhour='$VCScalls_halfhour',drops_halfhour='$VCSdrops_halfhour',drops_halfhour_pct='$VCSdrops_halfhour_pct',calls_fivemin='$VCScalls_five',drops_fivemin='$VCSdrops_five',drops_fivemin_pct='$VCSdrops_five_pct',calls_onemin='$VCScalls_one',drops_onemin='$VCSdrops_one',drops_onemin_pct='$VCSdrops_one_pct' where campaign_id='$campaign_id[$i]';"; - $affected_rows = $dbhA->do($stmtA); - $adaptive_string = "|AGENTS: $VCSagents|ACTIVE: $VCSagents_active|CALC: $VCSagents_calc|INCALL: $VCSINCALL|READY: $VCSREADY|LEVEL: $auto_dial_level[$i]|$dial_method[$i]|$available_only_ratio_tally[$i]|$adaptive_dropped_percentage[$i]|$adaptive_maximum_level[$i]|$adaptive_latest_target_gmt[$i] |$VCScalls_today|$VCSdrops_today|$VCSdrops_today_pct| |$VCScalls_hour|$VCSdrops_hour|$VCSdrops_hour_pct| |$VCScalls_halfhour|$VCSdrops_halfhour|$VCSdrops_halfhour_pct| |$VCScalls_five|$VCSdrops_five|$VCSdrops_five_pct| |$VCScalls_one|$VCSdrops_one|$VCSdrops_one_pct| $campaign_id[$i]|"; - if ($DB) {print "campaign stats updated: $campaign_id[$i] $adaptive_string\n";} - - &adaptive_logger; - } $i++; } diff --git a/agc_2-X/trunk/bin/AST_VDhopper.pl b/agc_2-X/trunk/bin/AST_VDhopper.pl index 560f8c9b..d5202a6f 100644 --- a/agc_2-X/trunk/bin/AST_VDhopper.pl +++ b/agc_2-X/trunk/bin/AST_VDhopper.pl @@ -1247,18 +1247,3 @@ if ($SYSLOG) $event_string=''; } - -sub adaptive_logger -{ -if ($SYSLOG) - { - $VDHCLOGfile = "$PATHlogs/adaptive-$campaign_id[$i].$file_date"; - - ### open the log file for writing ### - open(Aout, ">>$VDHCLOGfile") - || die "Can't open $VDHCLOGfile: $!\n"; - print Aout "$now_date$adaptive_string\n"; - close(Aout); - } -$adaptive_string=''; -} \ No newline at end of file diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index e5706c3a..a229e55e 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -479,7 +479,8 @@ dial_method ENUM('MANUAL','RATIO','ADAPT_HARD_LIMIT','ADAPT_TAPERED','ADAPT_AVER available_only_ratio_tally ENUM('Y','N') default 'N', adaptive_dropped_percentage SMALLINT(3) default '3', adaptive_maximum_level VARCHAR(6) default '3.0', -adaptive_latest_target_gmt VARCHAR(6) default '-7' +adaptive_latest_target_gmt VARCHAR(6) default '-7', +adaptive_intensity VARCHAR(6) default '0' ); CREATE TABLE vicidial_lists ( diff --git a/agc_2-X/trunk/extras/upgrade_2.0.1.sql b/agc_2-X/trunk/extras/upgrade_2.0.1.sql index 394f8282..c2713d01 100644 --- a/agc_2-X/trunk/extras/upgrade_2.0.1.sql +++ b/agc_2-X/trunk/extras/upgrade_2.0.1.sql @@ -23,6 +23,7 @@ ALTER TABLE vicidial_campaigns ADD available_only_ratio_tally ENUM('Y','N') defa ALTER TABLE vicidial_campaigns ADD adaptive_dropped_percentage SMALLINT(3) default '3'; ALTER TABLE vicidial_campaigns ADD adaptive_maximum_level VARCHAR(6) default '3.0'; ALTER TABLE vicidial_campaigns ADD adaptive_latest_target_gmt VARCHAR(6) default '-7'; +ALTER TABLE vicidial_campaigns ADD adaptive_intensity VARCHAR(6) default '0'; ALTER TABLE vicidial_campaign_stats ADD differential_onemin VARCHAR(20) default '0'; ALTER TABLE vicidial_campaign_stats ADD agents_average_onemin VARCHAR(20) default '0'; diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt index 87f538ea..0143b810 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt @@ -12,6 +12,7 @@ Available Only Tally -<\/B> This field if set to Y will leave out INCALL and QUE Drop Percentage Limit -<\/B> This field is where you set the limit of the percentage of dropped calls you would like while using an adaptive-predictive dial method, not MANUAL or RATIO Maximum Adapt Dial Level -<\/B> This field is where you set the limit of the limit to the numbr of lines you would like dialed per agent while using an adaptive-predictive dial method, not MANUAL or RATIO. This number can be higher than the Auto Dial Level if your hardware will support it. Value must be a positive number greater than one and can have decimal places Default 3.0 Latest Target Timezone -<\/B> This field is only used by the ADAPT_TAPERED dial method. You should select the current GMT offset value or timezone of the latest region that you will be calling. This allows the Tapered algorithm to decide how aggressively to dial by how long you have until you will be finished calling. NOTE- If you are calling in the USA and you have a very small amount of leads in Alaska or Hawaii but many leads in Pacific time zone, you should choose the pacific time zone for this field for the ADAPT_TAPERED dial method to work properly +Adapt Intensity Modifier -<\/B> This field is used to adjust the predictive intensity either higher or lower. The higher a positive number you select, the greater the dialer will increase the call pacing when it goes up and the slower the dialer will decrease the call pacing when it goes down. The lower the negative number you select here, the slower the dialer will increase the call pacing and the faster the dialer will lower the call pacing when it goes down. Default is 0. This field is not used by the MANUAL or RATIO dial methods System Performance Server Logs @@ -24,6 +25,7 @@ Available Only Tally Drop Percentage Limit Maximum Adapt Dial Level Latest Target Timezone +Adapt Intensity Modifier ############################################################ CLIENT diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index ef1be5a8..004a4012 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -288,6 +288,8 @@ if (isset($_GET["dial_method"])) {$dial_method=$_GET["dial_method"];} elseif (isset($_POST["dial_method"])) {$dial_method=$_POST["dial_method"];} if (isset($_GET["adaptive_latest_target_gmt"])) {$adaptive_latest_target_gmt=$_GET["adaptive_latest_target_gmt"];} elseif (isset($_POST["adaptive_latest_target_gmt"])){$adaptive_latest_target_gmt=$_POST["adaptive_latest_target_gmt"];} +if (isset($_GET["adaptive_intensity"])) {$adaptive_intensity=$_GET["adaptive_intensity"];} + elseif (isset($_POST["adaptive_intensity"])) {$adaptive_intensity=$_POST["adaptive_intensity"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} @@ -447,6 +449,7 @@ $campaign_rec_filename = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_rec_fi $call_time_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_name); $call_time_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_comments); $adaptive_latest_target_gmt = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$adaptive_latest_target_gmt); +$adaptive_intensity = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$adaptive_intensity); ### remove semi-colons ### $lead_filter_sql = ereg_replace(";","",$lead_filter_sql); @@ -524,12 +527,13 @@ $lead_filter_sql = ereg_replace(";","",$lead_filter_sql); # 60821-1625 - added ALLFORCE recording option for campaign_recording # 60823-1154 - added fields for adaptive dialing # 60824-1326 - added adaptive_latest_target_gmt for ADAPT_TAPERED dial method +# 60825-1205 - added adaptive_intensity for ADAPT_ dial methods # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$version = '2.0.62'; -$build = '60824-1326'; +$version = '2.0.63'; +$build = '60825-1205'; $STARTtime = date("U"); @@ -1136,6 +1140,11 @@ echo "
Latest Target Timezone - This field is only used by the ADAPT_TAPERED dial method. You should select the current GMT offset value or timezone of the latest region that you will be calling. This allows the Tapered algorithm to decide how aggressively to dial by how long you have until you will be finished calling. NOTE- If you are calling in the USA and you have a very small amount of leads in Alaska or Hawaii but many leads in Pacific time zone, you should choose the pacific time zone for this field for the ADAPT_TAPERED dial method to work properly. +
+ +
+Adapt Intensity Modifier - This field is used to adjust the predictive intensity either higher or lower. The higher a positive number you select, the greater the dialer will increase the call pacing when it goes up and the slower the dialer will decrease the call pacing when it goes down. The lower the negative number you select here, the slower the dialer will increase the call pacing and the faster the dialer will lower the call pacing when it goes down. Default is 0. This field is not used by the MANUAL or RATIO dial methods. +

@@ -2900,7 +2909,7 @@ if ($ADD==41) } } } - $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', $adlSQL next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',safe_harbor_message='$safe_harbor_message',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_target_gmt='$adaptive_latest_target_gmt' where campaign_id='$campaign_id';"; + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', $adlSQL next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',safe_harbor_message='$safe_harbor_message',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_target_gmt='$adaptive_latest_target_gmt',adaptive_intensity='$adaptive_intensity' where campaign_id='$campaign_id';"; $rslt=mysql_query($stmtA, $link); if ($reset_hopper == 'Y') @@ -3037,7 +3046,7 @@ if ($ADD==44) } } } - $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',hopper_level='$hopper_level', $adlSQL lead_filter_id='$lead_filter_id',dial_method='$dial_method' where campaign_id='$campaign_id';"; + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',hopper_level='$hopper_level', $adlSQL lead_filter_id='$lead_filter_id',dial_method='$dial_method',adaptive_intensity='$adaptive_intensity' where campaign_id='$campaign_id';"; $rslt=mysql_query($stmtA, $link); if ($reset_hopper == 'Y') @@ -4331,6 +4340,7 @@ echo "\n"; +echo "\n"; + echo "\n"; echo "
\n"; $adaptive_dropped_percentage = $row[48]; $adaptive_maximum_level = $row[49]; $adaptive_latest_target_gmt = $row[50]; + $adaptive_intensity = $row[51]; echo "
MODIFY A CAMPAIGNS RECORD: $row[0] - Basic View"; echo " | Detail View | "; @@ -4429,6 +4439,15 @@ echo "
Maximum Adapt Dial Level: Latest Target Timezone: (MUST Adjust for DST) $NWB#vicidial_campaigns-adaptive_latest_target_gmt$NWE
Adapt Intensity Modifier: $NWB#vicidial_campaigns-adaptive_intensity$NWE
Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE
Local Call Time: \n"; +echo "\n"; + echo "\n"; echo "\n";
\n"; if ($lead_filter_id=='') {$lead_filter_id='NONE';} $display_dialable_count = $row[39]; $dial_method = $row[46]; + $adaptive_intensity = $row[51]; echo "
MODIFY A CAMPAIGN'S RECORD: $row[0] - Basic View | "; echo "Detail View | "; @@ -4831,6 +4851,15 @@ echo "
Dial Method: Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Adapt Intensity Modifier: $NWB#vicidial_campaigns-adaptive_intensity$NWE
Script: $script_id
Get Call Launch: $get_call_launch