New: Le choix de la devise principale se fait par liste déroulante
This commit is contained in:
parent
2496a80138
commit
6024f76094
@ -52,6 +52,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update')
|
|||||||
|
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
print_titre($langs->trans("GlobalSetup"));
|
print_titre($langs->trans("GlobalSetup"));
|
||||||
@ -78,7 +79,8 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit')
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr class="impair"><td>'.$langs->trans("CompanyCurrency").'</td><td>';
|
print '<tr class="impair"><td>'.$langs->trans("CompanyCurrency").'</td><td>';
|
||||||
print '<input name="currency" value="'. MAIN_MONNAIE . '"></td></tr>';
|
$form->select_currency(MAIN_MONNAIE,"currency");
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr class="pair"><td width="50%">'.$langs->trans("Capital").'</td><td>';
|
print '<tr class="pair"><td width="50%">'.$langs->trans("Capital").'</td><td>';
|
||||||
print '<input name="capital" size="20" value="' . MAIN_INFO_CAPITAL . '"></td></tr>';
|
print '<input name="capital" size="20" value="' . MAIN_INFO_CAPITAL . '"></td></tr>';
|
||||||
@ -144,10 +146,12 @@ else
|
|||||||
print '<tr class="impair"><td width="50%">'.$langs->trans("CompanyName").'</td><td>' . MAIN_INFO_SOCIETE_NOM . '</td></tr>';
|
print '<tr class="impair"><td width="50%">'.$langs->trans("CompanyName").'</td><td>' . MAIN_INFO_SOCIETE_NOM . '</td></tr>';
|
||||||
|
|
||||||
print '<tr class="pair"><td>'.$langs->trans("Country").'</td><td>';
|
print '<tr class="pair"><td>'.$langs->trans("Country").'</td><td>';
|
||||||
print $form->pays_name(MAIN_INFO_SOCIETE_PAYS);
|
print $form->pays_name(MAIN_INFO_SOCIETE_PAYS,1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr class="impair"><td width="50%">'.$langs->trans("CompanyCurrency").'</td><td>' . MAIN_MONNAIE . '</td></tr>';
|
print '<tr class="impair"><td width="50%">'.$langs->trans("CompanyCurrency").'</td><td>';
|
||||||
|
print $form->currency_name(MAIN_MONNAIE,1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr class="pair"><td width="50%">'.$langs->trans("Capital").'</td><td>';
|
print '<tr class="pair"><td width="50%">'.$langs->trans("Capital").'</td><td>';
|
||||||
print MAIN_INFO_CAPITAL . '</td></tr>';
|
print MAIN_INFO_CAPITAL . '</td></tr>';
|
||||||
|
|||||||
@ -680,31 +680,69 @@ class Form
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne le nom d'un pays
|
* \brief Retourne le nom traduit ou code+nom d'un pays
|
||||||
* \param id id du pays
|
* \param id id du pays
|
||||||
|
* \param withcode 1=affiche code + nom
|
||||||
|
* \return string Nom traduit du pays
|
||||||
*/
|
*/
|
||||||
function pays_name($id)
|
function pays_name($id,$withcode=0)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid, libelle FROM ".MAIN_DB_PREFIX."c_pays";
|
global $langs;
|
||||||
$sql .= " WHERE rowid=$id;";
|
|
||||||
|
$sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays";
|
||||||
if ($this->db->query($sql))
|
$sql.= " WHERE rowid=$id;";
|
||||||
{
|
|
||||||
$num = $this->db->num_rows();
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
if ($num)
|
$num = $this->db->num_rows();
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object();
|
if ($num)
|
||||||
return $obj->libelle;
|
{
|
||||||
}
|
$obj = $this->db->fetch_object();
|
||||||
else
|
$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";
|
||||||
return "Non défini";
|
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 '<select class="flat" name="'.$htmlname.'">';
|
||||||
|
$num = $this->db->num_rows();
|
||||||
|
$i = 0;
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
$foundselected=false;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object();
|
||||||
|
if ($selected && $selected == $obj->code_iso)
|
||||||
|
{
|
||||||
|
$foundselected=true;
|
||||||
|
print '<option value="'.$obj->code_iso.'" selected>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<option value="'.$obj->code_iso.'">';
|
||||||
|
}
|
||||||
|
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
|
||||||
|
if ($obj->code_iso) { print $obj->code_iso . ' - '; }
|
||||||
|
print ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
|
||||||
|
print '</option>';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</select>';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Selection du taux de tva
|
* \brief Selection du taux de tva
|
||||||
* \param name Nom champ html
|
* \param name Nom champ html
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user