2006-04-19_snapshot
git-svn-id: svn://192.168.202.10@4 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_VDhopper.pl version 0.5
|
||||
# AST_VDhopper.pl version 0.7
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# uses Net::MySQL to update the VICIDIAL leads hopper for the new streamlined
|
||||
@@ -31,6 +31,7 @@
|
||||
# 60228-1735 - Added hopper gmt validation to remove gmt outside of time range
|
||||
# 60320-0932 - Added inactive lead list hopper deletion (Thanks Vic Jolin)
|
||||
# 60322-1030 - Added super debug output
|
||||
# 60418-0947 - Added lead filter per campaign
|
||||
#
|
||||
|
||||
# constants
|
||||
@@ -38,6 +39,10 @@ $DB=0; # Debug flag, set to 0 for no debug messages, On an active system this w
|
||||
$US='__';
|
||||
$MT[0]='';
|
||||
|
||||
# options
|
||||
$insert_auto_CB_to_hopper = 1; # set to 1 to automatically insert ANYONE callbacks into the hopper
|
||||
|
||||
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||
$year = ($year + 1900);
|
||||
$mon++;
|
||||
@@ -206,7 +211,7 @@ if ($inactive_lists_count > 0)
|
||||
|
||||
|
||||
### BEGIN Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed
|
||||
$stmtA = "SELECT count(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE' and recipient='ANYONE';";
|
||||
$stmtA = "SELECT count(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
@@ -222,16 +227,26 @@ if ($dbhA->has_selected_record)
|
||||
if ($CBHOLD_count > 0)
|
||||
{
|
||||
$update_leads='';
|
||||
$stmtA = "SELECT lead_id FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE' and recipient='ANYONE';";
|
||||
$stmtA = "SELECT vicidial_callbacks.lead_id,recipient,campaign_id,vicidial_callbacks.list_id,gmt_offset_now FROM vicidial_callbacks,vicidial_list where callback_time <= '$now_date' and vicidial_callbacks.status='ACTIVE' and vicidial_callbacks.lead_id=vicidial_list.lead_id;";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$cbc=0;
|
||||
$cba=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$lead_ids[$cbc] = $record->[0];
|
||||
$recipient = $record->[1];
|
||||
$update_leads .= "'$lead_ids[$cbc]',";
|
||||
if ($recipient == 'ANYONE')
|
||||
{
|
||||
$CA_lead_id[$cba] = $record->[0];
|
||||
$CA_campaign_id[$cba] = $record->[2];
|
||||
$CA_list_id[$cba] = $record->[3];
|
||||
$CA_gmt_offset_now[$cba] = $record->[4];
|
||||
$cba++;
|
||||
}
|
||||
$cbc++;
|
||||
}
|
||||
}
|
||||
@@ -254,6 +269,20 @@ if ($CBHOLD_count > 0)
|
||||
&event_logger;
|
||||
|
||||
}
|
||||
### INSERT ANYONE CALLBACKS INTO HOPPER DIRECTLY ###
|
||||
if ( ($cba > 0) && ($insert_auto_CB_to_hopper) )
|
||||
{
|
||||
if ($DB) {print "ANYONE Scheduled Callbacks Inserted into hopper: $cba\n";}
|
||||
$event_string = "|ANYONE CB HOPPER |$cba|";
|
||||
&event_logger;
|
||||
$CAu=0;
|
||||
foreach(@CA_lead_id)
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_hopper SET lead_id='$CA_lead_id[$CAu]',campaign_id='$CA_campaign_id[$CAu]',list_id='$CA_list_id[$CAu]',gmt_offset_now='$CA_gmt_offset_now[$CAu]';";
|
||||
$dbhA->query("$stmtA");
|
||||
$CAu++;
|
||||
}
|
||||
}
|
||||
}
|
||||
### END Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed
|
||||
|
||||
@@ -289,6 +318,7 @@ if ($dbhA->has_selected_record)
|
||||
else
|
||||
{$hopper_level[$rec_count] = "$CLIlevel";}
|
||||
$local_call_time[$rec_count] = "$record->[16]";
|
||||
$lead_filter_id[$rec_count] = "$record->[35]";
|
||||
$rec_count++;
|
||||
}
|
||||
}
|
||||
@@ -407,6 +437,7 @@ foreach(@campaign_id)
|
||||
{
|
||||
if ($DB) {print " hopper too low ($hopper_ready_count|$hopper_level[$i]) starting hopper dump\n";}
|
||||
|
||||
### Get list of the lists in the campaign ###
|
||||
$stmtA = "SELECT list_id FROM vicidial_lists where campaign_id='$campaign_id[$i]' and active='Y';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
@@ -424,7 +455,33 @@ foreach(@campaign_id)
|
||||
if ($DB) {print " campaign lists count: $rec_countLISTS | $camp_lists\n";}
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
|
||||
$stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and gmt_offset_now IN($GMT_allowed);";
|
||||
if ( ($lead_filter_id[$i] !~ /NONE/) && (length($lead_filter_id[$i])>0) )
|
||||
{
|
||||
### Get SQL of lead filter for the campaign ###
|
||||
$stmtA = "SELECT lead_filter_sql FROM vicidial_lead_filters where lead_filter_id='$lead_filter_id[$i]';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$lead_filter_sql[$i] = "$record->[0]";
|
||||
}
|
||||
}
|
||||
$lead_filter_sql[$i] =~ s/^and|and$|^or|or$|^ and|and $|^ or|or $//gi;
|
||||
$lead_filter_sql[$i] = "and $lead_filter_sql[$i]";
|
||||
if ($DB) {print " campaign lists count: $rec_countLISTS | $camp_lists\n";}
|
||||
if ($DB) {print " lead filter $lead_filter_id[$i] defined for $campaign_id[$i]\n";}
|
||||
if ($DBX) {print " |$lead_filter_sql[$i]|\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
$lead_filter_sql[$i] = '';
|
||||
if ($DB) {print " no lead filter defined for campaign: $campaign_id[$i]\n";}
|
||||
if ($DBX) {print " |$lead_filter_id[$i]|\n";}
|
||||
}
|
||||
|
||||
$stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and gmt_offset_now IN($GMT_allowed) $lead_filter_sql[$i];";
|
||||
$dbhA->query("$stmtA");
|
||||
$campaign_leads_to_call=0;
|
||||
if ($dbhA->has_selected_record)
|
||||
@@ -439,7 +496,7 @@ foreach(@campaign_id)
|
||||
}
|
||||
if ( ($lead_order[$i] eq "DOWN COUNT 2nd NEW") or ($lead_order[$i] eq "DOWN COUNT 3rd NEW") or ($lead_order[$i] eq "DOWN COUNT 4th NEW") )
|
||||
{
|
||||
$stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and gmt_offset_now IN($GMT_allowed);";
|
||||
$stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and gmt_offset_now IN($GMT_allowed) $lead_filter_sql[$i];";
|
||||
$dbhA->query("$stmtA");
|
||||
$NEW_campaign_leads_to_call=0;
|
||||
if ($dbhA->has_selected_record)
|
||||
@@ -509,7 +566,7 @@ foreach(@campaign_id)
|
||||
$order_stmt = 'order by called_count, lead_id asc';
|
||||
if ($DB) {print " looking for $NEW_level NEW leads mixed in with $OTHER_level other leads\n";}
|
||||
|
||||
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and gmt_offset_now IN($GMT_allowed) $order_stmt limit $NEW_level;";
|
||||
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and gmt_offset_now IN($GMT_allowed) $lead_filter_sql[$i] $order_stmt limit $NEW_level;";
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
@@ -535,7 +592,7 @@ foreach(@campaign_id)
|
||||
|
||||
|
||||
if ($DB) {print " lead call order: $order_stmt\n";}
|
||||
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and gmt_offset_now IN($GMT_allowed) $order_stmt limit $OTHER_level;";
|
||||
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and gmt_offset_now IN($GMT_allowed) $lead_filter_sql[$i] $order_stmt limit $OTHER_level;";
|
||||
if ($DBX) {print " |$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
|
||||
Reference in New Issue
Block a user