summaryrefslogtreecommitdiff
path: root/src/sections
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2023-09-01 12:00:23 +0200
committerpolo <ordipolo@gmx.fr>2023-09-01 12:00:23 +0200
commit45f1b99a1060ee43deb6055faef1f8b16b5d80a2 (patch)
tree2be0c73b839b220433280daaf29d41644ecd4851 /src/sections
parent6f4cc3afffde36a13618458ffda72e6104624f36 (diff)
downloadAppliGestionPHP-45f1b99a1060ee43deb6055faef1f8b16b5d80a2.zip
section 3 bientôt terminée
Diffstat (limited to 'src/sections')
-rw-r--r--src/sections/2_service.php23
-rw-r--r--src/sections/3-1_windows.php70
-rw-r--r--src/sections/3_modify_data.php157
-rw-r--r--src/sections/main_loop.php108
4 files changed, 155 insertions, 203 deletions
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
6function 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
29function 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
6require('3-1_windows.php');
7
6function modifyData($Client): array 8function 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/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 @@
1<?php
2// src/sections/main_loop.php
3//
4// -- BOUCLE PRINCIPALE --
5
6require('sections/1_customer.php');
7require('sections/2_service.php');
8require('sections/3_modify_data.php');
9require('sections/4_get_document.php');
10
11$main_loop = true;
12$section = [0, null]; // [code de retour, éventuelles données]
13
14while($main_loop)
15{
16 // -- MENU PRINCIPAL (niveau 1) --
17 if($section[0] === 0)
18 {
19 echo("Menu principal\n");
20 $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees);
21 $choix_niv1 = exec($MenuPrincipal->get());
22 }
23 else
24 {
25 $choix_niv1 = '';
26 }
27
28 // comparaison du retour de $MenuPrincipal->get() avec les noms des entrées du même menu
29
30 // -- SECTION 1: Clients et prospects --
31 if($choix_niv1 === ZenitySetup::$menu_principal_entrees[0] || $section[0] === 1)
32 {
33 echo("choix: ". ZenitySetup::$menu_principal_entrees[0] . "\n");
34 $section = newCustomer();
35 }
36
37 // -- SECTION 2: Prestations et devis --
38 elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[1] || $section[0] === 2)
39 {
40 echo("choix: ". ZenitySetup::$menu_principal_entrees[1] . "\n");
41 $section = newService($section[1]); // $section[1] vaut un type Clients ou null
42 }
43
44 // -- SECTION 3: Modifier un enregistrement --
45 elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[2] || $section[0] === 3)
46 {
47 echo("choix: " . ZenitySetup::$menu_principal_entrees[2] . "\n");
48 $section = modifyData($section[1]); // $section[1] vaut un type Clients ou null
49 }
50
51 // -- SECTION 4: Consulter, Imprimer un document --
52 elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[3] || $section[0] === 4) // = Imprimer un document
53 {
54 echo("choix: ". ZenitySetup::$menu_principal_entrees[3] . "\n");
55 $section = getOrPrintDocument();
56 }
57
58 // -- SECTION 5: Consulter/analyser les données --
59 elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[4] || $section[0] === 5)
60 {
61 echo("choix: ". ZenitySetup::$menu_principal_entrees[4] . "\n");
62 // quel affichage? des tableaux avec zenity? LaTeX? une page web? un autre outil servant à faire des tableaux et graphiques
63 }
64
65 // -- SECTION 6: Supports de communication --
66 elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[5] || $section[0] === 6) // = Communication
67 {
68 echo("choix: ". ZenitySetup::$menu_principal_entrees[5] . "\n");
69 $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication_text, ZenitySetup::$menu_communication_entrees);
70 $choix_niv2 = exec($MenuCommunication->get());
71 if($choix_niv2 === ZenitySetup::$menu_communication_entrees[0]) // = Flyer (nécessite gimp)
72 {
73 exec(windowAppCommand($image_editor, $flyer));
74 }
75 elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[1]) // = Carte de visite (nécessite scribus)
76 {
77 exec(windowAppCommand($publishing, $business_card));
78 }
79 elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[2]) // = Explorateur de fichiers
80 {
81 exec(windowAppCommand($file_explorer, $pub));
82 }
83 else
84 {
85 // retour menu principal
86 }
87 }
88
89 // -- SECTION 7: BDD --
90 elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[6] || $section[0] === 7) // = Base de données
91 {
92 echo("choix: ". ZenitySetup::$menu_principal_entrees[6] . "\n");
93 if($sqlitebrowser_enable)
94 {
95 exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path));
96 }
97 else
98 {
99 exec($x_term_command . ' ' . $sqlite_cli . ' ' . Config::$db_path); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite
100 }
101 }
102
103 // arrêt
104 else
105 {
106 $main_loop = false;
107 }
108}