From 78439b6a178e238ab8fb73d25567a85df78d6681 Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 3 Sep 2023 02:45:17 +0200 Subject: section 3 prestas non vendues --- src/sections/3_modify_data.php | 48 ++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'src/sections/3_modify_data.php') diff --git a/src/sections/3_modify_data.php b/src/sections/3_modify_data.php index 1f48870..5da7ed9 100644 --- a/src/sections/3_modify_data.php +++ b/src/sections/3_modify_data.php @@ -88,7 +88,9 @@ function modifyData($Client): array echo "debug: annulation sélection client\n"; return [3, $Client]; // menu précédent } - switch($Presta->getTypePresta()) + + $type = $Presta->getTypePresta(); + switch($type) { case 'facture': $PrestaDetails = new DevisFactures('factures'); @@ -103,16 +105,21 @@ function modifyData($Client): array case 'location': $PrestaDetails = new Locations(); break; + case 'non_vendue': + $PrestaDetails = null; + break; + } + if($type != 'non_vendue') + { + $PrestaDetails->setIDPresta($Presta->getID()); + $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); } - $PrestaDetails->setIDPresta($Presta->getID()); - $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); // -- partie 4: modifier une prestation -- // fenêtre $ModificationPrestaMenu = makeModifyServiceWindow($Presta, $PrestaDetails); - $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section3']); $choix_niv3 = exec($ModificationPrestaMenu->get()); if($choix_niv3 === ZenitySetup::$modification_presta['devis_facture']) // devis -> facture @@ -122,11 +129,13 @@ function modifyData($Client): array } elseif($choix_niv3 === 'Date:') { + // fenêtre + $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section3']); + $Date = new Dates(exec($Calendrier->get())); // exec() renvoie soit une chaîne soit un false - if($Date->getDate() == '') // on n'a pas cliqué sur "annuler" + if($Date->getDate() == '') // clic sur "annuler", touche "échap" { echo "debug: annulation à la saisie d'une date\n"; - //return [3, $Client]; // menu principal } else { @@ -135,10 +144,13 @@ function modifyData($Client): array $Presta->update(); // mettre à jour les documents - $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location - $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); - $DocumentPresta->makeLatex(); - makeTexAndPdf($DocumentPresta); + if($type === 'devis' || $type === 'facture' || $type === 'location') + { + $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location + $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); + $DocumentPresta->makeLatex(); + makeTexAndPdf($DocumentPresta); + } } return [3, $Client]; // menu précédent @@ -156,17 +168,21 @@ function modifyData($Client): array //if(is_string($input) && $input != '') if(is_string($input)) // chaine vide autorisée { - $Presta->set($choix_niv3, $input); - $PrestaDetails->set($choix_niv3, $input); - // mettre à jour la base de données + $Presta->set($choix_niv3, $input); $Presta->update(); - $PrestaDetails->update(); + + if($type != 'non_vendue') + { + $PrestaDetails->set($choix_niv3, $input); + $PrestaDetails->update(); + } // mettre à jour les documents - if($Presta->getTypePresta() === 'devis' || $Presta->getTypePresta() === 'facture' || $Presta->getTypePresta() === 'location') + //$type = $Presta->getTypePresta(); + if($type === 'devis' || $type === 'facture' || $type === 'location') { - $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location + $DocumentPresta = Latex::makeInstance($type); $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); $DocumentPresta->makeLatex(); makeTexAndPdf($DocumentPresta); -- cgit v1.2.3