From 747674b450d6840ce9bd9aecd765cf31445ef8d3 Mon Sep 17 00:00:00 2001 From: polo Date: Sat, 22 Jul 2023 12:29:47 +0200 Subject: navigation entre sections, boucle principale, client ou prospect --- src/Latex.php | 94 +++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 29 deletions(-) (limited to 'src/Latex.php') 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 protected $data = []; // données à insérer dans le template protected $latex = ''; // latex pur - static function makeLatexSubClass(string $type): Object + static function makeLatexSubClass(string $type) { switch($type) { @@ -27,16 +27,20 @@ abstract class Latex return new EnveloppeRectoLatex($type); case 'enveloppe_verso': return new EnveloppeVersoLatex($type); + // pas de document + case 'cesu': + return null; + case 'non_vendue': + return null; // documents pour la compta // erreur default: - echo 'erreur, la sous-classe latex à initialiser n\'existe pas'; + echo "erreur, la sous-classe latex à initialiser n'existe pas\n"; } } - // tester en private? public function __construct(string $type) { $this->type = $type; @@ -70,30 +74,28 @@ abstract class Latex { return $this->pdf_path; } - public function getLatex(): string { return $this->latex; } // setters - public function setFileName(string $file_name) - { - $this->file_name = $file_name; - } - public function setLatexPath(string $latex_path) - { - $this->latex_path = $latex_path; - } - public function setPdfPath(string $pdf_path) - { - $this->pdf_path = $pdf_path; - } + //~ public function setFileName(string $file_name) + //~ { + //~ $this->file_name = $file_name; + //~ } + //~ public function setLatexPath(string $latex_path) + //~ { + //~ $this->latex_path = $latex_path; + //~ } + //~ public function setPdfPath(string $pdf_path) + //~ { + //~ $this->pdf_path = $pdf_path; + //~ } public function setData(Object $Object) { $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs - //return $Object; // pour chainer les méthodes } } @@ -101,24 +103,36 @@ abstract class Latex abstract class PrestaLatex extends Latex { protected $Date; // sera un type "Dates" - protected $year = ''; - //~ public function __construct(string $type) // surcharge Latex::__construct() + //~ public function __construct(string $type) //~ { //~ $this->type = $type; - //~ $this->Date = new Dates(); - //~ $this->year = $this->Date->getYear(); //~ } - public function getYear(): string // parce que Dates::getDate() retourne une chaine + public function setData(Object $Object): self { - return $this->year; + $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs + + if(get_class($Object) === 'Prestations') + { + $this->file_name = $Object->getCodePresta() . '.tex'; + $this->makeDateInstance($Object->getDate()); // paramètre = int + + $this->latex_path = Config::$latex_path . $this->Date->getYear() . '/'; + $this->pdf_path = Config::$pdf_path . $this->Date->getYear() . '/'; + } + + return $this; // pour chainer les méthodes } - public function makeDateInstance(int $date) + //~ public function getYear(): string // parce que Dates::getDate() retourne une chaine + //~ { + //~ return $this->year; + //~ } + + protected function makeDateInstance(int $timestamp) { - $this->Date = new Dates($date); - $this->year = $this->Date->getYear(); + $this->Date = new Dates($timestamp); } // forme = code-presta.tex @@ -143,23 +157,45 @@ abstract class PrestaLatex extends Latex //return($latex); } } - class DevisLatex extends PrestaLatex // extends Latex {} class FactureLatex extends PrestaLatex // extends Latex {} class LocationLatex extends PrestaLatex // extends Latex {} + class EnveloppeRectoLatex extends Latex { + public function __construct(string $type) + { + $this->type = $type; + $this->latex_path = Config::$latex_path . 'enveloppes_recto/'; + $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/'; + } + + public function setData(Object $Client) // ici de type Clients + { + $this->file_name = $Client->getCodeClient() . '.tex'; + $this->data = array_merge($this->data, $Client->getAll()); // nécessite des tableaux associatifs + $this->spacesInPostCode(); // nécessite $this->data + } + // code postal avec 2 espaces entre chaque chiffre: 2 \ 9 \ 0 \ 0 \ 0 - public function spacesInPostCode() + protected function spacesInPostCode() { $this->data['code_postal_espaces'] = implode(' \ ', str_split($this->data['code_postal'])); } } class EnveloppeVersoLatex extends Latex -{} +{ + public function __construct(string $type) + { + $this->type = $type; + $this->file_name = 'enveloppe_verso.tex'; + $this->latex_path = Config::$latex_path; + $this->pdf_path = Config::$pdf_path; + } +} -- cgit v1.2.3