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 ++++++++++++---------------- src/model/entities/Devis.php | 16 +++++++--------- 2 files changed, 19 insertions(+), 25 deletions(-) (limited to 'src/model') 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 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 public static EntityManager $entityManager; - public function __construct(Prestation $presta = null) - { - if($presta != null) - { + public function __construct(?Prestation $presta = null){ + if($presta != null){ $this->setPresta($presta); } } @@ -63,7 +61,7 @@ class Devis } public function getAllWithWindowFields(): array - { + { //~ $taches = ["Tâches:" => $this->taches]; //~ $champs_communs = [ //~ "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, @@ -86,7 +84,7 @@ class Devis "Total HT:" => $this->total_HT, "Delai de livraison:" => $this->delai_livraison, "Durée de validité:" => $this->validite_devis, - "Devis signé:" => $this->signature_devis]; + "Devis signé:" => $this->signature_devis]; } // setters @@ -165,7 +163,7 @@ class Devis $this->total_HT = (float) $value; return($this); } - public function setPrixDevis($value) + public function setPrixDevis(string $value): Devis { $value = str_replace(',', '.', $value); $this->prix_devis = (float) $value; @@ -219,8 +217,8 @@ class Devis } $data_array = explode('|', $answers); // array - $check = false; - if(count($data_array) === 9) // facture normale + //$check = false; + if(count($data_array) === 9) // facture normale, "=== 9" = merdique { $this->getPresta()->setModePaiement(''); // sécurité, doctrine plante si "null" $this->setAll($data_array); -- cgit v1.2.3