From 63365247e23c206bc9eea63a224447543f1ec9b5 Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 12 Oct 2026 21:42:42 +0200 Subject: =?UTF-8?q?pr=C3=A9paration=20date=20bulletin=20de=20paie=20des=20?= =?UTF-8?q?CESU,=20relecture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/entities/CESU.php | 40 +++++++++++++++++++++++---------------- src/model/entities/Devis.php | 13 +++++-------- src/model/entities/Facture.php | 23 +++++++++------------- src/model/entities/Location.php | 15 +++++---------- src/model/entities/Prestation.php | 25 ++++++++++-------------- 5 files changed, 53 insertions(+), 63 deletions(-) (limited to 'src/model/entities') diff --git a/src/model/entities/CESU.php b/src/model/entities/CESU.php index de3a359..90eec69 100644 --- a/src/model/entities/CESU.php +++ b/src/model/entities/CESU.php @@ -27,18 +27,17 @@ class CESU #[ORM\Column] private float $salaire; + /*#[ORM\Column]*/ // pour plus tard + private ?string $date_bulletin_paie = null; // format Y-m-d conservé tout du long: formulaire, BDD, affichage + public static EntityManager $entityManager; - public function __construct(Prestation $presta = null) - { - if($presta != null) - { - $this->setPresta($presta); - } + public function __construct(?Prestation $presta = null){ + $this->setPresta($presta); } // getters - public function getPresta(): Prestation + public function getPresta(): ?Prestation { return $this->presta; } @@ -46,6 +45,11 @@ class CESU { return $this->salaire; } + + public function getPaySlipDate(): string + { + return $this->date_bulletin_paie; + } public function getAllWithWindowFields(): array { @@ -72,28 +76,33 @@ class CESU break; } } - private function setPresta(Prestation $input) // private? + private function setPresta(Prestation $input): void { $this->presta = $input; } - public function setTaches(string $value) + public function setTaches(string $value): CESU { $this->taches = $value; return($this); } - public function setDureeTravail(string $value) + public function setDureeTravail(string $value): CESU { $this->duree_travail = $value; return($this); } - public function setSalaire($value) + public function setSalaire($value): CESU { $value = str_replace(',', '.', $value); $this->salaire = (float) $value; return($this); } - private function setAll(array $input) // private? + public function setPaySlipDate(string $date): void // date 'aaaa-mm-jj' (sans heure) + { + $this->date_bulletin_paie = $date; + } + + private function setAll(array $input): void { $this->taches = $input[0]; $this->duree_travail = $input[1]; @@ -107,17 +116,16 @@ class CESU return str_replace($search, '', $data); } // à mettre plus tard dans une classe mère - public function hydrate(string $answers) + public function hydrate(string $answers): void { $answers = $this->cleanSpecialChars($answers); // possibilité que $answers devienne une chaine vide if($answers == '') { echo "erreur de CESU::hydrate(), la chaine \$answers est vide.\n"; - return false; + return; } $data_array = explode('|', $answers); // array - $check = false; if(count($data_array) === 4) // facture normale { $this->getPresta()->setModePaiement($data_array[3]); @@ -128,7 +136,7 @@ class CESU else { echo "erreur de CESU::hydrate(), le tableau \$data_array n'a pas la taille attendue.\n"; - return false; + return; } //self::$entityManager->persist('Prestation'); diff --git a/src/model/entities/Devis.php b/src/model/entities/Devis.php index ce2a043..70a3cbf 100644 --- a/src/model/entities/Devis.php +++ b/src/model/entities/Devis.php @@ -38,15 +38,13 @@ class Devis private string $delai_livraison; #[ORM\Column] private string $validite_devis; - #[ORM\Column (options: ['default' => 'non'])] + #[ORM\Column (options: ['default' => 'non'])] // défaut dans le cas d'un requête SQL ignorant ce champ private string $signature_devis = 'non'; public static EntityManager $entityManager; public function __construct(?Prestation $presta = null){ - if($presta != null){ - $this->setPresta($presta); - } + $this->setPresta($presta); } // getters @@ -207,17 +205,16 @@ class Devis return str_replace($search, '', $data); } // à mettre plus tard dans une classe mère - public function hydrate(string $answers) + public function hydrate(string $answers): void { $answers = $this->cleanSpecialChars($answers); // possibilité que $answers devienne une chaine vide if($answers == '') { echo "erreur de Devis::hydrate(), la chaine \$answers est vide.\n"; - return false; + return; } $data_array = explode('|', $answers); // array - //$check = false; if(count($data_array) === 9) // facture normale, "=== 9" = merdique { $this->getPresta()->setModePaiement(''); // sécurité, doctrine plante si "null" @@ -226,7 +223,7 @@ class Devis else { echo "erreur de Devis::hydrate(), le tableau \$data_array n'a pas la taille attendue.\n"; - return false; + return; } //self::$entityManager->persist('Prestation'); diff --git a/src/model/entities/Facture.php b/src/model/entities/Facture.php index 2eea0e5..9a9a89d 100644 --- a/src/model/entities/Facture.php +++ b/src/model/entities/Facture.php @@ -43,12 +43,8 @@ class Facture public static EntityManager $entityManager; - public function __construct(Prestation $presta = null) - { - if($presta != null) - { - $this->setPresta($presta); - } + public function __construct(?Prestation $presta = null){ + $this->setPresta($presta); } // getters @@ -62,8 +58,8 @@ class Facture return get_object_vars($this); } public function getTotalMainDOeuvre(): float - { - return $this->total_main_d_oeuvre; + { + return $this->total_main_d_oeuvre; } public function getTotalPieces(): float { @@ -75,7 +71,7 @@ class Facture } public function getAllWithWindowFields(): array - { + { //~ $taches = ["Tâches:" => $this->taches]; //~ $champs_facture = [ //~ "PC:" => $this->machine, @@ -99,7 +95,7 @@ class Facture "Pièces:" => $this->pieces, "Total des pièces:" => $this->total_pieces, "Déplacement:" => $this->deplacement, - "Total HT:" => $this->total_HT]; + "Total HT:" => $this->total_HT]; } // setters @@ -227,17 +223,16 @@ class Facture return str_replace($search, '', $data); } // à mettre plus tard dans une classe mère - public function hydrate(string $answers) + public function hydrate(string $answers): void { $answers = $this->cleanSpecialChars($answers); // possibilité que $answers devienne une chaine vide if($answers == '') { echo "erreur de Facture::hydrate(), la chaine \$answers est vide.\n"; - return false; + return; } $data_array = explode('|', $answers); // array - $check = false; if(count($data_array) === 11) // facture normale { $this->getPresta()->setModePaiement($data_array[10]); @@ -254,7 +249,7 @@ class Facture else { echo "erreur de Facture::hydrate(), le tableau \$data_array n'a pas la taille attendue.\n"; - return false; + return; } //self::$entityManager->persist('Prestation'); diff --git a/src/model/entities/Location.php b/src/model/entities/Location.php index b3c2f8a..66c3385 100644 --- a/src/model/entities/Location.php +++ b/src/model/entities/Location.php @@ -41,12 +41,8 @@ class Location public static EntityManager $entityManager; - public function __construct(Prestation $presta = null) - { - if($presta != null) - { - $this->setPresta($presta); - } + public function __construct(?Prestation $presta = null){ + $this->setPresta($presta); } // getters @@ -191,17 +187,16 @@ class Location return str_replace($search, '', $data); } // à mettre plus tard dans une classe mère - public function hydrate(string $answers) + public function hydrate(string $answers): void { $answers = $this->cleanSpecialChars($answers); // possibilité que $answers devienne une chaine vide if($answers == '') { echo "erreur de Location::hydrate(), la chaine \$answers est vide.\n"; - return false; + return; } $data_array = explode('|', $answers); // array - $check = false; if(count($data_array) === 8) { $this->getPresta()->setModePaiement(''); // sécurité, doctrine plante si "null" @@ -210,7 +205,7 @@ class Location else { echo "erreur de Location::hydrate(), le tableau \$data_array n'a pas la taille attendue.\n"; - return false; + return; } //self::$entityManager->persist('Prestation'); diff --git a/src/model/entities/Prestation.php b/src/model/entities/Prestation.php index ee9b3c0..e7abd8b 100644 --- a/src/model/entities/Prestation.php +++ b/src/model/entities/Prestation.php @@ -15,7 +15,7 @@ class Prestation #[ORM\ManyToOne(targetEntity: Client::class, cascade: ['persist'])] #[ORM\JoinColumn(name: 'id_client', referencedColumnName: 'id')] - private Client|null $client = null; // type int en SQL et dans la base + private ?Client $client = null; // type int en SQL et dans la base #[ORM\Column] private string $code_presta; @@ -40,12 +40,8 @@ class Prestation public static EntityManager $entityManager; - public function __construct(?Client $client = null) - { - if($client != null) - { - $this->setClient($client); - } + public function __construct(?Client $client = null){ + $this->setClient($client); } // getters @@ -94,8 +90,8 @@ class Prestation // une interface pour ça c'est bien aussi non? public function getFacture(): ?Facture - { - return $this->facture; + { + return $this->facture; } public function getDevis(): ?Devis { @@ -162,14 +158,13 @@ class Prestation //$input->typeToClient(); // on modifie $client ici (merci les références PHP) } - public function set(string $entry, $input) // $input = chaîne ou entier + public function set(string $entry, string|Dates $input): void { - if(gettype($input) === 'string') - { - $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide + if(gettype($input) === 'string'){ + $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide } - switch($entry) - { + + switch($entry){ // pas de cas "code presta" qui généré par setCodePresta, on peut modifier la date (ici) et le code client (ailleurs) //~ case "Numéro prestation:": //~ $this->setNumeroPresta($input); -- cgit v1.2.3