From 58703bada9ebe7bed60bcf2b226ee4fd51902c46 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 21 Jul 2004 09:08:02 +0000 Subject: [PATCH] =?UTF-8?q?Set=20le=20d=E9partement=20par=20d=E9faut=20dan?= =?UTF-8?q?s=20certains=20cas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/societe.class.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 281de698431..a0735897b38 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -98,6 +98,26 @@ class Societe { $this->fax = ereg_replace("\.","",$this->fax); + /* + * TODO simpliste pour l'instant mais remplit 95% des cas + * à améliorer + */ + + if ($this->departement_id == -1 && $this->pays_id == 1) + { + if (strlen(trim($this->cp)) == 5) + { + $depid = departement_rowid($this->db, + substr(trim($this->cp),0,2), + $this->pays_id); + if ($depid > 0) + { + $this->departement_id = $depid; + } + } + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; $sql .= " SET nom = '" . trim($this->nom) ."'"; $sql .= ",address = '" . trim($this->adresse) ."'";