From 45f1b99a1060ee43deb6055faef1f8b16b5d80a2 Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 1 Sep 2023 12:00:23 +0200 Subject: =?UTF-8?q?section=203=20bient=C3=B4t=20termin=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/Prestations.php | 54 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) (limited to 'src/model/Prestations.php') diff --git a/src/model/Prestations.php b/src/model/Prestations.php index fe09133..e9ba7a1 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php @@ -11,6 +11,7 @@ class Prestations extends Model protected $type_presta = ''; protected $mode_paiement = ''; protected $commentaires = ''; + //protected $numero_presta = 0; public function __construct(int $ID_client) { @@ -57,14 +58,33 @@ class Prestations extends Model return [ "Numéro prestation:" => end($code_presta_tableau), // dernière case "Date:" => $Date->getDate(), - "Type de Presta:" => $this->type_presta, + //"Type de Presta:" => $this->type_presta, // choix impossible pour le moment "Mode de paiement:" => $this->mode_paiement, "Commentaires:" => $this->commentaires]; } + public function set(string $entry, string $input) + { + switch($entry) + { + case "Numéro prestation:": + $this->setNumeroPresta($input); + break; + //~ case "Date:": // inutile, setDate() est appelé directement après choix fenêtre calendrier + //~ $this->setDate($input); + //~ break; + //~ case "Type de Presta:": // choix impossible pour le moment + //~ $this->setTypePresta($input); + //~ break; + case "Mode de paiement:": + $this->setModePaiement($input); + break; + case "Commentaires:": + $this->setCommentaires($input); + break; + } + } // setters - //~ public function setID() -> dans le trait ModelChildren - public function setIDClient(int $value) { $this->ID_client = $value; @@ -80,9 +100,20 @@ class Prestations extends Model $this->code_presta = $value; return $this; } - public function setDate(int $value) + public function setDate($value, bool $set_code_presta = false) // attend un timestamp { - $this->date = $value; + $this->date = (int) $value; + + if($set_code_presta) + { + $code_presta_tableau = explode('-', $this->code_presta); + $Date = new Dates($value); + $code_presta_tableau[0] = $Date->getYear(); + $code_presta_tableau[1] = $Date->getMonth(); + $code_presta_tableau[2] = $Date->getDay(); + $this->code_presta = implode('-', $code_presta_tableau); + } + return $this; } public function setTypePresta(string $value) @@ -100,6 +131,14 @@ class Prestations extends Model $this->commentaires = $value; return $this; } + public function setNumeroPresta($value) + { + // modifier le code presta, on pourrait aussi utiliser une regex + $code_presta_tableau = explode('-', $this->code_presta); + $code_presta_tableau[count($code_presta_tableau) - 1] = (int) $value; + $this->code_presta = implode('-', $code_presta_tableau); + return $this; + } // code client = année-mois-jour-codeclient-typedepresta-combientièmefois public function makeCodePresta(Dates $Date, string $code_client) @@ -112,3 +151,8 @@ class Prestations extends Model $this->code_presta = implode('-', $array_code); } } + +class CodePresta extends Prestations +{ + protected $numero_presta; +} -- cgit v1.2.3