summaryrefslogtreecommitdiff
path: root/src/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/functions.php')
-rw-r--r--src/functions.php47
1 files changed, 22 insertions, 25 deletions
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 @@
7// commande pour lancer une application graphique en ouvrant un fichier 7// commande pour lancer une application graphique en ouvrant un fichier
8function windowAppCommand(string $app, string $path = ''): string 8function windowAppCommand(string $app, string $path = ''): string
9{ 9{
10 // attention, la syntaxe utilisée est la plus simple: "app fichier" 10 // attention, la syntaxe utilisée est la plus simple: "app fichier"
11 // ça fonctionne avec les logiciels choisis: gimp, scribus 11 // ça fonctionne avec les logiciels choisis: gimp, scribus
12 // mais ça pourrait ne pas convenir 12 // mais ça pourrait ne pas convenir pour d'autres
13 13
14 $command = 'nohup ' . $app; // détache l'appli du script PHP 14 $command = 'nohup ' . $app; // détache l'appli du script PHP
15 if($path !== '') 15 if($path !== '')
16 { 16 {
17 $command .= ' ' . $path; 17 $command .= ' ' . $path;
18 } 18 }
19 $command .= ' > /dev/null 2>&1 &'; 19 $command .= ' > /dev/null 2>&1 &';
20 // stdout > /dev/null et & permettent de rendre la main à PHP 20 // stdout > /dev/null et & permettent de rendre la main à PHP
21 // stderr > stdout pour cacher un message inutile 21 // stderr > stdout pour cacher un message inutile
22 return $command; 22 return $command;
23} 23}
24 24
25function rechercheClient(string $saisie): array 25function rechercheClient(string $input, Clients $Client): array
26{ 26{
27 $resultats = []; 27 $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre
28 28
29 // recherche dans la BDD 29 $result = $Client->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées
30 30 return($result);
31
32 return($resultats);
33} 31}
34 32
35// NOTE 1: les objets sont passés aux fonctions par référence par défaut, toutefois ce n'est pas entièrement vrai 33// 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
37// NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?) 35// NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?)
38// NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée 36// NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée
39 37
40function enregistrementNouveauClient(Clients $Client, ZenityForms $NouveauClient) 38function enregistrementNouveauClient(string $name, Clients $Client): bool
41{ 39{
42 $entry = exec($NouveauClient->get()); 40 if($name !== '')
43 if($entry !== '')
44 { 41 {
45 $tableau = explode('|', $entry); 42 $tableau = explode('|', $name);
46 if(count($tableau) === 4) 43 if(count($tableau) === 4)
47 { 44 {
48 $Client->newRow($tableau); 45 $Client->newRow($tableau); // écriture dans la BDD
49 return true; 46 return true;
50 } 47 }
51 else 48 else