table = 'prestations'; $this->ID_client = $ID_client; $this->combientiemeFois(); } // getters public function getIDPresta(): int { return $this->ID_presta; } public function getIDClient(): int { return $this->ID_client; } public function getCombientiemeFois(): int { return $this->combientieme_fois; } public function getDate(): int { return $this->date; } // setters public function setIDPresta(int $value = 0) { if($value === 0) { $this->ID_presta = $this->db->lastInsertId(); // méthode de PDO } else { $this->ID_presta = $value; } return($this); } 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); } protected function combientiemeFois() { // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) $array = $this->find(['ID_client' => $this->ID_client]); $this->combientieme_fois = count($array) + 1; } // code client = année-mois-jour-codeclient-combientièmefois public function makeCodePresta(Dates $Date, string $code_client) { $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->combientieme_fois]; $this->code_presta = implode('-', $array_code); } //~ public function newRow(array $input) //~ { //~ $this->hydrate(['ID_client' => $input[0], 'code_presta' => $input[1], 'date' => $input[2], 'type_presta' => $input[3], 'mode_paiement' => $input[4], 'commentaires' => $input[5]]); //~ $this->create(); //~ // ID obtenu par auto-incrémentation //~ $this->ID_presta = $this->db->lastInsertId(); // méthode de PDO //~ } }