diff options
author | polo <ordipolo@gmx.fr> | 2023-03-06 12:54:43 +0100 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2023-03-06 12:54:43 +0100 |
commit | 1766952a8499919a1275b0214f6ebda8dfc812e2 (patch) | |
tree | ad5bd20b8c5b29a26d1b63071d18af688a0b0df4 /src | |
parent | b9c74de6d12ef40ab4baf67303ab22a10fcd5b32 (diff) | |
download | AppliGestionPHP-1766952a8499919a1275b0214f6ebda8dfc812e2.zip |
Config.ini renseigner '' = valeur par défaut
Diffstat (limited to 'src')
-rw-r--r-- | src/Config.php | 63 | ||||
-rw-r--r-- | src/model/Prestations.php | 1 | ||||
-rw-r--r-- | src/view/Zenity.php | 3 |
3 files changed, 37 insertions, 30 deletions
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 | |||
36 | self::$raw_data = parse_ini_file($file_path); | 36 | self::$raw_data = parse_ini_file($file_path); |
37 | } | 37 | } |
38 | 38 | ||
39 | static public function hydrate() | ||
40 | { | ||
41 | foreach(self::$raw_data as $field => $value) | ||
42 | { | ||
43 | if($value != '') // valeur par défaut | ||
44 | { | ||
45 | if(isset(self::$$field)) // vérification du nom du champ | ||
46 | { | ||
47 | // vérification du contenu | ||
48 | if(self::fieldIsPath($field)) // cas où le champ db_path, latex_path, pdf_path ou pub_path | ||
49 | { | ||
50 | if(self::checkPath($field, $value)) | ||
51 | { | ||
52 | $value = self::slashAtEndOfPath($value); | ||
53 | self::$$field = $value; | ||
54 | } | ||
55 | } | ||
56 | else // tester le reste? | ||
57 | { | ||
58 | self::$$field = $value; | ||
59 | } | ||
60 | // else: la valeur par défaut est conservée | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | 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"; | ||
65 | } | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | echo "debug: le champ " . $field . " est vide, la valeur par défaut " . self::$$field . " sera utilisée.\n"; | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | |||
39 | static private function fieldIsPath($field): bool | 74 | static private function fieldIsPath($field): bool |
40 | { | 75 | { |
41 | if($field === 'db_path' || $field === 'latex_path' || $field === 'pdf_path' || $field === 'pub_path') | 76 | if($field === 'db_path' || $field === 'latex_path' || $field === 'pdf_path' || $field === 'pub_path') |
@@ -82,34 +117,6 @@ class Config | |||
82 | } | 117 | } |
83 | } | 118 | } |
84 | 119 | ||
85 | static public function hydrate() | ||
86 | { | ||
87 | foreach(self::$raw_data as $field => $value) | ||
88 | { | ||
89 | if(isset(self::$$field)) // vérification du nom du champ | ||
90 | { | ||
91 | // vérification du contenu | ||
92 | if(self::fieldIsPath($field)) // cas où le champ db_path, latex_path, pdf_path ou pub_path | ||
93 | { | ||
94 | if(self::checkPath($field, $value)) | ||
95 | { | ||
96 | $value = self::slashAtEndOfPath($value); | ||
97 | self::$$field = $value; | ||
98 | } | ||
99 | } | ||
100 | else // tester le reste? | ||
101 | { | ||
102 | self::$$field = $value; | ||
103 | } | ||
104 | // else: la valeur par défaut est conservée | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | 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"; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | // à faire plus tard | 120 | // à faire plus tard |
114 | // transformer les chemins pour qu'ils soient relatifs au dossier 'src' où s'exécute le programme | 121 | // transformer les chemins pour qu'ils soient relatifs au dossier 'src' où s'exécute le programme |
115 | static private function adjustRelativePath($input) | 122 | 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 | |||
93 | public function makeCodePresta(Dates $Date, string $code_client) | 93 | public function makeCodePresta(Dates $Date, string $code_client) |
94 | { | 94 | { |
95 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) | 95 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) |
96 | // inconvénient: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer | ||
96 | $combientieme_fois = count($this->find(['ID_client' => $this->ID_client])) + 1; | 97 | $combientieme_fois = count($this->find(['ID_client' => $this->ID_client])) + 1; |
97 | 98 | ||
98 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->type_presta, $combientieme_fois]; | 99 | $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 | |||
9 | protected $command = 'zenity'; | 9 | protected $command = 'zenity'; |
10 | protected $command_type = ''; | 10 | protected $command_type = ''; |
11 | protected $rows = []; | 11 | protected $rows = []; |
12 | private $title = 'ORDIPOLO'; | ||
13 | protected $text = ''; | 12 | protected $text = ''; |
14 | protected $width = 300; | 13 | protected $width = 300; |
15 | protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 | 14 | protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 |
@@ -19,7 +18,7 @@ abstract class ZenityCmd | |||
19 | $this->text = $text; | 18 | $this->text = $text; |
20 | $this->rows= $rows; | 19 | $this->rows= $rows; |
21 | $this->command .= $this->command_type; | 20 | $this->command .= $this->command_type; |
22 | $this->command .= ' --title="' . $this->title . '"'; | 21 | $this->command .= ' --title="' . Config::$business_name . '"'; |
23 | $this->command .= ' --text="' . $this->text . '"'; | 22 | $this->command .= ' --text="' . $this->text . '"'; |
24 | } | 23 | } |
25 | 24 | ||