diff options
author | polo <ordipolo@gmx.fr> | 2024-07-16 05:04:13 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2024-07-16 05:04:13 +0200 |
commit | 9c9cda0ac823863c6760d77984ea2ecaf87c52ab (patch) | |
tree | fc00fd9fbd71bf2b62bca5fe5627f2a9e816870d /src/model | |
parent | c4a3f80a6dccdff9b2abff6f159ef8fdd4382787 (diff) | |
download | AppliGestionPHP-9c9cda0ac823863c6760d77984ea2ecaf87c52ab.zip |
renommage complet des ID en id: variables, méthodes, BDD
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/CESU.php | 8 | ||||
-rw-r--r-- | src/model/Clients.php | 8 | ||||
-rw-r--r-- | src/model/DevisFactures.php | 12 | ||||
-rw-r--r-- | src/model/Locations.php | 8 | ||||
-rw-r--r-- | src/model/Model.php | 18 | ||||
-rw-r--r-- | src/model/Prestations.php | 28 | ||||
-rw-r--r-- | src/model/StructTablesDB.php | 12 |
7 files changed, 47 insertions, 47 deletions
diff --git a/src/model/CESU.php b/src/model/CESU.php index 8bea94d..2768b8f 100644 --- a/src/model/CESU.php +++ b/src/model/CESU.php | |||
@@ -6,8 +6,8 @@ class CESU extends Model | |||
6 | //~ const TABLE = 'cesu'; | 6 | //~ const TABLE = 'cesu'; |
7 | 7 | ||
8 | // lecture des données ou hydratation | 8 | // lecture des données ou hydratation |
9 | protected $ID; | 9 | protected $id; |
10 | protected $ID_presta; | 10 | protected $id_presta; |
11 | protected $taches; | 11 | protected $taches; |
12 | protected $duree_travail; | 12 | protected $duree_travail; |
13 | protected $salaire; | 13 | protected $salaire; |
@@ -42,9 +42,9 @@ class CESU extends Model | |||
42 | } | 42 | } |
43 | 43 | ||
44 | // setters | 44 | // setters |
45 | public function setIDPresta(int $value) | 45 | public function setIdPresta(int $value) |
46 | { | 46 | { |
47 | $this->ID_presta = $value; | 47 | $this->id_presta = $value; |
48 | return($this); | 48 | return($this); |
49 | } | 49 | } |
50 | public function setTaches(string $value) | 50 | public function setTaches(string $value) |
diff --git a/src/model/Clients.php b/src/model/Clients.php index ce38d86..32cf0c5 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php | |||
@@ -4,7 +4,7 @@ | |||
4 | class Clients extends Model | 4 | class Clients extends Model |
5 | { | 5 | { |
6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
7 | protected $ID; // auto-incrémentée | 7 | protected $id; // auto-incrémentée |
8 | protected $prenom_nom; | 8 | protected $prenom_nom; |
9 | protected $code_client; | 9 | protected $code_client; |
10 | protected $adresse; | 10 | protected $adresse; |
@@ -21,9 +21,9 @@ class Clients extends Model | |||
21 | } | 21 | } |
22 | 22 | ||
23 | // getters | 23 | // getters |
24 | public function getID(): int | 24 | public function getId(): int |
25 | { | 25 | { |
26 | return $this->ID; | 26 | return $this->id; |
27 | } | 27 | } |
28 | public function getCodeClient(): string | 28 | public function getCodeClient(): string |
29 | { | 29 | { |
@@ -152,7 +152,7 @@ class Clients extends Model | |||
152 | $already_exist = false; | 152 | $already_exist = false; |
153 | for($j = 0; $j < count($result); $j++) // pour chaque tableau déjà enregistré dans le tableau $result | 153 | for($j = 0; $j < count($result); $j++) // pour chaque tableau déjà enregistré dans le tableau $result |
154 | { | 154 | { |
155 | if($result[$j]['ID'] === $one_array['ID']) | 155 | if($result[$j]['id'] === $one_array['id']) |
156 | { | 156 | { |
157 | $already_exist = true; | 157 | $already_exist = true; |
158 | } | 158 | } |
diff --git a/src/model/DevisFactures.php b/src/model/DevisFactures.php index 967067f..06a0a59 100644 --- a/src/model/DevisFactures.php +++ b/src/model/DevisFactures.php | |||
@@ -6,8 +6,8 @@ class DevisFactures extends Model | |||
6 | //~ public $type = ''; // deux tables séparées devis ou factures | 6 | //~ public $type = ''; // deux tables séparées devis ou factures |
7 | 7 | ||
8 | // lecture des données ou hydratation | 8 | // lecture des données ou hydratation |
9 | protected $ID; // auto-incrémentée | 9 | protected $id; // auto-incrémentée |
10 | protected $ID_presta; | 10 | protected $id_presta; |
11 | protected $taches; | 11 | protected $taches; |
12 | protected $machine; | 12 | protected $machine; |
13 | protected $OS; | 13 | protected $OS; |
@@ -114,14 +114,14 @@ class DevisFactures extends Model | |||
114 | } | 114 | } |
115 | 115 | ||
116 | // setters | 116 | // setters |
117 | //~ public function setID(int $value = 0) | 117 | //~ public function setId(int $value = 0) |
118 | //~ { | 118 | //~ { |
119 | //~ $this->ID = $value; | 119 | //~ $this->id = $value; |
120 | //~ return($this); | 120 | //~ return($this); |
121 | //~ } | 121 | //~ } |
122 | public function setIDPresta(int $value) | 122 | public function setIdPresta(int $value) |
123 | { | 123 | { |
124 | $this->ID_presta = $value; | 124 | $this->id_presta = $value; |
125 | return($this); | 125 | return($this); |
126 | } | 126 | } |
127 | public function setTaches(string $value) | 127 | public function setTaches(string $value) |
diff --git a/src/model/Locations.php b/src/model/Locations.php index 103cecd..c6b8deb 100644 --- a/src/model/Locations.php +++ b/src/model/Locations.php | |||
@@ -4,8 +4,8 @@ | |||
4 | class Locations extends Model | 4 | class Locations extends Model |
5 | { | 5 | { |
6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
7 | protected $ID; | 7 | protected $id; |
8 | protected $ID_presta; | 8 | protected $id_presta; |
9 | protected $designation; | 9 | protected $designation; |
10 | protected $modele_description; | 10 | protected $modele_description; |
11 | protected $valeur; | 11 | protected $valeur; |
@@ -70,9 +70,9 @@ class Locations extends Model | |||
70 | } | 70 | } |
71 | 71 | ||
72 | // setters | 72 | // setters |
73 | public function setIDPresta(int $value) | 73 | public function setIdPresta(int $value) |
74 | { | 74 | { |
75 | $this->ID_presta = $value; | 75 | $this->id_presta = $value; |
76 | return($this); | 76 | return($this); |
77 | } | 77 | } |
78 | public function setDesignation(string $value) | 78 | public function setDesignation(string $value) |
diff --git a/src/model/Model.php b/src/model/Model.php index 9ada9a4..b3d157d 100644 --- a/src/model/Model.php +++ b/src/model/Model.php | |||
@@ -21,15 +21,15 @@ abstract class Model extends DB | |||
21 | } | 21 | } |
22 | 22 | ||
23 | // setters | 23 | // setters |
24 | public function setID(int $value = 0) | 24 | public function setId(int $value = 0) |
25 | { | 25 | { |
26 | if($value === 0) | 26 | if($value === 0) |
27 | { | 27 | { |
28 | $this->ID = $this->db->lastInsertId(); // méthode de PDO, attention lastInsertId() ne gère pas la concurence | 28 | $this->id = $this->db->lastInsertId(); // méthode de PDO, attention lastInsertId() ne gère pas la concurence |
29 | } | 29 | } |
30 | else | 30 | else |
31 | { | 31 | { |
32 | $this->ID = $value; | 32 | $this->id = $value; |
33 | } | 33 | } |
34 | return $this; | 34 | return $this; |
35 | } | 35 | } |
@@ -202,7 +202,7 @@ abstract class Model extends DB | |||
202 | 202 | ||
203 | public function findById() // obtenir une entrée grace à son ID | 203 | public function findById() // obtenir une entrée grace à son ID |
204 | { | 204 | { |
205 | return($this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id = ' . $this->ID)->fetch()); | 205 | return($this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id = ' . $this->id)->fetch()); |
206 | } | 206 | } |
207 | public function getDetailsByIdPresta() | 207 | public function getDetailsByIdPresta() |
208 | { | 208 | { |
@@ -214,7 +214,7 @@ abstract class Model extends DB | |||
214 | } | 214 | } |
215 | else | 215 | else |
216 | { | 216 | { |
217 | return $this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id_Presta = ' . $this->ID_presta)->fetch(); // type array | 217 | return $this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id_Presta = ' . $this->id_presta)->fetch(); // type array |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
@@ -223,13 +223,13 @@ abstract class Model extends DB | |||
223 | $fields = []; | 223 | $fields = []; |
224 | $values = []; | 224 | $values = []; |
225 | 225 | ||
226 | // change "'ID' => 2" en "'ID' = ?" et "2" | 226 | // change "'id' => 2" en "'id' = ?" et "2" |
227 | foreach($criteria as $field => $value) | 227 | foreach($criteria as $field => $value) |
228 | { | 228 | { |
229 | $fields[] = "$field = ?"; // même chose que: $field . " = ?" | 229 | $fields[] = "$field = ?"; // même chose que: $field . " = ?" |
230 | $values[] = $value; | 230 | $values[] = $value; |
231 | } | 231 | } |
232 | $field_list = implode(' AND ', $fields); // créer une chaîne reliant les morceaux avec le morceau AND en paramètre: 'adresse = ? AND ID = ?' | 232 | $field_list = implode(' AND ', $fields); // créer une chaîne reliant les morceaux avec le morceau AND en paramètre: 'adresse = ? AND id = ?' |
233 | 233 | ||
234 | // SELECT * FROM annonces WHERE actif = 1; | 234 | // SELECT * FROM annonces WHERE actif = 1; |
235 | return($this->execQuery('SELECT * FROM ' . $this->table . ' WHERE ' . $field_list, $values)->fetchAll()); | 235 | return($this->execQuery('SELECT * FROM ' . $this->table . ' WHERE ' . $field_list, $values)->fetchAll()); |
@@ -252,7 +252,7 @@ abstract class Model extends DB | |||
252 | $values[] = $value; | 252 | $values[] = $value; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | $values[] = $this->ID; // cette syntaxe ajoute une valeur au tableau | 255 | $values[] = $this->id; // cette syntaxe ajoute une valeur au tableau |
256 | $field_list = implode(', ', $fields); | 256 | $field_list = implode(', ', $fields); |
257 | 257 | ||
258 | // UPDATE annonces SET titre = ?, description = ?, actif = ? WHERE id = ? | 258 | // UPDATE annonces SET titre = ?, description = ?, actif = ? WHERE id = ? |
@@ -261,7 +261,7 @@ abstract class Model extends DB | |||
261 | 261 | ||
262 | public function updateOneValue(string $field, $value) | 262 | public function updateOneValue(string $field, $value) |
263 | { | 263 | { |
264 | return($this->execQuery('UPDATE ' . $this->table . ' SET ' . $field . ' = ? WHERE id = ?', [$value, $this->ID])); | 264 | return($this->execQuery('UPDATE ' . $this->table . ' SET ' . $field . ' = ? WHERE id = ?', [$value, $this->id])); |
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
diff --git a/src/model/Prestations.php b/src/model/Prestations.php index 1666018..3a415be 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php | |||
@@ -4,8 +4,8 @@ | |||
4 | class Prestations extends Model | 4 | class Prestations extends Model |
5 | { | 5 | { |
6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
7 | protected $ID; // auto-incrémentée | 7 | protected $id; // auto-incrémentée |
8 | protected $ID_client = 0; | 8 | protected $id_client = 0; |
9 | protected $code_presta = ''; | 9 | protected $code_presta = ''; |
10 | protected $date = 0; // timestamp unix | 10 | protected $date = 0; // timestamp unix |
11 | protected $type_presta = ''; | 11 | protected $type_presta = ''; |
@@ -13,24 +13,24 @@ class Prestations extends Model | |||
13 | protected $commentaires = ''; | 13 | protected $commentaires = ''; |
14 | //protected $numero_presta = 0; | 14 | //protected $numero_presta = 0; |
15 | 15 | ||
16 | public function __construct(int $ID_client) | 16 | public function __construct(int $id_client) |
17 | { | 17 | { |
18 | $this->ID_client = $ID_client; | 18 | $this->id_client = $id_client; |
19 | $this->table = strtolower(__CLASS__); // prestations | 19 | $this->table = strtolower(__CLASS__); // prestations |
20 | } | 20 | } |
21 | 21 | ||
22 | // getters | 22 | // getters |
23 | public function getID(): int | 23 | public function getId(): int |
24 | { | 24 | { |
25 | return $this->ID; | 25 | return $this->id; |
26 | } | 26 | } |
27 | public function getIDClient(): int | 27 | public function getIdClient(): int |
28 | { | 28 | { |
29 | return $this->ID_client; | 29 | return $this->id_client; |
30 | } | 30 | } |
31 | public function getIDsByIdClient() // obtenir une entrée avec son ID_client, comportement différent si le type est connu | 31 | public function getIdsByIdClient() // obtenir une entrée avec son id_client, comportement différent si le type est connu |
32 | { | 32 | { |
33 | $sql = 'SELECT id FROM ' . $this->table . ' WHERE id_client = ' . $this->ID_client; | 33 | $sql = 'SELECT id FROM ' . $this->table . ' WHERE id_client = ' . $this->id_client; |
34 | if($this->type_presta != '') | 34 | if($this->type_presta != '') |
35 | { | 35 | { |
36 | $sql .= " AND type_presta = '" . $this->type_presta . "'"; | 36 | $sql .= " AND type_presta = '" . $this->type_presta . "'"; |
@@ -40,7 +40,7 @@ class Prestations extends Model | |||
40 | $IDs = []; // si $IDs reste vide, ne pas être de type NULL | 40 | $IDs = []; // si $IDs reste vide, ne pas être de type NULL |
41 | for($i = 0; $i < count($data); $i++) | 41 | for($i = 0; $i < count($data); $i++) |
42 | { | 42 | { |
43 | $IDs[$i] = $data[$i]['ID']; // tableau simple | 43 | $IDs[$i] = $data[$i]['id']; // tableau simple |
44 | } | 44 | } |
45 | return($IDs); | 45 | return($IDs); |
46 | } | 46 | } |
@@ -92,9 +92,9 @@ class Prestations extends Model | |||
92 | } | 92 | } |
93 | 93 | ||
94 | // setters | 94 | // setters |
95 | public function setIDClient(int $value) | 95 | public function setIdClient(int $value) |
96 | { | 96 | { |
97 | $this->ID_client = $value; | 97 | $this->id_client = $value; |
98 | return $this; | 98 | return $this; |
99 | } | 99 | } |
100 | //~ public function setCombientiemeFois(int $value) | 100 | //~ public function setCombientiemeFois(int $value) |
@@ -152,7 +152,7 @@ class Prestations extends Model | |||
152 | { | 152 | { |
153 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) | 153 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) |
154 | // inconvénient: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer | 154 | // inconvénient: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer |
155 | $combientieme_fois = count($this->find(['ID_client' => $this->ID_client])) + 1; | 155 | $combientieme_fois = count($this->find(['id_client' => $this->id_client])) + 1; |
156 | 156 | ||
157 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->type_presta, $combientieme_fois]; | 157 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->type_presta, $combientieme_fois]; |
158 | $this->code_presta = implode('-', $array_code); | 158 | $this->code_presta = implode('-', $array_code); |
diff --git a/src/model/StructTablesDB.php b/src/model/StructTablesDB.php index 48bf8e5..303af46 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/StructTablesDB.php | |||
@@ -9,12 +9,12 @@ 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', 'type' => 'TEXT DEFAULT prospect'], | 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', 'prix_devis' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT DEFAULT non'], | 14 | 'devis' => ['id' => 'INTEGER', 'id_presta' => 'INTEGER', 'taches' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'prix_devis' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT DEFAULT non'], |
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'], |
16 | 'cesu' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], | 16 | 'cesu' => ['id' => 'INTEGER', 'id_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], |
17 | 'locations' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'designation' => 'TEXT', 'modele_description' => 'TEXT', 'valeur' => 'REAL', 'etat_des_lieux_debut' => 'TEXT', 'etat_des_lieux_fin' => 'TEXT', 'duree_location' => 'TEXT', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] | 17 | 'locations' => ['id' => 'INTEGER', 'id_presta' => 'INTEGER', 'designation' => 'TEXT', 'modele_description' => 'TEXT', 'valeur' => 'REAL', 'etat_des_lieux_debut' => 'TEXT', 'etat_des_lieux_fin' => 'TEXT', 'duree_location' => 'TEXT', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] |
18 | ]; | 18 | ]; |
19 | 19 | ||
20 | // les types de variables de sqlite sont peu nombreux et autorisent un typage automatique | 20 | // les types de variables de sqlite sont peu nombreux et autorisent un typage automatique |