From 45f1b99a1060ee43deb6055faef1f8b16b5d80a2 Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 1 Sep 2023 12:00:23 +0200 Subject: =?UTF-8?q?section=203=20bient=C3=B4t=20termin=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/dev.sqlite | Bin 36864 -> 36864 bytes src/files.php | 14 ++++ src/functions.php | 12 ---- src/main.php | 2 +- src/main_loop.php | 108 ++++++++++++++++++++++++++++ src/model/Clients.php | 2 +- src/model/DevisFactures.php | 66 +++++++++++++++-- src/model/Prestations.php | 54 ++++++++++++-- src/sections/2_service.php | 23 +----- src/sections/3-1_windows.php | 70 ++++++++++++++++++ src/sections/3_modify_data.php | 157 +++++++++++++++++++++-------------------- src/sections/main_loop.php | 108 ---------------------------- src/view/ZenitySetup.php | 16 +++-- 13 files changed, 396 insertions(+), 236 deletions(-) create mode 100644 src/main_loop.php create mode 100644 src/sections/3-1_windows.php delete mode 100644 src/sections/main_loop.php diff --git a/data/dev.sqlite b/data/dev.sqlite index 61eb65d..07c5233 100644 Binary files a/data/dev.sqlite and b/data/dev.sqlite 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) unlink($pdf_path . $basename . '.aux'); unlink($pdf_path . $basename . '.log'); } + +function makeTexAndPdf(Object $Object) +{ + if(get_class($Object) !== 'EnveloppeVersoLatex') + { + makeFolder($Object->getLatexPath()); + makeFolder($Object->getPdfPath()); + } + makeFile($Object->getLatexPath(), $Object->getFileName(), $Object->getLatex()); // fichier .tex + latexToPdf($Object->getLatexPath(), $Object->getFileName(), $Object->getPdfPath()); // fichier .pdf avec pdflatex +} + +//~ function removeFile(Object $Object) +//~ {} 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) return $PrestaList[$input]; } } - - -function makeTexAndPdf(Object $Object) -{ - if(get_class($Object) !== 'EnveloppeVersoLatex') - { - makeFolder($Object->getLatexPath()); - makeFolder($Object->getPdfPath()); - } - makeFile($Object->getLatexPath(), $Object->getFileName(), $Object->getLatex()); // fichier .tex - latexToPdf($Object->getLatexPath(), $Object->getFileName(), $Object->getPdfPath()); // fichier .pdf avec pdflatex -} 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 // action !! -require('sections/main_loop.php'); +require('main_loop.php'); diff --git a/src/main_loop.php b/src/main_loop.php new file mode 100644 index 0000000..f68c251 --- /dev/null +++ b/src/main_loop.php @@ -0,0 +1,108 @@ +get()); + } + else + { + $choix_niv1 = ''; + } + + // comparaison du retour de $MenuPrincipal->get() avec les noms des entrées du même menu + + // -- SECTION 1: Clients et prospects -- + if($choix_niv1 === ZenitySetup::$menu_principal_entrees[0] || $section[0] === 1) + { + echo("choix: ". ZenitySetup::$menu_principal_entrees[0] . "\n"); + $section = newCustomer(); + } + + // -- SECTION 2: Prestations et devis -- + elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[1] || $section[0] === 2) + { + echo("choix: ". ZenitySetup::$menu_principal_entrees[1] . "\n"); + $section = newService($section[1]); // $section[1] vaut un type Clients ou null + } + + // -- SECTION 3: Modifier un enregistrement -- + elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[2] || $section[0] === 3) + { + echo("choix: " . ZenitySetup::$menu_principal_entrees[2] . "\n"); + $section = modifyData($section[1]); // $section[1] vaut un type Clients ou null + } + + // -- SECTION 4: Consulter, Imprimer un document -- + elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[3] || $section[0] === 4) // = Imprimer un document + { + echo("choix: ". ZenitySetup::$menu_principal_entrees[3] . "\n"); + $section = getOrPrintDocument(); + } + + // -- SECTION 5: Consulter/analyser les données -- + elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[4] || $section[0] === 5) + { + echo("choix: ". ZenitySetup::$menu_principal_entrees[4] . "\n"); + // quel affichage? des tableaux avec zenity? LaTeX? une page web? un autre outil servant à faire des tableaux et graphiques + } + + // -- SECTION 6: Supports de communication -- + elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[5] || $section[0] === 6) // = Communication + { + echo("choix: ". ZenitySetup::$menu_principal_entrees[5] . "\n"); + $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication_text, ZenitySetup::$menu_communication_entrees); + $choix_niv2 = exec($MenuCommunication->get()); + if($choix_niv2 === ZenitySetup::$menu_communication_entrees[0]) // = Flyer (nécessite gimp) + { + exec(windowAppCommand($image_editor, $flyer)); + } + elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[1]) // = Carte de visite (nécessite scribus) + { + exec(windowAppCommand($publishing, $business_card)); + } + elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[2]) // = Explorateur de fichiers + { + exec(windowAppCommand($file_explorer, $pub)); + } + else + { + // retour menu principal + } + } + + // -- SECTION 7: BDD -- + elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[6] || $section[0] === 7) // = Base de données + { + echo("choix: ". ZenitySetup::$menu_principal_entrees[6] . "\n"); + if($sqlitebrowser_enable) + { + exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path)); + } + else + { + exec($x_term_command . ' ' . $sqlite_cli . ' ' . Config::$db_path); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite + } + } + + // arrêt + else + { + $main_loop = false; + } +} 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 "À propos:" => $this->apropos, "Client ou Prospect?" => $this->type]; } - public function getSetterAndSet(string $entry, string $input) + public function set(string $entry, string $input) { switch($entry) { 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 } public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) { + $taches = ["Tâches:" => $this->taches]; $champs_communs = [ - "Tâches:" => $this->taches, - "PC:" => $this->machine, - "OS:" => $this->OS, - "Données:" => $this->donnees, - "Clés de licences:" => $this->cles_licences, "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, "Pièces" => $this->pieces, "Total des pièces" => $this->total_pieces, @@ -42,7 +38,13 @@ class DevisFactures extends Model if($this->table === 'factures') { - return ["Numéro facture:" => $this->ID] + $champs_communs; + $champs_facture = [ + "PC:" => $this->machine, + "OS:" => $this->OS, + "Données:" => $this->donnees, + "Clés de licences:" => $this->cles_licences]; + + return $taches + $champs_facture + $champs_communs; } elseif($this->table === 'devis') { @@ -51,15 +53,65 @@ class DevisFactures extends Model "Durée de validité" => $this->validite_devis, "Devis signé?" => $this->signature_devis]; - return ["Numéro devis:" => $this->ID] + $champs_communs + $champs_devis; + return $champs_communs + $champs_devis; } else { return []; } } + public function set(string $entry, string $input) + { + switch($entry) + { + case "Tâches:": + $this->setTaches($input); + break; + case "PC:": + $this->setMachine($input); + break; + case "OS:": + $this->setOS($input); + break; + case "Données:": + $this->setDonnees($input); + break; + case "Clés de licences:": + $this->setClesLicences($input); + break; + case "Total Main d'oeuvre:": + $this->setTotalMainDOeuvre($input); + break; + case "Pièces:": + $this->setPieces($input); + break; + case "Total des pièces:": + $this->setTotalPieces($input); + break; + case "Déplacement:": + $this->setDeplacement($input); + break; + case "Total HT:": + $this->setTotalHT($input); + break; + case "Delai de livraison:": + $this->setDelaiLivraison($input); + break; + case "Durée de validité:": + $this->setValiditedevis($input); + break; + case "Devis signé?:": + $this->setSignatureDevis($input); + break; + } + } // setters + //~ public function setID(int $value = 0) + //~ { + //~ $this->ID = $value; + //~ return($this); + //~ } public function setIDPresta(int $value) { $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 protected $type_presta = ''; protected $mode_paiement = ''; protected $commentaires = ''; + //protected $numero_presta = 0; public function __construct(int $ID_client) { @@ -57,14 +58,33 @@ class Prestations extends Model return [ "Numéro prestation:" => end($code_presta_tableau), // dernière case "Date:" => $Date->getDate(), - "Type de Presta:" => $this->type_presta, + //"Type de Presta:" => $this->type_presta, // choix impossible pour le moment "Mode de paiement:" => $this->mode_paiement, "Commentaires:" => $this->commentaires]; } + public function set(string $entry, string $input) + { + switch($entry) + { + case "Numéro prestation:": + $this->setNumeroPresta($input); + break; + //~ case "Date:": // inutile, setDate() est appelé directement après choix fenêtre calendrier + //~ $this->setDate($input); + //~ break; + //~ case "Type de Presta:": // choix impossible pour le moment + //~ $this->setTypePresta($input); + //~ break; + case "Mode de paiement:": + $this->setModePaiement($input); + break; + case "Commentaires:": + $this->setCommentaires($input); + break; + } + } // setters - //~ public function setID() -> dans le trait ModelChildren - public function setIDClient(int $value) { $this->ID_client = $value; @@ -80,9 +100,20 @@ class Prestations extends Model $this->code_presta = $value; return $this; } - public function setDate(int $value) + public function setDate($value, bool $set_code_presta = false) // attend un timestamp { - $this->date = $value; + $this->date = (int) $value; + + if($set_code_presta) + { + $code_presta_tableau = explode('-', $this->code_presta); + $Date = new Dates($value); + $code_presta_tableau[0] = $Date->getYear(); + $code_presta_tableau[1] = $Date->getMonth(); + $code_presta_tableau[2] = $Date->getDay(); + $this->code_presta = implode('-', $code_presta_tableau); + } + return $this; } public function setTypePresta(string $value) @@ -100,6 +131,14 @@ class Prestations extends Model $this->commentaires = $value; return $this; } + public function setNumeroPresta($value) + { + // modifier le code presta, on pourrait aussi utiliser une regex + $code_presta_tableau = explode('-', $this->code_presta); + $code_presta_tableau[count($code_presta_tableau) - 1] = (int) $value; + $this->code_presta = implode('-', $code_presta_tableau); + return $this; + } // code client = année-mois-jour-codeclient-typedepresta-combientièmefois public function makeCodePresta(Dates $Date, string $code_client) @@ -112,3 +151,8 @@ class Prestations extends Model $this->code_presta = implode('-', $array_code); } } + +class CodePresta extends Prestations +{ + protected $numero_presta; +} 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 { // fenêtres $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement_text, ZenitySetup::$menu_enregistrement_entrees); - $Calendrier = new ZenityCalendar(ZenitySetup::$calendar_text); + $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section2']); $FormulaireDevis = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_devis_entrees); $FormulaireFacture = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_facture_entrees); $FormulaireCesu = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_cesu_entrees); $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_location_entrees); $CommentairePrestation = new ZenityEntry(ZenitySetup::$commentaire_prestation_text); //$Recapitulatif = new ZenityList(ZenitySetup::$recapitulatif_text, ZenitySetup::$recapitulatif_entrees); // tableau à multiples colonnes - //$QuestionModifierPrestation = new ZenityQuestion(ZenitySetup::$question_modification_text); $FinSection2 = new ZenityList(ZenitySetup::$fin_section_2_text, ZenitySetup::$fin_section_2_entrees); @@ -178,31 +177,15 @@ function newService($Client): array // $Client est un Client ou null // fabrique d'objets (sans connaître les noms des classes) $EnveloppeRecto = Latex::makeInstance('enveloppe_recto'); $EnveloppeVerso = Latex::makeInstance('enveloppe_verso'); - $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location + $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // retourne objet ou null // génération du latex $EnveloppeRecto->setData($Client); - //~ $EnveloppeRecto->setFileName($Client->getCodeClient() . '.tex'); - //~ $EnveloppeRecto->setLatexPath(Config::$latex_path . 'enveloppes_recto/'); - //~ $EnveloppeRecto->setPdfPath(Config::$pdf_path . 'enveloppes_recto/'); - //~ $EnveloppeRecto->spacesInPostCode(); $EnveloppeRecto->makeLatex(); - - //~ $EnveloppeVerso->setFileName('enveloppe_verso.tex'); - //~ $EnveloppeVerso->setLatexPath(Config::$latex_path); - //~ $EnveloppeVerso->setPdfPath(Config::$pdf_path); $EnveloppeVerso->makeLatex(); - if($DocumentPresta !== null) { $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); - //~ $DocumentPresta->setData($Client); - //~ $DocumentPresta->setData($Presta); - //~ $DocumentPresta->makeDateInstance($Presta->getDate()); // paramètre = int - //~ $DocumentPresta->setFileName($Presta->getCodePresta() . '.tex'); - //~ $DocumentPresta->setLatexPath(Config::$latex_path . $DocumentPresta->getYear() . '/'); - //~ $DocumentPresta->setPdfPath(Config::$pdf_path . $DocumentPresta->getYear() . '/'); - //~ $DocumentPresta->setData($PrestaDetails); $DocumentPresta->makeLatex(); } @@ -236,7 +219,7 @@ function newService($Client): array // $Client est un Client ou null } elseif($choix_niv2 === ZenitySetup::$fin_section_2_entrees[1]) { - return [3, null]; // section 3: modifyData() + return [3, $Client]; // section 3: modifyData() } elseif($choix_niv2 === ZenitySetup::$fin_section_2_entrees[2]) { 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 @@ +getAllWithWindowFields(); + //var_dump($client_data); + foreach($client_data as $key => $value) + { + $entries[$i][] = $key; + $entries[$i][] = $value; + $i++; + } + $entries[$i][] = ZenitySetup::$modification_client['service']; + $entries[$i][] = ''; + //~ $i++; + //~ $entries[$i][] = ZenitySetup::$modification_client['return']; + //~ $entries[$i][] = ''; + $ModifyCustomer->setListRows($entries, 2, 2.5); + + return $ModifyCustomer; +} + +function makeModifyServiceWindow(Prestations $Service, $ServiceDetails = null): ZenityList +{ + $ModifyService = new ZenityList(ZenitySetup::$modification_presta['text'], []); + $entrees = []; + $i = 0; + + $presta_data = $Service->getAllWithWindowFields(); + //var_dump($presta_data); + foreach($presta_data as $key => $value) + { + $entrees[$i][] = $key; + $entrees[$i][] = $value; + $i++; + } + + if(is_object($ServiceDetails)) + { + $presta_data = $ServiceDetails->getAllWithWindowFields(); + //var_dump($presta_data); + foreach($presta_data as $key => $value) + { + $entrees[$i][] = $key; + $entrees[$i][] = $value; + $i++; + } + } + + if($Service->getTypePresta() === 'devis') + { + $entrees[$i][] = ZenitySetup::$modification_presta['devis_facture']; // option changer le devis en facture + $entrees[$i][] = ''; + //~ $i++; + } + //~ $entrees[$i][] = ZenitySetup::$modification_presta['service']; + //~ $entrees[$i][] = ''; + //~ $i++; + //~ $entrees[$i][] = ZenitySetup::$modification_presta['return']; + //~ $entrees[$i][] = ''; + $ModifyService->setListRows($entrees, 2, 2.5); + + return $ModifyService; +} 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 @@ // // -- SECTION 3: Modifier un client, un prospect, une prestation, un devis -- +require('3-1_windows.php'); + function modifyData($Client): array { // -- partie 1: rechercher un client -- @@ -19,38 +21,16 @@ function modifyData($Client): array // -- partie 2: modifier un client -- - // fenêtre $ModificationClient - $ModificationClientMenu = new ZenityList(ZenitySetup::$modification_client['text'], []); - $entrees = []; - $i = 0; - $client_data = $Client->getAllWithWindowFields(); - //var_dump($client_data); - foreach($client_data as $key => $value) - { - $entrees[$i][] = $key; - $entrees[$i][] = $value; - $i++; - } - $entrees[$i][] = ZenitySetup::$modification_client['service']; - $entrees[$i][] = ''; - $i++; - $entrees[$i][] = ZenitySetup::$modification_client['return']; - $entrees[$i][] = ''; - $ModificationClientMenu->setListRows($entrees, 2, 2.5); + // fenêtre + $ModificationClientMenu = makeModifyCustomerWindow($Client); - // modifier une valeur $choix_niv2 = exec($ModificationClientMenu->get()); if($choix_niv2 === ZenitySetup::$modification_client['service']) // ne pas modifier le client mais une prestation { echo "choix: modifier une prestation\n"; // on passe à la suite } - elseif($choix_niv2 === ZenitySetup::$modification_client['return']) // annuler - { - echo "choix: retour au menu principal\n"; - return [0, null]; // menu principal - } - elseif($choix_niv2 === "Client ou Prospect?") // modifier le client + elseif($choix_niv2 === "Client ou Prospect?") // modifier type de client { echo "choix: modifier" . $choix_niv2 . "\n"; $TypeDeClient = new ZenityList(ZenitySetup::$type_client_text, ZenitySetup::$type_client_entrees); @@ -72,18 +52,21 @@ function modifyData($Client): array $Client->update(); return [3, $Client]; // menu précédent } - elseif(is_string($choix_niv2) && $choix_niv2 != '') // modifier le client + elseif(is_string($choix_niv2) && $choix_niv2 != '') // modifier une valeur { echo "choix: modifier" . $choix_niv2 . "\n"; $ModificationClient = new ZenityEntry($choix_niv2); $input = exec($ModificationClient->get()); if(is_string($input) && $input != '') { - $Client->getSetterAndSet($choix_niv2, $input); + $Client->set($choix_niv2, $input); $Client->update(); - // mettre à jour les documents - + // mettre à jour les documents (il faudrait modifier tous les documents!!) + $EnveloppeRecto = Latex::makeInstance('enveloppe_recto'); + $EnveloppeRecto->setData($Client); + $EnveloppeRecto->makeLatex(); + makeTexAndPdf($EnveloppeRecto); } else { @@ -105,25 +88,6 @@ function modifyData($Client): array echo "debug: annulation sélection client\n"; return [3, $Client]; // menu précédent } - - - // -- partie 4: modifier une prestation -- - - // fenêtre $ModificationPresta - $ModificationPrestaMenu = new ZenityList(ZenitySetup::$modification_presta['text'], []); - $entrees = []; - $i = 0; - - $presta_data = $Presta->getAllWithWindowFields(); - var_dump($presta_data); - foreach($presta_data as $key => $value) - { - $entrees[$i][] = $key; - $entrees[$i][] = $value; - $i++; - } - - // infos des sous-tables 'facture', 'devis', etc switch($Presta->getTypePresta()) { case 'facture': @@ -140,38 +104,81 @@ function modifyData($Client): array $PrestaDetails = new Locations(); break; } - if(isset($PrestaDetails)) + $PrestaDetails->setIDPresta($Presta->getID()); + $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); + + + // -- partie 4: modifier une prestation -- + + // fenêtre + $ModificationPrestaMenu = makeModifyServiceWindow($Presta, $PrestaDetails); + $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section3']); + + $choix_niv3 = exec($ModificationPrestaMenu->get()); + if($choix_niv3 === ZenitySetup::$modification_presta['devis_facture']) // devis -> facture + { + echo "choix: changer un devis en facture\n"; + return [3, $Client]; // menu "client" + } + elseif($choix_niv3 === 'Date:') + { + $Date = new Dates(exec($Calendrier->get())); // exec() renvoie soit une chaîne soit un false + if($Date->getDate() == '') // on n'a pas cliqué sur "annuler" + { + echo "debug: annulation à la saisie d'une date\n"; + //return [3, $Client]; // menu principal + } + else + { + // mettre à jour la base de données + $Presta->setDate($Date->getTimestamp(), true); // un entier pour la BDD, "true" pour modifier le code_presta + $Presta->update(); + + // mettre à jour les documents + $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location + $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); + $DocumentPresta->makeLatex(); + makeTexAndPdf($DocumentPresta); + } + + return [3, $Client]; // menu précédent + } + //~ elseif($choix_niv3 === 'Type de Presta:') // choix impossible pour le moment + //~ { + //~ echo "choix: Impossible de modifier le type de prestation\n"; + //~ return [3, $Client]; // menu "client" + //~ } + elseif(is_string($choix_niv3) && $choix_niv3 != '') // modifier une valeur { - $PrestaDetails->setIDPresta($Presta->getID()); - $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); - $presta_data = $PrestaDetails->getAllWithWindowFields(); - var_dump($presta_data); - foreach($presta_data as $key => $value) + echo "choix: modifier" . $choix_niv3 . "\n"; + $ModificationPrestaForm = new ZenityEntry($choix_niv3); + $input = exec($ModificationPrestaForm->get()); + if(is_string($input) && $input != '') { - $entrees[$i][] = $key; - $entrees[$i][] = $value; - $i++; + $Presta->set($choix_niv3, $input); + $PrestaDetails->set($choix_niv3, $input); + + // mettre à jour la base de données + $Presta->update(); + $PrestaDetails->update(); + + // mettre à jour les documents + $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location + $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); + $DocumentPresta->makeLatex(); + makeTexAndPdf($DocumentPresta); + } + else + { + echo "choix: annulation\n"; } + return [3, $Client]; // menu précédent } - - if($Presta->getTypePresta() === 'devis') + else // annuler { - $entrees[$i][] = ZenitySetup::$modification_presta['devis_facture']; // option changer le devis en facture - $entrees[$i][] = ''; - $i++; + echo "annulation: retour au menu précédent\n"; + return [3, $Client]; // menu précédent } - $entrees[$i][] = ZenitySetup::$modification_presta['service']; - $entrees[$i][] = ''; - $i++; - $entrees[$i][] = ZenitySetup::$modification_presta['return']; - $entrees[$i][] = ''; - $ModificationPrestaMenu->setListRows($entrees, 2, 2.5); - - // modifier une valeur - $choix_niv3 = exec($ModificationPrestaMenu->get()); - var_dump($choix_niv3); - - // si changement de type de prestation autre que de devis à facture, ça devient compliqué! - return [0, null]; // menu principal + //return [0, null]; // menu principal } diff --git a/src/sections/main_loop.php b/src/sections/main_loop.php deleted file mode 100644 index f68c251..0000000 --- a/src/sections/main_loop.php +++ /dev/null @@ -1,108 +0,0 @@ -get()); - } - else - { - $choix_niv1 = ''; - } - - // comparaison du retour de $MenuPrincipal->get() avec les noms des entrées du même menu - - // -- SECTION 1: Clients et prospects -- - if($choix_niv1 === ZenitySetup::$menu_principal_entrees[0] || $section[0] === 1) - { - echo("choix: ". ZenitySetup::$menu_principal_entrees[0] . "\n"); - $section = newCustomer(); - } - - // -- SECTION 2: Prestations et devis -- - elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[1] || $section[0] === 2) - { - echo("choix: ". ZenitySetup::$menu_principal_entrees[1] . "\n"); - $section = newService($section[1]); // $section[1] vaut un type Clients ou null - } - - // -- SECTION 3: Modifier un enregistrement -- - elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[2] || $section[0] === 3) - { - echo("choix: " . ZenitySetup::$menu_principal_entrees[2] . "\n"); - $section = modifyData($section[1]); // $section[1] vaut un type Clients ou null - } - - // -- SECTION 4: Consulter, Imprimer un document -- - elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[3] || $section[0] === 4) // = Imprimer un document - { - echo("choix: ". ZenitySetup::$menu_principal_entrees[3] . "\n"); - $section = getOrPrintDocument(); - } - - // -- SECTION 5: Consulter/analyser les données -- - elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[4] || $section[0] === 5) - { - echo("choix: ". ZenitySetup::$menu_principal_entrees[4] . "\n"); - // quel affichage? des tableaux avec zenity? LaTeX? une page web? un autre outil servant à faire des tableaux et graphiques - } - - // -- SECTION 6: Supports de communication -- - elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[5] || $section[0] === 6) // = Communication - { - echo("choix: ". ZenitySetup::$menu_principal_entrees[5] . "\n"); - $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication_text, ZenitySetup::$menu_communication_entrees); - $choix_niv2 = exec($MenuCommunication->get()); - if($choix_niv2 === ZenitySetup::$menu_communication_entrees[0]) // = Flyer (nécessite gimp) - { - exec(windowAppCommand($image_editor, $flyer)); - } - elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[1]) // = Carte de visite (nécessite scribus) - { - exec(windowAppCommand($publishing, $business_card)); - } - elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[2]) // = Explorateur de fichiers - { - exec(windowAppCommand($file_explorer, $pub)); - } - else - { - // retour menu principal - } - } - - // -- SECTION 7: BDD -- - elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[6] || $section[0] === 7) // = Base de données - { - echo("choix: ". ZenitySetup::$menu_principal_entrees[6] . "\n"); - if($sqlitebrowser_enable) - { - exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path)); - } - else - { - exec($x_term_command . ' ' . $sqlite_cli . ' ' . Config::$db_path); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite - } - } - - // arrêt - else - { - $main_loop = false; - } -} 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 static public $resultats_recherche_presta_text = "Sélectionner une prestation"; static public $nouveau_client_text = "Nouveau client"; static public $nouveau_client_entrees = ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:"]; - static public $calendar_text = 'Nouvelle prestation étape 1/3 - Choisir une date'; + + static public $calendar = ['section2' => 'Nouvelle prestation étape 1/3 - Choisir une date', + 'section3' => 'Choisir une nouvelle date']; + static public $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; 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:"]; 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 static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; static public $modification_client = ['text' => 'Modifier une information concernant un client', - //'lignes' => ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:", "Client ou Prospect?"], // inutile, obtenu par $Client->getAll() - 'service' => "Modifier une prestation", - 'return' => "Retour menu principal"]; + 'service' => "Modifier une prestation"]; + //'return' => "Retour menu principal"]; static public $modification_presta = ['text' => 'Modifier une prestation', - 'devis_facture' => "Changer ce devis en facture", - 'service' => "Modifier une autre prestation", - 'return' => "Retour menu précédent"]; + 'devis_facture' => "Changer ce devis en facture"]; + //'service' => "Modifier une autre prestation", + //'return' => "Retour menu précédent"]; //~ static public $recapitulatif_text = "voici toutes les informations enregistrées"; //~ static public $recapitulatif_entrees = []; -- cgit v1.2.3