Modifs ajout {form_field}

This commit is contained in:
Noizette 2020-10-24 07:04:06 +02:00
parent 2014dff1a1
commit 8adc144bfa
5 changed files with 93 additions and 134 deletions

View file

@ -55,16 +55,20 @@ class Facture
switch($k)
{
case 'type_facture':
if (!array_key_exists($datas[$k], $this->type))
{
if (!array_key_exists($datas[$k], $this->type)) {
throw new UserException("$k est de type non-attendue ($data).");
}
if ($datas[$k] > 1) {
$recu = true;
}
else {
$recu = false;
}
break;
case 'receveur_membre':
case 'reglee':
case 'archivee':
if ($datas[$k] != 1 && $datas[$k] != 0)
{
if ($datas[$k] != 1 && $datas[$k] != 0) {
throw new UserException("$k est de valeur non-attendue ($data).");
}
break;
@ -94,13 +98,7 @@ class Facture
unset($cats);
break;
case 'contenu':
$tmp = false;
if ($datas['type_facture'] > 1) {
// $datas[$k] = null;
// break;
$tmp = true;
}
if (!$tmp && !is_array($datas[$k]) || empty($datas[$k])) {
if (!$recu && (!is_array($datas[$k]) || empty($datas[$k]))) {
throw new UserException("Le contenu du document est vide ($data).");
}
$total = 0;
@ -117,18 +115,14 @@ class Facture
}
$total += $r['prix'];
}
if($vide)
if(!$recu && $vide)
{
throw new UserException("Toutes les désignations/prix sont vides.");
}
$datas[$k] = json_encode($datas[$k]);
break;
case 'total':
if ($datas['type_facture'] > 1) {
// $datas[$k] = null;
break;
}
if (!isset($datas['contenu'])) {
if (!$recu && !isset($datas['contenu'])) {
throw new UserException("Pas de contenu fourni pour vérifier le total.");
}
if ($total != $datas[$k])