From 663d674e60c18c72dbce85077e20dad305992ea6 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 21 May 2018 21:07:48 +0000 Subject: [PATCH] Changed closer logs for AGENTDIRECT calls to log destination user git-svn-id: svn://192.168.202.10@2988 3d104415-ff17-0410-8863-d5cf3c621b8a --- agi/agi-VDAD_ALL_inbound.agi | 58 ++++++++++++++++++++++++++++++------ bin/FastAGI_log.pl | 15 +++++++--- 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/agi/agi-VDAD_ALL_inbound.agi b/agi/agi-VDAD_ALL_inbound.agi index 0d40ab8d..04d305ee 100644 --- a/agi/agi-VDAD_ALL_inbound.agi +++ b/agi/agi-VDAD_ALL_inbound.agi @@ -226,6 +226,7 @@ # 180321-0824 - Added source_id as optional channel variable to populate when inserting new leads # 180424-1539 - Added in-group populate_lead_source, populate_lead_vendor options # 180520-1802 - Added enter_ingroup_url feature +# 180521-0736 - Changed closer logs for AGENTDIRECT calls to log destination user # $script = 'agi-VDAD_ALL_inbound.agi'; @@ -1095,6 +1096,8 @@ if ( ($channel_group =~ /AGENTDIRECT/i) && (length($agent_only) < 1) ) $drop_call_seconds = 1; } +$LOGuser='VDCL'; + $AGI->stream_file('sip-silence'); $AGI->stream_file('sip-silence'); @@ -1579,6 +1582,10 @@ if ($ct_yest_stop > 2400) {$ct_stop_overflow = ($ct_yest_stop - 2400);} if ( ( ( ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) ) && ($hm >= $ct_stop_overflow) ) || ($MCafterhours_override > 0) ) && ($dial_ingroup_flag < 1) ) { + # set the log-user to the agentdirect destination user, if set + if ( ($channel_group =~ /AGENTDIRECT/i) && (length($agent_only) > 1) ) + {$LOGuser = $agent_only;} + $VHqueryCID = "VA$CIDdate$hour$min$sec$sec"; $AHstatus='AFTHRS'; $AHterm='AFTERHOURS'; @@ -1589,7 +1596,7 @@ if ( ( ( ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) ) && ($hm >= $c $AHterm = $MCterm; $AHcomments = $MCcomments; } - $stmtA = "INSERT INTO vicidial_closer_log set status='$AHstatus',start_epoch='$now_date_epoch',end_epoch='$now_date_epoch',length_in_sec='1',queue_seconds='0',lead_id = '$insert_lead_id',campaign_id='$channel_group',user='VDCL',list_id='$list_id',call_date='$now_date',phone_code='$phone_code',phone_number='$phone_number',comments='$AHcomments',term_reason='$AHterm',uniqueid='$uniqueid',called_count='$called_count';"; + $stmtA = "INSERT INTO vicidial_closer_log set status='$AHstatus',start_epoch='$now_date_epoch',end_epoch='$now_date_epoch',length_in_sec='1',queue_seconds='0',lead_id = '$insert_lead_id',campaign_id='$channel_group',user='$LOGuser',list_id='$list_id',call_date='$now_date',phone_code='$phone_code',phone_number='$phone_number',comments='$AHcomments',term_reason='$AHterm',uniqueid='$uniqueid',called_count='$called_count';"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02016'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; $stmtB = "SELECT LAST_INSERT_ID() LIMIT 1;"; @@ -1838,8 +1845,11 @@ if ( ( ($no_agent_no_queue =~ /Y|NO_PAUSED|NO_READY/) || ($MCnanque_override > 0 $NQterm = $MCterm; $NQcomments = $MCcomments; } + # set the log-user to the agentdirect destination user, if set + if ( ($channel_group =~ /AGENTDIRECT/i) && (length($agent_only) > 1) ) + {$LOGuser = $agent_only;} - $stmtA = "INSERT INTO vicidial_closer_log set status='$NQstatus',start_epoch='$now_date_epoch',end_epoch='$now_date_epoch',length_in_sec='1',queue_seconds='0',lead_id='$insert_lead_id',campaign_id='$channel_group',user='VDCL',list_id='$list_id',call_date='$now_date',phone_code='$phone_code',phone_number='$phone_number',comments='$NQcomments',term_reason='$NQterm',uniqueid='$uniqueid',called_count='$called_count';"; + $stmtA = "INSERT INTO vicidial_closer_log set status='$NQstatus',start_epoch='$now_date_epoch',end_epoch='$now_date_epoch',length_in_sec='1',queue_seconds='0',lead_id='$insert_lead_id',campaign_id='$channel_group',user='$LOGuser',list_id='$list_id',call_date='$now_date',phone_code='$phone_code',phone_number='$phone_number',comments='$NQcomments',term_reason='$NQterm',uniqueid='$uniqueid',called_count='$called_count';"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02105'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; $stmtB = "SELECT LAST_INSERT_ID() LIMIT 1;"; @@ -2383,7 +2393,7 @@ $Uaffected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02121'; $MEL_aff_rows=$Uaffected_rows; &mysql_error_logging; ### INSERT vicidial_closer_log record, call is entering the queue -$stmtA = "INSERT INTO vicidial_closer_log SET lead_id='$insert_lead_id', campaign_id='$channel_group', call_date='$SQLdate', start_epoch='$now_date_epoch', status='QUEUE', phone_code='$phone_code', phone_number='$phone_number', user='VDCL', processed='N', xfercallid='$insert_xfer_id', uniqueid='$uniqueid', queue_position='$queue_position',called_count='$called_count',list_id='$list_id' $adSQL;"; +$stmtA = "INSERT INTO vicidial_closer_log SET lead_id='$insert_lead_id', campaign_id='$channel_group', call_date='$SQLdate', start_epoch='$now_date_epoch', status='QUEUE', phone_code='$phone_code', phone_number='$phone_number', user='$LOGuser', processed='N', xfercallid='$insert_xfer_id', uniqueid='$uniqueid', queue_position='$queue_position',called_count='$called_count',list_id='$list_id' $adSQL;"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02031'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; @@ -4190,7 +4200,12 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override if ($drop_seconds < 1) {$drop_seconds = $drop_timer;} - $stmtA = "UPDATE vicidial_closer_log set status='HXFER',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='HOLDRECALLXFER' where lead_id = '$insert_lead_id' order by closecallid desc limit 1;"; + # set the log-user to the agentdirect destination user, if set + $LOGuserSQL=''; + if ( ($channel_group =~ /AGENTDIRECT/i) && (length($agent_only) > 1) ) + {$LOGuserSQL = ",user='$agent_only'";} + + $stmtA = "UPDATE vicidial_closer_log set status='HXFER',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='HOLDRECALLXFER'$LOGuserSQL where lead_id = '$insert_lead_id' order by closecallid desc limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02076'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;} @@ -4653,7 +4668,12 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override if ($drop_seconds < 1) {$drop_seconds = $drop_timer;} - $stmtA = "UPDATE vicidial_closer_log set status='$NQstatus',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='$NQterm',comments='$NQcomments' where lead_id = '$insert_lead_id' order by closecallid desc limit 1;"; + # set the log-user to the agentdirect destination user, if set + $LOGuserSQL=''; + if ( ($channel_group =~ /AGENTDIRECT/i) && (length($agent_only) > 1) ) + {$LOGuserSQL = ",user='$agent_only'";} + + $stmtA = "UPDATE vicidial_closer_log set status='$NQstatus',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='$NQterm',comments='$NQcomments'$LOGuserSQL where lead_id = '$insert_lead_id' order by closecallid desc limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02105'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) {$agi_string = "-- ACF VDCL vcl update: |$affected_rows|$insert_lead_id|$insert_close_id|$MCareacode_override|\n|$stmtA|"; &agi_output;} @@ -5262,8 +5282,13 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override if ($drop_seconds < 1) {$drop_seconds = $drop_timer;} + # set the log-user to the agentdirect destination user, if set + $LOGuserSQL=''; + if ( ($channel_group =~ /AGENTDIRECT/i) && (length($agent_only) > 1) ) + {$LOGuserSQL = ",user='$agent_only'";} + if (length($HT_status)<1) {$HT_status='WAITTO';} - $stmtA = "UPDATE vicidial_closer_log set status='$HT_status',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='HOLDTIME' where lead_id = '$insert_lead_id' order by closecallid desc limit 1;"; + $stmtA = "UPDATE vicidial_closer_log set status='$HT_status',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='HOLDTIME'$LOGuserSQL where lead_id = '$insert_lead_id' order by closecallid desc limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02091'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;} @@ -5758,8 +5783,13 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override if ($drop_seconds < 1) {$drop_seconds = $drop_timer;} + # set the log-user to the agentdirect destination user, if set + $LOGuserSQL=''; + if ( ($channel_group =~ /AGENTDIRECT/i) && (length($agent_only) > 1) ) + {$LOGuserSQL = ",user='$agent_only'";} + if (length($HT_status)<1) {$HT_status='HOLDTO';} - $stmtA = "UPDATE vicidial_closer_log set status='$HT_status',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='HOLDTIME' where lead_id = '$insert_lead_id' order by closecallid desc limit 1;"; + $stmtA = "UPDATE vicidial_closer_log set status='$HT_status',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='HOLDTIME'$LOGuserSQL where lead_id = '$insert_lead_id' order by closecallid desc limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02091'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;} @@ -6261,8 +6291,13 @@ if ($closing_check > 0) if ($drop_seconds < 1) {$drop_seconds = $drop_timer;} + # set the log-user to the agentdirect destination user, if set + $LOGuserSQL=''; + if ( ($channel_group =~ /AGENTDIRECT/i) && (length($agent_only) > 1) ) + {$LOGuserSQL = ",user='$agent_only'";} + if (length($HT_status)<1) {$HT_status='CLOSOP';} - $stmtA = "UPDATE vicidial_closer_log set status='$HT_status',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='CLOSETIME' where lead_id = '$insert_lead_id' order by closecallid desc limit 1;"; + $stmtA = "UPDATE vicidial_closer_log set status='$HT_status',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='CLOSETIME'$LOGuserSQL where lead_id = '$insert_lead_id' order by closecallid desc limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02243'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;} @@ -6548,7 +6583,12 @@ if ( ($drop_timer > $DROP_TIME) || ($MCdrop_override > 0) ) $dbhP=$dbhA; $mysql_count='02099'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) {$agi_string = "-- VDCL vac record deleted: |$affected_rows| $channel_group|"; &agi_output;} - $stmtA = "UPDATE vicidial_closer_log set status='$DRstatus',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='$DRterm' where lead_id='$insert_lead_id' order by closecallid desc limit 1;"; + # set the log-user to the agentdirect destination user, if set + $LOGuserSQL=''; + if ( ($channel_group =~ /AGENTDIRECT/i) && (length($agent_only) > 1) ) + {$LOGuserSQL = ",user='$agent_only'";} + + $stmtA = "UPDATE vicidial_closer_log set status='$DRstatus',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='$DRterm'$LOGuserSQL where lead_id='$insert_lead_id' order by closecallid desc limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02100'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;} diff --git a/bin/FastAGI_log.pl b/bin/FastAGI_log.pl index 0a4e526b..5b358825 100644 --- a/bin/FastAGI_log.pl +++ b/bin/FastAGI_log.pl @@ -25,7 +25,7 @@ # exten => h,1,DeadAGI(agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME}) # # -# Copyright (C) 2017 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2018 Matt Florell LICENSE: AGPLv2 # # CHANGELOG: # 61010-1007 - First test build @@ -80,6 +80,7 @@ # 170508-1148 - Added blind monitor call end logging # 170527-2340 - Fix for rare inbound logging issue #1017 # 170915-1753 - Asterisk 13 compatibility +# 180521-1153 - Changed closer log logging to use agent if call was AGENTDIRECT # # defaults for PreFork @@ -1088,7 +1089,7 @@ sub process_request { ########## FIND AND DELETE vicidial_auto_calls ########## $VD_alt_dial = 'NONE'; - $stmtA = "SELECT lead_id,callerid,campaign_id,alt_dial,stage,UNIX_TIMESTAMP(call_time),uniqueid,status,call_time,phone_code,phone_number,queue_position,server_ip FROM vicidial_auto_calls where uniqueid = '$uniqueid' or callerid = '$callerid' limit 1;"; + $stmtA = "SELECT lead_id,callerid,campaign_id,alt_dial,stage,UNIX_TIMESTAMP(call_time),uniqueid,status,call_time,phone_code,phone_number,queue_position,server_ip,agent_only FROM vicidial_auto_calls where uniqueid = '$uniqueid' or callerid = '$callerid' limit 1;"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1110,6 +1111,7 @@ sub process_request $VD_phone_number = $aryA[10]; $VD_queue_position = $aryA[11]; $VD_server_ip = $aryA[12]; + $VD_agent_only = $aryA[13]; $rec_countCUSTDATA++; } $sthA->finish(); @@ -1581,9 +1583,14 @@ sub process_request $VDCLSQL_update = "$VDCLSQL_status$VDCLSQL_term_reason$VDCLSQL_queue_seconds"; } + # set the log-user to the agentdirect destination user, if set + $LOGuserSQL=''; + if ( ($VD_campaign_id =~ /AGENTDIRECT/i) && (length($VD_agent_only) > 1) ) + {$LOGuserSQL = ",user='$VD_agent_only'";} + $VD_seconds = ($now_date_epoch - $VD_start_epoch); - $stmtA = "UPDATE vicidial_closer_log set $VDCLSQL_update end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where closecallid = '$VD_closecallid';"; - if ($AGILOG) {$agi_string = "|$VDCLSQL_update|$VD_status|$VD_length_in_sec|$VD_term_reason|$VD_queue_seconds|\n|$stmtA|"; &agi_output;} + $stmtA = "UPDATE vicidial_closer_log set $VDCLSQL_update end_epoch='$now_date_epoch',length_in_sec='$VD_seconds'$LOGuserSQL where closecallid = '$VD_closecallid';"; + if ($AGILOG) {$agi_string = "|$VDCLSQL_update|$VD_status|$VD_length_in_sec|$VD_term_reason|$VD_queue_seconds|$VD_campaign_id|$VD_agent_only|\n|$stmtA|"; &agi_output;} $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDCL update: |$affected_rows|$uniqueid|$VD_closecallid|"; &agi_output;}