summaryrefslogtreecommitdiff
path: root/src/Latex.php
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2023-07-22 12:29:47 +0200
committerpolo <ordipolo@gmx.fr>2023-07-22 12:29:47 +0200
commit747674b450d6840ce9bd9aecd765cf31445ef8d3 (patch)
tree46e47fd65c751e1951d9aa8438aea1b8c2d8aece /src/Latex.php
parent9bdfb5196a2ee1cbfc403702e8d2ef88076d366f (diff)
downloadAppliGestionPHP-747674b450d6840ce9bd9aecd765cf31445ef8d3.zip
navigation entre sections, boucle principale, client ou prospect
Diffstat (limited to 'src/Latex.php')
-rw-r--r--src/Latex.php94
1 files changed, 65 insertions, 29 deletions
diff --git a/src/Latex.php b/src/Latex.php
index 051c48b..547c130 100644
--- a/src/Latex.php
+++ b/src/Latex.php
@@ -12,7 +12,7 @@ abstract class Latex
12 protected $data = []; // données à insérer dans le template 12 protected $data = []; // données à insérer dans le template
13 protected $latex = ''; // latex pur 13 protected $latex = ''; // latex pur
14 14
15 static function makeLatexSubClass(string $type): Object 15 static function makeLatexSubClass(string $type)
16 { 16 {
17 switch($type) 17 switch($type)
18 { 18 {
@@ -27,16 +27,20 @@ abstract class Latex
27 return new EnveloppeRectoLatex($type); 27 return new EnveloppeRectoLatex($type);
28 case 'enveloppe_verso': 28 case 'enveloppe_verso':
29 return new EnveloppeVersoLatex($type); 29 return new EnveloppeVersoLatex($type);
30 // pas de document
31 case 'cesu':
32 return null;
33 case 'non_vendue':
34 return null;
30 35
31 // documents pour la compta 36 // documents pour la compta
32 37
33 // erreur 38 // erreur
34 default: 39 default:
35 echo 'erreur, la sous-classe latex à initialiser n\'existe pas'; 40 echo "erreur, la sous-classe latex à initialiser n'existe pas\n";
36 } 41 }
37 } 42 }
38 43
39 // tester en private?
40 public function __construct(string $type) 44 public function __construct(string $type)
41 { 45 {
42 $this->type = $type; 46 $this->type = $type;
@@ -70,30 +74,28 @@ abstract class Latex
70 { 74 {
71 return $this->pdf_path; 75 return $this->pdf_path;
72 } 76 }
73
74 public function getLatex(): string 77 public function getLatex(): string
75 { 78 {
76 return $this->latex; 79 return $this->latex;
77 } 80 }
78 81
79 // setters 82 // setters
80 public function setFileName(string $file_name) 83 //~ public function setFileName(string $file_name)
81 { 84 //~ {
82 $this->file_name = $file_name; 85 //~ $this->file_name = $file_name;
83 } 86 //~ }
84 public function setLatexPath(string $latex_path) 87 //~ public function setLatexPath(string $latex_path)
85 { 88 //~ {
86 $this->latex_path = $latex_path; 89 //~ $this->latex_path = $latex_path;
87 } 90 //~ }
88 public function setPdfPath(string $pdf_path) 91 //~ public function setPdfPath(string $pdf_path)
89 { 92 //~ {
90 $this->pdf_path = $pdf_path; 93 //~ $this->pdf_path = $pdf_path;
91 } 94 //~ }
92 95
93 public function setData(Object $Object) 96 public function setData(Object $Object)
94 { 97 {
95 $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs 98 $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs
96 //return $Object; // pour chainer les méthodes
97 } 99 }
98} 100}
99 101
@@ -101,24 +103,36 @@ abstract class Latex
101abstract class PrestaLatex extends Latex 103abstract class PrestaLatex extends Latex
102{ 104{
103 protected $Date; // sera un type "Dates" 105 protected $Date; // sera un type "Dates"
104 protected $year = '';
105 106
106 //~ public function __construct(string $type) // surcharge Latex::__construct() 107 //~ public function __construct(string $type)
107 //~ { 108 //~ {
108 //~ $this->type = $type; 109 //~ $this->type = $type;
109 //~ $this->Date = new Dates();
110 //~ $this->year = $this->Date->getYear();
111 //~ } 110 //~ }
112 111
113 public function getYear(): string // parce que Dates::getDate() retourne une chaine 112 public function setData(Object $Object): self
114 { 113 {
115 return $this->year; 114 $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs
115
116 if(get_class($Object) === 'Prestations')
117 {
118 $this->file_name = $Object->getCodePresta() . '.tex';
119 $this->makeDateInstance($Object->getDate()); // paramètre = int
120
121 $this->latex_path = Config::$latex_path . $this->Date->getYear() . '/';
122 $this->pdf_path = Config::$pdf_path . $this->Date->getYear() . '/';
123 }
124
125 return $this; // pour chainer les méthodes
116 } 126 }
117 127
118 public function makeDateInstance(int $date) 128 //~ public function getYear(): string // parce que Dates::getDate() retourne une chaine
129 //~ {
130 //~ return $this->year;
131 //~ }
132
133 protected function makeDateInstance(int $timestamp)
119 { 134 {
120 $this->Date = new Dates($date); 135 $this->Date = new Dates($timestamp);
121 $this->year = $this->Date->getYear();
122 } 136 }
123 137
124 // forme = code-presta.tex 138 // forme = code-presta.tex
@@ -143,23 +157,45 @@ abstract class PrestaLatex extends Latex
143 //return($latex); 157 //return($latex);
144 } 158 }
145} 159}
146
147class DevisLatex extends PrestaLatex // extends Latex 160class DevisLatex extends PrestaLatex // extends Latex
148{} 161{}
149class FactureLatex extends PrestaLatex // extends Latex 162class FactureLatex extends PrestaLatex // extends Latex
150{} 163{}
151class LocationLatex extends PrestaLatex // extends Latex 164class LocationLatex extends PrestaLatex // extends Latex
152{} 165{}
166
153class EnveloppeRectoLatex extends Latex 167class EnveloppeRectoLatex extends Latex
154{ 168{
169 public function __construct(string $type)
170 {
171 $this->type = $type;
172 $this->latex_path = Config::$latex_path . 'enveloppes_recto/';
173 $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/';
174 }
175
176 public function setData(Object $Client) // ici de type Clients
177 {
178 $this->file_name = $Client->getCodeClient() . '.tex';
179 $this->data = array_merge($this->data, $Client->getAll()); // nécessite des tableaux associatifs
180 $this->spacesInPostCode(); // nécessite $this->data
181 }
182
155 // code postal avec 2 espaces entre chaque chiffre: 2 \ 9 \ 0 \ 0 \ 0 183 // code postal avec 2 espaces entre chaque chiffre: 2 \ 9 \ 0 \ 0 \ 0
156 public function spacesInPostCode() 184 protected function spacesInPostCode()
157 { 185 {
158 $this->data['code_postal_espaces'] = implode(' \ ', str_split($this->data['code_postal'])); 186 $this->data['code_postal_espaces'] = implode(' \ ', str_split($this->data['code_postal']));
159 } 187 }
160} 188}
161class EnveloppeVersoLatex extends Latex 189class EnveloppeVersoLatex extends Latex
162{} 190{
191 public function __construct(string $type)
192 {
193 $this->type = $type;
194 $this->file_name = 'enveloppe_verso.tex';
195 $this->latex_path = Config::$latex_path;
196 $this->pdf_path = Config::$pdf_path;
197 }
198}
163 199
164 200
165 201