diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Dates.php | 12 | ||||
-rw-r--r-- | src/Latex.php | 53 | ||||
-rw-r--r-- | src/functions.php | 199 | ||||
-rwxr-xr-x | src/main.php | 3 | ||||
-rw-r--r-- | src/model/CESU.php | 12 | ||||
-rw-r--r-- | src/model/Clients.php | 49 | ||||
-rw-r--r-- | src/model/DevisFactures.php | 34 | ||||
-rw-r--r-- | src/model/Locations.php | 18 | ||||
-rw-r--r-- | src/model/Model.php | 25 | ||||
-rw-r--r-- | src/model/Prestations.php | 26 | ||||
-rw-r--r-- | src/model/StructTablesDB.php | 2 | ||||
-rw-r--r-- | src/model/traits.php | 13 | ||||
-rw-r--r-- | src/sections/1_customer.php | 25 | ||||
-rw-r--r-- | src/sections/2_service.php | 62 | ||||
-rw-r--r-- | src/sections/3_modify_data.php | 170 | ||||
-rw-r--r-- | src/sections/4_get_document.php | 2 | ||||
-rw-r--r-- | src/sections/main_loop.php | 30 | ||||
-rw-r--r-- | src/view/Zenity.php | 30 | ||||
-rw-r--r-- | src/view/ZenitySetup.php | 28 |
19 files changed, 549 insertions, 244 deletions
diff --git a/src/Dates.php b/src/Dates.php index 2fe93cb..d7ed6c7 100644 --- a/src/Dates.php +++ b/src/Dates.php | |||
@@ -59,8 +59,7 @@ class Dates | |||
59 | $input = $this->dashOrSlash($input); // formate pour strtotime() | 59 | $input = $this->dashOrSlash($input); // formate pour strtotime() |
60 | $this->setDayMonthYear($input); | 60 | $this->setDayMonthYear($input); |
61 | 61 | ||
62 | //~ if(checkdate($splitedDate[0], $splitedDate[1], $splitedDate[2])) | 62 | if(checkdate($this->month, $this->day, $this->year)) // checkdate() veut un format américain |
63 | if(checkdate($this->day, $this->month, $this->year)) | ||
64 | { | 63 | { |
65 | $this->date = $input; | 64 | $this->date = $input; |
66 | $this->timestamp = strtotime($input); // date (string) -> timestamp (int) | 65 | $this->timestamp = strtotime($input); // date (string) -> timestamp (int) |
@@ -87,13 +86,18 @@ class Dates | |||
87 | 86 | ||
88 | if(self::$date_format === 'euro') | 87 | if(self::$date_format === 'euro') |
89 | { | 88 | { |
89 | $this->day = $splitedDate[0]; | ||
90 | $this->month = $splitedDate[1]; | ||
91 | } | ||
92 | elseif(self::$date_format === 'usa') | ||
93 | { | ||
90 | $this->day = $splitedDate[1]; | 94 | $this->day = $splitedDate[1]; |
91 | $this->month = $splitedDate[0]; | 95 | $this->month = $splitedDate[0]; |
92 | } | 96 | } |
93 | else | 97 | else |
94 | { | 98 | { |
95 | $this->day = $splitedDate[0]; | 99 | echo("Le fichier config.php comporte une erreur. La variable $date_format doit avoir pour valeur 'euro' ou 'usa'"); |
96 | $this->month = $splitedDate[1]; | 100 | die(); // brutal |
97 | } | 101 | } |
98 | $this->year = $splitedDate[2]; | 102 | $this->year = $splitedDate[2]; |
99 | } | 103 | } |
diff --git a/src/Latex.php b/src/Latex.php index 547c130..fd76f7b 100644 --- a/src/Latex.php +++ b/src/Latex.php | |||
@@ -12,21 +12,21 @@ abstract class Latex | |||
12 | protected $data = []; // données à insérer dans le template | 12 | protected $data = []; // données à insérer dans le template |
13 | protected $latex = ''; // latex pur | 13 | protected $latex = ''; // latex pur |
14 | 14 | ||
15 | static function makeLatexSubClass(string $type) | 15 | static function makeInstance(string $type) |
16 | { | 16 | { |
17 | switch($type) | 17 | switch($type) |
18 | { | 18 | { |
19 | // documents pour les clients | 19 | // documents pour les clients |
20 | case 'devis': | 20 | case 'devis': |
21 | return new DevisLatex($type); | 21 | return new DevisLatex; |
22 | case 'facture': | 22 | case 'facture': |
23 | return new FactureLatex($type); | 23 | return new FactureLatex; |
24 | case 'location': | 24 | case 'location': |
25 | return new LocationLatex($type); | 25 | return new LocationLatex; |
26 | case 'enveloppe_recto': | 26 | case 'enveloppe_recto': |
27 | return new EnveloppeRectoLatex($type); | 27 | return new EnveloppeRectoLatex; |
28 | case 'enveloppe_verso': | 28 | case 'enveloppe_verso': |
29 | return new EnveloppeVersoLatex($type); | 29 | return new EnveloppeVersoLatex; |
30 | // pas de document | 30 | // pas de document |
31 | case 'cesu': | 31 | case 'cesu': |
32 | return null; | 32 | return null; |
@@ -41,10 +41,8 @@ abstract class Latex | |||
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
44 | public function __construct(string $type) | 44 | //~ public function __construct() |
45 | { | 45 | //~ {} |
46 | $this->type = $type; | ||
47 | } | ||
48 | 46 | ||
49 | public function makeLatex() | 47 | public function makeLatex() |
50 | { | 48 | { |
@@ -104,10 +102,8 @@ abstract class PrestaLatex extends Latex | |||
104 | { | 102 | { |
105 | protected $Date; // sera un type "Dates" | 103 | protected $Date; // sera un type "Dates" |
106 | 104 | ||
107 | //~ public function __construct(string $type) | 105 | //~ public function __construct() |
108 | //~ { | 106 | //~ {} |
109 | //~ $this->type = $type; | ||
110 | //~ } | ||
111 | 107 | ||
112 | public function setData(Object $Object): self | 108 | public function setData(Object $Object): self |
113 | { | 109 | { |
@@ -158,17 +154,32 @@ abstract class PrestaLatex extends Latex | |||
158 | } | 154 | } |
159 | } | 155 | } |
160 | class DevisLatex extends PrestaLatex // extends Latex | 156 | class DevisLatex extends PrestaLatex // extends Latex |
161 | {} | 157 | { |
158 | public function __construct() | ||
159 | { | ||
160 | $this->type = 'devis'; | ||
161 | } | ||
162 | } | ||
162 | class FactureLatex extends PrestaLatex // extends Latex | 163 | class FactureLatex extends PrestaLatex // extends Latex |
163 | {} | 164 | { |
165 | public function __construct() | ||
166 | { | ||
167 | $this->type = 'facture'; | ||
168 | } | ||
169 | } | ||
164 | class LocationLatex extends PrestaLatex // extends Latex | 170 | class LocationLatex extends PrestaLatex // extends Latex |
165 | {} | 171 | { |
172 | public function __construct() | ||
173 | { | ||
174 | $this->type = 'location'; | ||
175 | } | ||
176 | } | ||
166 | 177 | ||
167 | class EnveloppeRectoLatex extends Latex | 178 | class EnveloppeRectoLatex extends Latex |
168 | { | 179 | { |
169 | public function __construct(string $type) | 180 | public function __construct() |
170 | { | 181 | { |
171 | $this->type = $type; | 182 | $this->type = 'enveloppe_recto'; |
172 | $this->latex_path = Config::$latex_path . 'enveloppes_recto/'; | 183 | $this->latex_path = Config::$latex_path . 'enveloppes_recto/'; |
173 | $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/'; | 184 | $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/'; |
174 | } | 185 | } |
@@ -188,9 +199,9 @@ class EnveloppeRectoLatex extends Latex | |||
188 | } | 199 | } |
189 | class EnveloppeVersoLatex extends Latex | 200 | class EnveloppeVersoLatex extends Latex |
190 | { | 201 | { |
191 | public function __construct(string $type) | 202 | public function __construct() |
192 | { | 203 | { |
193 | $this->type = $type; | 204 | $this->type = 'enveloppe_verso'; |
194 | $this->file_name = 'enveloppe_verso.tex'; | 205 | $this->file_name = 'enveloppe_verso.tex'; |
195 | $this->latex_path = Config::$latex_path; | 206 | $this->latex_path = Config::$latex_path; |
196 | $this->pdf_path = Config::$pdf_path; | 207 | $this->pdf_path = Config::$pdf_path; |
diff --git a/src/functions.php b/src/functions.php index f78b23d..c847403 100644 --- a/src/functions.php +++ b/src/functions.php | |||
@@ -7,9 +7,8 @@ | |||
7 | // commande pour lancer une application graphique en ouvrant un fichier | 7 | // commande pour lancer une application graphique en ouvrant un fichier |
8 | function windowAppCommand(string $app, string $path = ''): string | 8 | function windowAppCommand(string $app, string $path = ''): string |
9 | { | 9 | { |
10 | // attention, la syntaxe utilisée est la plus simple: "app fichier" | 10 | // attention, ne supporte que la syntaxe la plus simple avec un seul paramètre:"app fichier" |
11 | // ça fonctionne avec les logiciels choisis: gimp, scribus | 11 | // fonctionne avec choisis: gimp, scribus, sqlite, "l'explorateur de fichiers par défaut" |
12 | // mais ça pourrait ne pas convenir pour d'autres | ||
13 | 12 | ||
14 | $command = 'nohup ' . $app; // détache l'appli du script PHP | 13 | $command = 'nohup ' . $app; // détache l'appli du script PHP |
15 | if($path !== '') | 14 | if($path !== '') |
@@ -49,65 +48,36 @@ function enterCustomer($Client): bool | |||
49 | function makeObjectClient() | 48 | function makeObjectClient() |
50 | { | 49 | { |
51 | // fenêtres | 50 | // fenêtres |
52 | //~ $QuestionNouveauClient = new ZenityQuestion(ZenitySetup::$question_nouveau_client_text); | ||
53 | $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client_text); | 51 | $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client_text); |
54 | $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client_text, []); | 52 | $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client_text, []); |
55 | //~ $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); | ||
56 | 53 | ||
57 | $Client = new Clients; | 54 | $Client = new Clients; |
58 | 55 | ||
59 | // est ce que le client est déjà dans la base? | 56 | $input = exec($RechercheClient->get()); |
60 | //~ $client_inconnu = true; | 57 | if($input == '') |
61 | //~ if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage | 58 | { |
62 | //~ { | 59 | echo "debug: recherche annulée ou saisie vide\n"; |
63 | //~ echo "choix: recherche d'une client\n"; | 60 | return 0; |
64 | $input = exec($RechercheClient->get()); | 61 | } |
65 | if($input == '') | 62 | |
66 | { | 63 | echo "debug: recherche effectuée\n"; |
67 | echo "debug: recherche annulée ou saisie vide\n"; | 64 | $ResultatsRechercheClient->setListRows( |
68 | return 0; | 65 | searchCustomer($input, $Client), |
69 | } | 66 | count(StructTablesDB::$structureOfTables[$Client->getTable()])); // 2è paramètre = nombre de colonnes |
70 | 67 | ||
71 | echo "debug: recherche effectuée\n"; | 68 | // sélection parmi les résultats |
72 | $ResultatsRechercheClient->setListRows(searchCustomer($input, $Client), $Client->getTable()); // recherche silencieuse | 69 | $input = exec($ResultatsRechercheClient->get()); // renvoie l'ID de la table 'clients' |
73 | 70 | $ResultatsRechercheClient->cleanCommand(); | |
74 | // sélection parmi les résultats | 71 | |
75 | $input = exec($ResultatsRechercheClient->get()); // renvoie l'ID de la table 'clients' | 72 | if($input == '') |
76 | $ResultatsRechercheClient->cleanCommand(); | 73 | { |
77 | 74 | echo "debug: client pas trouvé ou pas sélectionné\n"; | |
78 | if($input == '') | 75 | return 0; |
79 | { | 76 | } |
80 | echo "debug: client pas trouvé ou pas sélectionné\n"; | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | echo "debug: client sélectionné\n"; | ||
85 | $Client->hydrate($Client->findById($input)); | ||
86 | //~ $client_inconnu = false; | ||
87 | //~ } | ||
88 | //~ else | ||
89 | //~ { | ||
90 | //~ echo "choix: nouveau client\n"; | ||
91 | //~ } | ||
92 | 77 | ||
93 | // on n'a pas cherché OU on n'a pas trouvé | 78 | echo "debug: client sélectionné\n"; |
94 | //~ if($client_inconnu) | 79 | $Client->setID($input); |
95 | //~ { | 80 | $Client->hydrate($Client->findById()); |
96 | //~ $input = exec($NouveauClient->get()); | ||
97 | //~ if($input == '') | ||
98 | //~ { | ||
99 | //~ echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; | ||
100 | //~ return 0; | ||
101 | //~ } | ||
102 | //~ if(!$Client->hydrateFromForm($input)) | ||
103 | //~ { | ||
104 | //~ // messages d'erreur dans hydrateFromForm() | ||
105 | //~ return 0; | ||
106 | //~ } | ||
107 | //~ unset($input); | ||
108 | //~ $Client->create(); | ||
109 | //~ $Client->setID(); // sans paramètre, exécute un $this->db->lastInsertId() | ||
110 | //~ } | ||
111 | 81 | ||
112 | return $Client; | 82 | return $Client; |
113 | } | 83 | } |
@@ -121,10 +91,57 @@ function searchCustomer(string $input, Clients $Client): array | |||
121 | { | 91 | { |
122 | $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre | 92 | $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre |
123 | $result = $Client->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées | 93 | $result = $Client->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées |
94 | //var_dump($result); | ||
124 | return($result); | 95 | return($result); |
125 | } | 96 | } |
126 | 97 | ||
127 | 98 | ||
99 | function getServices(Clients $Client) | ||
100 | { | ||
101 | echo "debug: recherche d'une prestation\n"; | ||
102 | |||
103 | // recherche dans la table 'prestations' avec 'ID_client' les ID des prestas | ||
104 | $Presta = new Prestations($Client->getID()); | ||
105 | $IDs = $Presta->getIDsByIdClient(); | ||
106 | unset($Presta); | ||
107 | |||
108 | // mettres toutes les données dans un tableau | ||
109 | $PrestaList = []; | ||
110 | foreach($IDs as $id) | ||
111 | { | ||
112 | $PrestaList[$id] = new Prestations($Client->getID()); // renseigne 'ID_client' | ||
113 | $PrestaList[$id]->setID($id); // ID de la prestation = clé du tableau | ||
114 | $PrestaList[$id]->hydrate($PrestaList[$id]->findById()); // données copiés de la table à l'objet | ||
115 | } | ||
116 | |||
117 | // fenêtre | ||
118 | $entrees = []; | ||
119 | foreach($PrestaList as $Presta) | ||
120 | { | ||
121 | $id = $Presta->getID(); | ||
122 | $entrees[$id][] = $id; | ||
123 | $Date = new Dates((int)$Presta->getDate()); // envoi du timestamp, (int) est là par sécurité | ||
124 | $entrees[$id][] = $Date->getDate(); | ||
125 | $entrees[$id][] = $Presta->getTypePresta(); | ||
126 | $entrees[$id][] = $Presta->getCodePresta(); | ||
127 | } | ||
128 | $ResultatsRecherchePresta = new ZenityList(ZenitySetup::$resultats_recherche_presta_text, []); | ||
129 | $ResultatsRecherchePresta->setListRows($entrees, 4); | ||
130 | |||
131 | // choix de l'utilisateur | ||
132 | $input = exec($ResultatsRecherchePresta->get()); // $input est l'ID de la prestation | ||
133 | if($input == '') | ||
134 | { | ||
135 | echo "debug: recherche annulée ou saisie vide\n"; | ||
136 | return 0; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | return $PrestaList[$input]; | ||
141 | } | ||
142 | } | ||
143 | |||
144 | |||
128 | function makeTexAndPdf(Object $Object) | 145 | function makeTexAndPdf(Object $Object) |
129 | { | 146 | { |
130 | if(get_class($Object) !== 'EnveloppeVersoLatex') | 147 | if(get_class($Object) !== 'EnveloppeVersoLatex') |
@@ -132,72 +149,6 @@ function makeTexAndPdf(Object $Object) | |||
132 | makeFolder($Object->getLatexPath()); | 149 | makeFolder($Object->getLatexPath()); |
133 | makeFolder($Object->getPdfPath()); | 150 | makeFolder($Object->getPdfPath()); |
134 | } | 151 | } |
135 | makeFile($Object->getLatexPath(), $Object->getFileName(), $Object->getLatex()); | 152 | makeFile($Object->getLatexPath(), $Object->getFileName(), $Object->getLatex()); // fichier .tex |
136 | latexToPdf($Object->getLatexPath(), $Object->getFileName(), $Object->getPdfPath()); | 153 | latexToPdf($Object->getLatexPath(), $Object->getFileName(), $Object->getPdfPath()); // fichier .pdf avec pdflatex |
137 | } | 154 | } |
138 | |||
139 | //~ function makeLatexAndPdfDocuments(Clients $Client = null, Prestations $Presta = null, $PrestaDetails = null) | ||
140 | //~ { | ||
141 | //~ $latex = ''; | ||
142 | //~ $year = ''; | ||
143 | //~ $data = []; | ||
144 | //~ $latex_path = Config::$latex_path; | ||
145 | //~ $pdf_path = Config::$pdf_path; | ||
146 | |||
147 | //~ // verso d'une enveloppe | ||
148 | //~ $latex = makeLatex('enveloppe_verso'); // pas de données transmises, elles sont dans la classe Config | ||
149 | //~ $file_name = 'enveloppe_verso.tex'; | ||
150 | //~ makeFile($latex_path, $file_name, $latex); | ||
151 | |||
152 | //~ latexToPdf($latex_path, $file_name, $pdf_path); | ||
153 | |||
154 | |||
155 | //~ if($Client !== null) | ||
156 | //~ { | ||
157 | //~ $data = $Client->getAll(); | ||
158 | |||
159 | //~ // recto d'une enveloppe | ||
160 | //~ $latex_recto_path = $latex_path . 'enveloppes_recto/'; | ||
161 | //~ $pdf_recto_path = $pdf_path . 'enveloppes_recto/'; | ||
162 | //~ $data['code_postal_espaces'] = implode(' \ ', str_split($data['code_postal'])); // code postal avec 2 espaces entre chaque chiffre: 2 \ 9 \ 0 \ 0 \ 0 | ||
163 | |||
164 | //~ $latex = makeLatex('enveloppe_recto', $data); // injection des variables | ||
165 | //~ $file_name = $Client->getCodeClient() . '.tex'; | ||
166 | //~ makeFolder($latex_recto_path); | ||
167 | //~ makeFile($latex_recto_path, $file_name, $latex); | ||
168 | |||
169 | //~ makeFolder($pdf_recto_path); | ||
170 | //~ latexToPdf($latex_recto_path, $file_name, $pdf_recto_path); | ||
171 | |||
172 | //~ // facture, devis, location | ||
173 | //~ if($Presta !== null && $PrestaDetails !== null) | ||
174 | //~ { | ||
175 | //~ $type = $Presta->getTypePresta(); | ||
176 | //~ $file_name = $type . '.tex'; | ||
177 | //~ if($type === 'facture' || $type === 'devis' || $type === 'location') | ||
178 | //~ { | ||
179 | //~ $data = array_merge($data, $Presta->getAll()); | ||
180 | //~ $Date = new Dates($Presta->getDate()); // entrée = timestamp (doit être un "int"!!) | ||
181 | //~ $year = $Date->getYear(); | ||
182 | //~ $latex_year_path = $latex_path . $year . '/'; // un sous-dossier par année | ||
183 | //~ $pdf_year_path = $pdf_path . $year . '/'; | ||
184 | //~ $data = array_merge($data, $PrestaDetails->getAll()); | ||
185 | |||
186 | //~ $latex = makeLatex($type, $data, $Date); // injection des variables | ||
187 | //~ $file_name = $Presta->getCodePresta() . '.tex'; | ||
188 | //~ makeFolder($latex_year_path); | ||
189 | //~ makeFile($latex_year_path, $file_name, $latex); | ||
190 | |||
191 | //~ makeFolder($pdf_year_path); | ||
192 | //~ latexToPdf($latex_year_path, $file_name, $pdf_year_path); | ||
193 | //~ } | ||
194 | //~ elseif($type === 'cesu' || $type === 'non_vendue') | ||
195 | //~ {} // pas de document | ||
196 | //~ else | ||
197 | //~ { | ||
198 | //~ echo "debug: erreur génération latex, type de prestation \n"; | ||
199 | //~ return 0; | ||
200 | //~ } | ||
201 | //~ } | ||
202 | //~ } | ||
203 | //~ } | ||
diff --git a/src/main.php b/src/main.php index a0b973b..303e1ef 100755 --- a/src/main.php +++ b/src/main.php | |||
@@ -37,14 +37,13 @@ require('model/Model.php'); // class Model extends DB, requêtes SQL | |||
37 | require('model/StructTablesDB.php'); | 37 | require('model/StructTablesDB.php'); |
38 | Model::createTables(); | 38 | Model::createTables(); |
39 | 39 | ||
40 | //~ require('model/traits.php'); | ||
41 | require('model/Clients.php'); | 40 | require('model/Clients.php'); |
42 | require('model/Prestations.php'); | 41 | require('model/Prestations.php'); |
43 | require('model/DevisFactures.php'); | 42 | require('model/DevisFactures.php'); |
44 | require('model/CESU.php'); | 43 | require('model/CESU.php'); |
45 | require('model/Locations.php'); | 44 | require('model/Locations.php'); |
46 | 45 | ||
47 | require('view/Zenity.php'); // commande système zenity | 46 | require('view/Zenity.php'); // générer ler commandes système zenity |
48 | require('view/ZenitySetup.php'); // texte dans les fenêtres ET instanciation (un objet = une commande) | 47 | require('view/ZenitySetup.php'); // texte dans les fenêtres ET instanciation (un objet = une commande) |
49 | 48 | ||
50 | require('Latex.php'); // générer le code LaTeX | 49 | require('Latex.php'); // générer le code LaTeX |
diff --git a/src/model/CESU.php b/src/model/CESU.php index dbb4023..a8aa1e8 100644 --- a/src/model/CESU.php +++ b/src/model/CESU.php | |||
@@ -6,18 +6,26 @@ class CESU extends Model | |||
6 | //~ const TABLE = 'cesu'; | 6 | //~ const TABLE = 'cesu'; |
7 | 7 | ||
8 | // lecture des données ou hydratation | 8 | // lecture des données ou hydratation |
9 | protected $ID; | ||
9 | protected $ID_presta; | 10 | protected $ID_presta; |
10 | protected $taches; | 11 | protected $taches; |
11 | protected $duree_travail; | 12 | protected $duree_travail; |
12 | protected $salaire; | 13 | protected $salaire; |
13 | 14 | ||
14 | //~ use ModelChildren; | ||
15 | |||
16 | public function __construct() | 15 | public function __construct() |
17 | { | 16 | { |
18 | $this->table = strtolower(__CLASS__); // cesu | 17 | $this->table = strtolower(__CLASS__); // cesu |
19 | } | 18 | } |
20 | 19 | ||
20 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | ||
21 | { | ||
22 | return [ | ||
23 | "Numéro CESU:" => $this->ID, | ||
24 | "Tâche effectuée:" => $this->taches, | ||
25 | "Durée du travail:" => $this->duree_travail, | ||
26 | "Salaire:" => $this->salaire]; | ||
27 | } | ||
28 | |||
21 | // setters | 29 | // setters |
22 | public function setIDPresta(int $value) | 30 | public function setIDPresta(int $value) |
23 | { | 31 | { |
diff --git a/src/model/Clients.php b/src/model/Clients.php index f36acc1..6a4dcf5 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php | |||
@@ -14,8 +14,6 @@ class Clients extends Model | |||
14 | protected $courriel; | 14 | protected $courriel; |
15 | protected $apropos; | 15 | protected $apropos; |
16 | protected $type = 'prospect'; | 16 | protected $type = 'prospect'; |
17 | |||
18 | //~ use ModelChildren; | ||
19 | 17 | ||
20 | public function __construct() | 18 | public function __construct() |
21 | { | 19 | { |
@@ -31,6 +29,52 @@ class Clients extends Model | |||
31 | { | 29 | { |
32 | return $this->code_client; | 30 | return $this->code_client; |
33 | } | 31 | } |
32 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | ||
33 | { | ||
34 | return [ | ||
35 | "Prénom Nom:" => $this->prenom_nom, | ||
36 | "Code client (J.C.Dusse):" => $this->code_client, | ||
37 | "Adresse:" => $this->adresse, | ||
38 | "Code postal:" => $this->code_postal, | ||
39 | "Ville:" => $this->ville, | ||
40 | "Telephone:" => $this->telephone, | ||
41 | "Courriel:" => $this->courriel, | ||
42 | "À propos:" => $this->apropos, | ||
43 | "Client ou Prospect?" => $this->type]; | ||
44 | } | ||
45 | public function getSetterAndSet(string $entry, string $input) | ||
46 | { | ||
47 | switch($entry) | ||
48 | { | ||
49 | case "Prénom Nom:": | ||
50 | $this->setPrenomNom($input); | ||
51 | break; | ||
52 | case "Code client (J.C.Dusse):": | ||
53 | $this->setCodeClient($input); | ||
54 | break; | ||
55 | case "Adresse:": | ||
56 | $this->setAdresse($input); | ||
57 | break; | ||
58 | case "Code postal:": | ||
59 | $this->setCodePostal($input); | ||
60 | break; | ||
61 | case "Ville:": | ||
62 | $this->setVille($input); | ||
63 | break; | ||
64 | case "Telephone:": | ||
65 | $this->setTelephone($input); | ||
66 | break; | ||
67 | case "Courriel:": | ||
68 | $this->setCourriel($input); | ||
69 | break; | ||
70 | case "À propos:": | ||
71 | $this->setApropos($input); | ||
72 | break; | ||
73 | case "Client ou Prospect?": | ||
74 | $this->setType($input); | ||
75 | break; | ||
76 | } | ||
77 | } | ||
34 | 78 | ||
35 | // setters | 79 | // setters |
36 | public function setPrenomNom($value) | 80 | public function setPrenomNom($value) |
@@ -58,7 +102,6 @@ class Clients extends Model | |||
58 | $this->ville = (string) $value; | 102 | $this->ville = (string) $value; |
59 | return $this; | 103 | return $this; |
60 | } | 104 | } |
61 | |||
62 | public function setTelephone($value) // chaine parce que zenity renvoie une chaine et parce qu'on garde le 0 au début | 105 | public function setTelephone($value) // chaine parce que zenity renvoie une chaine et parce qu'on garde le 0 au début |
63 | { | 106 | { |
64 | if(is_numeric($value)) | 107 | if(is_numeric($value)) |
diff --git a/src/model/DevisFactures.php b/src/model/DevisFactures.php index c9b7d18..5769842 100644 --- a/src/model/DevisFactures.php +++ b/src/model/DevisFactures.php | |||
@@ -22,12 +22,42 @@ class DevisFactures extends Model | |||
22 | protected $validite_devis; | 22 | protected $validite_devis; |
23 | protected $signature_devis; | 23 | protected $signature_devis; |
24 | 24 | ||
25 | //~ use ModelChildren; | ||
26 | |||
27 | public function __construct(string $table) | 25 | public function __construct(string $table) |
28 | { | 26 | { |
29 | $this->table = $table; // deux tables séparées devis et factures | 27 | $this->table = $table; // deux tables séparées devis et factures |
30 | } | 28 | } |
29 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | ||
30 | { | ||
31 | $champs_communs = [ | ||
32 | "Tâches:" => $this->taches, | ||
33 | "PC:" => $this->machine, | ||
34 | "OS:" => $this->OS, | ||
35 | "Données:" => $this->donnees, | ||
36 | "Clés de licences:" => $this->cles_licences, | ||
37 | "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, | ||
38 | "Pièces" => $this->pieces, | ||
39 | "Total des pièces" => $this->total_pieces, | ||
40 | "Déplacement" => $this->deplacement, | ||
41 | "Total HT" => $this->total_HT]; | ||
42 | |||
43 | if($this->table === 'factures') | ||
44 | { | ||
45 | return ["Numéro facture:" => $this->ID] + $champs_communs; | ||
46 | } | ||
47 | elseif($this->table === 'devis') | ||
48 | { | ||
49 | $champs_devis = [ | ||
50 | "Delai de livraison" => $this->delai_livraison, | ||
51 | "Durée de validité" => $this->validite_devis, | ||
52 | "Devis signé?" => $this->signature_devis]; | ||
53 | |||
54 | return ["Numéro devis:" => $this->ID] + $champs_communs + $champs_devis; | ||
55 | } | ||
56 | else | ||
57 | { | ||
58 | return []; | ||
59 | } | ||
60 | } | ||
31 | 61 | ||
32 | // setters | 62 | // setters |
33 | public function setIDPresta(int $value) | 63 | public function setIDPresta(int $value) |
diff --git a/src/model/Locations.php b/src/model/Locations.php index b669e7c..e3c9507 100644 --- a/src/model/Locations.php +++ b/src/model/Locations.php | |||
@@ -4,6 +4,7 @@ | |||
4 | class Locations extends Model | 4 | class Locations extends Model |
5 | { | 5 | { |
6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
7 | protected $ID; | ||
7 | protected $ID_presta; | 8 | protected $ID_presta; |
8 | protected $designation; | 9 | protected $designation; |
9 | protected $modele_description; | 10 | protected $modele_description; |
@@ -15,13 +16,26 @@ class Locations extends Model | |||
15 | protected $loyers_payes; | 16 | protected $loyers_payes; |
16 | protected $caution; | 17 | protected $caution; |
17 | 18 | ||
18 | //~ use ModelChildren; | ||
19 | |||
20 | public function __construct() | 19 | public function __construct() |
21 | { | 20 | { |
22 | $this->table = strtolower(__CLASS__); // locations | 21 | $this->table = strtolower(__CLASS__); // locations |
23 | } | 22 | } |
24 | 23 | ||
24 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | ||
25 | { | ||
26 | return [ | ||
27 | "Numéro location:" => $this->ID, | ||
28 | "Désignation:" => $this->designation, | ||
29 | "Description du modèle:" => $this->modele_description, | ||
30 | "Valeur:" => $this->valeur, | ||
31 | "État des lieux de début:" => $this->etat_des_lieux_debut, | ||
32 | "État des lieux de fin:" => $this->etat_des_lieux_fin, | ||
33 | "Durée de la location:" => $this->duree_location, | ||
34 | "Loyer Mensuel" => $this->loyer_mensuel, | ||
35 | "Loyers Payés" => $this->loyers_payes, | ||
36 | "Caution" => $this->caution]; | ||
37 | } | ||
38 | |||
25 | // setters | 39 | // setters |
26 | public function setIDPresta(int $value) | 40 | public function setIDPresta(int $value) |
27 | { | 41 | { |
diff --git a/src/model/Model.php b/src/model/Model.php index 3fb3bdf..4c4a80c 100644 --- a/src/model/Model.php +++ b/src/model/Model.php | |||
@@ -19,7 +19,7 @@ abstract class Model extends DB | |||
19 | return $this->table; | 19 | return $this->table; |
20 | } | 20 | } |
21 | 21 | ||
22 | public function getAll(): array | 22 | public function getAll(): array // à améliorer pour ne pas renvoyer $db et $table |
23 | { | 23 | { |
24 | return get_object_vars($this); // retourne les propriétés de l'objet | 24 | return get_object_vars($this); // retourne les propriétés de l'objet |
25 | } | 25 | } |
@@ -29,7 +29,7 @@ abstract class Model extends DB | |||
29 | { | 29 | { |
30 | if($value === 0) | 30 | if($value === 0) |
31 | { | 31 | { |
32 | $this->ID = $this->db->lastInsertId(); // méthode de PDO (attention ne gère pas la concurence) | 32 | $this->ID = $this->db->lastInsertId(); // méthode de PDO, attention lastInsertId() ne gère pas la concurence |
33 | } | 33 | } |
34 | else | 34 | else |
35 | { | 35 | { |
@@ -183,9 +183,22 @@ abstract class Model extends DB | |||
183 | return($this->execQuery('SELECT * FROM ' . $this->table)->fetchAll()); // fonctionne aussi sans le point virgule dans le SQL!! | 183 | return($this->execQuery('SELECT * FROM ' . $this->table)->fetchAll()); // fonctionne aussi sans le point virgule dans le SQL!! |
184 | } | 184 | } |
185 | 185 | ||
186 | public function findById(int $id) // obtenir une entrée avec son ID | 186 | public function findById() // obtenir une entrée avec son ID |
187 | { | 187 | { |
188 | return($this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id = ' . $id)->fetch()); | 188 | return($this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id = ' . $this->ID)->fetch()); |
189 | } | ||
190 | public function getDetailsByIdPresta() | ||
191 | { | ||
192 | if($this->table == 'prestations') | ||
193 | { | ||
194 | // à l'occaz, rendre abstraite la classe Prestations | ||
195 | echo 'erreur: ne pas appeler Model::getDetailsByIdPresta() si la table ciblée est "prestations".'; | ||
196 | return 0; | ||
197 | } | ||
198 | else | ||
199 | { | ||
200 | return $this->execQuery('SELECT * FROM ' . $this->table . ' WHERE id_Presta = ' . $this->ID_presta)->fetch(); // type array | ||
201 | } | ||
189 | } | 202 | } |
190 | 203 | ||
191 | protected function find(array $criteria): array // obtenir une entrée avec un tableau associatif 'champ' => 'valeur' | 204 | protected function find(array $criteria): array // obtenir une entrée avec un tableau associatif 'champ' => 'valeur' |
@@ -207,7 +220,7 @@ abstract class Model extends DB | |||
207 | 220 | ||
208 | 221 | ||
209 | // update UPDATE | 222 | // update UPDATE |
210 | public function update(int $id) // utiliser plutôt $this->ID ? | 223 | public function update() |
211 | { | 224 | { |
212 | $fields = []; | 225 | $fields = []; |
213 | $values = []; | 226 | $values = []; |
@@ -219,7 +232,7 @@ abstract class Model extends DB | |||
219 | $values[] = $value; | 232 | $values[] = $value; |
220 | } | 233 | } |
221 | } | 234 | } |
222 | $values[] = $id; // cette syntaxe ajoute une valeur au tableau | 235 | $values[] = $this->ID; // cette syntaxe ajoute une valeur au tableau |
223 | $field_list = implode(', ', $fields); | 236 | $field_list = implode(', ', $fields); |
224 | 237 | ||
225 | // UPDATE annonces SET titre = ?, description = ?, actif = ? WHERE id = ? | 238 | // UPDATE annonces SET titre = ?, description = ?, actif = ? WHERE id = ? |
diff --git a/src/model/Prestations.php b/src/model/Prestations.php index 22865df..fe09133 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php | |||
@@ -11,8 +11,6 @@ class Prestations extends Model | |||
11 | protected $type_presta = ''; | 11 | protected $type_presta = ''; |
12 | protected $mode_paiement = ''; | 12 | protected $mode_paiement = ''; |
13 | protected $commentaires = ''; | 13 | protected $commentaires = ''; |
14 | |||
15 | //~ use ModelChildren; | ||
16 | 14 | ||
17 | public function __construct(int $ID_client) | 15 | public function __construct(int $ID_client) |
18 | { | 16 | { |
@@ -29,6 +27,16 @@ class Prestations extends Model | |||
29 | { | 27 | { |
30 | return $this->ID_client; | 28 | return $this->ID_client; |
31 | } | 29 | } |
30 | public function getIDsByIdClient() // obtenir une entrée avec son ID_client | ||
31 | { | ||
32 | $IDs = $this->execQuery('SELECT id FROM ' . $this->table . ' WHERE id_client = ' . $this->ID_client)->fetchAll(); | ||
33 | // changer le tableau de tableaux en tableau simple | ||
34 | for($i = 0; $i < count($IDs); $i++) | ||
35 | { | ||
36 | $IDs[$i] = $IDs[$i]['ID']; | ||
37 | } | ||
38 | return($IDs); | ||
39 | } | ||
32 | public function getCodePresta(): string | 40 | public function getCodePresta(): string |
33 | { | 41 | { |
34 | return $this->code_presta; | 42 | return $this->code_presta; |
@@ -41,6 +49,18 @@ class Prestations extends Model | |||
41 | { | 49 | { |
42 | return $this->type_presta; | 50 | return $this->type_presta; |
43 | } | 51 | } |
52 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | ||
53 | { | ||
54 | $code_presta_tableau = explode('-', $this->code_presta); | ||
55 | $Date = new Dates($this->date); | ||
56 | |||
57 | return [ | ||
58 | "Numéro prestation:" => end($code_presta_tableau), // dernière case | ||
59 | "Date:" => $Date->getDate(), | ||
60 | "Type de Presta:" => $this->type_presta, | ||
61 | "Mode de paiement:" => $this->mode_paiement, | ||
62 | "Commentaires:" => $this->commentaires]; | ||
63 | } | ||
44 | 64 | ||
45 | // setters | 65 | // setters |
46 | //~ public function setID() -> dans le trait ModelChildren | 66 | //~ public function setID() -> dans le trait ModelChildren |
@@ -81,7 +101,7 @@ class Prestations extends Model | |||
81 | return $this; | 101 | return $this; |
82 | } | 102 | } |
83 | 103 | ||
84 | // code client = année-mois-jour-codeclient-combientièmefois | 104 | // code client = année-mois-jour-codeclient-typedepresta-combientièmefois |
85 | public function makeCodePresta(Dates $Date, string $code_client) | 105 | public function makeCodePresta(Dates $Date, string $code_client) |
86 | { | 106 | { |
87 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) | 107 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) |
diff --git a/src/model/StructTablesDB.php b/src/model/StructTablesDB.php index 769d502..679adde 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/StructTablesDB.php | |||
@@ -11,7 +11,7 @@ class StructTablesDB | |||
11 | // les tables devis_factures, cesu et locations sont liées à la table prestations | 11 | // les tables devis_factures, cesu et locations sont liées à la table prestations |
12 | 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'code_postal' => 'TEXT', 'ville' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'apropos' => 'TEXT', 'type' => 'TEXT DEFAULT prospect'], | 12 | 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'code_postal' => 'TEXT', 'ville' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'apropos' => 'TEXT', 'type' => 'TEXT DEFAULT prospect'], |
13 | 'prestations' => ['ID' => 'INTEGER', 'ID_client' => 'INTEGER', 'code_presta' => 'TEXT', 'date' => 'INTEGER', 'type_presta' => 'TEXT', 'mode_paiement' => 'TEXT', 'commentaires' => 'TEXT'], | 13 | 'prestations' => ['ID' => 'INTEGER', 'ID_client' => 'INTEGER', 'code_presta' => 'TEXT', 'date' => 'INTEGER', 'type_presta' => 'TEXT', 'mode_paiement' => 'TEXT', 'commentaires' => 'TEXT'], |
14 | 'devis' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT'], | 14 | 'devis' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT DEFAULT non'], |
15 | 'factures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'machine' => 'TEXT', 'OS' => 'TEXT', 'donnees' => 'TEXT', 'cles_licences' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL'], | 15 | 'factures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'machine' => 'TEXT', 'OS' => 'TEXT', 'donnees' => 'TEXT', 'cles_licences' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL'], |
16 | 'cesu' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], | 16 | 'cesu' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], |
17 | 'locations' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'designation' => 'TEXT', 'modele_description' => 'TEXT', 'valeur' => 'REAL', 'etat_des_lieux_debut' => 'TEXT', 'etat_des_lieux_fin' => 'TEXT', 'duree_location' => 'TEXT', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] | 17 | 'locations' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'designation' => 'TEXT', 'modele_description' => 'TEXT', 'valeur' => 'REAL', 'etat_des_lieux_debut' => 'TEXT', 'etat_des_lieux_fin' => 'TEXT', 'duree_location' => 'TEXT', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] |
diff --git a/src/model/traits.php b/src/model/traits.php deleted file mode 100644 index 88451d9..0000000 --- a/src/model/traits.php +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | <?php | ||
2 | // src/model/traits.php | ||
3 | // | ||
4 | // fonctions "partagées" par les enfants de Model | ||
5 | |||
6 | trait ModelChildren | ||
7 | { | ||
8 | //~ public function __construct() | ||
9 | //~ { | ||
10 | //~ $this->table = strtolower(__CLASS__); | ||
11 | //~ echo "TABLE = " . $this->table . "\n"; | ||
12 | //~ } | ||
13 | } | ||
diff --git a/src/sections/1_customer.php b/src/sections/1_customer.php index cdec448..ca20d08 100644 --- a/src/sections/1_customer.php +++ b/src/sections/1_customer.php | |||
@@ -12,29 +12,36 @@ function newCustomer(): array | |||
12 | 12 | ||
13 | // -- partie 1: client ou prospect? -- | 13 | // -- partie 1: client ou prospect? -- |
14 | $Client = new Clients; | 14 | $Client = new Clients; |
15 | if(exec($TypeDeClient->get()) === 'Client') | 15 | $choix_niv2 = exec($TypeDeClient->get()); |
16 | if($choix_niv2 === ZenitySetup::$type_client_entrees[0]) | ||
16 | { | 17 | { |
18 | echo "choix: " . $choix_niv2 . "\n"; | ||
17 | $Client->setType('client'); | 19 | $Client->setType('client'); |
18 | } | 20 | } |
19 | //~ else // | 21 | elseif($choix_niv2 === ZenitySetup::$type_client_entrees[1]) |
20 | //~ { | 22 | { |
21 | //~ $Client->setType('prospect'); | 23 | echo "choix: " . $choix_niv2 . "\n"; |
22 | //~ } | 24 | $Client->setType('prospect'); |
25 | } | ||
26 | else | ||
27 | { | ||
28 | return [0, null]; // menu principal | ||
29 | } | ||
23 | 30 | ||
24 | // -- partie 2: saisie des infos -- | 31 | // -- partie 2: saisie des infos -- |
25 | if(enterCustomer($Client)) | 32 | if(enterCustomer($Client)) |
26 | { | 33 | { |
27 | // -- partie 3: on fait quoi maintenant -- | 34 | // -- partie 3: on fait quoi maintenant -- |
28 | $choix_niv2 = exec($FinSection1->get()); | 35 | $choix_niv3 = exec($FinSection1->get()); |
29 | if($choix_niv2 === ZenitySetup::$fin_section_1_entrees[0]) | 36 | if($choix_niv3 === ZenitySetup::$fin_section_1_entrees[0]) |
30 | { | 37 | { |
31 | return [2, $Client]; // section 2: newService() | 38 | return [2, $Client]; // section 2: newService() |
32 | } | 39 | } |
33 | elseif($choix_niv2 === ZenitySetup::$fin_section_1_entrees[1]) | 40 | elseif($choix_niv3 === ZenitySetup::$fin_section_1_entrees[1]) |
34 | { | 41 | { |
35 | return [3, $Client]; // section 3: modifyData() | 42 | return [3, $Client]; // section 3: modifyData() |
36 | } | 43 | } |
37 | elseif($choix_niv2 === ZenitySetup::$fin_section_1_entrees[2]) | 44 | elseif($choix_niv3 === ZenitySetup::$fin_section_1_entrees[2]) |
38 | { | 45 | { |
39 | return [1, null]; // relancer section 1: newCustomer() | 46 | return [1, null]; // relancer section 1: newCustomer() |
40 | } | 47 | } |
diff --git a/src/sections/2_service.php b/src/sections/2_service.php index 8109b31..2680db6 100644 --- a/src/sections/2_service.php +++ b/src/sections/2_service.php | |||
@@ -13,7 +13,7 @@ function newService($Client): array // $Client est un Client ou null | |||
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); | 17 | //$QuestionModifierPrestation = new ZenityQuestion(ZenitySetup::$question_modification_text); |
18 | $FinSection2 = new ZenityList(ZenitySetup::$fin_section_2_text, ZenitySetup::$fin_section_2_entrees); | 18 | $FinSection2 = new ZenityList(ZenitySetup::$fin_section_2_text, ZenitySetup::$fin_section_2_entrees); |
19 | 19 | ||
@@ -32,7 +32,7 @@ function newService($Client): array // $Client est un Client ou null | |||
32 | 32 | ||
33 | // -- partie 2: la prestation -- | 33 | // -- partie 2: la prestation -- |
34 | 34 | ||
35 | // niveau 2: type comptable d'enregistrement: devis, facture, cesu, location ou pas de prestation | 35 | // niveau 2: type comptable d'enregistrement: devis, facture, cesu, location ou prestation non vendue |
36 | $choix_niv2 = exec($MenuEnregistrement->get()); | 36 | $choix_niv2 = exec($MenuEnregistrement->get()); |
37 | if($choix_niv2 === '') | 37 | if($choix_niv2 === '') |
38 | { | 38 | { |
@@ -40,9 +40,6 @@ function newService($Client): array // $Client est un Client ou null | |||
40 | return [0, null]; // menu principal | 40 | return [0, null]; // menu principal |
41 | } | 41 | } |
42 | 42 | ||
43 | $Presta = new Prestations($Client->getID()); | ||
44 | |||
45 | // détail de la prestation | ||
46 | // calendrier - étape 1/3 | 43 | // calendrier - étape 1/3 |
47 | $Date = new Dates(exec($Calendrier->get())); // exec() renvoie soit une chaîne soit un false | 44 | $Date = new Dates(exec($Calendrier->get())); // exec() renvoie soit une chaîne soit un false |
48 | if($Date->getDate() == '') // on n'a pas cliqué sur "annuler" | 45 | if($Date->getDate() == '') // on n'a pas cliqué sur "annuler" |
@@ -51,32 +48,56 @@ function newService($Client): array // $Client est un Client ou null | |||
51 | return [0, null]; // menu principal | 48 | return [0, null]; // menu principal |
52 | } | 49 | } |
53 | 50 | ||
51 | $Presta = new Prestations($Client->getID()); | ||
54 | $Presta->setDate($Date->getTimestamp()); // un entier pour la BDD | 52 | $Presta->setDate($Date->getTimestamp()); // un entier pour la BDD |
55 | 53 | ||
54 | // formulaire - étape 2/3 | ||
56 | switch($choix_niv2) | 55 | switch($choix_niv2) |
57 | { | 56 | { |
58 | // formulaire - étape 2/3 | 57 | // comparaison retour de $MenuEnregistrement->get() avec les noms des entrées du même menu |
59 | //~ case ZenitySetup::$menu_enregistrement_entrees[0]: // "Devis" | 58 | case ZenitySetup::$menu_enregistrement_entrees[0]: // "Devis" |
60 | //~ $PrestaDetails = new DevisFactures('devis'); | 59 | $PrestaDetails = new DevisFactures('devis'); |
61 | //~ $Presta->setTypePresta('devis'); | 60 | $Presta->setTypePresta('devis'); |
62 | //~ $input = exec($FormulaireDevis->get()); | 61 | $input = exec($FormulaireDevis->get()); |
63 | //~ break; | 62 | break; |
64 | case ZenitySetup::$menu_enregistrement_entrees[0]: // "Facture" | 63 | case ZenitySetup::$menu_enregistrement_entrees[1]: // "Facture" |
65 | $PrestaDetails = new DevisFactures('factures'); // 'factures' est le nom de la table, pas le type de presta | 64 | $PrestaDetails = new DevisFactures('factures'); |
66 | $Presta->setTypePresta('facture'); | 65 | $Presta->setTypePresta('facture'); |
67 | $input =exec($FormulaireFacture->get()); | 66 | $input =exec($FormulaireFacture->get()); |
68 | break; | 67 | break; |
69 | case ZenitySetup::$menu_enregistrement_entrees[1]: // "CESU" | 68 | |
69 | //~ case ZenitySetup::$menu_enregistrement_entrees[2]: // "Facture à partir d'un devis" | ||
70 | //~ $PrestaDetails = new DevisFactures('facture'); | ||
71 | //~ $Presta->setTypePresta('facture'); | ||
72 | // 1 choix d'un devis | ||
73 | //makeObjectService(); // liste les devis existants pour ce client | ||
74 | // | ||
75 | // 2 hydratation | ||
76 | // | ||
77 | // 3 préremplissage du formulaire | ||
78 | //$FormulaireFacture->set($Data) | ||
79 | // | ||
80 | // et plus loin: | ||
81 | // 4 édition de la facture | ||
82 | //$input = exec($FormulaireFacture->get()); | ||
83 | // | ||
84 | // 5 hydratation avec les changements | ||
85 | // | ||
86 | //echo $FormulaireFacture->get() . "\n"; | ||
87 | //~ $input = exec($FormulaireFacture->get()); | ||
88 | //~ break; | ||
89 | |||
90 | case ZenitySetup::$menu_enregistrement_entrees[3]: // "CESU" | ||
70 | $PrestaDetails = new CESU(); | 91 | $PrestaDetails = new CESU(); |
71 | $Presta->setTypePresta('cesu'); | 92 | $Presta->setTypePresta('cesu'); |
72 | $input = exec($FormulaireCesu->get()); | 93 | $input = exec($FormulaireCesu->get()); |
73 | break; | 94 | break; |
74 | case ZenitySetup::$menu_enregistrement_entrees[2]: // "Location" | 95 | case ZenitySetup::$menu_enregistrement_entrees[4]: // "Location" |
75 | $PrestaDetails = new Locations(); | 96 | $PrestaDetails = new Locations(); |
76 | $Presta->setTypePresta('location'); | 97 | $Presta->setTypePresta('location'); |
77 | $input = exec($FormulaireLocation->get()); | 98 | $input = exec($FormulaireLocation->get()); |
78 | break; | 99 | break; |
79 | case ZenitySetup::$menu_enregistrement_entrees[3]: // "Prestation non vendue" | 100 | case ZenitySetup::$menu_enregistrement_entrees[5]: // "Prestation non vendue" |
80 | $Presta->setTypePresta('non_vendue'); | 101 | $Presta->setTypePresta('non_vendue'); |
81 | break; | 102 | break; |
82 | default: // inutile normallement, cas déjà géré avant | 103 | default: // inutile normallement, cas déjà géré avant |
@@ -86,7 +107,8 @@ function newService($Client): array // $Client est un Client ou null | |||
86 | 107 | ||
87 | $Presta->makeCodePresta($Date, $Client->getCodeClient()); // d'un objet à l'autre | 108 | $Presta->makeCodePresta($Date, $Client->getCodeClient()); // d'un objet à l'autre |
88 | 109 | ||
89 | if($choix_niv2 != ZenitySetup::$menu_enregistrement_entrees[3]) // si presta non vendue, saut étape 3/3 | 110 | // hydratation ou saut étape 3/3 si presta non vendu |
111 | if($choix_niv2 != ZenitySetup::$menu_enregistrement_entrees[5]) | ||
90 | { | 112 | { |
91 | if($input == '') // annulation | 113 | if($input == '') // annulation |
92 | { | 114 | { |
@@ -154,9 +176,9 @@ function newService($Client): array // $Client est un Client ou null | |||
154 | //~ {} | 176 | //~ {} |
155 | 177 | ||
156 | // fabrique d'objets (sans connaître les noms des classes) | 178 | // fabrique d'objets (sans connaître les noms des classes) |
157 | $EnveloppeRecto = Latex::makeLatexSubClass('enveloppe_recto'); | 179 | $EnveloppeRecto = Latex::makeInstance('enveloppe_recto'); |
158 | $EnveloppeVerso = Latex::makeLatexSubClass('enveloppe_verso'); | 180 | $EnveloppeVerso = Latex::makeInstance('enveloppe_verso'); |
159 | $DocumentPresta = Latex::makeLatexSubClass($Presta->getTypePresta()); // $type = facture, devis, location | 181 | $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location |
160 | 182 | ||
161 | // génération du latex | 183 | // génération du latex |
162 | $EnveloppeRecto->setData($Client); | 184 | $EnveloppeRecto->setData($Client); |
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 | ||
6 | function modifyData($Objet): array | 6 | function 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 | } |
diff --git a/src/sections/4_get_document.php b/src/sections/4_get_document.php index e28e526..baad117 100644 --- a/src/sections/4_get_document.php +++ b/src/sections/4_get_document.php | |||
@@ -3,7 +3,7 @@ | |||
3 | // | 3 | // |
4 | // -- SECTION 4: Afficher, imprimer un document -- | 4 | // -- SECTION 4: Afficher, imprimer un document -- |
5 | 5 | ||
6 | function getDocument($Objet): array | 6 | function getOrPrintDocument(): array |
7 | { | 7 | { |
8 | $MenuDocuments = new ZenityList(ZenitySetup::$menu_documents_text, ZenitySetup::$menu_documents_entrees); | 8 | $MenuDocuments = new ZenityList(ZenitySetup::$menu_documents_text, ZenitySetup::$menu_documents_entrees); |
9 | 9 | ||
diff --git a/src/sections/main_loop.php b/src/sections/main_loop.php index 7dd1af0..f68c251 100644 --- a/src/sections/main_loop.php +++ b/src/sections/main_loop.php | |||
@@ -6,14 +6,15 @@ | |||
6 | require('sections/1_customer.php'); | 6 | require('sections/1_customer.php'); |
7 | require('sections/2_service.php'); | 7 | require('sections/2_service.php'); |
8 | require('sections/3_modify_data.php'); | 8 | require('sections/3_modify_data.php'); |
9 | require('sections/4_get_document.php'); | ||
9 | 10 | ||
10 | $main_loop = true; | 11 | $main_loop = true; |
11 | $returned = [0, null]; // [code de retour, éventuelles données] | 12 | $section = [0, null]; // [code de retour, éventuelles données] |
12 | 13 | ||
13 | while($main_loop) | 14 | while($main_loop) |
14 | { | 15 | { |
15 | // -- MENU PRINCIPAL (niveau 1) -- | 16 | // -- MENU PRINCIPAL (niveau 1) -- |
16 | if($returned[0] === 0) | 17 | if($section[0] === 0) |
17 | { | 18 | { |
18 | echo("Menu principal\n"); | 19 | echo("Menu principal\n"); |
19 | $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); | 20 | $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); |
@@ -24,44 +25,45 @@ while($main_loop) | |||
24 | $choix_niv1 = ''; | 25 | $choix_niv1 = ''; |
25 | } | 26 | } |
26 | 27 | ||
27 | 28 | // comparaison du retour de $MenuPrincipal->get() avec les noms des entrées du même menu | |
29 | |||
28 | // -- SECTION 1: Clients et prospects -- | 30 | // -- SECTION 1: Clients et prospects -- |
29 | if($choix_niv1 === ZenitySetup::$menu_principal_entrees[0] || $returned[0] === 1) | 31 | if($choix_niv1 === ZenitySetup::$menu_principal_entrees[0] || $section[0] === 1) |
30 | { | 32 | { |
31 | echo("choix: ". ZenitySetup::$menu_principal_entrees[0] . "\n"); | 33 | echo("choix: ". ZenitySetup::$menu_principal_entrees[0] . "\n"); |
32 | $returned = newCustomer(); | 34 | $section = newCustomer(); |
33 | } | 35 | } |
34 | 36 | ||
35 | // -- SECTION 2: Prestations et devis -- | 37 | // -- SECTION 2: Prestations et devis -- |
36 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[1] || $returned[0] === 2) | 38 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[1] || $section[0] === 2) |
37 | { | 39 | { |
38 | echo("choix: ". ZenitySetup::$menu_principal_entrees[1] . "\n"); | 40 | echo("choix: ". ZenitySetup::$menu_principal_entrees[1] . "\n"); |
39 | $returned = newService($returned[1]); // $returned[1] vaut un type Clients ou null | 41 | $section = newService($section[1]); // $section[1] vaut un type Clients ou null |
40 | } | 42 | } |
41 | 43 | ||
42 | // -- SECTION 3: Modifier un enregistrement -- | 44 | // -- SECTION 3: Modifier un enregistrement -- |
43 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[2] || $returned[0] === 3) | 45 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[2] || $section[0] === 3) |
44 | { | 46 | { |
45 | echo("choix: " . ZenitySetup::$menu_principal_entrees[2] . "\n"); | 47 | echo("choix: " . ZenitySetup::$menu_principal_entrees[2] . "\n"); |
46 | $returned = modifyData(); | 48 | $section = modifyData($section[1]); // $section[1] vaut un type Clients ou null |
47 | } | 49 | } |
48 | 50 | ||
49 | // -- SECTION 4: Consulter, Imprimer un document -- | 51 | // -- SECTION 4: Consulter, Imprimer un document -- |
50 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[3] || $returned[0] === 4) // = Imprimer un document | 52 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[3] || $section[0] === 4) // = Imprimer un document |
51 | { | 53 | { |
52 | echo("choix: ". ZenitySetup::$menu_principal_entrees[3] . "\n"); | 54 | echo("choix: ". ZenitySetup::$menu_principal_entrees[3] . "\n"); |
53 | $returned = getDocument(); | 55 | $section = getOrPrintDocument(); |
54 | } | 56 | } |
55 | 57 | ||
56 | // -- SECTION 5: Consulter/analyser les données -- | 58 | // -- SECTION 5: Consulter/analyser les données -- |
57 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[4] || $returned[0] === 5) | 59 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[4] || $section[0] === 5) |
58 | { | 60 | { |
59 | echo("choix: ". ZenitySetup::$menu_principal_entrees[4] . "\n"); | 61 | echo("choix: ". ZenitySetup::$menu_principal_entrees[4] . "\n"); |
60 | // quel affichage? des tableaux avec zenity? LaTeX? une page web? un autre outil servant à faire des tableaux et graphiques | 62 | // quel affichage? des tableaux avec zenity? LaTeX? une page web? un autre outil servant à faire des tableaux et graphiques |
61 | } | 63 | } |
62 | 64 | ||
63 | // -- SECTION 6: Supports de communication -- | 65 | // -- SECTION 6: Supports de communication -- |
64 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[5] || $returned[0] === 6) // = Communication | 66 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[5] || $section[0] === 6) // = Communication |
65 | { | 67 | { |
66 | echo("choix: ". ZenitySetup::$menu_principal_entrees[5] . "\n"); | 68 | echo("choix: ". ZenitySetup::$menu_principal_entrees[5] . "\n"); |
67 | $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication_text, ZenitySetup::$menu_communication_entrees); | 69 | $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication_text, ZenitySetup::$menu_communication_entrees); |
@@ -85,7 +87,7 @@ while($main_loop) | |||
85 | } | 87 | } |
86 | 88 | ||
87 | // -- SECTION 7: BDD -- | 89 | // -- SECTION 7: BDD -- |
88 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[6] || $returned[0] === 7) // = Base de données | 90 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[6] || $section[0] === 7) // = Base de données |
89 | { | 91 | { |
90 | echo("choix: ". ZenitySetup::$menu_principal_entrees[6] . "\n"); | 92 | echo("choix: ". ZenitySetup::$menu_principal_entrees[6] . "\n"); |
91 | if($sqlitebrowser_enable) | 93 | if($sqlitebrowser_enable) |
diff --git a/src/view/Zenity.php b/src/view/Zenity.php index 73c8c3e..858dfa9 100644 --- a/src/view/Zenity.php +++ b/src/view/Zenity.php | |||
@@ -26,6 +26,11 @@ abstract class ZenityCmd | |||
26 | { | 26 | { |
27 | return($this->command); | 27 | return($this->command); |
28 | } | 28 | } |
29 | // pré-remlir un formulaire zenity --forms | ||
30 | //~ public function formSet() | ||
31 | //~ { | ||
32 | //~ return($this->command); | ||
33 | //~ } | ||
29 | } | 34 | } |
30 | 35 | ||
31 | 36 | ||
@@ -37,7 +42,7 @@ class ZenityList extends ZenityCmd | |||
37 | { | 42 | { |
38 | $this->command_type = ' --list'; | 43 | $this->command_type = ' --list'; |
39 | parent::__construct($text, $rows); | 44 | parent::__construct($text, $rows); |
40 | $this->columns = 1; | 45 | //$this->columns = 1; |
41 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text | 46 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text |
42 | if($this->rows !== []) | 47 | if($this->rows !== []) |
43 | { | 48 | { |
@@ -48,25 +53,29 @@ class ZenityList extends ZenityCmd | |||
48 | } | 53 | } |
49 | } | 54 | } |
50 | 55 | ||
51 | // cas ou $this->rows est renseignée après | 56 | // cas ou $this->rows n'est pas renseignée dans le constructeur |
52 | // la valeur de $columns n'est plus nécessairement celle apr défaut | 57 | // la valeur de $columns n'est plus nécessairement celle par défaut |
53 | public function setListRows(array $rows, string $table) | 58 | public function setListRows(array $rows, int $columns, float $widen = 1) |
54 | { | 59 | { |
60 | // si 1 colonne, $rows = tableau à une dimension | ||
61 | // si 2 colonnes ou plus, $rows = tableau à deux dimensions | ||
55 | $this->rows = $rows; | 62 | $this->rows = $rows; |
56 | $this->columns = count(StructTablesDB::$structureOfTables[$table]); | 63 | $this->columns = $columns; |
57 | $this->width = 800; | 64 | |
65 | $this->width = $this->columns * 120 * $widen; | ||
66 | $this->height = 91 + count($this->rows) * 25; // inclut les lignes et la barre de défilement horizontale | ||
67 | |||
58 | $this->command .= ' --width=' . $this->width; | 68 | $this->command .= ' --width=' . $this->width; |
59 | $this->height = 80 + count($this->rows) * 25; | ||
60 | $this->command .= ' --height=' . $this->height; | 69 | $this->command .= ' --height=' . $this->height; |
61 | $this->fillZenityList(); | 70 | $this->fillZenityList(); |
62 | } | 71 | } |
63 | 72 | ||
64 | // noter que la syntaxe de zentity --list est déroutante! | 73 | // noter que la syntaxe de zenity --list est déroutante! |
65 | // le remplissage est horizontal et le nombre de colonne dépend du nombre d'occurence de --column="" | 74 | // le remplissage est horizontal et le nombre de colonne dépend du nombre d'occurence de --column="" |
66 | public function fillZenityList() | 75 | public function fillZenityList() |
67 | { | 76 | { |
68 | $output = ''; | 77 | $output = ''; |
69 | if($this->columns === 1) | 78 | if($this->columns === 1) // $this->rows doit être un tableau |
70 | { | 79 | { |
71 | $output .= ' --column=""'; | 80 | $output .= ' --column=""'; |
72 | // remplissage vertical | 81 | // remplissage vertical |
@@ -75,7 +84,8 @@ class ZenityList extends ZenityCmd | |||
75 | $output .= ' "' . $one_row . '"'; // forme: ' "choix 1" "choix 2"' | 84 | $output .= ' "' . $one_row . '"'; // forme: ' "choix 1" "choix 2"' |
76 | } | 85 | } |
77 | } | 86 | } |
78 | elseif($this->columns >= 2) // marche quelque soit le nombre de colonnes | 87 | elseif($this->columns >= 2) // $this->rows doit être un tableau à deux dimensions |
88 | // marche quelque soit le nombre de colonnes | ||
79 | { | 89 | { |
80 | for($i = 0; $i < $this->columns; $i++) | 90 | for($i = 0; $i < $this->columns; $i++) |
81 | { | 91 | { |
diff --git a/src/view/ZenitySetup.php b/src/view/ZenitySetup.php index d0b785c..32648ea 100644 --- a/src/view/ZenitySetup.php +++ b/src/view/ZenitySetup.php | |||
@@ -1,10 +1,14 @@ | |||
1 | <?php | 1 | <?php |
2 | // src/view/ZenitySetup.php | 2 | // src/view/ZenitySetup.php |
3 | // | 3 | // |
4 | // ces variables sont des paramètres de la commande zenity (--text, --add-entry, --column) | 4 | // données pour les paramètres de la commande zenity comme: --text, --add-entry, --column |
5 | // les utiliser à l'instanciation des objets Zenity à la manière de l'exemple suivant: | 5 | // les utiliser à l'instanciation des objets Zenity à la manière de l'exemple suivant: |
6 | // $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); | 6 | // $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); |
7 | 7 | ||
8 | // pense-bête | ||
9 | // rassembler les 'text' et 'entrées' | ||
10 | // ce serait plus logique que ce fichier soit en JSON | ||
11 | |||
8 | class ZenitySetup | 12 | class ZenitySetup |
9 | { | 13 | { |
10 | static public $menu_principal_text = "Gestion d'une micro-entreprise"; | 14 | static public $menu_principal_text = "Gestion d'une micro-entreprise"; |
@@ -13,16 +17,17 @@ class ZenitySetup | |||
13 | static public $type_client_text = "Client ou prospect?"; | 17 | static public $type_client_text = "Client ou prospect?"; |
14 | static public $type_client_entrees = ["Client", "Prospect"]; | 18 | static public $type_client_entrees = ["Client", "Prospect"]; |
15 | static public $menu_enregistrement_text = "Type d\'enregistrement?"; | 19 | static public $menu_enregistrement_text = "Type d\'enregistrement?"; |
16 | //static public $menu_enregistrement_entrees = ["Devis", "Facture", "CESU", "Location", "Prestation non vendue"]; | 20 | static public $menu_enregistrement_entrees = ["Devis", "Facture", "Facture à partir d'un devis", "CESU", "Location", "Prestation non vendue"]; |
17 | static public $menu_enregistrement_entrees = ["Facture", "CESU", "Location", "Prestation non vendue"]; | 21 | //~ static public $menu_enregistrement_entrees = ["Devis", "Facture", "CESU", "Location", "Prestation non vendue"]; |
18 | static public $menu_documents_text = "Consulter, imprimer un document LaTeX"; | 22 | static public $menu_documents_text = "Consulter, imprimer un document LaTeX"; |
19 | static public $menu_documents_entrees = ["Devis", "Facture", "Lettre avec adresse", "Livre des recettes", "Registre des achats", "Bilan annuel"]; | 23 | static public $menu_documents_entrees = ["Devis", "Facture", "Lettre avec adresse", "Livre des recettes", "Registre des achats", "Bilan annuel"]; |
20 | static public $menu_communication_text = "Imprimer un support de communication"; | 24 | static public $menu_communication_text = "Imprimer un support de communication"; |
21 | static public $menu_communication_entrees = ["Flyer (nécessite gimp)", "Carte de visite (nécessite scribus)", "Explorateur de fichiers"]; | 25 | static public $menu_communication_entrees = ["Flyer (nécessite gimp)", "Carte de visite (nécessite scribus)", "Explorateur de fichiers"]; |
22 | static public $recherche_client_text = "Recherche d'un client avec son nom ou son code client"; | 26 | static public $recherche_client_text = "Recherche d'un client avec son nom ou son code client"; |
23 | static public $resultats_recherche_client_text = "Résultats de la recherche, sélectionner un client"; | 27 | static public $resultats_recherche_client_text = "Résultats de la recherche, sélectionner un client"; |
28 | static public $resultats_recherche_presta_text = "Sélectionner une prestation"; | ||
24 | static public $nouveau_client_text = "Nouveau client"; | 29 | static public $nouveau_client_text = "Nouveau client"; |
25 | static public $nouveau_client_entrees = ["Prénom Nom:", "Code client, exemple: J.P.Duchmol:", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:"]; | 30 | static public $nouveau_client_entrees = ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:"]; |
26 | static public $calendar_text = 'Nouvelle prestation étape 1/3 - Choisir une date'; | 31 | static public $calendar_text = 'Nouvelle prestation étape 1/3 - Choisir une date'; |
27 | static public $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; | 32 | static public $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; |
28 | 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:"]; | 33 | 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:"]; |
@@ -30,8 +35,19 @@ class ZenitySetup | |||
30 | static public $formulaire_cesu_entrees = ["Tâches effectuées:", "Duree de travail:", "Salaire net", "Mode de paiement"]; // en fait je pourrais ajouter plein d'autres trucs | 35 | static public $formulaire_cesu_entrees = ["Tâches effectuées:", "Duree de travail:", "Salaire net", "Mode de paiement"]; // en fait je pourrais ajouter plein d'autres trucs |
31 | static public $formulaire_location_entrees = ["Désignation du bien", "Modèle, numéro de série, description:", "Valeur", "État des lieux du début:", "État des lieux de fin:", "Durée de la location en mois:", "Loyer mensuel:", "Nombre de loyers déjà payés:", "Montant du chèque de caution:"]; | 36 | static public $formulaire_location_entrees = ["Désignation du bien", "Modèle, numéro de série, description:", "Valeur", "État des lieux du début:", "État des lieux de fin:", "Durée de la location en mois:", "Loyer mensuel:", "Nombre de loyers déjà payés:", "Montant du chèque de caution:"]; |
32 | static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; | 37 | static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; |
33 | static public $recapitulatif_text = "voici toutes les informations enregistrées"; | 38 | |
34 | static public $recapitulatif_entrees = []; | 39 | static public $modification_client = ['text' => 'Modifier une information concernant un client', |
40 | //'lignes' => ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:", "Client ou Prospect?"], // inutile, obtenu par $Client->getAll() | ||
41 | 'service' => "Modifier une prestation", | ||
42 | 'return' => "Retour menu principal"]; | ||
43 | static public $modification_presta = ['text' => 'Modifier une prestation', | ||
44 | 'devis_facture' => "Changer ce devis en facture", | ||
45 | 'service' => "Modifier une autre prestation", | ||
46 | 'return' => "Retour menu précédent"]; | ||
47 | |||
48 | //~ static public $recapitulatif_text = "voici toutes les informations enregistrées"; | ||
49 | //~ static public $recapitulatif_entrees = []; | ||
50 | |||
35 | //static public $question_modification_text = "Prestation enregistrée. Modifier les informations?"; | 51 | //static public $question_modification_text = "Prestation enregistrée. Modifier les informations?"; |
36 | 52 | ||
37 | static public $fin_section_1_text = "Client enregistré"; | 53 | static public $fin_section_1_text = "Client enregistré"; |