diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index c320d9fdf86..6c09adf2c8d 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -21,73 +21,76 @@ * $Source$ */ -class Form { +class Form +{ var $db; var $errorstr; Function Form($DB) - { - - $this->db = $DB; - - return 1; - } - + { + + $this->db = $DB; + + return 1; + } + /* * Retourne la liste déroulante des départements/province/cantons * avec un affichage avec rupture sur le pays * */ - Function select_departement($selected='') - { - 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"; + // 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 "; + $sql .= MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."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 "; + $sql .= "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 '\n"; - $pays=$obj->libelle_pays; - } - - if ($selected > 0 && $selected == $obj->rowid) - { - print ''; - } - else - { - print ''; - } - } - $i++; - } - } - } - else { - print "Erreur : $sql : ".$this->db->error(); - } - print ''; + 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 '\n"; + $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 * */ @@ -95,7 +98,7 @@ class Form { { print ''; } + /* + * Retourne le nom d'un pays + * + */ + Function pays_name($id) + { + $sql = "SELECT rowid, libelle FROM ".MAIN_DB_PREFIX."c_pays"; + $sql .= " WHERE rowid=$id"; + + if ($this->db->query($sql)) + { + $num = $this->db->num_rows(); + + if ($num) + { + $obj = $this->db->fetch_object(0); + print $obj->libelle; + } + else + { + print "Non définit"; + } + + } + print ''; + } + + /* * Retourne la liste déroulante des civilite actives @@ -132,7 +163,7 @@ class Form { { print '