From 084264d336fa9156e1b26196d3936eb3cf2c9782 Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 9 Oct 2026 17:45:25 +0200 Subject: =?UTF-8?q?Client::controlForm()=20filtre=20un=20client=20sans=20n?= =?UTF-8?q?om=20ou=20code=20client,=20=C3=A9crire=20"gratuit"=20pour=20un?= =?UTF-8?q?=20devis=20gratuit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/entities/Client.php | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/model/entities/Client.php') 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 return str_replace($search, '', $data); } - // une partie du code vient de Model::hydrateFromForm() - // à mettre dans une classe ClientManager? - public function enterCustomer(ZenityForms $Form): bool + public static function controlForm(string $input): string|false { - $input = exec($Form->get()); - if($input == ''){ - echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; - return false; - } - $data_array = explode('|', $input); // array - if($data_array[0] == ''){ - echo "debug: données insuffisantes, le nom du client doit au minimum être renseigné\n"; + + if($data_array[0] == '' || $data_array[1] == ''){ + echo "debug: données insuffisantes, renseignez au moins un nom et un code client\n"; return false; } - else{ - $this->setAll($data_array); - } + return $input; + } + + // une partie du code vient de Model::hydrateFromForm() + // à mettre dans une classe ClientManager? + public function enterCustomer(string $input): void + { + $this->setAll(explode('|', $input)); self::$entityManager->persist($this); self::$entityManager->flush(); //$this->id = $this->db->lastInsertId(); // synchro automatique avec doctrine - - return true; } public static function find(ZenityEntry $SearchCustomerForm, ZenityList $SearchCustomerResults): ?Client -- cgit v1.2.3