Added country ISO and TLD code database table

Added framework for crm_iframe extras example code

git-svn-id: svn://192.168.202.10@2443 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2015-12-28 15:53:51 +00:00
parent 65d9de6e3b
commit 8217920c2d
3 changed files with 72 additions and 2 deletions
+51 -1
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# ADMIN_area_code_populate.pl version 2.10
# ADMIN_area_code_populate.pl version 2.12
#
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
@@ -21,6 +21,7 @@
# 110424-0735 - Added timezone abbreviation column
# 130419-1237 - Added lata_type field to NANPA file format
# 150203-1751 - code cleanup
# 151228-1043 - Added ISO-TLD table and import
#
@@ -30,6 +31,7 @@ $domain = "http://phonecodes.vicidial.com";
#$URL1 = "$domain/phone_codes_GMT-latest.txt";
$URL1 = "$domain/phone_codes_GMT-latest-24.txt";
$URL2 = "$domain/GMT_USA_zip-latest.txt";
$URL3 = "$domain/country_ISO_TLD-latest.txt";
### begin parsing run-time options ###
@@ -54,6 +56,7 @@ if (length($ARGV[0])>1)
print "\n files used by this script are:\n";
print " phone_codes_GMT-latest-24.txt - Phone codes and country codes with time zone data\n";
print " GMT_USA_zip-latest.txt - USA zip code and time zone data\n";
print " country_ISO_TLD-latest.txt - Country code ISO and TLD data\n";
print " NANPA_prefix-latest.txt - North American areacode, prefix and time zone data\n";
exit;
@@ -288,10 +291,12 @@ else
# move old files
`mv -f $PATHhome/phone_codes_GMT-latest-24.txt $PATHhome/phone_codes_GMT-latest-24-old.txt`;
`mv -f $PATHhome/GMT_USA_zip-latest.txt $PATHhome/GMT_USA_zip-latest-old.txt`;
`mv -f $PATHhome/country_ISO_TLD-latest.txt $PATHhome/country_ISO_TLD-latest-old.txt`;
# get files
`wget $URL1`;
`wget $URL2`;
`wget $URL3`;
}
#### BEGIN vicidial_phone_codes population from phone_codes_GMT-latest-24.txt file ####
@@ -391,6 +396,51 @@ else
$ins_stmt="insert into vicidial_postal_codes VALUES ";
print STDERR "$pc\n";
#### END vicidial_postal_codes population ####
#### BEGIN vicidial_country_iso_tld population from GMT_USA_zip-latest.txt file ####
open(isofile, "$PATHhome/country_ISO_TLD-latest.txt") || die "can't open $PATHhome/country_ISO_TLD-latest.txt: $!\n";
@isofile = <isofile>;
close(isofile);
if ( ($purge_table > 0) && ($#isofile > 10) )
{
print "\n----- PURGING DATA IN vicidial_country_iso_tld TABLE -----\n\n";
$stmtA = "DELETE from vicidial_country_iso_tld;";
if($DB){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA);
$stmtA = "OPTIMIZE table vicidial_country_iso_tld;";
if($DB){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA);
}
$pc=0;
$ins_stmt="insert into vicidial_country_iso_tld VALUES ";
foreach (@isofile)
{
@row=split(/\t/, $isofile[$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;
$row[4] =~ s/\r|\n|\t| $//gi;
$ins_stmt.="(\"$row[0]\", '$row[1]', '$row[2]', '$row[3]', '$row[4]'), ";
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_country_iso_tld VALUES ";
print STDERR "$pc\r";
}
}
chop($ins_stmt);
chop($ins_stmt);
$affected_rows = $dbhA->do($ins_stmt);
$ins_stmt="insert into vicidial_country_iso_tld VALUES ";
print STDERR "$pc\n";
#### END vicidial_country_iso_tld population ####
}
$dbhA->disconnect();
+10 -1
View File
@@ -3403,6 +3403,15 @@ KEY lead_id (lead_id),
KEY filter_date (filter_date)
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE vicidial_country_iso_tld (
country_name VARCHAR(200) default '',
iso2 VARCHAR(2) default '',
iso3 VARCHAR(3) default '',
num3 VARCHAR(4) default '',
tld VARCHAR(20) default '',
index(iso3)
)ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;
ALTER TABLE vicidial_email_list MODIFY message text character set utf8;
@@ -3652,4 +3661,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version';
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1441',db_schema_update_date=NOW(),reload_timestamp=NOW();
UPDATE system_settings SET db_schema_version='1442',db_schema_update_date=NOW(),reload_timestamp=NOW();
+11
View File
@@ -412,3 +412,14 @@ ALTER TABLE phones ADD nva_new_phone_code VARCHAR(10) default '1';
ALTER TABLE phones ADD nva_new_status VARCHAR(6) default 'NVAINS';
UPDATE system_settings SET db_schema_version='1441',db_schema_update_date=NOW() where db_schema_version < 1441;
CREATE TABLE vicidial_country_iso_tld (
country_name VARCHAR(200) default '',
iso2 VARCHAR(2) default '',
iso3 VARCHAR(3) default '',
num3 VARCHAR(4) default '',
tld VARCHAR(20) default '',
index(iso3)
)ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;
UPDATE system_settings SET db_schema_version='1442',db_schema_update_date=NOW() where db_schema_version < 1442;