summaryrefslogtreecommitdiff
path: root/old/model version 0.1/DevisFactures.php
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2024-08-14 17:20:10 +0200
committerpolo <ordipolo@gmx.fr>2024-08-14 17:20:10 +0200
commit5fb0a2785718160317069c87496d1602e32ea3d6 (patch)
tree3225c81385576a2ece5fdefa54d3fb7059115b71 /old/model version 0.1/DevisFactures.php
parentbf6655a534a6775d30cafa67bd801276bda1d98d (diff)
downloadAppliGestionPHP-5fb0a2785718160317069c87496d1602e32ea3d6.zip
autoload avec composer
Diffstat (limited to 'old/model version 0.1/DevisFactures.php')
-rw-r--r--old/model version 0.1/DevisFactures.php215
1 files changed, 215 insertions, 0 deletions
diff --git a/old/model version 0.1/DevisFactures.php b/old/model version 0.1/DevisFactures.php
new file mode 100644
index 0000000..06a0a59
--- /dev/null
+++ b/old/model version 0.1/DevisFactures.php
@@ -0,0 +1,215 @@
1<?php
2// src/model/DevisFactures.php
3
4class DevisFactures extends Model
5{
6 //~ public $type = ''; // deux tables séparées devis ou factures
7
8 // lecture des données ou hydratation
9 protected $id; // auto-incrémentée
10 protected $id_presta;
11 protected $taches;
12 protected $machine;
13 protected $OS;
14 protected $donnees;
15 protected $cles_licences;
16 protected $total_main_d_oeuvre;
17 protected $pieces;
18 protected $total_pieces;
19 protected $deplacement;
20 protected $prix_devis;
21 protected $total_HT;
22 protected $delai_livraison;
23 protected $validite_devis;
24 protected $signature_devis;
25
26 public function __construct(string $table)
27 {
28 $this->table = $table; // deux tables séparées devis et factures
29 }
30
31 public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this)
32 {
33 $taches = ["Tâches:" => $this->taches];
34 $champs_communs = [
35 "Total Main d'oeuvre:" => $this->total_main_d_oeuvre,
36 "Pièces:" => $this->pieces,
37 "Total des pièces:" => $this->total_pieces,
38 "Déplacement:" => $this->deplacement,
39 "Total HT:" => $this->total_HT];
40
41 if($this->table === 'factures')
42 {
43 $champs_facture = [
44 "PC:" => $this->machine,
45 "OS:" => $this->OS,
46 "Données:" => $this->donnees,
47 "Clés de licences:" => $this->cles_licences];
48
49 return $taches + $champs_facture + $champs_communs;
50 }
51 elseif($this->table === 'devis')
52 {
53 $champs_devis = [
54 "Delai de livraison:" => $this->delai_livraison,
55 "Durée de validité:" => $this->validite_devis,
56 "Devis signé:" => $this->signature_devis];
57
58 return $champs_communs + $champs_devis;
59 }
60 else
61 {
62 return [];
63 }
64 }
65
66 public function set(string $entry, string $input) // trouve la bonne méthode
67 {
68 $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide
69 switch($entry)
70 {
71 case "Tâches:":
72 $this->setTaches($input);
73 break;
74 case "PC:":
75 $this->setMachine($input);
76 break;
77 case "OS:":
78 $this->setOS($input);
79 break;
80 case "Données:":
81 $this->setDonnees($input);
82 break;
83 case "Clés de licences:":
84 $this->setClesLicences($input);
85 break;
86 case "Total Main d'oeuvre:":
87 $this->setTotalMainDOeuvre($input);
88 break;
89 case "Pièces:":
90 $this->setPieces($input);
91 break;
92 case "Total des pièces:":
93 $this->setTotalPieces($input);
94 break;
95 case "Déplacement:":
96 $this->setDeplacement($input);
97 break;
98 case "Prix du devis:":
99 $this->setPrixDevis($input);
100 break;
101 case "Total HT:":
102 $this->setTotalHT($input);
103 break;
104 case "Delai de livraison:":
105 $this->setDelaiLivraison($input);
106 break;
107 case "Durée de validité:":
108 $this->setValiditedevis($input);
109 break;
110 case "Devis signé:":
111 $this->setSignatureDevis($input);
112 break;
113 }
114 }
115
116 // setters
117 //~ public function setId(int $value = 0)
118 //~ {
119 //~ $this->id = $value;
120 //~ return($this);
121 //~ }
122 public function setIdPresta(int $value)
123 {
124 $this->id_presta = $value;
125 return($this);
126 }
127 public function setTaches(string $value)
128 {
129 $this->taches = $value;
130 return($this);
131 }
132 public function setMachine(string $value)
133 {
134 $this->machine = $value;
135 return($this);
136 }
137 public function setOS(string $value)
138 {
139 $this->OS = $value;
140 return($this);
141 }
142 public function setDonnees(string $value)
143 {
144 $this->donnees = $value;
145 return($this);
146 }
147 public function setClesLicences(string $value)
148 {
149 $this->cles_licences = $value;
150 return($this);
151 }
152 public function setTotalMainDOeuvre($value)
153 {
154 $value = str_replace(',', '.', $value);
155 $this->total_main_d_oeuvre = (float) $value; // float "nettoie" tous les caractères après le dernier chiffre trouvé (ex: 50€ => 50, abc => 0)
156 return($this);
157 }
158 public function setPieces(string $value)
159 {
160 $this->pieces = $value;
161 return($this);
162 }
163 public function setTotalPieces($value)
164 {
165 $value = str_replace(',', '.', $value);
166 $this->total_pieces = (float) $value;
167 return($this);
168 }
169 public function setDeplacement($value)
170 {
171 $value = str_replace(',', '.', $value);
172 $this->deplacement = (float) $value;
173 return($this);
174 }
175 public function setTotalHT($value)
176 {
177 $value = str_replace(',', '.', $value);
178 $this->total_HT = (float) $value;
179 return($this);
180 }
181 public function setPrixDevis($value)
182 {
183 $value = str_replace(',', '.', $value);
184 $this->prix_devis = (float) $value;
185 return($this);
186 }
187 public function setDelaiLivraison(string $value)
188 {
189 $this->delai_livraison = $value;
190 return($this);
191 }
192 public function setValiditedevis(string $value)
193 {
194 $this->validite_devis = $value;
195 return($this);
196 }
197 public function setSignatureDevis(string $value)
198 {
199 $this->signature_devis = $value;
200 return($this);
201 }
202
203 // création d'une facture à partir d'un devis
204 public function hydrateReceiptWithQuotation($ReceiptDetails)
205 {
206 $ReceiptDetails->hydrate([
207 'taches' => $this->taches,
208 'total_main_d_oeuvre' => $this->total_main_d_oeuvre,
209 'pieces' => $this->pieces,
210 'total_pieces' => $this->total_pieces,
211 'deplacement' => $this->deplacement,
212 'total_HT' => $this->total_HT
213 ]);
214 }
215}