summaryrefslogtreecommitdiff
path: root/src/model/Locations.php
blob: ead2727e866aa41ea167a53be9615c3681a64dd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
// src/model/Locations.php

class Locations extends Model
{
    // lecture des données ou hydratation
    protected $ID;
    protected $ID_presta;
    protected $designation;
    protected $modele_description;
    protected $valeur;
    protected $etat_des_lieux_debut;
    protected $etat_des_lieux_fin;
    protected $duree_location;
    protected $loyer_mensuel;
    protected $loyers_payes;
    protected $caution;
    
    public function __construct()
    {
        $this->table = strtolower(__CLASS__); // locations
    }
    
    public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this)
    {
        return [
            "Désignation:" => $this->designation,
            "Description du modèle:" => $this->modele_description,
            "Valeur:" => $this->valeur,
            "État des lieux de début:" => $this->etat_des_lieux_debut,
            "État des lieux de fin:" => $this->etat_des_lieux_fin,
            "Durée de la location:" => $this->duree_location,
            "Loyer Mensuel:" => $this->loyer_mensuel,
            "Loyers Payés:" => $this->loyers_payes,
            "Caution:" => $this->caution];
    }
    public function set(string $entry, string $input)
    {
        switch($entry)
        {
			case "Désignation:":
                $this->setDesignation($input);
                break;
			case "Description du modèle:":
                $this->setModeleDescription($input);
                break;
			case "Valeur:":
                $this->setValeur($input);
                break;
			case "État des lieux de début:":
                $this->setEtatDesLieuxDebut($input);
                break;
			case "État des lieux de fin:":
                $this->setEtatDesLieuxFin($input);
                break;
			case "Durée de la location:":
                $this->setDureeLocation($input);
                break;
			case "Loyer Mensuel:":
                $this->setLoyerMensuel($input);
                break;
            case "Loyers Payés:":
                $this->setLoyersPayes($input);
                break;
            case "Caution:":
                $this->setCaution($input);
                break;
            }
    }
    
    // setters
    public function setIDPresta(int $value)
    {
        $this->ID_presta = $value;
        return($this);
    }
    public function setDesignation(string $value)
    {
        $this->designation = $value;
        return($this);
    }
    public function setModeleDescription(string $value)
    {
        $this->modele_description = $value;
        return($this);
    }
    public function setValeur($value)
    {
        $value = str_replace(',', '.', $value);
        $this->valeur = (float) $value;
        return($this);
    }
    public function setEtatDesLieuxDebut(string $value)
    {
        $this->etat_des_lieux_debut = $value;
        return($this);
    }
    public function setEtatDesLieuxFin(string $value)
    {
        $this->etat_des_lieux_fin = $value;
        return($this);
    }
    public function setDureeLocation(string $value)
    {
        $this->duree_location = $value;
        return($this);
    }
    public function setLoyerMensuel($value)
    {
        $value = str_replace(',', '.', $value);
        $this->loyer_mensuel = (float) $value;
        return($this);
    }
    public function setLoyersPayes($value)
    {
        $value = str_replace(',', '.', $value);
        $this->loyers_payes = (float) $value;
        return($this);
    }
    public function setCaution($value)
    {
        $value = str_replace(',', '.', $value);
        $this->caution = (float) $value;
        return($this);
    }
}