diff options
Diffstat (limited to 'src/model/Prestations.php')
-rw-r--r-- | src/model/Prestations.php | 73 |
1 files changed, 31 insertions, 42 deletions
diff --git a/src/model/Prestations.php b/src/model/Prestations.php index cbe8e6c..2f84daa 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php | |||
@@ -4,66 +4,59 @@ | |||
4 | class Prestations extends Model | 4 | class Prestations extends Model |
5 | { | 5 | { |
6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
7 | protected $ID_presta; // auto-incrémentée | 7 | protected $ID; // auto-incrémentée |
8 | protected $ID_client = 0; | 8 | protected $ID_client = 0; |
9 | protected $combientieme_fois = 0; | 9 | //~ protected $combientieme_fois = 0; |
10 | protected $code_presta = ''; | 10 | protected $code_presta = ''; |
11 | protected $date = 0; // timestamp unix | 11 | protected $date = 0; // timestamp unix |
12 | protected $type_presta = ''; | 12 | protected $type_presta = ''; |
13 | protected $mode_paiement = ''; | 13 | protected $mode_paiement = ''; |
14 | protected $commentaires = ''; | 14 | protected $commentaires = ''; |
15 | 15 | ||
16 | //~ use ModelChildren; | 16 | use ModelChildren; |
17 | 17 | ||
18 | public function __construct(int $ID_client) | 18 | public function __construct(int $ID_client) |
19 | { | 19 | { |
20 | $this->table = 'prestations'; | 20 | $this->table = 'prestations'; |
21 | $this->ID_client = $ID_client; | 21 | $this->ID_client = $ID_client; |
22 | $this->combientiemeFois(); | 22 | //~ $this->combientiemeFois(); |
23 | } | 23 | } |
24 | 24 | ||
25 | // getters | 25 | // getters |
26 | public function getIDPresta(): int | 26 | public function getID(): int |
27 | { | 27 | { |
28 | return $this->ID_presta; | 28 | return $this->ID; |
29 | } | 29 | } |
30 | public function getIDClient(): int | 30 | public function getIDClient(): int |
31 | { | 31 | { |
32 | return $this->ID_client; | 32 | return $this->ID_client; |
33 | } | 33 | } |
34 | public function getCombientiemeFois(): int | 34 | //~ public function getCombientiemeFois(): int |
35 | { | 35 | //~ { |
36 | return $this->combientieme_fois; | 36 | //~ return $this->combientieme_fois; |
37 | } | 37 | //~ } |
38 | public function getDate(): int | 38 | public function getDate(): int |
39 | { | 39 | { |
40 | return $this->date; | 40 | return $this->date; |
41 | } | 41 | } |
42 | 42 | public function getTypePresta(): string | |
43 | // setters | ||
44 | public function setIDPresta(int $value = 0) | ||
45 | { | 43 | { |
46 | if($value === 0) | 44 | return $this->type_presta; |
47 | { | ||
48 | $this->ID_presta = $this->db->lastInsertId(); // méthode de PDO | ||
49 | } | ||
50 | else | ||
51 | { | ||
52 | $this->ID_presta = $value; | ||
53 | } | ||
54 | return($this); | ||
55 | } | 45 | } |
46 | |||
47 | // setters | ||
48 | //~ public function setID() -> dans le trait ModelChildren | ||
56 | 49 | ||
57 | public function setIDClient(int $value) | 50 | public function setIDClient(int $value) |
58 | { | 51 | { |
59 | $this->ID_client = $value; | 52 | $this->ID_client = $value; |
60 | return($this); | 53 | return($this); |
61 | } | 54 | } |
62 | public function setCombientiemeFois(int $value) | 55 | //~ public function setCombientiemeFois(int $value) |
63 | { | 56 | //~ { |
64 | $this->combientieme_fois = $value; | 57 | //~ $this->combientieme_fois = $value; |
65 | return($this); | 58 | //~ return($this); |
66 | } | 59 | //~ } |
67 | public function setCodePresta(string $value) | 60 | public function setCodePresta(string $value) |
68 | { | 61 | { |
69 | $this->code_presta = $value; | 62 | $this->code_presta = $value; |
@@ -90,25 +83,21 @@ class Prestations extends Model | |||
90 | return($this); | 83 | return($this); |
91 | } | 84 | } |
92 | 85 | ||
93 | protected function combientiemeFois() | 86 | //~ protected function combientiemeFois() |
94 | { | 87 | //~ { |
95 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) | 88 | //~ // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) |
96 | $array = $this->find(['ID_client' => $this->ID_client]); | 89 | //~ $array = $this->find(['ID_client' => $this->ID_client]); |
97 | $this->combientieme_fois = count($array) + 1; | 90 | //~ //$this->combientieme_fois = count($array) + 1; |
98 | } | 91 | //~ return count($array) + 1; |
92 | //~ } | ||
99 | 93 | ||
100 | // code client = année-mois-jour-codeclient-combientièmefois | 94 | // code client = année-mois-jour-codeclient-combientièmefois |
101 | public function makeCodePresta(Dates $Date, string $code_client) | 95 | public function makeCodePresta(Dates $Date, string $code_client) |
102 | { | 96 | { |
103 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->combientieme_fois]; | 97 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) |
98 | $combientieme_fois = count($this->find(['ID_client' => $this->ID_client])) + 1; | ||
99 | |||
100 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $combientieme_fois]; | ||
104 | $this->code_presta = implode('-', $array_code); | 101 | $this->code_presta = implode('-', $array_code); |
105 | } | 102 | } |
106 | |||
107 | //~ public function newRow(array $input) | ||
108 | //~ { | ||
109 | //~ $this->hydrate(['ID_client' => $input[0], 'code_presta' => $input[1], 'date' => $input[2], 'type_presta' => $input[3], 'mode_paiement' => $input[4], 'commentaires' => $input[5]]); | ||
110 | //~ $this->create(); | ||
111 | //~ // ID obtenu par auto-incrémentation | ||
112 | //~ $this->ID_presta = $this->db->lastInsertId(); // méthode de PDO | ||
113 | //~ } | ||
114 | } | 103 | } |