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/Clients.php | 2 +- src/model/DevisFactures.php | 66 ++++++++++++++++++++++++++++++++++++++++----- src/model/Prestations.php | 54 +++++++++++++++++++++++++++++++++---- 3 files changed, 109 insertions(+), 13 deletions(-) (limited to 'src/model') diff --git a/src/model/Clients.php b/src/model/Clients.php index 6a4dcf5..524070a 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php @@ -42,7 +42,7 @@ class Clients extends Model "À propos:" => $this->apropos, "Client ou Prospect?" => $this->type]; } - public function getSetterAndSet(string $entry, string $input) + public function set(string $entry, string $input) { switch($entry) { diff --git a/src/model/DevisFactures.php b/src/model/DevisFactures.php index 5769842..2a5bf8d 100644 --- a/src/model/DevisFactures.php +++ b/src/model/DevisFactures.php @@ -28,12 +28,8 @@ class DevisFactures extends Model } public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) { + $taches = ["Tâches:" => $this->taches]; $champs_communs = [ - "Tâches:" => $this->taches, - "PC:" => $this->machine, - "OS:" => $this->OS, - "Données:" => $this->donnees, - "Clés de licences:" => $this->cles_licences, "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, "Pièces" => $this->pieces, "Total des pièces" => $this->total_pieces, @@ -42,7 +38,13 @@ class DevisFactures extends Model if($this->table === 'factures') { - return ["Numéro facture:" => $this->ID] + $champs_communs; + $champs_facture = [ + "PC:" => $this->machine, + "OS:" => $this->OS, + "Données:" => $this->donnees, + "Clés de licences:" => $this->cles_licences]; + + return $taches + $champs_facture + $champs_communs; } elseif($this->table === 'devis') { @@ -51,15 +53,65 @@ class DevisFactures extends Model "Durée de validité" => $this->validite_devis, "Devis signé?" => $this->signature_devis]; - return ["Numéro devis:" => $this->ID] + $champs_communs + $champs_devis; + return $champs_communs + $champs_devis; } else { return []; } } + public function set(string $entry, string $input) + { + switch($entry) + { + case "Tâches:": + $this->setTaches($input); + break; + case "PC:": + $this->setMachine($input); + break; + case "OS:": + $this->setOS($input); + break; + case "Données:": + $this->setDonnees($input); + break; + case "Clés de licences:": + $this->setClesLicences($input); + break; + case "Total Main d'oeuvre:": + $this->setTotalMainDOeuvre($input); + break; + case "Pièces:": + $this->setPieces($input); + break; + case "Total des pièces:": + $this->setTotalPieces($input); + break; + case "Déplacement:": + $this->setDeplacement($input); + break; + case "Total HT:": + $this->setTotalHT($input); + break; + case "Delai de livraison:": + $this->setDelaiLivraison($input); + break; + case "Durée de validité:": + $this->setValiditedevis($input); + break; + case "Devis signé?:": + $this->setSignatureDevis($input); + break; + } + } // setters + //~ public function setID(int $value = 0) + //~ { + //~ $this->ID = $value; + //~ return($this); + //~ } public function setIDPresta(int $value) { $this->ID_presta = $value; 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