summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2026-10-09 17:45:25 +0200
committerpolo <ordipolo@gmx.fr>2026-10-09 17:45:25 +0200
commit084264d336fa9156e1b26196d3936eb3cf2c9782 (patch)
tree11f177504172de9e75184fa4f61c01d4cf85be1c /src
parentf2f5560339203baad7951006c5a63d10f237ee6a (diff)
downloadAppliGestionPHP-084264d336fa9156e1b26196d3936eb3cf2c9782.tar.gz
AppliGestionPHP-084264d336fa9156e1b26196d3936eb3cf2c9782.tar.bz2
AppliGestionPHP-084264d336fa9156e1b26196d3936eb3cf2c9782.zip
Client::controlForm() filtre un client sans nom ou code client, écrire "gratuit" pour un devis gratuit
Diffstat (limited to 'src')
-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
4 files changed, 55 insertions, 50 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}