hopper fixes again

git-svn-id: svn://192.168.202.10@2352 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2015-07-17 16:47:28 +00:00
parent b1d98e9e9b
commit 6160e0ce95
+34 -34
View File
@@ -374,11 +374,11 @@ if ($count_only)
{
if (length($CLIcampaign)>0)
{
$stmtA = "(*) from $vicidial_hopper where campaign_id IN('$CLIcampaign');";
$stmtA = "SELECT count(*) from $vicidial_hopper where campaign_id IN('$CLIcampaign');";
}
else
{
$stmtA = "(*) from $vicidial_hopper;";
$stmtA = "SELECT count(*) from $vicidial_hopper;";
}
$hopper_count_only=0;
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
@@ -442,11 +442,11 @@ if ($inactive_lists_count > 0)
##### BEGIN Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed
if (length($CLIcampaign)>0)
{
$stmtA = "(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE' and campaign_id IN('$CLIcampaign');";
$stmtA = "SELECT count(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE' and campaign_id IN('$CLIcampaign');";
}
else
{
$stmtA = "(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE';";
$stmtA = "SELECT count(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE';";
}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -531,11 +531,11 @@ if ($CBHOLD_count > 0)
$hopper_dnc_count=0;
if (length($CLIcampaign)>0)
{
$stmtA = "(*) from $vicidial_hopper where status='DNC' and campaign_id IN('$CLIcampaign');";
$stmtA = "SELECT count(*) from $vicidial_hopper where status='DNC' and campaign_id IN('$CLIcampaign');";
}
else
{
$stmtA = "(*) from $vicidial_hopper where status='DNC';";
$stmtA = "SELECT count(*) from $vicidial_hopper where status='DNC';";
}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -633,10 +633,10 @@ if ($hopper_dnc_count > 0)
{
$alt_areacode = substr($VD_alt_phone, 0, 3);
$alt_areacode .= "XXXXXXX";
$stmtA="(*) FROM vicidial_dnc where phone_number IN('$VD_alt_phone','$alt_areacode');";
$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number IN('$VD_alt_phone','$alt_areacode');";
}
else
{$stmtA="(*) FROM vicidial_dnc where phone_number='$VD_alt_phone';";}
{$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_alt_phone';";}
if ($DB) {$event_string = "|$stmtA|"; &event_logger;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -657,10 +657,10 @@ if ($hopper_dnc_count > 0)
{
$alt_areacode = substr($VD_alt_phone, 0, 3);
$alt_areacode .= "XXXXXXX";
$stmtA="(*) FROM vicidial_campaign_dnc where phone_number IN('$VD_alt_phone','$alt_areacode') and campaign_id='$temp_VD_campaign_id';";
$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number IN('$VD_alt_phone','$alt_areacode') and campaign_id='$temp_VD_campaign_id';";
}
else
{$stmtA="(*) FROM vicidial_campaign_dnc where phone_number='$VD_alt_phone' and campaign_id='$temp_VD_campaign_id';";}
{$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_alt_phone' and campaign_id='$temp_VD_campaign_id';";}
if ($DB) {$event_string = "|$stmtA|"; &event_logger;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -713,10 +713,10 @@ if ($hopper_dnc_count > 0)
{
$addr3_areacode = substr($VD_address3, 0, 3);
$addr3_areacode .= "XXXXXXX";
$stmtA="(*) FROM vicidial_dnc where phone_number IN('$VD_address3','$addr3_areacode');";
$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number IN('$VD_address3','$addr3_areacode');";
}
else
{$stmtA="(*) FROM vicidial_dnc where phone_number='$VD_address3';";}
{$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_address3';";}
if ($DB) {$event_string = "|$stmtA|"; &event_logger;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -737,10 +737,10 @@ if ($hopper_dnc_count > 0)
{
$addr3_areacode = substr($VD_address3, 0, 3);
$addr3_areacode .= "XXXXXXX";
$stmtA="(*) FROM vicidial_campaign_dnc where phone_number IN('$VD_address3','$addr3_areacode') and campaign_id='$temp_VD_campaign_id';";
$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number IN('$VD_address3','$addr3_areacode') and campaign_id='$temp_VD_campaign_id';";
}
else
{$stmtA="(*) FROM vicidial_campaign_dnc where phone_number='$VD_address3' and campaign_id='$temp_VD_campaign_id';";}
{$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_address3' and campaign_id='$temp_VD_campaign_id';";}
if ($DB) {$event_string = "|$stmtA|"; &event_logger;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -789,7 +789,7 @@ if ($hopper_dnc_count > 0)
}
$sthA->finish();
$alt_dial_phones_count=0;
$stmtA="(*) FROM vicidial_list_alt_phones where lead_id='$AAD_lead_id[$aad]';";
$stmtA="SELECT count(*) FROM vicidial_list_alt_phones where lead_id='$AAD_lead_id[$aad]';";
if ($DB) {$event_string = "|$stmtA|"; &event_logger;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -835,10 +835,10 @@ if ($hopper_dnc_count > 0)
{
$ad_areacode = substr($VD_altdial_phone, 0, 3);
$ad_areacode .= "XXXXXXX";
$stmtA="(*) FROM vicidial_dnc where phone_number IN('$VD_altdial_phone','$ad_areacode');";
$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number IN('$VD_altdial_phone','$ad_areacode');";
}
else
{$stmtA="(*) FROM vicidial_dnc where phone_number='$VD_altdial_phone';";}
{$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_altdial_phone';";}
if ($DB) {$event_string = "|$stmtA|"; &event_logger;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -859,10 +859,10 @@ if ($hopper_dnc_count > 0)
{
$ad_areacode = substr($VD_altdial_phone, 0, 3);
$ad_areacode .= "XXXXXXX";
$stmtA="(*) FROM vicidial_campaign_dnc where phone_number IN('$VD_altdial_phone','$ad_areacode') and campaign_id='$temp_VD_campaign_id';";
$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number IN('$VD_altdial_phone','$ad_areacode') and campaign_id='$temp_VD_campaign_id';";
}
else
{$stmtA="(*) FROM vicidial_campaign_dnc where phone_number='$VD_altdial_phone' and campaign_id='$temp_VD_campaign_id';";}
{$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_altdial_phone' and campaign_id='$temp_VD_campaign_id';";}
if ($DB) {$event_string = "|$stmtA|"; &event_logger;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -965,14 +965,14 @@ while ($sthArows > $rec_count)
if ( $use_auto_hopper[$rec_count] =~ /Y/)
{
### Find the number of agents
$stmtB = "(*) FROM vicidial_live_agents WHERE campaign_id='$campaign_id[$rec_count]' and status IN ('READY','QUEUE','INCALL','CLOSER') and last_update_time >= '$VDL_tensec'";
$stmtB = "SELECT COUNT(*) FROM vicidial_live_agents WHERE campaign_id='$campaign_id[$rec_count]' and status IN ('READY','QUEUE','INCALL','CLOSER') and last_update_time >= '$VDL_tensec'";
$sthB = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhA->errstr;
@aryAgent = $sthB->fetchrow_array;
$num_agents = $aryAgent[0];
$sthB->finish();
$stmtB = "(*) FROM vicidial_live_agents WHERE campaign_id='$campaign_id[$rec_count]' and status IN ('PAUSED') and last_update_time >= '$VDL_tensec' and last_state_change >= '$VDL_one'";
$stmtB = "SELECT COUNT(*) FROM vicidial_live_agents WHERE campaign_id='$campaign_id[$rec_count]' and status IN ('PAUSED') and last_update_time >= '$VDL_tensec' and last_state_change >= '$VDL_one'";
$sthB = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhA->errstr;
@aryAgent = $sthB->fetchrow_array;
@@ -1023,7 +1023,7 @@ while ($sthArows > $rec_count)
{
if ($DB) { print "---------------Auto Trim Hopper Enabled For $campaign_id[$rec_count]---------------------\n"; }
$stmtB = "(*) FROM $vicidial_hopper WHERE campaign_id='$campaign_id[$rec_count]' and status IN ('READY') and source IN('S','N');";
$stmtB = "SELECT COUNT(*) FROM $vicidial_hopper WHERE campaign_id='$campaign_id[$rec_count]' and status IN ('READY') and source IN('S','N');";
$sthB = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhA->errstr;
@aryLead = $sthB->fetchrow_array;
@@ -1122,7 +1122,7 @@ foreach(@campaign_id)
if ($DB) {print "Campaign $campaign_id[$i] set to no-hopper-dialing: $no_hopper_dialing[$i]\n";}
### BEGIN Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed
$stmtA = "(*) FROM $vicidial_hopper where campaign_id='$campaign_id[$i]' and status NOT IN('QUEUE','HOLD');";
$stmtA = "SELECT count(*) FROM $vicidial_hopper where campaign_id='$campaign_id[$i]' and status NOT IN('QUEUE','HOLD');";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@aryA = $sthA->fetchrow_array;
@@ -1812,7 +1812,7 @@ foreach(@campaign_id)
### Find out how many leads are READY in the hopper from a specific campaign
$hopper_ready_count=0;
$stmtA = "(*) from $vicidial_hopper where campaign_id='$campaign_id[$i]' and status='READY';";
$stmtA = "SELECT count(*) from $vicidial_hopper where campaign_id='$campaign_id[$i]' and status='READY';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -1863,7 +1863,7 @@ foreach(@campaign_id)
# check that call time exists
if ($cur_call_time !~ /^campaign$/)
{
$stmtB = "(*) from vicidial_call_times where call_time_id = \"$cur_call_time\"";
$stmtB = "SELECT count(*) from vicidial_call_times where call_time_id = \"$cur_call_time\"";
$sthB = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthB->execute or die "executing: $stmtB", $dbhA->errstr;
@aryB = $sthB->fetchrow_array;
@@ -2443,12 +2443,12 @@ foreach(@campaign_id)
##### Get count of leads that are dialable #####
if ($list_order_mix[$i] =~ /DISABLED/)
{
$stmtA = "(*) FROM vicidial_list $VLforce_index where called_since_last_reset='N' and status IN($STATUSsql[$i]) and ($list_id_sql[$i]) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] $CCLsql[$i];";
$stmtA = "SELECT count(*) FROM vicidial_list $VLforce_index where called_since_last_reset='N' and status IN($STATUSsql[$i]) and ($list_id_sql[$i]) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] $CCLsql[$i];";
}
else
{
if (length($list_mix_dialableSQL)<3) {$list_mix_dialableSQL="called_count < 0";}
$stmtA = "(*) FROM vicidial_list $VLforce_index where called_since_last_reset='N' and ($list_mix_dialableSQL) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i];";
$stmtA = "SELECT count(*) FROM vicidial_list $VLforce_index where called_since_last_reset='N' and ($list_mix_dialableSQL) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i];";
}
if ($DBX) {print " |$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
@@ -2465,7 +2465,7 @@ foreach(@campaign_id)
if ( ($lead_order[$i] =~ / 2nd NEW$| 3rd NEW$| 4th NEW$| 5th NEW$| 6th NEW$/) && ($list_order_mix[$i] =~ /DISABLED/) )
{
$stmtA = "(*) FROM vicidial_list $VLforce_index where called_since_last_reset='N' and status IN('NEW') and ($list_id_sql[$i]) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i];";
$stmtA = "SELECT count(*) FROM vicidial_list $VLforce_index where called_since_last_reset='N' and status IN('NEW') and ($list_id_sql[$i]) and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i];";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -2928,10 +2928,10 @@ foreach(@campaign_id)
{
$pth_areacode = substr($phone_to_hopper[$h], 0, 3);
$pth_areacode .= "XXXXXXX";
$stmtA="(*) FROM vicidial_dnc where phone_number IN('$phone_to_hopper[$h]','$pth_areacode');";
$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number IN('$phone_to_hopper[$h]','$pth_areacode');";
}
else
{$stmtA="(*) FROM vicidial_dnc where phone_number='$phone_to_hopper[$h]';";}
{$stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_to_hopper[$h]';";}
if ($DB) {print " Doing DNC Check: $phone_to_hopper[$h] - $use_internal_dnc[$i]\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -2958,10 +2958,10 @@ foreach(@campaign_id)
{
$pth_areacode = substr($phone_to_hopper[$h], 0, 3);
$pth_areacode .= "XXXXXXX";
$stmtA="(*) FROM vicidial_campaign_dnc where phone_number IN('$phone_to_hopper[$h]','$pth_areacode') and campaign_id='$temp_campaign_id';";
$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number IN('$phone_to_hopper[$h]','$pth_areacode') and campaign_id='$temp_campaign_id';";
}
else
{$stmtA="(*) FROM vicidial_campaign_dnc where phone_number='$phone_to_hopper[$h]' and campaign_id='$temp_campaign_id';";}
{$stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$phone_to_hopper[$h]' and campaign_id='$temp_campaign_id';";}
if ($DBX) {print "$use_other_campaign_dnc[$i]|$stmtA\n";}
if ($DB) {print "Doing CAMP DNC Check: $phone_to_hopper[$h] - $use_campaign_dnc[$i] - $temp_campaign_id\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
@@ -2983,7 +2983,7 @@ foreach(@campaign_id)
}
$VAC_exist=0;
$stmtA="(*) FROM vicidial_auto_calls where lead_id='$leads_to_hopper[$h]';";
$stmtA="SELECT count(*) FROM vicidial_auto_calls where lead_id='$leads_to_hopper[$h]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -2995,7 +2995,7 @@ foreach(@campaign_id)
$sthA->finish();
$VLA_exist=0;
$stmtA="(*) FROM vicidial_live_agents where lead_id='$leads_to_hopper[$h]';";
$stmtA="SELECT count(*) FROM vicidial_live_agents where lead_id='$leads_to_hopper[$h]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;