From 6f4cc3afffde36a13618458ffda72e6104624f36 Mon Sep 17 00:00:00 2001 From: polo Date: Wed, 30 Aug 2023 12:20:39 +0200 Subject: =?UTF-8?q?section=20client=20=C3=A0=20part,=20section=20modif=20e?= =?UTF-8?q?n=20cours,=20bug=20dans=20Dates,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sections/3_modify_data.php | 170 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 169 insertions(+), 1 deletion(-) (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 cc95468..e16a58f 100644 --- a/src/sections/3_modify_data.php +++ b/src/sections/3_modify_data.php @@ -3,7 +3,175 @@ // // -- SECTION 3: Modifier un client, un prospect, une prestation, un devis -- -function modifyData($Objet): array +function modifyData($Client): array { + // -- partie 1: rechercher un client -- + if($Client == null || get_class($Client) !== 'Clients') // étape sautable + { + $Client = makeObjectClient(); // = 0 ou type "Clients" + if(!is_object($Client) || !get_class($Client) == 'Clients') + { + echo "debug: annulation sélection client\n"; + return [0, null]; // menu principal + } + } + + + // -- partie 2: modifier un client -- + + // fenêtre $ModificationClient + $ModificationClientMenu = new ZenityList(ZenitySetup::$modification_client['text'], []); + $entrees = []; + $i = 0; + $client_data = $Client->getAllWithWindowFields(); + //var_dump($client_data); + foreach($client_data as $key => $value) + { + $entrees[$i][] = $key; + $entrees[$i][] = $value; + $i++; + } + $entrees[$i][] = ZenitySetup::$modification_client['service']; + $entrees[$i][] = ''; + $i++; + $entrees[$i][] = ZenitySetup::$modification_client['return']; + $entrees[$i][] = ''; + $ModificationClientMenu->setListRows($entrees, 2, 2.5); + + // modifier une valeur + $choix_niv2 = exec($ModificationClientMenu->get()); + if($choix_niv2 === ZenitySetup::$modification_client['service']) // ne pas modifier le client mais une prestation + { + echo "choix: modifier une prestation\n"; + // on passe à la suite + } + elseif($choix_niv2 === ZenitySetup::$modification_client['return']) // annuler + { + echo "choix: retour au menu principal\n"; + return [0, null]; // menu principal + } + elseif($choix_niv2 === "Client ou Prospect?") // modifier le client + { + echo "choix: modifier" . $choix_niv2 . "\n"; + $TypeDeClient = new ZenityList(ZenitySetup::$type_client_text, ZenitySetup::$type_client_entrees); + $input = exec($TypeDeClient->get()); + if($input === ZenitySetup::$type_client_entrees[0]) + { + echo "choix: " . $input . "\n"; + $Client->setType('client'); + } + elseif($input === ZenitySetup::$type_client_entrees[1]) + { + echo "choix: " . $input . "\n"; + $Client->setType('prospect'); + } + else + { + echo "choix: annulation\n"; + } + $Client->update(); + return [3, $Client]; // menu précédent + } + elseif(is_string($choix_niv2) && $choix_niv2 != '') // modifier le client + { + echo "choix: modifier" . $choix_niv2 . "\n"; + $ModificationClient = new ZenityEntry($choix_niv2); + $input = exec($ModificationClient->get()); + if(is_string($input) && $input != '') + { + $Client->getSetterAndSet($choix_niv2, $input); + $Client->update(); + + // mettre à jour les documents + + } + else + { + echo "choix: annulation\n"; + } + return [3, $Client]; // menu précédent + } + else // annuler + { + echo "annulation: retour au menu principal\n"; + return [0, null]; // menu principal + } + + + // -- partie 3: rechercher une prestation -- + $Presta = getServices($Client); // = 0 ou type "Prestations" + if(!is_object($Presta) || !get_class($Presta) == 'Prestations') + { + echo "debug: annulation sélection client\n"; + return [3, $Client]; // menu précédent + } + + + // -- partie 4: modifier une prestation -- + + // fenêtre $ModificationPresta + $ModificationPrestaMenu = new ZenityList(ZenitySetup::$modification_presta['text'], []); + $entrees = []; + $i = 0; + + $presta_data = $Presta->getAllWithWindowFields(); + var_dump($presta_data); + foreach($presta_data as $key => $value) + { + $entrees[$i][] = $key; + $entrees[$i][] = $value; + $i++; + } + + // infos des sous-tables 'facture', 'devis', etc + switch($Presta->getTypePresta()) + { + case 'facture': + $PrestaDetails = new DevisFactures('factures'); + break; + + case 'devis': + $PrestaDetails = new DevisFactures('devis'); + break; + case 'cesu': + $PrestaDetails = new CESU(); + break; + case 'location': + $PrestaDetails = new Locations(); + break; + } + if(isset($PrestaDetails)) + { + $PrestaDetails->setIDPresta($Presta->getID()); + $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); + $presta_data = $PrestaDetails->getAllWithWindowFields(); + var_dump($presta_data); + foreach($presta_data as $key => $value) + { + $entrees[$i][] = $key; + $entrees[$i][] = $value; + $i++; + } + } + + if($Presta->getTypePresta() === 'devis') + { + $entrees[$i][] = ZenitySetup::$modification_presta['devis_facture']; // option changer le devis en facture + $entrees[$i][] = ''; + $i++; + } + $entrees[$i][] = ZenitySetup::$modification_presta['service']; + $entrees[$i][] = ''; + $i++; + $entrees[$i][] = ZenitySetup::$modification_presta['return']; + $entrees[$i][] = ''; + $ModificationPrestaMenu->setListRows($entrees, 2, 2.5); + + // modifier une valeur + $choix_niv3 = exec($ModificationPrestaMenu->get()); + var_dump($choix_niv3); + + // si changement de type de prestation autre que de devis à facture, ça devient compliqué! + return [0, null]; // menu principal } -- cgit v1.2.3