diff options
| author | polo <ordipolo@gmx.fr> | 2022-12-28 05:19:55 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2022-12-28 05:19:55 +0100 |
| commit | 1894fc377e6b938ea34df9980567a1634ec6ef48 (patch) | |
| tree | 812db64208797ecbdabbc9673a5247fbc18ebf8b /src/model | |
| parent | 7d564efbccc4b361d2fa2db2902fb35882304aae (diff) | |
| download | AppliGestionPHP-1894fc377e6b938ea34df9980567a1634ec6ef48.tar.gz AppliGestionPHP-1894fc377e6b938ea34df9980567a1634ec6ef48.tar.bz2 AppliGestionPHP-1894fc377e6b938ea34df9980567a1634ec6ef48.zip | |
réorganisation + bientôt finie la section 1
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/CESU.php | 23 | ||||
| -rw-r--r-- | src/model/Clients.php | 56 | ||||
| -rw-r--r-- | src/model/DevisFactures.php | 32 | ||||
| -rw-r--r-- | src/model/Locations.php | 21 | ||||
| -rw-r--r-- | src/model/Model.php | 12 | ||||
| -rw-r--r-- | src/model/Prestations.php | 81 | ||||
| -rw-r--r-- | src/model/StructTablesDB.php | 6 | ||||
| -rw-r--r-- | src/model/traits.php | 18 |
8 files changed, 187 insertions, 62 deletions
diff --git a/src/model/CESU.php b/src/model/CESU.php index 28a54a8..2be89c0 100644 --- a/src/model/CESU.php +++ b/src/model/CESU.php | |||
| @@ -3,28 +3,33 @@ | |||
| 3 | 3 | ||
| 4 | class CESU extends Model | 4 | class CESU extends Model |
| 5 | { | 5 | { |
| 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 | private $ID; | 9 | private $ID_cesu; |
| 10 | private $ID_presta; | ||
| 11 | private $taches; | 10 | private $taches; |
| 12 | private $duree_travail; | 11 | private $duree_travail; |
| 13 | private $salaire; | 12 | private $salaire; |
| 14 | 13 | ||
| 15 | use ModelChildren; | 14 | use ModelChildren; |
| 16 | 15 | ||
| 17 | // setters | 16 | public function __construct(int $client_ID) |
| 18 | public function setID(int $value) | ||
| 19 | { | 17 | { |
| 20 | $this->ID = $value; | 18 | parent::__construct($client_ID); |
| 21 | return($this); | 19 | $this->type == 'cesu'; |
| 22 | } | 20 | } |
| 23 | public function setIDPresta(int $value) | 21 | |
| 22 | // setters | ||
| 23 | public function setIDCesu(int $value) | ||
| 24 | { | 24 | { |
| 25 | $this->ID_presta = $value; | 25 | $this->ID_cesu = $value; |
| 26 | return($this); | 26 | return($this); |
| 27 | } | 27 | } |
| 28 | //~ public function setIDPresta(int $value) | ||
| 29 | //~ { | ||
| 30 | //~ $this->ID_presta = $value; | ||
| 31 | //~ return($this); | ||
| 32 | //~ } | ||
| 28 | public function setTaches(string $value) | 33 | public function setTaches(string $value) |
| 29 | { | 34 | { |
| 30 | $this->taches = $value; | 35 | $this->taches = $value; |
diff --git a/src/model/Clients.php b/src/model/Clients.php index 92a4b31..aeb39c1 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php | |||
| @@ -4,20 +4,37 @@ | |||
| 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 | public $ID; | 7 | protected $ID; // auto-incrémentée |
| 8 | public $prenom_nom; | 8 | protected $prenom_nom = ''; |
| 9 | public $adresse; | 9 | protected $code_client = ''; |
| 10 | public $code_client; | 10 | protected $adresse = ''; |
| 11 | public $commentaires; | 11 | protected $telephone = ''; |
| 12 | protected $courriel = ''; | ||
| 13 | protected $commentaires = ''; | ||
| 12 | 14 | ||
| 13 | use ModelChildren; // renseigne parent::table | 15 | use ModelChildren; // renseigne parent::table |
| 14 | 16 | ||
| 17 | public function __construct() | ||
| 18 | { | ||
| 19 | $this->table = 'clients'; | ||
| 20 | } | ||
| 21 | |||
| 15 | //~ public function set(string $variable, $value) | 22 | //~ public function set(string $variable, $value) |
| 16 | //~ { | 23 | //~ { |
| 17 | //~ $this->$variable = $value; | 24 | //~ $this->$variable = $value; |
| 18 | //~ return($this); | 25 | //~ return($this); |
| 19 | //~ } | 26 | //~ } |
| 20 | 27 | ||
| 28 | // getters | ||
| 29 | public function getID(): int | ||
| 30 | { | ||
| 31 | return $this->ID; | ||
| 32 | } | ||
| 33 | public function getCodeClient(): string | ||
| 34 | { | ||
| 35 | return $this->code_client; | ||
| 36 | } | ||
| 37 | |||
| 21 | // setters | 38 | // setters |
| 22 | public function setID(int $value) // inutile? il s'autoincrémente | 39 | public function setID(int $value) // inutile? il s'autoincrémente |
| 23 | { | 40 | { |
| @@ -29,14 +46,27 @@ class Clients extends Model | |||
| 29 | $this->prenom_nom = $value; | 46 | $this->prenom_nom = $value; |
| 30 | return($this); | 47 | return($this); |
| 31 | } | 48 | } |
| 49 | public function setCode_client(string $value) | ||
| 50 | { | ||
| 51 | $this->code_client = $value; | ||
| 52 | return($this); | ||
| 53 | } | ||
| 32 | public function setAdresse(string $value) | 54 | public function setAdresse(string $value) |
| 33 | { | 55 | { |
| 34 | $this->adresse = $value; | 56 | $this->adresse = $value; |
| 35 | return($this); | 57 | return($this); |
| 36 | } | 58 | } |
| 37 | public function setCode_client(string $value) | 59 | public function setTelephone(string $value) // chaine parce que zenity renvoie une chaine et parce qu'on garde le 0 au début |
| 38 | { | 60 | { |
| 39 | $this->code_client = $value; | 61 | if(is_numeric($value)) |
| 62 | { | ||
| 63 | $this->telephone = $value; | ||
| 64 | } | ||
| 65 | return($this); | ||
| 66 | } | ||
| 67 | public function setCourriel(string $value) | ||
| 68 | { | ||
| 69 | $this->courriel = $value; | ||
| 40 | return($this); | 70 | return($this); |
| 41 | } | 71 | } |
| 42 | public function setCommentaires(string $value) | 72 | public function setCommentaires(string $value) |
| @@ -48,12 +78,18 @@ class Clients extends Model | |||
| 48 | 78 | ||
| 49 | public function newRow(array $input) | 79 | public function newRow(array $input) |
| 50 | { | 80 | { |
| 51 | $this->hydrate(['prenom_nom' => $input[0], 'adresse' => $input[1], 'code_client' => $input[2], 'commentaires' => $input[3]]); | 81 | $this->hydrate(['prenom_nom' => $input[0], 'code_client' => $input[1], 'adresse' => $input[2], 'telephone' => $input[3], 'courriel' => $input[4], 'commentaires' => $input[5]]); |
| 52 | $this->create(); | 82 | $this->create(); |
| 53 | $this->setIdFromLastInsertID(); // dans ModelChildren, n'utilise pas Model::execQuery() | 83 | // ID obtenu par auto-incrémentation |
| 84 | $this->ID = $this->db->lastInsertId(); // méthode de PDO | ||
| 54 | } | 85 | } |
| 86 | //~ public function setIdFromLastInsertID() // à faire juste après l'écriture d'une nouvelle entrée | ||
| 87 | //~ { | ||
| 88 | //~ $this->db = parent::getInstance(); // $db est créée dans Model::execQuery() | ||
| 89 | //~ $this->ID = $this->db->lastInsertId(); // méthode de PDO | ||
| 90 | //~ } | ||
| 55 | 91 | ||
| 56 | public function findByKeywords(array $keywords, string $field): array | 92 | public function findByKeywords(array $keywords, string $field): array // n'hydrate pas les variables, on doit choisir un client et hydrater ensuite |
| 57 | { | 93 | { |
| 58 | $result = []; | 94 | $result = []; |
| 59 | for($i = 0; $i < count($keywords); $i++) | 95 | for($i = 0; $i < count($keywords); $i++) |
diff --git a/src/model/DevisFactures.php b/src/model/DevisFactures.php index 218ebfe..1ed3a5c 100644 --- a/src/model/DevisFactures.php +++ b/src/model/DevisFactures.php | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | class DevisFactures extends Model | 4 | class DevisFactures extends Model |
| 5 | { | 5 | { |
| 6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
| 7 | private $ID; | 7 | private $ID_devis_facture; // auto-incrémentée |
| 8 | private $ID_presta; | 8 | private $ID_presta = 0; |
| 9 | private $validite_devis; | 9 | private $validite_devis; |
| 10 | private $signature_devis; | 10 | private $signature_devis; |
| 11 | private $taches; | 11 | private $taches; |
| @@ -19,12 +19,25 @@ class DevisFactures extends Model | |||
| 19 | private $deplacement; | 19 | private $deplacement; |
| 20 | private $total_HT; | 20 | private $total_HT; |
| 21 | 21 | ||
| 22 | use ModelChildren; | 22 | //~ use ModelChildren; |
| 23 | |||
| 24 | public function __construct(int $ID_presta) | ||
| 25 | { | ||
| 26 | $this->table = 'devisfactures'; | ||
| 27 | $this->ID_presta = $ID_presta; | ||
| 28 | } | ||
| 23 | 29 | ||
| 24 | // setters | 30 | // setters |
| 25 | public function setID(int $value) | 31 | public function setIDDevisFacture(int $value = 0) |
| 26 | { | 32 | { |
| 27 | $this->ID = $value; | 33 | if($value === 0) |
| 34 | { | ||
| 35 | $this->ID_devis_facture = $this->db->lastInsertId(); // méthode de PDO | ||
| 36 | } | ||
| 37 | else | ||
| 38 | { | ||
| 39 | $this->ID_devis_facture = $value; | ||
| 40 | } | ||
| 28 | return($this); | 41 | return($this); |
| 29 | } | 42 | } |
| 30 | public function setIDPresta(int $value) | 43 | public function setIDPresta(int $value) |
| @@ -92,4 +105,13 @@ class DevisFactures extends Model | |||
| 92 | $this->total_HT = $value; | 105 | $this->total_HT = $value; |
| 93 | return($this); | 106 | return($this); |
| 94 | } | 107 | } |
| 108 | |||
| 109 | public function newRow(array $input, array $quotations_input = []) | ||
| 110 | { | ||
| 111 | if(!empty($quotations_input)) // cas d'un devis | ||
| 112 | { | ||
| 113 | $this->hydrate(['validite_devis' => $quotations_input[0], 'signature_devis' => $quotations_input[1]]); | ||
| 114 | } | ||
| 115 | $this->hydrate([]); | ||
| 116 | } | ||
| 95 | } | 117 | } |
diff --git a/src/model/Locations.php b/src/model/Locations.php index b788d43..21e9b09 100644 --- a/src/model/Locations.php +++ b/src/model/Locations.php | |||
| @@ -4,8 +4,7 @@ | |||
| 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 | private $ID; | 7 | private $ID_location; |
| 8 | private $ID_presta; | ||
| 9 | private $nature_bien; | 8 | private $nature_bien; |
| 10 | private $modele; | 9 | private $modele; |
| 11 | private $valeur; | 10 | private $valeur; |
| @@ -17,17 +16,23 @@ class Locations extends Model | |||
| 17 | 16 | ||
| 18 | use ModelChildren; | 17 | use ModelChildren; |
| 19 | 18 | ||
| 20 | // setters | 19 | public function __construct(int $client_ID) |
| 21 | public function setID(int $value) | ||
| 22 | { | 20 | { |
| 23 | $this->ID = $value; | 21 | parent::__construct($client_ID); |
| 24 | return($this); | 22 | $this->type == 'location'; |
| 25 | } | 23 | } |
| 26 | public function setIDPresta(int $value) | 24 | |
| 25 | // setters | ||
| 26 | public function setIDLocation(int $value) | ||
| 27 | { | 27 | { |
| 28 | $this->ID_presta = $value; | 28 | $this->ID_location = $value; |
| 29 | return($this); | 29 | return($this); |
| 30 | } | 30 | } |
| 31 | //~ public function setIDPresta(int $value) | ||
| 32 | //~ { | ||
| 33 | //~ $this->ID_presta = $value; | ||
| 34 | //~ return($this); | ||
| 35 | //~ } | ||
| 31 | public function setNatureBien(string $value) | 36 | public function setNatureBien(string $value) |
| 32 | { | 37 | { |
| 33 | $this->nature_bien = $value; | 38 | $this->nature_bien = $value; |
diff --git a/src/model/Model.php b/src/model/Model.php index 8cbf056..938e3dd 100644 --- a/src/model/Model.php +++ b/src/model/Model.php | |||
| @@ -9,7 +9,8 @@ class Model extends DB | |||
| 9 | 9 | ||
| 10 | public function __construct() | 10 | public function __construct() |
| 11 | { | 11 | { |
| 12 | $this->db = parent::getInstance(); // connexion | 12 | //~ $this->db = parent::getInstance(); // connexion |
| 13 | //~ $this->table = strtolower(__CLASS__); | ||
| 13 | } | 14 | } |
| 14 | 15 | ||
| 15 | // getters | 16 | // getters |
| @@ -26,8 +27,9 @@ class Model extends DB | |||
| 26 | // nom d'un setter, forme "setMachin()" | 27 | // nom d'un setter, forme "setMachin()" |
| 27 | $setterName = 'set' . ucfirst($key); // ucfirst met la première lettre en majuscule | 28 | $setterName = 'set' . ucfirst($key); // ucfirst met la première lettre en majuscule |
| 28 | // détection | 29 | // détection |
| 29 | if(method_exists($this, $setterName)) // on trouve aussi la méthode is_callable() | 30 | if(method_exists($this, $setterName) && $value != NULL) // on trouve aussi la méthode is_callable() |
| 30 | { | 31 | { |
| 32 | //~ var_dump($value); | ||
| 31 | // on renseigne les propriétés des l'instance | 33 | // on renseigne les propriétés des l'instance |
| 32 | $this->$setterName($value); // nom d'une méthode dans une variable | 34 | $this->$setterName($value); // nom d'une méthode dans une variable |
| 33 | } | 35 | } |
| @@ -84,7 +86,7 @@ class Model extends DB | |||
| 84 | 86 | ||
| 85 | 87 | ||
| 86 | // read SELECT | 88 | // read SELECT |
| 87 | public function readAll(): array // obtenir une table | 89 | protected function readAll(): array // obtenir une table |
| 88 | { | 90 | { |
| 89 | return($this->execQuery('SELECT * FROM ' . $this->table)->fetchAll()); // fonctionne aussi sans le point virgule dans le SQL!! | 91 | return($this->execQuery('SELECT * FROM ' . $this->table)->fetchAll()); // fonctionne aussi sans le point virgule dans le SQL!! |
| 90 | } | 92 | } |
| @@ -94,7 +96,7 @@ class Model extends DB | |||
| 94 | return($this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id = ' . $id)->fetch()); | 96 | return($this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id = ' . $id)->fetch()); |
| 95 | } | 97 | } |
| 96 | 98 | ||
| 97 | public function find(array $criteria): array // obtenir une entrée avec un tableau associatif 'champ' => 'valeur' | 99 | protected function find(array $criteria): array // obtenir une entrée avec un tableau associatif 'champ' => 'valeur' |
| 98 | { | 100 | { |
| 99 | $fields = []; | 101 | $fields = []; |
| 100 | $values = []; | 102 | $values = []; |
| @@ -134,7 +136,7 @@ class Model extends DB | |||
| 134 | 136 | ||
| 135 | 137 | ||
| 136 | // delete DELETE | 138 | // delete DELETE |
| 137 | public function delete(int $id) | 139 | protected function delete(int $id) |
| 138 | { | 140 | { |
| 139 | return($this->execQuery("DELETE FROM {$this->table} WHERE id = ?", [$id])); // double quotes "" pour insertion de variable, paramètre [$id] parce qu'on veut un tableau | 141 | return($this->execQuery("DELETE FROM {$this->table} WHERE id = ?", [$id])); // double quotes "" pour insertion de variable, paramètre [$id] parce qu'on veut un tableau |
| 140 | } | 142 | } |
diff --git a/src/model/Prestations.php b/src/model/Prestations.php index 32f9768..cbe8e6c 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php | |||
| @@ -4,23 +4,56 @@ | |||
| 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 | private $ID; | 7 | protected $ID_presta; // auto-incrémentée |
| 8 | private $IDClient; | 8 | protected $ID_client = 0; |
| 9 | private $combientieme_fois; | 9 | protected $combientieme_fois = 0; |
| 10 | private $code_presta; | 10 | protected $code_presta = ''; |
| 11 | private $date; | 11 | protected $date = 0; // timestamp unix |
| 12 | private $type; | 12 | protected $type_presta = ''; |
| 13 | private $mode_paiement; | 13 | protected $mode_paiement = ''; |
| 14 | private $commentaires; | 14 | protected $commentaires = ''; |
| 15 | 15 | ||
| 16 | use ModelChildren; | 16 | //~ use ModelChildren; |
| 17 | |||
| 18 | public function __construct(int $ID_client) | ||
| 19 | { | ||
| 20 | $this->table = 'prestations'; | ||
| 21 | $this->ID_client = $ID_client; | ||
| 22 | $this->combientiemeFois(); | ||
| 23 | } | ||
| 24 | |||
| 25 | // getters | ||
| 26 | public function getIDPresta(): int | ||
| 27 | { | ||
| 28 | return $this->ID_presta; | ||
| 29 | } | ||
| 30 | public function getIDClient(): int | ||
| 31 | { | ||
| 32 | return $this->ID_client; | ||
| 33 | } | ||
| 34 | public function getCombientiemeFois(): int | ||
| 35 | { | ||
| 36 | return $this->combientieme_fois; | ||
| 37 | } | ||
| 38 | public function getDate(): int | ||
| 39 | { | ||
| 40 | return $this->date; | ||
| 41 | } | ||
| 17 | 42 | ||
| 18 | // setters | 43 | // setters |
| 19 | public function setID(int $value) | 44 | public function setIDPresta(int $value = 0) |
| 20 | { | 45 | { |
| 21 | $this->ID = $value; | 46 | if($value === 0) |
| 47 | { | ||
| 48 | $this->ID_presta = $this->db->lastInsertId(); // méthode de PDO | ||
| 49 | } | ||
| 50 | else | ||
| 51 | { | ||
| 52 | $this->ID_presta = $value; | ||
| 53 | } | ||
| 22 | return($this); | 54 | return($this); |
| 23 | } | 55 | } |
| 56 | |||
| 24 | public function setIDClient(int $value) | 57 | public function setIDClient(int $value) |
| 25 | { | 58 | { |
| 26 | $this->ID_client = $value; | 59 | $this->ID_client = $value; |
| @@ -41,9 +74,9 @@ class Prestations extends Model | |||
| 41 | $this->date = $value; | 74 | $this->date = $value; |
| 42 | return($this); | 75 | return($this); |
| 43 | } | 76 | } |
| 44 | public function setType(string $value) | 77 | public function setTypePresta(string $value) |
| 45 | { | 78 | { |
| 46 | $this->type = $value; | 79 | $this->type_presta = $value; |
| 47 | return($this); | 80 | return($this); |
| 48 | } | 81 | } |
| 49 | public function setModePaiement(string $value) | 82 | public function setModePaiement(string $value) |
| @@ -56,4 +89,26 @@ class Prestations extends Model | |||
| 56 | $this->commentaires = $value; | 89 | $this->commentaires = $value; |
| 57 | return($this); | 90 | return($this); |
| 58 | } | 91 | } |
| 92 | |||
| 93 | protected function combientiemeFois() | ||
| 94 | { | ||
| 95 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) | ||
| 96 | $array = $this->find(['ID_client' => $this->ID_client]); | ||
| 97 | $this->combientieme_fois = count($array) + 1; | ||
| 98 | } | ||
| 99 | |||
| 100 | // code client = année-mois-jour-codeclient-combientièmefois | ||
| 101 | public function makeCodePresta(Dates $Date, string $code_client) | ||
| 102 | { | ||
| 103 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->combientieme_fois]; | ||
| 104 | $this->code_presta = implode('-', $array_code); | ||
| 105 | } | ||
| 106 | |||
| 107 | //~ public function newRow(array $input) | ||
| 108 | //~ { | ||
| 109 | //~ $this->hydrate(['ID_client' => $input[0], 'code_presta' => $input[1], 'date' => $input[2], 'type_presta' => $input[3], 'mode_paiement' => $input[4], 'commentaires' => $input[5]]); | ||
| 110 | //~ $this->create(); | ||
| 111 | //~ // ID obtenu par auto-incrémentation | ||
| 112 | //~ $this->ID_presta = $this->db->lastInsertId(); // méthode de PDO | ||
| 113 | //~ } | ||
| 59 | } | 114 | } |
diff --git a/src/model/StructTablesDB.php b/src/model/StructTablesDB.php index ee4baf1..0f13b80 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/StructTablesDB.php | |||
| @@ -9,11 +9,11 @@ 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', 'adresse' => 'TEXT', 'code_client' => 'TEXT', 'commentaires' => 'TEXT'], | 12 | 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'commentaires' => 'TEXT'], |
| 13 | 'prestations' => ['ID' => 'INTEGER', 'ID_client' => 'INTEGER', 'combientieme_fois' => '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 | 'devisfactures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT', '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'], | 14 | 'devisfactures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT', '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 | 'cesu' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], | 15 | 'cesu' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], |
| 16 | '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' => 'INTEGER', 'loyer_mensuel' => 'REAL', 'loyers_encaisse' => 'INTEGER', 'caution' => 'INTEGER'] | 16 | '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' => 'INTEGER', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] |
| 17 | ]; | 17 | ]; |
| 18 | 18 | ||
| 19 | // les types de variables de sqlite sont peu nombreux et autorisent un typage automatique | 19 | // les types de variables de sqlite sont peu nombreux et autorisent un typage automatique |
diff --git a/src/model/traits.php b/src/model/traits.php index 43d9b7f..3d446c1 100644 --- a/src/model/traits.php +++ b/src/model/traits.php | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | 3 | ||
| 4 | trait ModelChildren // pour ne pas toucher au constructeur de la classe Model | 4 | trait ModelChildren // pour ne pas toucher au constructeur de la classe Model |
| 5 | { | 5 | { |
| 6 | public function __construct() | 6 | //~ public function __construct() |
| 7 | { | 7 | //~ { |
| 8 | $this->table = strtolower(__CLASS__); | 8 | //~ $this->table = strtolower(__CLASS__); |
| 9 | } | 9 | //~ } |
| 10 | 10 | ||
| 11 | public function setIdFromLastInsertID() // à faire juste après l'écriture d'une nouvelle entrée | 11 | //~ public function setIdFromLastInsertID() // à faire juste après l'écriture d'une nouvelle entrée |
| 12 | { | 12 | //~ { |
| 13 | $this->db = parent::getInstance(); | 13 | //~ $this->db = parent::getInstance(); |
| 14 | $this->ID = $this->db->lastInsertId(); // méthode de PDO | 14 | //~ $this->ID = $this->db->lastInsertId(); // méthode de PDO |
| 15 | } | 15 | //~ } |
| 16 | } | 16 | } |
