diff options
Diffstat (limited to 'src/model/version 0.1/Locations.php')
-rw-r--r-- | src/model/version 0.1/Locations.php | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/src/model/version 0.1/Locations.php b/src/model/version 0.1/Locations.php new file mode 100644 index 0000000..c6b8deb --- /dev/null +++ b/src/model/version 0.1/Locations.php | |||
@@ -0,0 +1,127 @@ | |||
1 | <?php | ||
2 | // src/model/Locations.php | ||
3 | |||
4 | class Locations extends Model | ||
5 | { | ||
6 | // lecture des données ou hydratation | ||
7 | protected $id; | ||
8 | protected $id_presta; | ||
9 | protected $designation; | ||
10 | protected $modele_description; | ||
11 | protected $valeur; | ||
12 | protected $etat_des_lieux_debut; | ||
13 | protected $etat_des_lieux_fin; | ||
14 | protected $duree_location; | ||
15 | protected $loyer_mensuel; | ||
16 | protected $loyers_payes; | ||
17 | protected $caution; | ||
18 | |||
19 | public function __construct() | ||
20 | { | ||
21 | $this->table = strtolower(__CLASS__); // locations | ||
22 | } | ||
23 | |||
24 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | ||
25 | { | ||
26 | return [ | ||
27 | "Désignation:" => $this->designation, | ||
28 | "Description du modèle:" => $this->modele_description, | ||
29 | "Valeur:" => $this->valeur, | ||
30 | "État des lieux de début:" => $this->etat_des_lieux_debut, | ||
31 | "État des lieux de fin:" => $this->etat_des_lieux_fin, | ||
32 | "Durée de la location:" => $this->duree_location, | ||
33 | "Loyer Mensuel:" => $this->loyer_mensuel, | ||
34 | "Loyers Payés:" => $this->loyers_payes, | ||
35 | "Caution:" => $this->caution]; | ||
36 | } | ||
37 | public function set(string $entry, string $input) | ||
38 | { | ||
39 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide | ||
40 | switch($entry) | ||
41 | { | ||
42 | case "Désignation:": | ||
43 | $this->setDesignation($input); | ||
44 | break; | ||
45 | case "Description du modèle:": | ||
46 | $this->setModeleDescription($input); | ||
47 | break; | ||
48 | case "Valeur:": | ||
49 | $this->setValeur($input); | ||
50 | break; | ||
51 | case "État des lieux de début:": | ||
52 | $this->setEtatDesLieuxDebut($input); | ||
53 | break; | ||
54 | case "État des lieux de fin:": | ||
55 | $this->setEtatDesLieuxFin($input); | ||
56 | break; | ||
57 | case "Durée de la location:": | ||
58 | $this->setDureeLocation($input); | ||
59 | break; | ||
60 | case "Loyer Mensuel:": | ||
61 | $this->setLoyerMensuel($input); | ||
62 | break; | ||
63 | case "Loyers Payés:": | ||
64 | $this->setLoyersPayes($input); | ||
65 | break; | ||
66 | case "Caution:": | ||
67 | $this->setCaution($input); | ||
68 | break; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | // setters | ||
73 | public function setIdPresta(int $value) | ||
74 | { | ||
75 | $this->id_presta = $value; | ||
76 | return($this); | ||
77 | } | ||
78 | public function setDesignation(string $value) | ||
79 | { | ||
80 | $this->designation = $value; | ||
81 | return($this); | ||
82 | } | ||
83 | public function setModeleDescription(string $value) | ||
84 | { | ||
85 | $this->modele_description = $value; | ||
86 | return($this); | ||
87 | } | ||
88 | public function setValeur($value) | ||
89 | { | ||
90 | $value = str_replace(',', '.', $value); | ||
91 | $this->valeur = (float) $value; | ||
92 | return($this); | ||
93 | } | ||
94 | public function setEtatDesLieuxDebut(string $value) | ||
95 | { | ||
96 | $this->etat_des_lieux_debut = $value; | ||
97 | return($this); | ||
98 | } | ||
99 | public function setEtatDesLieuxFin(string $value) | ||
100 | { | ||
101 | $this->etat_des_lieux_fin = $value; | ||
102 | return($this); | ||
103 | } | ||
104 | public function setDureeLocation(string $value) | ||
105 | { | ||
106 | $this->duree_location = $value; | ||
107 | return($this); | ||
108 | } | ||
109 | public function setLoyerMensuel($value) | ||
110 | { | ||
111 | $value = str_replace(',', '.', $value); | ||
112 | $this->loyer_mensuel = (float) $value; | ||
113 | return($this); | ||
114 | } | ||
115 | public function setLoyersPayes($value) | ||
116 | { | ||
117 | $value = str_replace(',', '.', $value); | ||
118 | $this->loyers_payes = (float) $value; | ||
119 | return($this); | ||
120 | } | ||
121 | public function setCaution($value) | ||
122 | { | ||
123 | $value = str_replace(',', '.', $value); | ||
124 | $this->caution = (float) $value; | ||
125 | return($this); | ||
126 | } | ||
127 | } | ||