summaryrefslogtreecommitdiff
path: root/src/model/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/entities')
-rw-r--r--src/model/entities/Client.php28
-rw-r--r--src/model/entities/Devis.php16
2 files changed, 19 insertions, 25 deletions
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);