From cb562b495f345141cf59805981ab5d8b94663655 Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 11 Jun 2009 18:29:48 +0000 Subject: [PATCH] Fixed bugs in logging to vicidial_log and vicidial_agent_log for manual dial phone calls git-svn-id: svn://192.168.202.10@1150 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/AST_VDauto_dial.pl | 74 ++++++- .../trunk/extras/MySQL_AST_CREATE_tables.sql | 3 +- agc_2-X/trunk/extras/upgrade_2.2.0.sql | 4 + agc_2-X/trunk/www/agc/vdc_db_query.php | 207 +++++++++++++----- agc_2-X/trunk/www/agc/vicidial.php | 39 ++-- .../www/vicidial/AST_agent_status_detail.php | 2 +- .../www/vicidial/AST_agent_time_detail.php | 7 +- 7 files changed, 258 insertions(+), 78 deletions(-) diff --git a/agc_2-X/trunk/bin/AST_VDauto_dial.pl b/agc_2-X/trunk/bin/AST_VDauto_dial.pl index ed14b255..3df8f54c 100644 --- a/agc_2-X/trunk/bin/AST_VDauto_dial.pl +++ b/agc_2-X/trunk/bin/AST_VDauto_dial.pl @@ -75,6 +75,7 @@ # 90124-0721 - Added parameter to ensure no auto-dial calls are placed for MANUAL campaigns # 90202-0203 - Added outbound_autodial_active option to halt all dialing # 90306-1845 - Added configurable calls-per-second option +# 90611-0554 - Bug fix for Manual dial calls and logging # @@ -1064,6 +1065,22 @@ while($one_day_interval > 0) $rec_count++; } $sthA->finish(); + $stmtA = "SELECT user FROM vicidial_live_agents where callerid='$KLcallerid[$kill_vac]'"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $CLuser = "$aryA[0]"; + } + $sthA->finish(); + if ( (length($CLlead_id) < 1) || ($CLlead_id < 1) ) + { + $CLlead_id = $KLcallerid[$kill_vac]; + $CLlead_id = substr($CLlead_id, 11, 9); + $CLlead_id = ($CLlead_id + 0); + } if ($CLcall_type =~ /IN/) { @@ -1088,6 +1105,7 @@ while($one_day_interval > 0) $dialtime_log = ($end_epoch - $start_epoch); $dialtime_catch = ($now_date_epoch - ($start_epoch + $timeout_leeway)); + $hanguptime_manual = ($end_epoch + 60); if ($dialtime_catch > 100000) {$dialtime_catch=0;} $call_timeout = ($CLdial_timeout + $CLdrop_call_seconds); if ($CLstage =~ /SURVEY|REMIND/) {$call_timeout = ($call_timeout + 120);} @@ -1116,14 +1134,45 @@ while($one_day_interval > 0) if ($CLstatus =~ /LIVE/) {$CLnew_status = 'DROP';} else { + $insertVLuser = 'VDAD'; + $insertVLcount=0; + if ($KLcallerid[$kill_vac] =~ /^M\d\d\d\d\d\d\d\d\d\d/) + { + $beginUNIQUEID = $CLuniqueid; + $beginUNIQUEID =~ s/\..*//gi; + $insertVLuser = $CLuser; + $stmtA="SELECT count(*) from vicidial_log where lead_id='$CLlead_id' and user='$CLuser' and phone_number='$CLphone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArowsVL=$sthA->rows; + if ($sthArowsVL > 0) + { + @aryA = $sthA->fetchrow_array; + $insertVLcount = "$aryA[0]"; + } + $sthA->finish(); + } + $end_epoch = ($now_date_epoch + 1); - $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,length_in_sec,end_epoch,alt_dial) values('$CLuniqueid','$CLlead_id','$CLcampaign_id','$SQLdate','$now_date_epoch','$CLnew_status','$CLphone_code','$CLphone_number','VDAD','N','$CLstage','$end_epoch','$CLalt_dial')"; - if($M){print STDERR "\n|$stmtA|\n";} - $affected_rows = $dbhA->do($stmtA); + if ($insertVLcount < 1) + { + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,length_in_sec,end_epoch,alt_dial) values('$CLuniqueid','$CLlead_id','$CLcampaign_id','$SQLdate','$now_date_epoch','$CLnew_status','$CLphone_code','$CLphone_number','$insertVLuser','N','$CLstage','$end_epoch','$CLalt_dial')"; + if($M){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); - $event_string = "| dead NA call added to log $CLuniqueid|$CLlead_id|$CLphone_number|$CLstatus|$CLnew_status|$affected_rows|"; - &event_logger; + $event_string = "| dead NA call added to log $CLuniqueid|$CLlead_id|$CLphone_number|$CLstatus|$CLnew_status|$affected_rows|$insertVLcount"; + &event_logger; + } + else + { + $stmtA = "UPDATE vicidial_log SET status='$CLnew_status',length_in_sec='$CLstage',end_epoch='$end_epoch',alt_dial='$CLalt_dial' where lead_id='$CLlead_id' and user='$CLuser' and phone_number='$CLphone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + if($M){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); + $event_string = "| dead NA call updated in log $CLuniqueid|$CLlead_id|$CLphone_number|$CLstatus|$CLnew_status|$affected_rows|$insertVLcount|$beginUNIQUEID"; + &event_logger; + } } if ($CLlead_id > 0) @@ -1135,11 +1184,14 @@ while($one_day_interval > 0) &event_logger; } - $stmtA = "UPDATE vicidial_live_agents set status='PAUSED',random_id='10' where callerid='$KLcallerid[$kill_vac]';"; - $affected_rows = $dbhA->do($stmtA); + if ($KLcallerid[$kill_vac] !~ /^M\d\d\d\d\d\d\d\d\d\d/) + { + $stmtA = "UPDATE vicidial_live_agents set status='PAUSED',random_id='10' where callerid='$KLcallerid[$kill_vac]';"; + $affected_rows = $dbhA->do($stmtA); - $event_string = "| dead call vla agent PAUSED $affected_rows|$CLlead_id|$CLphone_number|$CLstatus|"; - &event_logger; + $event_string = "| dead call vla agent PAUSED $affected_rows|$CLlead_id|$CLphone_number|$CLstatus|"; + &event_logger; + } if ( ($enable_queuemetrics_logging > 0) && ($CLstatus =~ /LIVE/) ) { @@ -1163,7 +1215,7 @@ while($one_day_interval > 0) $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $epc_countCAMPDATA=0; + $epc_countCAMPDATA=0; while ($sthArows > $epc_countCAMPDATA) { @aryA = $sthA->fetchrow_array; @@ -1171,7 +1223,7 @@ while($one_day_interval > 0) $VD_auto_alt_dial_statuses = "$aryA[1]"; $VD_use_internal_dnc = "$aryA[2]"; $VD_use_campaign_dnc = "$aryA[3]"; - $epc_countCAMPDATA++; + $epc_countCAMPDATA++; } $sthA->finish(); if ( ($VD_auto_alt_dial_statuses =~ / $CLnew_status /) && ($CLlead_id > 0) ) diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index a8830685..8d5a5c80 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -341,6 +341,7 @@ external_hangup VARCHAR(1) default '', external_status VARCHAR(6) default '', external_pause VARCHAR(20) default '', external_dial VARCHAR(100) default '', +agent_log_id INT(9) UNSIGNED default '0', index (random_id), index (last_call_time), index (last_update_time), @@ -1650,7 +1651,7 @@ CREATE INDEX phone_number on vicidial_closer_log (phone_number); CREATE INDEX date_user on vicidial_closer_log (call_date,user); CREATE INDEX comment_a on live_inbound_log (comment_a); -UPDATE system_settings SET db_schema_version='1150'; +UPDATE system_settings SET db_schema_version='1151'; GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/agc_2-X/trunk/extras/upgrade_2.2.0.sql b/agc_2-X/trunk/extras/upgrade_2.2.0.sql index 930d19d1..2a6790ff 100644 --- a/agc_2-X/trunk/extras/upgrade_2.2.0.sql +++ b/agc_2-X/trunk/extras/upgrade_2.2.0.sql @@ -173,3 +173,7 @@ UPDATE system_settings SET db_schema_version='1149'; ALTER TABLE vicidial_campaigns ADD drop_lockout_time VARCHAR(6) default '0'; UPDATE system_settings SET db_schema_version='1150'; + +ALTER TABLE vicidial_live_agents ADD agent_log_id INT(9) UNSIGNED default '0'; + +UPDATE system_settings SET db_schema_version='1151'; diff --git a/agc_2-X/trunk/www/agc/vdc_db_query.php b/agc_2-X/trunk/www/agc/vdc_db_query.php index 055da4ce..6585257c 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -200,12 +200,13 @@ # 90508-0726 - Changed to PHP long tags # 90511-0923 - Added agentonly_callback_campaign_lock option # 90519-0634 - Fixed manual dial status and logging bug +# 90611-1423 - Fixed agent log and vicidial log bugs # -$version = '2.2.0-111'; -$build = '90519-0634'; +$version = '2.2.0-112'; +$build = '90611-1423'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=217; +$mysql_log_count=224; $one_mysql_log=0; require("dbconnect.php"); @@ -373,6 +374,8 @@ if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} if (isset($_GET["vtiger_callback_id"])) {$vtiger_callback_id=$_GET["vtiger_callback_id"];} elseif (isset($_POST["vtiger_callback_id"])) {$vtiger_callback_id=$_POST["vtiger_callback_id"];} +if (isset($_GET["dial_method"])) {$dial_method=$_GET["dial_method"];} + elseif (isset($_POST["dial_method"])) {$dial_method=$_POST["dial_method"];} header ("Content-type: text/html; charset=utf-8"); @@ -763,8 +766,29 @@ if ($ACTION == 'regCLOSER') } + + + ################################################################################ -### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### For every process below, lookup the current agent_log_id for the user +################################################################################ +$stmt="SELECT agent_log_id from vicidial_live_agents where user='$user';"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00222',$user,$server_ip,$session_name,$one_mysql_log);} +$users_to_parse = mysql_num_rows($rslt); +if ($users_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] > 0) {$agent_log_id = $rowx[0];} + } + + + + + + +################################################################################ +### manDiaLnextCaLL - for manual VICIDiaL dialing this will grab the next lead ### in the campaign, reserve it, send data back to client and ### place the call by inserting into vicidial_manager ################################################################################ @@ -1587,23 +1611,49 @@ if ($stage == "start") } else { - $user_group=''; - $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00056',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $ug_record_ct = mysql_num_rows($rslt); - if ($ug_record_ct > 0) - { - $row=mysql_fetch_row($rslt); - $user_group = trim("$row[0]"); - } - ##### insert log into vicidial_log for manual VICIDiaL call - $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed,user_group,alt_dial) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N','$user_group','$alt_dial');"; - if ($DB) {echo "$stmt\n";} + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00057',$user,$server_ip,$session_name,$one_mysql_log);} - $affected_rows = mysql_affected_rows($link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00056',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + $manualVLexists=0; + $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); + $stmt="SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00223',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VL_exists_ct = mysql_num_rows($rslt); + if ($VL_exists_ct > 0) + { + $row=mysql_fetch_row($rslt); + $manualVLexists = $row[0]; + } + + if ($manualVLexists < 1) + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed,user_group,alt_dial) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N','$user_group','$alt_dial');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00057',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="UPDATE vicidial_log SET list_id='$list_id',comments='MANUAL',user_group='$user_group',alt_dial='$alt_dial' where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00224',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } if ($affected_rows > 0) { @@ -2202,33 +2252,45 @@ if ($stage == "end") } ### check to see if the vicidial_log record exists, if not, insert it - $stmt="SELECT count(*) from vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + $manualVLexists=0; + $beginUNIQUEID = preg_replace("/\..*/","",$uniqueid); + $stmt="SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00186',$user,$server_ip,$session_name,$one_mysql_log);} - $VAC_vld_ct = mysql_num_rows($rslt); - if ($VAC_vld_ct > 0) + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00223',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VL_exists_ct = mysql_num_rows($rslt); + if ($VL_exists_ct > 0) { $row=mysql_fetch_row($rslt); - $VLD_count = $row[0]; - if ($VLD_count < 1) - { - ##### insert log into vicidial_log for manual VICIDiaL call - $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed,user_group,alt_dial) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','DONEM','$phone_code','$phone_number','$user','MANUAL','N','$user_group','$alt_dial');"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_query($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00057',$user,$server_ip,$session_name,$one_mysql_log);} - $affected_rows = mysql_affected_rows($link); + $manualVLexists = $row[0]; + } - if ($affected_rows > 0) - { - echo "VICIDiaL_LOG Inserted: $uniqueid|$channel|$NOW_TIME\n"; - echo "$StarTtime\n"; - } - else - { - echo "LOG NOT ENTERED\n"; - } + if ($manualVLexists < 1) + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed,user_group,alt_dial) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','DONEM','$phone_code','$phone_number','$user','MANUAL','N','$user_group','$alt_dial');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00057',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Inserted: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; } + else + { + echo "LOG NOT ENTERED\n"; + } + } + else + { + $stmt="UPDATE vicidial_log SET uniqueid='$uniqueid' where lead_id='$lead_id' and user='$user' and phone_number='$phone_number' and uniqueid LIKE \"$beginUNIQUEID%\";"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00057',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); } ##### update the duration and end time in the vicidial_log table @@ -2491,8 +2553,9 @@ if ($stage == "end") $talk_sec=0; $talk_epochSQL=''; + $lead_id_commentsSQL=''; $StarTtime = date("U"); - $stmt = "select talk_epoch,talk_sec,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + $stmt = "select talk_epoch,talk_sec,wait_sec,wait_epoch,lead_id,comments from vicidial_agent_log where agent_log_id='$agent_log_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00101',$user,$server_ip,$session_name,$one_mysql_log);} @@ -2503,11 +2566,22 @@ if ($stage == "end") if ( (eregi("NULL",$row[0])) or ($row[0] < 1000) ) { $talk_epochSQL=",talk_epoch='$StarTtime'"; - $row[0]=$row[2]; + $row[0]=$row[3]; } $talk_sec = (($StarTtime - $row[0]) + $row[1]); + if ( ( ($auto_dial_level < 1) or (preg_match('/^M/',$MDnextCID)) ) and (preg_match('/INBOUND_MAN/',$dial_method)) ) + { + if ( (eregi("NULL",$row[5])) or (strlen($row[5]) < 1) ) + { + $lead_id_commentsSQL .= ",comments='MANUAL'"; + } + if ( (eregi("NULL",$row[4])) or ($row[4] < 1) or (strlen($row[4]) < 1) ) + { + $lead_id_commentsSQL .= ",lead_id='$lead_id'"; + } + } } - $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',dispo_epoch='$StarTtime' $talk_epochSQL where agent_log_id='$agent_log_id';"; + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',dispo_epoch='$StarTtime' $talk_epochSQL $lead_id_commentsSQL where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00102',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3303,6 +3377,7 @@ if ($ACTION == 'updateDISPO') { $MT[0]=''; $row=''; $rowx=''; + $MAN_vl_insert=0; if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) { echo "Dispo Choice $dispo or lead_id $lead_id is not valid\n"; @@ -3354,7 +3429,7 @@ if ($ACTION == 'updateDISPO') { $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); - if ($auto_dial_level < 1) + if ( ($auto_dial_level < 1) or (preg_match('/^M/',$MDnextCID)) ) { $stmt = "SELECT count(*) from vicidial_log where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\";"; if ($format=='debug') {echo "\n";} @@ -3417,7 +3492,14 @@ if ($ACTION == 'updateDISPO') if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00215',$user,$server_ip,$session_name,$one_mysql_log);} + + $MAN_vl_insert++; } + + $stmt="DELETE FROM vicidial_auto_calls where callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00219',$user,$server_ip,$session_name,$one_mysql_log);} } else { @@ -3492,8 +3574,9 @@ if ($ACTION == 'updateDISPO') $dispo_sec=0; $dispo_epochSQL=''; + $lead_id_commentsSQL=''; $StarTtime = date("U"); - $stmt = "select dispo_epoch,dispo_sec,talk_epoch,wait_epoch from vicidial_agent_log where agent_log_id='$agent_log_id';"; + $stmt = "select dispo_epoch,dispo_sec,talk_epoch,wait_epoch,lead_id,comments from vicidial_agent_log where agent_log_id='$agent_log_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00150',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3513,8 +3596,19 @@ if ($ACTION == 'updateDISPO') $row[0]=$row[2]; } $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + if ( (preg_match('/^M/',$MDnextCID)) and (preg_match('/INBOUND_MAN/',$dial_method)) ) + { + if ( (eregi("NULL",$row[5])) or (strlen($row[5]) < 1) ) + { + $lead_id_commentsSQL .= ",comments='MANUAL'"; + } + if ( (eregi("NULL",$row[4])) or ($row[4] < 1) or (strlen($row[4]) < 1) ) + { + $lead_id_commentsSQL .= ",lead_id='$lead_id'"; + } + } } - $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',status='$dispo_choice' $dispo_epochSQL where agent_log_id='$agent_log_id';"; + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',status='$dispo_choice' $dispo_epochSQL $lead_id_commentsSQL where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00151',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3533,12 +3627,21 @@ if ($ACTION == 'updateDISPO') if ($auto_dial_level < 1) { - $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch,user_group) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime','$user_group');"; + $MAN_insert_leadIDsql=''; + if ($MAN_vl_insert > 0) + {$MAN_insert_leadIDsql = ",lead_id='$lead_id'";} + $stmt="INSERT INTO vicidial_agent_log SET user='$user',server_ip='$server_ip',event_time='$NOW_TIME',campaign_id='$campaign',pause_epoch='$StarTtime',pause_sec='0',wait_epoch='$StarTtime',user_group='$user_group'$MAN_insert_leadIDsql;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00153',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); $agent_log_id = mysql_insert_id($link); + + $stmt="UPDATE vicidial_live_agents SET agent_log_id='$agent_log_id' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00220',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAaffected_rows_update = mysql_affected_rows($link); } ### CALLBACK ENTRY @@ -4293,6 +4396,12 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00153',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); $agent_log_id = mysql_insert_id($link); + + $stmt="UPDATE vicidial_live_agents SET agent_log_id='$agent_log_id' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00221',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAaffected_rows_update = mysql_affected_rows($link); } } echo 'Agent ' . $user . ' is now in status ' . $stage . "\nNext agent_log_id:\n$agent_log_id\n"; diff --git a/agc_2-X/trunk/www/agc/vicidial.php b/agc_2-X/trunk/www/agc/vicidial.php index f5c42e39..3db6f559 100644 --- a/agc_2-X/trunk/www/agc/vicidial.php +++ b/agc_2-X/trunk/www/agc/vicidial.php @@ -232,12 +232,13 @@ # 90525-1012 - Fixed transfer issue of auto-received call after manual dial call # 90529-0741 - Added nophone agent phone login that will not show any empty session alerts # 90531-0635 - Added option to hide customer phone number +# 90611-1422 - Fixed multiple logging bugs # -$version = '2.2.0-210'; -$build = '90531-0635'; +$version = '2.2.0-211'; +$build = '90611-1422'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=60; +$mysql_log_count=61; $one_mysql_log=0; require("dbconnect.php"); @@ -1175,7 +1176,7 @@ $VDloginDISPLAY=0; ##### grab the inbound groups to choose from if campaign contains CLOSER $VARingroups="''"; - if ($campaign_allow_inbound == 'Y') + if ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') ) { $VARingroups=''; $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 60;"; @@ -1193,6 +1194,8 @@ $VDloginDISPLAY=0; } $VARingroups = substr("$VARingroups", 0, -1); } + else + {$closer_campaigns = "''";} ##### grab the allowable inbound groups to choose from for transfer options $xfer_groups = preg_replace("/^ | -$/","",$xfer_groups); @@ -1621,7 +1624,7 @@ else $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01030',$VD_login,$server_ip,$session_name,$one_mysql_log);} - if ( ($campaign_allow_inbound == 'Y') || ($campaign_leads_to_call > 0) || (ereg('Y',$no_hopper_leads_logins)) ) + if ( ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') ) || ($campaign_leads_to_call > 0) || (ereg('Y',$no_hopper_leads_logins)) ) { ### insert an entry into the user log for the login event $stmt = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE','$VU_user_group')"; @@ -1802,7 +1805,7 @@ else } - if ($campaign_allow_inbound == 'Y') + if ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') ) { print "\n"; } @@ -1913,6 +1916,12 @@ else $agent_log_id = mysql_insert_id($link); print "\n"; + $stmt="UPDATE vicidial_live_agents SET agent_log_id='$agent_log_id' where user='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01061',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VLAaffected_rows_update = mysql_affected_rows($link); + $stmt="UPDATE vicidial_users SET shift_override_flag='0' where user='$VD_login' and shift_override_flag='1';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); @@ -3707,7 +3716,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&list_id=" + document.vicidial_form.list_id.value + "&length_in_sec=0&phone_code=" + document.vicidial_form.phone_code.value + "&phone_number=" + lead_dial_number + - "&exten=" + extension + "&channel=" + lastcustchannel + "&start_epoch=" + MDlogEPOCH + "&auto_dial_level=" + auto_dial_level + "&VDstop_rec_after_each_call=" + VDstop_rec_after_each_call + "&conf_silent_prefix=" + conf_silent_prefix + "&protocol=" + protocol + "&extension=" + extension + "&ext_context=" + ext_context + "&conf_exten=" + session_id + "&user_abb=" + user_abb + "&agent_log_id=" + agent_log_id + "&MDnextCID=" + LasTCID + "&inOUT=" + inOUT + "&alt_dial=" + dialed_label + "&DB=0" + "&agentchannel=" + agentchannel + "&conf_dialed=" + conf_dialed + "&leaving_threeway=" + leaving_threeway + "&hangup_all_non_reserved=" + hangup_all_non_reserved + "&blind_transfer=" + blind_transfer; + "&exten=" + extension + "&channel=" + lastcustchannel + "&start_epoch=" + MDlogEPOCH + "&auto_dial_level=" + auto_dial_level + "&VDstop_rec_after_each_call=" + VDstop_rec_after_each_call + "&conf_silent_prefix=" + conf_silent_prefix + "&protocol=" + protocol + "&extension=" + extension + "&ext_context=" + ext_context + "&conf_exten=" + session_id + "&user_abb=" + user_abb + "&agent_log_id=" + agent_log_id + "&MDnextCID=" + LasTCID + "&inOUT=" + inOUT + "&alt_dial=" + dialed_label + "&DB=0" + "&agentchannel=" + agentchannel + "&conf_dialed=" + conf_dialed + "&leaving_threeway=" + leaving_threeway + "&hangup_all_non_reserved=" + hangup_all_non_reserved + "&blind_transfer=" + blind_transfer + "&dial_method" + dial_method; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); // document.getElementById("busycallsdebug").innerHTML = "vdc_db_query.php?" + manDiaLlog_query; @@ -4211,7 +4220,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} { auto_dial_level=0; - AutoDial_ReSume_PauSe('VDADpause'); + agent_log_id = AutoDial_ReSume_PauSe('VDADpause'); document.getElementById("DiaLControl").innerHTML = "\"\"Resume\"
\"Dial"; } @@ -4887,7 +4896,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign; + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign + "&dial_method" + dial_method; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(autoDiaLready_query); @@ -4907,6 +4916,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } delete xmlhttp; } + return agent_log_id; } @@ -5764,6 +5774,9 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} { if (hotkeysused == 'YES') { + manual_auto_hotkey = 1; + alt_dial_active=0; + document.getElementById("MainStatuSSpan").style.background = panel_bgcolor; document.getElementById("MainStatuSSpan").innerHTML = ''; if (dial_method == "INBOUND_MAN") @@ -6186,7 +6199,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - DSupdate_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=updateDISPO&format=text&user=" + user + "&pass=" + pass + "&dispo_choice=" + DispoChoice + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign + "&auto_dial_level=" + auto_dial_level + "&agent_log_id=" + agent_log_id + "&CallBackDatETimE=" + CallBackDatETimE + "&list_id=" + document.vicidial_form.list_id.value + "&recipient=" + CallBackrecipient + "&use_internal_dnc=" + use_internal_dnc + "&use_campaign_dnc=" + use_campaign_dnc + "&MDnextCID=" + LasTCID + "&stage=" + group + "&vtiger_callback_id=" + vtiger_callback_id + "&phone_number=" + document.vicidial_form.phone_number.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&comments=" + CallBackCommenTs; + DSupdate_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=updateDISPO&format=text&user=" + user + "&pass=" + pass + "&dispo_choice=" + DispoChoice + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign + "&auto_dial_level=" + auto_dial_level + "&agent_log_id=" + agent_log_id + "&CallBackDatETimE=" + CallBackDatETimE + "&list_id=" + document.vicidial_form.list_id.value + "&recipient=" + CallBackrecipient + "&use_internal_dnc=" + use_internal_dnc + "&use_campaign_dnc=" + use_campaign_dnc + "&MDnextCID=" + LasTCID + "&stage=" + group + "&vtiger_callback_id=" + vtiger_callback_id + "&phone_number=" + document.vicidial_form.phone_number.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&dial_method" + dial_method + "&comments=" + CallBackCommenTs; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(DSupdate_query); @@ -6286,7 +6299,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} if (auto_dial_level != '0') { AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready","NEW_ID"); + agent_log_id = AutoDial_ReSume_PauSe("VDADready","NEW_ID"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; } else @@ -6722,7 +6735,7 @@ if ($useIE > 0) function hotkeypress(evt) { enter_disable(); - if ( (hot_keys_active==1) && (VD_live_customer_call==1) ) + if ( (hot_keys_active==1) && ( (VD_live_customer_call==1) || (MD_ring_secondS > 4) ) ) { var e = evt? evt : window.event; if(!e) return; @@ -6769,7 +6782,7 @@ else function hotkeypress(evt) { enter_disable(); - if ( (hot_keys_active==1) && (VD_live_customer_call==1) ) + if ( (hot_keys_active==1) && ( (VD_live_customer_call==1) || (MD_ring_secondS > 4) ) ) { var e = evt? evt : window.event; if(!e) return; diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php b/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php index 0e1459ad..af564726 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php @@ -285,7 +285,7 @@ else { $row=mysql_fetch_row($rslt); - if ( ($row[0] > 0) and (strlen($row[3]) > 0) ) + if ( ($row[0] > 0) and (strlen($row[3]) > 0) and (!eregi("NULL",$row[3]))) { $calls[$i] = $row[0]; $full_name[$i] = $row[1]; diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php b/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php index 7bda6388..09381750 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php @@ -326,7 +326,7 @@ else ##### BEGIN Gather all agent time records and parse through them in PHP to save on DB load - $stmt="select user,wait_sec,talk_sec,dispo_sec,pause_sec,lead_id from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' $group_SQL $user_group_SQL limit 10000000;"; + $stmt="select user,wait_sec,talk_sec,dispo_sec,pause_sec,lead_id,status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' $group_SQL $user_group_SQL limit 10000000;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $rows_to_print = mysql_num_rows($rslt); @@ -343,6 +343,7 @@ else $dispo = $row[3]; $pause = $row[4]; $lead = $row[5]; + $status = $row[6]; if ($wait > 30000) {$wait=0;} if ($talk > 30000) {$talk=0;} @@ -353,7 +354,7 @@ else $TOTdispo = ($TOTdispo + $dispo); $TOTpause = ($TOTpause + $pause); $TOTALtime = ($TOTALtime + $pause + $dispo + $talk + $wait); - if ($lead > 0) {$TOTcalls++;} + if ( ($lead > 0) and ((!eregi("NULL",$status)) and (strlen($status) > 0)) ) {$TOTcalls++;} $user_found=0; if ($uc < 1) @@ -372,7 +373,7 @@ else $Stalk[$m] = ($Stalk[$m] + $talk); $Sdispo[$m] = ($Sdispo[$m] + $dispo); $Spause[$m] = ($Spause[$m] + $pause); - if ($lead > 0) {$Scalls[$m]++;} + if ( ($lead > 0) and ((!eregi("NULL",$status)) and (strlen($status) > 0)) ) {$Scalls[$m]++;} } $m++; }