From 1766952a8499919a1275b0214f6ebda8dfc812e2 Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 6 Mar 2023 12:54:43 +0100 Subject: =?UTF-8?q?Config.ini=20renseigner=20''=20=3D=20valeur=20par=20d?= =?UTF-8?q?=C3=A9faut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Config.php | 63 ++++++++++++++++++++++++++--------------------- src/model/Prestations.php | 1 + src/view/Zenity.php | 3 +-- 3 files changed, 37 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/Config.php b/src/Config.php index 1557705..3e2b204 100644 --- a/src/Config.php +++ b/src/Config.php @@ -36,6 +36,41 @@ class Config self::$raw_data = parse_ini_file($file_path); } + static public function hydrate() + { + foreach(self::$raw_data as $field => $value) + { + if($value != '') // valeur par défaut + { + if(isset(self::$$field)) // vérification du nom du champ + { + // vérification du contenu + if(self::fieldIsPath($field)) // cas où le champ db_path, latex_path, pdf_path ou pub_path + { + if(self::checkPath($field, $value)) + { + $value = self::slashAtEndOfPath($value); + self::$$field = $value; + } + } + else // tester le reste? + { + self::$$field = $value; + } + // else: la valeur par défaut est conservée + } + 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"; + } + } + } + static private function fieldIsPath($field): bool { if($field === 'db_path' || $field === 'latex_path' || $field === 'pdf_path' || $field === 'pub_path') @@ -82,34 +117,6 @@ class Config } } - static public function hydrate() - { - foreach(self::$raw_data as $field => $value) - { - if(isset(self::$$field)) // vérification du nom du champ - { - // vérification du contenu - if(self::fieldIsPath($field)) // cas où le champ db_path, latex_path, pdf_path ou pub_path - { - if(self::checkPath($field, $value)) - { - $value = self::slashAtEndOfPath($value); - self::$$field = $value; - } - } - else // tester le reste? - { - self::$$field = $value; - } - // else: la valeur par défaut est conservée - } - 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"; - } - } - } - // à faire plus tard // transformer les chemins pour qu'ils soient relatifs au dossier 'src' où s'exécute le programme static private function adjustRelativePath($input) diff --git a/src/model/Prestations.php b/src/model/Prestations.php index 2011dbe..d246a3d 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php @@ -93,6 +93,7 @@ class Prestations extends Model public function makeCodePresta(Dates $Date, string $code_client) { // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) + // inconvénient: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer $combientieme_fois = count($this->find(['ID_client' => $this->ID_client])) + 1; $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->type_presta, $combientieme_fois]; diff --git a/src/view/Zenity.php b/src/view/Zenity.php index 72d5eed..091a2c0 100644 --- a/src/view/Zenity.php +++ b/src/view/Zenity.php @@ -9,7 +9,6 @@ abstract class ZenityCmd protected $command = 'zenity'; protected $command_type = ''; protected $rows = []; - private $title = 'ORDIPOLO'; protected $text = ''; protected $width = 300; protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 @@ -19,7 +18,7 @@ abstract class ZenityCmd $this->text = $text; $this->rows= $rows; $this->command .= $this->command_type; - $this->command .= ' --title="' . $this->title . '"'; + $this->command .= ' --title="' . Config::$business_name . '"'; $this->command .= ' --text="' . $this->text . '"'; } -- cgit v1.2.3