From bf6655a534a6775d30cafa67bd801276bda1d98d Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 13 Aug 2024 23:45:21 +0200 Subject: =?UTF-8?q?VERSION=200.2=20doctrine=20ORM=20et=20entit=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/version 0.1/DevisFactures.php | 215 ++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 src/model/version 0.1/DevisFactures.php (limited to 'src/model/version 0.1/DevisFactures.php') diff --git a/src/model/version 0.1/DevisFactures.php b/src/model/version 0.1/DevisFactures.php new file mode 100644 index 0000000..06a0a59 --- /dev/null +++ b/src/model/version 0.1/DevisFactures.php @@ -0,0 +1,215 @@ +table = $table; // deux tables séparées devis et factures + } + + public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) + { + $taches = ["Tâches:" => $this->taches]; + $champs_communs = [ + "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, + "Pièces:" => $this->pieces, + "Total des pièces:" => $this->total_pieces, + "Déplacement:" => $this->deplacement, + "Total HT:" => $this->total_HT]; + + if($this->table === 'factures') + { + $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') + { + $champs_devis = [ + "Delai de livraison:" => $this->delai_livraison, + "Durée de validité:" => $this->validite_devis, + "Devis signé:" => $this->signature_devis]; + + return $champs_communs + $champs_devis; + } + else + { + return []; + } + } + + public function set(string $entry, string $input) // trouve la bonne méthode + { + $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide + 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 "Prix du devis:": + $this->setPrixDevis($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; + return($this); + } + public function setTaches(string $value) + { + $this->taches = $value; + return($this); + } + public function setMachine(string $value) + { + $this->machine = $value; + return($this); + } + public function setOS(string $value) + { + $this->OS = $value; + return($this); + } + public function setDonnees(string $value) + { + $this->donnees = $value; + return($this); + } + public function setClesLicences(string $value) + { + $this->cles_licences = $value; + return($this); + } + public function setTotalMainDOeuvre($value) + { + $value = str_replace(',', '.', $value); + $this->total_main_d_oeuvre = (float) $value; // float "nettoie" tous les caractères après le dernier chiffre trouvé (ex: 50€ => 50, abc => 0) + return($this); + } + public function setPieces(string $value) + { + $this->pieces = $value; + return($this); + } + public function setTotalPieces($value) + { + $value = str_replace(',', '.', $value); + $this->total_pieces = (float) $value; + return($this); + } + public function setDeplacement($value) + { + $value = str_replace(',', '.', $value); + $this->deplacement = (float) $value; + return($this); + } + public function setTotalHT($value) + { + $value = str_replace(',', '.', $value); + $this->total_HT = (float) $value; + return($this); + } + public function setPrixDevis($value) + { + $value = str_replace(',', '.', $value); + $this->prix_devis = (float) $value; + return($this); + } + public function setDelaiLivraison(string $value) + { + $this->delai_livraison = $value; + return($this); + } + public function setValiditedevis(string $value) + { + $this->validite_devis = $value; + return($this); + } + public function setSignatureDevis(string $value) + { + $this->signature_devis = $value; + return($this); + } + + // création d'une facture à partir d'un devis + public function hydrateReceiptWithQuotation($ReceiptDetails) + { + $ReceiptDetails->hydrate([ + 'taches' => $this->taches, + 'total_main_d_oeuvre' => $this->total_main_d_oeuvre, + 'pieces' => $this->pieces, + 'total_pieces' => $this->total_pieces, + 'deplacement' => $this->deplacement, + 'total_HT' => $this->total_HT + ]); + } +} -- cgit v1.2.3