summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Config.php57
-rw-r--r--src/Latex.php27
-rw-r--r--src/main.php4
-rw-r--r--src/main_loop.php25
-rw-r--r--src/sections/1_customer.php17
-rw-r--r--src/sections/6_advertising.php28
6 files changed, 69 insertions, 89 deletions
diff --git a/src/Config.php b/src/Config.php
index 5de966f..eea90bd 100644
--- a/src/Config.php
+++ b/src/Config.php
@@ -3,7 +3,7 @@
3 3
4class Config 4class Config
5{ 5{
6 // valeurs par défaut au cas où 6 // valeurs par défaut au cas où
7 static public string $business_name = 'ORDIPOLO'; 7 static public string $business_name = 'ORDIPOLO';
8 static public string $business_guy = 'Paul Jusot'; 8 static public string $business_guy = 'Paul Jusot';
9 static public string $business_address = "2A rue de l'île de Man"; 9 static public string $business_address = "2A rue de l'île de Man";
@@ -21,24 +21,25 @@ class Config
21 static public string $sgbd = 'sqlite'; 21 static public string $sgbd = 'sqlite';
22 static public string $sqlite_gui = 'sqlitebrowser'; // ne pas utiliser si le sgbd n'est pas sqlite 22 static public string $sqlite_gui = 'sqlitebrowser'; // ne pas utiliser si le sgbd n'est pas sqlite
23 static public string $date_format = 'euro'; 23 static public string $date_format = 'euro';
24 static public string $file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre
24 25
25 // ça pourrait être bien de founir sqlite avec l'application pour supprimer une dépendance 26 // ça pourrait être bien de founir sqlite avec l'application pour supprimer une dépendance
26 //~ static public $sqliteBin = 'lib/sqlite_linux'; 27 //~ static public $sqliteBin = 'lib/sqlite_linux';
27 //~ static public $sqliteBin = 'lib/sqlite_win.exe'; 28 //~ static public $sqliteBin = 'lib/sqlite_win.exe';
28 29
29 static private $raw_data; 30 static private array|false $raw_data;
30 31
31 static public function readFile($file_path) 32 static public function readFile(string $file_path): void
32 { 33 {
33 self::$raw_data = parse_ini_file($file_path); 34 self::$raw_data = parse_ini_file($file_path);
34 } 35 }
35 36
36 static public function hydrate() 37 static public function hydrate(): void
37 { 38 {
38 foreach(self::$raw_data as $field => $value) 39 foreach(self::$raw_data as $field => $value)
39 { 40 {
40 if($value != '') // valeur par défaut 41 if($value != '') // valeur par défaut
41 { 42 {
42 if(isset(self::$$field)) // vérification du nom du champ 43 if(isset(self::$$field)) // vérification du nom du champ
43 { 44 {
44 // problème du slash à la fin du nom d'un dossier 45 // problème du slash à la fin du nom d'un dossier
@@ -55,37 +56,37 @@ class Config
55 else 56 else
56 { 57 {
57 echo "debug: le fichier config.ini comporte une erreur, le champ: " . $field . " est incorrect,\nl'information contenue sur cette ligne ne sera pas utilisée\n"; 58 echo "debug: le fichier config.ini comporte une erreur, le champ: " . $field . " est incorrect,\nl'information contenue sur cette ligne ne sera pas utilisée\n";
58 } 59 }
59 } 60 }
60 else 61 else
61 { 62 {
62 echo "debug: le champ " . $field . " est vide, la valeur par défaut " . self::$$field . " sera utilisée.\n"; 63 echo "debug: le champ " . $field . " est vide, la valeur par défaut " . self::$$field . " sera utilisée.\n";
63 } 64 }
64 } 65 }
65 } 66 }
66 67
67 static private function fieldIsPath($field): bool 68 static private function fieldIsPath(string $field): bool
68 { 69 {
69 if($field === 'db_path' || $field === 'latex_path' || $field === 'pdf_path' || $field === 'pub_path') 70 if($field === 'db_path' || $field === 'latex_path' || $field === 'pdf_path' || $field === 'pub_path')
70 { 71 {
71 return true; 72 return true;
72 } 73 }
73 else 74 else
74 { 75 {
75 return false; 76 return false;
76 } 77 }
77 } 78 }
78 79
79 static public function slashAtEndOfPath($path): string 80 static public function slashAtEndOfPath(string $path): string
80 { 81 {
81 if(!str_ends_with($path, '/')) 82 if(!str_ends_with($path, '/'))
82 { 83 {
83 return($path . '/'); 84 return($path . '/');
84 } 85 }
85 else 86 else
86 { 87 {
87 return $path; 88 return $path;
88 } 89 }
89 } 90 }
90 91
91 92
@@ -94,21 +95,21 @@ class Config
94 static private function adjustRelativePath($input) 95 static private function adjustRelativePath($input)
95 { 96 {
96 // chemin windows? 97 // chemin windows?
97 98
98 // chemin relatif ou absolu (par le 1er caractère) 99 // chemin relatif ou absolu (par le 1er caractère)
99 100
100 // obtenir l'emplacement du dossier de l'utilisateur '~' 101 // obtenir l'emplacement du dossier de l'utilisateur '~'
101 $userHomePlace = exec(''); 102 $userHomePlace = exec('');
102 103
103 // obtenir l'emplacement du dossier 'src' 104 // obtenir l'emplacement du dossier 'src'
104 $appExecPlace = getcwd(); 105 $appExecPlace = getcwd();
105 } 106 }
106 107
107 //~ static public function makeDsn() 108 //~ static public function makeDsn()
108 //~ { 109 //~ {
109 //~ if($this->sgbd === 'sqlite') 110 //~ if($this->sgbd === 'sqlite')
110 //~ { 111 //~ {
111 //~ $this->dsn = 'sqlite:' . $this->db_name . '.sqlite'; 112 //~ $this->dsn = 'sqlite:' . $this->db_name . '.sqlite';
112 //~ } 113 //~ }
113 //~ } 114 //~ }
114} 115}
diff --git a/src/Latex.php b/src/Latex.php
index b254551..261d35e 100644
--- a/src/Latex.php
+++ b/src/Latex.php
@@ -150,31 +150,21 @@ abstract class PrestaLatex extends Latex
150} 150}
151class DevisLatex extends PrestaLatex // extends Latex 151class DevisLatex extends PrestaLatex // extends Latex
152{ 152{
153 public function __construct() 153 protected string $type = 'devis';
154 {
155 $this->type = 'devis';
156 }
157} 154}
158class FactureLatex extends PrestaLatex // extends Latex 155class FactureLatex extends PrestaLatex // extends Latex
159{ 156{
160 public function __construct() 157 protected string $type = 'facture';
161 {
162 $this->type = 'facture';
163 }
164} 158}
165class LocationLatex extends PrestaLatex // extends Latex 159class LocationLatex extends PrestaLatex // extends Latex
166{ 160{
167 public function __construct() 161 protected string $type = 'location';
168 {
169 $this->type = 'location';
170 }
171} 162}
172 163
173class EnveloppeRectoLatex extends Latex 164class EnveloppeRectoLatex extends Latex
174{ 165{
175 public function __construct() 166 protected string $type = 'enveloppe_recto';
176 { 167 public function __construct(){
177 $this->type = 'enveloppe_recto';
178 $this->latex_path = Config::$latex_path . 'enveloppes_recto/'; 168 $this->latex_path = Config::$latex_path . 'enveloppes_recto/';
179 $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/'; 169 $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/';
180 } 170 }
@@ -194,10 +184,9 @@ class EnveloppeRectoLatex extends Latex
194} 184}
195class EnveloppeVersoLatex extends Latex 185class EnveloppeVersoLatex extends Latex
196{ 186{
197 public function __construct() 187 protected string $type = 'enveloppe_verso';
198 { 188 protected string $file_name = 'enveloppe_verso.tex';
199 $this->type = 'enveloppe_verso'; 189 public function __construct(){
200 $this->file_name = 'enveloppe_verso.tex';
201 $this->latex_path = Config::$latex_path; 190 $this->latex_path = Config::$latex_path;
202 $this->pdf_path = Config::$pdf_path; 191 $this->pdf_path = Config::$pdf_path;
203 } 192 }
diff --git a/src/main.php b/src/main.php
index ded3248..306038c 100644
--- a/src/main.php
+++ b/src/main.php
@@ -19,9 +19,6 @@ makeFolder(Config::$pdf_path);
19 19
20// variables diverses 20// variables diverses
21$exec_mode = 'gui'; // les versions pure console (CLI) et serveur web (CGI) de ce programme ne sont pas prévues pour l'instant 21$exec_mode = 'gui'; // les versions pure console (CLI) et serveur web (CGI) de ce programme ne sont pas prévues pour l'instant
22$file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre
23$flyer = Config::$pub_path . Config::$flyer;
24$business_card = Config::$pub_path . Config::$business_card;
25Config::$db_path .= Config::$db_name . '.' . Config::$sgbd; 22Config::$db_path .= Config::$db_name . '.' . Config::$sgbd;
26$sqlitebrowser_enable = false; 23$sqlitebrowser_enable = false;
27$sqlite_cli = ''; // commande sqlite ou sqlite3 24$sqlite_cli = ''; // commande sqlite ou sqlite3
@@ -55,4 +52,5 @@ require 'src/sections/2_service.php';
55require 'src/sections/3_modify_data.php'; 52require 'src/sections/3_modify_data.php';
56require 'src/sections/4_get_document.php'; 53require 'src/sections/4_get_document.php';
57require 'src/sections/5_view_data.php'; 54require 'src/sections/5_view_data.php';
55require 'src/sections/6_advertising.php';
58require 'src/main_loop.php'; // action !! 56require 'src/main_loop.php'; // action !!
diff --git a/src/main_loop.php b/src/main_loop.php
index 8dac901..511ced6 100644
--- a/src/main_loop.php
+++ b/src/main_loop.php
@@ -62,36 +62,17 @@ while($main_loop)
62 elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][5] || $section[0] === 6) // = Communication 62 elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][5] || $section[0] === 6) // = Communication
63 { 63 {
64 echo("choix: ". ZenitySetup::$menu_principal['entrees'][5] . "\n"); 64 echo("choix: ". ZenitySetup::$menu_principal['entrees'][5] . "\n");
65 $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication['text'], ZenitySetup::$menu_communication['entrees']); 65 $section = EditAdvertising();
66 $choix_niv2 = exec($MenuCommunication->get());
67 if($choix_niv2 === ZenitySetup::$menu_communication['entrees'][0]) // = Flyer (nécessite gimp)
68 {
69 exec(windowAppCommand(Config::$image_editor, $flyer));
70 }
71 elseif($choix_niv2 === ZenitySetup::$menu_communication['entrees'][1]) // = Carte de visite (nécessite scribus)
72 {
73 exec(windowAppCommand(Config::$publishing, $business_card));
74 }
75 elseif($choix_niv2 === ZenitySetup::$menu_communication['entrees'][2]) // = Explorateur de fichiers
76 {
77 exec(windowAppCommand($file_explorer, Config::$pub_path));
78 }
79 else
80 {
81 // retour menu principal
82 }
83 } 66 }
84 67
85 // -- SECTION 7: BDD -- 68 // -- SECTION 7: BDD --
86 elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][6] || $section[0] === 7) // = Base de données 69 elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][6] || $section[0] === 7) // = Base de données
87 { 70 {
88 echo("choix: ". ZenitySetup::$menu_principal['entrees'][6] . "\n"); 71 echo("choix: ". ZenitySetup::$menu_principal['entrees'][6] . "\n");
89 if($sqlitebrowser_enable) 72 if($sqlitebrowser_enable){
90 {
91 exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path)); 73 exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path));
92 } 74 }
93 else 75 else{
94 {
95 exec($x_term_command . ' ' . $sqlite_cli . ' ' . Config::$db_path); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite 76 exec($x_term_command . ' ' . $sqlite_cli . ' ' . Config::$db_path); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite
96 } 77 }
97 } 78 }
diff --git a/src/sections/1_customer.php b/src/sections/1_customer.php
index db5c448..d282af2 100644
--- a/src/sections/1_customer.php
+++ b/src/sections/1_customer.php
@@ -13,23 +13,6 @@ function newCustomer(): array
13 $FinSection1 = new ZenityList(ZenitySetup::$fin_section_1['text'], ZenitySetup::$fin_section_1['entrees']); 13 $FinSection1 = new ZenityList(ZenitySetup::$fin_section_1['text'], ZenitySetup::$fin_section_1['entrees']);
14 14
15 $Customer = new Client; 15 $Customer = new Client;
16
17 // -- partie 1: client ou prospect? --
18 //~ $choix_niv2 = exec($TypeDeClient->get());
19 //~ if($choix_niv2 === ZenitySetup::$type_client['entrees'][0])
20 //~ {
21 //~ echo "choix: " . $choix_niv2 . "\n";
22 //~ $Customer->setType('client');
23 //~ }
24 //~ elseif($choix_niv2 === ZenitySetup::$type_client['entrees'][1])
25 //~ {
26 //~ echo "choix: " . $choix_niv2 . "\n";
27 //~ $Customer->setType('prospect');
28 //~ }
29 //~ else
30 //~ {
31 //~ return [0, null]; // menu principal
32 //~ }
33 16
34 // -- partie 2: saisie des infos -- 17 // -- partie 2: saisie des infos --
35 if($Customer->enterCustomer($NouveauClient)) 18 if($Customer->enterCustomer($NouveauClient))
diff --git a/src/sections/6_advertising.php b/src/sections/6_advertising.php
new file mode 100644
index 0000000..80ce2d5
--- /dev/null
+++ b/src/sections/6_advertising.php
@@ -0,0 +1,28 @@
1<?php
2// src/sections/6_advertising.php
3//
4// -- SECTION 6: Communication --
5
6function EditAdvertising(): array
7{
8 $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication['text'], ZenitySetup::$menu_communication['entrees']);
9
10 $choix_niv2 = exec($MenuCommunication->get());
11 if($choix_niv2 === ZenitySetup::$menu_communication['entrees'][0]) // = Flyer (nécessite gimp)
12 {
13 exec(windowAppCommand(Config::$image_editor, Config::$pub_path . Config::$flyer));
14 }
15 elseif($choix_niv2 === ZenitySetup::$menu_communication['entrees'][1]) // = Carte de visite (nécessite scribus)
16 {
17 exec(windowAppCommand(Config::$publishing, Config::$pub_path . Config::$business_card));
18 }
19 elseif($choix_niv2 === ZenitySetup::$menu_communication['entrees'][2]) // = Explorateur de fichiers
20 {
21 exec(windowAppCommand(Config::$file_explorer, Config::$pub_path));
22 }
23 else
24 {
25 return [0, null]; // menu principal
26 }
27 return [6, null];
28}