diff options
| author | polo <ordipolo@gmx.fr> | 2023-07-22 12:29:47 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2023-07-22 12:29:47 +0200 |
| commit | 747674b450d6840ce9bd9aecd765cf31445ef8d3 (patch) | |
| tree | 46e47fd65c751e1951d9aa8438aea1b8c2d8aece /src/model | |
| parent | 9bdfb5196a2ee1cbfc403702e8d2ef88076d366f (diff) | |
| download | AppliGestionPHP-747674b450d6840ce9bd9aecd765cf31445ef8d3.tar.gz AppliGestionPHP-747674b450d6840ce9bd9aecd765cf31445ef8d3.tar.bz2 AppliGestionPHP-747674b450d6840ce9bd9aecd765cf31445ef8d3.zip | |
navigation entre sections, boucle principale, client ou prospect
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/Clients.php | 6 | ||||
| -rw-r--r-- | src/model/Model.php | 13 | ||||
| -rw-r--r-- | src/model/StructTablesDB.php | 2 | ||||
| -rw-r--r-- | src/model/traits.php | 2 |
4 files changed, 17 insertions, 6 deletions
diff --git a/src/model/Clients.php b/src/model/Clients.php index d9dd28d..f36acc1 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php | |||
| @@ -13,6 +13,7 @@ class Clients extends Model | |||
| 13 | protected $telephone; | 13 | protected $telephone; |
| 14 | protected $courriel; | 14 | protected $courriel; |
| 15 | protected $apropos; | 15 | protected $apropos; |
| 16 | protected $type = 'prospect'; | ||
| 16 | 17 | ||
| 17 | //~ use ModelChildren; | 18 | //~ use ModelChildren; |
| 18 | 19 | ||
| @@ -81,6 +82,11 @@ class Clients extends Model | |||
| 81 | $this->apropos = (string) $value; | 82 | $this->apropos = (string) $value; |
| 82 | return $this; | 83 | return $this; |
| 83 | } | 84 | } |
| 85 | public function setType($value) | ||
| 86 | { | ||
| 87 | $this->type = (string) $value; | ||
| 88 | return $this; | ||
| 89 | } | ||
| 84 | 90 | ||
| 85 | 91 | ||
| 86 | public function findByKeywords(array $keywords, string $field): array // n'hydrate pas les variables, on doit choisir un client et hydrater ensuite | 92 | public function findByKeywords(array $keywords, string $field): array // n'hydrate pas les variables, on doit choisir un client et hydrater ensuite |
diff --git a/src/model/Model.php b/src/model/Model.php index 17d1292..3fb3bdf 100644 --- a/src/model/Model.php +++ b/src/model/Model.php | |||
| @@ -43,7 +43,7 @@ abstract class Model extends DB | |||
| 43 | foreach($data as $key => $value) | 43 | foreach($data as $key => $value) |
| 44 | { | 44 | { |
| 45 | // nom du setter | 45 | // nom du setter |
| 46 | // nom_du_champ devient setNomDuChamp | 46 | // nom_propriete => setPropriete |
| 47 | // on sépare les mots par des espaces, ucwords met la première lettre de chaque mot en majuscule, puis on supprime les espaces | 47 | // on sépare les mots par des espaces, ucwords met la première lettre de chaque mot en majuscule, puis on supprime les espaces |
| 48 | $setter_name = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); // ucwords: première lettre de chaque mot en majuscule | 48 | $setter_name = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); // ucwords: première lettre de chaque mot en majuscule |
| 49 | if(method_exists($this, $setter_name)) | 49 | if(method_exists($this, $setter_name)) |
| @@ -207,7 +207,7 @@ abstract class Model extends DB | |||
| 207 | 207 | ||
| 208 | 208 | ||
| 209 | // update UPDATE | 209 | // update UPDATE |
| 210 | public function update(int $id) | 210 | public function update(int $id) // utiliser plutôt $this->ID ? |
| 211 | { | 211 | { |
| 212 | $fields = []; | 212 | $fields = []; |
| 213 | $values = []; | 213 | $values = []; |
| @@ -219,13 +219,18 @@ abstract class Model extends DB | |||
| 219 | $values[] = $value; | 219 | $values[] = $value; |
| 220 | } | 220 | } |
| 221 | } | 221 | } |
| 222 | $values[] = $id; | 222 | $values[] = $id; // cette syntaxe ajoute une valeur au tableau |
| 223 | $field_list = implode(', ', $fields); | 223 | $field_list = implode(', ', $fields); |
| 224 | 224 | ||
| 225 | // UPDATE annonces SET titre = ?, description = ?, actif = ? WHERE id= ? | 225 | // UPDATE annonces SET titre = ?, description = ?, actif = ? WHERE id = ? |
| 226 | return($this->execQuery('UPDATE ' . $this->table . ' SET ' . $field_list . ' WHERE id = ?', $values)); | 226 | return($this->execQuery('UPDATE ' . $this->table . ' SET ' . $field_list . ' WHERE id = ?', $values)); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | public function updateOneValue(string $field, $value) | ||
| 230 | { | ||
| 231 | return($this->execQuery('UPDATE ' . $this->table . ' SET ' . $field . ' = ? WHERE id = ?', [$value, $this->ID])); | ||
| 232 | } | ||
| 233 | |||
| 229 | 234 | ||
| 230 | // delete DELETE | 235 | // delete DELETE |
| 231 | protected function delete(int $id) | 236 | protected function delete(int $id) |
diff --git a/src/model/StructTablesDB.php b/src/model/StructTablesDB.php index 75a4383..769d502 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/StructTablesDB.php | |||
| @@ -9,7 +9,7 @@ class StructTablesDB | |||
| 9 | static public $structureOfTables = [ | 9 | static public $structureOfTables = [ |
| 10 | // la table prestations est liée à la table clients | 10 | // la table prestations est liée à la table clients |
| 11 | // les tables devis_factures, cesu et locations sont liées à la table prestations | 11 | // les tables devis_factures, cesu et locations sont liées à la table prestations |
| 12 | 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'code_postal' => 'TEXT', 'ville' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'apropos' => 'TEXT'], | 12 | 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'code_postal' => 'TEXT', 'ville' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'apropos' => 'TEXT', 'type' => 'TEXT DEFAULT prospect'], |
| 13 | 'prestations' => ['ID' => 'INTEGER', 'ID_client' => 'INTEGER', 'code_presta' => 'TEXT', 'date' => 'INTEGER', 'type_presta' => 'TEXT', 'mode_paiement' => 'TEXT', 'commentaires' => 'TEXT'], | 13 | 'prestations' => ['ID' => 'INTEGER', 'ID_client' => 'INTEGER', 'code_presta' => 'TEXT', 'date' => 'INTEGER', 'type_presta' => 'TEXT', 'mode_paiement' => 'TEXT', 'commentaires' => 'TEXT'], |
| 14 | 'devis' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT'], | 14 | 'devis' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT'], |
| 15 | 'factures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'machine' => 'TEXT', 'OS' => 'TEXT', 'donnees' => 'TEXT', 'cles_licences' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL'], | 15 | 'factures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'machine' => 'TEXT', 'OS' => 'TEXT', 'donnees' => 'TEXT', 'cles_licences' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL'], |
diff --git a/src/model/traits.php b/src/model/traits.php index 03121be..88451d9 100644 --- a/src/model/traits.php +++ b/src/model/traits.php | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/traits.php | 2 | // src/model/traits.php |
| 3 | // | 3 | // |
| 4 | // fonctions à utiliser par les enfants de Model | 4 | // fonctions "partagées" par les enfants de Model |
| 5 | 5 | ||
| 6 | trait ModelChildren | 6 | trait ModelChildren |
| 7 | { | 7 | { |
