From 6de5edd4b080f2e1580b3274948c2ad8bcf00f2d Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 24 Apr 2007 15:15:44 +0000 Subject: [PATCH] several small changes to fix a bug with fronter/closer calls where the vicidial_auto_calls record would get deleted during the transfer resulting in some strange effects git-svn-id: svn://192.168.202.10@599 3d104415-ff17-0410-8863-d5cf3c621b8a --- agi/agi-VDADcloser.agi | 21 +++++++++++++++++---- bin/AST_VDauto_dial.pl | 4 ++-- www/agc/manager_send.php | 2 +- www/agc/vdc_db_query.php | 19 +++++++++++++++---- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/agi/agi-VDADcloser.agi b/agi/agi-VDADcloser.agi index ac006b3f..2993b945 100644 --- a/agi/agi-VDADcloser.agi +++ b/agi/agi-VDADcloser.agi @@ -314,18 +314,18 @@ $sthA->finish(); ### insert a LIVE record to the vicidial_auto_calls table $stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage) values('$VARserver_ip','$channel_group','LIVE','$CIDlead_id','$uniqueid','$callerid','$channel','$VDADphone_code','$VDADphone','$SQLdate','IN','LIVE-0')"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} $stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDCL','N')"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rows = $dbhA->do($stmtA); -if ($AGILOG) {$agi_string = "-- VDCL : |$VDADlead_id|$CIDlead_id|insert to vicidial_closer_log"; &agi_output;} +if ($AGILOG) {$agi_string = "-- VDCL : |$affected_rows|$VDADlead_id|$CIDlead_id|insert to vicidial_closer_log"; &agi_output;} $stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$CIDlead_id','$VDADcampaign','$SQLdate','$VDADphone_code','$VDADphone','$VDADfronter','VDXL')"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rows = $dbhA->do($stmtA); -if ($AGILOG) {$agi_string = "-- VDXL : |$VDADlead_id|$CIDlead_id|insert to vicidial_xfer_log"; &agi_output;} +if ($AGILOG) {$agi_string = "-- VDXL : |$affected_rows|$VDADlead_id|$CIDlead_id|insert to vicidial_xfer_log"; &agi_output;} $drop_timer=0; @@ -412,6 +412,12 @@ if ($channel_status < 1) $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER', stage='CLOSER-$drop_timer' where callerid='$callerid';"; $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDCL XFER : |$affected_rows|$callerid\n|$stmtA|"; &agi_output;} + if ($affected_rows < 1) + { + $stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage) values('$VARserver_ip','$channel_group','CLOSER','$CIDlead_id','$uniqueid','$callerid','$channel','$VDADphone_code','$VDADphone','$SQLdate','IN','CLOSER-$drop_timer')"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "$affected_rows|VDAC-reinsert|$stmtA|"; &agi_output;} + } $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$CIDlead_id' order by call_date desc limit 1;"; $affected_rows = $dbhA->do($stmtA); @@ -485,7 +491,14 @@ else $stmtA = "UPDATE vicidial_auto_calls set stage='LIVE-$drop_timer' where callerid='$callerid';"; $affected_rows = $dbhA->do($stmtA); -#if ($AGILOG) {$agi_string = "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|"; &agi_output;} +if ($AGILOG) {$agi_string = "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|"; &agi_output;} +if ($affected_rows < 1) + { + $stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage) values('$VARserver_ip','$channel_group','LIVE','$CIDlead_id','$uniqueid','$callerid','$channel','$VDADphone_code','$VDADphone','$SQLdate','IN','LIVE-$drop_timer')"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "$affected_rows|VDAC-reinsert|$stmtA|"; &agi_output;} + } + } diff --git a/bin/AST_VDauto_dial.pl b/bin/AST_VDauto_dial.pl index ba4b5144..429b00f5 100644 --- a/bin/AST_VDauto_dial.pl +++ b/bin/AST_VDauto_dial.pl @@ -336,7 +336,7 @@ while($one_day_interval > 0) $sthA->finish(); ### see how many total VDAD calls are going on right now for max limiter - $stmtA = "SELECT count(*) FROM vicidial_auto_calls where server_ip='$server_ip' and status IN('SENT','RINGING','LIVE','XFER');"; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where server_ip='$server_ip' and status IN('SENT','RINGING','LIVE','XFER','CLOSER');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -473,7 +473,7 @@ while($one_day_interval > 0) { $tally_xfer_line_counter=0; ### see how many VDAD calls are live as XFERs to agents - $stmtA = "SELECT count(*) FROM vicidial_auto_calls where server_ip='$DBIPaddress[$user_CIPct]' and campaign_id='$DBIPcampaign[$user_CIPct]' and status='XFER';"; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where server_ip='$DBIPaddress[$user_CIPct]' and campaign_id='$DBIPcampaign[$user_CIPct]' and status IN('XFER','CLOSER');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; diff --git a/www/agc/manager_send.php b/www/agc/manager_send.php index 10aa003d..a82cc03f 100644 --- a/www/agc/manager_send.php +++ b/www/agc/manager_send.php @@ -610,7 +610,7 @@ if ($ACTION=="RedirectXtraCX") if ($WeBRooTWritablE > 0) { $fp = fopen ("./vicidial_debug.txt", "a"); - fwrite ($fp, "$NOW_TIME|RDCXC|$filename|$user|$campaign|$$channel|$extrachannel|$queryCID|$exten|$ext_context|ext_priority|\n"); + fwrite ($fp, "$NOW_TIME|RDCXC|$filename|$user|$campaign|$channel|$extrachannel|$queryCID|$exten|$ext_context|ext_priority|\n"); fclose($fp); } } diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index eb5251b2..7d75cb1a 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -129,10 +129,11 @@ # 70319-1544 - Added agent disable update customer data function # 70322-1545 - Added sipsak display ability # 70413-1253 - Fixed bug for outbound call time in CLOSER-type blended campaigns +# 70424-1100 - Fixed bug for fronter/closer calls that would delete vdac records # -$version = '2.0.56'; -$build = '70413-1253'; +$version = '2.0.57'; +$build = '70424-1100'; require("dbconnect.php"); @@ -1078,11 +1079,12 @@ if ($stage == "end") } ### delete call record from vicidial_auto_calls - $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id';"; + $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and uniqueid='$uniqueid';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME',comments='' where user='$user' and server_ip='$server_ip';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); @@ -1143,7 +1145,7 @@ if ($stage == "end") mysql_close($linkB); } - $stmt = "DELETE from vicidial_auto_calls lead_id='$lead_id';"; + $stmt = "DELETE from vicidial_auto_calls lead_id='$lead_id' and uniqueid='$uniqueid';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); @@ -1466,6 +1468,15 @@ if ($ACTION == 'VDADcheckINCOMING') $dialed_number =$row[1]; $dialed_label =$row[2]; } + else + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND|$callerid|$user|$user_group|$list_id|$lead_id|$phone_number|$uniqueid|\n"); + fclose($fp); + } + } $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; if ($DB) {echo "$stmt\n";}