diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index f00f8326020..809fd4e7f97 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -79,7 +79,8 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update') { create_exdir($conf->mycompany->dir_output.'/logos/'); } - if (dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->mycompany->dir_output.'/logos/'.$original_file,1,0,$_FILES['logo']['error']) > 0) + $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); @@ -108,6 +109,12 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update') } 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").'
'; diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index 844eac0ab3f..e5384ca0605 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -64,13 +64,13 @@ $base=0; $sqls = array(); if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') { - $sqls[0] = "SHOW VARIABLES"; - $sqls[1] = "SHOW STATUS"; + $sqls[0] = "SHOW VARIABLES"; // TODO Use function getServerParametersValues + $sqls[1] = "SHOW STATUS"; // TODO Use function getServerStatusValues $base=1; } else if ($conf->db->type == 'pgsql') { - $sqls[0] = "select name,setting from pg_settings;"; + $sqls[0] = "select name,setting from pg_settings"; $base=2; } else if ($conf->db->type == 'mssql') diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 29059e671b2..f5aad0df34b 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -89,9 +89,20 @@ $dblabel=$db->getLabel(); $dbversion=$db->getVersion(); print "".$langs->trans("Version")."" .$dblabel." ".$dbversion."\n"; print ''; +// Add checks on database options +if ($db->type == 'pgsql') +{ + // Check option standard_conforming_strings is on + $paramarray=$db->getServerParametersValues('standard_conforming_strings'); + if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1) + { + $langs->load("errors"); + print '
'.$langs->trans("ErrorDatabaseParameterWrong",'standard_conforming_strings','on').'
'; + } +} print '
'; -// Database +// Browser print ''; print "\n"; print "\n"; diff --git a/htdocs/includes/modules/modFacture.class.php b/htdocs/includes/modules/modFacture.class.php index 25126bc55dd..9ff2d92c797 100644 --- a/htdocs/includes/modules/modFacture.class.php +++ b/htdocs/includes/modules/modFacture.class.php @@ -92,7 +92,7 @@ class modFacture extends DolibarrModules $this->const[$r][0] = "FACTURE_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/odttemplates/invoices"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/invoices"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -217,9 +217,9 @@ class modFacture extends DolibarrModules $this->remove(); require_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); - $dirodt=DOL_DATA_ROOT.'/odttemplates/invoices'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/invoices'; create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/odttemplates/invoices/template_invoice.odt',$dirodt.'/template_invoice.odt',0,0); + dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt',$dirodt.'/template_invoice.odt',0,0); $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, diff --git a/htdocs/includes/modules/modSociete.class.php b/htdocs/includes/modules/modSociete.class.php index 242c90d5315..73fee6930d9 100644 --- a/htdocs/includes/modules/modSociete.class.php +++ b/htdocs/includes/modules/modSociete.class.php @@ -104,7 +104,7 @@ class modSociete extends DolibarrModules $this->const[$r][0] = "COMPANY_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/odttemplates/thirdparties"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/thirdparties"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -277,9 +277,9 @@ class modSociete extends DolibarrModules //$this->remove($options); require_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); - $dirodt=DOL_DATA_ROOT.'/odttemplates/thirdparties'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties'; create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/odttemplates/thirdparties/template_thirdparty.odt',$dirodt.'/template_thirdparty.odt',0,0); + dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt',$dirodt.'/template_thirdparty.odt',0,0); $sql = array(); diff --git a/htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php index 0897fc3f13a..51a41e4dbb1 100644 --- a/htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/includes/modules/societe/doc/doc_generic_odt.modules.php @@ -82,6 +82,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc function get_substitutionarray_mysoc($mysoc) { return array( + 'mycompany_logo'=>$mysoc->logo, 'mycompany_name'=>$mysoc->name, 'mycompany_email'=>$mysoc->email, 'mycompany_phone'=>$mysoc->phone, @@ -90,13 +91,15 @@ class doc_generic_odt extends ModeleThirdPartyDoc 'mycompany_zip'=>$mysoc->zip, 'mycompany_town'=>$mysoc->town, 'mycompany_country'=>$mysoc->country, - 'mycompany_url'=>$mysoc->url, + 'mycompany_web'=>$mysoc->url, + 'mycompany_juridicalstatus'=>$mysoc->forme_juridique, + 'mycompany_capital'=>$mysoc->capital, 'mycompany_barcode'=>$mysoc->gencode, - 'mycompany_vat'=>$mysoc->tva_intra, 'mycompany_idprof1'=>$mysoc->profid1, 'mycompany_idprof2'=>$mysoc->profid2, 'mycompany_idprof3'=>$mysoc->profid3, 'mycompany_idprof4'=>$mysoc->profid4, + 'mycompany_vatnumber'=>$mysoc->tva_intra, 'mycompany_note'=>$mysoc->note ); } @@ -118,13 +121,15 @@ class doc_generic_odt extends ModeleThirdPartyDoc 'company_zip'=>$object->zip, 'company_town'=>$object->town, 'company_country'=>$object->country, - 'company_url'=>$object->url, + 'company_web'=>$object->url, 'company_barcode'=>$object->gencode, - 'company_vat'=>$object->tva_intra, + 'company_vatnumber'=>$object->tva_intra, 'company_customercode'=>$object->code_client, 'company_suppliercode'=>$object->code_fournisseur, 'company_customeraccountancycode'=>$object->code_compta, 'company_supplieraccountancycode'=>$object->code_compta_fournisseur, + 'company_juridicalstatus'=>$object->forme_juridique, + 'company_capital'=>$object->capital, 'company_idprof1'=>$object->idprof1, 'company_idprof2'=>$object->idprof2, 'company_idprof3'=>$object->idprof3, diff --git a/htdocs/install/odttemplates/README b/htdocs/install/doctemplates/README similarity index 100% rename from htdocs/install/odttemplates/README rename to htdocs/install/doctemplates/README diff --git a/htdocs/install/odttemplates/invoices/template_invoice.odt b/htdocs/install/doctemplates/invoices/template_invoice.odt similarity index 100% rename from htdocs/install/odttemplates/invoices/template_invoice.odt rename to htdocs/install/doctemplates/invoices/template_invoice.odt diff --git a/htdocs/install/doctemplates/thirdparties/template_thirdparty.odt b/htdocs/install/doctemplates/thirdparties/template_thirdparty.odt new file mode 100644 index 00000000000..fa6bfc9ee7c Binary files /dev/null and b/htdocs/install/doctemplates/thirdparties/template_thirdparty.odt differ diff --git a/htdocs/install/odttemplates/thirdparties/template_thirdparty.odt b/htdocs/install/odttemplates/thirdparties/template_thirdparty.odt deleted file mode 100644 index 7e8c0c5b825..00000000000 Binary files a/htdocs/install/odttemplates/thirdparties/template_thirdparty.odt and /dev/null differ diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index d54a0e7c397..9f9c1e8e916 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -69,3 +69,4 @@ WarningsOnXLines=Warnings on %s source lines ErrorFileIsInfectedWithAVirus=The antivirus program was not able to validate the file (file might be infected by a virus) ErrorSpecialCharNotAllowedForField=Special characters are not allowed for field "%s" WarningNoDocumentModelActivated=No model, for document generation, has been activated. A model will be choosed by default until you check your module setup. +ErrorDatabaseParameterWrong=Database setup parameter '%s' has a value not compatible to use Dolibarr (must have value '%s'). diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index af2de5b0c51..53b5e6c7f30 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -70,3 +70,4 @@ WarningsOnXLines=Alertes sur %s lignes sources ErrorFileIsInfectedWithAVirus=L'antivirus n'a pas pu valider ce fichier (il est probablement infecté par un virus) ! ErrorSpecialCharNotAllowedForField=Les caractères spéciaux ne sont pas admis pour le champ "%s" WarningNoDocumentModelActivated=Aucun modèle, pour la génération de document, n'a été activé. Un modèle sera pris par défaut en attendant la correction de configuration du module. +ErrorDatabaseParameterWrong=Le paramètre de configuration de la base de donnée '%s' a une valeur non compatible pour une utilisation de Dolibarr (doit avoir la valeur '%s'). \ No newline at end of file diff --git a/htdocs/lib/databases/mysql.lib.php b/htdocs/lib/databases/mysql.lib.php index 46e18e01fab..3dba903229a 100644 --- a/htdocs/lib/databases/mysql.lib.php +++ b/htdocs/lib/databases/mysql.lib.php @@ -1155,6 +1155,47 @@ class DoliDb return $fullpathofimport; } + /** + * \brief Return value of server parameters + * \param filter Filter list on a particular value + * \return string Value for parameter + */ + function getServerParametersValues($filter='') + { + $result=array(); + + $sql='SHOW VARIABLES'; + if ($filter) $sql.=" LIKE '".addslashes($key)."'"; + $resql=$this->query($sql); + if ($resql) + { + $obj=$this->fetch_object($resql); + $result[$obj->Variable_name]=$obj->Value; + } + + return $result; + } + + /** + * \brief Return value of server status + * \param filter Filter list on a particular value + * \return string Value for parameter + */ + function getServerStatusValues($key,$filter='') + { + $result=array(); + + $sql='SHOW STATUS'; + if ($filter) $sql.=" LIKE '".addslashes($key)."'"; + $resql=$this->query($sql); + if ($resql) + { + $obj=$this->fetch_object($resql); + $result[$obj->Variable_name]=$obj->Value; + } + + return $result; + } } ?> diff --git a/htdocs/lib/databases/mysqli.lib.php b/htdocs/lib/databases/mysqli.lib.php index 3e66d347cc0..953f468d12a 100644 --- a/htdocs/lib/databases/mysqli.lib.php +++ b/htdocs/lib/databases/mysqli.lib.php @@ -1167,6 +1167,47 @@ class DoliDb return $fullpathofimport; } + /** + * \brief Return value of server parameters + * \param filter Filter list on a particular value + * \return string Value for parameter + */ + function getServerParametersValues($key,$filter='') + { + $result=array(); + + $sql='SHOW VARIABLES'; + if ($filter) $sql.=" LIKE '".addslashes($key)."'"; + $resql=$this->query($sql); + if ($resql) + { + $obj=$this->fetch_object($resql); + $result[$obj->Variable_name]=$obj->Value; + } + + return $result; + } + + /** + * \brief Return value of server status + * \param filter Filter list on a particular value + * \return string Value for parameter + */ + function getServerStatusValues($filter='') + { + $result=array(); + + $sql='SHOW STATUS'; + if ($filter) $sql.=" LIKE '".addslashes($key)."'"; + $resql=$this->query($sql); + if ($resql) + { + $obj=$this->fetch_object($resql); + $result[$obj->Variable_name]=$obj->Value; + } + + return $result; + } } ?> diff --git a/htdocs/lib/databases/pgsql.lib.php b/htdocs/lib/databases/pgsql.lib.php index 9061d172a0b..53b302a2566 100644 --- a/htdocs/lib/databases/pgsql.lib.php +++ b/htdocs/lib/databases/pgsql.lib.php @@ -1221,5 +1221,25 @@ class DoliDb return $fullpathofmysqldump; } + /** + * \brief Return value of server parameters + * \param filter Filter list on a particular value + * \return string Value for parameter + */ + function getServerParametersValues($filter='') + { + $result=array(); + + $resql='select name,setting from pg_settings'; + if ($filter) $resql.=" WHERE name = '".addslashes($filter)."'"; + $resql=$this->query($resql); + if ($resql) + { + $obj=$this->fetch_object($resql); + $result[$obj->name]=$obj->setting; + } + + return $result; + } } ?> diff --git a/htdocs/soc.php b/htdocs/soc.php index 4d3282a72c7..f0a6e967912 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -294,40 +294,47 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && /* * Generate document */ -if ($_REQUEST['action'] == 'builddoc' && ! is_numeric($_REQUEST['model'])) // En get ou en post +if ($_REQUEST['action'] == 'builddoc') // En get ou en post { - require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php'); - - $soc = new Societe($db); - $soc->fetch($socid); - $soc->fetch_client(); - - /*if ($_REQUEST['model']) + if (is_numeric($_REQUEST['model'])) { - $fac->setDocModel($user, $_REQUEST['model']); - } - */ - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$fac->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result=thirdparty_doc_create($db, $soc->id, '', $_REQUEST['model'], $outputlangs); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model")); } else { - Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$soc->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); - exit; + require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php'); + + $soc = new Societe($db); + $soc->fetch($socid); + $soc->fetch_client(); + + /*if ($_REQUEST['model']) + { + $fac->setDocModel($user, $_REQUEST['model']); + } + */ + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$fac->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=thirdparty_doc_create($db, $soc->id, '', $_REQUEST['model'], $outputlangs); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + else + { + Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$soc->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + exit; + } } }
".$langs->trans("Browser")."
".$langs->trans("UserAgent")."" .$_SERVER["HTTP_USER_AGENT"]."