diff --git a/UPGRADE b/UPGRADE index 4fcba33c..752ed8f6 100644 --- a/UPGRADE +++ b/UPGRADE @@ -335,6 +335,9 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom 79. Added 5 custom fields to the user settings +80. Added Initial Queue Position logging on inbound calls and a summary of this + to the Inbound report + diff --git a/agi/agi-VDAD_ALL_inbound.agi b/agi/agi-VDAD_ALL_inbound.agi index 6505e371..1e04ad15 100644 --- a/agi/agi-VDAD_ALL_inbound.agi +++ b/agi/agi-VDAD_ALL_inbound.agi @@ -105,6 +105,7 @@ # 91105-1258 - Added CallerIDnumber change on Drop when sending call out # 91122-2352 - Added queue_log IVR and DID entry linking # 91125-0921 - Fixed no-agent-no-queue AGENTDIRECT bug +# 91213-0942 - Added queue_position to queue_log COMPLETE... records # $script = 'agi-VDAD_ALL_inbound.agi'; @@ -115,7 +116,7 @@ $start_moh=1; $at='@'; $S='*'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=119; +$mysql_log_count=121; $one_mysql_log=0; @@ -1173,7 +1174,7 @@ $sthArows=$sthA->rows; if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $auto_call_id = "$aryA[0]"; + $auto_call_id = $aryA[0]; ### UPDATE existing record to LIVE in the vicidial_auto_calls table $stmtA = "UPDATE vicidial_auto_calls SET campaign_id='$channel_group',status='LIVE',lead_id='$insert_lead_id',callerid='$callerid',channel='$channel',phone_code='$phone_code',phone_number='$phone_number',call_time='$SQLdate',call_type='IN',stage='LIVE-0',queue_priority='$queue_priority' $adSQL WHERE auto_call_id='$auto_call_id';"; @@ -1198,7 +1199,7 @@ if ($Uaffected_rows < 1) if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $auto_call_id = "$aryA[0]"; + $auto_call_id = $aryA[0]; } $sthA->finish(); } @@ -1213,7 +1214,28 @@ if ($enable_queuemetrics_logging > 0) $dbhB->disconnect(); } -$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' $adSQL;"; +### determin original queue position of the call +$queue_position=1; +$stmtA = "SELECT count(*) from vicidial_auto_calls where status = 'LIVE' and campaign_id='$channel_group';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; + if ($AGILOG) {$agi_string = "$sthArows|$stmtA|"; &agi_output;} + $dbhP=$dbhA; $mysql_count='02120'; $MEL_aff_rows=$sthArows; &mysql_error_logging; +if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $queue_position = $aryA[0]; + } + +### UPDATE vicidial_auto_calls record with starting queue_position +$stmtA = "UPDATE vicidial_auto_calls SET queue_position='$queue_position' WHERE auto_call_id='$auto_call_id';"; +$Uaffected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "$Uaffected_rows|$stmtA|"; &agi_output;} + $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' $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; diff --git a/bin/AST_VDauto_dial.pl b/bin/AST_VDauto_dial.pl index 0b8230d4..e4220f17 100644 --- a/bin/AST_VDauto_dial.pl +++ b/bin/AST_VDauto_dial.pl @@ -87,6 +87,7 @@ # 91026-1218 - Added AREACODE DNC option # 91108-2122 - Added LAGGED PAUSEREASON QM entry for lagged agents # 91123-1802 - Added outbound_autodial field, and exception for outbound-only agents on blended campaign +# 91213-1856 - Added queue_position to queue_log ABANDON records # @@ -1373,7 +1374,45 @@ while($one_day_interval > 0) if ($DBX) {print "CONNECTED TO DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} - $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$KLcallerid[$kill_vac]',queue='$CLcampaign_id',agent='NONE',verb='ABANDON',data1='1',data2='1',data3='$CLstage',serverid='$queuemetrics_log_id';"; + $secX = time(); + $Rtarget = ($secX - 21600); # look for VDCL entry within last 6 hours + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + $RSQLdate = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; + + ### find original queue position of the call + $queue_position=1; + $stmtA = "SELECT queue_position FROM vicidial_closer_log where lead_id='$CLlead_id' and campaign_id='$CLcampaign_id' and call_date > \"$RSQLdate\" order by closecallid desc limit 1;"; + $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; + $queue_position = $aryA[0]; + } + $sthA->finish(); + + ### find current number of calls in this queue to find position when channel hung up + $current_position=1; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and campaign_id='$CLcampaign_id';"; + $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; + $current_position = ($aryA[0] + 1); + } + $sthA->finish(); + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$KLcallerid[$kill_vac]',queue='$CLcampaign_id',agent='NONE',verb='ABANDON',data1='$current_position',data2='$queue_position',data3='$CLstage',serverid='$queuemetrics_log_id';"; $Baffected_rows = $dbhB->do($stmtB); $dbhB->disconnect(); @@ -1959,7 +1998,45 @@ while($one_day_interval > 0) if ($DBX) {print "CONNECTED TO DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} - $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$CLcallerid',queue='$CLcampaign_id',agent='NONE',verb='ABANDON',data1='1',data2='1',data3='$CLstage',serverid='$queuemetrics_log_id';"; + $secX = time(); + $Rtarget = ($secX - 21600); # look for VDCL entry within last 6 hours + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + $RSQLdate = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; + + ### find original queue position of the call + $queue_position=1; + $stmtA = "SELECT queue_position FROM vicidial_closer_log where lead_id='$CLlead_id' and campaign_id='$CLcampaign_id' and call_date > \"$RSQLdate\" order by closecallid desc limit 1;"; + $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; + $queue_position = $aryA[0]; + } + $sthA->finish(); + + ### find current number of calls in this queue to find position when channel hung up + $current_position=1; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and campaign_id='$CLcampaign_id';"; + $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; + $current_position = ($aryA[0] + 1); + } + $sthA->finish(); + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$CLcallerid',queue='$CLcampaign_id',agent='NONE',verb='ABANDON',data1='$current_position',data2='$queue_position',data3='$CLstage',serverid='$queuemetrics_log_id';"; $Baffected_rows = $dbhB->do($stmtB); $dbhB->disconnect(); diff --git a/bin/AST_cleanup_agent_log.pl b/bin/AST_cleanup_agent_log.pl index 73848aa6..f2884144 100644 --- a/bin/AST_cleanup_agent_log.pl +++ b/bin/AST_cleanup_agent_log.pl @@ -22,6 +22,7 @@ # 91112-1100 - Added fixing for more QM issues, added CALLOUTBOUND checking with ENTERQUEUE # 91209-0956 - Added PAUSEREASON-LAGGED queue_log correction during live call # 91210-0609 - Added LOGOFF queue_log correction during live call +# 91214-0933 - Added queue_position to queue_log COMPLETE... and ABANDON records # # constants @@ -293,6 +294,8 @@ if ($enable_queuemetrics_logging > 0) $queue[$h] = $aryB[2]; $verb[$h] = $aryB[3]; $serverid[$h] = $aryB[4]; + $lead_id[$h] = substr($call_id[$h], 11, 9); + $lead_id[$h] = ($lead_id[$h] + 0); $h++; } $sthB->finish(); @@ -347,9 +350,36 @@ if ($enable_queuemetrics_logging > 0) $EQdead++; if ($DB) {print " DEAD IN-QUEUE queue_log CALL: $EQdead|$call_id[$h]|$VLAlive_count|$VAClive_count\n";} + $secX = time(); + $Rtarget = ($secX - 21600); # look for VDCL entry within last 6 hours + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + $RSQLdate = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; + + ### find original queue position of the call + $queue_position=1; + $queue_seconds=0; + $stmtA = "SELECT queue_position,queue_seconds FROM vicidial_closer_log where lead_id='$lead_id[$h]' and campaign_id='$queue[$h]' and call_date > \"$RSQLdate\" order by closecallid desc limit 1;"; + $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; + $queue_position = $aryA[0]; + $queue_seconds = floor($aryA[1] + .5); + } + $sthA->finish(); + $newtimeABANDON = ($time_id[$h] + 1); ##### insert an ABANDON record for this call into the queue_log - $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$newtimeABANDON',call_id='$call_id[$h]',queue='$queue[$h]',agent='NONE',verb='ABANDON',data1='1',data2='1',data3='1',serverid='$serverid[$h]';"; + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$newtimeABANDON',call_id='$call_id[$h]',queue='$queue[$h]',agent='NONE',verb='ABANDON',data1='1',data2='$queue_position',data3='$queue_seconds',serverid='$serverid[$h]';"; if ($TEST < 1) { $Baffected_rows = $dbhB->do($stmtB); @@ -505,6 +535,7 @@ if ( ($enable_queuemetrics_logging > 0) && ($login_lagged_check > 0) ) @agent=@MT; @verb=@MT; @serverid=@MT; + @lead_id=@MT; if ($DB) {print " - Checking for LOGIN and LAGGED pausereason records in queue_log\n";} @@ -783,6 +814,8 @@ if ($enable_queuemetrics_logging > 0) $Sagent[$h] = "$aryB[3]"; $Sverb[$h] = "$aryB[4]"; $Sserverid[$h] = "$aryB[5]"; + $Slead_id[$h] = substr($Scall_id[$h], 11, 9); + $Slead_id[$h] = ($Slead_id[$h] + 0); } $sthB->finish(); @@ -825,9 +858,36 @@ if ($enable_queuemetrics_logging > 0) } else { + $secX = time(); + $Rtarget = ($secX - 21600); # look for VDCL entry within last 6 hours + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + $RSQLdate = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; + + ### find original queue position of the call + $queue_position=1; + $queue_seconds=0; + $stmtA = "SELECT queue_position,queue_seconds FROM vicidial_closer_log where lead_id='$Slead_id[$h]' and campaign_id='$Squeue[$h]' and call_date > \"$RSQLdate\" order by closecallid desc limit 1;"; + $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; + $queue_position = $aryA[0]; + $queue_seconds = floor($aryA[1] + .5); + } + $sthA->finish(); + ##### insert a COMPLETEAGENT record for this call into the queue_log $CALLtime[$h] = ($Stime_id[$h] - $time_id[$h]); - $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$Stime_id[$h]',call_id='$Scall_id[$h]',queue='$Squeue[$h]',agent='$Sagent[$h]',verb='COMPLETEAGENT',data1='$Cdata1[$h]',data2='$CALLtime[$h]',data3='1',serverid='$Sserverid[$h]';"; + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$Stime_id[$h]',call_id='$Scall_id[$h]',queue='$Squeue[$h]',agent='$Sagent[$h]',verb='COMPLETEAGENT',data1='$Cdata1[$h]',data2='$CALLtime[$h]',data3='$queue_position',serverid='$Sserverid[$h]';"; if ($TEST < 1) { $Baffected_rows = $dbhB->do($stmtB); @@ -909,9 +969,39 @@ if ($enable_queuemetrics_logging > 0) $VALstatus =~ s/ //gi; if ( ($VALstatus =~ /NULL/i) || (length($VALstatus<1)) ) {$VALstatus='ERI';} + $Clead_id[$h] = substr($Ccall_id[$h], 11, 9); + $Clead_id[$h] = ($Clead_id[$h] + 0); + + $secX = time(); + $Rtarget = ($secX - 21600); # look for VDCL entry within last 6 hours + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + $RSQLdate = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; + + ### find original queue position of the call + $queue_position=1; + $queue_seconds=0; + $stmtA = "SELECT queue_position,queue_seconds FROM vicidial_closer_log where lead_id='$Clead_id[$h]' and campaign_id='$Cqueue[$h]' and call_date > \"$RSQLdate\" order by closecallid desc limit 1;"; + $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; + $queue_position = $aryA[0]; + $queue_seconds = floor($aryA[1] + .5); + } + $sthA->finish(); + ##### insert a COMPLETEAGENT record for this call into the queue_log $CALLtime[$h] = ($Stime_id[$h] - $time_id[$h]); - $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$Stime_id[$h]',call_id='$Ccall_id[$h]',queue='$Cqueue[$h]',agent='$Cagent[$h]',verb='COMPLETEAGENT',data1='$Cdata1[$h]',data2='$CALLtime[$h]',data3='1',serverid='$Cserverid[$h]';"; + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$Stime_id[$h]',call_id='$Ccall_id[$h]',queue='$Cqueue[$h]',agent='$Cagent[$h]',verb='COMPLETEAGENT',data1='$Cdata1[$h]',data2='$CALLtime[$h]',data3='$queue_position',serverid='$Cserverid[$h]';"; if ($TEST < 1) { $Baffected_rows = $dbhB->do($stmtB) or die "ERROR: $stmtB" . DBI->errstr; diff --git a/bin/FastAGI_log.pl b/bin/FastAGI_log.pl index fd33c4d4..7fa40ae9 100644 --- a/bin/FastAGI_log.pl +++ b/bin/FastAGI_log.pl @@ -51,6 +51,7 @@ # 90815-0750 - Fixed extra vicidial_log logging # 91020-0055 - Fixed several bugs with auto-alt-dial, DNC and extended alt number dialing # 91026-1148 - Added AREACODE DNC option +# 91213-1213 - Added queue_position to queue_log COMPLETE... and ABANDON records # # defaults for PreFork @@ -749,7 +750,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 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 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; @@ -758,17 +759,18 @@ sub process_request if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $VD_lead_id = $aryA[0]; - $VD_callerid = $aryA[1]; - $VD_campaign_id = $aryA[2]; - $VD_alt_dial = $aryA[3]; - $VD_stage = $aryA[4]; - $VD_start_epoch = $aryA[5]; - $VD_uniqueid = $aryA[6]; - $VD_status = $aryA[7]; - $VD_call_time = $aryA[8]; - $VD_phone_code = $aryA[9]; - $VD_phone_number = $aryA[10]; + $VD_lead_id = $aryA[0]; + $VD_callerid = $aryA[1]; + $VD_campaign_id = $aryA[2]; + $VD_alt_dial = $aryA[3]; + $VD_stage = $aryA[4]; + $VD_start_epoch = $aryA[5]; + $VD_uniqueid = $aryA[6]; + $VD_status = $aryA[7]; + $VD_call_time = $aryA[8]; + $VD_phone_code = $aryA[9]; + $VD_phone_number = $aryA[10]; + $VD_queue_position = $aryA[11]; $rec_countCUSTDATA++; } $sthA->finish(); @@ -789,17 +791,15 @@ sub process_request $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) + if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $enable_queuemetrics_logging = "$aryA[0]"; - $queuemetrics_server_ip = "$aryA[1]"; - $queuemetrics_dbname = "$aryA[2]"; - $queuemetrics_login= "$aryA[3]"; - $queuemetrics_pass = "$aryA[4]"; - $queuemetrics_log_id = "$aryA[5]"; - $rec_count++; + $enable_queuemetrics_logging = $aryA[0]; + $queuemetrics_server_ip = $aryA[1]; + $queuemetrics_dbname = $aryA[2]; + $queuemetrics_login= $aryA[3]; + $queuemetrics_pass = $aryA[4]; + $queuemetrics_log_id = $aryA[5]; } $sthA->finish(); ##### END QUEUEMETRICS LOGGING LOOKUP ##### @@ -830,14 +830,52 @@ sub process_request } $sthB->finish(); + $secX = time(); + $Rtarget = ($secX - 21600); # look for VDCL entry within last 6 hours + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + $RSQLdate = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; + + ### find original queue position of the call + $queue_position=1; + $stmtA = "SELECT queue_position FROM vicidial_closer_log where uniqueid='$unique_id' and lead_id='$CIDlead_id' and campaign_id='$VD_campaign_id' and call_date > \"$RSQLdate\" order by closecallid desc limit 1;"; + $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; + $queue_position = $aryA[0]; + } + $sthA->finish(); + if ($rec_count < 1) { - $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$VD_callerid',queue='$VD_campaign_id',agent='$VD_agent',verb='ABANDON',data1='1',data2='1',data3='$VD_stage',serverid='$queuemetrics_log_id';"; + ### find current number of calls in this queue to find position when channel hung up + $current_position=1; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and campaign_id='$VD_campaign_id';"; + $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; + $current_position = ($aryA[0] + 1); + } + $sthA->finish(); + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$VD_callerid',queue='$VD_campaign_id',agent='$VD_agent',verb='ABANDON',data1='$current_position',data2='$queue_position',data3='$VD_stage',serverid='$queuemetrics_log_id';"; $Baffected_rows = $dbhB->do($stmtB); } else { - $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$VD_callerid',queue='$VD_campaign_id',agent='$VD_agent',verb='COMPLETECALLER',data1='$VD_stage',data2='$VD_call_length',data3='1',serverid='$queuemetrics_log_id';"; + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$VD_callerid',queue='$VD_campaign_id',agent='$VD_agent',verb='COMPLETECALLER',data1='$VD_stage',data2='$VD_call_length',data3='$queue_position',serverid='$queuemetrics_log_id';"; $Baffected_rows = $dbhB->do($stmtB); } diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index 9a18a762..608fbe40 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -385,6 +385,7 @@ alt_dial VARCHAR(6) default 'NONE', queue_priority TINYINT(2) default '0', agent_only VARCHAR(20) default '', agent_grab VARCHAR(20) default '', +queue_position SMALLINT(4) UNSIGNED default '1', index (uniqueid), index (callerid), index (call_time), @@ -434,6 +435,7 @@ xfercallid INT(9) UNSIGNED, term_reason ENUM('CALLER','AGENT','QUEUETIMEOUT','ABANDON','AFTERHOURS','HOLDRECALLXFER','HOLDTIME','NOAGENT','NONE') default 'NONE', uniqueid VARCHAR(20) NOT NULL default '', agent_only VARCHAR(20) default '', +queue_position SMALLINT(4) UNSIGNED default '1', index (lead_id), index (call_date), index (campaign_id), @@ -1988,7 +1990,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='1187',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1188',db_schema_update_date=NOW(); GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/extras/upgrade_2.2.0.sql b/extras/upgrade_2.2.0.sql index 98839aae..ee3809a3 100644 --- a/extras/upgrade_2.2.0.sql +++ b/extras/upgrade_2.2.0.sql @@ -666,3 +666,9 @@ ALTER TABLE vicidial_campaigns ADD crm_popup_login ENUM('Y','N') default 'N'; ALTER TABLE vicidial_campaigns ADD crm_login_address TEXT; UPDATE system_settings SET db_schema_version='1187',db_schema_update_date=NOW(); + +ALTER TABLE vicidial_closer_log ADD queue_position SMALLINT(4) UNSIGNED default '1'; + +ALTER TABLE vicidial_auto_calls ADD queue_position SMALLINT(4) UNSIGNED default '1'; + +UPDATE system_settings SET db_schema_version='1188',db_schema_update_date=NOW(); diff --git a/www/agc/manager_send.php b/www/agc/manager_send.php index 3b354e94..40cf2dbd 100644 --- a/www/agc/manager_send.php +++ b/www/agc/manager_send.php @@ -93,10 +93,11 @@ # 90924-1555 - Added am_message_exten_override for list_id option # 91112-1110 - Added CALLOUTBOUND value to QM entry lookup # 91205-2103 - Code cleanup +# 91213-1208 - Added queue_position to queue_log COMPLETE... records # -$version = '2.2.0-45'; -$build = '91205-2103'; +$version = '2.2.0-46'; +$build = '91213-1208'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=85; $one_mysql_log=0; @@ -607,24 +608,26 @@ if ($ACTION=="Hangup") if ($format=='debug') {echo "\n";} if ($caller_connect > 0) { + $CLqueue_position='1'; ### grab call lead information needed for QM logging - $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where callerid='$CalLCID' order by call_time limit 1;"; + $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid,queue_position from vicidial_auto_calls where callerid='$CalLCID' order by call_time limit 1;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02016',$user,$server_ip,$session_name,$one_mysql_log);} $VAC_qm_ct = mysql_num_rows($rslt); if ($VAC_qm_ct > 0) { $row=mysql_fetch_row($rslt); - $auto_call_id = $row[0]; - $CLlead_id = $row[1]; - $CLphone_number = $row[2]; - $CLstatus = $row[3]; - $CLcampaign_id = $row[4]; - $CLphone_code = $row[5]; - $CLalt_dial = $row[6]; - $CLstage = $row[7]; - $CLcallerid = $row[8]; - $CLuniqueid = $row[9]; + $auto_call_id = $row[0]; + $CLlead_id = $row[1]; + $CLphone_number = $row[2]; + $CLstatus = $row[3]; + $CLcampaign_id = $row[4]; + $CLphone_code = $row[5]; + $CLalt_dial = $row[6]; + $CLstage = $row[7]; + $CLcallerid = $row[8]; + $CLuniqueid = $row[9]; + $CLqueue_position = $row[10]; } if ($format=='debug') {echo "\n";} @@ -659,7 +662,7 @@ if ($ACTION=="Hangup") {$secondS = ($StarTtime - $time_id);} if ($format=='debug') {echo "\n";} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$secondS',data3='1',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$secondS',data3='$CLqueue_position',serverid='$queuemetrics_log_id';"; $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02019',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index a206da63..9d3fac86 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -223,12 +223,13 @@ # 91112-1107 - Changed ENTERQUEUE to CALLOUTBOUND for QM logging # 91123-1801 - Added outbound_autodial field # 91204-1937 - Added logging of agent grab calls +# 91213-0946 - Added queue_position to queue_log COMPLETE... records # -$version = '2.2.0-132'; -$build = '91204-1937'; +$version = '2.2.0-133'; +$build = '91213-0946'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=272; +$mysql_log_count=273; $one_mysql_log=0; require("dbconnect.php"); @@ -2864,8 +2865,9 @@ if ($stage == "end") { if ($enable_queuemetrics_logging > 0) { + $CLqueue_position=1; ### check to see if lead should be alt_dialed - $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where lead_id='$lead_id' order by call_time desc limit 1;"; + $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid,queue_position from vicidial_auto_calls where lead_id='$lead_id' order by call_time desc limit 1;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00084',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -2873,22 +2875,23 @@ if ($stage == "end") if ($VAC_qm_ct > 0) { $row=mysql_fetch_row($rslt); - $auto_call_id = $row[0]; - $CLlead_id = $row[1]; - $CLphone_number = $row[2]; - $CLstatus = $row[3]; - $CLcampaign_id = $row[4]; - $CLphone_code = $row[5]; - $CLalt_dial = $row[6]; - $CLstage = $row[7]; - $CLcallerid = $row[8]; - $CLuniqueid = $row[9]; + $auto_call_id = $row[0]; + $CLlead_id = $row[1]; + $CLphone_number = $row[2]; + $CLstatus = $row[3]; + $CLcampaign_id = $row[4]; + $CLphone_code = $row[5]; + $CLalt_dial = $row[6]; + $CLstage = $row[7]; + $CLcallerid = $row[8]; + $CLuniqueid = $row[9]; + $CLqueue_position = $row[10]; } $CLstage = preg_replace("/XFER|CLOSER|-/",'',$CLstage); if ($CLstage < 0.25) {$CLstage=0;} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$CLqueue_position',serverid='$queuemetrics_log_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00085',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3025,16 +3028,17 @@ if ($stage == "end") if ( (ereg("NONE",$term_reason)) or (ereg("NONE",$VDterm_reason)) or (strlen($VDterm_reason) < 1) ) { - ### check to see if lead should be alt_dialed - $stmt="SELECT term_reason,closecallid from vicidial_closer_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + ### find out who hung up the call + $stmt="SELECT term_reason,closecallid,queue_position from vicidial_closer_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00091',$user,$server_ip,$session_name,$one_mysql_log);} $VAC_qm_ct = mysql_num_rows($rslt); if ($VAC_qm_ct > 0) { $row=mysql_fetch_row($rslt); - $VDterm_reason = $row[0]; - $VDvicidial_id = $row[1]; + $VDterm_reason = $row[0]; + $VDvicidial_id = $row[1]; + $VDqueue_position = $row[2]; $VDIDselect = "VDCL_LID4HOUR $lead_id $four_hours_ago"; } if (ereg("CALLER",$VDterm_reason)) @@ -3074,7 +3078,23 @@ if ($stage == "end") } if ($agent_complete < 1) { - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',serverid='$queuemetrics_log_id';"; + if (strlen($VDqueue_position) < 1) + { + ### find out who hung up the call + $stmt="SELECT queue_position from vicidial_closer_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00273',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDqueue_position = $row[0]; + } + } + if (strlen($VDqueue_position) < 1) + {$VDqueue_position=1;} + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='$VDqueue_position',serverid='$queuemetrics_log_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00094',$user,$server_ip,$session_name,$one_mysql_log);} diff --git a/www/vicidial/AST_CLOSERstats.php b/www/vicidial/AST_CLOSERstats.php index 5056ba70..b16ffe3e 100644 --- a/www/vicidial/AST_CLOSERstats.php +++ b/www/vicidial/AST_CLOSERstats.php @@ -23,6 +23,7 @@ # 90508-0644 - Changed to PHP long tags # 90524-2231 - Changed to use functions.php for seconds to HH:MM:SS conversion # 90801-0921 - Added in-group name to pulldown +# 91214-0955 - Added INITIAL QUEUE POSITION BREAKDOWN # require("dbconnect.php"); @@ -1049,6 +1050,67 @@ echo "| TOTAL | $TOTCATcalls |\n"; echo "+----------------------+------------+\n"; +############################## +######### CALL INITIAL QUEUE POSITION BREAKDOWN + +$TOTALcalls = 0; + +echo "\n"; +echo "---------- CALL INITIAL QUEUE POSITION BREAKDOWN\n"; +echo "+-------------------------------------------------------------------------------------+------------+\n"; +echo "| 1 2 3 4 5 6 7 8 9 10 15 20 25 +25 | TOTAL |\n"; +echo "+-------------------------------------------------------------------------------------+------------+\n"; + +$stmt="select count(*),queue_position from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) group by queue_position;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$positions_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $positions_to_print) + { + $row=mysql_fetch_row($rslt); + + $TOTALcalls = ($TOTALcalls + $row[0]); + + if ( ($row[1] > 0) and ($row[1] <= 1) ) {$qp_1 = ($qp_1 + $row[0]);} + if ( ($row[1] > 1) and ($row[1] <= 2) ) {$qp_2 = ($qp_2 + $row[0]);} + if ( ($row[1] > 2) and ($row[1] <= 3) ) {$qp_3 = ($qp_3 + $row[0]);} + if ( ($row[1] > 3) and ($row[1] <= 4) ) {$qp_4 = ($qp_4 + $row[0]);} + if ( ($row[1] > 4) and ($row[1] <= 5) ) {$qp_5 = ($qp_5 + $row[0]);} + if ( ($row[1] > 5) and ($row[1] <= 6) ) {$qp_6 = ($qp_6 + $row[0]);} + if ( ($row[1] > 6) and ($row[1] <= 7) ) {$qp_7 = ($qp_7 + $row[0]);} + if ( ($row[1] > 7) and ($row[1] <= 8) ) {$qp_8 = ($qp_8 + $row[0]);} + if ( ($row[1] > 8) and ($row[1] <= 9) ) {$qp_9 = ($qp_9 + $row[0]);} + if ( ($row[1] > 9) and ($row[1] <= 10) ) {$qp10 = ($qp10 + $row[0]);} + if ( ($row[1] > 10) and ($row[1] <= 15) ) {$qp15 = ($qp15 + $row[0]);} + if ( ($row[1] > 15) and ($row[1] <= 20) ) {$qp20 = ($qp20 + $row[0]);} + if ( ($row[1] > 20) and ($row[1] <= 25) ) {$qp25 = ($qp25 + $row[0]);} + if ($row[1] > 25) {$qp99 = ($qp99 + $row[0]);} + $i++; + } + +$qp_1 = sprintf("%5s", $qp_1); +$qp_2 = sprintf("%5s", $qp_2); +$qp_3= sprintf("%5s", $qp_3); +$qp_4 = sprintf("%5s", $qp_4); +$qp_5 = sprintf("%5s", $qp_5); +$qp_6 = sprintf("%5s", $qp_6); +$qp_7 = sprintf("%5s", $qp_7); +$qp_8 = sprintf("%5s", $qp_8); +$qp_9 = sprintf("%5s", $qp_9); +$qp10 = sprintf("%5s", $qp10); +$qp15 = sprintf("%5s", $qp15); +$qp20 = sprintf("%5s", $qp20); +$qp25 = sprintf("%5s", $qp25); +$qp99 = sprintf("%5s", $qp99); + +$TOTALcalls = sprintf("%10s", $TOTALcalls); + +echo "| $qp_1 $qp_2 $qp_3 $qp_4 $qp_5 $qp_6 $qp_7 $qp_8 $qp_9 $qp10 $qp15 $qp20 $qp25 $qp99 | $TOTALcalls |\n"; +echo "+-------------------------------------------------------------------------------------+------------+\n"; + + + ############################## ######### USER STATS