Added option in the web-based lead loader to convert state names to their

two-letter abbreviations.

git-svn-id: svn://192.168.202.10@2359 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2015-07-28 13:15:32 +00:00
parent 1bafb8dee7
commit 3f0c44ac82
4 changed files with 124 additions and 13 deletions
+3
View File
@@ -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.
@@ -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
+101 -13
View File
@@ -1,5 +1,5 @@
<?php
# admin_listloader_fourth_gen.php - version 2.10
# admin_listloader_fourth_gen.php - version 2.12
# (based upon - new_listloader_superL.php script)
#
# Copyright (C) 2015 Matt Florell,Joe Johnson <vicidial@gmail.com> 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
<option value="NANPA"><?php echo _QXZ("NANPA AREACODE PREFIX FIRST"); ?></option>
</select></td>
</tr>
<tr>
<td align=right width="25%"><font face="arial, helvetica" size=2><?php echo _QXZ("State Abbreviation Lookup"); ?>: </font></td>
<td align=left width="75%"><font face="arial, helvetica" size=1><select size=1 name=state_conversion>
<option selected value=""><?php echo _QXZ("DISABLED"); ?></option>
<option value="STATELOOKUP"><?php echo _QXZ("FULL STATE NAME TO ABBREVIATION"); ?></option>
</select></td>
</tr>
<tr>
<td align=center colspan=2><input type=submit value="<?php echo _QXZ("SUBMIT"); ?>" name='submit_file'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=button onClick="javascript:document.location='admin_listloader_fourth_gen.php'" value="<?php echo _QXZ("START OVER"); ?>" name='reload_page'></td>
</tr>
@@ -668,6 +679,11 @@ else
<td align=right width="35%"><B><font face="arial, helvetica" size=2><?php echo _QXZ("Lead Time Zone Lookup"); ?>:</font></B></td>
<td align=left width="75%"><font face="arial, helvetica" size=2><?php echo $postalgmt ?></font></td>
</tr>
<tr>
<td align=right width="35%"><B><font face="arial, helvetica" size=2><?php echo _QXZ("State Abbreviation Lookup"); ?>:</font></B></td>
<td align=left width="75%"><font face="arial, helvetica" size=2><?php echo $state_conversion ?></font></td>
</tr>
<tr>
<td align=center colspan=2><B><font face="arial, helvetica" size=2>
@@ -738,6 +754,10 @@ if ($OK_to_process)
{
print "<BR>"._QXZ("OMITTING DUPLICATES AGAINST FOLLOWING STATUSES ONLY").": $status_dedupe_str<BR>\n";
}
if (strlen($state_conversion)>9)
{
print "<BR>"._QXZ("CONVERSION OF STATE NAMES TO ABBREVIATIONS ENABLED").": $state_conversion<BR>\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 "<BR>"._QXZ("OMITTING DUPLICATES AGAINST FOLLOWING STATUSES ONLY").": ".preg_replace('/\'/', '', $template_statuses)."<BR>\n";
}
if (strlen($state_conversion)>9)
{
print "<BR>"._QXZ("CONVERSION OF STATE NAMES TO ABBREVIATIONS ENABLED").": $state_conversion<BR>\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 "<BR>"._QXZ("OMITTING DUPLICATES AGAINST FOLLOWING STATUSES ONLY").": $status_dedupe_str<BR>\n";
}
if (strlen($state_conversion)>9)
{
print "<BR>"._QXZ("CONVERSION OF STATE NAMES TO ABBREVIATIONS ENABLED").": $state_conversion<BR>\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 "<BR>"._QXZ("OMITTING DUPLICATES AGAINST FOLLOWING STATUSES ONLY").": $status_dedupe_str<BR>\n";
}
if (strlen($state_conversion)>9)
{
print "<BR>"._QXZ("CONVERSION OF STATE NAMES TO ABBREVIATIONS ENABLED").": $state_conversion<BR>\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 " <input type=hidden name=dedupe_statuses_override value=\"$status_dedupe_str\">\r\n";
print " <input type=hidden name=dupcheck value=\"$dupcheck\">\r\n";
print " <input type=hidden name=usacan_check value=\"$usacan_check\">\r\n";
print " <input type=hidden name=state_conversion value=\"$state_conversion\">\r\n";
print " <input type=hidden name=postalgmt value=\"$postalgmt\">\r\n";
print " <input type=hidden name=lead_file value=\"$lead_file\">\r\n";
print " <input type=hidden name=list_id_override value=\"$list_id_override\">\r\n";
+6
View File
@@ -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)
<BR>
<B><?php echo _QXZ("Template ID"); ?> -</B><?php echo _QXZ("If the user has selected Custom layout from the File layout options, then this the the template the lead loader will use. It will also override the selected list ID with the list ID that was assigned to the selected template when it was created."); ?>
<BR>
<A NAME="list_loader-state_conversion">
<BR>
<B><?php echo _QXZ("State Abbreviation Lookup"); ?> -</B><?php echo _QXZ("If your lead file has state names spelled out and you would like to load them into the state field as their two-character abbreviations, this feature will look up the abbreviation from the internal database. Default is DISABLED."); ?>
<BR><BR><BR><BR>