diff options
| author | polo <ordipolo@gmx.fr> | 2023-01-10 13:08:54 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2023-01-10 13:08:54 +0100 |
| commit | 945af9fda5146405ab9903d4d268bcb2fe95da25 (patch) | |
| tree | 0c3af5ae3e4068e65c3e066c83c7d72058339a7d /src/model/DevisFactures.php | |
| parent | 1894fc377e6b938ea34df9980567a1634ec6ef48 (diff) | |
| download | AppliGestionPHP-945af9fda5146405ab9903d4d268bcb2fe95da25.tar.gz AppliGestionPHP-945af9fda5146405ab9903d4d268bcb2fe95da25.tar.bz2 AppliGestionPHP-945af9fda5146405ab9903d4d268bcb2fe95da25.zip | |
enregistrement section 1
Diffstat (limited to 'src/model/DevisFactures.php')
| -rw-r--r-- | src/model/DevisFactures.php | 102 |
1 files changed, 56 insertions, 46 deletions
diff --git a/src/model/DevisFactures.php b/src/model/DevisFactures.php index 1ed3a5c..ff80960 100644 --- a/src/model/DevisFactures.php +++ b/src/model/DevisFactures.php | |||
| @@ -3,49 +3,42 @@ | |||
| 3 | 3 | ||
| 4 | class DevisFactures extends Model | 4 | class DevisFactures extends Model |
| 5 | { | 5 | { |
| 6 | //~ public $type = ''; // deux tables séparées devis ou factures | ||
| 7 | |||
| 6 | // lecture des données ou hydratation | 8 | // lecture des données ou hydratation |
| 7 | private $ID_devis_facture; // auto-incrémentée | 9 | protected $ID; // auto-incrémentée |
| 8 | private $ID_presta = 0; | 10 | protected $ID_presta; |
| 9 | private $validite_devis; | 11 | protected $taches; |
| 10 | private $signature_devis; | 12 | protected $machine; |
| 11 | private $taches; | 13 | protected $OS; |
| 12 | private $machine; | 14 | protected $donnees; |
| 13 | private $OS; | 15 | protected $cles_licences; |
| 14 | private $donnees; | 16 | protected $temps; |
| 15 | private $cles_licences; | 17 | protected $total_main_d_oeuvre; |
| 16 | private $total_main_d_oeuvre; | 18 | protected $pieces; |
| 17 | private $pieces; | 19 | protected $total_pieces; |
| 18 | private $total_pieces; | 20 | protected $deplacement; |
| 19 | private $deplacement; | 21 | protected $total_HT; |
| 20 | private $total_HT; | 22 | protected $validite_devis; |
| 23 | protected $signature_devis; | ||
| 21 | 24 | ||
| 22 | //~ use ModelChildren; | 25 | use ModelChildren; // pour hydrateFromForm() |
| 23 | 26 | ||
| 24 | public function __construct(int $ID_presta) | 27 | public function __construct(int $ID_presta, string $table) |
| 25 | { | 28 | { |
| 26 | $this->table = 'devisfactures'; | ||
| 27 | $this->ID_presta = $ID_presta; | 29 | $this->ID_presta = $ID_presta; |
| 30 | $this->table = $table; // deux tables séparées devis et factures | ||
| 28 | } | 31 | } |
| 29 | 32 | ||
| 30 | // setters | 33 | // setters |
| 31 | public function setIDDevisFacture(int $value = 0) | 34 | //~ public function setID() -> dans le trait ModelChildren |
| 32 | { | 35 | |
| 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 | } | ||
| 41 | return($this); | ||
| 42 | } | ||
| 43 | public function setIDPresta(int $value) | 36 | public function setIDPresta(int $value) |
| 44 | { | 37 | { |
| 45 | $this->ID_presta = $value; | 38 | $this->ID_presta = $value; |
| 46 | return($this); | 39 | return($this); |
| 47 | } | 40 | } |
| 48 | public function setValiditeDdevis(string $value) | 41 | public function setValiditedevis(string $value) |
| 49 | { | 42 | { |
| 50 | $this->validite_devis = $value; | 43 | $this->validite_devis = $value; |
| 51 | return($this); | 44 | return($this); |
| @@ -80,9 +73,15 @@ class DevisFactures extends Model | |||
| 80 | $this->cles_licences = $value; | 73 | $this->cles_licences = $value; |
| 81 | return($this); | 74 | return($this); |
| 82 | } | 75 | } |
| 83 | public function setTotalMainDOeuvre(float $value) | 76 | public function setTemps(string $value) |
| 84 | { | 77 | { |
| 85 | $this->total_main_d_oeuvre = $value; | 78 | $this->temps = $value; |
| 79 | return($this); | ||
| 80 | } | ||
| 81 | public function setTotalMainDOeuvre($value) | ||
| 82 | { | ||
| 83 | $value = str_replace(',', '.', $value); | ||
| 84 | $this->total_main_d_oeuvre = (float) $value; // float "nettoie" tous les caractères après le dernier chiffre trouvé (ex: 50€ => 50, abc => 0) | ||
| 86 | return($this); | 85 | return($this); |
| 87 | } | 86 | } |
| 88 | public function setPieces(string $value) | 87 | public function setPieces(string $value) |
| @@ -90,28 +89,39 @@ class DevisFactures extends Model | |||
| 90 | $this->pieces = $value; | 89 | $this->pieces = $value; |
| 91 | return($this); | 90 | return($this); |
| 92 | } | 91 | } |
| 93 | public function setTotalPieces(float $value) | 92 | public function setTotalPieces($value) |
| 94 | { | 93 | { |
| 95 | $this->total_pieces = $value; | 94 | $value = str_replace(',', '.', $value); |
| 95 | $this->total_pieces = (float) $value; | ||
| 96 | return($this); | 96 | return($this); |
| 97 | } | 97 | } |
| 98 | public function setDeplacement(float $value) | 98 | public function setDeplacement($value) |
| 99 | { | 99 | { |
| 100 | $this->deplacement = $value; | 100 | $value = str_replace(',', '.', $value); |
| 101 | $this->deplacement = (float) $value; | ||
| 101 | return($this); | 102 | return($this); |
| 102 | } | 103 | } |
| 103 | public function setTotalHT(float $value) | 104 | public function setTotalHT($value) |
| 104 | { | 105 | { |
| 105 | $this->total_HT = $value; | 106 | $value = str_replace(',', '.', $value); |
| 107 | $this->total_HT = (float) $value; | ||
| 106 | return($this); | 108 | return($this); |
| 107 | } | 109 | } |
| 108 | 110 | ||
| 109 | public function newRow(array $input, array $quotations_input = []) | 111 | //~ public function newRow(array $input) |
| 110 | { | 112 | //~ { |
| 111 | if(!empty($quotations_input)) // cas d'un devis | 113 | //~ if($this->table === 'devis') // comme la table 'factures' avec deux champs en plus |
| 112 | { | 114 | //~ { |
| 113 | $this->hydrate(['validite_devis' => $quotations_input[0], 'signature_devis' => $quotations_input[1]]); | 115 | //~ $this->hydrate(['ID' => $input[0], 'ID_presta' => $input[1], 'taches' => $input[2], 'machine' => $input[3], 'OS' => $input[4], 'donnees' => $input[5], 'cles_licences' => $input[6], 'total_main_d_oeuvre' => $input[7], 'pieces' => $input[8], 'total_pieces' => $input[9], 'deplacement' => $input[10], 'total_HT' => $input[11]], |
| 114 | } | 116 | //~ ['validite_devis' => $input[12], 'signature_devis' => $input[13]]); |
| 115 | $this->hydrate([]); | 117 | //~ $this->hydrate(['validite_devis' => $quotations_input[0], 'signature_devis' => $quotations_input[1]]); |
| 116 | } | 118 | //~ } |
| 119 | //~ elseif($this->table === 'factures') | ||
| 120 | //~ { | ||
| 121 | //~ $this->hydrate(['ID' => $input[0], 'ID_presta' => $input[1], 'taches' => $input[2], 'machine' => $input[3], 'OS' => $input[4], 'donnees' => $input[5], 'cles_licences' => $input[6], 'total_main_d_oeuvre' => $input[7], 'pieces' => $input[8], 'total_pieces' => $input[9], 'deplacement' => $input[10], 'total_HT' => $input[11]]); | ||
| 122 | //~ } | ||
| 123 | //~ $this->hydrate(['ID' => $input[0], 'ID_presta' => $input[1], 'taches' => $input[2], 'machine' => $input[3], 'OS' => $input[4], 'donnees' => $input[5], 'cles_licences' => $input[6], 'total_main_d_oeuvre' => $input[7], 'pieces' => $input[8], 'total_pieces' => $input[9], 'deplacement' => $input[10], 'total_HT' => $input[11]]); | ||
| 124 | //~ $this->create(); | ||
| 125 | //~ $this->ID_devis_facture = $this->db->lastInsertId(); // méthode de PDO | ||
| 126 | //~ } | ||
| 117 | } | 127 | } |
