From 747674b450d6840ce9bd9aecd765cf31445ef8d3 Mon Sep 17 00:00:00 2001 From: polo Date: Sat, 22 Jul 2023 12:29:47 +0200 Subject: navigation entre sections, boucle principale, client ou prospect --- src/functions.php | 118 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 51 deletions(-) (limited to 'src/functions.php') diff --git a/src/functions.php b/src/functions.php index aaacb36..f78b23d 100644 --- a/src/functions.php +++ b/src/functions.php @@ -22,21 +22,45 @@ function windowAppCommand(string $app, string $path = ''): string return $command; } -function makeObjectCLient() +function enterCustomer($Client): bool +{ + // fenêtre + $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); + + $input = exec($NouveauClient->get()); + if($input == '') + { + echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; + return false; + } + if(!$Client->hydrateFromForm($input)) + { + // messages d'erreur dans hydrateFromForm() + return false; + } + unset($input); + + $Client->create(); // écrire dans la base + $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId() + + return true; +} + +function makeObjectClient() { // fenêtres - $QuestionNouveauClient = new ZenityQuestion(ZenitySetup::$question_nouveau_client_text); + //~ $QuestionNouveauClient = new ZenityQuestion(ZenitySetup::$question_nouveau_client_text); $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client_text); $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client_text, []); - $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); + //~ $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); $Client = new Clients; // est ce que le client est déjà dans la base? - $client_inconnu = true; - if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage - { - echo "choix: recherche d'une client\n"; + //~ $client_inconnu = true; + //~ if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage + //~ { + //~ echo "choix: recherche d'une client\n"; $input = exec($RechercheClient->get()); if($input == '') { @@ -45,7 +69,7 @@ function makeObjectCLient() } echo "debug: recherche effectuée\n"; - $ResultatsRechercheClient->setListRows(rechercheClient($input, $Client), $Client->getTable()); // recherche silencieuse + $ResultatsRechercheClient->setListRows(searchCustomer($input, $Client), $Client->getTable()); // recherche silencieuse // sélection parmi les résultats $input = exec($ResultatsRechercheClient->get()); // renvoie l'ID de la table 'clients' @@ -59,31 +83,31 @@ function makeObjectCLient() echo "debug: client sélectionné\n"; $Client->hydrate($Client->findById($input)); - $client_inconnu = false; - } - else - { - echo "choix: nouveau client\n"; - } + //~ $client_inconnu = false; + //~ } + //~ else + //~ { + //~ echo "choix: nouveau client\n"; + //~ } // on n'a pas cherché OU on n'a pas trouvé - if($client_inconnu) - { - $input = exec($NouveauClient->get()); - if($input == '') - { - echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; - return 0; - } - if(!$Client->hydrateFromForm($input)) - { - // messages d'erreur dans hydrateFromForm() - return 0; - } - unset($input); - $Client->create(); - $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId() - } + //~ if($client_inconnu) + //~ { + //~ $input = exec($NouveauClient->get()); + //~ if($input == '') + //~ { + //~ echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; + //~ return 0; + //~ } + //~ if(!$Client->hydrateFromForm($input)) + //~ { + //~ // messages d'erreur dans hydrateFromForm() + //~ return 0; + //~ } + //~ unset($input); + //~ $Client->create(); + //~ $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId() + //~ } return $Client; } @@ -93,7 +117,7 @@ function makeObjectCLient() // NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?) // NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée -function rechercheClient(string $input, Clients $Client): array +function searchCustomer(string $input, Clients $Client): array { $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre $result = $Client->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées @@ -101,6 +125,17 @@ function rechercheClient(string $input, Clients $Client): array } +function makeTexAndPdf(Object $Object) +{ + if(get_class($Object) !== 'EnveloppeVersoLatex') + { + makeFolder($Object->getLatexPath()); + makeFolder($Object->getPdfPath()); + } + makeFile($Object->getLatexPath(), $Object->getFileName(), $Object->getLatex()); + latexToPdf($Object->getLatexPath(), $Object->getFileName(), $Object->getPdfPath()); +} + //~ function makeLatexAndPdfDocuments(Clients $Client = null, Prestations $Presta = null, $PrestaDetails = null) //~ { //~ $latex = ''; @@ -166,22 +201,3 @@ function rechercheClient(string $input, Clients $Client): array //~ } //~ } //~ } - -//~ function makeLatex(string $type, array $data = [], Dates $Date = null) -//~ { - //~ $date = ''; - //~ if($Date != null) - //~ { - //~ $date = $Date->getDate(); - //~ $date = preg_replace('#\D#', '/', $date); // date avec des slashs / parce que j'aime bien - //~ } - - //~ // on obtient la variable $latex avec ob_get_clean() - //~ // le include() ici, c'est du génie ou c'est moche ou les deux? - //~ // un nouveau fichier php est inséré à chaque itération - //~ include('latex_templates/' . $type . '.php'); - - //~ // on retourne le buffer - //~ // normallement le code PHP inséré avec include est nettoyé en quittant la fonction - //~ return($latex); -//~ } -- cgit v1.2.3