From 7d564efbccc4b361d2fa2db2902fb35882304aae Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 20 Dec 2022 03:31:33 +0100 Subject: recherche de clients --- src/functions.php | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'src/functions.php') diff --git a/src/functions.php b/src/functions.php index 6ddbae0..82263bb 100644 --- a/src/functions.php +++ b/src/functions.php @@ -7,29 +7,27 @@ // commande pour lancer une application graphique en ouvrant un fichier function windowAppCommand(string $app, string $path = ''): string { - // attention, la syntaxe utilisée est la plus simple: "app fichier" - // ça fonctionne avec les logiciels choisis: gimp, scribus - // mais ça pourrait ne pas convenir - - $command = 'nohup ' . $app; // détache l'appli du script PHP - if($path !== '') - { - $command .= ' ' . $path; - } - $command .= ' > /dev/null 2>&1 &'; - // stdout > /dev/null et & permettent de rendre la main à PHP - // stderr > stdout pour cacher un message inutile - return $command; + // attention, la syntaxe utilisée est la plus simple: "app fichier" + // ça fonctionne avec les logiciels choisis: gimp, scribus + // mais ça pourrait ne pas convenir pour d'autres + + $command = 'nohup ' . $app; // détache l'appli du script PHP + if($path !== '') + { + $command .= ' ' . $path; + } + $command .= ' > /dev/null 2>&1 &'; + // stdout > /dev/null et & permettent de rendre la main à PHP + // stderr > stdout pour cacher un message inutile + return $command; } -function rechercheClient(string $saisie): array +function rechercheClient(string $input, Clients $Client): array { - $resultats = []; - - // recherche dans la BDD - - - return($resultats); + $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 + return($result); } // NOTE 1: les objets sont passés aux fonctions par référence par défaut, toutefois ce n'est pas entièrement vrai @@ -37,15 +35,14 @@ function rechercheClient(string $saisie): array // 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 enregistrementNouveauClient(Clients $Client, ZenityForms $NouveauClient) +function enregistrementNouveauClient(string $name, Clients $Client): bool { - $entry = exec($NouveauClient->get()); - if($entry !== '') + if($name !== '') { - $tableau = explode('|', $entry); + $tableau = explode('|', $name); if(count($tableau) === 4) { - $Client->newRow($tableau); + $Client->newRow($tableau); // écriture dans la BDD return true; } else -- cgit v1.2.3