2006-06-16 snapshot

git-svn-id: svn://192.168.202.10@9 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2006-07-07 15:27:12 +00:00
parent 36f070cc92
commit 8d319a6c2c
30 changed files with 4284 additions and 450 deletions
+134 -4
View File
@@ -34,6 +34,8 @@
# 60418-0947 - Added lead filter per campaign
# 60509-1416 - Rewrite of local_call_time functions
# 60511-1150 - Added inserts into vicidial_campaign_stats table
# 60609-1451 - Added ability to filter by DNC list vicidial_dnc
# 60614-1159 - Added campaign lead recycling ability
#
# constants
@@ -324,6 +326,7 @@ if ($dbhA->has_selected_record)
{$hopper_level[$rec_count] = "$CLIlevel";}
$local_call_time[$rec_count] = "$record->[16]";
$lead_filter_id[$rec_count] = "$record->[35]";
$use_internal_dnc[$rec_count] = "$record->[43]";
$rec_count++;
}
}
@@ -767,7 +770,65 @@ foreach(@campaign_id)
##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ###
##### BEGIN lead recycling parsing and prep ###
$stmtA = "SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id[$i]' and active='Y';";
$dbhA->query("$stmtA");
$rec_ct=0;
if ($dbhA->has_selected_record)
{
@recycle_status=@MT;
@recycle_delay=@MT;
@recycle_maximum=@MT;
@RSQLdate=@MT;
$iter=$dbhA->create_record_iterator;
while ( $record = $iter->each)
{
$recycle_status[$rec_ct] = $record->[2];
$recycle_delay[$rec_ct] = $record->[3];
$recycle_maximum[$rec_ct] = $record->[4];
$rec_ct++;
}
}
if ($rec_ct > 0)
{
$rc=0;
$recycle_SQL = "( ";
while($rc < $rec_ct)
{
$secX = time();
$Rtarget = ($secX - $recycle_delay[$rc]);
($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget);
$Ryear = ($Ryear + 1900);
$Rmon++;
if ($Rmon < 10) {$Rmon = "0$Rmon";}
if ($Rmday < 10) {$Rmday = "0$Rmday";}
if ($Rhour < 10) {$Rhour = "0$Rhour";}
if ($Rmin < 10) {$Rmin = "0$Rmin";}
if ($Rsec < 10) {$Rsec = "0$Rsec";}
$RSQLdate[$rc] = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec";
$Y=1;
$recycle_Y = "'Y'";
while ($Y < $recycle_maximum[$rc])
{
$recycle_Y .= ",'Y$Y'";
$Y++;
}
if ($rc > 0) {$recycle_SQL .= " or ";}
$recycle_SQL .= "( (called_since_last_reset IN($recycle_Y)) and (status='$recycle_status[$rc]') and (modify_date < \"$RSQLdate[$rc]\") )";
if ($DBX) {print "RECYCLE: |$campaign_id[$i]|$recycle_status[$rc]|$recycle_delay[$rc]|$recycle_maximum[$rc]|$RSQLdate[$rc]|\n";}
$rc++;
}
$recycle_SQL .= " )";
if ($DBX) {print "RECYCLE SQL: |$recycle_SQL|\n";}
}
##### END lead recycling parsing and prep ###
if ($DB) {print "Starting hopper run for $campaign_id[$i] campaign- GMT: $local_call_time[$i] HOPPER: $hopper_level[$i] \n";}
@@ -942,6 +1003,37 @@ foreach(@campaign_id)
if ($lead_order[$i] eq "DOWN COUNT 3rd NEW") {$NEW_count = 3;}
if ($lead_order[$i] eq "DOWN COUNT 4th NEW") {$NEW_count = 4;}
### BEGIN recycle grab leads ###
if ($rec_ct > 0)
{
if ($DB) {print " looking for RECYCLE leads, maximum of 100\n";}
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where $recycle_SQL and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL) $lead_filter_sql[$i] limit 100;";
if ($DBX) {print " |$stmtA|\n";}
$REC_rec_countLEADS=0;
@REC_leads_to_hopper=@MT;
@REC_lists_to_hopper=@MT;
@REC_phone_to_hopper=@MT;
$dbhA->query("$stmtA");
if ($dbhA->has_selected_record)
{
$iter=$dbhA->create_record_iterator;
while ( $record = $iter->each)
{
$REC_leads_to_hopper[$REC_rec_countLEADS] = "$record->[0]";
$REC_lists_to_hopper[$REC_rec_countLEADS] = "$record->[1]";
$REC_gmt_to_hopper[$REC_rec_countLEADS] = "$record->[2]";
$REC_phone_to_hopper[$REC_rec_countLEADS] = "$record->[3]";
$REC_state_to_hopper[$REC_rec_countLEADS] = "$record->[4]";
if ($DB_show_offset) {print "LEAD_ADD: $record->[2] $record->[3] $record->[4]\n";}
$REC_rec_countLEADS++;
}
}
if ($DB) {print " RECYCLE leads to call count: $REC_rec_countLEADS\n";}
if ($DBX) {print " |$stmtA|\n";}
}
### END recycle grab leads ###
if ($NEW_count > 0)
{
$NEW_level = int($hopper_level[$i] / $NEW_count);
@@ -973,8 +1065,6 @@ 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 ($all_gmtSQL) $lead_filter_sql[$i] $order_stmt limit $OTHER_level;";
if ($DBX) {print " |$stmtA|\n";}
@@ -985,6 +1075,9 @@ foreach(@campaign_id)
$rec_countLEADS=0; $NEW_dec=99; $NEW_in=0;
@leads_to_hopper=@MT;
@lists_to_hopper=@MT;
@gmt_to_hopper=@MT;
@state_to_hopper=@MT;
@phone_to_hopper=@MT;
while ( $record = $iter->each)
{
if ( ($NEW_count > 0) && ($NEW_rec_countLEADS > $NEW_in) )
@@ -1000,16 +1093,28 @@ foreach(@campaign_id)
$lists_to_hopper[$rec_countLEADS] = "$NEW_lists_to_hopper[$NEW_in]";
$gmt_to_hopper[$rec_countLEADS] = "$NEW_gmt_to_hopper[$NEW_in]";
$state_to_hopper[$rec_countLEADS] = "$NEW_state_to_hopper[$NEW_in]";
$phone_to_hopper[$rec_countLEADS] = "$NEW_phone_to_hopper[$NEW_in]";
if ($DB_show_offset) {print "LEAD_ADD: $NEW_leads_to_hopper[$NEW_in] $NEW_phone_to_hopper[$NEW_in]\n";}
$rec_countLEADS++;
$NEW_in++;
$NEW_dec=2;
}
}
if ($REC_rec_countLEADS > $REC_insert_count)
{
$leads_to_hopper[$rec_countLEADS] = "$REC_leads_to_hopper[$REC_insert_count]";
$lists_to_hopper[$rec_countLEADS] = "$REC_lists_to_hopper[$REC_insert_count]";
$gmt_to_hopper[$rec_countLEADS] = "$REC_gmt_to_hopper[$REC_insert_count]";
$state_to_hopper[$rec_countLEADS] = "$REC_state_to_hopper[$REC_insert_count]";
$phone_to_hopper[$rec_countLEADS] = "$REC_phone_to_hopper[$REC_insert_count]";
$rec_countLEADS++;
$REC_insert_count++;
}
$leads_to_hopper[$rec_countLEADS] = "$record->[0]";
$lists_to_hopper[$rec_countLEADS] = "$record->[1]";
$gmt_to_hopper[$rec_countLEADS] = "$record->[2]";
$state_to_hopper[$rec_countLEADS] = "$record->[4]";
$phone_to_hopper[$rec_countLEADS] = "$record->[3]";
if ($DB_show_offset) {print "LEAD_ADD: $record->[2] $record->[3] $record->[4]\n";}
$rec_countLEADS++;
}
@@ -1024,8 +1129,33 @@ foreach(@campaign_id)
{
if ($leads_to_hopper[$h] != '0')
{
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]');";
$dbhA->query("$stmtA");
$DNClead=0;
if ($use_internal_dnc[$i] =~ /Y/)
{
if ($DB) {print " Doinbg DNC Check: $phone_to_hopper[$h]\n";}
$stmtA = "SELECT count(*) from vicidial_dnc where phone_number='$phone_to_hopper[$h]';";
$dbhA->query("$stmtA");
if ($dbhA->has_selected_record)
{
$iter=$dbhA->create_record_iterator;
$rec_count=0;
while ( $record = $iter->each)
{
$DNClead = "$record->[0]";
}
}
if ($DNClead != '0')
{
$stmtA = "UPDATE vicidial_list SET status='DNCL' where lead_id='$leads_to_hopper[$h]';";
$dbhA->query("$stmtA");
if ($DB) {print "Flagging DNC lead: $leads_to_hopper[$h] $phone_to_hopper[$h]\n";}
}
}
if ($DNClead == '0')
{
$stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]');";
$dbhA->query("$stmtA");
}
}
$h++;
}