diff options
Diffstat (limited to 'src/model/Prestations.php')
| -rw-r--r-- | src/model/Prestations.php | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/src/model/Prestations.php b/src/model/Prestations.php index fe09133..e9ba7a1 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php | |||
| @@ -11,6 +11,7 @@ class Prestations extends Model | |||
| 11 | protected $type_presta = ''; | 11 | protected $type_presta = ''; |
| 12 | protected $mode_paiement = ''; | 12 | protected $mode_paiement = ''; |
| 13 | protected $commentaires = ''; | 13 | protected $commentaires = ''; |
| 14 | //protected $numero_presta = 0; | ||
| 14 | 15 | ||
| 15 | public function __construct(int $ID_client) | 16 | public function __construct(int $ID_client) |
| 16 | { | 17 | { |
| @@ -57,14 +58,33 @@ class Prestations extends Model | |||
| 57 | return [ | 58 | return [ |
| 58 | "Numéro prestation:" => end($code_presta_tableau), // dernière case | 59 | "Numéro prestation:" => end($code_presta_tableau), // dernière case |
| 59 | "Date:" => $Date->getDate(), | 60 | "Date:" => $Date->getDate(), |
| 60 | "Type de Presta:" => $this->type_presta, | 61 | //"Type de Presta:" => $this->type_presta, // choix impossible pour le moment |
| 61 | "Mode de paiement:" => $this->mode_paiement, | 62 | "Mode de paiement:" => $this->mode_paiement, |
| 62 | "Commentaires:" => $this->commentaires]; | 63 | "Commentaires:" => $this->commentaires]; |
| 63 | } | 64 | } |
| 65 | public function set(string $entry, string $input) | ||
| 66 | { | ||
| 67 | switch($entry) | ||
| 68 | { | ||
| 69 | case "Numéro prestation:": | ||
| 70 | $this->setNumeroPresta($input); | ||
| 71 | break; | ||
| 72 | //~ case "Date:": // inutile, setDate() est appelé directement après choix fenêtre calendrier | ||
| 73 | //~ $this->setDate($input); | ||
| 74 | //~ break; | ||
| 75 | //~ case "Type de Presta:": // choix impossible pour le moment | ||
| 76 | //~ $this->setTypePresta($input); | ||
| 77 | //~ break; | ||
| 78 | case "Mode de paiement:": | ||
| 79 | $this->setModePaiement($input); | ||
| 80 | break; | ||
| 81 | case "Commentaires:": | ||
| 82 | $this->setCommentaires($input); | ||
| 83 | break; | ||
| 84 | } | ||
| 85 | } | ||
| 64 | 86 | ||
| 65 | // setters | 87 | // setters |
| 66 | //~ public function setID() -> dans le trait ModelChildren | ||
| 67 | |||
| 68 | public function setIDClient(int $value) | 88 | public function setIDClient(int $value) |
| 69 | { | 89 | { |
| 70 | $this->ID_client = $value; | 90 | $this->ID_client = $value; |
| @@ -80,9 +100,20 @@ class Prestations extends Model | |||
| 80 | $this->code_presta = $value; | 100 | $this->code_presta = $value; |
| 81 | return $this; | 101 | return $this; |
| 82 | } | 102 | } |
| 83 | public function setDate(int $value) | 103 | public function setDate($value, bool $set_code_presta = false) // attend un timestamp |
| 84 | { | 104 | { |
| 85 | $this->date = $value; | 105 | $this->date = (int) $value; |
| 106 | |||
| 107 | if($set_code_presta) | ||
| 108 | { | ||
| 109 | $code_presta_tableau = explode('-', $this->code_presta); | ||
| 110 | $Date = new Dates($value); | ||
| 111 | $code_presta_tableau[0] = $Date->getYear(); | ||
| 112 | $code_presta_tableau[1] = $Date->getMonth(); | ||
| 113 | $code_presta_tableau[2] = $Date->getDay(); | ||
| 114 | $this->code_presta = implode('-', $code_presta_tableau); | ||
| 115 | } | ||
| 116 | |||
| 86 | return $this; | 117 | return $this; |
| 87 | } | 118 | } |
| 88 | public function setTypePresta(string $value) | 119 | public function setTypePresta(string $value) |
| @@ -100,6 +131,14 @@ class Prestations extends Model | |||
| 100 | $this->commentaires = $value; | 131 | $this->commentaires = $value; |
| 101 | return $this; | 132 | return $this; |
| 102 | } | 133 | } |
| 134 | public function setNumeroPresta($value) | ||
| 135 | { | ||
| 136 | // modifier le code presta, on pourrait aussi utiliser une regex | ||
| 137 | $code_presta_tableau = explode('-', $this->code_presta); | ||
| 138 | $code_presta_tableau[count($code_presta_tableau) - 1] = (int) $value; | ||
| 139 | $this->code_presta = implode('-', $code_presta_tableau); | ||
| 140 | return $this; | ||
| 141 | } | ||
| 103 | 142 | ||
| 104 | // code client = année-mois-jour-codeclient-typedepresta-combientièmefois | 143 | // code client = année-mois-jour-codeclient-typedepresta-combientièmefois |
| 105 | public function makeCodePresta(Dates $Date, string $code_client) | 144 | public function makeCodePresta(Dates $Date, string $code_client) |
| @@ -112,3 +151,8 @@ class Prestations extends Model | |||
| 112 | $this->code_presta = implode('-', $array_code); | 151 | $this->code_presta = implode('-', $array_code); |
| 113 | } | 152 | } |
| 114 | } | 153 | } |
| 154 | |||
| 155 | class CodePresta extends Prestations | ||
| 156 | { | ||
| 157 | protected $numero_presta; | ||
| 158 | } | ||
