summaryrefslogtreecommitdiff
path: root/src/model/entities/Client.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/entities/Client.php')
-rw-r--r--src/model/entities/Client.php28
1 files changed, 12 insertions, 16 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