diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index db7cbf01dbf..0af58872457 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -32,42 +32,62 @@ class Form { return 1; } + /* - * + * Retourne la liste déroulante des départements/province/cantons + * avec un affichage avec rupture sur le pays * */ - Function select_departement($selected='', $addnsp=0) - { - print ''; - if ($this->db->query($sql)) - { - $num = $this->db->num_rows(); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $this->db->fetch_object( $i); - if ($selected == $obj->rowid) - { - print ''; - } - else - { - print ''; - } - $i++; - } - } - } - print ''; - } - /* - * + // On recherche les départements/cantons/province active d'une region et pays actif + $sql = "SELECT d.rowid, d.code_departement as code , d.nom, d.active, p.libelle as libelle_pays, p.code as code_pays FROM llx_c_departements as d, llx_c_regions as r, llx_c_pays as p"; + $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid"; + $sql .= " AND d.active = 1 AND r.active = 1 AND p.active = 1 ORDER BY code_pays, code ASC"; + + if ($this->db->query($sql)) + { + $num = $this->db->num_rows(); + $i = 0; + if ($num) + { + $pays=''; + while ($i < $num) + { + $obj = $this->db->fetch_object( $i); + if ($obj->code == 0) { + print ''; + } + else { + if ($pays == '' || $pays != $obj->libelle_pays) { + // Affiche la rupture + print ''; + $pays=$obj->libelle_pays; + } + + if ($selected > 0 && $selected == $obj->rowid) + { + print ''; + } + else + { + print ''; + } + } + $i++; + } + } + } + else { + print "Erreur : $sql : ".$this->db->error(); + } + print ''; + } + + /* + * Retourne la liste déroulante des pays actifs * */ Function select_pays($selected='', $addnsp=0) @@ -75,8 +95,8 @@ class Form { print '