diff options
Diffstat (limited to 'src/sections/3_modify_data.php')
-rw-r--r-- | src/sections/3_modify_data.php | 157 |
1 files changed, 82 insertions, 75 deletions
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 | } |