summaryrefslogtreecommitdiff
path: root/src/Latex.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Latex.php')
-rw-r--r--src/Latex.php22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/Latex.php b/src/Latex.php
index c638264..871a845 100644
--- a/src/Latex.php
+++ b/src/Latex.php
@@ -14,8 +14,7 @@ abstract class Latex
14 14
15 static function makeInstance(string $type): ?Latex 15 static function makeInstance(string $type): ?Latex
16 { 16 {
17 switch($type) 17 switch($type){
18 {
19 // documents pour les clients 18 // documents pour les clients
20 case 'devis': 19 case 'devis':
21 return new DevisLatex; 20 return new DevisLatex;
@@ -120,9 +119,10 @@ abstract class Latex
120 //~ $this->pdf_path = $pdf_path; 119 //~ $this->pdf_path = $pdf_path;
121 //~ } 120 //~ }
122 121
123 public function setData(Object $Object) 122 public function setData(Object $Object): Latex
124 { 123 {
125 $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs 124 $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs
125 return $this; // pour chainer les méthodes
126 } 126 }
127} 127}
128 128
@@ -134,9 +134,11 @@ abstract class PrestaLatex extends Latex
134 public function setData(Object $Object): Latex // polymorphisme 134 public function setData(Object $Object): Latex // polymorphisme
135 { 135 {
136 $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs 136 $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs
137 137 if(isset($this->data['date'])){
138 if(get_class($Object) === 'Prestation') 138 $this->data['date'] = str_replace('-', '/', $this->data['date']); // 17/10/2026, avec des / parce que j'aime bien
139 { 139 }
140
141 if(in_array(get_class($Object), ['Facture', 'Devis', 'Location'])){
140 $this->file_name = $Object->getCodePresta() . '.tex'; 142 $this->file_name = $Object->getCodePresta() . '.tex';
141 $this->date_array = explode('-', $Object->getdate()); 143 $this->date_array = explode('-', $Object->getdate());
142 $this->latex_path = Config::$latex_path . $this->date_array[0] . DIRECTORY_SEPARATOR; 144 $this->latex_path = Config::$latex_path . $this->date_array[0] . DIRECTORY_SEPARATOR;
@@ -152,10 +154,10 @@ abstract class PrestaLatex extends Latex
152 //~ $this->fileName = $quoi . '-' . $codePresta . '.tex'; 154 //~ $this->fileName = $quoi . '-' . $codePresta . '.tex';
153 //~ } 155 //~ }
154 156
155 public function makeLatex() 157 public function makeLatex(): void
156 { 158 {
157 $data = $this->data; 159 $data = $this->data;
158 $date = preg_replace('#\D#', '/', $this->date_array[2] . '/' . $this->date_array[1] . '/' . $this->date_array[0]); // 17/10/2026, avec des / parce que j'aime bien 160 //$date = preg_replace('#\D#', '/', $this->date_array[2] . '/' . $this->date_array[1] . '/' . $this->date_array[0]);
159 161
160 // on obtient la variable $latex avec ob_get_clean() 162 // on obtient la variable $latex avec ob_get_clean()
161 // le include() ici, c'est du génie ou c'est moche ou les deux? 163 // le include() ici, c'est du génie ou c'est moche ou les deux?
@@ -189,11 +191,13 @@ class EnveloppeRectoLatex extends Latex
189 $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/'; 191 $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/';
190 } 192 }
191 193
192 public function setData(Object $Client) // ici de type Clients 194 public function setData(Object $Client): Latex // ici de type Clients
193 { 195 {
194 $this->file_name = $Client->getCodeClient() . '.tex'; 196 $this->file_name = $Client->getCodeClient() . '.tex';
195 $this->data = array_merge($this->data, $Client->getAll()); // nécessite des tableaux associatifs 197 $this->data = array_merge($this->data, $Client->getAll()); // nécessite des tableaux associatifs
196 $this->spacesInPostCode(); // nécessite $this->data 198 $this->spacesInPostCode(); // nécessite $this->data
199
200 return $this; // pour chainer les méthodes
197 } 201 }
198 202
199 // code postal avec 2 espaces entre chaque chiffre: 2 \ 9 \ 0 \ 0 \ 0 203 // code postal avec 2 espaces entre chaque chiffre: 2 \ 9 \ 0 \ 0 \ 0