diff options
| author | polo <ordipolo@gmx.fr> | 2023-12-23 10:00:24 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2023-12-23 10:00:24 +0100 |
| commit | a4d88fd1913758cc95b395eefcf5e9d730450382 (patch) | |
| tree | a7ffe3ab2816d7562cc967b5b4ef7c974dd7a0e2 /src/model | |
| parent | 78439b6a178e238ab8fb73d25567a85df78d6681 (diff) | |
| download | AppliGestionPHP-a4d88fd1913758cc95b395eefcf5e9d730450382.tar.gz AppliGestionPHP-a4d88fd1913758cc95b395eefcf5e9d730450382.tar.bz2 AppliGestionPHP-a4d88fd1913758cc95b395eefcf5e9d730450382.zip | |
devis payant, créer devis depuis facture, changement dans getIDsByIdClient(), suppression dépendance paquet latex "ulem", (string) dans setTelephone()
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/Clients.php | 14 | ||||
| -rw-r--r-- | src/model/DevisFactures.php | 32 | ||||
| -rw-r--r-- | src/model/Model.php | 35 | ||||
| -rw-r--r-- | src/model/Prestations.php | 24 | ||||
| -rw-r--r-- | src/model/StructTablesDB.php | 2 |
5 files changed, 68 insertions, 39 deletions
diff --git a/src/model/Clients.php b/src/model/Clients.php index 524070a..a5cc276 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php | |||
| @@ -102,17 +102,11 @@ class Clients extends Model | |||
| 102 | $this->ville = (string) $value; | 102 | $this->ville = (string) $value; |
| 103 | return $this; | 103 | return $this; |
| 104 | } | 104 | } |
| 105 | public function setTelephone($value) // chaine parce que zenity renvoie une chaine et parce qu'on garde le 0 au début | 105 | public function setTelephone($value) |
| 106 | { | 106 | { |
| 107 | if(is_numeric($value)) | 107 | // type string parce que |
| 108 | { | 108 | // zenity renvoie une chaine, on peut ainsi garder le 0 au début et avoir plusieurs numéros (séparés par virgule et espace) |
| 109 | $this->telephone = (string) $value; | 109 | $this->telephone = (string) $value; |
| 110 | } | ||
| 111 | else | ||
| 112 | { | ||
| 113 | $this->telephone = ''; | ||
| 114 | echo 'debug: le champ "telephone" ne doit comporter que des nombres, aucun numéro ne sera utilisé' . "\n"; | ||
| 115 | } | ||
| 116 | return $this; | 110 | return $this; |
| 117 | } | 111 | } |
| 118 | public function setCourriel($value) | 112 | public function setCourriel($value) |
diff --git a/src/model/DevisFactures.php b/src/model/DevisFactures.php index 259690b..7c31f13 100644 --- a/src/model/DevisFactures.php +++ b/src/model/DevisFactures.php | |||
| @@ -17,6 +17,7 @@ class DevisFactures extends Model | |||
| 17 | protected $pieces; | 17 | protected $pieces; |
| 18 | protected $total_pieces; | 18 | protected $total_pieces; |
| 19 | protected $deplacement; | 19 | protected $deplacement; |
| 20 | protected $prix_devis; | ||
| 20 | protected $total_HT; | 21 | protected $total_HT; |
| 21 | protected $delai_livraison; | 22 | protected $delai_livraison; |
| 22 | protected $validite_devis; | 23 | protected $validite_devis; |
| @@ -26,6 +27,7 @@ class DevisFactures extends Model | |||
| 26 | { | 27 | { |
| 27 | $this->table = $table; // deux tables séparées devis et factures | 28 | $this->table = $table; // deux tables séparées devis et factures |
| 28 | } | 29 | } |
| 30 | |||
| 29 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | 31 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) |
| 30 | { | 32 | { |
| 31 | $taches = ["Tâches:" => $this->taches]; | 33 | $taches = ["Tâches:" => $this->taches]; |
| @@ -60,7 +62,8 @@ class DevisFactures extends Model | |||
| 60 | return []; | 62 | return []; |
| 61 | } | 63 | } |
| 62 | } | 64 | } |
| 63 | public function set(string $entry, string $input) | 65 | |
| 66 | public function set(string $entry, string $input) // trouve la bonne méthode | ||
| 64 | { | 67 | { |
| 65 | switch($entry) | 68 | switch($entry) |
| 66 | { | 69 | { |
| @@ -91,6 +94,9 @@ class DevisFactures extends Model | |||
| 91 | case "Déplacement:": | 94 | case "Déplacement:": |
| 92 | $this->setDeplacement($input); | 95 | $this->setDeplacement($input); |
| 93 | break; | 96 | break; |
| 97 | case "Prix du devis:": | ||
| 98 | $this->setPrixDevis($input); | ||
| 99 | break; | ||
| 94 | case "Total HT:": | 100 | case "Total HT:": |
| 95 | $this->setTotalHT($input); | 101 | $this->setTotalHT($input); |
| 96 | break; | 102 | break; |
| @@ -142,11 +148,6 @@ class DevisFactures extends Model | |||
| 142 | $this->cles_licences = $value; | 148 | $this->cles_licences = $value; |
| 143 | return($this); | 149 | return($this); |
| 144 | } | 150 | } |
| 145 | //~ public function setTemps(string $value) | ||
| 146 | //~ { | ||
| 147 | //~ $this->temps = $value; | ||
| 148 | //~ return($this); | ||
| 149 | //~ } | ||
| 150 | public function setTotalMainDOeuvre($value) | 151 | public function setTotalMainDOeuvre($value) |
| 151 | { | 152 | { |
| 152 | $value = str_replace(',', '.', $value); | 153 | $value = str_replace(',', '.', $value); |
| @@ -176,6 +177,12 @@ class DevisFactures extends Model | |||
| 176 | $this->total_HT = (float) $value; | 177 | $this->total_HT = (float) $value; |
| 177 | return($this); | 178 | return($this); |
| 178 | } | 179 | } |
| 180 | public function setPrixDevis($value) | ||
| 181 | { | ||
| 182 | $value = str_replace(',', '.', $value); | ||
| 183 | $this->prix_devis = (float) $value; | ||
| 184 | return($this); | ||
| 185 | } | ||
| 179 | public function setDelaiLivraison(string $value) | 186 | public function setDelaiLivraison(string $value) |
| 180 | { | 187 | { |
| 181 | $this->delai_livraison = $value; | 188 | $this->delai_livraison = $value; |
| @@ -192,6 +199,19 @@ class DevisFactures extends Model | |||
| 192 | return($this); | 199 | return($this); |
| 193 | } | 200 | } |
| 194 | 201 | ||
| 202 | // création d'une facture à partir d'un devis | ||
| 203 | public function hydrateReceiptWithQuotation($ReceiptDetails) | ||
| 204 | { | ||
| 205 | $ReceiptDetails->hydrate([ | ||
| 206 | 'taches' => $this->taches, | ||
| 207 | 'total_main_d_oeuvre' => $this->total_main_d_oeuvre, | ||
| 208 | 'pieces' => $this->pieces, | ||
| 209 | 'total_pieces' => $this->total_pieces, | ||
| 210 | 'deplacement' => $this->deplacement, | ||
| 211 | 'total_HT' => $this->total_HT | ||
| 212 | ]); | ||
| 213 | } | ||
| 214 | |||
| 195 | //~ public function newRow(array $input) | 215 | //~ public function newRow(array $input) |
| 196 | //~ { | 216 | //~ { |
| 197 | //~ if($this->table === 'devis') // comme la table 'factures' avec deux champs en plus | 217 | //~ if($this->table === 'devis') // comme la table 'factures' avec deux champs en plus |
diff --git a/src/model/Model.php b/src/model/Model.php index 07826af..d6597f0 100644 --- a/src/model/Model.php +++ b/src/model/Model.php | |||
| @@ -37,6 +37,11 @@ abstract class Model extends DB | |||
| 37 | } | 37 | } |
| 38 | return $this; | 38 | return $this; |
| 39 | } | 39 | } |
| 40 | public function setTable(string $value) | ||
| 41 | { | ||
| 42 | $this->table = $value; | ||
| 43 | return($this); | ||
| 44 | } | ||
| 40 | 45 | ||
| 41 | public function hydrate(array $data): bool // $data = tableau associatif en entrée: nom_du_champ => valeur | 46 | public function hydrate(array $data): bool // $data = tableau associatif en entrée: nom_du_champ => valeur |
| 42 | { | 47 | { |
| @@ -60,6 +65,7 @@ abstract class Model extends DB | |||
| 60 | } | 65 | } |
| 61 | 66 | ||
| 62 | // cette fonction reçoit des données d'un tableau simple, permettant d'associer des champs de formulaires aux noms différents des champs de la BDD | 67 | // cette fonction reçoit des données d'un tableau simple, permettant d'associer des champs de formulaires aux noms différents des champs de la BDD |
| 68 | // méthode lancée par des objets de type enfants | ||
| 63 | function hydrateFromForm(string $data_string, Object $Presta = NULL): bool // quand l'objet est $Details, on hydrate aussi $Presta | 69 | function hydrateFromForm(string $data_string, Object $Presta = NULL): bool // quand l'objet est $Details, on hydrate aussi $Presta |
| 64 | { | 70 | { |
| 65 | //~ $tableSize = count(StructTablesDB::$structureOfTables[$this->getTable()]); // int | 71 | //~ $tableSize = count(StructTablesDB::$structureOfTables[$this->getTable()]); // int |
| @@ -84,18 +90,25 @@ abstract class Model extends DB | |||
| 84 | case 'prestations'; // inutilisé | 90 | case 'prestations'; // inutilisé |
| 85 | break; | 91 | break; |
| 86 | case 'devis'; | 92 | case 'devis'; |
| 87 | //~ $check = $Presta->hydrate(['mode_paiement' => $data_array[6]]); | 93 | $check = $this->hydrate(['taches' => $data_array[0], 'total_main_d_oeuvre' => $data_array[1], 'pieces' => $data_array[2], 'total_pieces' => $data_array[3], 'deplacement' => $data_array[4], 'prix_devis' => $data_array[5], 'total_HT' => $data_array[6], 'delai_livraison' => $data_array[7], 'validite_devis' => $data_array[8]]); |
| 88 | //~ if($check) | ||
| 89 | //~ { | ||
| 90 | //~ $check = $this->hydrate(['taches' => $data_array[0], 'total_main_d_oeuvre' => $data_array[1], 'pieces' => $data_array[2], 'total_pieces' => $data_array[3], 'deplacement' => $data_array[4], 'total_HT' => $data_array[5], 'delai_livraison' => $data_array[7], 'validite_devis' => $data_array[8], 'signature_devis' => $data_array[9]]); | ||
| 91 | $check = $this->hydrate(['taches' => $data_array[0], 'total_main_d_oeuvre' => $data_array[1], 'pieces' => $data_array[2], 'total_pieces' => $data_array[3], 'deplacement' => $data_array[4], 'total_HT' => $data_array[5], 'delai_livraison' => $data_array[6], 'validite_devis' => $data_array[7]]); | ||
| 92 | //~ } | ||
| 93 | break; | 94 | break; |
| 94 | case 'factures'; | 95 | case 'factures'; |
| 95 | $check = $Presta->hydrate(['mode_paiement' => $data_array[10]]); | 96 | if(count($data_array) === 11) |
| 96 | if($check) | 97 | { |
| 98 | $check = $Presta->hydrate(['mode_paiement' => $data_array[10]]); | ||
| 99 | if($check) | ||
| 100 | { | ||
| 101 | $check = $this->hydrate(['taches' => $data_array[0], 'machine' => $data_array[1], 'OS' => $data_array[2], 'donnees' => $data_array[3], 'cles_licences' => $data_array[4], 'total_main_d_oeuvre' => $data_array[5], 'pieces' => $data_array[6], 'total_pieces' => $data_array[7], 'deplacement' => $data_array[8], 'total_HT' => $data_array[9]]); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | elseif(count($data_array) === 5) | ||
| 97 | { | 105 | { |
| 98 | $check = $this->hydrate(['taches' => $data_array[0], 'machine' => $data_array[1], 'OS' => $data_array[2], 'donnees' => $data_array[3], 'cles_licences' => $data_array[4], 'total_main_d_oeuvre' => $data_array[5], 'pieces' => $data_array[6], 'total_pieces' => $data_array[7], 'deplacement' => $data_array[8], 'total_HT' => $data_array[9]]); | 106 | $check = $this->hydrate(['machine' => $data_array[1], 'OS' => $data_array[2], 'donnees' => $data_array[3], 'cles_licences' => $data_array[4]]); |
| 107 | } | ||
| 108 | else | ||
| 109 | { | ||
| 110 | echo "debug: le tableau \$data_array n'a pas la taille attendue.\n"; | ||
| 111 | return false; | ||
| 99 | } | 112 | } |
| 100 | break; | 113 | break; |
| 101 | case 'cesu'; | 114 | case 'cesu'; |
| @@ -106,11 +119,7 @@ abstract class Model extends DB | |||
| 106 | } | 119 | } |
| 107 | break; | 120 | break; |
| 108 | case 'locations'; | 121 | case 'locations'; |
| 109 | //~ $check = $Presta->hydrate(['mode_paiement' => $data_array[11]]); | ||
| 110 | //~ if($check) | ||
| 111 | //~ { | ||
| 112 | $check = $this->hydrate(['designation' => $data_array[0], 'modele_description' => $data_array[1], 'valeur' => $data_array[2], 'etat_des_lieux_debut' => $data_array[3], 'etat_des_lieux_fin' => $data_array[4], 'duree_location' => $data_array[5], 'loyer_mensuel' => $data_array[6], 'loyers_payes' => $data_array[7], 'caution' => $data_array[8]]); | 122 | $check = $this->hydrate(['designation' => $data_array[0], 'modele_description' => $data_array[1], 'valeur' => $data_array[2], 'etat_des_lieux_debut' => $data_array[3], 'etat_des_lieux_fin' => $data_array[4], 'duree_location' => $data_array[5], 'loyer_mensuel' => $data_array[6], 'loyers_payes' => $data_array[7], 'caution' => $data_array[8]]); |
| 113 | //~ } | ||
| 114 | break; | 123 | break; |
| 115 | default: // inutilisé | 124 | default: // inutilisé |
| 116 | echo "debug: table inconnue hydrateFromForm()"; | 125 | echo "debug: table inconnue hydrateFromForm()"; |
diff --git a/src/model/Prestations.php b/src/model/Prestations.php index 54ad4b7..8591e83 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php | |||
| @@ -28,13 +28,19 @@ class Prestations extends Model | |||
| 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 | 31 | public function getIDsByIdClient() // obtenir une entrée avec son ID_client, comportement différent si le type est connu |
| 32 | { | 32 | { |
| 33 | $IDs = $this->execQuery('SELECT id FROM ' . $this->table . ' WHERE id_client = ' . $this->ID_client)->fetchAll(); | 33 | $sql = 'SELECT id FROM ' . $this->table . ' WHERE id_client = ' . $this->ID_client; |
| 34 | // changer le tableau de tableaux en tableau simple | 34 | if($this->type_presta != '') |
| 35 | for($i = 0; $i < count($IDs); $i++) | ||
| 36 | { | 35 | { |
| 37 | $IDs[$i] = $IDs[$i]['ID']; | 36 | $sql .= " AND type_presta = '" . $this->type_presta . "'"; |
| 37 | } | ||
| 38 | $data = $this->execQuery($sql)->fetchAll(); // tableau de tableaux | ||
| 39 | |||
| 40 | $IDs = []; // si $IDs reste vide, ne pas être de type NULL | ||
| 41 | for($i = 0; $i < count($data); $i++) | ||
| 42 | { | ||
| 43 | $IDs[$i] = $data[$i]['ID']; // tableau simple | ||
| 38 | } | 44 | } |
| 39 | return($IDs); | 45 | return($IDs); |
| 40 | } | 46 | } |
| @@ -152,7 +158,7 @@ class Prestations extends Model | |||
| 152 | } | 158 | } |
| 153 | } | 159 | } |
| 154 | 160 | ||
| 155 | class CodePresta extends Prestations | 161 | //~ class CodePresta extends Prestations |
| 156 | { | 162 | //~ { |
| 157 | protected $numero_presta; | 163 | //~ protected $numero_presta; |
| 158 | } | 164 | //~ } |
diff --git a/src/model/StructTablesDB.php b/src/model/StructTablesDB.php index 679adde..48bf8e5 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/StructTablesDB.php | |||
| @@ -11,7 +11,7 @@ class StructTablesDB | |||
| 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', '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'] |
