summaryrefslogtreecommitdiff
path: root/src/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/functions.php')
-rw-r--r--src/functions.php118
1 files changed, 67 insertions, 51 deletions
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
22 return $command; 22 return $command;
23} 23}
24 24
25function makeObjectCLient() 25function enterCustomer($Client): bool
26{
27 // fenêtre
28 $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees);
29
30 $input = exec($NouveauClient->get());
31 if($input == '')
32 {
33 echo "debug: annulation lors de l'enregistrement d'un nouveau client\n";
34 return false;
35 }
36 if(!$Client->hydrateFromForm($input))
37 {
38 // messages d'erreur dans hydrateFromForm()
39 return false;
40 }
41 unset($input);
42
43 $Client->create(); // écrire dans la base
44 $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId()
45
46 return true;
47}
48
49function makeObjectClient()
26{ 50{
27 // fenêtres 51 // fenêtres
28 $QuestionNouveauClient = new ZenityQuestion(ZenitySetup::$question_nouveau_client_text); 52 //~ $QuestionNouveauClient = new ZenityQuestion(ZenitySetup::$question_nouveau_client_text);
29 $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client_text); 53 $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client_text);
30 $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client_text, []); 54 $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client_text, []);
31 $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); 55 //~ $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees);
32 56
33 $Client = new Clients; 57 $Client = new Clients;
34 58
35 // est ce que le client est déjà dans la base? 59 // est ce que le client est déjà dans la base?
36 $client_inconnu = true; 60 //~ $client_inconnu = true;
37 if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage 61 //~ if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage
38 { 62 //~ {
39 echo "choix: recherche d'une client\n"; 63 //~ echo "choix: recherche d'une client\n";
40 $input = exec($RechercheClient->get()); 64 $input = exec($RechercheClient->get());
41 if($input == '') 65 if($input == '')
42 { 66 {
@@ -45,7 +69,7 @@ function makeObjectCLient()
45 } 69 }
46 70
47 echo "debug: recherche effectuée\n"; 71 echo "debug: recherche effectuée\n";
48 $ResultatsRechercheClient->setListRows(rechercheClient($input, $Client), $Client->getTable()); // recherche silencieuse 72 $ResultatsRechercheClient->setListRows(searchCustomer($input, $Client), $Client->getTable()); // recherche silencieuse
49 73
50 // sélection parmi les résultats 74 // sélection parmi les résultats
51 $input = exec($ResultatsRechercheClient->get()); // renvoie l'ID de la table 'clients' 75 $input = exec($ResultatsRechercheClient->get()); // renvoie l'ID de la table 'clients'
@@ -59,31 +83,31 @@ function makeObjectCLient()
59 83
60 echo "debug: client sélectionné\n"; 84 echo "debug: client sélectionné\n";
61 $Client->hydrate($Client->findById($input)); 85 $Client->hydrate($Client->findById($input));
62 $client_inconnu = false; 86 //~ $client_inconnu = false;
63 } 87 //~ }
64 else 88 //~ else
65 { 89 //~ {
66 echo "choix: nouveau client\n"; 90 //~ echo "choix: nouveau client\n";
67 } 91 //~ }
68 92
69 // on n'a pas cherché OU on n'a pas trouvé 93 // on n'a pas cherché OU on n'a pas trouvé
70 if($client_inconnu) 94 //~ if($client_inconnu)
71 { 95 //~ {
72 $input = exec($NouveauClient->get()); 96 //~ $input = exec($NouveauClient->get());
73 if($input == '') 97 //~ if($input == '')
74 { 98 //~ {
75 echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; 99 //~ echo "debug: annulation lors de l'enregistrement d'un nouveau client\n";
76 return 0; 100 //~ return 0;
77 } 101 //~ }
78 if(!$Client->hydrateFromForm($input)) 102 //~ if(!$Client->hydrateFromForm($input))
79 { 103 //~ {
80 // messages d'erreur dans hydrateFromForm() 104 //~ // messages d'erreur dans hydrateFromForm()
81 return 0; 105 //~ return 0;
82 } 106 //~ }
83 unset($input); 107 //~ unset($input);
84 $Client->create(); 108 //~ $Client->create();
85 $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId() 109 //~ $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId()
86 } 110 //~ }
87 111
88 return $Client; 112 return $Client;
89} 113}
@@ -93,7 +117,7 @@ function makeObjectCLient()
93// NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?) 117// NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?)
94// NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée 118// NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée
95 119
96function rechercheClient(string $input, Clients $Client): array 120function searchCustomer(string $input, Clients $Client): array
97{ 121{
98 $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre 122 $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre
99 $result = $Client->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées 123 $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
101} 125}
102 126
103 127
128function makeTexAndPdf(Object $Object)
129{
130 if(get_class($Object) !== 'EnveloppeVersoLatex')
131 {
132 makeFolder($Object->getLatexPath());
133 makeFolder($Object->getPdfPath());
134 }
135 makeFile($Object->getLatexPath(), $Object->getFileName(), $Object->getLatex());
136 latexToPdf($Object->getLatexPath(), $Object->getFileName(), $Object->getPdfPath());
137}
138
104//~ function makeLatexAndPdfDocuments(Clients $Client = null, Prestations $Presta = null, $PrestaDetails = null) 139//~ function makeLatexAndPdfDocuments(Clients $Client = null, Prestations $Presta = null, $PrestaDetails = null)
105//~ { 140//~ {
106 //~ $latex = ''; 141 //~ $latex = '';
@@ -166,22 +201,3 @@ function rechercheClient(string $input, Clients $Client): array
166 //~ } 201 //~ }
167 //~ } 202 //~ }
168//~ } 203//~ }
169
170//~ function makeLatex(string $type, array $data = [], Dates $Date = null)
171//~ {
172 //~ $date = '';
173 //~ if($Date != null)
174 //~ {
175 //~ $date = $Date->getDate();
176 //~ $date = preg_replace('#\D#', '/', $date); // date avec des slashs / parce que j'aime bien
177 //~ }
178
179 //~ // on obtient la variable $latex avec ob_get_clean()
180 //~ // le include() ici, c'est du génie ou c'est moche ou les deux?
181 //~ // un nouveau fichier php est inséré à chaque itération
182 //~ include('latex_templates/' . $type . '.php');
183
184 //~ // on retourne le buffer
185 //~ // normallement le code PHP inséré avec include est nettoyé en quittant la fonction
186 //~ return($latex);
187//~ }