cleanCommand(); // inutile parce qu'on ne boucle pas dans cette fonction //if(!is_object($Client) || !get_class($Client) == 'Client') if($Client === 0) { echo "debug: annulation sélection client\n"; return [0, null]; // menu principal } } // -- partie 2: modifier un client -- // fenêtre dynamique $ModificationClientMenu = makeModifyCustomerWindow($Client); $choix_niv2 = exec($ModificationClientMenu->get()); if($choix_niv2 === ZenitySetup::$modification_client['service']) // clic sur "Modifier une prestation" { echo "choix: modifier une prestation\n"; // ne rien faire dans cette partie et passer à la suite } elseif($choix_niv2 === "Client ou Prospect?") { echo "choix: modifier" . $choix_niv2 . "\n"; $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::$entityManager->flush(); // à mettre dans une classe Manager return [3, $Client]; // menu précédent } elseif(is_string($choix_niv2) && $choix_niv2 != '') // modifier autre chose chez le client { echo "choix: modifier " . $choix_niv2 . "\n"; $ModificationClient = new ZenityEntry($choix_niv2); $input = exec($ModificationClient->get()); if(is_string($input) && $input != '') { // entités et BDD $Client->set($choix_niv2, $input); $Client::$entityManager->flush(); // documents (les factures, etc, ne sont pas modifiées ici) $EnveloppeRecto = Latex::makeInstance('enveloppe_recto'); $EnveloppeRecto->setData($Client); $EnveloppeRecto->makeLatex(); makeTexAndPdf($EnveloppeRecto); } else { echo "choix: annulation\n"; } return [3, $Client]; // menu précédent } else { echo "annulation: retour au menu principal\n"; return [0, null]; // menu principal } // -- partie 3: rechercher une prestation -- $Presta = Prestation::getServices($Client); // = 0 ou type "Prestation" if(!is_object($Presta) || !get_class($Presta) == 'Prestation') { echo "debug: annulation sélection d'une prestation\n"; return [3, $Client]; // menu précédent } $type_presta = $Presta->getTypePresta(); switch($type_presta) { case 'facture': $classe = 'Facture'; break; case 'devis': $classe = 'Devis'; break; case 'cesu': $classe = 'CESU'; break; case 'location': $classe = 'Location'; break; case 'non_vendue': $PrestaDetails = null; break; } if($type_presta != 'non_vendue') { $repository = $classe::$entityManager->getRepository($classe); $PrestaDetails = $repository->findOneBy(['presta' => $Presta->getId()]); } // -- partie 4: modifier une prestation -- // fenêtre $ModificationPrestaMenu = makeModifyServiceWindow($Presta, $PrestaDetails); $choix_niv3 = exec($ModificationPrestaMenu->get()); if($choix_niv3 === 'Date:') { $Date = new Dates(exec($Calendrier->get())); // exec() renvoie soit une chaîne soit un false if($Date->getDate() == '') // clic sur "annuler", touche "échap" { echo "debug: annulation à la saisie d'une date\n"; } else { // entités et BDD $Presta->set($choix_niv3, $Date); $old_code = $Presta->getCodePresta(); $Presta->setCodePresta(0); $Presta::$entityManager->flush(); // documents if($type_presta === 'devis' || $type_presta === 'facture' || $type_presta === 'location') { $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); $DocumentPresta->makeLatex(); // en mémoire renameFiles($DocumentPresta, $old_code, $Presta->getCodePresta()); makeTexAndPdf($DocumentPresta); // une nouvelle facture est créée, supprimer l'ancienne ou la renommer avec la nouvelle date } } return [3, $Client]; // menu précédent } //~ elseif($choix_niv3 === 'Type de Presta:') // compliqué! choix impossible pour le moment //~ { //~ echo "choix: changer le type de prestation (devis, facture, etc)\n"; //~ return [3, $Client]; // menu "client" //~ } elseif(is_string($choix_niv3) && $choix_niv3 != '') // modifier une valeur { echo "choix: modifier " . $choix_niv3 . "\n"; $ModificationPrestaForm = new ZenityEntry($choix_niv3); $input = shell_exec($ModificationPrestaForm->get()); // shell_exec() retourne null si la commande échoue, exec() retourne la dernière ligne de texte en sortie ou null si aucune commande ne réussit if(is_string($input)) // chaîne vide autorisée { // entités et BDD $Presta->set($choix_niv3, $input); $old_code = $Presta->getCodePresta(); $Presta->setCodePresta(0); if($type_presta != 'non_vendue') { $PrestaDetails->set($choix_niv3, $input); $PrestaDetails::$entityManager->flush(); } else { $Presta::$entityManager->flush(); } // documents if($type_presta === 'devis' || $type_presta === 'facture' || $type_presta === 'location') { $DocumentPresta = Latex::makeInstance($type_presta); $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); $DocumentPresta->makeLatex(); renameFiles($DocumentPresta, $old_code, $Presta->getCodePresta()); makeTexAndPdf($DocumentPresta); } } else { echo "choix: annulation\n"; } return [3, $Client]; // menu précédent } else // annuler { echo "annulation: retour au menu précédent\n"; return [3, $Client]; // menu précédent } //return [0, null]; // menu principal }