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->update(); return [3, $Client]; // menu précédent } elseif(is_string($choix_niv2) && $choix_niv2 != '') // autres choix, modifier une valeur { echo "choix: modifier" . $choix_niv2 . "\n"; $ModificationClient = new ZenityEntry($choix_niv2); $input = exec($ModificationClient->get()); if(is_string($input) && $input != '') { $Client->set($choix_niv2, $input); $Client->update(); // mettre à jour les documents (il faudrait modifier tous les documents!!) $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 = 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 } $type = $Presta->getTypePresta(); switch($type) { 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; case 'non_vendue': $PrestaDetails = null; break; } if($type != 'non_vendue') { $PrestaDetails->setIDPresta($Presta->getID()); $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); } // -- partie 4: modifier une prestation -- // fenêtre $ModificationPrestaMenu = makeModifyServiceWindow($Presta, $PrestaDetails); $choix_niv3 = exec($ModificationPrestaMenu->get()); //~ if($choix_niv3 === ZenitySetup::$modification_presta['devis_facture']) // devis -> facture //~ { //~ echo "choix: changer un devis en facture\n"; //~ return [2, $Client]; // menu "client" //~ } 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 { // mettre à jour la base de données $Presta->setDate($Date->getTimestamp(), true); // un entier pour la BDD, "true" pour modifier le code_presta $Presta->update(); // mettre à jour les documents 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 } //~ elseif($choix_niv3 === 'Type de Presta:') // 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)) // chaine vide autorisée { // mettre à jour la base de données $Presta->set($choix_niv3, $input); $Presta->update(); if($type != 'non_vendue') { $PrestaDetails->set($choix_niv3, $input); $PrestaDetails->update(); } // mettre à jour les documents if($type === 'devis' || $type === 'facture' || $type === 'location') { $DocumentPresta = Latex::makeInstance($type); $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); $DocumentPresta->makeLatex(); 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 }