added GMT_USA_zip.txt import into vicidial_postal_codes table in order to allocate USA time zones by zip code where available

git-svn-id: svn://192.168.202.10@402 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2006-11-23 00:04:02 +00:00
parent 97cae33bf8
commit 18e0914a39
4 changed files with 90 additions and 36 deletions
+73 -36
View File
@@ -10,6 +10,7 @@
# 60615-1514 - Changed to ignore the header row
# 60807-1003 - Changed to DBI
# - changed to use /etc/astguiclient.conf for configs
# 61122-1902 - Added GMT_USA_zip.txt data import for USA postal GMT data
#
@@ -65,43 +66,79 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
$slash_star = '\*';
open(codefile, "$PATHhome/phone_codes_GMT.txt") || die "can't open $PATHhome/phone_codes_GMT.txt: $!\n";
@codefile = <codefile>;
close(codefile);
$pc=0;
$ins_stmt="insert into vicidial_phone_codes VALUES ";
foreach (@codefile)
{
@row=split(/\t/, $codefile[$pc]);
if ($codefile[$pc] !~ /GEOGRAPHIC DESCRIPTION/)
{
$pc++;
$row[7] =~ s/\r|\n|\t| $//gi;
$row[6] =~ s/\r|\n|\t| $//gi;
$row[5] =~ s/\r|\n|\t| $//gi;
$row[4] =~ s/\r|\n|\t| $//gi;
$row[3] =~ s/\r|\n|\t| $//gi;
$row[2] =~ s/\r|\n|\t| $//gi;
$row[1] =~ s/\r|\n|\t| $//gi;
$row[0] =~ s/\r|\n|\t| $//gi;
$ins_stmt.="('$row[0]', '$row[1]', '$row[2]', '$row[3]', '$row[4]', '$row[5]', '$row[6]', '$row[7]'), ";
if ($pc =~ /00$/)
{
chop($ins_stmt);
chop($ins_stmt);
$affected_rows = $dbhA->do($ins_stmt) || die "can't execute query: |$ins_stmt| $!\n";
$ins_stmt="insert into vicidial_phone_codes VALUES ";
print STDERR "$pc\n";
}
}
else {$pc++;}
}
chop($ins_stmt);
chop($ins_stmt);
$affected_rows = $dbhA->do($ins_stmt);
$ins_stmt="insert into vicidial_phone_codes VALUES ";
print STDERR "$pc\n";
#### BEGIN vicidial_phone_codes population from phone_codes_GMT.txt file ####
open(codefile, "$PATHhome/phone_codes_GMT.txt") || die "can't open $PATHhome/phone_codes_GMT.txt: $!\n";
@codefile = <codefile>;
close(codefile);
$pc=0;
$ins_stmt="insert into vicidial_phone_codes VALUES ";
foreach (@codefile)
{
@row=split(/\t/, $codefile[$pc]);
if ($codefile[$pc] !~ /GEOGRAPHIC DESCRIPTION/)
{
$pc++;
$row[7] =~ s/\r|\n|\t| $//gi;
$row[6] =~ s/\r|\n|\t| $//gi;
$row[5] =~ s/\r|\n|\t| $//gi;
$row[4] =~ s/\r|\n|\t| $//gi;
$row[3] =~ s/\r|\n|\t| $//gi;
$row[2] =~ s/\r|\n|\t| $//gi;
$row[1] =~ s/\r|\n|\t| $//gi;
$row[0] =~ s/\r|\n|\t| $//gi;
$ins_stmt.="('$row[0]', '$row[1]', '$row[2]', '$row[3]', '$row[4]', '$row[5]', '$row[6]', '$row[7]'), ";
if ($pc =~ /00$/)
{
chop($ins_stmt);
chop($ins_stmt);
$affected_rows = $dbhA->do($ins_stmt) || die "can't execute query: |$ins_stmt| $!\n";
$ins_stmt="insert into vicidial_phone_codes VALUES ";
print STDERR "$pc\n";
}
}
else {$pc++;}
}
chop($ins_stmt);
chop($ins_stmt);
$affected_rows = $dbhA->do($ins_stmt);
$ins_stmt="insert into vicidial_phone_codes VALUES ";
print STDERR "$pc\n";
#### END vicidial_phone_codes population from phone_codes_GMT.txt file ####
#### BEGIN vicidial_postal_codes population from GMT_USA_zip.txt file ####
open(zipfile, "$PATHhome/GMT_USA_zip.txt") || die "can't open $PATHhome/GMT_USA_zip.txt: $!\n";
@zipfile = <zipfile>;
close(zipfile);
$pc=0;
$ins_stmt="insert into vicidial_postal_codes VALUES ";
foreach (@zipfile)
{
@row=split(/\t/, $zipfile[$pc]);
$pc++;
$row[0] =~ s/\r|\n|\t| $//gi;
$row[1] =~ s/\r|\n|\t| $//gi;
$row[2] =~ s/\r|\n|\t| $//gi;
$row[3] =~ s/\r|\n|\t| $//gi;
$ins_stmt.="('$row[0]', '$row[1]', '$row[2]', '$row[3]', 'USA'), ";
if ($pc =~ /00$/)
{
chop($ins_stmt);
chop($ins_stmt);
$affected_rows = $dbhA->do($ins_stmt) || die "can't execute query: |$ins_stmt| $!\n";
$ins_stmt="insert into vicidial_postal_codes VALUES ";
print STDERR "$pc\n";
}
}
chop($ins_stmt);
chop($ins_stmt);
$affected_rows = $dbhA->do($ins_stmt);
$ins_stmt="insert into vicidial_postal_codes VALUES ";
print STDERR "$pc\n";
#### END vicidial_postal_codes population from GMT_USA_zip.txt file ####
$dbhA->disconnect();
@@ -800,6 +800,15 @@ index (campaign_id),
index (server_ip)
);
CREATE TABLE vicidial_postal_codes (
postal_code VARCHAR(10) NOT NULL,
state VARCHAR(4),
GMT_offset VARCHAR(5),
DST enum('Y','N'),
country CHAR(3)
);
INSERT INTO vicidial_call_times SET call_time_id='24hours',call_time_name='default 24 hours calling',ct_default_start='0',ct_default_stop='2400';
+7
View File
@@ -34,3 +34,10 @@ ALTER TABLE vicidial_user_groups ADD allowed_campaigns TEXT;
UPDATE vicidial_user_groups SET allowed_campaigns=' -ALL-CAMPAIGNS- - -';
CREATE TABLE vicidial_postal_codes (
postal_code VARCHAR(10) NOT NULL,
state VARCHAR(4),
GMT_offset VARCHAR(5),
DST enum('Y','N'),
country CHAR(3)
);
+1
View File
@@ -1240,6 +1240,7 @@ if ($WEBONLY < 1)
`chmod 0755 $PATHhome/*`;
print "Copying extras files to $PATHhome ...\n";
`cp -f ./extras/GMT_USA_zip.txt $PATHhome/`;
`cp -f ./extras/phone_codes_GMT.txt $PATHhome/`;
`cp -f ./extras/MySQL_AST_CREATE_tables.sql $PATHhome/`;