fixed errors in agi-VDAD scripts

git-svn-id: svn://192.168.202.10@155 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2006-08-11 15:12:29 +00:00
parent 660be18d49
commit 84c69ca0b8
4 changed files with 253 additions and 244 deletions
@@ -199,10 +199,10 @@ if (!$DB_port) {$DB_port='3306';}
### Grab Server values from the database
$cbc=0;
$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -220,15 +220,15 @@ $stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gm
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
$cbc++;
}
$sthA->finish();
$sthA->finish();
### Grab call parameters from vicidial_list table
$cbc=0;
$stmtA = "SELECT phone_number,phone_code,user FROM vicidial_list where lead_id='$CIDlead_id' limit 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
$VDADcampaign = "$channel_group";
@@ -238,16 +238,16 @@ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$VDADfronter = "$aryA[2]";
$cbc++;
}
$sthA->finish();
$sthA->finish();
### Grab inbound_group values from the database
$cbc=0;
$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -259,7 +259,7 @@ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;}
$cbc++;
}
$sthA->finish();
$sthA->finish();
### insert a LIVE record to the vicidial_auto_calls table
@@ -411,6 +411,10 @@ if ($channel_status < 1)
exit;
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
}
else
{
@@ -233,10 +233,10 @@ if (!$DB_port) {$DB_port='3306';}
### Grab Server values from the database
$cbc=0;
$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -254,43 +254,43 @@ $stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gm
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
$cbc++;
}
$sthA->finish();
$sthA->finish();
### insert a record into the vicidial_list table
$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00');";
$affected_rows = $dbhA->do($stmtA);
$cbc=0;
$stmtA = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$cbc=0;
$stmtA = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
$insert_lead_id = "$aryA[0]";
$cbc++;
}
$sthA->finish();
$sthA->finish();
$new_lead_id = $insert_lead_id;
if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";}
$PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);}
# YmmddhhmmssLLLLLLLLL
$PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);}
# YmmddhhmmssLLLLLLLLL
$YqueryCID = "Y$CIDdate$PADlead_id";
$callerid = $YqueryCID;
### set the callerid
print "SET CALLERID $YqueryCID\n";
checkresult($result);
print STDERR "callerID changed: $YqueryCID\n";
### set the callerid
print "SET CALLERID $YqueryCID\n";
checkresult($result);
print STDERR "callerID changed: $YqueryCID\n";
### Grab inbound_group values from the database
$cbc=0;
$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
$DBdrop_call_seconds = "$aryA[0]";
@@ -301,7 +301,7 @@ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;}
$cbc++;
}
$sthA->finish();
$sthA->finish();
@@ -310,10 +310,10 @@ $stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group
$affected_rows = $dbhA->do($stmtA);
if($M){print STDERR "\n|$stmtA|\n";}
$stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','XFER','$phone_code','$phone_number','$fronter','N')";
$stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','XFER','$phone_code','$phone_number','$fronter','N')";
if($M){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";}
$affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";}
$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')";
if($M){print STDERR "\n|$stmtA|\n";}
@@ -416,11 +416,7 @@ if ($channel_status < 1)
$cbc++;
}
$sthA->finish();
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';";
my $affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";}
@@ -471,6 +467,11 @@ if ($channel_status < 1)
exit;
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
}
else
{
print STDERR "WWWWWWWW VDAD REMOTE XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n";
@@ -200,10 +200,10 @@ if (!$DB_port) {$DB_port='3306';}
### Grab Server values from the database
$cbc=0;
$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -221,15 +221,15 @@ $stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gm
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
$cbc++;
}
$sthA->finish();
$sthA->finish();
### Grab call parameters from vicidial_list table
$cbc=0;
$stmtA = "SELECT phone_number,phone_code,user FROM vicidial_list where lead_id='$CIDlead_id' limit 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
$VDADcampaign = "$channel_group";
@@ -239,16 +239,16 @@ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$VDADfronter = "$aryA[2]";
$cbc++;
}
$sthA->finish();
$sthA->finish();
### Grab inbound_group values from the database
$cbc=0;
$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -260,7 +260,7 @@ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;}
$cbc++;
}
$sthA->finish();
$sthA->finish();
### insert a LIVE record to the vicidial_auto_calls table
@@ -400,6 +400,10 @@ if ($channel_status < 1)
exit;
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
}
else
{
@@ -497,6 +501,10 @@ if ($channel_status < 1)
exit;
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
}
else
{
@@ -233,10 +233,10 @@ if (!$DB_port) {$DB_port='3306';}
### Grab Server values from the database
$cbc=0;
$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -254,43 +254,43 @@ $stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gm
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
$cbc++;
}
$sthA->finish();
$sthA->finish();
### insert a record into the vicidial_list table
$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00');";
$affected_rows = $dbhA->do($stmtA);
$cbc=0;
$stmtA = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$cbc=0;
$stmtA = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
$insert_lead_id = "$aryA[0]";
$cbc++;
}
$sthA->finish();
$sthA->finish();
$new_lead_id = $insert_lead_id;
if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";}
$PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);}
# YmmddhhmmssLLLLLLLLL
$PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);}
# YmmddhhmmssLLLLLLLLL
$YqueryCID = "Y$CIDdate$PADlead_id";
$callerid = $YqueryCID;
### set the callerid
print "SET CALLERID $YqueryCID\n";
checkresult($result);
print STDERR "callerID changed: $YqueryCID\n";
### set the callerid
print "SET CALLERID $YqueryCID\n";
checkresult($result);
print STDERR "callerID changed: $YqueryCID\n";
### Grab inbound_group values from the database
$cbc=0;
$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
$DBdrop_call_seconds = "$aryA[0]";
@@ -301,7 +301,7 @@ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;}
$cbc++;
}
$sthA->finish();
$sthA->finish();
@@ -310,10 +310,10 @@ $stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group
$affected_rows = $dbhA->do($stmtA);
if($M){print STDERR "\n|$stmtA|\n";}
$stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','XFER','$phone_code','$phone_number','$fronter','N')";
$stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','XFER','$phone_code','$phone_number','$fronter','N')";
if($M){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";}
$affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";}
$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')";
if($M){print STDERR "\n|$stmtA|\n";}
@@ -414,11 +414,7 @@ if ($channel_status < 1)
$cbc++;
}
$sthA->finish();
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';";
my $affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";}
@@ -457,6 +453,11 @@ if ($channel_status < 1)
exit;
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
}
else
{
print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n";
@@ -509,11 +510,7 @@ if ($channel_status < 1)
$cbc++;
}
$sthA->finish();
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';";
my $affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";}
@@ -564,6 +561,11 @@ if ($channel_status < 1)
exit;
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
}
else
{
print STDERR "WWWWWWWW VDAD REMOTE XFER WAIT: |$rec_countWAITrem|$channel_group|$channel|$callerid|$uniqueid|\n";
@@ -664,12 +666,6 @@ if ($drop_seconds < 1)
my $affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";}
# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';";
# if($M){print STDERR "\n\n|$stmtA|\n";}
# $dbhA->query("$stmtA");
# my $affected_rows = $dbhA->get_affected_rows_length;
# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";}
$stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$new_lead_id' order by start_epoch desc limit 1;";
if($M){print STDERR "\n\n|$stmtA|\n";}
my $affected_rows = $dbhA->do($stmtA);