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 | |
parent | c4a3f80a6dccdff9b2abff6f159ef8fdd4382787 (diff) | |
download | AppliGestionPHP-9c9cda0ac823863c6760d77984ea2ecaf87c52ab.zip |
renommage complet des ID en id: variables, méthodes, BDD
-rw-r--r-- | src/functions.php | 16 | ||||
-rw-r--r-- | src/main.php | 14 | ||||
-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 | ||||
-rw-r--r-- | src/sections/2_service.php | 12 | ||||
-rw-r--r-- | src/sections/3_modify_data.php | 2 |
11 files changed, 70 insertions, 68 deletions
diff --git a/src/functions.php b/src/functions.php index e7c2e5b..47cea42 100644 --- a/src/functions.php +++ b/src/functions.php | |||
@@ -40,7 +40,7 @@ function enterCustomer($Client): bool | |||
40 | unset($input); | 40 | unset($input); |
41 | 41 | ||
42 | $Client->create(); // écrire dans la base | 42 | $Client->create(); // écrire dans la base |
43 | $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId() | 43 | $Client->setId(); // sans paramètre, exécute un $this->db->lastInsertId() |
44 | 44 | ||
45 | return true; | 45 | return true; |
46 | } | 46 | } |
@@ -76,7 +76,7 @@ function makeObjectClient() | |||
76 | } | 76 | } |
77 | 77 | ||
78 | echo "debug: client sélectionné\n"; | 78 | echo "debug: client sélectionné\n"; |
79 | $Client->setID($input); | 79 | $Client->setId($input); |
80 | $Client->hydrate($Client->findById()); | 80 | $Client->hydrate($Client->findById()); |
81 | 81 | ||
82 | return $Client; | 82 | return $Client; |
@@ -100,18 +100,18 @@ function getServices(Clients $Client, string $type = '') | |||
100 | { | 100 | { |
101 | echo "debug: recherche d'une prestation\n"; | 101 | echo "debug: recherche d'une prestation\n"; |
102 | 102 | ||
103 | // on recherche les ID des prestas dans la table 'prestations' avec 'ID_client' | 103 | // on recherche les ID des prestas dans la table 'prestations' avec 'id_client' |
104 | $Presta = new Prestations($Client->getID()); | 104 | $Presta = new Prestations($Client->getId()); |
105 | $Presta->setTypePresta($type); | 105 | $Presta->setTypePresta($type); |
106 | $IDs = $Presta->getIDsByIdClient(); // comportement différent si le type est connu | 106 | $IDs = $Presta->getIdsByIdClient(); // comportement différent si le type est connu |
107 | unset($Presta); | 107 | unset($Presta); |
108 | 108 | ||
109 | // mettres toutes les données dans un tableau | 109 | // mettres toutes les données dans un tableau |
110 | $PrestaList = []; | 110 | $PrestaList = []; |
111 | foreach($IDs as $id) | 111 | foreach($IDs as $id) |
112 | { | 112 | { |
113 | $PrestaList[$id] = new Prestations($Client->getID()); // renseigne 'ID_client' | 113 | $PrestaList[$id] = new Prestations($Client->getId()); // renseigne 'id_client' |
114 | $PrestaList[$id]->setID($id); // ID de la prestation = clé du tableau | 114 | $PrestaList[$id]->setId($id); // ID de la prestation = clé du tableau |
115 | $PrestaList[$id]->hydrate($PrestaList[$id]->findById()); // données copiés de la table à l'objet | 115 | $PrestaList[$id]->hydrate($PrestaList[$id]->findById()); // données copiés de la table à l'objet |
116 | } | 116 | } |
117 | 117 | ||
@@ -119,7 +119,7 @@ function getServices(Clients $Client, string $type = '') | |||
119 | $entrees = []; | 119 | $entrees = []; |
120 | foreach($PrestaList as $Presta) | 120 | foreach($PrestaList as $Presta) |
121 | { | 121 | { |
122 | $id = $Presta->getID(); | 122 | $id = $Presta->getId(); |
123 | $entrees[$id][] = $id; | 123 | $entrees[$id][] = $id; |
124 | $Date = new Dates((int)$Presta->getDate()); // envoi du timestamp, (int) est là par sécurité | 124 | $Date = new Dates((int)$Presta->getDate()); // envoi du timestamp, (int) est là par sécurité |
125 | $entrees[$id][] = $Date->getDate(); | 125 | $entrees[$id][] = $Date->getDate(); |
diff --git a/src/main.php b/src/main.php index fb2b85e..e90c1d5 100644 --- a/src/main.php +++ b/src/main.php | |||
@@ -2,21 +2,23 @@ | |||
2 | <?php | 2 | <?php |
3 | // src/main.php | 3 | // src/main.php |
4 | 4 | ||
5 | //require('model/File.php'); | 5 | //require('model/File.php'); // utilité d'une classe File? |
6 | require('src/files.php'); | 6 | require('src/files.php'); |
7 | require('src/functions.php'); | 7 | require('src/functions.php'); |
8 | 8 | ||
9 | // configuration du programme par l'utilisateur | 9 | // configuration de l'utilisateur |
10 | require('src/Config.php'); // classe structure de données, lit config.ini et préviens les erreurs (par exemple les / aux chemins manquants) | 10 | require('src/Config.php'); // lit le config.ini et gère certaines erreurs (exemple les / aux chemins manquants) |
11 | Config::readFile('config/config.ini'); | 11 | Config::readFile('config/config.ini'); |
12 | Config::hydrate(); | 12 | Config::hydrate(); |
13 | // et à coder peut-être plus tard | ||
14 | //require('config_window.php'); // configuration user-friendly et assistée avec des messages d'erreur et des indications | ||
15 | |||
16 | // création du dossier data et sous-dossiers | ||
13 | makeFolder(Config::$db_path); | 17 | makeFolder(Config::$db_path); |
14 | makeFolder(Config::$latex_path); | 18 | makeFolder(Config::$latex_path); |
15 | makeFolder(Config::$pdf_path); | 19 | makeFolder(Config::$pdf_path); |
16 | // et à coder peut-être plus tard | ||
17 | //require('config_window.php'); // configuration user-friendly et assistée avec des messages d'erreur et des indications | ||
18 | 20 | ||
19 | // variables diverses, certaines utilisent les variables de config.php | 21 | // variables diverses |
20 | $exec_mode = 'gui'; // les versions pure console (CLI) et serveur web (CGI) de ce programme ne sont pas prévues pour l'instant | 22 | $exec_mode = 'gui'; // les versions pure console (CLI) et serveur web (CGI) de ce programme ne sont pas prévues pour l'instant |
21 | $file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre | 23 | $file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre |
22 | $flyer = Config::$pub_path . Config::$flyer; | 24 | $flyer = Config::$pub_path . Config::$flyer; |
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 |
diff --git a/src/sections/2_service.php b/src/sections/2_service.php index 78e4dd4..3dd620d 100644 --- a/src/sections/2_service.php +++ b/src/sections/2_service.php | |||
@@ -48,7 +48,7 @@ function newService($Client): array // $Client est un Client ou null | |||
48 | return [0, null]; // menu principal | 48 | return [0, null]; // menu principal |
49 | } | 49 | } |
50 | 50 | ||
51 | $Presta = new Prestations($Client->getID()); | 51 | $Presta = new Prestations($Client->getId()); |
52 | $Presta->setDate($Date->getTimestamp()); // un entier pour la BDD | 52 | $Presta->setDate($Date->getTimestamp()); // un entier pour la BDD |
53 | 53 | ||
54 | // formulaire - étape 2/3 | 54 | // formulaire - étape 2/3 |
@@ -67,7 +67,7 @@ function newService($Client): array // $Client est un Client ou null | |||
67 | break; | 67 | break; |
68 | case ZenitySetup::$menu_enregistrement_entrees[2]: // "Facture à partir d'un devis" | 68 | case ZenitySetup::$menu_enregistrement_entrees[2]: // "Facture à partir d'un devis" |
69 | // recherche du devis | 69 | // recherche du devis |
70 | $Quotation = getServices($Client, 'devis'); // rechercher un devis, type 'devis' spécifié pour $Presta->getIDsByIdClient() | 70 | $Quotation = getServices($Client, 'devis'); // rechercher un devis, type 'devis' spécifié pour $Presta->getIdsByIdClient() |
71 | if(!is_object($Quotation) || get_class($Quotation) != 'Prestations' || $Quotation->getTypePresta() != 'devis') | 71 | if(!is_object($Quotation) || get_class($Quotation) != 'Prestations' || $Quotation->getTypePresta() != 'devis') |
72 | { | 72 | { |
73 | echo "debug: annulation sélection client\n"; | 73 | echo "debug: annulation sélection client\n"; |
@@ -124,7 +124,7 @@ function newService($Client): array // $Client est un Client ou null | |||
124 | if($choix_niv2 === ZenitySetup::$menu_enregistrement_entrees[2]) // cas: facture à partir d'un devis | 124 | if($choix_niv2 === ZenitySetup::$menu_enregistrement_entrees[2]) // cas: facture à partir d'un devis |
125 | { | 125 | { |
126 | // devis retrouvé ($Quotation est déjà hydraté) | 126 | // devis retrouvé ($Quotation est déjà hydraté) |
127 | $QuotationDetails->setIDPresta($Quotation->getID()); | 127 | $QuotationDetails->setIdPresta($Quotation->getId()); |
128 | $QuotationDetails->hydrate($QuotationDetails->getDetailsByIdPresta()); | 128 | $QuotationDetails->hydrate($QuotationDetails->getDetailsByIdPresta()); |
129 | 129 | ||
130 | // facture avec le devis | 130 | // facture avec le devis |
@@ -148,13 +148,13 @@ function newService($Client): array // $Client est un Client ou null | |||
148 | 148 | ||
149 | // mise à jour base de données | 149 | // mise à jour base de données |
150 | $Presta->create(); | 150 | $Presta->create(); |
151 | $Presta->setID(); // sans paramètre, exécute un $this->db->lastInsertId() | 151 | $Presta->setId(); // sans paramètre, exécute un $this->db->lastInsertId() |
152 | 152 | ||
153 | if(isset($PrestaDetails)) // presta vendue | 153 | if(isset($PrestaDetails)) // presta vendue |
154 | { | 154 | { |
155 | $PrestaDetails->setIDPresta($Presta->getID()); // d'un objet à l'autre | 155 | $PrestaDetails->setIdPresta($Presta->getId()); // d'un objet à l'autre |
156 | $PrestaDetails->create(); | 156 | $PrestaDetails->create(); |
157 | $PrestaDetails->setID(); // sans paramètre, exécute un $this->db->lastInsertId() | 157 | $PrestaDetails->setId(); // sans paramètre, exécute un $this->db->lastInsertId() |
158 | } | 158 | } |
159 | 159 | ||
160 | // si encore de type prospect, devient un type client | 160 | // si encore de type prospect, devient un type client |
diff --git a/src/sections/3_modify_data.php b/src/sections/3_modify_data.php index 279310b..c2f683a 100644 --- a/src/sections/3_modify_data.php +++ b/src/sections/3_modify_data.php | |||
@@ -114,7 +114,7 @@ function modifyData($Client): array | |||
114 | } | 114 | } |
115 | if($type != 'non_vendue') | 115 | if($type != 'non_vendue') |
116 | { | 116 | { |
117 | $PrestaDetails->setIDPresta($Presta->getID()); | 117 | $PrestaDetails->setIdPresta($Presta->getId()); |
118 | $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); | 118 | $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); |
119 | } | 119 | } |
120 | 120 | ||