summaryrefslogtreecommitdiff
path: root/src/model/CESU.php
blob: 8bea94df32d13dec977a1af90acb5517226311a7 (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
<?php
// src/model/CESU.php

class CESU extends Model
{
    //~ const TABLE = 'cesu';
    
    // lecture des données ou hydratation
    protected $ID;
    protected $ID_presta;
    protected $taches;
    protected $duree_travail;
    protected $salaire;
    
    public function __construct()
    {
        $this->table = strtolower(__CLASS__); // cesu
    }
    
    public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this)
    {
        return [
            "Tâche effectuée:" => $this->taches,
            "Durée du travail:" => $this->duree_travail,
            "Salaire:" => $this->salaire];
    }
    public function set(string $entry, string $input)
    {
        $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide
        switch($entry)
        {
			case "Tâche effectuée:":
                $this->setTaches($input);
                break;
			case "Durée du travail:":
                $this->setDureeTravail($input);
                break;
			case "Salaire:":
                $this->setSalaire($input);
                break;
            }
    }
    
    // setters
    public function setIDPresta(int $value)
    {
        $this->ID_presta = $value;
        return($this);
    }
    public function setTaches(string $value)
    {
        $this->taches = $value;
        return($this);
    }
    public function setDureeTravail(string $value)
    {
        $this->duree_travail = $value;
        return($this);
    }
    public function setSalaire($value)
    {
        $value = str_replace(',', '.', $value);
        $this->salaire = (float) $value;
        return($this);
    }
}