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,67 +199,67 @@ if (!$DB_port) {$DB_port='3306';}
### Grab Server values from the database ### Grab Server values from the database
$cbc=0; $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';"; $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 = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$DBvoicemail_dump_exten = "$aryA[0]"; $DBvoicemail_dump_exten = "$aryA[0]";
$DBext_context = "$aryA[1]"; $DBext_context = "$aryA[1]";
$DBanswer_transfer_agent = "$aryA[2]"; $DBanswer_transfer_agent = "$aryA[2]";
$DBSERVER_GMT = "$aryA[3]"; $DBSERVER_GMT = "$aryA[3]";
$DBasterisk_version = "$aryA[4]"; $DBasterisk_version = "$aryA[4]";
$DBmax_vicidial_trunks = "$aryA[5]"; $DBmax_vicidial_trunks = "$aryA[5]";
if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;}
if ($DBext_context) {$ext_context = $DBext_context;} if ($DBext_context) {$ext_context = $DBext_context;}
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;}
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
### Grab call parameters from vicidial_list table ### Grab call parameters from vicidial_list table
$cbc=0; $cbc=0;
$stmtA = "SELECT phone_number,phone_code,user FROM vicidial_list where lead_id='$CIDlead_id' limit 1;"; $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 = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$VDADcampaign = "$channel_group"; $VDADcampaign = "$channel_group";
$VDADphone = "$aryA[0]"; $VDADphone = "$aryA[0]";
$VDADphone_code = "$aryA[1]"; $VDADphone_code = "$aryA[1]";
$VDADlead_id = "$CIDlead_id"; $VDADlead_id = "$CIDlead_id";
$VDADfronter = "$aryA[2]"; $VDADfronter = "$aryA[2]";
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
### Grab inbound_group values from the database ### Grab inbound_group values from the database
$cbc=0; $cbc=0;
$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; $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 = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$DBdrop_call_seconds = "$aryA[0]"; $DBdrop_call_seconds = "$aryA[0]";
$DBdrop_message = "$aryA[1]"; $DBdrop_message = "$aryA[1]";
$DBdrop_exten = "$aryA[2]"; $DBdrop_exten = "$aryA[2]";
if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;}
if ($DBdrop_message) {$drop_message = $DBdrop_message;} if ($DBdrop_message) {$drop_message = $DBdrop_message;}
if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;}
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
### insert a LIVE record to the vicidial_auto_calls table ### insert a LIVE record to the vicidial_auto_calls table
@@ -362,7 +362,7 @@ if ($channel_status < 1)
$VDADserver_ip = "$aryA[3]"; $VDADserver_ip = "$aryA[3]";
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';";
my $affected_rows = $dbhA->do($stmtA); my $affected_rows = $dbhA->do($stmtA);
@@ -411,6 +411,10 @@ if ($channel_status < 1)
exit; exit;
} }
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
} }
else else
{ {
@@ -233,75 +233,75 @@ if (!$DB_port) {$DB_port='3306';}
### Grab Server values from the database ### Grab Server values from the database
$cbc=0; $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';"; $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 = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$DBvoicemail_dump_exten = "$aryA[0]"; $DBvoicemail_dump_exten = "$aryA[0]";
$DBext_context = "$aryA[1]"; $DBext_context = "$aryA[1]";
$DBanswer_transfer_agent = "$aryA[2]"; $DBanswer_transfer_agent = "$aryA[2]";
$DBSERVER_GMT = "$aryA[3]"; $DBSERVER_GMT = "$aryA[3]";
$DBasterisk_version = "$aryA[4]"; $DBasterisk_version = "$aryA[4]";
$DBmax_vicidial_trunks = "$aryA[5]"; $DBmax_vicidial_trunks = "$aryA[5]";
if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;}
if ($DBext_context) {$ext_context = $DBext_context;} if ($DBext_context) {$ext_context = $DBext_context;}
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;}
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
### insert a record into the vicidial_list table ### 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');"; $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); $affected_rows = $dbhA->do($stmtA);
$cbc=0; $cbc=0;
$stmtA = "select LAST_INSERT_ID() LIMIT 1;"; $stmtA = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$insert_lead_id = "$aryA[0]"; $insert_lead_id = "$aryA[0]";
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
$new_lead_id = $insert_lead_id; $new_lead_id = $insert_lead_id;
if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} 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);} $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);}
# YmmddhhmmssLLLLLLLLL # YmmddhhmmssLLLLLLLLL
$YqueryCID = "Y$CIDdate$PADlead_id"; $YqueryCID = "Y$CIDdate$PADlead_id";
$callerid = $YqueryCID; $callerid = $YqueryCID;
### set the callerid ### set the callerid
print "SET CALLERID $YqueryCID\n"; print "SET CALLERID $YqueryCID\n";
checkresult($result); checkresult($result);
print STDERR "callerID changed: $YqueryCID\n"; print STDERR "callerID changed: $YqueryCID\n";
### Grab inbound_group values from the database ### Grab inbound_group values from the database
$cbc=0; $cbc=0;
$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; $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 = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$DBdrop_call_seconds = "$aryA[0]"; $DBdrop_call_seconds = "$aryA[0]";
$DBdrop_message = "$aryA[1]"; $DBdrop_message = "$aryA[1]";
$DBdrop_exten = "$aryA[2]"; $DBdrop_exten = "$aryA[2]";
if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;}
if ($DBdrop_message) {$drop_message = $DBdrop_message;} if ($DBdrop_message) {$drop_message = $DBdrop_message;}
if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;}
$cbc++; $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); $affected_rows = $dbhA->do($stmtA);
if($M){print STDERR "\n|$stmtA|\n";} 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";} if($M){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA); $affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";} 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')"; $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";} if($M){print STDERR "\n|$stmtA|\n";}
@@ -416,11 +416,7 @@ if ($channel_status < 1)
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';";
my $affected_rows = $dbhA->do($stmtA); my $affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";}
@@ -470,6 +466,11 @@ if ($channel_status < 1)
print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n";
exit; exit;
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
} }
else else
{ {
@@ -200,67 +200,67 @@ if (!$DB_port) {$DB_port='3306';}
### Grab Server values from the database ### Grab Server values from the database
$cbc=0; $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';"; $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 = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$DBvoicemail_dump_exten = "$aryA[0]"; $DBvoicemail_dump_exten = "$aryA[0]";
$DBext_context = "$aryA[1]"; $DBext_context = "$aryA[1]";
$DBanswer_transfer_agent = "$aryA[2]"; $DBanswer_transfer_agent = "$aryA[2]";
$DBSERVER_GMT = "$aryA[3]"; $DBSERVER_GMT = "$aryA[3]";
$DBasterisk_version = "$aryA[4]"; $DBasterisk_version = "$aryA[4]";
$DBmax_vicidial_trunks = "$aryA[5]"; $DBmax_vicidial_trunks = "$aryA[5]";
if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;}
if ($DBext_context) {$ext_context = $DBext_context;} if ($DBext_context) {$ext_context = $DBext_context;}
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;}
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
### Grab call parameters from vicidial_list table ### Grab call parameters from vicidial_list table
$cbc=0; $cbc=0;
$stmtA = "SELECT phone_number,phone_code,user FROM vicidial_list where lead_id='$CIDlead_id' limit 1;"; $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 = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$VDADcampaign = "$channel_group"; $VDADcampaign = "$channel_group";
$VDADphone = "$aryA[0]"; $VDADphone = "$aryA[0]";
$VDADphone_code = "$aryA[1]"; $VDADphone_code = "$aryA[1]";
$VDADlead_id = "$CIDlead_id"; $VDADlead_id = "$CIDlead_id";
$VDADfronter = "$aryA[2]"; $VDADfronter = "$aryA[2]";
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
### Grab inbound_group values from the database ### Grab inbound_group values from the database
$cbc=0; $cbc=0;
$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; $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 = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$DBdrop_call_seconds = "$aryA[0]"; $DBdrop_call_seconds = "$aryA[0]";
$DBdrop_message = "$aryA[1]"; $DBdrop_message = "$aryA[1]";
$DBdrop_exten = "$aryA[2]"; $DBdrop_exten = "$aryA[2]";
if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;}
if ($DBdrop_message) {$drop_message = $DBdrop_message;} if ($DBdrop_message) {$drop_message = $DBdrop_message;}
if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;}
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
### insert a LIVE record to the vicidial_auto_calls table ### insert a LIVE record to the vicidial_auto_calls table
@@ -363,7 +363,7 @@ if ($channel_status < 1)
$VDADextension = "$aryA[2]"; $VDADextension = "$aryA[2]";
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';";
my $affected_rows = $dbhA->do($stmtA); my $affected_rows = $dbhA->do($stmtA);
@@ -400,6 +400,10 @@ if ($channel_status < 1)
exit; exit;
} }
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
} }
else else
{ {
@@ -448,7 +452,7 @@ if ($channel_status < 1)
$VDADserver_ip = "$aryA[3]"; $VDADserver_ip = "$aryA[3]";
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';";
my $affected_rows = $dbhA->do($stmtA); my $affected_rows = $dbhA->do($stmtA);
@@ -497,6 +501,10 @@ if ($channel_status < 1)
exit; exit;
} }
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
} }
else else
{ {
@@ -233,75 +233,75 @@ if (!$DB_port) {$DB_port='3306';}
### Grab Server values from the database ### Grab Server values from the database
$cbc=0; $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';"; $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 = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$DBvoicemail_dump_exten = "$aryA[0]"; $DBvoicemail_dump_exten = "$aryA[0]";
$DBext_context = "$aryA[1]"; $DBext_context = "$aryA[1]";
$DBanswer_transfer_agent = "$aryA[2]"; $DBanswer_transfer_agent = "$aryA[2]";
$DBSERVER_GMT = "$aryA[3]"; $DBSERVER_GMT = "$aryA[3]";
$DBasterisk_version = "$aryA[4]"; $DBasterisk_version = "$aryA[4]";
$DBmax_vicidial_trunks = "$aryA[5]"; $DBmax_vicidial_trunks = "$aryA[5]";
if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;}
if ($DBext_context) {$ext_context = $DBext_context;} if ($DBext_context) {$ext_context = $DBext_context;}
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;}
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
### insert a record into the vicidial_list table ### 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');"; $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); $affected_rows = $dbhA->do($stmtA);
$cbc=0; $cbc=0;
$stmtA = "select LAST_INSERT_ID() LIMIT 1;"; $stmtA = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$insert_lead_id = "$aryA[0]"; $insert_lead_id = "$aryA[0]";
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
$new_lead_id = $insert_lead_id; $new_lead_id = $insert_lead_id;
if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} 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);} $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);}
# YmmddhhmmssLLLLLLLLL # YmmddhhmmssLLLLLLLLL
$YqueryCID = "Y$CIDdate$PADlead_id"; $YqueryCID = "Y$CIDdate$PADlead_id";
$callerid = $YqueryCID; $callerid = $YqueryCID;
### set the callerid ### set the callerid
print "SET CALLERID $YqueryCID\n"; print "SET CALLERID $YqueryCID\n";
checkresult($result); checkresult($result);
print STDERR "callerID changed: $YqueryCID\n"; print STDERR "callerID changed: $YqueryCID\n";
### Grab inbound_group values from the database ### Grab inbound_group values from the database
$cbc=0; $cbc=0;
$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; $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 = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
while ($sthArows > $cbc) while ($sthArows > $cbc)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
$DBdrop_call_seconds = "$aryA[0]"; $DBdrop_call_seconds = "$aryA[0]";
$DBdrop_message = "$aryA[1]"; $DBdrop_message = "$aryA[1]";
$DBdrop_exten = "$aryA[2]"; $DBdrop_exten = "$aryA[2]";
if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;}
if ($DBdrop_message) {$drop_message = $DBdrop_message;} if ($DBdrop_message) {$drop_message = $DBdrop_message;}
if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;}
$cbc++; $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); $affected_rows = $dbhA->do($stmtA);
if($M){print STDERR "\n|$stmtA|\n";} 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";} if($M){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA); $affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";} 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')"; $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";} if($M){print STDERR "\n|$stmtA|\n";}
@@ -414,11 +414,7 @@ if ($channel_status < 1)
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';";
my $affected_rows = $dbhA->do($stmtA); my $affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";}
@@ -456,6 +452,11 @@ if ($channel_status < 1)
print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n";
exit; exit;
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
} }
else else
{ {
@@ -509,11 +510,7 @@ if ($channel_status < 1)
$cbc++; $cbc++;
} }
$sthA->finish(); $sthA->finish();
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';";
my $affected_rows = $dbhA->do($stmtA); my $affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";}
@@ -563,6 +560,11 @@ if ($channel_status < 1)
print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n";
exit; exit;
}
else
{
print STDERR "NNNNNNNNNN No agent record found!!!\n";
}
} }
else else
{ {
@@ -664,12 +666,6 @@ if ($drop_seconds < 1)
my $affected_rows = $dbhA->do($stmtA); my $affected_rows = $dbhA->do($stmtA);
if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";} 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;"; $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";} if($M){print STDERR "\n\n|$stmtA|\n";}
my $affected_rows = $dbhA->do($stmtA); my $affected_rows = $dbhA->do($stmtA);