diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 1652a39a11c..26b8b0a0013 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1713,6 +1713,7 @@ else $soc = new Societe($db, $fac->socid); $soc->fetch($fac->socid); + $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL'); $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL'); diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index c1a13d28d0e..0075a4ef789 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -3873,4 +3873,38 @@ function dolibarr_print_reduction($reduction=0) return $string; } + +/** + \brief Returns formated reduction + \param reduction Reduction percentage + \return int Return number of error messages shown +*/ +function dol_htmloutput_errors($mesgstring='',$mesgarray='') +{ + global $langs; + + $ret = 0; + $langs->load("errors"); + + if (is_array($mesgarray) && sizeof($mesgarray)) + { + print '
'; + foreach($mesgarray as $message) + { + $ret++; + print $langs->trans($message)."
\n"; + } + print '
'; + } + if ($mesgstring) + { + $ret++; + print '
'; + print $mesgstring; + print '
'; + } + + return $ret; +} + ?> diff --git a/htdocs/soc.php b/htdocs/soc.php index 09c2bf52d6b..0ef8ecf495b 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -188,6 +188,7 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) { $soc->id = $socid; $reload = 0; + $mesg = $soc->error; $_GET["action"]= "edit"; } @@ -325,15 +326,7 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || print "
\n"; } - if (sizeof($soc->errors)) - { - print '
'; - foreach($soc->errors as $message) - { - print $langs->trans($message)."
\n"; - } - print '
'; - } + dol_htmloutput_errors($soc->error,$soc->errors); print '
'; @@ -672,13 +665,8 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') } } - if ($soc->error) - { - print '
'; - print $soc->error; - print '
'; - } - + dol_htmloutput_errors($soc->error,$soc->errors); + print ''; print ''; print ''; diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 04fea7ec855..2b407c60a9a 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -340,7 +340,9 @@ class Societe if ($this->code_client == -1) $this->get_codeclient($this->prefix_comm,0); if ($this->code_fournisseur == -1) $this->get_codefournisseur($this->prefix_comm,1); - $result = $this->verify(); // Verifie que nom obligatoire et code client ok et unique + // Check name is required and codes are ok or unique. + // If error, this->errors[] is filled + $result = $this->verify(); if ($result >= 0) { @@ -367,7 +369,7 @@ class Societe $sql .= ",ape = '". addslashes($this->ape) ."'"; $sql .= ",idprof4 = '". addslashes($this->idprof4) ."'"; - $sql .= ",tva_assuj = ".($this->tva_assuj>=0?"'".$this->tva_assuj."'":"null"); + $sql .= ",tva_assuj = ".($this->tva_assuj>=0?"'".$this->tva_assuj."'":"null"); $sql .= ",tva_intra = '" . addslashes($this->tva_intra) ."'"; $sql .= ",capital = '" . addslashes($this->capital) ."'"; @@ -412,7 +414,7 @@ class Societe $sql .= " WHERE rowid = '" . $id ."'"; - dolibarr_syslog("Societe::update sql=".$sql); + dolibarr_syslog("Societe::update sql=".$sql); $resql=$this->db->query($sql); if ($resql) {