Skip to content
Snippets Groups Projects
Commit b5e7b261 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Work on zipautofill module

parent 723a82c1
No related branches found
No related tags found
No related merge requests found
......@@ -63,16 +63,13 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
if ($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY) // Use zip-town table
{
$sql = "SELECT z.rowid, z.zip, z.town, z.fk_county";
$sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_country";
$sql.= ", p.rowid as fk_country, p.code as country_code, p.libelle as country";
$sql.= ", d.rowid as fk_county, d.code_departement as county_code , d.nom as county";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z";
$sql.= ", ".MAIN_DB_PREFIX ."c_departements as d";
$sql.= ", ".MAIN_DB_PREFIX."c_regions as r";
$sql.= ",".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE z.fk_county = d.rowid";
$sql.= " AND d.fk_region = r.code_region";
$sql.= " AND r.fk_pays = p.rowid";
$sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z,".MAIN_DB_PREFIX."c_pays as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON z.fk_county = d.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region";
$sql.= " WHERE z.fk_pays = p.rowid";
$sql.= " AND z.active = 1 AND d.active = 1 AND r.active = 1 AND p.active = 1";
if ($zipcode) " AND z.zip LIKE '" . $db->escape($zipcode) . "%'";
if ($town) " AND z.town LIKE '%" . $db->escape($town) . "%'";
......
......@@ -17,6 +17,9 @@ RENAME TABLE llx_c_methode_commande_fournisseur TO llx_c_input_method;
ALTER TABLE llx_adherent MODIFY login varchar(50);
ALTER TABLE llx_c_ziptown ADD COLUMN fk_pays integer NOT NULL DEFAULT 0 after fk_county;
ALTER TABLE llx_c_ziptown MODIFY fk_county integer NULL;
ALTER TABLE llx_c_actioncomm ADD COLUMN position integer NOT NULL DEFAULT 0;
ALTER TABLE llx_propal ADD COLUMN fk_demand_reason integer NULL DEFAULT 0;
ALTER TABLE llx_commande_fournisseur ADD COLUMN fk_cond_reglement integer NULL DEFAULT 0;
......
......@@ -22,7 +22,8 @@ create table llx_c_ziptown
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
code varchar(5) DEFAULT NULL, -- ex: code insee pour la France
fk_county integer NOT NULL, -- County id in llx_c_departements
fk_county integer, -- State id in llx_c_departements
fk_pays integer NOT NULL DEFAULT 0, -- Country id in llx_c_pays
zip varchar(10) NOT NULL, -- Zip code
town varchar(255) NOT NULL, -- Town name
active tinyint NOT NULL DEFAULT 1
......
......@@ -185,7 +185,7 @@ class DoliDb
$line=preg_replace('/,$/','',$line);
}
// Process case: "CREATE TABLE llx_c_ziptown(rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,code..."
// Process case: "CREATE TABLE llx_mytable(rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,code..."
if (preg_match('/[\s\t\(]*(\w*)[\s\t]+int.*auto_increment/i',$line,$reg)) {
$newline=preg_replace('/([\s\t\(]*)([a-zA-Z_0-9]*)[\s\t]+int.*auto_increment[^,]*/i','\\1 \\2 SERIAL PRIMARY KEY',$line);
//$line = "-- ".$line." replaced by --\n".$newline;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment