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 --- 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 ---------------------------- 4 files changed, 155 insertions(+), 203 deletions(-) create mode 100644 src/sections/3-1_windows.php delete mode 100644 src/sections/main_loop.php (limited to 'src/sections') 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; - } -} -- cgit v1.2.3