diff options
Diffstat (limited to 'index.php')
-rwxr-xr-x | index.php | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/index.php b/index.php new file mode 100755 index 0000000..cf54199 --- /dev/null +++ b/index.php | |||
@@ -0,0 +1,203 @@ | |||
1 | #!/bin/php | ||
2 | <?php | ||
3 | // index.php | ||
4 | |||
5 | // configuration du programme par l'utilisateur | ||
6 | require('config.php'); // fichier de l'utilisateur | ||
7 | //require('config_check.php'); // contrôle de config.php | ||
8 | |||
9 | // variables diverses, certaines utilisent les variables de config.php | ||
10 | $exec_mode = 'gui'; // les versions pure console (CLI) et serveur web (CGI) de ce programme ne sont pas prévues pour l'instant | ||
11 | $file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre | ||
12 | $flyer = $pub . $flyer; | ||
13 | $business_card = $pub . $business_card; | ||
14 | $db_place .= $db_name . '.sqlite'; | ||
15 | $sqlitebrowser_enable = false; | ||
16 | $sqlite_cli = ''; // commande sqlite ou sqlite3 | ||
17 | $x_term_command = ''; // commande terminal en mode graphique | ||
18 | |||
19 | require('php/dependances.php'); // vérification des dépendances | ||
20 | require('php/functions.php'); | ||
21 | |||
22 | require('php/ZenityClasses.php'); // créer les commandes | ||
23 | require('php/zenity_text.php'); // texte dans les fenêtres | ||
24 | |||
25 | require('php/Database.php'); // connexion à la base et création de la base et des tables si elles n'existent pas déjà | ||
26 | $Database = new SQL; | ||
27 | SQL::create_tables(); | ||
28 | |||
29 | // require('php/latex.php'); | ||
30 | // require('php/compileLatex.php'); | ||
31 | |||
32 | // commandes système qui ouvrent les fenêtres zenity | ||
33 | // s'utilisent comme ceci: exec($Objet->get()); | ||
34 | $MenuPrincipal = new Zenity_list($menu_principal_text, $menu_principal_entrees); | ||
35 | $QuestionNouveauClient = new Zenity_question($question_nouveau_client_text); | ||
36 | $MenuEnregistrement = new Zenity_list($menu_enregistrement_text, $menu_enregistrement_entrees); | ||
37 | $MenuDocuments = new Zenity_list($menu_documents_text, $menu_documents_entrees); | ||
38 | $MenuCommunication = new Zenity_list($menu_communication_text, $menu_communication_entrees); | ||
39 | $RechercheClient = new zenity_entry($recherche_client_text); | ||
40 | $ResultatsRechercheClient = new zenity_list($resultats_recherche_client_text, []); | ||
41 | $NouveauClient = new Zenity_forms($nouveau_client_text, $nouveau_client_entrees); | ||
42 | $Calendrier = new Zenity_calendar($calendar_text); | ||
43 | $FormulairePrestation = new Zenity_forms($formulaire_text, $formulaire_entrees); | ||
44 | $CommentairePrestation = new Zenity_entry($commentaire_prestation_text); | ||
45 | |||
46 | // boucle principale | ||
47 | $boucle = true; | ||
48 | while($boucle) | ||
49 | { | ||
50 | // menu principal | ||
51 | $choix_niv1 = exec($MenuPrincipal->get()); | ||
52 | |||
53 | // enregistrement | ||
54 | if($choix_niv1 == 'Nouvelle prestation') | ||
55 | { | ||
56 | // est ce que le client est déjà dans la base? | ||
57 | if(exec($QuestionNouveauClient->get()) == 0) // $? = 0 signifie oui | ||
58 | { | ||
59 | // saisie du nom du client et recherche | ||
60 | $client_saisie = exec($RechercheClient->get()); | ||
61 | |||
62 | // sélection parmi les résultats | ||
63 | $ResultatsRechercheClient->set_entries(recherche_client($client_saisie)); | ||
64 | $choix_niv2 = exec($ResultatsRechercheClient->get()); | ||
65 | if($choix_niv2 != '') | ||
66 | { | ||
67 | echo "client trouvé\n"; | ||
68 | } | ||
69 | else // chaîne vide | ||
70 | { | ||
71 | echo "client pas trouvé\n"; | ||
72 | exec($NouveauClient->get()); | ||
73 | |||
74 | // enregistrement dans la BDD | ||
75 | |||
76 | } | ||
77 | |||
78 | // récupération des infos dans la BDD | ||
79 | |||
80 | } | ||
81 | else | ||
82 | { | ||
83 | echo "nouveau client\n"; | ||
84 | exec($NouveauClient->get()); | ||
85 | |||
86 | // enregistrement dans la BDD | ||
87 | |||
88 | } | ||
89 | |||
90 | // infos sur la prestation | ||
91 | $choix_niv2 = exec($MenuEnregistrement->get()); | ||
92 | $continuer = true; | ||
93 | if($choix_niv2 == "Devis") | ||
94 | { | ||
95 | $type = 'DEVIS'; | ||
96 | } | ||
97 | elseif($choix_niv2 == "Facture") | ||
98 | { | ||
99 | $type = 'FACTURE'; | ||
100 | } | ||
101 | elseif($choix_niv2 == "CESU") | ||
102 | { | ||
103 | $type = 'CESU'; | ||
104 | } | ||
105 | elseif($choix_niv2 == "Pas de prestation") | ||
106 | { | ||
107 | $type = ''; | ||
108 | } | ||
109 | else | ||
110 | { | ||
111 | $continuer = false; // retour menu principal | ||
112 | } | ||
113 | |||
114 | if($continuer) | ||
115 | { | ||
116 | exec($Calendrier->get()); | ||
117 | exec($FormulairePrestation->get()); | ||
118 | // enregistrement date et prestation en BDD | ||
119 | exec($CommentairePrestation->get()); | ||
120 | // enregistrement commentaire en BDD | ||
121 | } | ||
122 | } | ||
123 | |||
124 | elseif($choix_niv1 == 'Fichier clients') | ||
125 | { | ||
126 | // quel affichage? un grand tableau avec zenity? une page web? un document LaTeX? | ||
127 | } | ||
128 | |||
129 | // documents à imprimer | ||
130 | elseif($choix_niv1 == 'Créer/imprimer un document') | ||
131 | { | ||
132 | $choix_niv2 = exec($MenuDocuments->get()); | ||
133 | if($choix_niv2 == 'Devis') | ||
134 | { | ||
135 | |||
136 | } | ||
137 | elseif($choix_niv2 == 'Facture') | ||
138 | { | ||
139 | |||
140 | } | ||
141 | elseif($choix_niv2 == 'Lettre avec adresse') | ||
142 | { | ||
143 | |||
144 | } | ||
145 | elseif($choix_niv2 == 'Livre des recettes') | ||
146 | { | ||
147 | |||
148 | } | ||
149 | elseif($choix_niv2 == "Registre des achats") | ||
150 | { | ||
151 | |||
152 | } | ||
153 | elseif($choix_niv2 == "Bilan annuel") | ||
154 | { | ||
155 | |||
156 | } | ||
157 | else | ||
158 | { | ||
159 | // retour menu principal | ||
160 | } | ||
161 | } | ||
162 | |||
163 | // Supports de communication | ||
164 | elseif($choix_niv1 == 'Communication') | ||
165 | { | ||
166 | $choix_niv2 = exec($MenuCommunication->get()); | ||
167 | if($choix_niv2 == 'Flyer (nécessite gimp)') | ||
168 | { | ||
169 | exec(window_app_command('gimp', $flyer)); | ||
170 | } | ||
171 | elseif($choix_niv2 == 'Carte de visite (nécessite scribus)') | ||
172 | { | ||
173 | exec(window_app_command('scribus', $business_card)); | ||
174 | } | ||
175 | elseif($choix_niv2 == 'Explorateur de fichiers') | ||
176 | { | ||
177 | exec(window_app_command($file_explorer, $pub)); | ||
178 | } | ||
179 | else | ||
180 | { | ||
181 | // retour menu principal | ||
182 | } | ||
183 | } | ||
184 | |||
185 | // BDD | ||
186 | elseif($choix_niv1 == 'Base de données') | ||
187 | { | ||
188 | if($sqlitebrowser_enable) | ||
189 | { | ||
190 | exec(window_app_command('sqlitebrowser', $db_place)); | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | exec($x_term_command . ' ' . $sqlite_cli . ' ' . $db_place); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite | ||
195 | } | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | $boucle = false; // byebye | ||
200 | } | ||
201 | } | ||
202 | |||
203 | // sauvegarder la base de données | ||