From 510baa2584feaa325666d1be11000f6170bac95b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 21 Oct 2010 13:34:31 +0000 Subject: [PATCH] Work on multicompany --- htdocs/core/class/conf.class.php | 3 ++- htdocs/core/class/html.form.class.php | 37 ++++++++++++++++++--------- htdocs/master.inc.php | 35 +++++++++++++------------ 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index df3854a9d44..3c4e91c683b 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -346,7 +346,8 @@ class Conf // conf->monnaie if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR'; - $this->monnaie=$this->global->MAIN_MONNAIE; + $this->monnaie=$this->global->MAIN_MONNAIE; // TODO deprecated + $this->currency=$this->global->MAIN_MONNAIE; // $this->compta->mode = Option du module Comptabilite (simple ou expert): // Defini le mode de calcul des etats comptables (CA,...) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 86ef014cf7c..8b0730bbf8c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2282,16 +2282,29 @@ class Form } } + /** + * Retourne la liste des devises, dans la langue de l'utilisateur + * @param selected code devise pre-selectionne + * @param htmlname nom de la liste deroulante + * TODO trier liste sur noms apres traduction plutot que avant + */ + function select_currency($selected='',$htmlname='currency_id') + { + print $this->selectcurrency($selected,$htmlname); + } + /** * \brief Retourne la liste des devises, dans la langue de l'utilisateur * \param selected code devise pre-selectionne * \param htmlname nom de la liste deroulante * \todo trier liste sur noms apres traduction plutot que avant */ - function select_currency($selected='',$htmlname='currency_id') + function selectcurrency($selected='',$htmlname='currency_id') { global $conf,$langs,$user; $langs->load("dict"); + + $out=''; if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilite @@ -2303,7 +2316,7 @@ class Form $resql=$this->db->query($sql); if ($resql) { - print ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -2315,26 +2328,26 @@ class Form if ($selected && $selected == $obj->code_iso) { $foundselected=true; - print ''; + $out.= ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'')); + $out.= ''; $i++; } } - print ''; - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - return 0; + $out.= ''; + if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + return $out; } - else { + else + { dol_print_error($this->db); - return 1; } } diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 5dc3931eff4..d3de81c67ee 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -357,39 +357,42 @@ if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC')) $mysoc=new Societe($db); $mysoc->id=0; - $mysoc->nom=$conf->global->MAIN_INFO_SOCIETE_NOM; // TODO obsolete + $mysoc->nom=$conf->global->MAIN_INFO_SOCIETE_NOM; // TODO deprecated $mysoc->name=$conf->global->MAIN_INFO_SOCIETE_NOM; - $mysoc->adresse=$conf->global->MAIN_INFO_SOCIETE_ADRESSE; // TODO obsolete + $mysoc->adresse=$conf->global->MAIN_INFO_SOCIETE_ADRESSE; // TODO deprecated $mysoc->address=$conf->global->MAIN_INFO_SOCIETE_ADRESSE; - $mysoc->cp=$conf->global->MAIN_INFO_SOCIETE_CP; // TODO obsolete + $mysoc->cp=$conf->global->MAIN_INFO_SOCIETE_CP; // TODO deprecated $mysoc->zip=$conf->global->MAIN_INFO_SOCIETE_CP; - $mysoc->ville=$conf->global->MAIN_INFO_SOCIETE_VILLE; // TODO obsolete + $mysoc->ville=$conf->global->MAIN_INFO_SOCIETE_VILLE; // TODO deprecated $mysoc->town=$conf->global->MAIN_INFO_SOCIETE_VILLE; - $mysoc->departement_id=$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT; + $mysoc->state_id=$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT; + $mysoc->departement_id=$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT; // TODO deprecated $mysoc->note=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE; // We define pays_id, pays_code and pays_label $tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_PAYS); - $pays_id=$tmp[0]; + $country_id=$tmp[0]; if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_PAYS is "id:code:label" { - $pays_code=$tmp[1]; - $pays_label=$tmp[2]; + $country_code=$tmp[1]; + $country_label=$tmp[2]; } else // For backward compatibility { dol_syslog("Your country setup use an old syntax. Reedit it in setup area.", LOG_WARNING); include_once(DOL_DOCUMENT_ROOT.'/lib/company.lib.php'); - $pays_code=getCountry($pays_id,2,$db); // This need a SQL request, but it's the old feature - $pays_label=getCountry($pays_id,0,$db); // This need a SQL request, but it's the old feature + $country_code=getCountry($country_id,2,$db); // This need a SQL request, but it's the old feature + $country_label=getCountry($country_id,0,$db); // This need a SQL request, but it's the old feature } - $mysoc->pays_id=$pays_id; - $mysoc->pays_code=$pays_code; - $mysoc->country=$pays_label; - if (is_object($langs)) $mysoc->country=($langs->trans('Country'.$pays_code)!='Country'.$pays_code)?$langs->trans('Country'.$pays_code):$pays_label; - $mysoc->pays=$mysoc->country; // deprecated + $mysoc->pays_id=$country_id; // TODO deprecated + $mysoc->country_id=$country_id; + $mysoc->pays_code=$country_code; // TODO deprecated + $mysoc->country_code=$country_code; + $mysoc->country=$country_label; + if (is_object($langs)) $mysoc->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label; + $mysoc->pays=$mysoc->country; // TODO deprecated - $mysoc->tel=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; // deprecated + $mysoc->tel=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; // TODO deprecated $mysoc->phone=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; $mysoc->fax=empty($conf->global->MAIN_INFO_SOCIETE_FAX)?'':$conf->global->MAIN_INFO_SOCIETE_FAX; $mysoc->url=empty($conf->global->MAIN_INFO_SOCIETE_WEB)?'':$conf->global->MAIN_INFO_SOCIETE_WEB;