From 2939cf408ee78d9f87d036aa7daa03f66bfa0f52 Mon Sep 17 00:00:00 2001 From: mattf Date: Sat, 12 Mar 2022 20:46:51 +0000 Subject: [PATCH] Added List CID Group Override to the List Modification admin screen. Added new vicidial_dial_cid_log database call logging git-svn-id: svn://192.168.202.10@3589 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/UPGRADE | 2 + agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl | 129 ++++++++++++ agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl | 32 ++- agc_2-X/trunk/bin/AST_VDauto_dial.pl | 82 +++++++- agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl | 92 ++++++++- .../trunk/extras/MySQL_AST_CREATE_tables.sql | 19 +- agc_2-X/trunk/extras/upgrade_2.14.sql | 18 ++ agc_2-X/trunk/www/agc/manager_send.php | 11 +- agc_2-X/trunk/www/agc/vdc_db_query.php | 184 +++++++++++++++++- agc_2-X/trunk/www/vicidial/admin.php | 75 ++++++- .../trunk/www/vicidial/admin_modify_lead.php | 57 ++++-- .../trunk/www/vicidial/help_documentation.txt | 13 +- agc_2-X/trunk/www/vicidial/non_agent_api.php | 10 +- agc_2-X/trunk/www/vicidial/send_CID_call.php | 6 + 14 files changed, 673 insertions(+), 57 deletions(-) diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index b7b313e0..52199973 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -714,6 +714,8 @@ OTHER CHANGES: variable on the web screens for troubleshooting issues. It is disabled by default. +200. Added List CID Group Override to the List Modification admin screen. + diff --git a/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl b/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl index 5f1fef70..ec71a88e 100644 --- a/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl +++ b/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl @@ -64,6 +64,7 @@ # 210819-0826 - Added vicidial_inbound_caller_codes archiving # 210912-1546 - Added --api-log-days=X and --api-only flags # 220309-2246 - Added --api-archive-days=X and --api-archive-only flags +# 220312-0859 - Added vicidial_dial_cid_log table archiving, same as vicidial_dial_log # $CALC_TEST=0; @@ -672,6 +673,35 @@ if (!$T) } ##### END vicidial_dial_log_archive trim processing ##### + ##### BEGIN vicidial_dial_cid_log_archive trim processing ##### + $stmtA = "SELECT count(*) from vicidial_dial_cid_log_archive;"; + $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; + $vicidial_dial_cid_log_archive_count = $aryA[0]; + } + $sthA->finish(); + + if (!$Q) {print "Trimming vicidial_dial_cid_log_archive table... ($vicidial_dial_cid_log_archive_count)\n";} + + $rv = $sthA->err(); + if (!$rv) + { + $stmtA = "DELETE FROM vicidial_dial_cid_log_archive WHERE call_date < '$del_time';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows = $sthA->rows; + if (!$Q) {print "$sthArows rows deleted from vicidial_dial_cid_log_archive table \n";} + + $stmtA = "optimize table vicidial_dial_cid_log_archive;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + } + ##### END vicidial_dial_cid_log_archive trim processing ##### + if ($only_trim_archive > 1) { @@ -1223,6 +1253,53 @@ if (!$T) ##### END vicidial_dial_log DAILY processing ##### + ##### BEGIN vicidial_dial_cid_log DAILY processing ##### + $stmtA = "SELECT count(*) from vicidial_dial_cid_log;"; + $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; + $vicidial_dial_cid_log_count = $aryA[0]; + } + $sthA->finish(); + + $stmtA = "SELECT count(*) from vicidial_dial_cid_log_archive;"; + $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; + $vicidial_dial_cid_log_archive_count = $aryA[0]; + } + $sthA->finish(); + + if (!$Q) {print "\nProcessing vicidial_dial_cid_log table... ($vicidial_dial_cid_log_count|$vicidial_dial_cid_log_archive_count)\n";} + $stmtA = "INSERT IGNORE INTO vicidial_dial_cid_log_archive SELECT * from vicidial_dial_cid_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + + $sthArows = $sthA->rows; + if (!$Q) {print "$sthArows rows inserted into vicidial_dial_cid_log_archive table \n";} + + $rv = $sthA->err(); + if (!$rv) + { + $stmtA = "DELETE FROM vicidial_dial_cid_log WHERE call_date < '$del_time';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows = $sthA->rows; + if (!$Q) {print "$sthArows rows deleted from vicidial_dial_cid_log table \n";} + + $stmtA = "optimize table vicidial_dial_cid_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + } + ##### END vicidial_dial_cid_log DAILY processing ##### + + ##### BEGIN vicidial_api_log DAILY processing ##### $stmtA = "SELECT count(*) from vicidial_api_log;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -2225,6 +2302,58 @@ if (!$T) } + ##### vicidial_dial_cid_log + $stmtA = "SELECT count(*) from vicidial_dial_cid_log;"; + $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; + $vicidial_dial_cid_log_count = $aryA[0]; + } + $sthA->finish(); + + $stmtA = "SELECT count(*) from vicidial_dial_cid_log_archive;"; + $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; + $vicidial_dial_cid_log_archive_count = $aryA[0]; + } + $sthA->finish(); + + if (!$Q) {print "\nProcessing vicidial_dial_cid_log table... ($vicidial_dial_cid_log_count|$vicidial_dial_cid_log_archive_count)\n";} + $stmtA = "INSERT IGNORE INTO vicidial_dial_cid_log_archive SELECT * from vicidial_dial_cid_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + + $sthArows = $sthA->rows; + if (!$Q) {print "$sthArows rows inserted into vicidial_dial_cid_log_archive table \n";} + + $rv = $sthA->err(); + if (!$rv) + { + if ($wipe_all > 0) + {$stmtA = "DELETE FROM vicidial_dial_cid_log;";} + else + {$stmtA = "DELETE FROM vicidial_dial_cid_log WHERE call_date < '$del_time';";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows = $sthA->rows; + if (!$Q) {print "$sthArows rows deleted from vicidial_dial_cid_log table \n";} + + $stmtA = "optimize table vicidial_dial_cid_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + + $stmtA = "optimize table vicidial_dial_cid_log_archive;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + } + ##### vicidial_api_log $stmtA = "SELECT count(*) from vicidial_api_log;"; diff --git a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl index 7090768f..65422221 100644 --- a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl +++ b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl @@ -15,7 +15,7 @@ # - Auto reset lists at defined times # - Auto restarts Asterisk process if enabled in servers settings # -# Copyright (C) 2021 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2022 Matt Florell LICENSE: AGPLv2 # # CHANGES # 61011-1348 - First build @@ -154,9 +154,10 @@ # 210827-0939 - Added PJSIP compatibility # 210924-2333 - Fix for calls_today issue at timeclock-end-of-day # 220310-0959 - Added purging of vicidial_sync_log table +# 220312-0819 - Added CID Group Auto-Rotate to check for List use # -$build = '220310-0959'; +$build = '220312-0819'; $DB=0; # Debug flag $teodDB=0; # flag to log Timeclock End of Day processes to log file @@ -5009,6 +5010,13 @@ if ( ($active_voicemail_server =~ /$server_ip/) && ((length($active_voicemail_se $i=0; while ($sthArows > $i) { + $Rcampaign_calldate=''; + $Rcampaign_id=''; + $Rcampaign_calldate_epoch=0; + $Lcampaign_calldate=''; + $Llist_id=''; + $Lcampaign_calldate_epoch=0; + $stmtA = "SELECT campaign_calldate,campaign_id,UNIX_TIMESTAMP(campaign_calldate) from vicidial_campaigns where cid_group_id='$cid_group_id[$i]' order by campaign_calldate desc limit 1;"; if ($DBX) {print "$stmtA\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -5023,13 +5031,27 @@ if ( ($active_voicemail_server =~ /$server_ip/) && ((length($active_voicemail_se } $sthA->finish(); - if ( ($Rcampaign_calldate_epoch < $FMtarget) && (length($cid_auto_rotate_cid[$i]) >= 6 ) ) + $stmtA = "SELECT list_lastcalldate,list_id,UNIX_TIMESTAMP(list_lastcalldate) from vicidial_lists where cid_group_id='$cid_group_id[$i]' order by list_lastcalldate desc limit 1;"; + if ($DBX) {print "$stmtA\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArowsX=$sthA->rows; + if ($sthArowsX > 0) { - if ($DB) {print " skip CID Group rotate, no recent campaign calls: $cid_group_id[$i]|$Rcampaign_id|$Rcampaign_calldate| ($Rcampaign_calldate_epoch <> $FMtarget)\n";} + @aryA = $sthA->fetchrow_array; + $Lcampaign_calldate = $aryA[0]; + $Llist_id = $aryA[1]; + $Lcampaign_calldate_epoch = $aryA[2]; + } + $sthA->finish(); + + if ( ( ($Rcampaign_calldate_epoch < $FMtarget) && ($Lcampaign_calldate_epoch < $FMtarget) ) && (length($cid_auto_rotate_cid[$i]) >= 6 ) ) + { + if ($DB) {print " skip CID Group rotate, no recent campaign/list calls: $cid_group_id[$i]|$Rcampaign_id|$Rcampaign_calldate| ($Rcampaign_calldate_epoch <> $FMtarget)|$Llist_id|$Lcampaign_calldate|($Lcampaign_calldate_epoch < $FMtarget)\n";} } else { - if ($DBX) {print " DEBUG: CID Group rotate, recent campaign calls: $cid_group_id[$i]|$Rcampaign_id|$Rcampaign_calldate| ($Rcampaign_calldate_epoch <> $FMtarget)\n";} + if ($DBX) {print " DEBUG: CID Group rotate, recent campaign/list calls: $cid_group_id[$i]|$Rcampaign_id|$Rcampaign_calldate| ($Rcampaign_calldate_epoch <> $FMtarget)|$Llist_id|$Lcampaign_calldate|($Lcampaign_calldate_epoch < $FMtarget)\n";} $rotate_run_minutes = (($secX - $cid_last_auto_rotate_epoch[$i]) / 60); if ($rotate_run_minutes < $cid_auto_rotate_minutes[$i]) { diff --git a/agc_2-X/trunk/bin/AST_VDauto_dial.pl b/agc_2-X/trunk/bin/AST_VDauto_dial.pl index 06cad5f2..bf284c31 100644 --- a/agc_2-X/trunk/bin/AST_VDauto_dial.pl +++ b/agc_2-X/trunk/bin/AST_VDauto_dial.pl @@ -148,9 +148,10 @@ # 211022-1637 - Added incall_tally_threshold_seconds campaign feature # 220118-0938 - Added $ADB auto-alt-dial extra debug output option, fix for extended auto-alt-dial issue #1337 # 220118-2206 - Added auto_alt_threshold campaign & list settings +# 220311-1920 - Added List CID Group Override option # -$build='220118-2206'; +$build='220311-1920'; $script='AST_VDauto_dial'; ### begin parsing run-time options ### if (length($ARGV[0])>1) @@ -1819,9 +1820,10 @@ while($one_day_interval > 0) if ($rec_countCUSTDATA) { $campaign_cid_override=''; + $LIST_cid_group_override=''; $auto_alt_threshold=-1; ### gather list_id overrides - $stmtA = "SELECT campaign_cid_override,auto_alt_threshold FROM vicidial_lists where list_id='$list_id';"; + $stmtA = "SELECT campaign_cid_override,auto_alt_threshold,cid_group_id FROM vicidial_lists where list_id='$list_id';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArowsL=$sthA->rows; @@ -1830,6 +1832,7 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $campaign_cid_override = $aryA[0]; $auto_alt_threshold = $aryA[1]; + $LIST_cid_group_override = $aryA[2]; } $sthA->finish(); @@ -2068,7 +2071,74 @@ while($one_day_interval > 0) $VDAD_dial_exten = $routing_prefix . $VDAD_dial_exten; } - if (length($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++; $CCIDtype='LIST_CID';} + $temp_CID=''; + if ( (length($LIST_cid_group_override) > 0) && ($LIST_cid_group_override !~ /\-\-\-DISABLED\-\-\-/) ) + { + $stmtA = "SELECT cid_group_type FROM vicidial_cid_groups where cid_group_id='$LIST_cid_group_override';"; + $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; + $cid_group_type = $aryA[0]; + $temp_CID=''; + $temp_vcca=''; + $temp_ac=''; + + if ($cid_group_type =~ /AREACODE/) + { + $temp_ac_two = substr("$phone_number", 0, 2); + $temp_ac_three = substr("$phone_number", 0, 3); + $temp_ac_four = substr("$phone_number", 0, 4); + $temp_ac_five = substr("$phone_number", 0, 5); + $stmtA = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and areacode IN('$temp_ac_two','$temp_ac_three','$temp_ac_four','$temp_ac_five') and active='Y' order by CAST(areacode as SIGNED INTEGER) asc, call_count_today desc limit 100000;"; + } + if ($cid_group_type =~ /STATE/) + { + $temp_state = $state; + $stmtA = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and areacode IN('$temp_state') and active='Y' order by call_count_today desc limit 100000;"; + } + if ($cid_group_type =~ /NONE/) + { + $stmtA = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and active='Y' order by call_count_today desc limit 100000;"; + } + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $act=0; + while ($sthArows > $act) + { + @aryA = $sthA->fetchrow_array; + $temp_vcca = $aryA[0]; + $temp_ac = $aryA[1]; + $act++; + } + if ($act > 0) + { + $sthA->finish(); + $stmtA="UPDATE vicidial_campaign_cid_areacodes set call_count_today=(call_count_today + 1) where campaign_id='$LIST_cid_group_override' and areacode='$temp_ac' and outbound_cid='$temp_vcca';"; + $affected_rows = $dbhA->do($stmtA); + + if ($cid_group_type =~ /NONE/) + { + $stmtA="UPDATE vicidial_cid_groups set cid_auto_rotate_calls=(cid_auto_rotate_calls + 1) where cid_group_id='$LIST_cid_group_override';"; + $affected_rows = $dbhA->do($stmtA); + } + } + else + {$sthA->finish();} + $temp_CID = $temp_vcca; + $temp_CID =~ s/\D//gi; + } + } + if ( (length($campaign_cid_override) > 6) || (length($temp_CID) > 6) ) + { + if (length($temp_CID) > 6) + {$CCID = "$temp_CID"; $CCID_on++; $CCIDtype='LIST_CID_GROUP';} + else + {$CCID = "$campaign_cid_override"; $CCID_on++; $CCIDtype='LIST_CID';} + } else { if (length($DBIPcampaigncid[$user_CIPct]) > 6) {$CCID = "$DBIPcampaigncid[$user_CIPct]"; $CCID_on++; $CCIDtype='CAMPAIGN_CID';} @@ -2298,7 +2368,11 @@ while($one_day_interval > 0) $stmtD = "INSERT INTO vicidial_lead_24hour_calls SET lead_id='$lead_id',list_id='$list_id',call_date=NOW(),phone_number='$phone_number',phone_code='$phone_code',state='$TFhourSTATE',call_type='AUTO';"; $affected_rowsD = $dbhA->do($stmtD); - $event_string = "| number call dialed|$DBIPcampaign[$user_CIPct]|$VqueryCID|$affected_rowsA|$stmtA|$gmt_offset_now|$alt_dial|$affected_rowsB|$affected_rowsC|$affected_rowsD|$CCIDtype|"; + ### insert log record into vicidial_dial_cid_log table + $stmtE = "INSERT INTO vicidial_dial_cid_log SET caller_code='$VqueryCID',call_date=NOW(),call_type='OUT',call_alt='$alt_dial',outbound_cid='$CCID',outbound_cid_type='$CCIDtype';"; + $affected_rowsE = $dbhA->do($stmtE); + + $event_string = "| number call dialed|$DBIPcampaign[$user_CIPct]|$VqueryCID|$affected_rowsA|$stmtA|$gmt_offset_now|$alt_dial|$affected_rowsB|$affected_rowsC|$affected_rowsD|$affected_rowsE|$CCIDtype|"; &event_logger; ### sleep for a five hundredths of a second to not flood the server with new calls diff --git a/agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl b/agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl index e4387ba8..4262435a 100644 --- a/agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl +++ b/agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl @@ -12,7 +12,7 @@ # # Should only be run on one server in a multi-server Asterisk/VICIDIAL cluster # -# Copyright (C) 2021 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2022 Matt Florell LICENSE: AGPLv2 # # CHANGELOG: # 61115-1246 - First build, framework setup, non-functional @@ -50,6 +50,7 @@ # 201220-1034 - Changes for shared agent campaigns # 210715-1335 - Added call_limit_24hour feature support, also fix for variable issue # 210731-0951 - Added cid_group_id_two campaign option +# 220311-1922 - Added List CID Group Override option # ### begin parsing run-time options ### @@ -836,8 +837,9 @@ while($one_day_interval > 0) ### END check for Dial Timeout Lead override for this lead ### $campaign_cid_override=''; + $LIST_cid_group_override=''; ### gather list_id overrides - $stmtA = "SELECT campaign_cid_override FROM vicidial_lists where list_id='$list_id';"; + $stmtA = "SELECT campaign_cid_override,cid_group_id FROM vicidial_lists where list_id='$list_id';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArowsL=$sthA->rows; @@ -845,6 +847,7 @@ while($one_day_interval > 0) { @aryA = $sthA->fetchrow_array; $campaign_cid_override = $aryA[0]; + $LIST_cid_group_override = $aryA[1]; } $sthA->finish(); @@ -975,8 +978,77 @@ while($one_day_interval > 0) if (length($DBIPvdadexten[$camp_CIPct]) > 0) {$VDAD_dial_exten = "$DBIPvdadexten[$camp_CIPct]";} else {$VDAD_dial_exten = "$answer_transfer_agent";} - if (length($DBIPcampaigncid[$camp_CIPct]) > 6) {$CCID = "$DBIPcampaigncid[$camp_CIPct]"; $CCID_on++; $CCIDtype='CAMPAIGN_CID';} - if (length($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++; $CCIDtype='LIST_CID';} + if (length($DBIPcampaigncid[$camp_CIPct]) > 6) + {$CCID = "$DBIPcampaigncid[$camp_CIPct]"; $CCID_on++; $CCIDtype='CAMPAIGN_CID';} + + $temp_CID=''; + if ( (length($LIST_cid_group_override) > 0) && ($LIST_cid_group_override !~ /\-\-\-DISABLED\-\-\-/) ) + { + $stmtA = "SELECT cid_group_type FROM vicidial_cid_groups where cid_group_id='$LIST_cid_group_override';"; + $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; + $cid_group_type = $aryA[0]; + $temp_CID=''; + $temp_vcca=''; + $temp_ac=''; + + if ($cid_group_type =~ /AREACODE/) + { + $temp_ac_two = substr("$phone_number", 0, 2); + $temp_ac_three = substr("$phone_number", 0, 3); + $temp_ac_four = substr("$phone_number", 0, 4); + $temp_ac_five = substr("$phone_number", 0, 5); + $stmtA = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and areacode IN('$temp_ac_two','$temp_ac_three','$temp_ac_four','$temp_ac_five') and active='Y' order by CAST(areacode as SIGNED INTEGER) asc, call_count_today desc limit 100000;"; + } + if ($cid_group_type =~ /STATE/) + { + $temp_state = $state; + $stmtA = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and areacode IN('$temp_state') and active='Y' order by call_count_today desc limit 100000;"; + } + if ($cid_group_type =~ /NONE/) + { + $stmtA = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and active='Y' order by call_count_today desc limit 100000;"; + } + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $act=0; + while ($sthArows > $act) + { + @aryA = $sthA->fetchrow_array; + $temp_vcca = $aryA[0]; + $temp_ac = $aryA[1]; + $act++; + } + if ($act > 0) + { + $sthA->finish(); + $stmtA="UPDATE vicidial_campaign_cid_areacodes set call_count_today=(call_count_today + 1) where campaign_id='$LIST_cid_group_override' and areacode='$temp_ac' and outbound_cid='$temp_vcca';"; + $affected_rows = $dbhA->do($stmtA); + + if ($cid_group_type =~ /NONE/) + { + $stmtA="UPDATE vicidial_cid_groups set cid_auto_rotate_calls=(cid_auto_rotate_calls + 1) where cid_group_id='$LIST_cid_group_override';"; + $affected_rows = $dbhA->do($stmtA); + } + } + else + {$sthA->finish();} + $temp_CID = $temp_vcca; + $temp_CID =~ s/\D//gi; + } + } + if ( (length($campaign_cid_override) > 6) || (length($temp_CID) > 6) ) + { + if (length($temp_CID) > 6) + {$CCID = "$temp_CID"; $CCID_on++; $CCIDtype='LIST_CID_GROUP';} + else + {$CCID = "$campaign_cid_override"; $CCID_on++; $CCIDtype='LIST_CID';} + } else { if ($DBIPuse_custom_cid[$camp_CIPct] =~ /Y/) @@ -1218,6 +1290,10 @@ while($one_day_interval > 0) ### insert log record into vicidial_lead_24hour_calls table $stmtD = "INSERT INTO vicidial_lead_24hour_calls SET lead_id='$lead_id',list_id='$list_id',call_date=NOW(),phone_number='$phone_number',phone_code='$phone_code',state='$TFhourSTATE',call_type='AUTO';"; $affected_rowsD = $dbhA->do($stmtD); + + ### insert log record into vicidial_dial_cid_log table + $stmtE = "INSERT INTO vicidial_dial_cid_log SET caller_code='$VqueryCID',call_date='$SQLdate',call_type='OUTBALANCE',call_alt='$alt_dial',outbound_cid='$CCID',outbound_cid_type='$CCIDtype';"; + $affected_rowsE = $dbhA->do($stmtE); } else { @@ -1232,6 +1308,8 @@ while($one_day_interval > 0) $vltfh_inserts[$staggered_ct] = "INSERT INTO vicidial_lead_24hour_calls SET lead_id='$lead_id',list_id='$list_id',call_date=NOW(),phone_number='$phone_number',phone_code='$phone_code',state='$TFhourSTATE',call_type='AUTO';"; + $vdcl_inserts[$staggered_ct] = "INSERT INTO vicidial_dial_cid_log SET caller_code='$VqueryCID',call_date='$SQLdate',call_type='OUTBALANCE',call_alt='$alt_dial',outbound_cid='$CCID',outbound_cid_type='$CCIDtype';"; + $DB_camp_servers_calls_placed++; $calls_placed++; $staggered_ct++; @@ -1331,6 +1409,7 @@ while($one_day_interval > 0) $TEMP_st_logged = ''; $TEMP_vddl_inserts = ''; $TEMP_vltfh_inserts = ''; + $TEMP_vdcl_inserts = ''; $TEMP_vm_insert = ''; $TEMP_vac_insert = ''; $TEMP_vddl_inserts = ''; @@ -1348,6 +1427,7 @@ while($one_day_interval > 0) $TEMP_st_logged = $st_logged[$staggered_fill]; $TEMP_vddl_inserts = $vddl_inserts[$staggered_fill]; $TEMP_vltfh_inserts = $vltfh_inserts[$staggered_fill]; + $TEMP_vdcl_inserts = $vdcl_inserts[$staggered_fill]; $TEMP_vm_insert =~ s/XXXXXXXXXXXXXXX/$TEMP_server_ip/gi; $TEMP_vac_insert =~ s/XXXXXXXXXXXXXXX/$TEMP_server_ip/gi; @@ -1366,6 +1446,7 @@ while($one_day_interval > 0) $affected_rows_vac = $dbhA->do($TEMP_vac_insert); $affected_rows_vddl = $dbhA->do($TEMP_vddl_inserts); $affected_rows_vltfh = $dbhA->do($TEMP_vltfh_inserts); + $affected_rows_vdcl = $dbhA->do($TEMP_vdcl_inserts); if ($DB) {print "LEAD UPDATE: $affected_rows_vl|$TEMP_vl_update|\n";} if ($DB) {print "LEAD CALL COUNT UPDATE: $affected_rows_vdc|$TEMP_vdc_update|\n";} @@ -1373,9 +1454,10 @@ while($one_day_interval > 0) if ($DB) {print "VICIDIAL_AUTO_CALLS INSERT: $affected_rows_vac|$TEMP_vac_insert|\n";} if ($DB) {print "VICIDIAL_DIAL_LOG INSERT: $affected_rows_vddl|$TEMP_vddl_inserts|\n";} if ($DB) {print "VICIDIAL_LEAD_24HOUR_CALLS INSERT: $affected_rows_vltfh|$TEMP_vltfh_inserts|\n";} + if ($DB) {print "VICIDIAL_DIAL_CID_LOG INSERT: $affected_rows_vdcl|$TEMP_vdcl_inserts|\n";} } - $event_string = "| number call stagger dialed|$TEMP_vm_insert|$TEMP_server_ip|$staggered_fill|$staggered_ct|$affected_rows_vm|$affected_rows_vac|$affected_rows_vl|$affected_rows_vddl $TEMP_st_logged"; + $event_string = "| number call stagger dialed|$TEMP_vm_insert|$TEMP_server_ip|$staggered_fill|$staggered_ct|$affected_rows_vm|$affected_rows_vac|$affected_rows_vl|$affected_rows_vddl|$affected_rows_vltfh|$affected_rows_vdcl $TEMP_st_logged"; &event_logger; ### sleep for 2.5 hundredths of a second to not flood the server with new calls 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 451385ec..524793f4 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -1131,7 +1131,8 @@ inbound_after_hours_voicemail VARCHAR(20), qc_scorecard_id VARCHAR(20) DEFAULT '', qc_statuses_id VARCHAR(20) DEFAULT '', qc_web_form_address VARCHAR(255) DEFAULT '', -auto_alt_threshold TINYINT(3) default '-1' +auto_alt_threshold TINYINT(3) default '-1', +cid_group_id VARCHAR(20) default '---DISABLED---' ) ENGINE=MyISAM; CREATE TABLE vicidial_statuses ( @@ -4719,6 +4720,17 @@ user_group VARCHAR(20) default '---ALL---', active ENUM('Y','N') ) ENGINE=MyISAM; +CREATE TABLE vicidial_dial_cid_log ( +caller_code VARCHAR(30) NOT NULL, +call_date DATETIME, +call_type ENUM('OUT','OUTBALANCE','MANUAL','OVERRIDE','3WAY') default 'OUT', +call_alt VARCHAR(20) default '', +outbound_cid VARCHAR(20) default '', +outbound_cid_type VARCHAR(20) default '', +index (caller_code), +index (call_date) +) ENGINE=MyISAM; + ALTER TABLE vicidial_email_list MODIFY message text character set utf8; @@ -4979,6 +4991,9 @@ ALTER TABLE vicidial_peer_event_log_archive MODIFY peer_event_id INT(9) UNSIGNED CREATE TABLE vicidial_inbound_caller_codes_archive LIKE vicidial_inbound_caller_codes; +CREATE TABLE vicidial_dial_cid_log_archive LIKE vicidial_dial_cid_log; +CREATE UNIQUE INDEX caller_code_date on vicidial_dial_cid_log_archive (caller_code,call_date); + GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; @@ -5064,4 +5079,4 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_ UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1656',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1657',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.14.sql b/agc_2-X/trunk/extras/upgrade_2.14.sql index 26897853..102ff100 100644 --- a/agc_2-X/trunk/extras/upgrade_2.14.sql +++ b/agc_2-X/trunk/extras/upgrade_2.14.sql @@ -1899,3 +1899,21 @@ KEY ajax_dbtime_key (db_time) ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; UPDATE system_settings SET db_schema_version='1656',db_schema_update_date=NOW() where db_schema_version < 1656; + +ALTER TABLE vicidial_lists ADD cid_group_id VARCHAR(20) default '---DISABLED---'; + +CREATE TABLE vicidial_dial_cid_log ( +caller_code VARCHAR(30) NOT NULL, +call_date DATETIME, +call_type ENUM('OUT','OUTBALANCE','MANUAL','OVERRIDE','3WAY') default 'OUT', +call_alt VARCHAR(20) default '', +outbound_cid VARCHAR(20) default '', +outbound_cid_type VARCHAR(20) default '', +index (caller_code), +index (call_date) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_dial_cid_log_archive LIKE vicidial_dial_cid_log; +CREATE UNIQUE INDEX caller_code_date on vicidial_dial_cid_log_archive (caller_code,call_date); + +UPDATE system_settings SET db_schema_version='1657',db_schema_update_date=NOW() where db_schema_version < 1657; diff --git a/agc_2-X/trunk/www/agc/manager_send.php b/agc_2-X/trunk/www/agc/manager_send.php index 0239dd97..bbf2704d 100644 --- a/agc_2-X/trunk/www/agc/manager_send.php +++ b/agc_2-X/trunk/www/agc/manager_send.php @@ -150,10 +150,11 @@ # 210823-0916 - Fix for security issue # 210825-0911 - Fix for XSS security issue # 220220-0904 - Added allow_web_debug system setting +# 220312-0936 - Added vicidial_dial_cid_log logging # -$version = '2.14-97'; -$build = '220220-0904'; +$version = '2.14-98'; +$build = '220312-0936'; $php_script = 'manager_send.php'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=143; @@ -621,6 +622,12 @@ if ($ACTION=="Originate") $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02119',$user,$server_ip,$session_name,$one_mysql_log);} + ### log outbound call in the dial cid log + $stmt = "INSERT INTO vicidial_dial_cid_log SET caller_code='$queryCID',call_date='$NOW_TIME',call_type='MANUAL',call_alt='$agent_dialed_type', outbound_cid='$outbound_cid',outbound_cid_type='AGENT';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ( (strlen($lead_id) > 0) and (strlen($session_id) > 0) and (preg_match("/^DC/",$queryCID)) ) { $stmt="INSERT INTO vicidial_sessions_recent SET lead_id='$lead_id',server_ip='$server_ip',call_date=NOW(),user='$user',campaign_id='$campaign',conf_exten='$session_id',call_type='X';"; 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 168fef1b..7221bbdd 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -523,10 +523,11 @@ # 220119-1014 - Added auto_alt_threshold feature # 220212-0919 - Added pause_max_url_trigger input # 220219-0134 - Added allow_web_debug system setting +# 220311-1709 - Added List CID Group Override option # -$version = '2.14-416'; -$build = '220219-0134'; +$version = '2.14-417'; +$build = '220311-1709'; $php_script = 'vdc_db_query.php'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=876; @@ -4419,13 +4420,14 @@ if ($ACTION == 'manDiaLnextCaLL') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00788',$user,$server_ip,$session_name,$one_mysql_log);} $campaign_cid_override=''; + $LIST_cid_group_override=''; $LISTweb_form_address=''; $LISTweb_form_address_two=''; $LISTweb_form_address_three=''; ### check if there is a list_id override if (strlen($list_id) > 1) { - $stmt = "SELECT campaign_cid_override,web_form_address,web_form_address_two,web_form_address_three,list_description,default_xfer_group FROM vicidial_lists where list_id='$list_id';"; + $stmt = "SELECT campaign_cid_override,web_form_address,web_form_address_two,web_form_address_three,list_description,default_xfer_group,cid_group_id FROM vicidial_lists where list_id='$list_id';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00245',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -4439,6 +4441,7 @@ if ($ACTION == 'manDiaLnextCaLL') $LISTweb_form_address_three = $row[3]; $list_description = $row[4]; $LISTdefault_xfer_group = $row[5]; + $LIST_cid_group_override = $row[6]; if ( (strlen($LISTdefault_xfer_group)>0) and (!preg_match("/---NONE---/",$LISTdefault_xfer_group)) ) {$default_xfer_group = $LISTdefault_xfer_group;} } @@ -4585,7 +4588,75 @@ if ($ACTION == 'manDiaLnextCaLL') manual_dnc_check($agent_dialed_number, $no_hopper_dialing_used, 0); } - if (strlen($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++; $CCIDtype='LIST_CID';} + $temp_CID=''; + if ( (strlen($LIST_cid_group_override) > 0) and ($LIST_cid_group_override != '---DISABLED---') ) + { + $stmt = "SELECT cid_group_type FROM vicidial_cid_groups where cid_group_id='$LIST_cid_group_override';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cidg_ct = mysqli_num_rows($rslt); + if ($cidg_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $cid_group_type = $row[0]; + $temp_vcca=''; + $temp_ac=''; + + if ($cid_group_type == 'AREACODE') + { + $temp_ac_two = substr("$agent_dialed_number", 0, 2); + $temp_ac_three = substr("$agent_dialed_number", 0, 3); + $temp_ac_four = substr("$agent_dialed_number", 0, 4); + $temp_ac_five = substr("$agent_dialed_number", 0, 5); + $stmt = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and areacode IN('$temp_ac_two','$temp_ac_three','$temp_ac_four','$temp_ac_five') and active='Y' order by CAST(areacode as SIGNED INTEGER) asc, call_count_today desc limit 100000;"; + } + if ($cid_group_type == 'STATE') + { + $temp_state = $state; + $stmt = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and areacode IN('$temp_state') and active='Y' order by call_count_today desc limit 100000;"; + } + if ($cid_group_type == 'NONE') + { + $stmt = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and active='Y' order by call_count_today desc limit 100000;"; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vcca_ct = mysqli_num_rows($rslt); + $act=0; + while ($vcca_ct > $act) + { + $row=mysqli_fetch_row($rslt); + $temp_vcca = $row[0]; + $temp_ac = $row[1]; + $act++; + } + if ($act > 0) + { + $stmt="UPDATE vicidial_campaign_cid_areacodes SET call_count_today=(call_count_today + 1) where campaign_id='$LIST_cid_group_override' and areacode='$temp_ac' and outbound_cid='$temp_vcca';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + + if ($cid_group_type == 'NONE') + { + $stmt="UPDATE vicidial_cid_groups SET cid_auto_rotate_calls=(cid_auto_rotate_calls + 1) where cid_group_id='$LIST_cid_group_override';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + $temp_CID = preg_replace("/\D/",'',$temp_vcca); + } + if ( (strlen($campaign_cid_override) > 6) or (strlen($temp_CID) > 6) ) + { + if (strlen($temp_CID) > 6) + {$CCID = "$temp_CID"; $CCID_on++; $CCIDtype='LIST_CID_GROUP';} + else + {$CCID = "$campaign_cid_override"; $CCID_on++; $CCIDtype='LIST_CID';} + } else { if ($uccid_ct > 0) @@ -4941,14 +5012,20 @@ if ($ACTION == 'manDiaLnextCaLL') } #### END check for manual_dial_cid == 'AGENT_PHONE_OVERRIDE' - #### BEGIN check for API forced CID override #### + #### BEGIN check for API forced CID or Agent-Selected Group Alias override #### if ( ($usegroupalias > 0) and ($account=='-FORCE-') and (strlen($campaign_cid) > 6) ) { $FORCEoutbound_cid = preg_replace("/\D/",'',$campaign_cid); if (strlen($FORCEoutbound_cid) > 6) {$CCID = "$FORCEoutbound_cid"; $CCID_on++; $CCIDtype='API_CID';} } - #### END check for API forced CID override #### + if ( ($usegroupalias > 0) and (strlen($account)>0) and (strlen($campaign_cid) > 6) ) + { + $FORCEoutbound_cid = preg_replace("/\D/",'',$campaign_cid); + if (strlen($FORCEoutbound_cid) > 6) + {$CCID = "$FORCEoutbound_cid"; $CCID_on++; $CCIDtype='AGENT_CHOOSE_CID';} + } + #### END check for API forced CID or Agent-Selected Group Alias override #### if ($CCID_on) {$CIDstring = "\"$MqueryCID$EAC\" <$CCID>";} else {$CIDstring = "$MqueryCID$EAC";} @@ -4972,6 +5049,12 @@ if ($ACTION == 'manDiaLnextCaLL') $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00852',$user,$server_ip,$session_name,$one_mysql_log);} + ### log outbound call in the dial cid log + $stmt = "INSERT INTO vicidial_dial_cid_log SET caller_code='$MqueryCID',call_date='$NOW_TIME',call_type='MANUAL',call_alt='$agent_dialed_type', outbound_cid='$CCID',outbound_cid_type='$CCIDtype';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $calls_todaySQL = ",calls_today='$calls_today'"; ### Skip logging and list overrides if dial in-group is used if (strlen($dial_ingroup) < 1) @@ -6325,7 +6408,7 @@ if ($ACTION == 'manDiaLonly') if (strlen($list_id) > 1) { - $stmt = "SELECT campaign_cid_override,web_form_address,web_form_address_two,web_form_address_three,list_description FROM vicidial_lists where list_id='$list_id';"; + $stmt = "SELECT campaign_cid_override,web_form_address,web_form_address_two,web_form_address_three,list_description,cid_group_id FROM vicidial_lists where list_id='$list_id';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00247',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -6338,12 +6421,81 @@ if ($ACTION == 'manDiaLonly') $LISTweb_form_address_two = $row[2]; $LISTweb_form_address_three = $row[3]; $list_description = $row[4]; + $LIST_cid_group_override = $row[5]; } } } } - if (strlen($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++; $CCIDtype='LIST_CID';} + $temp_CID=''; + if ( (strlen($LIST_cid_group_override) > 0) and ($LIST_cid_group_override != '---DISABLED---') ) + { + $stmt = "SELECT cid_group_type FROM vicidial_cid_groups where cid_group_id='$LIST_cid_group_override';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cidg_ct = mysqli_num_rows($rslt); + if ($cidg_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $cid_group_type = $row[0]; + $temp_vcca=''; + $temp_ac=''; + + if ($cid_group_type == 'AREACODE') + { + $temp_ac_two = substr("$agent_dialed_number", 0, 2); + $temp_ac_three = substr("$agent_dialed_number", 0, 3); + $temp_ac_four = substr("$agent_dialed_number", 0, 4); + $temp_ac_five = substr("$agent_dialed_number", 0, 5); + $stmt = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and areacode IN('$temp_ac_two','$temp_ac_three','$temp_ac_four','$temp_ac_five') and active='Y' order by CAST(areacode as SIGNED INTEGER) asc, call_count_today desc limit 100000;"; + } + if ($cid_group_type == 'STATE') + { + $temp_state = $state; + $stmt = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and areacode IN('$temp_state') and active='Y' order by call_count_today desc limit 100000;"; + } + if ($cid_group_type == 'NONE') + { + $stmt = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$LIST_cid_group_override' and active='Y' order by call_count_today desc limit 100000;"; + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vcca_ct = mysqli_num_rows($rslt); + $act=0; + while ($vcca_ct > $act) + { + $row=mysqli_fetch_row($rslt); + $temp_vcca = $row[0]; + $temp_ac = $row[1]; + $act++; + } + if ($act > 0) + { + $stmt="UPDATE vicidial_campaign_cid_areacodes SET call_count_today=(call_count_today + 1) where campaign_id='$LIST_cid_group_override' and areacode='$temp_ac' and outbound_cid='$temp_vcca';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + + if ($cid_group_type == 'NONE') + { + $stmt="UPDATE vicidial_cid_groups SET cid_auto_rotate_calls=(cid_auto_rotate_calls + 1) where cid_group_id='$LIST_cid_group_override';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + $temp_CID = preg_replace("/\D/",'',$temp_vcca); + } + if ( (strlen($campaign_cid_override) > 6) or (strlen($temp_CID) > 6) ) + { + if (strlen($temp_CID) > 6) + {$CCID = "$temp_CID"; $CCID_on++; $CCIDtype='LIST_CID_GROUP';} + else + {$CCID = "$campaign_cid_override"; $CCID_on++; $CCIDtype='LIST_CID';} + } else { ### check for custom cid use @@ -6575,14 +6727,20 @@ if ($ACTION == 'manDiaLonly') } #### END check for manual_dial_cid == 'AGENT_PHONE_OVERRIDE' - #### BEGIN check for API forced CID override #### + #### BEGIN check for API forced CID or Agent-Selected Group Alias override #### if ( ($usegroupalias > 0) and ($account=='-FORCE-') and (strlen($campaign_cid) > 6) ) { $FORCEoutbound_cid = preg_replace("/\D/",'',$campaign_cid); if (strlen($FORCEoutbound_cid) > 6) {$CCID = "$FORCEoutbound_cid"; $CCID_on++; $CCIDtype='API_CID';} } - #### END check for API forced CID override #### + if ( ($usegroupalias > 0) and (strlen($account)>0) and (strlen($campaign_cid) > 6) ) + { + $FORCEoutbound_cid = preg_replace("/\D/",'',$campaign_cid); + if (strlen($FORCEoutbound_cid) > 6) + {$CCID = "$FORCEoutbound_cid"; $CCID_on++; $CCIDtype='AGENT_CHOOSE_CID';} + } + #### END check for API forced CID or Agent-Selected Group Alias override #### #### BEGIN run manual_dial_hopper_check process if enabled if ($manual_dial_hopper_check == 'Y') @@ -6688,6 +6846,12 @@ if ($ACTION == 'manDiaLonly') $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00855',$user,$server_ip,$session_name,$one_mysql_log);} + ### log outbound call in the dial cid log + $stmt = "INSERT INTO vicidial_dial_cid_log SET caller_code='$MqueryCID',call_date='$NOW_TIME',call_type='MANUAL',call_alt='$agent_dialed_type', outbound_cid='$CCID',outbound_cid_type='$CCIDtype';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + ### update the agent status to INCALL in vicidial_live_agents $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME',pause_code='',preview_lead_id='0' where user='$user' and server_ip='$server_ip';"; if ($DB) {echo "$stmt\n";} diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 39af8125..ece5bee1 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -5883,12 +5883,14 @@ if ($SSscript_remove_js > 0) # 220218-1656 - Added allow_web_debug system setting to disable $DB output by default # 220307-1151 - Added 'update_presets' Non-Agent API function # 220310-1007 - Added STAGING option for campaign presets +# 220311-0808 - Added List setting for Campaign CID Group Override +# 220312-0937 - Added vicidial_dial_cid_log logging # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.14-850a'; -$build = '220310-1007'; +$admin_version = '2.14-852a'; +$build = '220312-0937'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -16626,7 +16628,7 @@ if ($ADD==41) $rslt=mysql_to_mysqli($stmt, $link); ### gather list_id overrides - $stmt="SELECT campaign_cid_override FROM vicidial_lists where list_id='$manual_dial_list_id' $LOGallowed_campaignsSQL;"; + $stmt="SELECT campaign_cid_override,cid_group_id FROM vicidial_lists where list_id='$manual_dial_list_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $CIDor_ct = mysqli_num_rows($rslt); @@ -16634,7 +16636,8 @@ if ($ADD==41) if ($CIDor_ct > 0) { $row=mysqli_fetch_row($rslt); - $campaign_cid_override = $row[0]; + $campaign_cid_override = $row[0]; + $campaign_cid_group_override = $row[1]; } ### gather server information @@ -16693,6 +16696,12 @@ if ($ADD==41) $stmtD = "INSERT INTO vicidial_dial_log SET caller_code='$VqueryCID',lead_id='$lead_id',server_ip='$old_server_ip',call_date='$SQLdate',extension='$VDAD_dial_exten',channel='$local_DEF$Ndialstring$local_AMP$ext_context',timeout='$Local_dial_timeout',outbound_cid='$CIDstring',context='$ext_context';"; $rslt=mysql_to_mysqli($stmtD, $link); + ### log outbound call in the dial cid log + $stmt = "INSERT INTO vicidial_dial_cid_log SET caller_code='$VqueryCID',call_date='$SQLdate',call_type='MANUAL',call_alt='MAIN', outbound_cid='$CCID',outbound_cid_type='CAMPAIGN_TEST';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + ### LOG INSERTION Admin Log Table, for campaign ### $SQL_log = "$stmtA|$stmtB|$stmtC|"; $SQL_log = preg_replace('/;/', '', $SQL_log); @@ -17746,7 +17755,7 @@ if ($ADD==411) echo "
"._QXZ("LIST MODIFIED").": $list_id\n"; - $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active',list_description='$list_description',list_changedate='$SQLdate',reset_time='$reset_time',agent_script_override='$agent_script_override',inbound_list_script_override='$inbound_list_script_override',campaign_cid_override='$campaign_cid_override',am_message_exten_override='$am_message_exten_override',drop_inbound_group_override='$drop_inbound_group_override',xferconf_a_number='$xferconf_a_number',xferconf_b_number='$xferconf_b_number',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',web_form_address='" . mysqli_real_escape_string($link, $web_form_address) . "',web_form_address_two='" . mysqli_real_escape_string($link, $web_form_address_two) . "',time_zone_setting='$time_zone_setting',inventory_report='$inventory_report',expiration_date='$expiration_date',na_call_url='" . mysqli_real_escape_string($link, $na_call_url) . "',local_call_time='$local_call_time',web_form_address_three='" . mysqli_real_escape_string($link, $web_form_address_three) . "',status_group_id='$status_group_id',user_new_lead_limit='$user_new_lead_limit',default_xfer_group='$default_xfer_group',qc_scorecard_id='$qc_scorecard_id' $daily_reset_limitSQL,auto_active_list_rank='$auto_active_list_rank',qc_statuses_id='$qc_statuses_id',qc_web_form_address='" . mysqli_real_escape_string($link, $qc_web_form_address) . "',inbound_drop_voicemail='$inbound_drop_voicemail',inbound_after_hours_voicemail='$inbound_after_hours_voicemail',auto_alt_threshold='$auto_alt_threshold' where list_id='$list_id';"; + $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active',list_description='$list_description',list_changedate='$SQLdate',reset_time='$reset_time',agent_script_override='$agent_script_override',inbound_list_script_override='$inbound_list_script_override',campaign_cid_override='$campaign_cid_override',am_message_exten_override='$am_message_exten_override',drop_inbound_group_override='$drop_inbound_group_override',xferconf_a_number='$xferconf_a_number',xferconf_b_number='$xferconf_b_number',xferconf_c_number='$xferconf_c_number',xferconf_d_number='$xferconf_d_number',xferconf_e_number='$xferconf_e_number',web_form_address='" . mysqli_real_escape_string($link, $web_form_address) . "',web_form_address_two='" . mysqli_real_escape_string($link, $web_form_address_two) . "',time_zone_setting='$time_zone_setting',inventory_report='$inventory_report',expiration_date='$expiration_date',na_call_url='" . mysqli_real_escape_string($link, $na_call_url) . "',local_call_time='$local_call_time',web_form_address_three='" . mysqli_real_escape_string($link, $web_form_address_three) . "',status_group_id='$status_group_id',user_new_lead_limit='$user_new_lead_limit',default_xfer_group='$default_xfer_group',qc_scorecard_id='$qc_scorecard_id' $daily_reset_limitSQL,auto_active_list_rank='$auto_active_list_rank',qc_statuses_id='$qc_statuses_id',qc_web_form_address='" . mysqli_real_escape_string($link, $qc_web_form_address) . "',inbound_drop_voicemail='$inbound_drop_voicemail',inbound_after_hours_voicemail='$inbound_after_hours_voicemail',auto_alt_threshold='$auto_alt_threshold',cid_group_id='$cid_group_id' where list_id='$list_id';"; $rslt=mysql_to_mysqli($stmt, $link); ## QC Addition for Audited Comments @@ -30589,7 +30598,7 @@ if ($ADD==311) } } - $stmt="SELECT vicidial_lists.list_id,list_name,campaign_id,active,list_description,list_changedate,list_lastcalldate,reset_time,agent_script_override,campaign_cid_override,am_message_exten_override,drop_inbound_group_override,xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number,web_form_address,web_form_address_two,time_zone_setting,inventory_report,IFNULL(audit_comments,0),expiration_date,DATE_FORMAT(expiration_date,'%Y%m%d'),na_call_url,local_call_time,web_form_address_three,status_group_id,user_new_lead_limit,inbound_list_script_override,default_xfer_group,daily_reset_limit,resets_today,auto_active_list_rank,inbound_drop_voicemail,inbound_after_hours_voicemail,qc_scorecard_id,qc_statuses_id,qc_web_form_address,auto_alt_threshold from vicidial_lists left outer join vicidial_lists_custom on vicidial_lists.list_id=vicidial_lists_custom.list_id where vicidial_lists.list_id='$list_id' $LOGallowed_campaignsSQL;"; + $stmt="SELECT vicidial_lists.list_id,list_name,campaign_id,active,list_description,list_changedate,list_lastcalldate,reset_time,agent_script_override,campaign_cid_override,am_message_exten_override,drop_inbound_group_override,xferconf_a_number,xferconf_b_number,xferconf_c_number,xferconf_d_number,xferconf_e_number,web_form_address,web_form_address_two,time_zone_setting,inventory_report,IFNULL(audit_comments,0),expiration_date,DATE_FORMAT(expiration_date,'%Y%m%d'),na_call_url,local_call_time,web_form_address_three,status_group_id,user_new_lead_limit,inbound_list_script_override,default_xfer_group,daily_reset_limit,resets_today,auto_active_list_rank,inbound_drop_voicemail,inbound_after_hours_voicemail,qc_scorecard_id,qc_statuses_id,qc_web_form_address,auto_alt_threshold,cid_group_id from vicidial_lists left outer join vicidial_lists_custom on vicidial_lists.list_id=vicidial_lists_custom.list_id where vicidial_lists.list_id='$list_id' $LOGallowed_campaignsSQL;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} @@ -30633,6 +30642,7 @@ if ($ADD==311) $qc_statuses_id = $row[37]; $qc_web_form_address = $row[38]; $auto_alt_threshold = $row[39]; + $cid_group_id = $row[40]; # grab names of global statuses and statuses in the selected campaign $stmt="SELECT status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable,scheduled_callback,completed,min_sec,max_sec,answering_machine from vicidial_statuses order by status;"; @@ -30828,6 +30838,43 @@ if ($ADD==311) echo "$DID_edit_link_BEGIN"._QXZ("Campaign CID Override")."$DID_edit_link_END: $NWB#lists-campaign_cid_override$NWE\n"; + if ($SScampaign_cid_areacodes_enabled == '1') + { + ##### get vicidial_cid_groups listings for dynamic pulldown list + $stmt="SELECT cid_group_id,cid_group_type,cid_group_notes from vicidial_cid_groups $whereLOGadmin_viewable_groupsSQL order by cid_group_id;"; + $rslt=mysql_to_mysqli($stmt, $link); + $cid_groups_to_print = mysqli_num_rows($rslt); + $cid_groups_menu=''; + $cid_groups_selected=0; + $o=0; + while ($cid_groups_to_print > $o) + { + $rowx=mysqli_fetch_row($rslt); + $cid_groups_menu .= "\n"; + $o++; + } + + echo ""; + if ($cid_groups_selected > 0) + {echo ""._QXZ("Campaign CID Group Override")."";} + else + {echo _QXZ("Campaign CID Group Override");} + echo ": $NWB#lists-cid_group_id$NWE\n"; + } + else + { + echo ""; + } + echo ""._QXZ("Answering Machine Message Override").": "._QXZ("audio chooser")." $NWB#lists-am_message_exten_override$NWE\n"; echo ""._QXZ("Drop Inbound Group Override").":