From 39d4558eaf5fa5fd6060a0f202b22bcec5a982dc Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 9 Oct 2026 15:09:38 +0200 Subject: =?UTF-8?q?variables=20d=C3=A9plac=C3=A9es=20dans=20Config,=20supp?= =?UTF-8?q?ressions=20constructeurs=20Latex.php,=20=C3=A9bauche=20de=20sec?= =?UTF-8?q?tion=206=5Fadvertising,=20un=20peu=20de=20typage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Config.php | 57 +++++++++++++++++++++--------------------- src/Latex.php | 27 ++++++-------------- src/main.php | 4 +-- src/main_loop.php | 25 +++--------------- src/sections/1_customer.php | 17 ------------- src/sections/6_advertising.php | 28 +++++++++++++++++++++ 6 files changed, 69 insertions(+), 89 deletions(-) create mode 100644 src/sections/6_advertising.php (limited to 'src') 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 @@ class Config { - // valeurs par défaut au cas où + // valeurs par défaut au cas où static public string $business_name = 'ORDIPOLO'; static public string $business_guy = 'Paul Jusot'; static public string $business_address = "2A rue de l'île de Man"; @@ -21,24 +21,25 @@ class Config static public string $sgbd = 'sqlite'; static public string $sqlite_gui = 'sqlitebrowser'; // ne pas utiliser si le sgbd n'est pas sqlite static public string $date_format = 'euro'; + static public string $file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre // ça pourrait être bien de founir sqlite avec l'application pour supprimer une dépendance //~ static public $sqliteBin = 'lib/sqlite_linux'; //~ static public $sqliteBin = 'lib/sqlite_win.exe'; - static private $raw_data; + static private array|false $raw_data; - static public function readFile($file_path) - { - self::$raw_data = parse_ini_file($file_path); + static public function readFile(string $file_path): void + { + self::$raw_data = parse_ini_file($file_path); } - static public function hydrate() + static public function hydrate(): void { foreach(self::$raw_data as $field => $value) { if($value != '') // valeur par défaut - { + { if(isset(self::$$field)) // vérification du nom du champ { // problème du slash à la fin du nom d'un dossier @@ -55,37 +56,37 @@ class Config else { 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"; - } + } } else - { - echo "debug: le champ " . $field . " est vide, la valeur par défaut " . self::$$field . " sera utilisée.\n"; + { + echo "debug: le champ " . $field . " est vide, la valeur par défaut " . self::$$field . " sera utilisée.\n"; } } } - static private function fieldIsPath($field): bool - { + static private function fieldIsPath(string $field): bool + { if($field === 'db_path' || $field === 'latex_path' || $field === 'pdf_path' || $field === 'pub_path') - { - return true; + { + return true; } else - { - return false; - } + { + return false; + } } - static public function slashAtEndOfPath($path): string + static public function slashAtEndOfPath(string $path): string { if(!str_ends_with($path, '/')) { return($path . '/'); } else - { - return $path; - } + { + return $path; + } } @@ -94,21 +95,21 @@ class Config static private function adjustRelativePath($input) { // chemin windows? - + // chemin relatif ou absolu (par le 1er caractère) // obtenir l'emplacement du dossier de l'utilisateur '~' $userHomePlace = exec(''); // obtenir l'emplacement du dossier 'src' - $appExecPlace = getcwd(); + $appExecPlace = getcwd(); } //~ static public function makeDsn() - //~ { + //~ { //~ if($this->sgbd === 'sqlite') - //~ { - //~ $this->dsn = 'sqlite:' . $this->db_name . '.sqlite'; - //~ } - //~ } + //~ { + //~ $this->dsn = 'sqlite:' . $this->db_name . '.sqlite'; + //~ } + //~ } } 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 } class DevisLatex extends PrestaLatex // extends Latex { - public function __construct() - { - $this->type = 'devis'; - } + protected string $type = 'devis'; } class FactureLatex extends PrestaLatex // extends Latex { - public function __construct() - { - $this->type = 'facture'; - } + protected string $type = 'facture'; } class LocationLatex extends PrestaLatex // extends Latex { - public function __construct() - { - $this->type = 'location'; - } + protected string $type = 'location'; } class EnveloppeRectoLatex extends Latex { - public function __construct() - { - $this->type = 'enveloppe_recto'; + protected string $type = 'enveloppe_recto'; + public function __construct(){ $this->latex_path = Config::$latex_path . 'enveloppes_recto/'; $this->pdf_path = Config::$pdf_path . 'enveloppes_recto/'; } @@ -194,10 +184,9 @@ class EnveloppeRectoLatex extends Latex } class EnveloppeVersoLatex extends Latex { - public function __construct() - { - $this->type = 'enveloppe_verso'; - $this->file_name = 'enveloppe_verso.tex'; + protected string $type = 'enveloppe_verso'; + protected string $file_name = 'enveloppe_verso.tex'; + public function __construct(){ $this->latex_path = Config::$latex_path; $this->pdf_path = Config::$pdf_path; } 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); // variables diverses $exec_mode = 'gui'; // les versions pure console (CLI) et serveur web (CGI) de ce programme ne sont pas prévues pour l'instant -$file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre -$flyer = Config::$pub_path . Config::$flyer; -$business_card = Config::$pub_path . Config::$business_card; Config::$db_path .= Config::$db_name . '.' . Config::$sgbd; $sqlitebrowser_enable = false; $sqlite_cli = ''; // commande sqlite ou sqlite3 @@ -55,4 +52,5 @@ require 'src/sections/2_service.php'; require 'src/sections/3_modify_data.php'; require 'src/sections/4_get_document.php'; require 'src/sections/5_view_data.php'; +require 'src/sections/6_advertising.php'; require '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) elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][5] || $section[0] === 6) // = Communication { echo("choix: ". ZenitySetup::$menu_principal['entrees'][5] . "\n"); - $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication['text'], ZenitySetup::$menu_communication['entrees']); - $choix_niv2 = exec($MenuCommunication->get()); - if($choix_niv2 === ZenitySetup::$menu_communication['entrees'][0]) // = Flyer (nécessite gimp) - { - exec(windowAppCommand(Config::$image_editor, $flyer)); - } - elseif($choix_niv2 === ZenitySetup::$menu_communication['entrees'][1]) // = Carte de visite (nécessite scribus) - { - exec(windowAppCommand(Config::$publishing, $business_card)); - } - elseif($choix_niv2 === ZenitySetup::$menu_communication['entrees'][2]) // = Explorateur de fichiers - { - exec(windowAppCommand($file_explorer, Config::$pub_path)); - } - else - { - // retour menu principal - } + $section = EditAdvertising(); } // -- SECTION 7: BDD -- elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][6] || $section[0] === 7) // = Base de données { echo("choix: ". ZenitySetup::$menu_principal['entrees'][6] . "\n"); - if($sqlitebrowser_enable) - { + if($sqlitebrowser_enable){ exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path)); } - else - { + else{ exec($x_term_command . ' ' . $sqlite_cli . ' ' . Config::$db_path); // correpond à priori à: xterm -e sqlite3 ~/ORDIPOLO/Appli_PHP/ordipolo.sqlite } } 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 $FinSection1 = new ZenityList(ZenitySetup::$fin_section_1['text'], ZenitySetup::$fin_section_1['entrees']); $Customer = new Client; - - // -- partie 1: client ou prospect? -- - //~ $choix_niv2 = exec($TypeDeClient->get()); - //~ if($choix_niv2 === ZenitySetup::$type_client['entrees'][0]) - //~ { - //~ echo "choix: " . $choix_niv2 . "\n"; - //~ $Customer->setType('client'); - //~ } - //~ elseif($choix_niv2 === ZenitySetup::$type_client['entrees'][1]) - //~ { - //~ echo "choix: " . $choix_niv2 . "\n"; - //~ $Customer->setType('prospect'); - //~ } - //~ else - //~ { - //~ return [0, null]; // menu principal - //~ } // -- partie 2: saisie des infos -- 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 @@ +get()); + if($choix_niv2 === ZenitySetup::$menu_communication['entrees'][0]) // = Flyer (nécessite gimp) + { + exec(windowAppCommand(Config::$image_editor, Config::$pub_path . Config::$flyer)); + } + elseif($choix_niv2 === ZenitySetup::$menu_communication['entrees'][1]) // = Carte de visite (nécessite scribus) + { + exec(windowAppCommand(Config::$publishing, Config::$pub_path . Config::$business_card)); + } + elseif($choix_niv2 === ZenitySetup::$menu_communication['entrees'][2]) // = Explorateur de fichiers + { + exec(windowAppCommand(Config::$file_explorer, Config::$pub_path)); + } + else + { + return [0, null]; // menu principal + } + return [6, null]; +} -- cgit v1.2.3