Fix: Les messages d'erreurs sur creation/modif societe ne s'affichaient plus

This commit is contained in:
Laurent Destailleur 2007-12-11 20:42:49 +00:00
parent cdc282167d
commit b827e5b2ce
4 changed files with 44 additions and 19 deletions

View File

@ -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');

View File

@ -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 '<div class="error">';
foreach($mesgarray as $message)
{
$ret++;
print $langs->trans($message)."<br>\n";
}
print '</div>';
}
if ($mesgstring)
{
$ret++;
print '<div class="error">';
print $mesgstring;
print '</div>';
}
return $ret;
}
?>

View File

@ -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 "<br>\n";
}
if (sizeof($soc->errors))
{
print '<div class="error">';
foreach($soc->errors as $message)
{
print $langs->trans($message)."<br>\n";
}
print '</div>';
}
dol_htmloutput_errors($soc->error,$soc->errors);
print '<form action="soc.php" method="post" name="formsoc">';
@ -672,13 +665,8 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
}
}
if ($soc->error)
{
print '<div class="error">';
print $soc->error;
print '</div>';
}
dol_htmloutput_errors($soc->error,$soc->errors);
print '<form action="soc.php?socid='.$soc->id.'" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="socid" value="'.$soc->id.'">';

View File

@ -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)
{