From 1b9ee9c5979527ba15685adb9b15fea9ceb38652 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Aug 2010 15:30:17 +0000 Subject: [PATCH] Qual: Clean code Perf: Country id+code is now stored into MAIN_INFO_SOCIETE_PAYS instead of only id. This avoid a select to finf country code at each request. --- htdocs/adherents/fiche.php | 2 +- htdocs/admin/company.php | 1473 +++++++++--------- htdocs/comm/address.php | 4 +- htdocs/contact/fiche.php | 2 +- htdocs/core/class/html.formcompany.class.php | 2 +- htdocs/lib/company.lib.php | 1 - htdocs/lib/files.lib.php | 13 + htdocs/lib/lib_head.js | 13 + htdocs/main.inc.php | 3 - htdocs/master.inc.php | 2 +- htdocs/societe/soc.php | 4 +- 11 files changed, 769 insertions(+), 750 deletions(-) diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 8c859132c25..7ca3f123ab1 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -881,7 +881,7 @@ if ($action == 'create') $adh->fk_departement = $_POST["departement_id"]; // We set pays_id, pays_code and label for the selected country - $adh->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + $adh->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; if ($adh->pays_id) { $sql = "SELECT rowid, code, libelle"; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 2e51597bf91..02c1c272bd0 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -51,171 +51,177 @@ $quality = 80; if ( (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["cancel"])) || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) { - require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); + require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_VILLE",$_POST["ville"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_CP",$_POST["cp"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS",$_POST["pays_id"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_DEPARTEMENT",$_POST["departement_id"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MONNAIE",$_POST["currency"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL",$_POST["tel"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX",$_POST["fax"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL",$_POST["mail"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB",$_POST["web"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE",$_POST["note"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD",$_POST["gencod"],'chaine',0,'',$conf->entity); - if ($_FILES["logo"]["tmp_name"]) - { - if (preg_match('/([^\\/:]+)$/i',$_FILES["logo"]["name"],$reg)) - { - $original_file=$reg[1]; + $new_pays_id=$_POST["pays_id"]; + $new_pays_code=getCountry($new_pays_id,2); + $new_pays_label=getCountry($new_pays_id,0); + //dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS", $new_pays_id,'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS", $new_pays_id.':'.$new_pays_code.':'.$new_pays_label,'chaine',0,'',$conf->entity); - $isimage=image_format_supported($original_file); - if ($isimage >= 0) - { - dol_syslog("Move file ".$_FILES["logo"]["tmp_name"]." to ".$conf->mycompany->dir_output.'/logos/'.$original_file); - if (! is_dir($conf->mycompany->dir_output.'/logos/')) - { - create_exdir($conf->mycompany->dir_output.'/logos/'); - } - $result=dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->mycompany->dir_output.'/logos/'.$original_file,1,0,$_FILES['logo']['error']); - if ($result > 0) - { - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file,'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_VILLE",$_POST["ville"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_CP",$_POST["cp"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_DEPARTEMENT",$_POST["departement_id"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MONNAIE",$_POST["currency"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL",$_POST["tel"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX",$_POST["fax"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL",$_POST["mail"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB",$_POST["web"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE",$_POST["note"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD",$_POST["gencod"],'chaine',0,'',$conf->entity); + if ($_FILES["logo"]["tmp_name"]) + { + if (preg_match('/([^\\/:]+)$/i',$_FILES["logo"]["name"],$reg)) + { + $original_file=$reg[1]; - // Create thumbs of logo (Note that PDF use original file and not thumbs) - if ($isimage > 0) - { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); - if (preg_match('/([^\\/:]+)$/i',$imgThumbSmall,$reg)) - { - $imgThumbSmall = $reg[1]; - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall,'chaine',0,'',$conf->entity); - } - else dol_syslog($imgThumbSmall); + $isimage=image_format_supported($original_file); + if ($isimage >= 0) + { + dol_syslog("Move file ".$_FILES["logo"]["tmp_name"]." to ".$conf->mycompany->dir_output.'/logos/'.$original_file); + if (! is_dir($conf->mycompany->dir_output.'/logos/')) + { + create_exdir($conf->mycompany->dir_output.'/logos/'); + } + $result=dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->mycompany->dir_output.'/logos/'.$original_file,1,0,$_FILES['logo']['error']); + if ($result > 0) + { + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file,'chaine',0,'',$conf->entity); - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality); - if (preg_match('/([^\\/:]+)$/i',$imgThumbMini,$reg)) - { - $imgThumbMini = $reg[1]; - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$imgThumbMini,'chaine',0,'',$conf->entity); - } - else dol_syslog($imgThumbMini); - } - else dol_syslog($langs->trans("ErrorImageFormatNotSupported"),LOG_WARNING); - } - else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result)) - { - $langs->load("errors"); - $tmparray=explode(':',$result); - $message .= '
'.$langs->trans('ErrorFileIsInfectedWithAVirus',$tmparray[1]).'
'; - } - else - { - $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; - } - } - else - { - $message .= '
'.$langs->trans("ErrorOnlyPngJpgSupported").'
'; - } - } - } + // Create thumbs of logo (Note that PDF use original file and not thumbs) + if ($isimage > 0) + { + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); + if (preg_match('/([^\\/:]+)$/i',$imgThumbSmall,$reg)) + { + $imgThumbSmall = $reg[1]; + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall,'chaine',0,'',$conf->entity); + } + else dol_syslog($imgThumbSmall); - dolibarr_set_const($db, "MAIN_INFO_CAPITAL",$_POST["capital"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE",$_POST["forme_juridique_code"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SIREN",$_POST["siren"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SIRET",$_POST["siret"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_APE",$_POST["ape"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_RCS",$_POST["rcs"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_TVAINTRA",$_POST["tva"],'chaine',0,'',$conf->entity); + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality); + if (preg_match('/([^\\/:]+)$/i',$imgThumbMini,$reg)) + { + $imgThumbMini = $reg[1]; + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$imgThumbMini,'chaine',0,'',$conf->entity); + } + else dol_syslog($imgThumbMini); + } + else dol_syslog($langs->trans("ErrorImageFormatNotSupported"),LOG_WARNING); + } + else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result)) + { + $langs->load("errors"); + $tmparray=explode(':',$result); + $message .= '
'.$langs->trans('ErrorFileIsInfectedWithAVirus',$tmparray[1]).'
'; + } + else + { + $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; + } + } + else + { + $message .= '
'.$langs->trans("ErrorOnlyPngJpgSupported").'
'; + } + } + } - dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START",$_POST["fiscalmonthstart"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_CAPITAL",$_POST["capital"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE",$_POST["forme_juridique_code"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SIREN",$_POST["siren"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SIRET",$_POST["siret"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_APE",$_POST["ape"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_RCS",$_POST["rcs"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_TVAINTRA",$_POST["tva"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "FACTURE_TVAOPTION",$_POST["optiontva"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START",$_POST["fiscalmonthstart"],'chaine',0,'',$conf->entity); - // Local taxes - dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION",$_POST["optionlocaltax1"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION",$_POST["optionlocaltax2"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "FACTURE_TVAOPTION",$_POST["optiontva"],'chaine',0,'',$conf->entity); - if ($_POST['action'] != 'updateedit' && ! $message) - { - Header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } + // Local taxes + dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION",$_POST["optionlocaltax1"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION",$_POST["optionlocaltax2"],'chaine',0,'',$conf->entity); + + if ($_POST['action'] != 'updateedit' && ! $message) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } } if ($_GET["action"] == 'addthumb') { - if (file_exists($conf->societe->dir_output.'/logos/'.$_GET["file"])) - { - $isimage=image_format_supported($_GET["file"]); + if (file_exists($conf->societe->dir_output.'/logos/'.$_GET["file"])) + { + $isimage=image_format_supported($_GET["file"]); - // Create thumbs of logo - if ($isimage > 0) - { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small',$quality); - if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i',$imgThumbSmall,$reg)) - { - $imgThumbSmall = $reg[1]; - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall,'chaine',0,'',$conf->entity); - } - else dol_syslog($imgThumbSmall); + // Create thumbs of logo + if ($isimage > 0) + { + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small',$quality); + if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i',$imgThumbSmall,$reg)) + { + $imgThumbSmall = $reg[1]; + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall,'chaine',0,'',$conf->entity); + } + else dol_syslog($imgThumbSmall); - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini',$quality); - if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i',$imgThumbMini,$reg)) - { - $imgThumbMini = $reg[1]; - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$imgThumbMini,'chaine',0,'',$conf->entity); - } - else dol_syslog($imgThumbMini); + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini',$quality); + if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i',$imgThumbMini,$reg)) + { + $imgThumbMini = $reg[1]; + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$imgThumbMini,'chaine',0,'',$conf->entity); + } + else dol_syslog($imgThumbMini); - Header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - else - { - $message .= '
'.$langs->trans("ErrorImageFormatNotSupported").'
'; - dol_syslog($langs->transnoentities("ErrorImageFormatNotSupported"),LOG_WARNING); - } - } - else - { - $message .= '
'.$langs->trans("ErrorFileDoesNotExists",$_GET["file"]).'
'; - dol_syslog($langs->transnoentities("ErrorFileDoesNotExists",$_GET["file"]),LOG_WARNING); - } + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + $message .= '
'.$langs->trans("ErrorImageFormatNotSupported").'
'; + dol_syslog($langs->transnoentities("ErrorImageFormatNotSupported"),LOG_WARNING); + } + } + else + { + $message .= '
'.$langs->trans("ErrorFileDoesNotExists",$_GET["file"]).'
'; + dol_syslog($langs->transnoentities("ErrorFileDoesNotExists",$_GET["file"]),LOG_WARNING); + } } if ($_GET["action"] == 'removelogo') { - $logofile=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; - dol_delete_file($logofile); - dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO",$conf->entity); - $mysoc->logo=''; + $logofile=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; + dol_delete_file($logofile); + dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO",$conf->entity); + $mysoc->logo=''; - $logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; - dol_delete_file($logosmallfile); - dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$conf->entity); - $mysoc->logo_small=''; + $logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; + dol_delete_file($logosmallfile); + dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$conf->entity); + $mysoc->logo_small=''; - $logominifile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini; - dol_delete_file($logominifile); - dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$conf->entity); - $mysoc->logo_mini=''; + $logominifile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini; + dol_delete_file($logominifile); + dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$conf->entity); + $mysoc->logo_mini=''; } + /* - * Affichage page + * View */ $wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; @@ -226,6 +232,30 @@ $formcompany = new FormCompany($db); $countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +// We define pays_id, pays_code and pays_label +if (! empty($conf->global->MAIN_INFO_SOCIETE_PAYS)) +{ + $tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_PAYS); + $pays_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]; + } + else + { + $pays_code=getCountry($pays_id,2); + $pays_label=getCountry($pays_id,0); + } +} +else +{ + $pays_id=0; + $pays_code=''; + $pays_label=''; +} + + print_fiche_titre($langs->trans("CompanyFoundation"),'','setup'); print $langs->trans("CompanyFundationDesc")."
\n"; @@ -234,711 +264,678 @@ print "
\n"; if ((isset($_GET["action"]) && $_GET["action"] == 'edit') || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) { - /** - * Edition des parametres - */ + /** + * Edition des parametres + */ - print '
'; - print ''; - print ''; - $var=true; + print ''; + print ''; + print ''; + $var=true; - print ''; - print ''."\n"; + print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'; + print ''."\n"; - $var=!$var; - print ''."\n"; + $var=!$var; + print ''."\n"; - $var=!$var; - print ''."\n"; + $var=!$var; + print ''."\n"; - $var=!$var; - print ''."\n"; + $var=!$var; + print ''."\n"; - $var=!$var; - print ''."\n"; + $var=!$var; + print ''."\n"; - $var=!$var; - print ''."\n"; + $var=!$var; + print ''."\n"; - $var=!$var; - print ''."\n"; + $var=!$var; + print ''."\n"; - $var=!$var; - print ''."\n"; + $var=!$var; + print ''."\n"; - $var=!$var; - print ''; - print ''."\n"; + $var=!$var; + print ''; + print ''."\n"; - $var=!$var; - print ''; - print ''."\n"; + $var=!$var; + print ''; + print ''."\n"; - $var=!$var; - print ''; - print ''."\n"; + $var=!$var; + print ''; + print ''."\n"; - // Web - $var=!$var; - print ''; - print ''."\n"; + // Web + $var=!$var; + print ''; + print ''."\n"; - // Barcode - if ($conf->barcode->enabled) - { - $var=!$var; - print ''; - print ''; - } + // Barcode + if ($conf->barcode->enabled) + { + $var=!$var; + print ''; + print ''; + } - // Logo - $var=!$var; - print ''; + // Logo + $var=!$var; + print ''; - $var=!$var; - print ''; - print ''; + $var=!$var; + print ''; + print ''; - print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyName").''; - print '
'.$langs->trans("CompanyName").''; + print '
'.$langs->trans("CompanyAddress").''; - print '
'.$langs->trans("CompanyAddress").''; + print '
'.$langs->trans("CompanyZip").''; - print '
'.$langs->trans("CompanyZip").''; + print '
'.$langs->trans("CompanyTown").''; - print '
'.$langs->trans("CompanyTown").''; + print '
'.$langs->trans("Country").''; - $form->select_pays($conf->global->MAIN_INFO_SOCIETE_PAYS,'pays_id',($conf->use_javascript_ajax?' onChange="company_save_refresh()"':'')); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'.$langs->trans("Country").''; + $pays_selected=$pays_id; + //if (empty($pays_selected)) $pays_selected=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation + $form->select_pays($pays_selected,'pays_id',($conf->use_javascript_ajax?' onChange="company_save_refresh()"':'')); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans("State").''; - $pays_code=''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) $pays_code=getCountry($conf->global->MAIN_INFO_SOCIETE_PAYS,2); - $formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT,$pays_code,'departement_id'); - print '
'.$langs->trans("State").''; + $formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT,$pays_code,'departement_id'); + print '
'.$langs->trans("CompanyCurrency").''; - $form->select_currency($conf->global->MAIN_MONNAIE,"currency"); - print '
'.$langs->trans("CompanyCurrency").''; + $form->select_currency($conf->global->MAIN_MONNAIE,"currency"); + print '
'.$langs->trans("Tel").''; - print '
'.$langs->trans("Tel").''; + print '
'.$langs->trans("Fax").''; - print '
'.$langs->trans("Fax").''; + print '
'.$langs->trans("Mail").''; - print '
'.$langs->trans("Mail").''; + print '
'.$langs->trans("Web").''; - print '
'.$langs->trans("Web").''; + print '
'.$langs->trans("Gencod").''; - print '
'.$langs->trans("Gencod").''; + print '
'.$langs->trans("Logo").' (png,jpg)'; - print '
'; - print ''; - print ''; - if ($mysoc->logo_mini) - { - print ''.img_delete($langs->trans("Delete")).''; - if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) - { - print '   '; - print ''; - } - } - else - { - print ''; - } - print '
'; - print '
'.$langs->trans("Logo").' (png,jpg)'; + print '
'; + print ''; + print ''; + if ($mysoc->logo_mini) + { + print ''.img_delete($langs->trans("Delete")).''; + if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) + { + print '   '; + print ''; + } + } + else + { + print ''; + } + print '
'; + print '
'.$langs->trans("Note").''; - print '
'.$langs->trans("Note").''; + print '
'; + print ''; - print '
'; + print '
'; - // Identifiants de la societe (propre au pays) - print ''; - print ''; - $var=true; + // Identifiants de la societe (propre au pays) + print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'; + print ''; + $var=true; - $langs->load("companies"); + $langs->load("companies"); - // Recupere code pays - $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; - $sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS; - $resql=$db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj->code) $code_pays=$obj->code; - } - else { - dol_print_error($db); - } - } + // Capital + $var=!$var; + print ''; - // Capital - $var=!$var; - print ''; + // Forme juridique + $var=!$var; + print ''; - // Forme juridique - $var=!$var; - print ''; + // ProfID1 + if ($langs->transcountry("ProfId1",$pays_code) != '-') + { + $var=!$var; + print ''; + } - // ProfID1 - if ($langs->transcountry("ProfId1",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // ProfId2 + if ($langs->transcountry("ProfId2",$pays_code) != '-') + { + $var=!$var; + print ''; + } - // ProfId2 - if ($langs->transcountry("ProfId2",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // ProfId3 + if ($langs->transcountry("ProfId3",$pays_code) != '-') + { + $var=!$var; + print ''; + } - // ProfId3 - if ($langs->transcountry("ProfId3",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // ProfId4 + if ($langs->transcountry("ProfId4",$pays_code) != '-') + { + $var=!$var; + print ''; + } - // ProfId4 - if ($langs->transcountry("ProfId4",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // TVA Intra + $var=!$var; + print ''; - // TVA Intra - $var=!$var; - print ''; - - print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("Capital").''; + print '
'.$langs->trans("Capital").''; - print '
'.$langs->trans("JuridicalStatus").''; + if ($pays_code) + { + $formcompany->select_forme_juridique($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$pays_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans("JuridicalStatus").''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - $formcompany->select_forme_juridique($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$code_pays); - } - else - { - print $countrynotdefined; - } - print '
'.$langs->transcountry("ProfId1",$pays_code).''; + if ($pays_code) + { + print ''; + } + else + { + print $countrynotdefined; + } + print '
'.$langs->transcountry("ProfId1",$code_pays).''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - print ''; - } - else - { - print $countrynotdefined; - } - print '
'.$langs->transcountry("ProfId2",$pays_code).''; + if ($pays_code) + { + print ''; + } + else + { + print $countrynotdefined; + } + print '
'.$langs->transcountry("ProfId2",$code_pays).''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - print ''; - } - else - { - print $countrynotdefined; - } - print '
'.$langs->transcountry("ProfId3",$pays_code).''; + if ($pays_code) + { + print ''; + } + else + { + print $countrynotdefined; + } + print '
'.$langs->transcountry("ProfId3",$code_pays).''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - print ''; - } - else - { - print $countrynotdefined; - } - print '
'.$langs->transcountry("ProfId4",$pays_code).''; + if ($pays_code) + { + print ''; + } + else + { + print $countrynotdefined; + } + print '
'.$langs->transcountry("ProfId4",$code_pays).''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - print ''; - } - else - { - print $countrynotdefined; - } - print '
'.$langs->trans("VATIntra").''; + print ''; + print '
'.$langs->trans("VATIntra").''; - print ''; - print '
'; + print ''; - /* - * Debut d'annee fiscale - */ - print '
'; - print ''; - print ''; - print ''; - print "\n"; - $var=true; + /* + * Debut d'annee fiscale + */ + print '
'; + print '
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
'; + print ''; + print ''; + print "\n"; + $var=true; - $var=!$var; - print ''; + $var=!$var; + print ''; - print "
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
'.$langs->trans("FiscalMonthStart").''; - print $form->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . '
'.$langs->trans("FiscalMonthStart").''; + print $form->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . '
"; + print ""; - /* - * Options fiscale - */ - print '
'; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $var=true; + /* + * Options fiscale + */ + print '
'; + print '
'.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; + print ''; + print ''; + print ''; + print "\n"; + $var=true; - $var=!$var; - print ""; - print '\n"; + $var=!$var; + print ""; + print '\n"; - $var=!$var; - print ""; - print '\n"; + $var=!$var; + print ""; + print '\n"; - print "
'.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; - print ""; - print ""; - print "\n"; - print "
".$langs->trans("VATIsUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."
"; - print "
'; + print ""; + print ""; + print "\n"; + print "
".$langs->trans("VATIsUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."
"; + print "
'; - print ""; - print ""; - print "\n"; - print "
".$langs->trans("VATIsNotUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."
"; - print "
'; + print ""; + print ""; + print "\n"; + print "
".$langs->trans("VATIsNotUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."
"; + print "
"; + print ""; - /* - * Local Taxes - */ - if ($code_pays=='ES') - { - // Local Tax 1 - print '
'; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $var=true; + /* + * Local Taxes + */ + if ($pays_code=='ES') + { + // Local Tax 1 + print '
'; + print '
'.$langs->transcountry("LocalTax1Management",$code_pays).''.$langs->trans("Description").' 
'; + print ''; + print ''; + print ''; + print "\n"; + $var=true; - $var=!$var; - print ""; - print '\n"; + $var=!$var; + print ""; + print '\n"; - $var=!$var; - print ""; - print '\n"; - print "
'.$langs->transcountry("LocalTax1Management",$pays_code).''.$langs->trans("Description").' 
'; - print ""; - print ""; - print "\n"; - print "
".$langs->transcountry("LocalTax1IsUsedDesc",$code_pays)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$code_pays)."
"; - print "
'; + print ""; + print ""; + print "\n"; + print "
".$langs->transcountry("LocalTax1IsUsedDesc",$pays_code)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$pays_code)."
"; + print "
'; - print ""; - print ""; - print "\n"; - print "
".$langs->transcountry("LocalTax1IsNotUsedDesc",$code_pays)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample",$code_pays)."
"; - print "
"; + $var=!$var; + print ""; + print ''; + print ""; + print ""; + print "\n"; + print "
".$langs->transcountry("LocalTax1IsNotUsedDesc",$pays_code)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample",$pays_code)."
"; + print "\n"; + print ""; - // Local Tax 2 - print '
'; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $var=true; + // Local Tax 2 + print '
'; + print '
'.$langs->transcountry("LocalTax2Management",$code_pays).''.$langs->trans("Description").' 
'; + print ''; + print ''; + print ''; + print "\n"; + $var=true; - $var=!$var; - print ""; - print '\n"; + $var=!$var; + print ""; + print '\n"; - $var=!$var; - print ""; - print '\n"; - print "
'.$langs->transcountry("LocalTax2Management",$pays_code).''.$langs->trans("Description").' 
'; - print ""; - print ""; - print "\n"; - print "
".$langs->transcountry("LocalTax2IsUsedDesc",$code_pays)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$code_pays)."
"; - print "
'; + print ""; + print ""; + print "\n"; + print "
".$langs->transcountry("LocalTax2IsUsedDesc",$pays_code)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$pays_code)."
"; + print "
'; - print ""; - print ""; - print "\n"; - print "
".$langs->transcountry("LocalTax2IsNotUsedDesc",$code_pays)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$code_pays)."
"; - print "
"; - } + $var=!$var; + print ""; + print ''; + print ""; + print ""; + print "\n"; + print "
".$langs->transcountry("LocalTax2IsNotUsedDesc",$pays_code)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$pays_code)."
"; + print "\n"; + print ""; + } - print '
'; + print '
'; print ''; print '     '; print ''; print '
'; - print '
'; + print '
'; - print ''; + print ''; } else { - /* - * Show parameters - */ + /* + * Show parameters + */ - if ($message) print $message.'
'; + if ($message) print $message.'
'; - // Actions buttons - //print '
'; - //print ''.$langs->trans("Modify").''; - //print '

'; + // Actions buttons + //print '
'; + //print ''.$langs->trans("Modify").''; + //print '

'; - print ''; - print ''; - $var=true; + print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'; + print ''; + $var=true; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - // Web - $var=!$var; - print ''; + // Web + $var=!$var; + print ''; - // Barcode - if ($conf->barcode->enabled) - { - $var=!$var; - print ''; - } + // Barcode + if ($conf->barcode->enabled) + { + $var=!$var; + print ''; + } - // Logo - $var=!$var; - print ''; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyName").'' . $conf->global->MAIN_INFO_SOCIETE_NOM . '
'.$langs->trans("CompanyName").'' . $conf->global->MAIN_INFO_SOCIETE_NOM . '
'.$langs->trans("CompanyAddress").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_ADRESSE) . '
'.$langs->trans("CompanyAddress").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_ADRESSE) . '
'.$langs->trans("CompanyZip").'' . $conf->global->MAIN_INFO_SOCIETE_CP . '
'.$langs->trans("CompanyZip").'' . $conf->global->MAIN_INFO_SOCIETE_CP . '
'.$langs->trans("CompanyTown").'' . $conf->global->MAIN_INFO_SOCIETE_VILLE . '
'.$langs->trans("CompanyTown").'' . $conf->global->MAIN_INFO_SOCIETE_VILLE . '
'.$langs->trans("CompanyCountry").''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - $img=picto_from_langcode(getCountry($conf->global->MAIN_INFO_SOCIETE_PAYS,2)); - print $img?$img.' ':''; - print getCountry($conf->global->MAIN_INFO_SOCIETE_PAYS,1); - } - print '
'.$langs->trans("CompanyCountry").''; + if ($pays_code) + { + $img=picto_from_langcode($pays_code); + print $img?$img.' ':''; + print getCountry($pays_code,1); + } + print '
'.$langs->trans("State").''; - if ($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT) - { - $sql = "SELECT code_departement as code, nom as label from ".MAIN_DB_PREFIX."c_departements where rowid = '".$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT."'"; - $resql=$db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - } - else - { - dol_print_error($db); - } - $state=$obj->label; - print $state; - } - print '
'.$langs->trans("State").''; + if ($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT) + { + $sql = "SELECT code_departement as code, nom as label from ".MAIN_DB_PREFIX."c_departements where rowid = '".$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $state=$obj->label; + print $state; + } + print '
'.$langs->trans("CompanyCurrency").''; - print currency_name($conf->global->MAIN_MONNAIE,1); - print ' ('.$conf->global->MAIN_MONNAIE.')'; - print '
'.$langs->trans("CompanyCurrency").''; + print currency_name($conf->global->MAIN_MONNAIE,1); + print ' ('.$conf->global->MAIN_MONNAIE.')'; + print '
'.$langs->trans("Tel").'' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_TEL,$mysoc->pays_code) . '
'.$langs->trans("Tel").'' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_TEL,$mysoc->pays_code) . '
'.$langs->trans("Fax").'' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_FAX,$mysoc->pays_code) . '
'.$langs->trans("Fax").'' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_FAX,$mysoc->pays_code) . '
'.$langs->trans("Mail").'' . dol_print_email($conf->global->MAIN_INFO_SOCIETE_MAIL,0,0,0,80) . '
'.$langs->trans("Mail").'' . dol_print_email($conf->global->MAIN_INFO_SOCIETE_MAIL,0,0,0,80) . '
'.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB,'_blank',80) . '
'.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB,'_blank',80) . '
'.$langs->trans("Gencod").'' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '
'.$langs->trans("Gencod").'' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '
'.$langs->trans("Logo").''; + // Logo + $var=!$var; + print '
'.$langs->trans("Logo").''; - print '
'; - print $mysoc->logo; - print ''; + print '
'; + print $mysoc->logo; + print ''; - // On propose la generation de la vignette si elle n'existe pas - if (!is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini) && preg_match('/(\.jpg|\.jpeg|\.png)$/i',$mysoc->logo)) - { - print 'logo).'">'.img_refresh($langs->trans('GenerateThumb')).'  '; - } - else if ($mysoc->logo_mini && is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) - { - print ''; - } - else - { - print ''; - } - print '
'; + // On propose la generation de la vignette si elle n'existe pas + if (!is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini) && preg_match('/(\.jpg|\.jpeg|\.png)$/i',$mysoc->logo)) + { + print 'logo).'">'.img_refresh($langs->trans('GenerateThumb')).'  '; + } + else if ($mysoc->logo_mini && is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) + { + print ''; + } + else + { + print ''; + } + print '
'; - print '
'.$langs->trans("Note").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) . '
'.$langs->trans("Note").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) . '
'; + print ''; - print '
'; + print '
'; - // Identifiants de la societe (propre au pays) - print '
'; - print ''; - print ''; - print ''; - $var=true; + // Identifiants de la societe (propre au pays) + print ''; + print ''; + print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'; + print ''; + $var=true; - // Recupere code pays - $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; - $sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS; - $result=$db->query($sql); - if ($result) - { - $obj = $db->fetch_object($result); - if ($obj->code) $code_pays=$obj->code; - } - else { - dol_print_error($db); - } - } + // Capital + $var=!$var; + print ''; - // Capital - $var=!$var; - print ''; + // Forme juridique + $var=!$var; + print ''; - // Forme juridique - $var=!$var; - print ''; + // ProfId1 + if ($langs->transcountry("ProfId1",$pays_code) != '-') + { + $var=!$var; + print ''; + } - // ProfId1 - if ($langs->transcountry("ProfId1",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // ProfId2 + if ($langs->transcountry("ProfId2",$pays_code) != '-') + { + $var=!$var; + print ''; + } - // ProfId2 - if ($langs->transcountry("ProfId2",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // ProfId3 + if ($langs->transcountry("ProfId3",$pays_code) != '-') + { + $var=!$var; + print ''; + } - // ProfId3 - if ($langs->transcountry("ProfId3",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // ProfId4 + if ($langs->transcountry("ProfId4",$pays_code) != '-') + { + $var=!$var; + print ''; + } - // ProfId4 - if ($langs->transcountry("ProfId4",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // TVA + if ($conf->use_javascript_ajax) + { + print "\n"; + print ''; + print "\n"; + } + $var=!$var; + print ''; + print ''; + print ''; - // TVA - if ($conf->use_javascript_ajax) - { - print "\n"; - print ''; - print "\n"; - } - $var=!$var; - print ''; - print ''; - print ''; + print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("Capital").''; + print $conf->global->MAIN_INFO_CAPITAL . '
'.$langs->trans("Capital").''; - print $conf->global->MAIN_INFO_CAPITAL . '
'.$langs->trans("JuridicalStatus").''; + print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,1); + print '
'.$langs->trans("JuridicalStatus").''; - print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,1); - print '
'.$langs->transcountry("ProfId1",$pays_code).''; + if ($langs->transcountry("ProfId1",$pays_code) != '-') + { + print $conf->global->MAIN_INFO_SIREN; + if ($conf->global->MAIN_INFO_SIREN && $pays_code == 'FR') print '   '.$langs->trans("Check").''; + } + print '
'.$langs->transcountry("ProfId1",$code_pays).''; - if ($langs->transcountry("ProfId1",$code_pays) != '-') - { - print $conf->global->MAIN_INFO_SIREN; - if ($conf->global->MAIN_INFO_SIREN && $code_pays == 'FR') print '   '.$langs->trans("Check").''; - } - print '
'.$langs->transcountry("ProfId2",$pays_code).''; + if ($langs->transcountry("ProfId2",$pays_code) != '-') + { + print $conf->global->MAIN_INFO_SIRET; + } + print '
'.$langs->transcountry("ProfId2",$code_pays).''; - if ($langs->transcountry("ProfId2",$code_pays) != '-') - { - print $conf->global->MAIN_INFO_SIRET; - } - print '
'.$langs->transcountry("ProfId3",$pays_code).''; + if ($langs->transcountry("ProfId3",$pays_code) != '-') + { + print $conf->global->MAIN_INFO_APE; + } + print '
'.$langs->transcountry("ProfId3",$code_pays).''; - if ($langs->transcountry("ProfId3",$code_pays) != '-') - { - print $conf->global->MAIN_INFO_APE; - } - print '
'.$langs->transcountry("ProfId4",$pays_code).''; + if ($langs->transcountry("ProfId4",$pays_code) != '-') + { + print $conf->global->MAIN_INFO_RCS; + } + print '
'.$langs->transcountry("ProfId4",$code_pays).''; - if ($langs->transcountry("ProfId4",$code_pays) != '-') - { - print $conf->global->MAIN_INFO_RCS; - } - print '
'.$langs->trans("VATIntra").''; + if ($conf->global->MAIN_INFO_TVAINTRA) + { + $s=''; + $s.=$conf->global->MAIN_INFO_TVAINTRA; + $s.=''; + $s.='   '; + if ($conf->use_javascript_ajax) + { + $s.=''.$langs->trans("VATIntraCheck").''; + print $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); + } + else + { + print $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; + } + } + else + { + print ' '; + } + print '
'.$langs->trans("VATIntra").''; - if ($conf->global->MAIN_INFO_TVAINTRA) - { - $s=''; - $s.=$conf->global->MAIN_INFO_TVAINTRA; - $s.=''; - $s.='   '; - if ($conf->use_javascript_ajax) - { - $s.=''.$langs->trans("VATIntraCheck").''; - print $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); - } - else - { - print $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; - } - } - else - { - print ' '; - } - print '
'; + print '
'; - print ''; - print ''; + /* + * Debut d'annee fiscale + */ + print '
'; + print ''; + print ''; + print ''; + print "\n"; + $var=true; - /* - * Debut d'annee fiscale - */ - print '
'; - print '
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
'; - print ''; - print ''; - print "\n"; - $var=true; + $var=!$var; + print ''; - $var=!$var; - print ''; + print "
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
'.$langs->trans("FiscalMonthStart").''; + $monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1; + print monthArrayOrSelected($monthstart) . '
'.$langs->trans("FiscalMonthStart").''; - $monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1; - print monthArrayOrSelected($monthstart) . '
"; - print ""; + /* + * Options fiscale + */ + print '
'; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $var=true; - /* - * Options fiscale - */ - print '
'; - print '
'.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; - print ''; - print ''; - print ''; - print "\n"; - $var=true; + $var=!$var; + print ""; + print '\n"; - $var=!$var; - print ""; - print '\n"; + $var=!$var; + print ""; + print '\n"; - $var=!$var; - print ""; - print '\n"; - - print "
'.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; + print ""; + print ""; + print "\n"; + print "
".$langs->trans("VATIsUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."
"; + print "
'; - print ""; - print ""; - print "\n"; - print "
".$langs->trans("VATIsUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."
"; - print "
'; + print ""; + print ""; + print "\n"; + print "
".$langs->trans("VATIsNotUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."
"; + print "
'; - print ""; - print ""; - print "\n"; - print "
".$langs->trans("VATIsNotUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."
"; - print "
"; + print ""; - /* - * Local Taxes - */ - if ($code_pays=='ES') - { - // Local Tax 1 - print '
'; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $var=true; + /* + * Local Taxes + */ + if ($pays_code=='ES') + { + // Local Tax 1 + print '
'; + print '
'.$langs->transcountry("LocalTax1Management",$code_pays).''.$langs->trans("Description").' 
'; + print ''; + print ''; + print ''; + print "\n"; + $var=true; - $var=!$var; - print ""; - print '\n"; + $var=!$var; + print ""; + print '\n"; - $var=!$var; - print ""; - print '\n"; + $var=!$var; + print ""; + print '\n"; - print "
'.$langs->transcountry("LocalTax1Management",$pays_code).''.$langs->trans("Description").' 
'; - print ""; - print ""; - print "\n"; - print "
".$langs->transcountry("LocalTax1IsUsedDesc",$code_pays)."
".$langs->trans("Example",$code_pays).': '.$langs->transcountry("LocalTax1IsUsedExample",$code_pays)."
"; - print "
'; + print ""; + print ""; + print "\n"; + print "
".$langs->transcountry("LocalTax1IsUsedDesc",$pays_code)."
".$langs->trans("Example",$pays_code).': '.$langs->transcountry("LocalTax1IsUsedExample",$pays_code)."
"; + print "
'; - print ""; - print ""; - print "\n"; - print "
".$langs->transcountry("LocalTax1IsNotUsedDesc",$code_pays)."
".$langs->trans("Example",$code_pays).': '.$langs->transcountry("LocalTax1IsNotUsedExample",$code_pays)."
"; - print "
'; + print ""; + print ""; + print "\n"; + print "
".$langs->transcountry("LocalTax1IsNotUsedDesc",$pays_code)."
".$langs->trans("Example",$pays_code).': '.$langs->transcountry("LocalTax1IsNotUsedExample",$pays_code)."
"; + print "
"; + print ""; - // Local Tax 2 - print '
'; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $var=true; + // Local Tax 2 + print '
'; + print '
'.$langs->transcountry("LocalTax2Management",$code_pays).''.$langs->trans("Description").' 
'; + print ''; + print ''; + print ''; + print "\n"; + $var=true; - $var=!$var; - print ""; - print '\n"; + $var=!$var; + print ""; + print '\n"; - $var=!$var; - print ""; - print '\n"; + $var=!$var; + print ""; + print '\n"; - print "
'.$langs->transcountry("LocalTax2Management",$pays_code).''.$langs->trans("Description").' 
'; - print ""; - print ""; - print "\n"; - print "
".$langs->transcountry("LocalTax2IsUsedDesc",$code_pays)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$code_pays)."
"; - print "
'; + print ""; + print ""; + print "\n"; + print "
".$langs->transcountry("LocalTax2IsUsedDesc",$pays_code)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$pays_code)."
"; + print "
'; - print ""; - print ""; - print "\n"; - print "
".$langs->transcountry("LocalTax2IsNotUsedDesc",$code_pays)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$code_pays)."
"; - print "
'; + print ""; + print ""; + print "\n"; + print "
".$langs->transcountry("LocalTax2IsNotUsedDesc",$pays_code)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$pays_code)."
"; + print "
"; - } + print ""; + } - // Actions buttons - print '
'; - print ''.$langs->trans("Modify").''; - print '
'; + // Actions buttons + print '
'; + print ''.$langs->trans("Modify").''; + print '
'; - print '
'; + print '
'; } $db->close(); diff --git a/htdocs/comm/address.php b/htdocs/comm/address.php index 1617535fb88..099ac5939f3 100644 --- a/htdocs/comm/address.php +++ b/htdocs/comm/address.php @@ -193,7 +193,7 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create') } // On positionne pays_id, pays_code et libelle du pays choisi - $address->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + $address->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; if ($address->pays_id) { $sql = "SELECT code, libelle"; @@ -296,7 +296,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') $address->address = $_POST["address"]; $address->zip = $_POST["zip"]; $address->ville = $_POST["ville"]; - $address->pays_id = $_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + $address->pays_id = $_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; $address->tel = $_POST["tel"]; $address->fax = $_POST["fax"]; $address->note = $_POST["note"]; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 4a7bac3b2f6..f8b1628b105 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -276,7 +276,7 @@ if ($user->rights->societe->contact->creer) $contact->fk_departement = $_POST["departement_id"]; // We set pays_id, pays_code and label for the selected country - $contact->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + $contact->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; if ($contact->fk_pays) { $sql = "SELECT code, libelle"; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index bccb6a89b14..23ca735993f 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -228,7 +228,7 @@ class FormCompany // Affiche la rupture si on est en mode liste multipays if (! $pays_code && $obj->code_pays) { - print '\n"; + print '\n"; $pays=$obj->libelle_pays; } } diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php index 17a970e40d5..cf60ffa0494 100644 --- a/htdocs/lib/company.lib.php +++ b/htdocs/lib/company.lib.php @@ -189,7 +189,6 @@ function getCountry($id,$withcode=0) { global $db,$langs; - // TODO Optimize: Try to translate and make SQL request only if it fails $sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays"; if (is_numeric($id)) $sql.= " WHERE rowid=".$id; else $sql.= " WHERE code='".$id."'"; diff --git a/htdocs/lib/files.lib.php b/htdocs/lib/files.lib.php index 1a0a8955f78..da2ded5cefa 100644 --- a/htdocs/lib/files.lib.php +++ b/htdocs/lib/files.lib.php @@ -244,6 +244,19 @@ function dol_mimetype($file,$default='application/octet-stream',$shortmime=0) } +/** + * \brief Test if filename is a directory + * \param folder Name of folder + * \return boolean True if it's a directory, False if not found + */ +function dol_is_dir($folder) +{ + $newfolder=dol_osencode($folder); + if (is_dir($newfolder)) return true; + else return false; +} + + /** * \brief Test if a folder is empty * \param folder Name of folder diff --git a/htdocs/lib/lib_head.js b/htdocs/lib/lib_head.js index 2ab991f00ef..32abd7e4a52 100644 --- a/htdocs/lib/lib_head.js +++ b/htdocs/lib/lib_head.js @@ -569,6 +569,17 @@ function getIntegerInString(str,i,minlength,maxlength) } +/*================================================================= +Purpose: Clean string to have it url encoded +Input: s +Author: Laurent Destailleur +Licence: GPL +==================================================================*/ +function urlencode(s) { + return s.replace(/\+/gi,'%2B'); +} + + /*================================================================= Purpose: Show a popup HTML page. Input: url,title @@ -767,3 +778,5 @@ function uncheckBox(boxId) { elementId.checked = false; } } + + diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 04519c88c8d..e08eb0b50b4 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -669,9 +669,6 @@ dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]); //Another call for easy debugg //dol_syslog("Access to ".$_SERVER["PHP_SELF"].' GET='.join(',',array_keys($_GET)).'->'.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST)); -// For backward compatibility -if (! defined('MAIN_INFO_SOCIETE_PAYS')) define('MAIN_INFO_SOCIETE_PAYS','1'); - // Load main languages files if (! defined('NOREQUIRETRAN')) { diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 1ea7d5377ef..ca8fceddfcd 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -362,7 +362,7 @@ if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC')) } else // For backward compatibility { - include(DOL_DOCUMENT_ROOT.'/lib/company.lib.php'); + include_once(DOL_DOCUMENT_ROOT.'/lib/company.lib.php'); $pays_code=getCountry($pays_id,2); // This need a SQL request, but it's the old feature $pays_label=getCountry($pays_id,0); // This need a SQL request, but it's the old feature } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 4afb7bd58c6..d32b2b167f7 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -428,7 +428,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create') $soc->default_lang=$_POST["default_lang"]; // We set pays_id, pays_code and label for the selected country - $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; if ($soc->pays_id) { $sql = "SELECT code, libelle"; @@ -802,7 +802,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') $soc->address=$_POST["adresse"]; $soc->cp=$_POST["cp"]; $soc->ville=$_POST["ville"]; - $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; $soc->departement_id=$_POST["departement_id"]; $soc->tel=$_POST["tel"]; $soc->fax=$_POST["fax"];