diff options
author | polo <ordipolo@gmx.fr> | 2022-12-14 12:55:46 +0100 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2022-12-14 12:55:46 +0100 |
commit | ff14091476a35de16a9ea3208501040cfae93a06 (patch) | |
tree | 89ebd00ad68fbb97aac71ef8a2972748f82dee0d /src/view | |
parent | a45a3e0345890b9df3c5fa7c82966a64491eca02 (diff) | |
download | AppliGestionPHP-ff14091476a35de16a9ea3208501040cfae93a06.zip |
MODEL + reorganisation
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/Zenity.php | 110 | ||||
-rw-r--r-- | src/view/zenity_setup.php | 37 |
2 files changed, 147 insertions, 0 deletions
diff --git a/src/view/Zenity.php b/src/view/Zenity.php new file mode 100644 index 0000000..a04b794 --- /dev/null +++ b/src/view/Zenity.php | |||
@@ -0,0 +1,110 @@ | |||
1 | <?php | ||
2 | // php/Zenity.php | ||
3 | // | ||
4 | // commande système zenity | ||
5 | |||
6 | abstract class ZenityCmd | ||
7 | { | ||
8 | protected $command = 'zenity'; | ||
9 | protected $command_type = ''; | ||
10 | protected $rows = []; | ||
11 | private $title = 'ORDIPOLO'; | ||
12 | private $text = ''; | ||
13 | protected $width = 300; | ||
14 | protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 | ||
15 | |||
16 | protected function __construct($text, array $rows = []) // $rows est optionnel | ||
17 | { | ||
18 | $this->text = $text; | ||
19 | $this->rows= $rows; | ||
20 | $this->command .= $this->command_type; | ||
21 | $this->command .= ' --title="' . $this->title . '"'; | ||
22 | $this->command .= ' --text="' . $this->text . '"'; | ||
23 | } | ||
24 | |||
25 | public function get() | ||
26 | { | ||
27 | return($this->command); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | |||
32 | class ZenityList extends ZenityCmd | ||
33 | { | ||
34 | public function __construct($text, array $rows) | ||
35 | { | ||
36 | $this->command_type = ' --list'; | ||
37 | parent::__construct($text, $rows); | ||
38 | $this->height = 80 + count($this->rows) * 25; | ||
39 | $this->command .= ' --width=' . $this->width; | ||
40 | $this->command .= ' --height=' . $this->height; | ||
41 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text | ||
42 | self::one_column_zenity_list($this->rows); | ||
43 | } | ||
44 | |||
45 | public function set_entries($rows_set) // variable renseignée après la construction | ||
46 | { | ||
47 | $this->rows = $rows_set; | ||
48 | } | ||
49 | |||
50 | private function one_column_zenity_list($rows) | ||
51 | { | ||
52 | $output = ' --column=""'; | ||
53 | foreach($rows as $entry) | ||
54 | { | ||
55 | $output .= ' "' . $entry . '"'; // forme: ' "choix 1" "choix 2"' | ||
56 | } | ||
57 | $this->command .= $output; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | class ZenityQuestion extends ZenityCmd | ||
62 | { | ||
63 | public function __construct($text) | ||
64 | { | ||
65 | $this->command_type = ' --question'; | ||
66 | parent::__construct($text); | ||
67 | $this->command .= ' && echo $?'; | ||
68 | // la sortie de "zenity --question" est le statut de sortie "$?" | ||
69 | // $? vaut 0 pour oui, 1 pour non, à ceci près que pour non zenity ne renvoie rien | ||
70 | } | ||
71 | } | ||
72 | |||
73 | class ZenityForms extends ZenityCmd | ||
74 | { | ||
75 | public function __construct($text, array $rows) | ||
76 | { | ||
77 | $this->command_type = ' --forms'; | ||
78 | parent::__construct($text, $rows); | ||
79 | //$this->height = 80 + count($this->rows) * 25; // à tester, mais devrait produire le rendu attendu | ||
80 | self::entries_zenity_forms($this->rows); | ||
81 | } | ||
82 | |||
83 | private function entries_zenity_forms($entries) | ||
84 | { | ||
85 | $output = ''; | ||
86 | foreach($entries as $one_entry) | ||
87 | { | ||
88 | $output .= ' --add-entry="' . $one_entry . '"'; // forme: ' "choix 1" "choix 2"' | ||
89 | } | ||
90 | $this->command .= $output; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | class ZenityCalendar extends ZenityCmd | ||
95 | { | ||
96 | public function __construct($text) | ||
97 | { | ||
98 | $this->command_type = ' --calendar'; | ||
99 | parent::__construct($text); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | class ZenityEntry extends ZenityCmd | ||
104 | { | ||
105 | public function __construct($text) | ||
106 | { | ||
107 | $this->command_type = ' --entry'; | ||
108 | parent::__construct($text); | ||
109 | } | ||
110 | } | ||
diff --git a/src/view/zenity_setup.php b/src/view/zenity_setup.php new file mode 100644 index 0000000..2f55cf2 --- /dev/null +++ b/src/view/zenity_setup.php | |||
@@ -0,0 +1,37 @@ | |||
1 | <?php | ||
2 | // php/zenity_setup.php | ||
3 | |||
4 | |||
5 | // contenu des fenêtres zenity | ||
6 | $menu_principal_text = "Gestion d'une micro-entreprise"; | ||
7 | $menu_principal_entrees = ["Nouvelle prestation", "Modifier enregistrement", "Fichier clients", "Créer/imprimer un document", "Communication", "Base de données"]; | ||
8 | $question_nouveau_client_text = "Ce client figure t\'il déjà dans le fichier clients?"; | ||
9 | $menu_enregistrement_text = "Type d\'enregistrement?"; | ||
10 | $menu_enregistrement_entrees = ["Devis", "Facture", "CESU", "Pas de prestation"]; | ||
11 | $menu_documents_text = "Création de documents LaTeX"; | ||
12 | $menu_documents_entrees = ["Devis", "Facture", "Lettre avec adresse", "Livre des recettes", "Registre des achats", "Bilan annuel"]; | ||
13 | $menu_communication_text = "Imprimer un support de communication"; | ||
14 | $menu_communication_entrees = ["Flyer (nécessite gimp)", "Carte de visite (nécessite scribus)", "Explorateur de fichiers"]; | ||
15 | $recherche_client_text = "Recherche d'un client avec son nom ou son code client"; | ||
16 | $resultats_recherche_client_text = "Résultats de la recherche, sélectionner un client"; | ||
17 | $nouveau_client_text = "Nouveau client"; | ||
18 | $nouveau_client_entrees = ["Prénom Nom:", "Adresse:", "Code client, type: J.P.Duchmol"]; | ||
19 | $calendar_text = 'Nouvelle prestation étape 1/3 - Choisir une date'; | ||
20 | $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; | ||
21 | $formulaire_entrees = ["Tâches effectuées:", "Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Temps main d\'oeuvre (heures):", "Total main d\'oeuvre (euros):", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):",]; | ||
22 | $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; | ||
23 | |||
24 | |||
25 | // commandes système qui ouvrent les fenêtres zenity, un objet = une commande | ||
26 | // s'utilisent comme ceci: exec($Objet->get()); | ||
27 | $MenuPrincipal = new ZenityList($menu_principal_text, $menu_principal_entrees); | ||
28 | $QuestionNouveauClient = new ZenityQuestion($question_nouveau_client_text); | ||
29 | $MenuEnregistrement = new ZenityList($menu_enregistrement_text, $menu_enregistrement_entrees); | ||
30 | $MenuDocuments = new ZenityList($menu_documents_text, $menu_documents_entrees); | ||
31 | $MenuCommunication = new ZenityList($menu_communication_text, $menu_communication_entrees); | ||
32 | $RechercheClient = new zenityEntry($recherche_client_text); | ||
33 | $ResultatsRechercheClient = new zenityList($resultats_recherche_client_text, []); | ||
34 | $NouveauClient = new ZenityForms($nouveau_client_text, $nouveau_client_entrees); | ||
35 | $Calendrier = new ZenityCalendar($calendar_text); | ||
36 | $FormulairePrestation = new ZenityForms($formulaire_text, $formulaire_entrees); | ||
37 | $CommentairePrestation = new ZenityEntry($commentaire_prestation_text); | ||