diff --git a/UPGRADE b/UPGRADE
index 6d1f09b2..c411b444 100644
--- a/UPGRADE
+++ b/UPGRADE
@@ -115,6 +115,9 @@ OTHER CHANGES:
21. Added campaign option to display some lead fields as read-only in the agent
screen. Those fields are: entry_date,source_id,date_of_birth,rank,owner
+22. Added option in the web-based lead loader to convert state names to their
+ two-letter abbreviations.
+
diff --git a/extras/testMULTI_VICIDIAL_lead_file_state_conv.txt b/extras/testMULTI_VICIDIAL_lead_file_state_conv.txt
new file mode 100644
index 00000000..0b47e30b
--- /dev/null
+++ b/extras/testMULTI_VICIDIAL_lead_file_state_conv.txt
@@ -0,0 +1,14 @@
+100001|10001|129|1|7275551213|MR|John|Q|Public01|249 MUNDON ROAD|||MALDON|Florida||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS
+100002|10002|129|1|3125551213|MR|John|Q|Public02|249 MUNDON ROAD|||MALDON|FLORIDA||33709|USA|M|1970-01-01|3125551212|test@test.com|nothing|COMMENTS
+100003|10003|129|1|3035551213|MR|John|Q|Public03|249 MUNDON ROAD|||MALDON|FLORida||33709|USA|M|1970-01-01|3035551212|test@test.com|nothing|COMMENTS
+100004|10004|129|1|8585551213|MR|John|Q|Public04|249 MUNDON ROAD|||MALDON|Georgia||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS
+100005|10005|129|44|7275551213|MR|John|Q|Public05|249 MUNDON ROAD|||MALDON|GA||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS
+100006|10006|129|61|727555121|MR|John|Q|Public06|249 MUNDON ROAD|||MALDON|NT||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS
+100007|10007|129|61|727555121|MR|John|Q|Public07|249 MUNDON ROAD|||MALDON|Nebraska||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS
+100008|10008|129|52|2485551213|MR|John|Q|Public08|249 MUNDON ROAD|||MALDON|ALBERTA||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS
+100009|10009|129|1|7275551213|MR|John|Q|Public09|249 MUNDON ROAD|||MALDON|New hampshire||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS
+100010|10010|129|1|8585551213|MR|John|Q|Public10|249 MUNDON ROAD|||MALDON|north carolina||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS
+100011|10011|129|1|3035551213|MR|John|Q|Public11|249 MUNDON ROAD|||MALDON|mississippi||33709|USA|M|1970-01-01|3035551212|test@test.com|nothing|COMMENTS
+100012|10012|129|1|3125551213|MR|John|Q|Public12|249 MUNDON ROAD|||MALDON|Massachusetts||33709|USA|M|1970-01-01|3125551212|test@test.com|nothing|COMMENTS
+100013|10013|129|1|7275551213|MR|John|Q|Public13|249 MUNDON ROAD|||MALDON|Guam||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS
+100014|10014|129|1|7275551213|MR|John|Q|Public14|249 MUNDON ROAD|||MALDON|Kansas||33709|USA|M|1970-01-01|7275551212|test@test.com|nothing|COMMENTS
diff --git a/www/vicidial/admin_listloader_fourth_gen.php b/www/vicidial/admin_listloader_fourth_gen.php
index 525ad4db..769cba1a 100644
--- a/www/vicidial/admin_listloader_fourth_gen.php
+++ b/www/vicidial/admin_listloader_fourth_gen.php
@@ -1,5 +1,5 @@
LICENSE: AGPLv2
@@ -61,10 +61,11 @@
# 150209-2113 - Added master_list_override option to override template setting
# 150312-1505 - Allow for single quotes in vicidial_list data fields
# 150516-1136 - Fixed conflict with functions.php
+# 150728-0732 - Added state fullname to abbreviation conversion feature (state_conversion)
#
-$version = '2.12-59';
-$build = '150516-1136';
+$version = '2.12-60';
+$build = '150728-0732';
require("dbconnect_mysqli.php");
require("functions.php");
@@ -164,6 +165,8 @@ if (isset($_GET["template_id"])) {$template_id=$_GET["template_id"];}
elseif (isset($_POST["template_id"])) {$template_id=$_POST["template_id"];}
if (isset($_GET["usacan_check"])) {$usacan_check=$_GET["usacan_check"];}
elseif (isset($_POST["usacan_check"])) {$usacan_check=$_POST["usacan_check"];}
+if (isset($_GET["state_conversion"])) {$state_conversion=$_GET["state_conversion"];}
+ elseif (isset($_POST["state_conversion"])) {$state_conversion=$_POST["state_conversion"];}
if (strlen($dedupe_statuses_override)>0) {
$dedupe_statuses=explode(",", $dedupe_statuses_override);
@@ -631,6 +634,14 @@ if ( (!$OK_to_process) or ( ($leadfile) and ($file_layout!="standard" && $file_l
+
@@ -738,6 +754,10 @@ if ($OK_to_process)
{
print " "._QXZ("OMITTING DUPLICATES AGAINST FOLLOWING STATUSES ONLY").": $status_dedupe_str \n";
}
+ if (strlen($state_conversion)>9)
+ {
+ print " "._QXZ("CONVERSION OF STATE NAMES TO ABBREVIATIONS ENABLED").": $state_conversion \n";
+ }
if ($custom_fields_enabled > 0)
{
@@ -861,6 +881,25 @@ if ($OK_to_process)
{
$phone_code = $phone_code_override;
}
+ if (strlen($phone_code)<1) {$phone_code = '1';}
+
+ if ( ($state_conversion == 'STATELOOKUP') and (strlen($state) > 3) )
+ {
+ $stmt = "select state from vicidial_phone_codes where geographic_description='$state' and country_code='$phone_code' limit 1;";
+ if ($DB>0) {echo "DEBUG: state conversion query - $stmt\n";}
+ $rslt=mysql_to_mysqli($stmt, $link);
+ $sc_recs = mysqli_num_rows($rslt);
+ if ($sc_recs > 0)
+ {
+ $row=mysqli_fetch_row($rslt);
+ $state_abbr=$row[0];
+ if ( (strlen($state_abbr) > 0) and (strlen($state_abbr) < 3 ) )
+ {
+ if ($DB>0) {echo "DEBUG: state conversion found - $state|$state_abbr\n";}
+ $state = $state_abbr;
+ }
+ }
+ }
##### BEGIN custom fields columns list ###
$custom_SQL='';
@@ -1077,8 +1116,6 @@ if ($OK_to_process)
if ( ($valid_number>0) and ($dup_lead<1) and ($list_id >= 100 ))
{
- if (strlen($phone_code)<1) {$phone_code = '1';}
-
if (preg_match("/TITLEALTPHONE/i",$dupcheck))
{$phone_list .= "$alt_phone$title$US$list_id|";}
else
@@ -1162,7 +1199,7 @@ if ($OK_to_process)
}
### LOG INSERTION Admin Log Table ###
- $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='LOAD', record_id='$list_id_override', event_code='ADMIN LOAD LIST CUSTOM', event_sql='', event_notes='File Name: $leadfile_name, GOOD: $good, BAD: $bad, TOTAL: $total, DEBUG: dedupe_statuses:$dedupe_statuses[0]| dedupe_statuses_override:$dedupe_statuses_override| dupcheck:$dupcheck| lead_file:$lead_file| list_id_override:$list_id_override| phone_code_override:$phone_code_override| postalgmt:$postalgmt| template_id:$template_id| usacan_check:$usacan_check|';";
+ $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='LOAD', record_id='$list_id_override', event_code='ADMIN LOAD LIST CUSTOM', event_sql='', event_notes='File Name: $leadfile_name, GOOD: $good, BAD: $bad, TOTAL: $total, DEBUG: dedupe_statuses:$dedupe_statuses[0]| dedupe_statuses_override:$dedupe_statuses_override| dupcheck:$dupcheck| lead_file:$lead_file| list_id_override:$list_id_override| phone_code_override:$phone_code_override| postalgmt:$postalgmt| template_id:$template_id| usacan_check:$usacan_check| state_conversion:$state_conversion|';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
@@ -1180,7 +1217,7 @@ if (($leadfile) && ($LF_path))
$total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list='';
### LOG INSERTION Admin Log Table ###
- $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='LOAD', record_id='$list_id_override', event_code='ADMIN LOAD LIST', event_sql='', event_notes='File Name: $leadfile_name, DEBUG: dedupe_statuses:$dedupe_statuses[0]| dedupe_statuses_override:$dedupe_statuses_override| dupcheck:$dupcheck| lead_file:$lead_file| list_id_override:$list_id_override| phone_code_override:$phone_code_override| postalgmt:$postalgmt| template_id:$template_id| usacan_check:$usacan_check|';";
+ $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='LOAD', record_id='$list_id_override', event_code='ADMIN LOAD LIST', event_sql='', event_notes='File Name: $leadfile_name, DEBUG: dedupe_statuses:$dedupe_statuses[0]| dedupe_statuses_override:$dedupe_statuses_override| dupcheck:$dupcheck| lead_file:$lead_file| list_id_override:$list_id_override| phone_code_override:$phone_code_override| postalgmt:$postalgmt| template_id:$template_id| usacan_check:$usacan_check| state_conversion:$state_conversion|';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
@@ -1307,6 +1344,11 @@ if (($leadfile) && ($LF_path))
{
print " "._QXZ("OMITTING DUPLICATES AGAINST FOLLOWING STATUSES ONLY").": ".preg_replace('/\'/', '', $template_statuses)." \n";
}
+ if (strlen($state_conversion)>9)
+ {
+ print " "._QXZ("CONVERSION OF STATE NAMES TO ABBREVIATIONS ENABLED").": $state_conversion \n";
+ }
+
while (!feof($file))
{
$record++;
@@ -1394,6 +1436,26 @@ if (($leadfile) && ($LF_path))
{
$phone_code = $phone_code_override;
}
+ if (strlen($phone_code)<1) {$phone_code = '1';}
+
+ if ( ($state_conversion == 'STATELOOKUP') and (strlen($state) > 3) )
+ {
+ $stmt = "select state from vicidial_phone_codes where geographic_description='$state' and country_code='$phone_code' limit 1;";
+ if ($DB>0) {echo "DEBUG: state conversion query - $stmt\n";}
+ $rslt=mysql_to_mysqli($stmt, $link);
+ $sc_recs = mysqli_num_rows($rslt);
+ if ($sc_recs > 0)
+ {
+ $row=mysqli_fetch_row($rslt);
+ $state_abbr=$row[0];
+ if ( (strlen($state_abbr) > 0) and (strlen($state_abbr) < 3 ) )
+ {
+ if ($DB>0) {echo "DEBUG: state conversion found - $state|$state_abbr\n";}
+ $state = $state_abbr;
+ }
+ }
+ }
+
##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign #####
if (preg_match("/DUPCAMP/i",$dupcheck))
@@ -1566,8 +1628,6 @@ if (($leadfile) && ($LF_path))
if ( ($valid_number>0) and ($dup_lead<1) and ($list_id >= 100 ))
{
- if (strlen($phone_code)<1) {$phone_code = '1';}
-
if (preg_match("/TITLEALTPHONE/i",$dupcheck))
{$phone_list .= "$alt_phone$title$US$list_id|";}
else
@@ -1693,7 +1753,7 @@ if (($leadfile) && ($LF_path))
{fwrite($stmt_file, $custom_ins_stmt."\r\n");}
}
### LOG INSERTION Admin Log Table ###
- $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='LOAD', record_id='$list_id_override', event_code='ADMIN LOAD LIST STANDARD', event_sql='', event_notes='File Name: $leadfile_name, GOOD: $good, BAD: $bad, TOTAL: $total, DEBUG: dedupe_statuses:$dedupe_statuses[0]| dedupe_statuses_override:$dedupe_statuses_override| dupcheck:$dupcheck| lead_file:$lead_file| list_id_override:$list_id_override| phone_code_override:$phone_code_override| postalgmt:$postalgmt| template_id:$template_id| usacan_check:$usacan_check|';";
+ $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='LOAD', record_id='$list_id_override', event_code='ADMIN LOAD LIST STANDARD', event_sql='', event_notes='File Name: $leadfile_name, GOOD: $good, BAD: $bad, TOTAL: $total, DEBUG: dedupe_statuses:$dedupe_statuses[0]| dedupe_statuses_override:$dedupe_statuses_override| dupcheck:$dupcheck| lead_file:$lead_file| list_id_override:$list_id_override| phone_code_override:$phone_code_override| postalgmt:$postalgmt| template_id:$template_id| usacan_check:$usacan_check| state_conversion:$state_conversion|';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
@@ -1795,6 +1855,11 @@ if (($leadfile) && ($LF_path))
{
print " "._QXZ("OMITTING DUPLICATES AGAINST FOLLOWING STATUSES ONLY").": $status_dedupe_str \n";
}
+ if (strlen($state_conversion)>9)
+ {
+ print " "._QXZ("CONVERSION OF STATE NAMES TO ABBREVIATIONS ENABLED").": $state_conversion \n";
+ }
+
while (!feof($file))
{
$record++;
@@ -1878,6 +1943,25 @@ if (($leadfile) && ($LF_path))
{
$phone_code = $phone_code_override;
}
+ if (strlen($phone_code)<1) {$phone_code = '1';}
+
+ if ( ($state_conversion == 'STATELOOKUP') and (strlen($state) > 3) )
+ {
+ $stmt = "select state from vicidial_phone_codes where geographic_description='$state' and country_code='$phone_code' limit 1;";
+ if ($DB>0) {echo "DEBUG: state conversion query - $stmt\n";}
+ $rslt=mysql_to_mysqli($stmt, $link);
+ $sc_recs = mysqli_num_rows($rslt);
+ if ($sc_recs > 0)
+ {
+ $row=mysqli_fetch_row($rslt);
+ $state_abbr=$row[0];
+ if ( (strlen($state_abbr) > 0) and (strlen($state_abbr) < 3 ) )
+ {
+ if ($DB>0) {echo "DEBUG: state conversion found - $state|$state_abbr\n";}
+ $state = $state_abbr;
+ }
+ }
+ }
##### Check for duplicate phone numbers in vicidial_list table for all lists in a campaign #####
if (preg_match("/DUPCAMP/i",$dupcheck))
@@ -2050,8 +2134,6 @@ if (($leadfile) && ($LF_path))
if ( ($valid_number>0) and ($dup_lead<1) and ($list_id >= 100 ))
{
- if (strlen($phone_code)<1) {$phone_code = '1';}
-
if (preg_match("/TITLEALTPHONE/i",$dupcheck))
{$phone_list .= "$alt_phone$title$US$list_id|";}
else
@@ -2115,7 +2197,7 @@ if (($leadfile) && ($LF_path))
{fwrite($stmt_file, $stmtZ."\r\n");}
}
### LOG INSERTION Admin Log Table ###
- $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='LOAD', record_id='$list_id_override', event_code='ADMIN LOAD LIST STANDARD', event_sql='', event_notes='File Name: $leadfile_name, GOOD: $good, BAD: $bad, TOTAL: $total, DEBUG: dedupe_statuses:$dedupe_statuses[0]| dedupe_statuses_override:$dedupe_statuses_override| dupcheck:$dupcheck| lead_file:$lead_file| list_id_override:$list_id_override| phone_code_override:$phone_code_override| postalgmt:$postalgmt| template_id:$template_id| usacan_check:$usacan_check|';";
+ $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='LOAD', record_id='$list_id_override', event_code='ADMIN LOAD LIST STANDARD', event_sql='', event_notes='File Name: $leadfile_name, GOOD: $good, BAD: $bad, TOTAL: $total, DEBUG: dedupe_statuses:$dedupe_statuses[0]| dedupe_statuses_override:$dedupe_statuses_override| dupcheck:$dupcheck| lead_file:$lead_file| list_id_override:$list_id_override| phone_code_override:$phone_code_override| postalgmt:$postalgmt| template_id:$template_id| usacan_check:$usacan_check| state_conversion:$state_conversion|';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
@@ -2269,6 +2351,11 @@ if (($leadfile) && ($LF_path))
{
print " "._QXZ("OMITTING DUPLICATES AGAINST FOLLOWING STATUSES ONLY").": $status_dedupe_str \n";
}
+ if (strlen($state_conversion)>9)
+ {
+ print " "._QXZ("CONVERSION OF STATE NAMES TO ABBREVIATIONS ENABLED").": $state_conversion \n";
+ }
+
$buffer=rtrim(fgets($file, 4096));
$buffer=stripslashes($buffer);
$row=explode($delimiter, preg_replace('/[\"]/i', '', $buffer));
@@ -2301,6 +2388,7 @@ if (($leadfile) && ($LF_path))
print " \r\n";
print " \r\n";
print " \r\n";
+ print " \r\n";
print " \r\n";
print " \r\n";
print " \r\n";
diff --git a/www/vicidial/help.php b/www/vicidial/help.php
index 09fe0b7a..fbb6774c 100644
--- a/www/vicidial/help.php
+++ b/www/vicidial/help.php
@@ -55,6 +55,7 @@
# 150724-0047 - Added agent_debug_logging
# 150725-1406 - Added agent_display_fields
# 150727-1039 - Added default_language
+# 150728-0904 - Added state_conversion for list loader
#
require("dbconnect_mysqli.php");
@@ -3659,6 +3660,11 @@ if ($SSoutbound_autodial_active > 0)
-
+
+
+
+ -
+
|