ID_client = $ID_client; $this->table = strtolower(__CLASS__); // prestations } // getters public function getID(): int { return $this->ID; } public function getIDClient(): int { return $this->ID_client; } public function getIDsByIdClient() // obtenir une entrée avec son ID_client { $IDs = $this->execQuery('SELECT id FROM ' . $this->table . ' WHERE id_client = ' . $this->ID_client)->fetchAll(); // changer le tableau de tableaux en tableau simple for($i = 0; $i < count($IDs); $i++) { $IDs[$i] = $IDs[$i]['ID']; } return($IDs); } public function getCodePresta(): string { return $this->code_presta; } public function getDate(): int // timestamp unix { return $this->date; } public function getTypePresta(): string { return $this->type_presta; } 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), // dernière case "Date:" => $Date->getDate(), "Type de Presta:" => $this->type_presta, "Mode de paiement:" => $this->mode_paiement, "Commentaires:" => $this->commentaires]; } // setters //~ public function setID() -> dans le trait ModelChildren public function setIDClient(int $value) { $this->ID_client = $value; return $this; } //~ public function setCombientiemeFois(int $value) //~ { //~ $this->combientieme_fois = $value; //~ return($this); //~ } public function setCodePresta(string $value) { $this->code_presta = $value; return $this; } public function setDate(int $value) { $this->date = $value; return $this; } public function setTypePresta(string $value) { $this->type_presta = $value; return $this; } public function setModePaiement(string $value) { $this->mode_paiement = $value; return $this; } public function setCommentaires(string $value) { $this->commentaires = $value; return $this; } // code client = année-mois-jour-codeclient-typedepresta-combientièmefois public function makeCodePresta(Dates $Date, string $code_client) { // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) // inconvénient: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer $combientieme_fois = count($this->find(['ID_client' => $this->ID_client])) + 1; $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->type_presta, $combientieme_fois]; $this->code_presta = implode('-', $array_code); } }