Fix: Bad error mangement

This commit is contained in:
Laurent Destailleur 2009-05-07 12:17:28 +00:00
parent 1ea905d8b3
commit edb5dab96c

View File

@ -49,11 +49,15 @@ if ($_POST["action"] == 'setremise')
{ {
if (price2num($_POST["amount_ht"]) > 0) if (price2num($_POST["amount_ht"]) > 0)
{ {
if (! $_POST["desc"]) $error=0;
if (empty($_POST["desc"]))
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("ReasonDiscount")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("ReasonDiscount")).'</div>';
$error++;
} }
if (! $error)
{
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($_GET["id"]); $soc->fetch($_GET["id"]);
$soc->set_remise_except($_POST["amount_ht"],$user,$_POST["desc"],$_POST["tva_tx"]); $soc->set_remise_except($_POST["amount_ht"],$user,$_POST["desc"],$_POST["tva_tx"]);
@ -65,9 +69,11 @@ if ($_POST["action"] == 'setremise')
} }
else else
{ {
$error++;
$mesg='<div class="error">'.$soc->error.'</div>'; $mesg='<div class="error">'.$soc->error.'</div>';
} }
} }
}
else else
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")).'</div>';