summaryrefslogtreecommitdiff
path: root/src/sections/3_modify_data.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/sections/3_modify_data.php')
-rw-r--r--src/sections/3_modify_data.php170
1 files changed, 169 insertions, 1 deletions
diff --git a/src/sections/3_modify_data.php b/src/sections/3_modify_data.php
index cc95468..e16a58f 100644
--- a/src/sections/3_modify_data.php
+++ b/src/sections/3_modify_data.php
@@ -3,7 +3,175 @@
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
6function modifyData($Objet): array 6function modifyData($Client): array
7{ 7{
8 // -- partie 1: rechercher un client --
9 if($Client == null || get_class($Client) !== 'Clients') // étape sautable
10 {
11 $Client = makeObjectClient(); // = 0 ou type "Clients"
12 if(!is_object($Client) || !get_class($Client) == 'Clients')
13 {
14 echo "debug: annulation sélection client\n";
15 return [0, null]; // menu principal
16 }
17 }
18
19
20 // -- partie 2: modifier un client --
21
22 // fenêtre $ModificationClient
23 $ModificationClientMenu = new ZenityList(ZenitySetup::$modification_client['text'], []);
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
41 // modifier une valeur
42 $choix_niv2 = exec($ModificationClientMenu->get());
43 if($choix_niv2 === ZenitySetup::$modification_client['service']) // ne pas modifier le client mais une prestation
44 {
45 echo "choix: modifier une prestation\n";
46 // on passe à la suite
47 }
48 elseif($choix_niv2 === ZenitySetup::$modification_client['return']) // annuler
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 {
55 echo "choix: modifier" . $choix_niv2 . "\n";
56 $TypeDeClient = new ZenityList(ZenitySetup::$type_client_text, ZenitySetup::$type_client_entrees);
57 $input = exec($TypeDeClient->get());
58 if($input === ZenitySetup::$type_client_entrees[0])
59 {
60 echo "choix: " . $input . "\n";
61 $Client->setType('client');
62 }
63 elseif($input === ZenitySetup::$type_client_entrees[1])
64 {
65 echo "choix: " . $input . "\n";
66 $Client->setType('prospect');
67 }
68 else
69 {
70 echo "choix: annulation\n";
71 }
72 $Client->update();
73 return [3, $Client]; // menu précédent
74 }
75 elseif(is_string($choix_niv2) && $choix_niv2 != '') // modifier le client
76 {
77 echo "choix: modifier" . $choix_niv2 . "\n";
78 $ModificationClient = new ZenityEntry($choix_niv2);
79 $input = exec($ModificationClient->get());
80 if(is_string($input) && $input != '')
81 {
82 $Client->getSetterAndSet($choix_niv2, $input);
83 $Client->update();
84
85 // mettre à jour les documents
86
87 }
88 else
89 {
90 echo "choix: annulation\n";
91 }
92 return [3, $Client]; // menu précédent
93 }
94 else // annuler
95 {
96 echo "annulation: retour au menu principal\n";
97 return [0, null]; // menu principal
98 }
99
100
101 // -- partie 3: rechercher une prestation --
102 $Presta = getServices($Client); // = 0 ou type "Prestations"
103 if(!is_object($Presta) || !get_class($Presta) == 'Prestations')
104 {
105 echo "debug: annulation sélection client\n";
106 return [3, $Client]; // menu précédent
107 }
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())
128 {
129 case 'facture':
130 $PrestaDetails = new DevisFactures('factures');
131 break;
132
133 case 'devis':
134 $PrestaDetails = new DevisFactures('devis');
135 break;
136 case 'cesu':
137 $PrestaDetails = new CESU();
138 break;
139 case 'location':
140 $PrestaDetails = new Locations();
141 break;
142 }
143 if(isset($PrestaDetails))
144 {
145 $PrestaDetails->setIDPresta($Presta->getID());
146 $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta());
147 $presta_data = $PrestaDetails->getAllWithWindowFields();
148 var_dump($presta_data);
149 foreach($presta_data as $key => $value)
150 {
151 $entrees[$i][] = $key;
152 $entrees[$i][] = $value;
153 $i++;
154 }
155 }
156
157 if($Presta->getTypePresta() === 'devis')
158 {
159 $entrees[$i][] = ZenitySetup::$modification_presta['devis_facture']; // option changer le devis en facture
160 $entrees[$i][] = '';
161 $i++;
162 }
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
8 return [0, null]; // menu principal 176 return [0, null]; // menu principal
9} 177}