From 5bacb9346bd601a4106f0d894ea1cd1652ae93eb Mon Sep 17 00:00:00 2001 From: mattf Date: Wed, 6 Jul 2011 12:26:41 +0000 Subject: [PATCH] Added Outbound Campaign Test Call feature to allow you to place a call from the Campaign Detail screen that will go out as if it were an auto-dial call. Must be enabled in System Settings. Added ability to check for USA and Canada valid prefix and areacodes when loading leads into the web/cli/api lead loaders git-svn-id: svn://192.168.202.10@1687 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 7 + bin/ADMIN_keepalive_ALL.pl | 46 ++-- bin/AST_VDauto_dial.pl | 2 +- bin/VICIDIAL_IN_new_leads_file.pl | 67 +++++- docs/AGENT_API.txt | 2 +- docs/NON-AGENT_API.txt | 10 +- extras/MySQL_AST_CREATE_tables.sql | 12 +- extras/upgrade_2.4.sql | 5 + .../TO_BE_TRANSLATED_2.4.txt | 7 + www/agc/vdc_db_query.php | 6 +- www/vicidial/admin.php | 200 +++++++++++++++--- www/vicidial/admin_listloader_third_gen.php | 113 +++++++++- www/vicidial/non_agent_api.php | 43 +++- 13 files changed, 439 insertions(+), 81 deletions(-) diff --git a/UPGRADE b/UPGRADE index 93227de5..0cf53846 100644 --- a/UPGRADE +++ b/UPGRADE @@ -628,6 +628,13 @@ OTHER CHANGES: 140. Added HIDDEN and READONLY field types for custom list fields. +141. Added Outbound Campaign Test Call feature to allow you to place a call from + the Campaign Detail screen that will go out as if it were an auto-dial + call. Must be enabled in System Settings. + +142. Added ability to check for USA and Canada valid prefix and areacodes when + loading leads into the web/cli/api lead loaders + diff --git a/bin/ADMIN_keepalive_ALL.pl b/bin/ADMIN_keepalive_ALL.pl index dbb3460f..6d5a66c4 100644 --- a/bin/ADMIN_keepalive_ALL.pl +++ b/bin/ADMIN_keepalive_ALL.pl @@ -61,6 +61,7 @@ # 101214-1507 - Changed list auto-reset to work with inactive lists # 110512-2112 - Added vicidial_campaign_stats_debug to table cleaning # 110525-2334 - Added cm.agi optional logging to call menus +# 110705-2023 - Added agents_calls_reset option # $DB=0; # Debug flag @@ -631,6 +632,18 @@ $timeclock_end_of_day_NOW=0; if ($timeclock_end_of_day_NOW > 0) { + $stmtA = "SELECT agents_calls_reset from system_settings;"; + if ($DB) {print "|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $SSsel_ct=$sthA->rows; + if ($SSsel_ct > 0) + { + @aryA = $sthA->fetchrow_array; + $agents_calls_reset = $aryA[0]; + } + $sthA->finish(); + if ($DB) {print "Starting clear out non-used vicidial_conferences sessions process...\n";} $stmtA = "SELECT conf_exten,extension from vicidial_conferences where server_ip='$server_ip' and leave_3way='0';"; @@ -785,16 +798,29 @@ if ($timeclock_end_of_day_NOW > 0) if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} $sthA->finish(); - $stmtA = "delete from vicidial_live_inbound_agents where last_call_finish < \"$TDSQLdate\";"; - if($DBX){print STDERR "\n|$stmtA|\n";} - $affected_rows = $dbhA->do($stmtA); - if($DB){print STDERR "\n|$affected_rows vicidial_live_inbound_agents old records deleted|\n";} - $stmtA = "update vicidial_live_inbound_agents SET calls_today=0;"; if($DBX){print STDERR "\n|$stmtA|\n";} $affected_rows = $dbhA->do($stmtA); if($DB){print STDERR "\n|$affected_rows vicidial_live_inbound_agents call counts reset|\n";} + if ($agents_calls_reset > 0) + { + $stmtA = "delete from vicidial_live_inbound_agents where last_call_finish < \"$TDSQLdate\";"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); + if($DB){print STDERR "\n|$affected_rows vicidial_live_inbound_agents old records deleted|\n";} + + $stmtA = "delete from vicidial_live_agents where last_state_change < \"$TDSQLdate\" and extension NOT LIKE \"R/%\";"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); + if($DB){print STDERR "\n|$affected_rows vicidial_live_agents old records deleted|\n";} + + $stmtA = "delete from vicidial_auto_calls where last_update_time < \"$TDSQLdate\";"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); + if($DB){print STDERR "\n|$affected_rows vicidial_auto_calls old records deleted|\n";} + } + $stmtA = "optimize table vicidial_live_inbound_agents;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -804,11 +830,6 @@ if ($timeclock_end_of_day_NOW > 0) if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} $sthA->finish(); - $stmtA = "delete from vicidial_live_agents where last_state_change < \"$TDSQLdate\" and extension NOT LIKE \"R/%\";"; - if($DBX){print STDERR "\n|$stmtA|\n";} - $affected_rows = $dbhA->do($stmtA); - if($DB){print STDERR "\n|$affected_rows vicidial_live_agents old records deleted|\n";} - $stmtA = "optimize table vicidial_live_agents;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -818,11 +839,6 @@ if ($timeclock_end_of_day_NOW > 0) if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} $sthA->finish(); - $stmtA = "delete from vicidial_auto_calls where last_update_time < \"$TDSQLdate\";"; - if($DBX){print STDERR "\n|$stmtA|\n";} - $affected_rows = $dbhA->do($stmtA); - if($DB){print STDERR "\n|$affected_rows vicidial_auto_calls old records deleted|\n";} - $stmtA = "optimize table vicidial_auto_calls;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; diff --git a/bin/AST_VDauto_dial.pl b/bin/AST_VDauto_dial.pl index c6de6bc8..edc2154f 100644 --- a/bin/AST_VDauto_dial.pl +++ b/bin/AST_VDauto_dial.pl @@ -1170,7 +1170,7 @@ while($one_day_interval > 0) if (length($ext_context) < 1) {$ext_context='default';} ### use manager middleware-app to connect the next call to the meetme room - # VmmddhhmmssLLLLLLLLL + # VmddhhmmssLLLLLLLLLL $VqueryCID = "V$CIDdate$PADlead_id"; if ($CCID_on) {$CIDstring = "\"$VqueryCID\" <$CCID>";} else {$CIDstring = "$VqueryCID";} diff --git a/bin/VICIDIAL_IN_new_leads_file.pl b/bin/VICIDIAL_IN_new_leads_file.pl index 78cbf7d4..8dd0adaf 100644 --- a/bin/VICIDIAL_IN_new_leads_file.pl +++ b/bin/VICIDIAL_IN_new_leads_file.pl @@ -51,9 +51,10 @@ # 100928-1121 - Added file-prefix-filter option # 110420-0944 - Fixed file prefix issue with multiple processes running # 110424-0948 - Added time-zone-code-gmt option to use time zone code from the owner field +# 110705-1913 - Added options for USACAN prefix(no 0 or 1) and valid areacode filtering # -$version = '110424-0948'; +$version = '110705-1913'; $secX = time(); $MT[0]=''; @@ -161,6 +162,8 @@ if (length($ARGV[0])>1) print " [--new-listid-prefix=X] = prefix for listID when creating new lists, must be only numbers, and 4 or less digits\n"; print " [--new-listname-prefix=X] = prefix for list name when creating new lists, will be followed by filename\n"; print " [--new-list-campaign=X] = campaign that the new list will be assigned to\n"; + print " [--USACAN-prefix-check] = check for the 4th digit 2-9, USA and Canada validation\n"; + print " [--USACAN-areacode-check] = check for the valid phone code 1 areacodes, USA and Canada validation\n"; print " [--duplicate-check] = checks for the same phone number in the same list id before inserting lead\n"; print " [--duplicate-campaign-check] = checks for the same phone number in the same campaign before inserting lead\n"; print " [--duplicate-system-check] = checks for the same phone number in the entire system before inserting lead\n"; @@ -282,6 +285,16 @@ if (length($ARGV[0])>1) else {$file_prefix_filter = '';} + if ($args =~ /--USACAN-prefix-check/i) + { + $usacan_prefix_check=1; + if ($q < 1) {print "\n----- USACAN PREFIX CHECK -----\n\n";} + } + if ($args =~ /--USACAN-areacode-check/i) + { + $usacan_areacode_check=1; + if ($q < 1) {print "\n----- USACAN AREACODE CHECK -----\n\n";} + } if ($args =~ /-duplicate-check/i) { $dupcheck=1; @@ -622,6 +635,7 @@ foreach(@FILES) $e=0; ### status of 'ERROR' counter ### $f=0; ### number of 'DUPLICATE' counter ### $g=0; ### number of leads with multi-alt-entries + $h=0; ### number of 'INVALID' counter ### $multi_insert_counter=0; $multistmt=''; @@ -1572,6 +1586,40 @@ foreach(@FILES) if ($DBX) {print "$a|$phone_number\n";} + + $valid_lead=1; + ##### Check for valid USA and Canada prefix ##### + if ($usacan_prefix_check > 0) + { + $USprefix = substr($phone_number, 3, 1); + if ($USprefix < 2) + { + $valid_lead = '0'; + if ($DBX) {print " Invalid USACAN prefix 4th digit: |$USprefix|$phone_number|\n";} + } + } + + ##### Check for valid USA and Canada areacodes ##### + if ( ($usacan_areacode_check > 0) && ($valid_lead > 0) ) + { + $USarea = substr($phone_number, 0, 3); + $stmtA = "select count(*) from vicidial_phone_codes where areacode='$USarea' and country_code='1';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $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; + $valid_lead = $aryA[0]; + if ($valid_lead < 1) + { + if ($DBX) {print " Invalid USACAN areacode: |$USprefix|$phone_number|\n";} + } + } + $sthA->finish(); + } + ##### Check for duplicate phone numbers in vicidial_list table entire database ##### if ($dupchecksys > 0) { @@ -1718,7 +1766,7 @@ foreach(@FILES) } } - if ( (length($phone_number)>6) && ($dup_lead < 1) ) + if ( (length($phone_number)>6) && ($dup_lead < 1) && ($valid_lead > 0) ) { if ( ($duptapchecklist > 0) || ($duptapchecksys > 0) ) {$phone_list .= "$alt_phone$title$US$list_id|";} @@ -2019,10 +2067,15 @@ foreach(@FILES) } else { - if ($dup_lead > 0) - {if ($q < 1) {print "DUPLICATE: $phone_number|$list_id|$dup_lead_list|$a|$title $alt_phone\n";} $f++;} + if ($valid_lead < 1) + {if ($q < 1) {print "INVALID: $phone_number|$list_id|$dup_lead_list|$a|$title $alt_phone\n";} $h++;} else - {if ($q < 1) {print "BAD Home_Phone: $phone_number|$vendor_id|$a\n";} $e++;} + { + if ($dup_lead > 0) + {if ($q < 1) {print "DUPLICATE: $phone_number|$list_id|$dup_lead_list|$a|$title $alt_phone\n";} $f++;} + else + {if ($q < 1) {print "BAD Home_Phone: $phone_number|$vendor_id|$a\n";} $e++;} + } } $a++; @@ -2038,7 +2091,7 @@ foreach(@FILES) if ($a =~ /700$/i) {print STDERR "| $a\r";} if ($a =~ /800$/i) {print STDERR "+ $a\r";} if ($a =~ /900$/i) {print STDERR "0 $a\r";} - if ($a =~ /000$/i) {print "$a|$b|$c|$d|$e|$f|$g|$phone_number|\n";} + if ($a =~ /000$/i) {print "$a|$b|$c|$d|$e|$f|$g|$h|$phone_number|\n";} } } @@ -2073,6 +2126,8 @@ foreach(@FILES) $Falert .= "MULTI-ALT-PHONE: $g\n"; if ($f > 0) {$Falert .= "DUPLICATES: $f\n";} + if ($h > 0) + {$Falert .= "INVALID PHONES: $h\n";} if ($q < 1) {print "$Falert";} print Sout "$Falert"; diff --git a/docs/AGENT_API.txt b/docs/AGENT_API.txt index 48a4b127..bd7ade60 100644 --- a/docs/AGENT_API.txt +++ b/docs/AGENT_API.txt @@ -1,4 +1,4 @@ -AGENT API DOCUMENT Started: 2008-07-03 +AGENT API DOCUMENT Started: 2008-07-03 Updated: 2011-04-30 This document describes the functions of an API(Application Programming Interface) for the VICIDIAL Agent screen. This functionality will be rather limited at first diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index 75546352..6698896d 100644 --- a/docs/NON-AGENT_API.txt +++ b/docs/NON-AGENT_API.txt @@ -1,4 +1,4 @@ -NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2011-05-29 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2011-07-05 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -59,7 +59,7 @@ Changes: 110424-0854 - Added option for time zone code lookups using owner field in add_lead function 110529-1220 - Added time zone information output to version function 110614-0726 - Added reset_lead option to update_lead function(issue #502) - +110705-1928 - Added options for USACAN 4th digit prefix(no 0 or 1) and valid areacode filtering to add_lead @@ -300,6 +300,8 @@ duplicate_check - Check for duplicate records in the system, can select more tha DUPNAMEPHONELIST - check for duplicate first_name, last_name and phone_number in same list DUPNAMEPHONECAMP - check for duplicate first_name, last_name and phone_number in all lists for this list's campaign DUPNAMEPHONESYS - check for duplicate first_name, last_name and phone_number in entire system +usacan_prefix_check - Y or N, default is N. Check for a valid 4th digit for USA and Canada phone numbers (cannot be 0 or 1) +usacan_areacode_check - Y or N, default is N. Check for a valid areacode for USA and Canada phone numbers custom_fields - Y or N, default is N. Defines whether the API will accept custom field data when inserting leads into the vicidial_list table For custom fields to be inserted, just add the field label as a variable to the URL string For example, if the field_label is "favorite_color" you would add "&favorite_color=blue" @@ -369,7 +371,9 @@ NOTICE: add_lead CUSTOM FIELDS NOT ADDED, NO FIELDS DEFINED - 7275551111|1234|10 NOTICE: add_lead MULTI-ALT-PHONE NUMBERS LOADED - 3|6666|193716 NOTICE: add_lead NOT ADDED TO HOPPER, OUTSIDE OF LOCAL TIME - 7275551111|6666|193716|-4|0 -ERROR: add_lead INVALID PHONE NUMBER - 72755|6666 +ERROR: add_lead INVALID PHONE NUMBER LENGTH - 72755|6666 +ERROR: add_lead INVALID PHONE NUMBER PREFIX - 72755|6666 +ERROR: add_lead INVALID PHONE NUMBER AREACODE - 72755|6666 ERROR: add_lead USER DOES NOT HAVE PERMISSION TO ADD LEADS TO THE SYSTEM - 6666|0 diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index cab3956f..0f1a7e0b 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -387,13 +387,13 @@ external_dtmf VARCHAR(100) default '', external_transferconf VARCHAR(100) default '', external_park VARCHAR(40) default '', external_timer_action_destination VARCHAR(100) default '', +on_hook_agent ENUM('Y','N') default 'N', +on_hook_ring_time SMALLINT(5) default '15', +ring_callerid VARCHAR(20) default '' index (random_id), index (last_call_time), index (last_update_time), index (last_call_finish), -on_hook_agent ENUM('Y','N') default 'N', -on_hook_ring_time SMALLINT(5) default '15', -ring_callerid VARCHAR(20) default '' ); CREATE TABLE vicidial_auto_calls ( @@ -1408,7 +1408,9 @@ generate_cross_server_exten ENUM('0','1') default '0', queuemetrics_addmember_enabled ENUM('0','1') default '0', queuemetrics_dispo_pause VARCHAR(6) default '', label_hide_field_logs VARCHAR(6) default 'Y', -queuemetrics_pe_phone_append ENUM('0','1') default '0' +queuemetrics_pe_phone_append ENUM('0','1') default '0', +test_campaign_calls ENUM('0','1') default '0', +agents_calls_reset ENUM('0','1') default '1' ); CREATE TABLE vicidial_campaigns_list_mix ( @@ -2531,7 +2533,7 @@ ALTER TABLE vicidial_closer_log_archive MODIFY closecallid INT(9) UNSIGNED NOT N CREATE TABLE vicidial_outbound_ivr_log_archive LIKE vicidial_outbound_ivr_log; -UPDATE system_settings SET db_schema_version='1284',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1285',db_schema_update_date=NOW(); GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/extras/upgrade_2.4.sql b/extras/upgrade_2.4.sql index 4674f78d..9d652cba 100644 --- a/extras/upgrade_2.4.sql +++ b/extras/upgrade_2.4.sql @@ -863,3 +863,8 @@ UPDATE system_settings SET db_schema_version='1283',db_schema_update_date=NOW() ALTER TABLE vicidial_lists_fields MODIFY field_type ENUM('TEXT','AREA','SELECT','MULTI','RADIO','CHECKBOX','DATE','TIME','DISPLAY','SCRIPT','HIDDEN','READONLY') default 'TEXT'; UPDATE system_settings SET db_schema_version='1284',db_schema_update_date=NOW() where db_schema_version < 1284; + +ALTER TABLE system_settings ADD test_campaign_calls ENUM('0','1') default '0'; +ALTER TABLE system_settings ADD agents_calls_reset ENUM('0','1') default '1'; + +UPDATE system_settings SET db_schema_version='1285',db_schema_update_date=NOW() where db_schema_version < 1285; diff --git a/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt b/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt index 7d3c1fab..dcbcc7bd 100644 --- a/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt +++ b/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt @@ -639,6 +639,13 @@ CAMPAIGNS USING THIS SCREEN LABEL|| QueueMetrics Phone Environment Phone Append|| This option, if enabled, will append the agent phone login to the data4 record in the queue log table if the Campaign Phone Environment field is populated. Default is 0 for disabled|| HIDDEN will not show the agent the field, but will allow the field to have data imported into it and exported from it, as well as have it available to the script tab and web form address. READONLY will display the value of the data in the field, but will not allow the agent to alter the data|| +Enable Campaign Test Calls|| +This setting enables the ability to enter a phone code and phone number into fields at the bottom of the Campaign Detail screen and place a phone call to that number as if it were a lead being auto-dialed in the system. The phone number will be stored as a new lead in the manual dial list ID list. The campaign must be active for this feature to be enabled, and it is recommended that the lists assigned to the campaign all be set to inactive. The dial prefix, dial timeout and all other dialing related features, except for DNC and call time options, will affect the dialing of the test number. The phone call will be placed on the server selected as the voicemail server in the system settings. Default is 0 for disabled|| +Test calling disabled|| +PLACE TEST CALL|| +Test Outbound Call|| +Agents Calls Reset|| +This setting defines whether the logged-in agents and active phone calls records are to be reset at the timeclock end of day. Default is 1 for enabled|| lead_report_export.php diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index b0c6e152..9da6aad9 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -2188,7 +2188,7 @@ if ($ACTION == 'manDiaLnextCaLL') # generate callerID for unique identifier in xfer_log file $PADlead_id = sprintf("%010s", $lead_id); while (strlen($PADlead_id) > 10) {$PADlead_id = substr("$PADlead_id", 1);} - # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + # Create unique calleridname to track the call: MmddhhmmssLLLLLLLLLL $MqueryCID = "M$CIDdate$PADlead_id"; # DATETIME|campaign|lead_id|phone_number|user|type @@ -2360,7 +2360,7 @@ if ($ACTION == 'manDiaLnextCaLL') $use_eac = $row[0]; } - # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + # Create unique calleridname to track the call: MmddhhmmssLLLLLLLLLL $MqueryCID = "M$CIDdate$PADlead_id"; $EAC=''; if ($use_eac > 0) @@ -2910,7 +2910,7 @@ if ($ACTION == 'manDiaLonly') $PADlead_id = sprintf("%010s", $lead_id); while (strlen($PADlead_id) > 10) {$PADlead_id = substr("$PADlead_id", 1);} - # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + # Create unique calleridname to track the call: MmddhhmmssLLLLLLLLLL $MqueryCID = "M$CIDdate$PADlead_id"; $EAC=''; if ($use_eac > 0) diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 98db676a..582849ed 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -1579,6 +1579,10 @@ if (isset($_GET["status_display_fields"])) {$status_display_fields=$_GET["stat elseif (isset($_POST["status_display_fields"])) {$status_display_fields=$_POST["status_display_fields"];} if (isset($_GET["queuemetrics_pe_phone_append"])) {$queuemetrics_pe_phone_append=$_GET["queuemetrics_pe_phone_append"];} elseif (isset($_POST["queuemetrics_pe_phone_append"])) {$queuemetrics_pe_phone_append=$_POST["queuemetrics_pe_phone_append"];} +if (isset($_GET["test_campaign_calls"])) {$test_campaign_calls=$_GET["test_campaign_calls"];} + elseif (isset($_POST["test_campaign_calls"])) {$test_campaign_calls=$_POST["test_campaign_calls"];} +if (isset($_GET["agents_calls_reset"])) {$agents_calls_reset=$_GET["agents_calls_reset"];} + elseif (isset($_POST["agents_calls_reset"])) {$agents_calls_reset=$_POST["agents_calls_reset"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} @@ -1592,7 +1596,7 @@ if (strlen($dial_status) > 0) ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password FROM system_settings;"; +$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); @@ -1615,6 +1619,8 @@ if ($qm_conf_ct > 0) $SSdefault_phone_registration_password =$row[13]; $SSdefault_phone_login_password = $row[14]; $SSdefault_server_password = $row[15]; + $SStest_campaign_calls = $row[16]; + $SSactive_voicemail_server = $row[17]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -1821,6 +1827,8 @@ if ($non_latin < 1) $dtmf_log = ereg_replace("[^0-9]","",$dtmf_log); $callback_days_limit = ereg_replace("[^0-9]","",$callback_days_limit); $queuemetrics_pe_phone_append = ereg_replace("[^0-9]","",$queuemetrics_pe_phone_append); + $test_campaign_calls = ereg_replace("[^0-9]","",$test_campaign_calls); + $agents_calls_reset = ereg_replace("[^0-9]","",$agents_calls_reset); $drop_call_seconds = ereg_replace("[^-0-9]","",$drop_call_seconds); @@ -2770,16 +2778,20 @@ else # 110624-0842 - Added Export Leads Report links and permissions # 110624-2246 - Added Screen Labels subsection for Admin and status_display_fields feature # 110625-2338 - Added queuemetrics_pe_phone_append option +# 110703-1400 - Added test_campaign_calls and agents_calls_reset features # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.4-321a'; -$build = '110625-2338'; +$admin_version = '2.4-322a'; +$build = '110703-1400'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); $REPORTdate = date("Y-m-d"); +$CIDdate = date("mdHis"); +while (strlen($CIDdate) > 9) {$CIDdate = substr("$CIDdate", 1);} + $MT[0]=''; $US='_'; $active_lists=0; @@ -2787,6 +2799,7 @@ $inactive_lists=0; $modify_refresh_set=0; $modify_footer_refresh=0; $check_time = ($STARTtime - 86400); +$SSanswer_transfer_agent = '8368'; $month_old = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $past_month_date = date("Y-m-d H:i:s",$month_old); @@ -7345,6 +7358,11 @@ if ($ADD==99999)
Timeclock End Of Day - This setting defines when all users are to be auto logged out of the timeclock system. Only runs once a day. must be only 4 digits 2 digit hour and 2 digit minutes in 24 hour time. Default is 0000. +
+ +
+ Agents Calls Reset - This setting defines whether the logged-in agents and active phone calls records are to be reset at the timeclock end of day. Default is 1 for enabled. +

@@ -7473,6 +7491,11 @@ if ($ADD==99999)
Enable Custom List Fields - This setting enables the custom list fields feature that allows for custom data fields to be defined in the administration web interface on a per-list basis and then have those fields available in a FORM tab to the agent in the agent web interface. Default is 0 for disabled. +
+
+
+ Enable Campaign Test Calls - This setting enables the ability to enter a phone code and phone number into fields at the bottom of the Campaign Detail screen and place a phone call to that number as if it were a lead being auto-dialed in the system. The phone number will be stored as a new lead in the manual dial list ID list. The campaign must be active for this feature to be enabled, and it is recommended that the lists assigned to the campaign all be set to inactive. The dial prefix, dial timeout and all other dialing related features, except for DNC and call time options, will affect the dialing of the test number. The phone call will be placed on the server selected as the voicemail server in the system settings. Default is 0 for disabled. +

@@ -13470,31 +13493,116 @@ if ($ADD==41) $lead_order_randomize = 'N'; $lead_order_secondary = 'LEAD_ASCEND'; } - if (ereg('list_activation',$stage)) + if ( (ereg('list_activation',$stage)) or (ereg('test_call',$stage)) ) { - $p=0; - echo "
ACTIVE LISTS CHANGED"; - $list_active_change_ct = count($list_active_change); - while ($p < $list_active_change_ct) + if (ereg('test_call',$stage)) { - $LIST_ACTIVATE .= "'$list_active_change[$p]',"; - $p++; + $p=0; + echo "
TEST CALL:"; + + if (strlen($phone_number)<6) + { + echo " NOT PLACED, number too small - $phone_number"; + } + else + { + ### insert a new lead in the system with this phone number + $stmtA = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$manual_dial_list_id',status='CTCALL',user='VDAD',called_since_last_reset='Y',entry_date='$SQLdate',last_local_call_time='$SQLdate',called_count='1',first_name='Test',last_name='Call',address1='Test Call',city='Springfield',state='IL',vendor_lead_code='999999',comments='$campaign_id test call placed $SQLdate',rank='99',owner='Test Outbound Call';"; + if ($DB) {echo "$stmtA\n";} + $rslt=mysql_query($stmtA, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id($link); + + ### LOG INSERTION Admin Log Table, for lead ### + $SQL_log = "$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='ADD', record_id='$lead_id', event_code='ADMIN ADD TEST LEAD', event_sql=\"$SQL_log\", event_notes='';"; + $rslt=mysql_query($stmt, $link); + + ### gather list_id overrides + $stmt="SELECT campaign_cid_override FROM vicidial_lists where list_id='$manual_dial_list_id';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $CIDor_ct = mysql_num_rows($rslt); + $campaign_cid_override=''; + if ($CIDor_ct > 0) + { + $row=mysql_fetch_row($rslt); + $campaign_cid_override = $row[0]; + } + + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_vdad_exten) > 0) {$VDAD_dial_exten = "$campaign_vdad_exten";} + else {$VDAD_dial_exten = "$SSanswer_transfer_agent";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (strlen($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++;} + if (preg_match("/x/",$dial_prefix)) {$Local_out_prefix = '';} + if (strlen($ext_context) < 1) {$ext_context='default';} + if ($omit_phone_code > 0) {$Ndialstring = "$Local_out_prefix$phone_number";} + else {$Ndialstring = "$Local_out_prefix$phone_code$phone_number";} + + # generate callerID for unique identifier in xfer_log file + $PADlead_id = sprintf("%010s", $lead_id); while (strlen($PADlead_id) > 10) {$PADlead_id = substr("$PADlead_id", 1);} + # Create unique calleridname to track the call: VmddhhmmssLLLLLLLLLL + $VqueryCID = "V$CIDdate$PADlead_id"; + + if ($CCID_on) {$CIDstring = "\"$VqueryCID\" <$CCID>";} + else {$CIDstring = "$VqueryCID";} + + ### insert a NEW record to the vicidial_manager table to be processed + $stmtB = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$SSactive_voicemail_server','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','VDACnote: $campaign_id|$lead_id|$phone_code|$phone_number|OUT|MAIN|99')"; + $rslt=mysql_query($stmtB, $link); + + ### insert a SENT record to the vicidial_auto_calls table + $stmtC = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type,alt_dial,queue_priority) values('$SSactive_voicemail_server','$campaign_id','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUT','MAIN','99')"; + $rslt=mysql_query($stmtC, $link); + + ### LOG INSERTION Admin Log Table, for campaign ### + $SQL_log = "$stmtA|$stmtB|$stmtC|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='OTHER', record_id='$campaign_id', event_code='ADMIN CAMPAIGN TEST CALL', event_sql=\"$SQL_log\", event_notes='';"; + $rslt=mysql_query($stmt, $link); + + if ($DB > 0) {echo "|$stmtA|\n|$stmtB|\n|$stmtC|\n";} + echo " PLACED TO $phone_code $phone_number\n
"; + } } - - $stmt = "UPDATE vicidial_lists SET active='Y' where list_id IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';"; - $stmtB = "UPDATE vicidial_lists SET active='N' where list_id NOT IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';"; - $rslt=mysql_query($stmt, $link); - $rslt=mysql_query($stmtB, $link); - ### LOG INSERTION Admin Log Table ### - $SQL_log = "$stmt|$stmtB|"; - $SQL_log = ereg_replace(';','',$SQL_log); - $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN ACTIVE LISTS', event_sql=\"$SQL_log\", event_notes='';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); + if (ereg('list_activation',$stage)) + { + $p=0; + echo "
ACTIVE LISTS CHANGED"; + $list_active_change_ct = count($list_active_change); + while ($p < $list_active_change_ct) + { + $LIST_ACTIVATE .= "'$list_active_change[$p]',"; + $p++; + } + + $stmt = "UPDATE vicidial_lists SET active='Y' where list_id IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';"; + $stmtB = "UPDATE vicidial_lists SET active='N' where list_id NOT IN($LIST_ACTIVATE'') and campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $rslt=mysql_query($stmtB, $link); - if ($DB > 0) {echo "|$stmt|\n|$stmtB|\n";} + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtB|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN ACTIVE LISTS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ($DB > 0) {echo "|$stmt|\n|$stmtB|\n";} + } } else { @@ -15910,7 +16018,7 @@ if ($ADD==411111111111111) } $reports_use_slave_db = preg_replace("/,$/","",$new_field_value); - $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='$vtiger_url',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second',enable_tts_integration='$enable_tts_integration',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory',active_voicemail_server='$active_voicemail_server',auto_dial_limit='$auto_dial_limit',user_territories_active='$user_territories_active',allow_custom_dialplan='$allow_custom_dialplan',enable_second_webform='$enable_second_webform',default_webphone='$default_webphone',default_external_server_ip='$default_external_server_ip',webphone_url='" . mysql_real_escape_string($webphone_url) . "',enable_agc_dispo_log='$enable_agc_dispo_log',custom_dialplan_entry='$custom_dialplan_entry',queuemetrics_loginout='$queuemetrics_loginout',callcard_enabled='$callcard_enabled',queuemetrics_callstatus='$queuemetrics_callstatus',default_codecs='$default_codecs',admin_web_directory='$admin_web_directory',label_title='$label_title',label_first_name='$label_first_name',label_middle_initial='$label_middle_initial',label_last_name='$label_last_name',label_address1='$label_address1',label_address2='$label_address2',label_address3='$label_address3',label_city='$label_city',label_state='$label_state',label_province='$label_province',label_postal_code='$label_postal_code',label_vendor_lead_code='$label_vendor_lead_code',label_gender='$label_gender',label_phone_number='$label_phone_number',label_phone_code='$label_phone_code',label_alt_phone='$label_alt_phone',label_security_phrase='$label_security_phrase',label_email='$label_email',label_comments='$label_comments',custom_fields_enabled='$custom_fields_enabled',slave_db_server='$slave_db_server',reports_use_slave_db='$reports_use_slave_db',webphone_systemkey='$webphone_systemkey',first_login_trigger='$first_login_trigger',default_phone_registration_password='$default_phone_registration_password',default_phone_login_password='$default_phone_login_password',default_server_password='$default_server_password',admin_modify_refresh='$admin_modify_refresh',nocache_admin='$nocache_admin',generate_cross_server_exten='$generate_cross_server_exten',queuemetrics_addmember_enabled='$queuemetrics_addmember_enabled',queuemetrics_dispo_pause='$queuemetrics_dispo_pause',label_hide_field_logs='$label_hide_field_logs',queuemetrics_pe_phone_append='$queuemetrics_pe_phone_append';"; + $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='$vtiger_url',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second',enable_tts_integration='$enable_tts_integration',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory',active_voicemail_server='$active_voicemail_server',auto_dial_limit='$auto_dial_limit',user_territories_active='$user_territories_active',allow_custom_dialplan='$allow_custom_dialplan',enable_second_webform='$enable_second_webform',default_webphone='$default_webphone',default_external_server_ip='$default_external_server_ip',webphone_url='" . mysql_real_escape_string($webphone_url) . "',enable_agc_dispo_log='$enable_agc_dispo_log',custom_dialplan_entry='$custom_dialplan_entry',queuemetrics_loginout='$queuemetrics_loginout',callcard_enabled='$callcard_enabled',queuemetrics_callstatus='$queuemetrics_callstatus',default_codecs='$default_codecs',admin_web_directory='$admin_web_directory',label_title='$label_title',label_first_name='$label_first_name',label_middle_initial='$label_middle_initial',label_last_name='$label_last_name',label_address1='$label_address1',label_address2='$label_address2',label_address3='$label_address3',label_city='$label_city',label_state='$label_state',label_province='$label_province',label_postal_code='$label_postal_code',label_vendor_lead_code='$label_vendor_lead_code',label_gender='$label_gender',label_phone_number='$label_phone_number',label_phone_code='$label_phone_code',label_alt_phone='$label_alt_phone',label_security_phrase='$label_security_phrase',label_email='$label_email',label_comments='$label_comments',custom_fields_enabled='$custom_fields_enabled',slave_db_server='$slave_db_server',reports_use_slave_db='$reports_use_slave_db',webphone_systemkey='$webphone_systemkey',first_login_trigger='$first_login_trigger',default_phone_registration_password='$default_phone_registration_password',default_phone_login_password='$default_phone_login_password',default_server_password='$default_server_password',admin_modify_refresh='$admin_modify_refresh',nocache_admin='$nocache_admin',generate_cross_server_exten='$generate_cross_server_exten',queuemetrics_addmember_enabled='$queuemetrics_addmember_enabled',queuemetrics_dispo_pause='$queuemetrics_dispo_pause',label_hide_field_logs='$label_hide_field_logs',queuemetrics_pe_phone_append='$queuemetrics_pe_phone_append',test_campaign_calls='$test_campaign_calls',agents_calls_reset='$agents_calls_reset';"; $rslt=mysql_query($stmt, $link); if ($reload_dialplan_on_servers > 0) @@ -17058,7 +17166,7 @@ if ($ADD==62) } } - $stmt = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$VLA_user[$k]','LOGOUT','$VLA_campaign_id[$k]','$NOW_TIME','$now_date_epoch','$VAL_user_group');"; + $stmt = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$VLA_user[$k]','LOGOUT','$VLA_campaign_id[$k]','$SQLdate','$now_date_epoch','$VAL_user_group');"; if ($DB) {echo "
$stmt\n";} $rslt=mysql_query($stmt, $link); @@ -18850,6 +18958,7 @@ if ($ADD==31) $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $campaign_name = $row[1]; + $campaign_active = $row[2]; $dial_status_a = $row[3]; $dial_status_b = $row[4]; $dial_status_c = $row[5]; @@ -19297,7 +19406,7 @@ if ($ADD==31) echo "Campaign Change Date: $campaign_changedate   $NWB#vicidial_campaigns-campaign_changedate$NWE\n"; echo "Campaign Login Date: $campaign_logindate   $NWB#vicidial_campaigns-campaign_logindate$NWE\n"; echo "Campaign Call Date: $campaign_calldate   $NWB#vicidial_campaigns-campaign_calldate$NWE\n"; - echo "Active: $NWB#vicidial_campaigns-active$NWE\n"; + echo "Active: $NWB#vicidial_campaigns-active$NWE\n"; echo "Park Music-on-Hold:
moh chooser $NWB#vicidial_campaigns-park_ext$NWE\n"; echo "Web Form: $NWB#vicidial_campaigns-web_form_address$NWE\n"; if ($SSenable_second_webform > 0) @@ -20252,11 +20361,6 @@ if ($ADD==31) - - - - - echo "
\n"; if ($display_dialable_count == 'Y') @@ -20282,6 +20386,33 @@ if ($ADD==31) echo "Click here to see a VDAD report for this campaign

\n"; } echo "Click here to see all CallBack Holds in this campaign

\n"; + + if ($SSoutbound_autodial_active > 0) + { + if ( ($SStest_campaign_calls > 0) and ($campaign_active == 'Y') ) + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Test Outbound Call: "; + echo "code:   "; + echo "number:   "; + echo "   $NWB#settings-test_campaign_calls$NWE


\n"; + } + else + { + echo "Test calling disabled

\n"; + } + } + if ($LOGuser_level >= 9) { echo "

Click here to see Admin changes to this campaign\n"; @@ -26836,7 +26967,7 @@ if ($ADD==311111111111111) echo "\n"; echo "\n"; echo "\n"; + echo "\n"; echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; diff --git a/www/vicidial/admin_listloader_third_gen.php b/www/vicidial/admin_listloader_third_gen.php index 08c9b255..788e4ff9 100644 --- a/www/vicidial/admin_listloader_third_gen.php +++ b/www/vicidial/admin_listloader_third_gen.php @@ -41,10 +41,11 @@ # 100712-1416 - Added entry_list_id field to vicidial_list to preserve link to custom fields if any # 100728-0900 - Filtered uploaded filenames for unsupported characters # 110424-0926 - Added option for time zone code in the owner field +# 110705-1947 - Added USACAN check for prefix and areacode # -$version = '2.4-40'; -$build = '110424-0926'; +$version = '2.4-41'; +$build = '110705-1947'; require("dbconnect.php"); @@ -135,6 +136,9 @@ if (isset($_GET["phone_code_override"])) {$phone_code_override=$_GET["phone_co $phone_code_override = (preg_replace("/\D/","",$phone_code_override)); if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["usacan_check"])) {$usacan_check=$_GET["usacan_check"];} + elseif (isset($_POST["usacan_check"])) {$usacan_check=$_POST["usacan_check"];} + # if the didnt select an over ride wipe out in_file if ( $list_id_override == "in_file" ) { $list_id_override = ""; } @@ -334,10 +338,10 @@ function openNewWindow(url) { window.open (url,"",'width=700,height=300,scrollbars=yes,menubar=yes,address=yes'); } -function ShowProgress(good, bad, total, dup, post) +function ShowProgress(good, bad, total, dup, inv, post) { parent.lead_count.document.open(); - parent.lead_count.document.write('
\n"; echo ""; - $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append from system_settings;"; + $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append,test_campaign_calls,agents_calls_reset from system_settings;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $version = $row[0]; @@ -26928,6 +27059,8 @@ if ($ADD==311111111111111) $queuemetrics_dispo_pause = $row[86]; $label_hide_field_logs = $row[87]; $queuemetrics_pe_phone_append = $row[88]; + $test_campaign_calls = $row[89]; + $agents_calls_reset = $row[90]; echo "
MODIFY VICIDIAL SYSTEM SETTINGS
\n"; echo "\n"; @@ -26954,6 +27087,7 @@ if ($ADD==311111111111111) echo "
Enable Agent Transfer Logfile: $NWB#settings-enable_agc_xfer_log$NWE
Enable Agent Disposition Logfile: $NWB#settings-enable_agc_dispo_log$NWE
Timeclock End Of Day: $NWB#settings-timeclock_end_of_day$NWE
Agents Calls Reset: $NWB#settings-agents_calls_reset$NWE
Timeclock Last Auto Logout: $timeclock_last_reset_date
Agent Screen Header Date Format:
Enable Custom List Fields: $NWB#settings-custom_fields_enabled$NWE
Enable Campaign Test Calls: $NWB#settings-test_campaign_calls$NWE
First Login Trigger: $first_login_trigger   $NWB#settings-first_login_trigger$NWE
Default Phone Registration Password: $NWB#settings-default_phone_registration_password$NWE     Strength:
Current file status:
Good:'+good+'
Bad:'+bad+'
Total:'+total+'
   
Duplicate:'+dup+'
Postal Match:'+post+'
'); + parent.lead_count.document.write('
Current file status:
Good:'+good+'
Bad:'+bad+'
Total:'+total+'
   
Duplicate:'+dup+'
Invalid:'+inv+'
Postal Match:'+post+'
'); parent.lead_count.document.close(); } function ParseFileName() @@ -427,7 +431,7 @@ if ( (!$OK_to_process) or ( ($leadfile) and ($file_layout!="standard") ) ) File layout to use: Standard Format    Custom layout - + Lead Duplicate Check: + + USA-Canada Check: + + Lead Time Zone Lookup: @@ -468,6 +481,10 @@ else + USA-Canada Check: + + + Lead Duplicate Check: @@ -815,8 +832,37 @@ if ($OK_to_process) } } + $valid_number=1; + if ( (strlen($phone_number)<6) || (strlen($phone_number)>16) ) + { + $valid_number=0; + $invalid_reason = "INVALID PHONE NUMBER LENGTH"; + } + if ( (preg_match("/PREFIX/",$usacan_check)) and ($valid_number > 0) ) + { + $USprefix = substr($phone_number, 3, 1); + if ($DB>0) {echo "DEBUG: usacan prefix check - $USprefix|$phone_number\n";} + if ($USprefix < 2) + { + $valid_number=0; + $invalid_reason = "INVALID PHONE NUMBER PREFIX"; + } + } + if ( (preg_match("/AREACODE/",$usacan_check)) and ($valid_number > 0) ) + { + $phone_areacode = substr($phone_number, 0, 3); + $stmt = "select count(*) from vicidial_phone_codes where areacode='$phone_areacode' and country_code='1';"; + if ($DB>0) {echo "DEBUG: usacan areacode query - $stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $valid_number=$row[0]; + if ($valid_number < 1) + { + $invalid_reason = "INVALID PHONE NUMBER AREACODE"; + } + } - if ( (strlen($phone_number)>6) and ($dup_lead<1) and ($list_id >= 100 )) + if ( ($valid_number>0) and ($dup_lead<1) and ($list_id >= 100 )) { if (strlen($phone_code)<1) {$phone_code = '1';} @@ -873,7 +919,14 @@ if ($OK_to_process) } else { - print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead $dup_lead_list\n"; + if ($valid_number < 1) + { + print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| INV: $phone_number\n"; + } + else + { + print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead $dup_lead_list\n"; + } } } $bad++; @@ -881,7 +934,7 @@ if ($OK_to_process) $total++; if ($total%100==0) { - print ""; + print ""; usleep(1000); flush(); } @@ -1196,7 +1249,37 @@ if (($leadfile) && ($LF_path)) } } - if ( (strlen($phone_number)>6) and ($dup_lead<1) and ($list_id >= 100 )) + $valid_number=1; + if ( (strlen($phone_number)<6) || (strlen($phone_number)>16) ) + { + $valid_number=0; + $invalid_reason = "INVALID PHONE NUMBER LENGTH"; + } + if ( (preg_match("/PREFIX/",$usacan_check)) and ($valid_number > 0) ) + { + $USprefix = substr($phone_number, 3, 1); + if ($DB>0) {echo "DEBUG: usacan prefix check - $USprefix|$phone_number\n";} + if ($USprefix < 2) + { + $valid_number=0; + $invalid_reason = "INVALID PHONE NUMBER PREFIX"; + } + } + if ( (preg_match("/AREACODE/",$usacan_check)) and ($valid_number > 0) ) + { + $phone_areacode = substr($phone_number, 0, 3); + $stmt = "select count(*) from vicidial_phone_codes where areacode='$phone_areacode' and country_code='1';"; + if ($DB>0) {echo "DEBUG: usacan areacode query - $stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $valid_number=$row[0]; + if ($valid_number < 1) + { + $invalid_reason = "INVALID PHONE NUMBER AREACODE"; + } + } + + if ( ($valid_number>0) and ($dup_lead<1) and ($list_id >= 100 )) { if (strlen($phone_code)<1) {$phone_code = '1';} @@ -1234,7 +1317,14 @@ if (($leadfile) && ($LF_path)) } else { - print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead $dup_lead_list\n"; + if ($valid_number < 1) + { + print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| INV: $phone_number\n"; + } + else + { + print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead $dup_lead_list\n"; + } } } $bad++; @@ -1242,7 +1332,7 @@ if (($leadfile) && ($LF_path)) $total++; if ($total%100==0) { - print ""; + print ""; usleep(1000); flush(); } @@ -1422,6 +1512,7 @@ if (($leadfile) && ($LF_path)) } print " \r\n"; print " \r\n"; + print " \r\n"; print " \r\n"; print " \r\n"; print " \r\n"; diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index db332855..c4f2132a 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -49,10 +49,11 @@ # 110424-0854 - Added option for time zone code lookups using owner field # 110529-1220 - Added time zone information output to version function # 110614-0726 - Added reset_lead option to update_lead function(issue #502) +# 110705-1928 - Added options for USACAN 4th digit prefix(no 0 or 1) and valid areacode filtering to add_lead # -$version = '2.4-35'; -$build = '110614-0726'; +$version = '2.4-36'; +$build = '110705-1928'; $startMS = microtime(); @@ -245,8 +246,12 @@ if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} if (isset($_GET["tz_method"])) {$tz_method=$_GET["tz_method"];} elseif (isset($_POST["tz_method"])) {$tz_method=$_POST["tz_method"];} -if (isset($_GET["reset_lead"])) {$reset_lead=$_GET["reset_lead"];} +if (isset($_GET["reset_lead"])) {$reset_lead=$_GET["reset_lead"];} elseif (isset($_POST["reset_lead"])) {$reset_lead=$_POST["reset_lead"];} +if (isset($_GET["usacan_areacode_check"])) {$usacan_areacode_check=$_GET["usacan_areacode_check"];} + elseif (isset($_POST["usacan_areacode_check"])) {$usacan_areacode_check=$_POST["usacan_areacode_check"];} +if (isset($_GET["usacan_prefix_check"])) {$usacan_prefix_check=$_GET["usacan_prefix_check"];} + elseif (isset($_POST["usacan_prefix_check"])) {$usacan_prefix_check=$_POST["usacan_prefix_check"];} header ("Content-type: text/html; charset=utf-8"); @@ -374,6 +379,8 @@ if ($non_latin < 1) $uniqueid=ereg_replace("[^- \.\_0-9a-zA-Z]","",$uniqueid); $tz_method = ereg_replace("[^-\_0-9a-zA-Z]","",$tz_method); $reset_lead = ereg_replace("[^A-Z]","",$reset_lead); + $usacan_areacode_check = ereg_replace("[^A-Z]","",$usacan_areacode_check); + $usacan_prefix_check = ereg_replace("[^A-Z]","",$usacan_prefix_check); } else { @@ -2517,10 +2524,38 @@ if ($function == 'add_lead') if (strlen($list_id)<3) {$list_id='999';} if (strlen($phone_code)<1) {$phone_code='1';} + $valid_number=1; if ( (strlen($phone_number)<6) || (strlen($phone_number)>16) ) + { + $valid_number=0; + $result_reason = "add_lead INVALID PHONE NUMBER LENGTH"; + } + if ( ($usacan_prefix_check=='Y') and ($valid_number > 0) ) + { + $USprefix = substr($phone_number, 3, 1); + if ($DB>0) {echo "DEBUG: add_lead prefix check - $USprefix|$phone_number\n";} + if ($USprefix < 2) + { + $valid_number=0; + $result_reason = "add_lead INVALID PHONE NUMBER PREFIX"; + } + } + if ( ($usacan_areacode_check=='Y') and ($valid_number > 0) ) + { + $phone_areacode = substr($phone_number, 0, 3); + $stmt = "select count(*) from vicidial_phone_codes where areacode='$phone_areacode' and country_code='1';"; + if ($DB>0) {echo "DEBUG: add_lead areacode check query - $stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $valid_number=$row[0]; + if ($valid_number < 1) + { + $result_reason = "add_lead INVALID PHONE NUMBER AREACODE"; + } + } + if ($valid_number < 1) { $result = 'ERROR'; - $result_reason = "add_lead INVALID PHONE NUMBER"; echo "$result: $result_reason - $phone_number|$user\n"; $data = "$phone_number"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);