diff options
| author | polo <ordipolo@gmx.fr> | 2026-10-17 23:47:31 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-10-17 23:47:45 +0200 |
| commit | 32843e50aa981f190bdb4fbc9adbeacc06fdf775 (patch) | |
| tree | a24ca45e170a69546a251f284dc1ebc578d14be8 /src/model/entities | |
| parent | 93c5a89a7a4ff7e7e3d83fd6799df96b7da4283a (diff) | |
| download | AppliGestionPHP-32843e50aa981f190bdb4fbc9adbeacc06fdf775.tar.gz AppliGestionPHP-32843e50aa981f190bdb4fbc9adbeacc06fdf775.tar.bz2 AppliGestionPHP-32843e50aa981f190bdb4fbc9adbeacc06fdf775.zip | |
retypage date prestations en string 3, classe Dates supprimée
Diffstat (limited to 'src/model/entities')
| -rw-r--r-- | src/model/entities/Prestation.php | 43 |
1 files changed, 19 insertions, 24 deletions
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 | |||
| 52 | { | 52 | { |
| 53 | return $this->code_presta; | 53 | return $this->code_presta; |
| 54 | } | 54 | } |
| 55 | public function getDate(): int | 55 | public function getDate(): string |
| 56 | { | 56 | { |
| 57 | return $this->date; | 57 | return $this->date; |
| 58 | } | 58 | } |
| @@ -76,12 +76,9 @@ class Prestation | |||
| 76 | 76 | ||
| 77 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | 77 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) |
| 78 | { | 78 | { |
| 79 | //$code_presta_tableau = explode('-', $this->code_presta); | ||
| 80 | $Date = new Dates($this->date); | ||
| 81 | |||
| 82 | return [ | 79 | return [ |
| 83 | //"Numéro prestation:" => end($code_presta_tableau), // crée des conflits, calcul automatique par setCodePresta() | 80 | //"Numéro prestation:" => end($code_presta_tableau), // crée des conflits, calcul automatique par setCodePresta() |
| 84 | "Date:" => $Date->getDate(), | 81 | "Date:" => $this->date, |
| 85 | //"Type de Presta:" => $this->type_presta, // choix impossible pour le moment | 82 | //"Type de Presta:" => $this->type_presta, // choix impossible pour le moment |
| 86 | "Mode de paiement:" => $this->mode_paiement, // non pertinent pour un devis | 83 | "Mode de paiement:" => $this->mode_paiement, // non pertinent pour un devis |
| 87 | "Commentaires:" => $this->commentaires]; | 84 | "Commentaires:" => $this->commentaires]; |
| @@ -112,10 +109,9 @@ class Prestation | |||
| 112 | //~ return $this; | 109 | //~ return $this; |
| 113 | //~ } | 110 | //~ } |
| 114 | //public function setDate(int $value) | 111 | //public function setDate(int $value) |
| 115 | public function setDate(Dates $Date) | 112 | public function setDate(string $date): Prestation |
| 116 | { | 113 | { |
| 117 | //$this->date = (int)$value; // attend un timestamp | 114 | $this->date = $date; |
| 118 | $this->date = $Date->getTimestamp(); | ||
| 119 | return $this; | 115 | return $this; |
| 120 | /*if($set_code_presta) | 116 | /*if($set_code_presta) |
| 121 | { | 117 | { |
| @@ -157,11 +153,9 @@ class Prestation | |||
| 157 | //$input->typeToClient(); // on modifie $client ici (merci les références PHP) | 153 | //$input->typeToClient(); // on modifie $client ici (merci les références PHP) |
| 158 | } | 154 | } |
| 159 | 155 | ||
| 160 | public function set(string $entry, string|Dates $input): void | 156 | public function set(string $entry, string $input): void |
| 161 | { | 157 | { |
| 162 | if(gettype($input) === 'string'){ | 158 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide |
| 163 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide | ||
| 164 | } | ||
| 165 | 159 | ||
| 166 | switch($entry){ | 160 | switch($entry){ |
| 167 | // pas de cas "code presta" qui généré par setCodePresta, on peut modifier la date (ici) et le code client (ailleurs) | 161 | // 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 | |||
| 185 | } | 179 | } |
| 186 | 180 | ||
| 187 | // code presta = année-mois-jour-codeclient-typedepresta-combientièmefois | 181 | // code presta = année-mois-jour-codeclient-typedepresta-combientièmefois |
| 188 | public function setCodePresta(int $increment) // 0 pour modif, 1 pour nouvelle presta | 182 | public function setCodePresta(int $increment): Prestation // 0 pour modif, 1 pour nouvelle presta |
| 189 | { | 183 | { |
| 190 | $Date = new Dates($this->date); | ||
| 191 | $repository = self::$entityManager->getRepository('Prestation'); // prestas de tout type d'un client | 184 | $repository = self::$entityManager->getRepository('Prestation'); // prestas de tout type d'un client |
| 192 | // attention: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer | 185 | // attention: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer |
| 193 | $combientieme_fois = count($repository->findBy(['client' => $this->client->getId()])) + $increment; | 186 | $how_many_times = count($repository->findBy(['client' => $this->client->getId()])) + $increment; |
| 194 | //var_dump($combientieme_fois); | 187 | //var_dump($how_many_times); |
| 195 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $this->client->getCodeClient(), $this->type_presta, $combientieme_fois]; | 188 | $date_array = explode('-', $this->date); |
| 196 | //~ $array_code[0] = $Date->getYear(); | 189 | $array_code = [ |
| 197 | //~ $array_code[1] = $Date->getMonth(); | 190 | $date_array[0], // année |
| 198 | //~ $array_code[2] = $Date->getDay(); | 191 | $date_array[1], // mois |
| 199 | //~ $array_code[3] = $this->client->getCodeClient(); // mise à jour éventuelle | 192 | $date_array[2], // jour |
| 200 | //~ $array_code[4] = $this->type_presta; | 193 | $this->client->getCodeClient(), // mise à jour éventuelle |
| 194 | $this->type_presta, | ||
| 195 | $how_many_times | ||
| 196 | ]; | ||
| 201 | $this->code_presta = implode('-', $array_code); | 197 | $this->code_presta = implode('-', $array_code); |
| 202 | return $this; | 198 | return $this; |
| 203 | } | 199 | } |
| @@ -244,8 +240,7 @@ class Prestation | |||
| 244 | { | 240 | { |
| 245 | $id = $Presta->getId(); | 241 | $id = $Presta->getId(); |
| 246 | $entrees[$id][] = $id; | 242 | $entrees[$id][] = $id; |
| 247 | $Date = new Dates((int)$Presta->getDate()); // envoi du timestamp, (int) est là par sécurité | 243 | $entrees[$id][] = $Presta->getDate(); |
| 248 | $entrees[$id][] = $Date->getDate(); | ||
| 249 | $entrees[$id][] = $Presta->getTypePresta(); | 244 | $entrees[$id][] = $Presta->getTypePresta(); |
| 250 | $entrees[$id][] = $Presta->getCodePresta(); | 245 | $entrees[$id][] = $Presta->getCodePresta(); |
| 251 | } | 246 | } |
