From 32843e50aa981f190bdb4fbc9adbeacc06fdf775 Mon Sep 17 00:00:00 2001 From: polo Date: Sat, 17 Oct 2026 23:47:31 +0200 Subject: =?UTF-8?q?retypage=20date=20prestations=20en=20string=203,=20clas?= =?UTF-8?q?se=20Dates=20supprim=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/entities/Prestation.php | 43 +++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'src/model/entities/Prestation.php') diff --git a/src/model/entities/Prestation.php b/src/model/entities/Prestation.php index fad7d7c..a0489d3 100644 --- a/src/model/entities/Prestation.php +++ b/src/model/entities/Prestation.php @@ -52,7 +52,7 @@ class Prestation { return $this->code_presta; } - public function getDate(): int + public function getDate(): string { return $this->date; } @@ -76,12 +76,9 @@ class Prestation public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) { - //$code_presta_tableau = explode('-', $this->code_presta); - $Date = new Dates($this->date); - return [ //"Numéro prestation:" => end($code_presta_tableau), // crée des conflits, calcul automatique par setCodePresta() - "Date:" => $Date->getDate(), + "Date:" => $this->date, //"Type de Presta:" => $this->type_presta, // choix impossible pour le moment "Mode de paiement:" => $this->mode_paiement, // non pertinent pour un devis "Commentaires:" => $this->commentaires]; @@ -112,10 +109,9 @@ class Prestation //~ return $this; //~ } //public function setDate(int $value) - public function setDate(Dates $Date) + public function setDate(string $date): Prestation { - //$this->date = (int)$value; // attend un timestamp - $this->date = $Date->getTimestamp(); + $this->date = $date; return $this; /*if($set_code_presta) { @@ -157,11 +153,9 @@ class Prestation //$input->typeToClient(); // on modifie $client ici (merci les références PHP) } - public function set(string $entry, string|Dates $input): void + public function set(string $entry, string $input): void { - if(gettype($input) === 'string'){ - $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide - } + $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide switch($entry){ // pas de cas "code presta" qui généré par setCodePresta, on peut modifier la date (ici) et le code client (ailleurs) @@ -185,19 +179,21 @@ class Prestation } // code presta = année-mois-jour-codeclient-typedepresta-combientièmefois - public function setCodePresta(int $increment) // 0 pour modif, 1 pour nouvelle presta + public function setCodePresta(int $increment): Prestation // 0 pour modif, 1 pour nouvelle presta { - $Date = new Dates($this->date); $repository = self::$entityManager->getRepository('Prestation'); // prestas de tout type d'un client // attention: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer - $combientieme_fois = count($repository->findBy(['client' => $this->client->getId()])) + $increment; - //var_dump($combientieme_fois); - $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $this->client->getCodeClient(), $this->type_presta, $combientieme_fois]; - //~ $array_code[0] = $Date->getYear(); - //~ $array_code[1] = $Date->getMonth(); - //~ $array_code[2] = $Date->getDay(); - //~ $array_code[3] = $this->client->getCodeClient(); // mise à jour éventuelle - //~ $array_code[4] = $this->type_presta; + $how_many_times = count($repository->findBy(['client' => $this->client->getId()])) + $increment; + //var_dump($how_many_times); + $date_array = explode('-', $this->date); + $array_code = [ + $date_array[0], // année + $date_array[1], // mois + $date_array[2], // jour + $this->client->getCodeClient(), // mise à jour éventuelle + $this->type_presta, + $how_many_times + ]; $this->code_presta = implode('-', $array_code); return $this; } @@ -244,8 +240,7 @@ class Prestation { $id = $Presta->getId(); $entrees[$id][] = $id; - $Date = new Dates((int)$Presta->getDate()); // envoi du timestamp, (int) est là par sécurité - $entrees[$id][] = $Date->getDate(); + $entrees[$id][] = $Presta->getDate(); $entrees[$id][] = $Presta->getTypePresta(); $entrees[$id][] = $Presta->getCodePresta(); } -- cgit v1.2.3