diff options
| author | polo <ordipolo@gmx.fr> | 2023-09-01 12:00:23 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2023-09-01 12:00:23 +0200 |
| commit | 45f1b99a1060ee43deb6055faef1f8b16b5d80a2 (patch) | |
| tree | 2be0c73b839b220433280daaf29d41644ecd4851 | |
| parent | 6f4cc3afffde36a13618458ffda72e6104624f36 (diff) | |
| download | AppliGestionPHP-45f1b99a1060ee43deb6055faef1f8b16b5d80a2.tar.gz AppliGestionPHP-45f1b99a1060ee43deb6055faef1f8b16b5d80a2.tar.bz2 AppliGestionPHP-45f1b99a1060ee43deb6055faef1f8b16b5d80a2.zip | |
section 3 bientôt terminée
| -rw-r--r-- | data/dev.sqlite | bin | 36864 -> 36864 bytes | |||
| -rw-r--r-- | src/files.php | 14 | ||||
| -rw-r--r-- | src/functions.php | 12 | ||||
| -rwxr-xr-x | src/main.php | 2 | ||||
| -rw-r--r-- | src/main_loop.php (renamed from src/sections/main_loop.php) | 0 | ||||
| -rw-r--r-- | src/model/Clients.php | 2 | ||||
| -rw-r--r-- | src/model/DevisFactures.php | 66 | ||||
| -rw-r--r-- | src/model/Prestations.php | 54 | ||||
| -rw-r--r-- | src/sections/2_service.php | 23 | ||||
| -rw-r--r-- | src/sections/3-1_windows.php | 70 | ||||
| -rw-r--r-- | src/sections/3_modify_data.php | 157 | ||||
| -rw-r--r-- | src/view/ZenitySetup.php | 16 |
12 files changed, 288 insertions, 128 deletions
diff --git a/data/dev.sqlite b/data/dev.sqlite index 61eb65d..07c5233 100644 --- a/data/dev.sqlite +++ b/data/dev.sqlite | |||
| Binary files differ | |||
diff --git a/src/files.php b/src/files.php index 2d12280..d8fcba7 100644 --- a/src/files.php +++ b/src/files.php | |||
| @@ -50,3 +50,17 @@ function latexToPdf(string $latex_path, string $file_name, string $pdf_path) | |||
| 50 | unlink($pdf_path . $basename . '.aux'); | 50 | unlink($pdf_path . $basename . '.aux'); |
| 51 | unlink($pdf_path . $basename . '.log'); | 51 | unlink($pdf_path . $basename . '.log'); |
| 52 | } | 52 | } |
| 53 | |||
| 54 | function makeTexAndPdf(Object $Object) | ||
| 55 | { | ||
| 56 | if(get_class($Object) !== 'EnveloppeVersoLatex') | ||
| 57 | { | ||
| 58 | makeFolder($Object->getLatexPath()); | ||
| 59 | makeFolder($Object->getPdfPath()); | ||
| 60 | } | ||
| 61 | makeFile($Object->getLatexPath(), $Object->getFileName(), $Object->getLatex()); // fichier .tex | ||
| 62 | latexToPdf($Object->getLatexPath(), $Object->getFileName(), $Object->getPdfPath()); // fichier .pdf avec pdflatex | ||
| 63 | } | ||
| 64 | |||
| 65 | //~ function removeFile(Object $Object) | ||
| 66 | //~ {} | ||
diff --git a/src/functions.php b/src/functions.php index c847403..47961f2 100644 --- a/src/functions.php +++ b/src/functions.php | |||
| @@ -140,15 +140,3 @@ function getServices(Clients $Client) | |||
| 140 | return $PrestaList[$input]; | 140 | return $PrestaList[$input]; |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | |||
| 144 | |||
| 145 | function makeTexAndPdf(Object $Object) | ||
| 146 | { | ||
| 147 | if(get_class($Object) !== 'EnveloppeVersoLatex') | ||
| 148 | { | ||
| 149 | makeFolder($Object->getLatexPath()); | ||
| 150 | makeFolder($Object->getPdfPath()); | ||
| 151 | } | ||
| 152 | makeFile($Object->getLatexPath(), $Object->getFileName(), $Object->getLatex()); // fichier .tex | ||
| 153 | latexToPdf($Object->getLatexPath(), $Object->getFileName(), $Object->getPdfPath()); // fichier .pdf avec pdflatex | ||
| 154 | } | ||
diff --git a/src/main.php b/src/main.php index 303e1ef..d176b56 100755 --- a/src/main.php +++ b/src/main.php | |||
| @@ -50,4 +50,4 @@ require('Latex.php'); // générer le code LaTeX | |||
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | // action !! | 52 | // action !! |
| 53 | require('sections/main_loop.php'); | 53 | require('main_loop.php'); |
diff --git a/src/sections/main_loop.php b/src/main_loop.php index f68c251..f68c251 100644 --- a/src/sections/main_loop.php +++ b/src/main_loop.php | |||
diff --git a/src/model/Clients.php b/src/model/Clients.php index 6a4dcf5..524070a 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php | |||
| @@ -42,7 +42,7 @@ class Clients extends Model | |||
| 42 | "À propos:" => $this->apropos, | 42 | "À propos:" => $this->apropos, |
| 43 | "Client ou Prospect?" => $this->type]; | 43 | "Client ou Prospect?" => $this->type]; |
| 44 | } | 44 | } |
| 45 | public function getSetterAndSet(string $entry, string $input) | 45 | public function set(string $entry, string $input) |
| 46 | { | 46 | { |
| 47 | switch($entry) | 47 | switch($entry) |
| 48 | { | 48 | { |
diff --git a/src/model/DevisFactures.php b/src/model/DevisFactures.php index 5769842..2a5bf8d 100644 --- a/src/model/DevisFactures.php +++ b/src/model/DevisFactures.php | |||
| @@ -28,12 +28,8 @@ class DevisFactures extends Model | |||
| 28 | } | 28 | } |
| 29 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | 29 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) |
| 30 | { | 30 | { |
| 31 | $taches = ["Tâches:" => $this->taches]; | ||
| 31 | $champs_communs = [ | 32 | $champs_communs = [ |
| 32 | "Tâches:" => $this->taches, | ||
| 33 | "PC:" => $this->machine, | ||
| 34 | "OS:" => $this->OS, | ||
| 35 | "Données:" => $this->donnees, | ||
| 36 | "Clés de licences:" => $this->cles_licences, | ||
| 37 | "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, | 33 | "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, |
| 38 | "Pièces" => $this->pieces, | 34 | "Pièces" => $this->pieces, |
| 39 | "Total des pièces" => $this->total_pieces, | 35 | "Total des pièces" => $this->total_pieces, |
| @@ -42,7 +38,13 @@ class DevisFactures extends Model | |||
| 42 | 38 | ||
| 43 | if($this->table === 'factures') | 39 | if($this->table === 'factures') |
| 44 | { | 40 | { |
| 45 | return ["Numéro facture:" => $this->ID] + $champs_communs; | 41 | $champs_facture = [ |
| 42 | "PC:" => $this->machine, | ||
| 43 | "OS:" => $this->OS, | ||
| 44 | "Données:" => $this->donnees, | ||
| 45 | "Clés de licences:" => $this->cles_licences]; | ||
| 46 | |||
| 47 | return $taches + $champs_facture + $champs_communs; | ||
| 46 | } | 48 | } |
| 47 | elseif($this->table === 'devis') | 49 | elseif($this->table === 'devis') |
| 48 | { | 50 | { |
| @@ -51,15 +53,65 @@ class DevisFactures extends Model | |||
| 51 | "Durée de validité" => $this->validite_devis, | 53 | "Durée de validité" => $this->validite_devis, |
| 52 | "Devis signé?" => $this->signature_devis]; | 54 | "Devis signé?" => $this->signature_devis]; |
| 53 | 55 | ||
| 54 | return ["Numéro devis:" => $this->ID] + $champs_communs + $champs_devis; | 56 | return $champs_communs + $champs_devis; |
| 55 | } | 57 | } |
| 56 | else | 58 | else |
| 57 | { | 59 | { |
| 58 | return []; | 60 | return []; |
| 59 | } | 61 | } |
| 60 | } | 62 | } |
| 63 | public function set(string $entry, string $input) | ||
| 64 | { | ||
| 65 | switch($entry) | ||
| 66 | { | ||
| 67 | case "Tâches:": | ||
| 68 | $this->setTaches($input); | ||
| 69 | break; | ||
| 70 | case "PC:": | ||
| 71 | $this->setMachine($input); | ||
| 72 | break; | ||
| 73 | case "OS:": | ||
| 74 | $this->setOS($input); | ||
| 75 | break; | ||
| 76 | case "Données:": | ||
| 77 | $this->setDonnees($input); | ||
| 78 | break; | ||
| 79 | case "Clés de licences:": | ||
| 80 | $this->setClesLicences($input); | ||
| 81 | break; | ||
| 82 | case "Total Main d'oeuvre:": | ||
| 83 | $this->setTotalMainDOeuvre($input); | ||
| 84 | break; | ||
| 85 | case "Pièces:": | ||
| 86 | $this->setPieces($input); | ||
| 87 | break; | ||
| 88 | case "Total des pièces:": | ||
| 89 | $this->setTotalPieces($input); | ||
| 90 | break; | ||
| 91 | case "Déplacement:": | ||
| 92 | $this->setDeplacement($input); | ||
| 93 | break; | ||
| 94 | case "Total HT:": | ||
| 95 | $this->setTotalHT($input); | ||
| 96 | break; | ||
| 97 | case "Delai de livraison:": | ||
| 98 | $this->setDelaiLivraison($input); | ||
| 99 | break; | ||
| 100 | case "Durée de validité:": | ||
| 101 | $this->setValiditedevis($input); | ||
| 102 | break; | ||
| 103 | case "Devis signé?:": | ||
| 104 | $this->setSignatureDevis($input); | ||
| 105 | break; | ||
| 106 | } | ||
| 107 | } | ||
| 61 | 108 | ||
| 62 | // setters | 109 | // setters |
| 110 | //~ public function setID(int $value = 0) | ||
| 111 | //~ { | ||
| 112 | //~ $this->ID = $value; | ||
| 113 | //~ return($this); | ||
| 114 | //~ } | ||
| 63 | public function setIDPresta(int $value) | 115 | public function setIDPresta(int $value) |
| 64 | { | 116 | { |
| 65 | $this->ID_presta = $value; | 117 | $this->ID_presta = $value; |
diff --git a/src/model/Prestations.php b/src/model/Prestations.php index fe09133..e9ba7a1 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php | |||
| @@ -11,6 +11,7 @@ class Prestations extends Model | |||
| 11 | protected $type_presta = ''; | 11 | protected $type_presta = ''; |
| 12 | protected $mode_paiement = ''; | 12 | protected $mode_paiement = ''; |
| 13 | protected $commentaires = ''; | 13 | protected $commentaires = ''; |
| 14 | //protected $numero_presta = 0; | ||
| 14 | 15 | ||
| 15 | public function __construct(int $ID_client) | 16 | public function __construct(int $ID_client) |
| 16 | { | 17 | { |
| @@ -57,14 +58,33 @@ class Prestations extends Model | |||
| 57 | return [ | 58 | return [ |
| 58 | "Numéro prestation:" => end($code_presta_tableau), // dernière case | 59 | "Numéro prestation:" => end($code_presta_tableau), // dernière case |
| 59 | "Date:" => $Date->getDate(), | 60 | "Date:" => $Date->getDate(), |
| 60 | "Type de Presta:" => $this->type_presta, | 61 | //"Type de Presta:" => $this->type_presta, // choix impossible pour le moment |
| 61 | "Mode de paiement:" => $this->mode_paiement, | 62 | "Mode de paiement:" => $this->mode_paiement, |
| 62 | "Commentaires:" => $this->commentaires]; | 63 | "Commentaires:" => $this->commentaires]; |
| 63 | } | 64 | } |
| 65 | public function set(string $entry, string $input) | ||
| 66 | { | ||
| 67 | switch($entry) | ||
| 68 | { | ||
| 69 | case "Numéro prestation:": | ||
| 70 | $this->setNumeroPresta($input); | ||
| 71 | break; | ||
| 72 | //~ case "Date:": // inutile, setDate() est appelé directement après choix fenêtre calendrier | ||
| 73 | //~ $this->setDate($input); | ||
| 74 | //~ break; | ||
| 75 | //~ case "Type de Presta:": // choix impossible pour le moment | ||
| 76 | //~ $this->setTypePresta($input); | ||
| 77 | //~ break; | ||
| 78 | case "Mode de paiement:": | ||
| 79 | $this->setModePaiement($input); | ||
| 80 | break; | ||
| 81 | case "Commentaires:": | ||
| 82 | $this->setCommentaires($input); | ||
| 83 | break; | ||
| 84 | } | ||
| 85 | } | ||
| 64 | 86 | ||
| 65 | // setters | 87 | // setters |
| 66 | //~ public function setID() -> dans le trait ModelChildren | ||
| 67 | |||
| 68 | public function setIDClient(int $value) | 88 | public function setIDClient(int $value) |
| 69 | { | 89 | { |
| 70 | $this->ID_client = $value; | 90 | $this->ID_client = $value; |
| @@ -80,9 +100,20 @@ class Prestations extends Model | |||
| 80 | $this->code_presta = $value; | 100 | $this->code_presta = $value; |
| 81 | return $this; | 101 | return $this; |
| 82 | } | 102 | } |
| 83 | public function setDate(int $value) | 103 | public function setDate($value, bool $set_code_presta = false) // attend un timestamp |
| 84 | { | 104 | { |
| 85 | $this->date = $value; | 105 | $this->date = (int) $value; |
| 106 | |||
| 107 | if($set_code_presta) | ||
| 108 | { | ||
| 109 | $code_presta_tableau = explode('-', $this->code_presta); | ||
| 110 | $Date = new Dates($value); | ||
| 111 | $code_presta_tableau[0] = $Date->getYear(); | ||
| 112 | $code_presta_tableau[1] = $Date->getMonth(); | ||
| 113 | $code_presta_tableau[2] = $Date->getDay(); | ||
| 114 | $this->code_presta = implode('-', $code_presta_tableau); | ||
| 115 | } | ||
| 116 | |||
| 86 | return $this; | 117 | return $this; |
| 87 | } | 118 | } |
| 88 | public function setTypePresta(string $value) | 119 | public function setTypePresta(string $value) |
| @@ -100,6 +131,14 @@ class Prestations extends Model | |||
| 100 | $this->commentaires = $value; | 131 | $this->commentaires = $value; |
| 101 | return $this; | 132 | return $this; |
| 102 | } | 133 | } |
| 134 | public function setNumeroPresta($value) | ||
| 135 | { | ||
| 136 | // modifier le code presta, on pourrait aussi utiliser une regex | ||
| 137 | $code_presta_tableau = explode('-', $this->code_presta); | ||
| 138 | $code_presta_tableau[count($code_presta_tableau) - 1] = (int) $value; | ||
| 139 | $this->code_presta = implode('-', $code_presta_tableau); | ||
| 140 | return $this; | ||
| 141 | } | ||
| 103 | 142 | ||
| 104 | // code client = année-mois-jour-codeclient-typedepresta-combientièmefois | 143 | // code client = année-mois-jour-codeclient-typedepresta-combientièmefois |
| 105 | public function makeCodePresta(Dates $Date, string $code_client) | 144 | public function makeCodePresta(Dates $Date, string $code_client) |
| @@ -112,3 +151,8 @@ class Prestations extends Model | |||
| 112 | $this->code_presta = implode('-', $array_code); | 151 | $this->code_presta = implode('-', $array_code); |
| 113 | } | 152 | } |
| 114 | } | 153 | } |
| 154 | |||
| 155 | class CodePresta extends Prestations | ||
| 156 | { | ||
| 157 | protected $numero_presta; | ||
| 158 | } | ||
diff --git a/src/sections/2_service.php b/src/sections/2_service.php index 2680db6..1d58606 100644 --- a/src/sections/2_service.php +++ b/src/sections/2_service.php | |||
| @@ -7,14 +7,13 @@ function newService($Client): array // $Client est un Client ou null | |||
| 7 | { | 7 | { |
| 8 | // fenêtres | 8 | // fenêtres |
| 9 | $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement_text, ZenitySetup::$menu_enregistrement_entrees); | 9 | $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement_text, ZenitySetup::$menu_enregistrement_entrees); |
| 10 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar_text); | 10 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section2']); |
| 11 | $FormulaireDevis = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_devis_entrees); | 11 | $FormulaireDevis = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_devis_entrees); |
| 12 | $FormulaireFacture = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_facture_entrees); | 12 | $FormulaireFacture = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_facture_entrees); |
| 13 | $FormulaireCesu = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_cesu_entrees); | 13 | $FormulaireCesu = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_cesu_entrees); |
| 14 | $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_location_entrees); | 14 | $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_location_entrees); |
| 15 | $CommentairePrestation = new ZenityEntry(ZenitySetup::$commentaire_prestation_text); | 15 | $CommentairePrestation = new ZenityEntry(ZenitySetup::$commentaire_prestation_text); |
| 16 | //$Recapitulatif = new ZenityList(ZenitySetup::$recapitulatif_text, ZenitySetup::$recapitulatif_entrees); // tableau à multiples colonnes | 16 | //$Recapitulatif = new ZenityList(ZenitySetup::$recapitulatif_text, ZenitySetup::$recapitulatif_entrees); // tableau à multiples colonnes |
| 17 | //$QuestionModifierPrestation = new ZenityQuestion(ZenitySetup::$question_modification_text); | ||
| 18 | $FinSection2 = new ZenityList(ZenitySetup::$fin_section_2_text, ZenitySetup::$fin_section_2_entrees); | 17 | $FinSection2 = new ZenityList(ZenitySetup::$fin_section_2_text, ZenitySetup::$fin_section_2_entrees); |
| 19 | 18 | ||
| 20 | 19 | ||
| @@ -178,31 +177,15 @@ function newService($Client): array // $Client est un Client ou null | |||
| 178 | // fabrique d'objets (sans connaître les noms des classes) | 177 | // fabrique d'objets (sans connaître les noms des classes) |
| 179 | $EnveloppeRecto = Latex::makeInstance('enveloppe_recto'); | 178 | $EnveloppeRecto = Latex::makeInstance('enveloppe_recto'); |
| 180 | $EnveloppeVerso = Latex::makeInstance('enveloppe_verso'); | 179 | $EnveloppeVerso = Latex::makeInstance('enveloppe_verso'); |
| 181 | $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location | 180 | $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // retourne objet ou null |
| 182 | 181 | ||
| 183 | // génération du latex | 182 | // génération du latex |
| 184 | $EnveloppeRecto->setData($Client); | 183 | $EnveloppeRecto->setData($Client); |
| 185 | //~ $EnveloppeRecto->setFileName($Client->getCodeClient() . '.tex'); | ||
| 186 | //~ $EnveloppeRecto->setLatexPath(Config::$latex_path . 'enveloppes_recto/'); | ||
| 187 | //~ $EnveloppeRecto->setPdfPath(Config::$pdf_path . 'enveloppes_recto/'); | ||
| 188 | //~ $EnveloppeRecto->spacesInPostCode(); | ||
| 189 | $EnveloppeRecto->makeLatex(); | 184 | $EnveloppeRecto->makeLatex(); |
| 190 | |||
| 191 | //~ $EnveloppeVerso->setFileName('enveloppe_verso.tex'); | ||
| 192 | //~ $EnveloppeVerso->setLatexPath(Config::$latex_path); | ||
| 193 | //~ $EnveloppeVerso->setPdfPath(Config::$pdf_path); | ||
| 194 | $EnveloppeVerso->makeLatex(); | 185 | $EnveloppeVerso->makeLatex(); |
| 195 | |||
| 196 | if($DocumentPresta !== null) | 186 | if($DocumentPresta !== null) |
| 197 | { | 187 | { |
| 198 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); | 188 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); |
| 199 | //~ $DocumentPresta->setData($Client); | ||
| 200 | //~ $DocumentPresta->setData($Presta); | ||
| 201 | //~ $DocumentPresta->makeDateInstance($Presta->getDate()); // paramètre = int | ||
| 202 | //~ $DocumentPresta->setFileName($Presta->getCodePresta() . '.tex'); | ||
| 203 | //~ $DocumentPresta->setLatexPath(Config::$latex_path . $DocumentPresta->getYear() . '/'); | ||
| 204 | //~ $DocumentPresta->setPdfPath(Config::$pdf_path . $DocumentPresta->getYear() . '/'); | ||
| 205 | //~ $DocumentPresta->setData($PrestaDetails); | ||
| 206 | $DocumentPresta->makeLatex(); | 189 | $DocumentPresta->makeLatex(); |
| 207 | } | 190 | } |
| 208 | 191 | ||
| @@ -236,7 +219,7 @@ function newService($Client): array // $Client est un Client ou null | |||
| 236 | } | 219 | } |
| 237 | elseif($choix_niv2 === ZenitySetup::$fin_section_2_entrees[1]) | 220 | elseif($choix_niv2 === ZenitySetup::$fin_section_2_entrees[1]) |
| 238 | { | 221 | { |
| 239 | return [3, null]; // section 3: modifyData() | 222 | return [3, $Client]; // section 3: modifyData() |
| 240 | } | 223 | } |
| 241 | elseif($choix_niv2 === ZenitySetup::$fin_section_2_entrees[2]) | 224 | elseif($choix_niv2 === ZenitySetup::$fin_section_2_entrees[2]) |
| 242 | { | 225 | { |
diff --git a/src/sections/3-1_windows.php b/src/sections/3-1_windows.php new file mode 100644 index 0000000..7952f6d --- /dev/null +++ b/src/sections/3-1_windows.php | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | <?php | ||
| 2 | // src/sections/3-1_windows.php | ||
| 3 | // | ||
| 4 | // fonctions pour 3_modify_data.php | ||
| 5 | |||
| 6 | function makeModifyCustomerWindow(Clients $Customer): ZenityList | ||
| 7 | { | ||
| 8 | $ModifyCustomer = new ZenityList(ZenitySetup::$modification_client['text'], []); | ||
| 9 | $entries = []; | ||
| 10 | $i = 0; | ||
| 11 | $client_data = $Customer->getAllWithWindowFields(); | ||
| 12 | //var_dump($client_data); | ||
| 13 | foreach($client_data as $key => $value) | ||
| 14 | { | ||
| 15 | $entries[$i][] = $key; | ||
| 16 | $entries[$i][] = $value; | ||
| 17 | $i++; | ||
| 18 | } | ||
| 19 | $entries[$i][] = ZenitySetup::$modification_client['service']; | ||
| 20 | $entries[$i][] = ''; | ||
| 21 | //~ $i++; | ||
| 22 | //~ $entries[$i][] = ZenitySetup::$modification_client['return']; | ||
| 23 | //~ $entries[$i][] = ''; | ||
| 24 | $ModifyCustomer->setListRows($entries, 2, 2.5); | ||
| 25 | |||
| 26 | return $ModifyCustomer; | ||
| 27 | } | ||
| 28 | |||
| 29 | function makeModifyServiceWindow(Prestations $Service, $ServiceDetails = null): ZenityList | ||
| 30 | { | ||
| 31 | $ModifyService = new ZenityList(ZenitySetup::$modification_presta['text'], []); | ||
| 32 | $entrees = []; | ||
| 33 | $i = 0; | ||
| 34 | |||
| 35 | $presta_data = $Service->getAllWithWindowFields(); | ||
| 36 | //var_dump($presta_data); | ||
| 37 | foreach($presta_data as $key => $value) | ||
| 38 | { | ||
| 39 | $entrees[$i][] = $key; | ||
| 40 | $entrees[$i][] = $value; | ||
| 41 | $i++; | ||
| 42 | } | ||
| 43 | |||
| 44 | if(is_object($ServiceDetails)) | ||
| 45 | { | ||
| 46 | $presta_data = $ServiceDetails->getAllWithWindowFields(); | ||
| 47 | //var_dump($presta_data); | ||
| 48 | foreach($presta_data as $key => $value) | ||
| 49 | { | ||
| 50 | $entrees[$i][] = $key; | ||
| 51 | $entrees[$i][] = $value; | ||
| 52 | $i++; | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | if($Service->getTypePresta() === 'devis') | ||
| 57 | { | ||
| 58 | $entrees[$i][] = ZenitySetup::$modification_presta['devis_facture']; // option changer le devis en facture | ||
| 59 | $entrees[$i][] = ''; | ||
| 60 | //~ $i++; | ||
| 61 | } | ||
| 62 | //~ $entrees[$i][] = ZenitySetup::$modification_presta['service']; | ||
| 63 | //~ $entrees[$i][] = ''; | ||
| 64 | //~ $i++; | ||
| 65 | //~ $entrees[$i][] = ZenitySetup::$modification_presta['return']; | ||
| 66 | //~ $entrees[$i][] = ''; | ||
| 67 | $ModifyService->setListRows($entrees, 2, 2.5); | ||
| 68 | |||
| 69 | return $ModifyService; | ||
| 70 | } | ||
diff --git a/src/sections/3_modify_data.php b/src/sections/3_modify_data.php index e16a58f..71b977a 100644 --- a/src/sections/3_modify_data.php +++ b/src/sections/3_modify_data.php | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | // | 3 | // |
| 4 | // -- SECTION 3: Modifier un client, un prospect, une prestation, un devis -- | 4 | // -- SECTION 3: Modifier un client, un prospect, une prestation, un devis -- |
| 5 | 5 | ||
| 6 | require('3-1_windows.php'); | ||
| 7 | |||
| 6 | function modifyData($Client): array | 8 | function modifyData($Client): array |
| 7 | { | 9 | { |
| 8 | // -- partie 1: rechercher un client -- | 10 | // -- partie 1: rechercher un client -- |
| @@ -19,38 +21,16 @@ function modifyData($Client): array | |||
| 19 | 21 | ||
| 20 | // -- partie 2: modifier un client -- | 22 | // -- partie 2: modifier un client -- |
| 21 | 23 | ||
| 22 | // fenêtre $ModificationClient | 24 | // fenêtre |
| 23 | $ModificationClientMenu = new ZenityList(ZenitySetup::$modification_client['text'], []); | 25 | $ModificationClientMenu = makeModifyCustomerWindow($Client); |
| 24 | $entrees = []; | ||
| 25 | $i = 0; | ||
| 26 | $client_data = $Client->getAllWithWindowFields(); | ||
| 27 | //var_dump($client_data); | ||
| 28 | foreach($client_data as $key => $value) | ||
| 29 | { | ||
| 30 | $entrees[$i][] = $key; | ||
| 31 | $entrees[$i][] = $value; | ||
| 32 | $i++; | ||
| 33 | } | ||
| 34 | $entrees[$i][] = ZenitySetup::$modification_client['service']; | ||
| 35 | $entrees[$i][] = ''; | ||
| 36 | $i++; | ||
| 37 | $entrees[$i][] = ZenitySetup::$modification_client['return']; | ||
| 38 | $entrees[$i][] = ''; | ||
| 39 | $ModificationClientMenu->setListRows($entrees, 2, 2.5); | ||
| 40 | 26 | ||
| 41 | // modifier une valeur | ||
| 42 | $choix_niv2 = exec($ModificationClientMenu->get()); | 27 | $choix_niv2 = exec($ModificationClientMenu->get()); |
| 43 | if($choix_niv2 === ZenitySetup::$modification_client['service']) // ne pas modifier le client mais une prestation | 28 | if($choix_niv2 === ZenitySetup::$modification_client['service']) // ne pas modifier le client mais une prestation |
| 44 | { | 29 | { |
| 45 | echo "choix: modifier une prestation\n"; | 30 | echo "choix: modifier une prestation\n"; |
| 46 | // on passe à la suite | 31 | // on passe à la suite |
| 47 | } | 32 | } |
| 48 | elseif($choix_niv2 === ZenitySetup::$modification_client['return']) // annuler | 33 | elseif($choix_niv2 === "Client ou Prospect?") // modifier type de client |
| 49 | { | ||
| 50 | echo "choix: retour au menu principal\n"; | ||
| 51 | return [0, null]; // menu principal | ||
| 52 | } | ||
| 53 | elseif($choix_niv2 === "Client ou Prospect?") // modifier le client | ||
| 54 | { | 34 | { |
| 55 | echo "choix: modifier" . $choix_niv2 . "\n"; | 35 | echo "choix: modifier" . $choix_niv2 . "\n"; |
| 56 | $TypeDeClient = new ZenityList(ZenitySetup::$type_client_text, ZenitySetup::$type_client_entrees); | 36 | $TypeDeClient = new ZenityList(ZenitySetup::$type_client_text, ZenitySetup::$type_client_entrees); |
| @@ -72,18 +52,21 @@ function modifyData($Client): array | |||
| 72 | $Client->update(); | 52 | $Client->update(); |
| 73 | return [3, $Client]; // menu précédent | 53 | return [3, $Client]; // menu précédent |
| 74 | } | 54 | } |
| 75 | elseif(is_string($choix_niv2) && $choix_niv2 != '') // modifier le client | 55 | elseif(is_string($choix_niv2) && $choix_niv2 != '') // modifier une valeur |
| 76 | { | 56 | { |
| 77 | echo "choix: modifier" . $choix_niv2 . "\n"; | 57 | echo "choix: modifier" . $choix_niv2 . "\n"; |
| 78 | $ModificationClient = new ZenityEntry($choix_niv2); | 58 | $ModificationClient = new ZenityEntry($choix_niv2); |
| 79 | $input = exec($ModificationClient->get()); | 59 | $input = exec($ModificationClient->get()); |
| 80 | if(is_string($input) && $input != '') | 60 | if(is_string($input) && $input != '') |
| 81 | { | 61 | { |
| 82 | $Client->getSetterAndSet($choix_niv2, $input); | 62 | $Client->set($choix_niv2, $input); |
| 83 | $Client->update(); | 63 | $Client->update(); |
| 84 | 64 | ||
| 85 | // mettre à jour les documents | 65 | // mettre à jour les documents (il faudrait modifier tous les documents!!) |
| 86 | 66 | $EnveloppeRecto = Latex::makeInstance('enveloppe_recto'); | |
| 67 | $EnveloppeRecto->setData($Client); | ||
| 68 | $EnveloppeRecto->makeLatex(); | ||
| 69 | makeTexAndPdf($EnveloppeRecto); | ||
| 87 | } | 70 | } |
| 88 | else | 71 | else |
| 89 | { | 72 | { |
| @@ -105,25 +88,6 @@ function modifyData($Client): array | |||
| 105 | echo "debug: annulation sélection client\n"; | 88 | echo "debug: annulation sélection client\n"; |
| 106 | return [3, $Client]; // menu précédent | 89 | return [3, $Client]; // menu précédent |
| 107 | } | 90 | } |
| 108 | |||
| 109 | |||
| 110 | // -- partie 4: modifier une prestation -- | ||
| 111 | |||
| 112 | // fenêtre $ModificationPresta | ||
| 113 | $ModificationPrestaMenu = new ZenityList(ZenitySetup::$modification_presta['text'], []); | ||
| 114 | $entrees = []; | ||
| 115 | $i = 0; | ||
| 116 | |||
| 117 | $presta_data = $Presta->getAllWithWindowFields(); | ||
| 118 | var_dump($presta_data); | ||
| 119 | foreach($presta_data as $key => $value) | ||
| 120 | { | ||
| 121 | $entrees[$i][] = $key; | ||
| 122 | $entrees[$i][] = $value; | ||
| 123 | $i++; | ||
| 124 | } | ||
| 125 | |||
| 126 | // infos des sous-tables 'facture', 'devis', etc | ||
| 127 | switch($Presta->getTypePresta()) | 91 | switch($Presta->getTypePresta()) |
| 128 | { | 92 | { |
| 129 | case 'facture': | 93 | case 'facture': |
| @@ -140,38 +104,81 @@ function modifyData($Client): array | |||
| 140 | $PrestaDetails = new Locations(); | 104 | $PrestaDetails = new Locations(); |
| 141 | break; | 105 | break; |
| 142 | } | 106 | } |
| 143 | if(isset($PrestaDetails)) | 107 | $PrestaDetails->setIDPresta($Presta->getID()); |
| 108 | $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); | ||
| 109 | |||
| 110 | |||
| 111 | // -- partie 4: modifier une prestation -- | ||
| 112 | |||
| 113 | // fenêtre | ||
| 114 | $ModificationPrestaMenu = makeModifyServiceWindow($Presta, $PrestaDetails); | ||
| 115 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section3']); | ||
| 116 | |||
| 117 | $choix_niv3 = exec($ModificationPrestaMenu->get()); | ||
| 118 | if($choix_niv3 === ZenitySetup::$modification_presta['devis_facture']) // devis -> facture | ||
| 119 | { | ||
| 120 | echo "choix: changer un devis en facture\n"; | ||
| 121 | return [3, $Client]; // menu "client" | ||
| 122 | } | ||
| 123 | elseif($choix_niv3 === 'Date:') | ||
| 124 | { | ||
| 125 | $Date = new Dates(exec($Calendrier->get())); // exec() renvoie soit une chaîne soit un false | ||
| 126 | if($Date->getDate() == '') // on n'a pas cliqué sur "annuler" | ||
| 127 | { | ||
| 128 | echo "debug: annulation à la saisie d'une date\n"; | ||
| 129 | //return [3, $Client]; // menu principal | ||
| 130 | } | ||
| 131 | else | ||
| 132 | { | ||
| 133 | // mettre à jour la base de données | ||
| 134 | $Presta->setDate($Date->getTimestamp(), true); // un entier pour la BDD, "true" pour modifier le code_presta | ||
| 135 | $Presta->update(); | ||
| 136 | |||
| 137 | // mettre à jour les documents | ||
| 138 | $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location | ||
| 139 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); | ||
| 140 | $DocumentPresta->makeLatex(); | ||
| 141 | makeTexAndPdf($DocumentPresta); | ||
| 142 | } | ||
| 143 | |||
| 144 | return [3, $Client]; // menu précédent | ||
| 145 | } | ||
| 146 | //~ elseif($choix_niv3 === 'Type de Presta:') // choix impossible pour le moment | ||
| 147 | //~ { | ||
| 148 | //~ echo "choix: Impossible de modifier le type de prestation\n"; | ||
| 149 | //~ return [3, $Client]; // menu "client" | ||
| 150 | //~ } | ||
| 151 | elseif(is_string($choix_niv3) && $choix_niv3 != '') // modifier une valeur | ||
| 144 | { | 152 | { |
| 145 | $PrestaDetails->setIDPresta($Presta->getID()); | 153 | echo "choix: modifier" . $choix_niv3 . "\n"; |
| 146 | $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); | 154 | $ModificationPrestaForm = new ZenityEntry($choix_niv3); |
| 147 | $presta_data = $PrestaDetails->getAllWithWindowFields(); | 155 | $input = exec($ModificationPrestaForm->get()); |
| 148 | var_dump($presta_data); | 156 | if(is_string($input) && $input != '') |
| 149 | foreach($presta_data as $key => $value) | ||
| 150 | { | 157 | { |
| 151 | $entrees[$i][] = $key; | 158 | $Presta->set($choix_niv3, $input); |
| 152 | $entrees[$i][] = $value; | 159 | $PrestaDetails->set($choix_niv3, $input); |
| 153 | $i++; | 160 | |
| 161 | // mettre à jour la base de données | ||
| 162 | $Presta->update(); | ||
| 163 | $PrestaDetails->update(); | ||
| 164 | |||
| 165 | // mettre à jour les documents | ||
| 166 | $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location | ||
| 167 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); | ||
| 168 | $DocumentPresta->makeLatex(); | ||
| 169 | makeTexAndPdf($DocumentPresta); | ||
| 170 | } | ||
| 171 | else | ||
| 172 | { | ||
| 173 | echo "choix: annulation\n"; | ||
| 154 | } | 174 | } |
| 175 | return [3, $Client]; // menu précédent | ||
| 155 | } | 176 | } |
| 156 | 177 | else // annuler | |
| 157 | if($Presta->getTypePresta() === 'devis') | ||
| 158 | { | 178 | { |
| 159 | $entrees[$i][] = ZenitySetup::$modification_presta['devis_facture']; // option changer le devis en facture | 179 | echo "annulation: retour au menu précédent\n"; |
| 160 | $entrees[$i][] = ''; | 180 | return [3, $Client]; // menu précédent |
| 161 | $i++; | ||
| 162 | } | 181 | } |
| 163 | $entrees[$i][] = ZenitySetup::$modification_presta['service']; | ||
| 164 | $entrees[$i][] = ''; | ||
| 165 | $i++; | ||
| 166 | $entrees[$i][] = ZenitySetup::$modification_presta['return']; | ||
| 167 | $entrees[$i][] = ''; | ||
| 168 | $ModificationPrestaMenu->setListRows($entrees, 2, 2.5); | ||
| 169 | |||
| 170 | // modifier une valeur | ||
| 171 | $choix_niv3 = exec($ModificationPrestaMenu->get()); | ||
| 172 | var_dump($choix_niv3); | ||
| 173 | |||
| 174 | // si changement de type de prestation autre que de devis à facture, ça devient compliqué! | ||
| 175 | 182 | ||
| 176 | return [0, null]; // menu principal | 183 | //return [0, null]; // menu principal |
| 177 | } | 184 | } |
diff --git a/src/view/ZenitySetup.php b/src/view/ZenitySetup.php index 32648ea..cf3ed11 100644 --- a/src/view/ZenitySetup.php +++ b/src/view/ZenitySetup.php | |||
| @@ -28,7 +28,10 @@ class ZenitySetup | |||
| 28 | static public $resultats_recherche_presta_text = "Sélectionner une prestation"; | 28 | static public $resultats_recherche_presta_text = "Sélectionner une prestation"; |
| 29 | static public $nouveau_client_text = "Nouveau client"; | 29 | static public $nouveau_client_text = "Nouveau client"; |
| 30 | static public $nouveau_client_entrees = ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:"]; | 30 | static public $nouveau_client_entrees = ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:"]; |
| 31 | static public $calendar_text = 'Nouvelle prestation étape 1/3 - Choisir une date'; | 31 | |
| 32 | static public $calendar = ['section2' => 'Nouvelle prestation étape 1/3 - Choisir une date', | ||
| 33 | 'section3' => 'Choisir une nouvelle date']; | ||
| 34 | |||
| 32 | static public $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; | 35 | static public $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; |
| 33 | static public $formulaire_devis_entrees = ["Tâches effectuées:", "Total main d\'oeuvre (euros):", "Détail des pièces:", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):", "Delai de livraison", "Durée de validite du devis:"]; | 36 | static public $formulaire_devis_entrees = ["Tâches effectuées:", "Total main d\'oeuvre (euros):", "Détail des pièces:", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):", "Delai de livraison", "Durée de validite du devis:"]; |
| 34 | static public $formulaire_facture_entrees = ["Tâches effectuées:", "Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Total main d\'oeuvre (euros):", "Détail des pièces:", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):", "Mode de paiement"]; | 37 | static public $formulaire_facture_entrees = ["Tâches effectuées:", "Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Total main d\'oeuvre (euros):", "Détail des pièces:", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):", "Mode de paiement"]; |
| @@ -37,13 +40,12 @@ class ZenitySetup | |||
| 37 | static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; | 40 | static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; |
| 38 | 41 | ||
| 39 | static public $modification_client = ['text' => 'Modifier une information concernant un client', | 42 | static public $modification_client = ['text' => 'Modifier une information concernant un client', |
| 40 | //'lignes' => ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:", "Client ou Prospect?"], // inutile, obtenu par $Client->getAll() | 43 | 'service' => "Modifier une prestation"]; |
| 41 | 'service' => "Modifier une prestation", | 44 | //'return' => "Retour menu principal"]; |
| 42 | 'return' => "Retour menu principal"]; | ||
| 43 | static public $modification_presta = ['text' => 'Modifier une prestation', | 45 | static public $modification_presta = ['text' => 'Modifier une prestation', |
| 44 | 'devis_facture' => "Changer ce devis en facture", | 46 | 'devis_facture' => "Changer ce devis en facture"]; |
| 45 | 'service' => "Modifier une autre prestation", | 47 | //'service' => "Modifier une autre prestation", |
| 46 | 'return' => "Retour menu précédent"]; | 48 | //'return' => "Retour menu précédent"]; |
| 47 | 49 | ||
| 48 | //~ static public $recapitulatif_text = "voici toutes les informations enregistrées"; | 50 | //~ static public $recapitulatif_text = "voici toutes les informations enregistrées"; |
| 49 | //~ static public $recapitulatif_entrees = []; | 51 | //~ static public $recapitulatif_entrees = []; |
