added postal code search and duplicate options to super listloader web lead loader scripts

git-svn-id: svn://192.168.202.10@412 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2006-11-28 17:52:02 +00:00
parent b2704d6293
commit 5a730ea177
5 changed files with 347 additions and 97 deletions
+2 -1
View File
@@ -120,7 +120,7 @@ function openNewWindow(url) {
}
function ShowProgress(good, bad, total, dup, post) {
parent.lead_count.document.open();
parent.lead_count.document.write('<html><body><table border=0 width=200 cellpadding=10 cellspacing=0 align=center valign=top><tr bgcolor="#000000"><th colspan=2><font face="arial, helvetica" size=3 color=white>Current file status:</font></th></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Good:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+good+'</B></font></td></tr><tr bgcolor="#990000"><td align=right><font face="arial, helvetica" size=2 color=white><B>Bad:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+bad+'</B></font></td></tr><tr bgcolor="#000099"><td align=right><font face="arial, helvetica" size=2 color=white><B>Total:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+total+'</B></font></td></tr> <tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B> &nbsp; </B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B> &nbsp; </B></font></td></tr></table><body></html><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Duplicate:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+dup+'</B></font></td></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Postal Match:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+post+'</B></font></td></tr>');
parent.lead_count.document.write('<html><body><table border=0 width=200 cellpadding=10 cellspacing=0 align=center valign=top><tr bgcolor="#000000"><th colspan=2><font face="arial, helvetica" size=3 color=white>Current file status:</font></th></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Good:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+good+'</B></font></td></tr><tr bgcolor="#990000"><td align=right><font face="arial, helvetica" size=2 color=white><B>Bad:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+bad+'</B></font></td></tr><tr bgcolor="#000099"><td align=right><font face="arial, helvetica" size=2 color=white><B>Total:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+total+'</B></font></td></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B> &nbsp; </B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B> &nbsp; </B></font></td></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Duplicate:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+dup+'</B></font></td></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Postal Match:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+post+'</B></font></td></tr></table><body></html>');
parent.lead_count.document.close();
}
</script>
@@ -250,6 +250,7 @@ if ($leadfile and filesize($LF_path)<=8388608) {
if ( (strlen($phone_number)>6) and ($dup_lead<1) )
{
$US='_';
$entry_date = "$pulldate";
$modify_date = "";
$status = "NEW";
+56 -4
View File
@@ -14,6 +14,7 @@
# 60822-1121 - fixed for nonwritable directories
# 60906-1058 - added filter of non-digits in alt_phone field
# 61110-1229 - added new USA-Canada DST scheme and Brazil DST scheme
# 61128-1215 - added postal code GMT lookup and duplicate check options
#
### begin parsing run-time options ###
@@ -29,9 +30,15 @@ if (length($ARGV[0])>1)
if ($args =~ /--help|-h/i)
{
print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n";
exit;
}
else
{
if ($args =~ /-duplicate-check/i)
{$dupcheck=1;}
if ($args =~ /-postal-code-gmt/i)
{$postalgmt=1;}
if ($args =~ /--forcelistid=/i)
{
@data_in = split(/--forcelistid=/,$args);
@@ -216,12 +223,56 @@ foreach $oWkS (@{$oBook->{Worksheet}}) {
if ($oWkC) {$comments=$oWkC->Value; }
$comments=~s/^\s*(.*?)\s*$/$1/;
if (length($phone_number)>6) {
if (length($forcelistid) > 0)
if (length($forcelistid) > 0)
{
$list_id = $forcelistid; # set list_id to override value
}
if ($dupcheck > 0)
{
$dup_lead=0;
$stmtA = "select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@aryA = $sthA->fetchrow_array;
$dup_lead = $aryA[0];
$sthA->finish();
if ($dup_lead < 1)
{
$list_id = $forcelistid; # set list_id to override value
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
if ( (length($phone_number)>6) && ($dup_lead < 1) )
{
$phone_list .= "$phone_number$US$list_id|";
$postalgmt_found=0;
if ( ($postalgmt > 0) && (length($postal_code)>4) )
{
if ($phone_code =~ /^1$/)
{
$stmtA = "select * from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";";
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;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$gmt_offset = $aryA[2]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[3];
$dst_range = $aryA[4];
$PC_processed++;
$rec_count++;
$postalgmt_found++;
if ($DBX) {print " Postal GMT record found for $postal_code: |$gmt_offset|$dst|$dst_range|\n";}
}
$sthA->finish();
}
}
if ($postalgmt_found < 1)
{
$PC_processed=0;
### UNITED STATES ###
if ($phone_code =~ /^1$/)
@@ -303,6 +354,7 @@ foreach $oWkS (@{$oBook->{Worksheet}}) {
}
$sthA->finish();
}
}
### Find out if DST to raise the gmt offset ###
$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD);
@@ -24,9 +24,15 @@ if (length($ARGV[0])>1)
if ($args =~ /--help|-h/i)
{
print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n";
exit;
}
else
{
if ($args =~ /-duplicate-check/i)
{$dupcheck=1;}
if ($args =~ /-postal-code-gmt/i)
{$postalgmt=1;}
if ($args =~ /--lead-file=/i)
{
@data_in = split(/--lead-file=/,$args);
+60 -6
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
### listloader_super.pl version 0.2 *DBI-version*
### listloader_super.pl version 0.3 *DBI-version*
###
### Copyright (C) 2006 Matt Florell,Joe Johnson <vicidial@gmail.com> LICENSE: GPLv2
###
@@ -13,6 +13,7 @@
# 60811-1329 - changed to use /etc/astguiclient.conf for configs
# 60906-1056 - added filter of non-digits in alt_phone field
# 61110-1229 - added new USA-Canada DST scheme and Brazil DST scheme
# 61128-1207 - added postal code GMT lookup and duplicate check options
#
### begin parsing run-time options ###
@@ -28,9 +29,15 @@ if (length($ARGV[0])>1)
if ($args =~ /--help|-h/i)
{
print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n";
exit;
}
else
{
if ($args =~ /-duplicate-check/i)
{$dupcheck=1;}
if ($args =~ /-postal-code-gmt/i)
{$postalgmt=1;}
if ($args =~ /--forcelistid=/i)
{
@data_in = split(/--forcelistid=/,$args);
@@ -216,12 +223,58 @@ foreach $oWkS (@{$oBook->{Worksheet}}) {
if ($oWkC) {$comments=$oWkC->Value; }
$comments=~s/^\s*(.*?)\s*$/$1/;
if (length($phone_number)>6) {
if (length($forcelistid) > 0)
{
$list_id = $forcelistid; # set list_id to override value
}
if (length($forcelistid) > 0)
{
$list_id = $forcelistid; # set list_id to override value
}
if ($dupcheck > 0)
{
$dup_lead=0;
$stmtA = "select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@aryA = $sthA->fetchrow_array;
$dup_lead = $aryA[0];
$sthA->finish();
if ($dup_lead < 1)
{
if ($phone_list =~ /\|$phone_number$US$list_id\|/)
{$dup_lead++;}
}
}
if ( (length($phone_number)>6) && ($dup_lead < 1) )
{
$phone_list .= "$phone_number$US$list_id|";
$postalgmt_found=0;
if ( ($postalgmt > 0) && (length($postal_code)>4) )
{
if ($phone_code =~ /^1$/)
{
$stmtA = "select * from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";";
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;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$gmt_offset = $aryA[2]; $gmt_offset =~ s/\+| //gi;
$dst = $aryA[3];
$dst_range = $aryA[4];
$PC_processed++;
$rec_count++;
$postalgmt_found++;
if ($DBX) {print " Postal GMT record found for $postal_code: |$gmt_offset|$dst|$dst_range|\n";}
}
$sthA->finish();
}
}
if ($postalgmt_found < 1)
{
$PC_processed=0;
### UNITED STATES ###
if ($phone_code =~ /^1$/)
@@ -303,6 +356,7 @@ foreach $oWkS (@{$oBook->{Worksheet}}) {
}
$sthA->finish();
}
}
### Find out if DST to raise the gmt offset ###
$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD);
@@ -16,11 +16,12 @@
# 60822-1121 - fixed for nonwritable directories
# 60906-1100 - added filter of non-digits in alt_phone field
# 61110-1222 - added new USA-Canada DST scheme and Brazil DST scheme
# 61128-1149 - added postal code GMT lookup and duplicate check options
#
# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time.
$version = '2.0.2';
$build = '61110-1222';
$build = '61128-1149';
require("dbconnect.php");
@@ -99,6 +100,10 @@ if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_overr
$list_id_override = (preg_replace("/\D/","",$list_id_override));
if (isset($_GET["lead_file"])) {$lead_file=$_GET["lead_file"];}
elseif (isset($_POST["lead_file"])) {$lead_file=$_POST["lead_file"];}
if (isset($_GET["dupcheck"])) {$dupcheck=$_GET["dupcheck"];}
elseif (isset($_POST["dupcheck"])) {$dupcheck=$_POST["dupcheck"];}
if (isset($_GET["postalgmt"])) {$postalgmt=$_GET["postalgmt"];}
elseif (isset($_POST["postalgmt"])) {$postalgmt=$_POST["postalgmt"];}
# $country_field=$_GET["country_field"]; if (!$country_field) {$country_field=$_POST["country_field"];}
@@ -262,9 +267,9 @@ A.employee_standard { font-family: garamond, sans-serif; font-size: ".macfontfi
function openNewWindow(url) {
window.open (url,"",'width=500,height=300,scrollbars=yes,menubar=yes,address=yes');
}
function ShowProgress(good, bad, total) {
function ShowProgress(good, bad, total, dup, post) {
parent.lead_count.document.open();
parent.lead_count.document.write('<html><body><table border=0 width=200 cellpadding=10 cellspacing=0 align=center valign=top><tr bgcolor="#000000"><th colspan=2><font face="arial, helvetica" size=3 color=white>Current file status:</font></th></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Good:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+good+'</B></font></td></tr><tr bgcolor="#990000"><td align=right><font face="arial, helvetica" size=2 color=white><B>Bad:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+bad+'</B></font></td></tr><tr bgcolor="#000099"><td align=right><font face="arial, helvetica" size=2 color=white><B>Total:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+total+'</B></font></td></tr></table><body></html>');
parent.lead_count.document.write('<html><body><table border=0 width=200 cellpadding=10 cellspacing=0 align=center valign=top><tr bgcolor="#000000"><th colspan=2><font face="arial, helvetica" size=3 color=white>Current file status:</font></th></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Good:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+good+'</B></font></td></tr><tr bgcolor="#990000"><td align=right><font face="arial, helvetica" size=2 color=white><B>Bad:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+bad+'</B></font></td></tr><tr bgcolor="#000099"><td align=right><font face="arial, helvetica" size=2 color=white><B>Total:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+total+'</B></font></td></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B> &nbsp; </B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B> &nbsp; </B></font></td></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Duplicate:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+dup+'</B></font></td></tr><tr bgcolor="#009900"><td align=right><font face="arial, helvetica" size=2 color=white><B>Postal Match:</B></font></td><td align=left><font face="arial, helvetica" size=2 color=white><B>'+post+'</B></font></td></tr></table><body></html>');
parent.lead_count.document.close();
}
function ParseFileName() {
@@ -296,8 +301,16 @@ function ParseFileName() {
<tr>
<td align=right><B><font face="arial, helvetica" size=2>File layout to use:</font></B></td>
<td align=left><font face="arial, helvetica" size=2><input type=radio name="file_layout" value="standard" checked>Standard VICIDIAL&nbsp;&nbsp;&nbsp;&nbsp;<input type=radio name="file_layout" value="custom">Custom layout</td>
</tr>
<tr>
<td align=right width="25%"><font face="arial, helvetica" size=2>Lead Duplicate Check: </font></td>
<td align=left width="75%"><font face="arial, helvetica" size=1><select size=1 name=dupcheck><option selected value="NONE">NO DUPLICATE CHECK</option><option value="DUP">CHECK FOR DUPLICATES BY PHONE IN LIST ID</option></select></td>
</tr>
<tr>
<td align=right width="25%"><font face="arial, helvetica" size=2>Lead Timezone Lookup: </font></td>
<td align=left width="75%"><font face="arial, helvetica" size=1><select size=1 name=postalgmt><option selected value="AREA">COUNTRY CODE AND AREA CODE ONLY</option><option value="POSTAL">POSTAL CODE FIRST</option></select></td>
</tr>
<tr>
<td align=center colspan=2><input type=submit value="SUBMIT" name='submit_file'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=button onClick="javascript:document.location='new_listloader_superL.php'" value="START OVER" name='reload_page'></td>
</tr>
<tr><td colspan=2><font size=1><a href="listloaderMAIN.php" target="_parent">CLICK HERE TO GO TO THE BASIC LEAD LOADER </a> &nbsp; &nbsp; &nbsp; &nbsp; <a href="admin.php" target="_parent">BACK TO ADMIN</a></font></td></tr>
@@ -310,7 +323,7 @@ function ParseFileName() {
if ($OK_to_process) {
print "<script language='JavaScript1.2'>document.forms[0].leadfile.disabled=true;document.forms[0].list_id_override.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;</script>";
flush();
$total=0; $good=0; $bad=0;
$total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list='';
if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) {
# copy($leadfile, "./vicidial_temp_file.txt");
@@ -377,16 +390,38 @@ function ParseFileName() {
$security_phrase = $row[$security_phrase_field];
$comments = trim($row[$comments_field]);
if (strlen($phone_number)>6) {
if (strlen($list_id_override)>0)
{
# print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>";
$list_id = $list_id_override;
}
if (strlen($list_id_override)>0)
##### Check for duplicate phone numbers in vicidial_list table #####
if (eregi("DUP",$dupcheck))
{
$dup_lead=0;
$stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
# print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>";
$list_id = $list_id_override;
$row=mysql_fetch_row($rslt);
$dup_lead = $row[0];
}
if ($dup_lead < 1)
{
if (eregi("$phone_number$US$list_id",$phone_list))
{$dup_lead++; $dup++;}
}
}
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear);
if ( (strlen($phone_number)>6) and ($dup_lead<1) )
{
$US='_';
$phone_list .= "$phone_number$US$list_id|";
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code);
if ($multi_insert_counter > 8) {
### insert good deal into pending_transactions table ###
@@ -404,12 +439,12 @@ function ParseFileName() {
$good++;
} else {
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]|</font><b>\n";}
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead</font><b>\n";}
$bad++;
}
$total++;
if ($total%100==0) {
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total)</script>";
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total, $dup, $post)</script>";
usleep(1000);
flush();
}
@@ -437,7 +472,10 @@ function ParseFileName() {
print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>\n";
}
# print "|$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override --lead_file=$lead_file|";
passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override --lead-file=$lead_file");
$dupcheckCLI=''; $postalgmtCLI='';
if (eregi("DUP",$dupcheck)) {$dupcheckCLI='--duplicate-check';}
if (eregi("POSTAL",$postalgmt)) {$postalgmtCLI='--postal-code-gmt';}
passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override --lead-file=$lead_file $postalgmtCLI $dupcheckCLI");
} else {
# copy($leadfile, "./vicidial_temp_file.csv");
$file=fopen("$lead_file", "r");
@@ -486,15 +524,38 @@ function ParseFileName() {
$security_phrase = $row[$security_phrase_field];
$comments = trim($row[$comments_field]);
if (strlen($phone_number)>6) {
if (strlen($list_id_override)>0)
{
# print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>";
$list_id = $list_id_override;
}
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear);
##### Check for duplicate phone numbers in vicidial_list table #####
if (eregi("DUP",$dupcheck))
{
$dup_lead=0;
$stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$dup_lead = $row[0];
}
if ($dup_lead < 1)
{
if (eregi("$phone_number$US$list_id",$phone_list))
{$dup_lead++; $dup++;}
}
}
if ( (strlen($phone_number)>6) and ($dup_lead<1) )
{
$US='_';
$phone_list .= "$phone_number$US$list_id|";
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code);
if ($multi_insert_counter > 8) {
@@ -513,12 +574,12 @@ function ParseFileName() {
$good++;
} else {
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]|</font><b>\n";}
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead</font><b>\n";}
$bad++;
}
$total++;
if ($total%100==0) {
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total)</script>";
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total, $dup, $post)</script>";
usleep(1000);
flush();
}
@@ -535,7 +596,7 @@ function ParseFileName() {
}
if ($leadfile && filesize($LF_path)<=8388608) {
$total=0; $good=0; $bad=0;
$total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list='';
if ($file_layout=="standard") {
print "<script language='JavaScript1.2'>document.forms[0].leadfile.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;</script>";
@@ -567,7 +628,7 @@ if ($leadfile && filesize($LF_path)<=8388608) {
if (count($field_check)>=5) {
flush();
$file=fopen("$lead_file", "r");
$total=0; $good=0; $bad=0;
$total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list='';
print "<center><font face='arial, helvetica' size=3 color='#009900'><B>Processing $delim_name-delimited file... ($tab_count|$pipe_count)\n";
if (strlen($list_id_override)>0)
{
@@ -614,15 +675,38 @@ if ($leadfile && filesize($LF_path)<=8388608) {
$security_phrase = $row[21];
$comments = trim($row[22]);
if (strlen($phone_number)>6) {
if (strlen($list_id_override)>0)
{
# print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>";
$list_id = $list_id_override;
}
if (strlen($list_id_override)>0)
##### Check for duplicate phone numbers in vicidial_list table #####
if (eregi("DUP",$dupcheck))
{
$dup_lead=0;
$stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
# print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>";
$list_id = $list_id_override;
$row=mysql_fetch_row($rslt);
$dup_lead = $row[0];
}
if ($dup_lead < 1)
{
if (eregi("$phone_number$US$list_id",$phone_list))
{$dup_lead++; $dup++;}
}
}
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear);
if ( (strlen($phone_number)>6) and ($dup_lead<1) )
{
$US='_';
$phone_list .= "$phone_number$US$list_id|";
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code);
if ($multi_insert_counter > 8) {
@@ -641,12 +725,12 @@ if ($leadfile && filesize($LF_path)<=8388608) {
$good++;
} else {
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]|</font><b>\n";}
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead</font><b>\n";}
$bad++;
}
$total++;
if ($total%100==0) {
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total)</script>";
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total, $dup, $post)</script>";
usleep(1000);
flush();
}
@@ -679,7 +763,10 @@ if ($leadfile && filesize($LF_path)<=8388608) {
$file=fopen("$lead_file", "r");
# echo "|$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override --lead-file=$lead_file|";
passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override --lead-file=$lead_file");
$dupcheckCLI=''; $postalgmtCLI='';
if (eregi("DUP",$dupcheck)) {$dupcheckCLI='--duplicate-check';}
if (eregi("POSTAL",$postalgmt)) {$postalgmtCLI='--postal-code-gmt';}
passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override --lead-file=$lead_file $postalgmtCLI $dupcheckCLI");
}
else
@@ -739,15 +826,38 @@ if ($leadfile && filesize($LF_path)<=8388608) {
$security_phrase = $row[21];
$comments = trim($row[22]);
if (strlen($phone_number)>6) {
if (strlen($list_id_override)>0)
{
# print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>";
$list_id = $list_id_override;
}
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear);
##### Check for duplicate phone numbers in vicidial_list table #####
if (eregi("DUP",$dupcheck))
{
$dup_lead=0;
$stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$dup_lead = $row[0];
}
if ($dup_lead < 1)
{
if (eregi("$phone_number$US$list_id",$phone_list))
{$dup_lead++; $dup++;}
}
}
if ( (strlen($phone_number)>6) and ($dup_lead<1) )
{
$US='_';
$phone_list .= "$phone_number$US$list_id|";
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code);
if ($multi_insert_counter > 8) {
@@ -766,12 +876,12 @@ if ($leadfile && filesize($LF_path)<=8388608) {
$good++;
} else {
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]|</font><b>\n";}
if ($bad < 10) {print "<BR></b><font size=1 color=red>record $total BAD- PHONE: $phone_number ROW: |$row[0]| DUP: $dup_lead</font><b>\n";}
$bad++;
}
$total++;
if ($total%100==0) {
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total)</script>";
print "<script language='JavaScript1.2'>ShowProgress($good, $bad, $total, $dup, $post)</script>";
usleep(1000);
flush();
}
@@ -900,7 +1010,10 @@ if ($leadfile && filesize($LF_path)<=8388608) {
}
# echo "|$WeBServeRRooT/vicidial/listloader_rowdisplay.pl --lead-file=$lead_file|";
passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl --lead-file=$lead_file");
$dupcheckCLI=''; $postalgmtCLI='';
if (eregi("DUP",$dupcheck)) {$dupcheckCLI='--duplicate-check';}
if (eregi("POSTAL",$postalgmt)) {$postalgmtCLI='--postal-code-gmt';}
passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl --lead-file=$lead_file $postalgmtCLI $dupcheckCLI");
}
else
{
@@ -926,7 +1039,7 @@ if ($leadfile && filesize($LF_path)<=8388608) {
print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>";
}
$total=0; $good=0; $bad=0;
$total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list='';
$row=fgetcsv($file, 1000, ",");
for ($i=0; $i<mysql_num_fields($rslt); $i++) {
print " <tr bgcolor=#D9E6FE>\r\n";
@@ -980,6 +1093,8 @@ if ($leadfile && filesize($LF_path)<=8388608) {
}
}
print " <tr bgcolor='#330099'>\r\n";
print " <input type=hidden name=dupcheck value=\"$dupcheck\">\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";
print " <th colspan=2><input type=submit name='OK_to_process' value='OK TO PROCESS'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=button onClick=\"javascript:document.location='new_listloader_superL.php'\" value=\"START OVER\" name='reload_page'></th>\r\n";
@@ -1006,71 +1121,93 @@ exit;
function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear)
function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code)
{
require("dbconnect.php");
$PC_processed=0;
### UNITED STATES ###
if ($phone_code =='1')
$postalgmt_found=0;
if ( (eregi("POSTAL",$postalgmt)) && (strlen($postal_code)>4) )
{
$stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
if (preg_match('/^1$/', $phone_code))
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
$stmt="select * from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[2]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[3];
$dst_range = $row[4];
$PC_processed++;
$postalgmt_found++;
$post++;
}
}
}
### MEXICO ###
if ($phone_code =='52')
if ($postalgmt_found < 1)
{
$stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
$PC_processed=0;
### UNITED STATES ###
if ($phone_code =='1')
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
$stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
}
}
}
### AUSTRALIA ###
if ($phone_code =='61')
{
$stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
### MEXICO ###
if ($phone_code =='52')
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
$stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
}
}
}
### ALL OTHER COUNTRY CODES ###
if (!$PC_processed)
{
$PC_processed++;
$stmt="select * from vicidial_phone_codes where country_code='$phone_code';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
### AUSTRALIA ###
if ($phone_code =='61')
{
$stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
}
}
### ALL OTHER COUNTRY CODES ###
if (!$PC_processed)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
$stmt="select * from vicidial_phone_codes where country_code='$phone_code';";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
{
$row=mysql_fetch_row($rslt);
$gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset);
$dst = $row[5];
$dst_range = $row[6];
$PC_processed++;
}
}
}