summaryrefslogtreecommitdiff
path: root/src/Latex.php
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2026-10-17 23:47:31 +0200
committerpolo <ordipolo@gmx.fr>2026-10-17 23:47:45 +0200
commit32843e50aa981f190bdb4fbc9adbeacc06fdf775 (patch)
treea24ca45e170a69546a251f284dc1ebc578d14be8 /src/Latex.php
parent93c5a89a7a4ff7e7e3d83fd6799df96b7da4283a (diff)
downloadAppliGestionPHP-32843e50aa981f190bdb4fbc9adbeacc06fdf775.tar.gz
AppliGestionPHP-32843e50aa981f190bdb4fbc9adbeacc06fdf775.tar.bz2
AppliGestionPHP-32843e50aa981f190bdb4fbc9adbeacc06fdf775.zip
retypage date prestations en string 3, classe Dates supprimée
Diffstat (limited to 'src/Latex.php')
-rw-r--r--src/Latex.php26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/Latex.php b/src/Latex.php
index 261d35e..f49fdea 100644
--- a/src/Latex.php
+++ b/src/Latex.php
@@ -12,7 +12,7 @@ abstract class Latex
12 protected array $data = []; // données à insérer dans le template 12 protected array $data = []; // données à insérer dans le template
13 protected string $latex; // latex pur 13 protected string $latex; // latex pur
14 14
15 static function makeInstance(string $type) 15 static function makeInstance(string $type): ?Latex
16 { 16 {
17 switch($type) 17 switch($type)
18 { 18 {
@@ -38,6 +38,7 @@ abstract class Latex
38 // erreur 38 // erreur
39 default: 39 default:
40 echo "erreur, la sous-classe latex à initialiser n'existe pas\n"; 40 echo "erreur, la sous-classe latex à initialiser n'existe pas\n";
41 return null;
41 } 42 }
42 } 43 }
43 44
@@ -98,34 +99,23 @@ abstract class Latex
98 99
99abstract class PrestaLatex extends Latex 100abstract class PrestaLatex extends Latex
100{ 101{
101 protected Dates $Date; 102 protected array $date_array; // [année, mois, jour]
102 103
103 public function setData(Object $Object): self 104 public function setData(Object $Object): Latex // polymorphisme
104 { 105 {
105 $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs 106 $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs
106 107
107 if(get_class($Object) === 'Prestation') 108 if(get_class($Object) === 'Prestation')
108 { 109 {
109 $this->file_name = $Object->getCodePresta() . '.tex'; 110 $this->file_name = $Object->getCodePresta() . '.tex';
110 $this->makeDateInstance($Object->getDate()); // paramètre = int 111 $this->date_array = explode('-', $Object->getdate());
111 112 $this->latex_path = Config::$latex_path . $this->date_array[0] . '/';
112 $this->latex_path = Config::$latex_path . $this->Date->getYear() . '/'; 113 $this->pdf_path = Config::$pdf_path . $this->date_array[0] . '/';
113 $this->pdf_path = Config::$pdf_path . $this->Date->getYear() . '/';
114 } 114 }
115 115
116 return $this; // pour chainer les méthodes 116 return $this; // pour chainer les méthodes
117 } 117 }
118 118
119 //~ public function getYear(): string // parce que Dates::getDate() retourne une chaine
120 //~ {
121 //~ return $this->year;
122 //~ }
123
124 protected function makeDateInstance(int $timestamp)
125 {
126 $this->Date = new Dates($timestamp);
127 }
128
129 // forme = code-presta.tex 119 // forme = code-presta.tex
130 //~ protected function nameTheFile(string $quoi, string $codePresta) 120 //~ protected function nameTheFile(string $quoi, string $codePresta)
131 //~ { 121 //~ {
@@ -135,7 +125,7 @@ abstract class PrestaLatex extends Latex
135 public function makeLatex() 125 public function makeLatex()
136 { 126 {
137 $data = $this->data; 127 $data = $this->data;
138 $date = preg_replace('#\D#', '/', $this->Date->getDate()); // date avec des slashs / parce que j'aime bien 128 $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
139 129
140 // on obtient la variable $latex avec ob_get_clean() 130 // on obtient la variable $latex avec ob_get_clean()
141 // le include() ici, c'est du génie ou c'est moche ou les deux? 131 // le include() ici, c'est du génie ou c'est moche ou les deux?