diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php
index 8dd44b0eb98..62c2a2630a8 100644
--- a/htdocs/admin/index.php
+++ b/htdocs/admin/index.php
@@ -52,6 +52,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update')
llxHeader();
+
$form = new Form($db);
print_titre($langs->trans("GlobalSetup"));
@@ -78,7 +79,8 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit')
print '';
print '
| '.$langs->trans("CompanyCurrency").' | ';
- print ' |
';
+ $form->select_currency(MAIN_MONNAIE,"currency");
+ print '';
print '| '.$langs->trans("Capital").' | ';
print ' |
';
@@ -144,10 +146,12 @@ else
print '| '.$langs->trans("CompanyName").' | ' . MAIN_INFO_SOCIETE_NOM . ' |
';
print '| '.$langs->trans("Country").' | ';
- print $form->pays_name(MAIN_INFO_SOCIETE_PAYS);
+ print $form->pays_name(MAIN_INFO_SOCIETE_PAYS,1);
print ' |
';
- print '| '.$langs->trans("CompanyCurrency").' | ' . MAIN_MONNAIE . ' |
';
+ print '| '.$langs->trans("CompanyCurrency").' | ';
+ print $form->currency_name(MAIN_MONNAIE,1);
+ print ' |
';
print '| '.$langs->trans("Capital").' | ';
print MAIN_INFO_CAPITAL . ' |
';
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 23c9e5ecfc2..fb5f0ccda94 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -680,31 +680,69 @@ class Form
/**
- * \brief Retourne le nom d'un pays
- * \param id id du pays
+ * \brief Retourne le nom traduit ou code+nom d'un pays
+ * \param id id du pays
+ * \param withcode 1=affiche code + nom
+ * \return string Nom traduit du 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();
- return $obj->libelle;
- }
- else
- {
- return "Non défini";
- }
+ function pays_name($id,$withcode=0)
+ {
+ global $langs;
+
+ $sql = "SELECT rowid, code, 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();
+ $label=$obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code?$langs->trans("Country".$obj->code):($obj->libelle!='-'?$obj->libelle:'');
+ if ($withcode) return $label==$obj->code?"$obj->code":"$obj->code - $label";
+ else return $label;
+ }
+ else
+ {
+ return $langs->trans("NotDefined");
+ }
+
+ }
+ }
- }
-
- }
+
+ /**
+ * \brief Retourne le nom traduit ou code+nom d'une devise
+ * \param code_iso Code iso de la devise
+ * \param withcode 1=affiche code + nom
+ * \return string Nom traduit de la devise
+ */
+ function currency_name($code_iso,$withcode=0)
+ {
+ global $langs;
+
+ $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies";
+ $sql.= " WHERE code_iso='$code_iso';";
+
+ if ($this->db->query($sql))
+ {
+ $num = $this->db->num_rows();
+
+ if ($num)
+ {
+ $obj = $this->db->fetch_object();
+ $label=$langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'');
+ if ($withcode) return $label==$code_iso?"$code_iso":"$code_iso - $label";
+ else return $label;
+ }
+ else
+ {
+ return $code_iso;
+ }
+
+ }
+ }
/**
@@ -735,6 +773,60 @@ class Form
}
+ /**
+ * \brief Retourne la liste des devies, dans la langue de l'utilisateur
+ * \param selected code devise pré-sélectionnée
+ * \param htmlname nom de la liste deroulante
+ * \todo trier liste sur noms après traduction plutot que avant
+ */
+ function select_currency($selected='',$htmlname='currency_id')
+ {
+ global $conf,$langs;
+ $langs->load("dict");
+
+ if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilité
+
+ $sql = "SELECT code_iso, label, active FROM ".MAIN_DB_PREFIX."c_currencies";
+ $sql .= " WHERE active = 1";
+ $sql .= " ORDER BY code_iso ASC;";
+
+ if ($this->db->query($sql))
+ {
+ print '';
+ return 0;
+ }
+ else {
+ dolibarr_print_error($this->db);
+ return 1;
+ }
+ }
+
+
/**
* \brief Selection du taux de tva
* \param name Nom champ html