Le test sur saisi des paramètres (compte, montant, type de paiement) et fait avant les ecritures en base.
This commit is contained in:
parent
08950a86c8
commit
55073f4506
@ -50,15 +50,13 @@ if ($_POST["action"] == 'add_paiement')
|
|||||||
{
|
{
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
if ($_POST["paiementid"] > 0)
|
|
||||||
{
|
|
||||||
$datepaye = $db->idate(mktime(12, 0 , 0,
|
$datepaye = $db->idate(mktime(12, 0 , 0,
|
||||||
$_POST["remonth"],
|
$_POST["remonth"],
|
||||||
$_POST["reday"],
|
$_POST["reday"],
|
||||||
$_POST["reyear"]));
|
$_POST["reyear"]));
|
||||||
|
|
||||||
$paiement_id = 0;
|
$paiement_id = 0;
|
||||||
$total = 0;
|
$total = 0;
|
||||||
|
// Génère tableau des montants amounts
|
||||||
$amounts = array();
|
$amounts = array();
|
||||||
foreach ($_POST as $key => $value)
|
foreach ($_POST as $key => $value)
|
||||||
{
|
{
|
||||||
@ -71,9 +69,32 @@ if ($_POST["action"] == 'add_paiement')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($total > 0)
|
// Effectue les vérifications des parametres
|
||||||
|
if ($_POST["paiementid"] <= 0)
|
||||||
{
|
{
|
||||||
|
$fiche_erreur_message = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("PaymentMode")).'</div>';
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($conf->banque->enabled)
|
||||||
|
{
|
||||||
|
// Si module bank actif, un compte est obligatoire lors de la saisie
|
||||||
|
// d'un paiement
|
||||||
|
if (! $_POST["accountid"])
|
||||||
|
{
|
||||||
|
$fiche_erreur_message = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("AccountToCredit")).'</div>';
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($total <= 0)
|
||||||
|
{
|
||||||
|
$fiche_erreur_message = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Amount")).'</div>';
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
// Creation de la ligne paiement
|
// Creation de la ligne paiement
|
||||||
@ -102,15 +123,6 @@ if ($_POST["action"] == 'add_paiement')
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->banque->enabled)
|
if ($conf->banque->enabled)
|
||||||
{
|
|
||||||
// Si module bank actif, un compte est obligatoire lors de la saisie
|
|
||||||
// d'un paiement
|
|
||||||
if (! $_POST["accountid"])
|
|
||||||
{
|
|
||||||
$fiche_erreur_message = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("AccountToCredit")).'</div>';
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Insertion dans llx_bank
|
// Insertion dans llx_bank
|
||||||
$label = "Règlement facture";
|
$label = "Règlement facture";
|
||||||
@ -124,7 +136,6 @@ if ($_POST["action"] == 'add_paiement')
|
|||||||
'',
|
'',
|
||||||
$user);
|
$user);
|
||||||
|
|
||||||
|
|
||||||
// Mise a jour fk_bank dans llx_paiement.
|
// Mise a jour fk_bank dans llx_paiement.
|
||||||
// On connait ainsi le paiement qui a généré l'écriture bancaire
|
// On connait ainsi le paiement qui a généré l'écriture bancaire
|
||||||
if ($bank_line_id > 0)
|
if ($bank_line_id > 0)
|
||||||
@ -156,11 +167,11 @@ if ($_POST["action"] == 'add_paiement')
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error=$paiement->error;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,15 +187,6 @@ if ($_POST["action"] == 'add_paiement')
|
|||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$fiche_erreur_message = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Amount")).'</div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$fiche_erreur_message = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("PaymentMode")).'</div>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sécurité accés client
|
// Sécurité accés client
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user