summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/latex_templates/devis.php6
-rw-r--r--src/model/entities/Client.php28
-rw-r--r--src/model/entities/Devis.php16
-rw-r--r--src/sections/1_customer.php55
-rw-r--r--à faire.txt5
5 files changed, 58 insertions, 52 deletions
diff --git a/src/latex_templates/devis.php b/src/latex_templates/devis.php
index b686d22..34c0dd3 100644
--- a/src/latex_templates/devis.php
+++ b/src/latex_templates/devis.php
@@ -22,6 +22,10 @@ if($data['total_HT'] != 0)
22 $data['total_HT'] = ((string) $data['total_HT']) . '€'; 22 $data['total_HT'] = ((string) $data['total_HT']) . '€';
23} 23}
24 24
25if($data['prix_devis'] === 0){ // un float est fait juste avant
26 $data['prix_devis'] = "gratuit";
27}
28
25ob_start(); 29ob_start();
26?> 30?>
27\documentclass{report} 31\documentclass{report}
@@ -90,7 +94,7 @@ ob_start();
90 94
91 Déplacement : \textcolor{vert}{<?= $data['deplacement'] ?>} 95 Déplacement : \textcolor{vert}{<?= $data['deplacement'] ?>}
92 96
93 Devis Payant : \textcolor{vert}{<?= $data['prix_devis'] ?>} 97 Prix Devis : \textcolor{vert}{<?= $data['prix_devis'] ?>}
94 98
95 Total HT : \textcolor{vert}{<?= $data['total_HT'] ?>} 99 Total HT : \textcolor{vert}{<?= $data['total_HT'] ?>}
96 100
diff --git a/src/model/entities/Client.php b/src/model/entities/Client.php
index 97951be..a0bc405 100644
--- a/src/model/entities/Client.php
+++ b/src/model/entities/Client.php
@@ -173,31 +173,27 @@ class Client
173 return str_replace($search, '', $data); 173 return str_replace($search, '', $data);
174 } 174 }
175 175
176 // une partie du code vient de Model::hydrateFromForm() 176 public static function controlForm(string $input): string|false
177 // à mettre dans une classe ClientManager?
178 public function enterCustomer(ZenityForms $Form): bool
179 { 177 {
180 $input = exec($Form->get());
181 if($input == ''){
182 echo "debug: annulation lors de l'enregistrement d'un nouveau client\n";
183 return false;
184 }
185
186 $data_array = explode('|', $input); // array 178 $data_array = explode('|', $input); // array
187 if($data_array[0] == ''){ 179
188 echo "debug: données insuffisantes, le nom du client doit au minimum être renseigné\n"; 180 if($data_array[0] == '' || $data_array[1] == ''){
181 echo "debug: données insuffisantes, renseignez au moins un nom et un code client\n";
189 return false; 182 return false;
190 } 183 }
191 else{
192 $this->setAll($data_array);
193 }
194 184
185 return $input;
186 }
187
188 // une partie du code vient de Model::hydrateFromForm()
189 // à mettre dans une classe ClientManager?
190 public function enterCustomer(string $input): void
191 {
192 $this->setAll(explode('|', $input));
195 self::$entityManager->persist($this); 193 self::$entityManager->persist($this);
196 self::$entityManager->flush(); 194 self::$entityManager->flush();
197 195
198 //$this->id = $this->db->lastInsertId(); // synchro automatique avec doctrine 196 //$this->id = $this->db->lastInsertId(); // synchro automatique avec doctrine
199
200 return true;
201 } 197 }
202 198
203 public static function find(ZenityEntry $SearchCustomerForm, ZenityList $SearchCustomerResults): ?Client 199 public static function find(ZenityEntry $SearchCustomerForm, ZenityList $SearchCustomerResults): ?Client
diff --git a/src/model/entities/Devis.php b/src/model/entities/Devis.php
index 8518f8e..ce2a043 100644
--- a/src/model/entities/Devis.php
+++ b/src/model/entities/Devis.php
@@ -43,10 +43,8 @@ class Devis
43 43
44 public static EntityManager $entityManager; 44 public static EntityManager $entityManager;
45 45
46 public function __construct(Prestation $presta = null) 46 public function __construct(?Prestation $presta = null){
47 { 47 if($presta != null){
48 if($presta != null)
49 {
50 $this->setPresta($presta); 48 $this->setPresta($presta);
51 } 49 }
52 } 50 }
@@ -63,7 +61,7 @@ class Devis
63 } 61 }
64 62
65 public function getAllWithWindowFields(): array 63 public function getAllWithWindowFields(): array
66 { 64 {
67 //~ $taches = ["Tâches:" => $this->taches]; 65 //~ $taches = ["Tâches:" => $this->taches];
68 //~ $champs_communs = [ 66 //~ $champs_communs = [
69 //~ "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, 67 //~ "Total Main d'oeuvre:" => $this->total_main_d_oeuvre,
@@ -86,7 +84,7 @@ class Devis
86 "Total HT:" => $this->total_HT, 84 "Total HT:" => $this->total_HT,
87 "Delai de livraison:" => $this->delai_livraison, 85 "Delai de livraison:" => $this->delai_livraison,
88 "Durée de validité:" => $this->validite_devis, 86 "Durée de validité:" => $this->validite_devis,
89 "Devis signé:" => $this->signature_devis]; 87 "Devis signé:" => $this->signature_devis];
90 } 88 }
91 89
92 // setters 90 // setters
@@ -165,7 +163,7 @@ class Devis
165 $this->total_HT = (float) $value; 163 $this->total_HT = (float) $value;
166 return($this); 164 return($this);
167 } 165 }
168 public function setPrixDevis($value) 166 public function setPrixDevis(string $value): Devis
169 { 167 {
170 $value = str_replace(',', '.', $value); 168 $value = str_replace(',', '.', $value);
171 $this->prix_devis = (float) $value; 169 $this->prix_devis = (float) $value;
@@ -219,8 +217,8 @@ class Devis
219 } 217 }
220 $data_array = explode('|', $answers); // array 218 $data_array = explode('|', $answers); // array
221 219
222 $check = false; 220 //$check = false;
223 if(count($data_array) === 9) // facture normale 221 if(count($data_array) === 9) // facture normale, "=== 9" = merdique
224 { 222 {
225 $this->getPresta()->setModePaiement(''); // sécurité, doctrine plante si "null" 223 $this->getPresta()->setModePaiement(''); // sécurité, doctrine plante si "null"
226 $this->setAll($data_array); 224 $this->setAll($data_array);
diff --git a/src/sections/1_customer.php b/src/sections/1_customer.php
index d282af2..d0d49ff 100644
--- a/src/sections/1_customer.php
+++ b/src/sections/1_customer.php
@@ -3,8 +3,6 @@
3// 3//
4// -- SECTION 1: Fichier clients et propects -- 4// -- SECTION 1: Fichier clients et propects --
5 5
6use Doctrine\ORM\EntityManager;
7
8function newCustomer(): array 6function newCustomer(): array
9{ 7{
10 // fenêtres 8 // fenêtres
@@ -13,29 +11,38 @@ function newCustomer(): array
13 $FinSection1 = new ZenityList(ZenitySetup::$fin_section_1['text'], ZenitySetup::$fin_section_1['entrees']); 11 $FinSection1 = new ZenityList(ZenitySetup::$fin_section_1['text'], ZenitySetup::$fin_section_1['entrees']);
14 12
15 $Customer = new Client; 13 $Customer = new Client;
14
16 15
17 // -- partie 2: saisie des infos -- 16 // -- partie 2: saisie des infos --
18 if($Customer->enterCustomer($NouveauClient)) 17 $input = exec($NouveauClient->get());
19 { 18
20 // -- partie 3: on fait quoi maintenant -- 19 // annulation
21 $choix_niv3 = exec($FinSection1->get()); 20 if($input == ''){
22 if($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][0]) 21 echo "debug: annulation lors de l'enregistrement d'un nouveau client\n";
23 { 22 return [0, null]; // menu principal
24 return [2, $Customer]; // section 2: newService() 23 }
25 } 24
26 elseif($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][1]) 25 $input = Client::controlForm($input);
27 { 26
28 return [3, $Customer]; // section 3: modifyData() 27 // vide
29 } 28 if(!$input){
30 elseif($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][2]) 29 return [1, null]; // relancer section 1: newCustomer()
31 { 30 }
32 return [1, null]; // relancer section 1: newCustomer() 31 $Customer->enterCustomer($input);
33 } 32
34 else 33
35 { 34 // -- partie 3: on fait quoi maintenant --
36 return [0, null]; // menu principal 35 $choix_niv3 = exec($FinSection1->get());
37 } 36 if($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][0]){
37 return [2, $Customer]; // section 2: newService()
38 }
39 elseif($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][1]){
40 return [3, $Customer]; // section 3: modifyData()
41 }
42 elseif($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][2]){
43 return [1, null]; // relancer section 1: newCustomer()
44 }
45 else{
46 return [0, null]; // menu principal
38 } 47 }
39
40 return [0, null]; // menu principal
41} 48}
diff --git a/à faire.txt b/à faire.txt
index 013e1e8..3009ed9 100644
--- a/à faire.txt
+++ b/à faire.txt
@@ -1,9 +1,10 @@
1À FAIRE: 1À FAIRE:
2 2
3empêcher création d'un client sans code client
4
5champ booléen "payé" dans la table prestations 3champ booléen "payé" dans la table prestations
6 4
5les prix non-entiers écrits avec une virgule perdent leurs décimales avec (float)
6ça se passe dans les entités aux les lignes comme $this->total_HT = (float)$input[6];
7
7filtre saisie caractères spéciaux: #, saut de ligne (inutile en latex) 8filtre saisie caractères spéciaux: #, saut de ligne (inutile en latex)
8 9
9une fenêtre au lancement pour prévenir si la BDD ou le mapping ne sont pas créés 10une fenêtre au lancement pour prévenir si la BDD ou le mapping ne sont pas créés