From a187babbacb51b77bfa43d347cf49a84b9b7420d Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Wed, 10 Jan 2024 18:43:23 +0100 Subject: [PATCH] Correction bug oubli choix receveur --- admin/_facture_common.php | 51 ++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/admin/_facture_common.php b/admin/_facture_common.php index c0d781b..0648c79 100644 --- a/admin/_facture_common.php +++ b/admin/_facture_common.php @@ -51,7 +51,7 @@ if ( !$target ) { // Traitement $data=[]; $form->runIf(f('save') && !$form->hasErrors(), - function () use ($client, &$data) + function () use ($client, &$data, $form) { try { @@ -101,6 +101,10 @@ $form->runIf(f('save') && !$form->hasErrors(), $data['receveur_membre'] = 1; $data['receveur_id'] = f('membre'); } + else + { + throw new UserException('Vous devez indiquer si le receveur est un client ou un membre'); + } } catch(UserException $e) @@ -152,33 +156,36 @@ $form->runIf(f('add_cotis') && !$form->hasErrors(), } }, 'add_cotis_2'); -if ($step) +if (! $form->hasErrors()) { - try + if ($step) { - $liste = $facture->getCotis((int)f('membre_cotis')); + try + { + $liste = $facture->getCotis((int)f('membre_cotis')); + } + catch (UserException $e) + { + $form->addError($e->getMessage()); + } } - catch (UserException $e) + elseif (count($data) > 0) { - $form->addError($e->getMessage()); + if ($target) + { + $id = $facture->add($data, $plugin->getConfig('pattern')); + Utils::redirect(PLUGIN_ADMIN_URL . 'facture.php?id='.(int)$id); + } + else + { + if ($facture->edit($id, $data)) + { + Utils::redirect(PLUGIN_ADMIN_URL . 'facture.php?id='.(int)$id); + } + throw new UserException('Erreur d\'édition du reçu'); + } } } -elseif (count($data) > 0) -{ - if ($target) - { - $id = $facture->add($data, $plugin->getConfig('pattern')); - Utils::redirect(PLUGIN_ADMIN_URL . 'facture.php?id='.(int)$id); - } - else - { - if ($facture->edit($id, $data)) - { - Utils::redirect(PLUGIN_ADMIN_URL . 'facture.php?id='.(int)$id); - } - throw new UserException('Erreur d\'édition du reçu'); - } -} // Affichage