diff options
author | polo <ordipolo@gmx.fr> | 2023-02-25 02:27:22 +0100 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2023-02-25 02:27:22 +0100 |
commit | 9d8133643773912d54fb0c7d86ef04e6acffa8c9 (patch) | |
tree | 8048a9eeded086e9e9c00ce0a68b9454c171d085 | |
parent | 209c0b93c529356a094d7133a717e8f6ee6d90c6 (diff) | |
download | AppliGestionPHP-9d8133643773912d54fb0c7d86ef04e6acffa8c9.zip |
lire tables, modifications BDD, création documents et enveloppes latex, suppression de traits.php
-rw-r--r-- | README.txt | 28 | ||||
-rw-r--r-- | config.ini | 12 | ||||
-rw-r--r-- | data/dev.sqlite (renamed from data/ordipolo.sqlite) | bin | 32768 -> 36864 bytes | |||
-rw-r--r-- | data/latex/ordipolo.png (renamed from data/ordipolo.png) | bin | 46751 -> 46751 bytes | |||
-rw-r--r-- | src/Config.php | 6 | ||||
-rw-r--r-- | src/Dates.php | 87 | ||||
-rw-r--r-- | src/functions.php | 82 | ||||
-rw-r--r-- | src/latex_templates/devis.php (renamed from data/templates/devis.php) | 26 | ||||
-rw-r--r-- | src/latex_templates/enveloppe_recto.php (renamed from data/templates/enveloppe_recto.php) | 10 | ||||
-rw-r--r-- | src/latex_templates/enveloppe_verso.pdf | bin | 0 -> 26388 bytes | |||
-rw-r--r-- | src/latex_templates/enveloppe_verso.php (renamed from data/templates/enveloppe_verso.php) | 9 | ||||
-rw-r--r-- | src/latex_templates/facture.php (renamed from data/templates/facture.php) | 32 | ||||
-rw-r--r-- | src/latex_templates/location.php (renamed from data/templates/location.php) | 2 | ||||
-rw-r--r-- | src/latex_templates/ordipolo.png | bin | 0 -> 46751 bytes | |||
-rw-r--r-- | src/latex_templates/originaux_pas_toucher/devis.tex (renamed from data/originaux pas toucher/devis.tex) | 2 | ||||
-rw-r--r-- | src/latex_templates/originaux_pas_toucher/enveloppe_recto.tex (renamed from data/originaux pas toucher/enveloppe_recto.tex) | 0 | ||||
-rw-r--r-- | src/latex_templates/originaux_pas_toucher/enveloppe_verso.tex (renamed from data/originaux pas toucher/enveloppe_verso.tex) | 2 | ||||
-rw-r--r-- | src/latex_templates/originaux_pas_toucher/facture.tex (renamed from data/originaux pas toucher/facture.tex) | 0 | ||||
-rw-r--r-- | src/latex_templates/originaux_pas_toucher/location.tex (renamed from data/originaux pas toucher/location.tex) | 0 | ||||
-rwxr-xr-x | src/main.php | 4 | ||||
-rw-r--r-- | src/model/CESU.php | 29 | ||||
-rw-r--r-- | src/model/Clients.php | 31 | ||||
-rw-r--r-- | src/model/DB.php | 2 | ||||
-rw-r--r-- | src/model/DevisFactures.php | 44 | ||||
-rw-r--r-- | src/model/Locations.php | 69 | ||||
-rw-r--r-- | src/model/Model.php | 95 | ||||
-rw-r--r-- | src/model/Prestations.php | 14 | ||||
-rw-r--r-- | src/model/StructTablesDB.php | 6 | ||||
-rw-r--r-- | src/model/traits.php | 86 | ||||
-rw-r--r-- | src/sections/1_new_service.php | 68 | ||||
-rw-r--r-- | src/view/ZenitySetup.php | 8 |
31 files changed, 434 insertions, 320 deletions
@@ -1,23 +1,37 @@ | |||
1 | ATTENTION | ||
2 | Ce programme est destiné à un usage privé et hors-ligne, | ||
3 | il ne nécessite pas de déclaration à la CNIL. | ||
4 | Il ne comporte aucune fonctionnalité réseau, ni aucune sécurité. | ||
5 | L'utilisateur est responsable des informations enregistrées, | ||
6 | lesquelles ne sont destinées sortir de son ordinteur. | ||
7 | |||
8 | |||
1 | OS compatible: | 9 | OS compatible: |
2 | linux! | 10 | linux! |
3 | bsd et mac sont probablement compatibles si les dépendances requises sont disponibles | 11 | bsd et mac sont probablement compatibles si les dépendances requises sont disponibles |
4 | pas de version windows prévue | 12 | pas de version windows prévue |
5 | 13 | ||
6 | dépendances obligatoires: | 14 | dépendances obligatoires: |
7 | - php-cli (si votre distribution sépare php serveur web de php ligne de commande, installer le paquet php-cli) | 15 | - php-cli (certaines distributions (= debian) séparent php serveur web de php ligne de commande, installer le paquet php-cli) |
8 | version minimale de php = | 16 | version minimale de php = |
9 | - php-sqlite (moteur de base de données, activer si nécessaire le module pdo-sqlite dans le php.ini) | 17 | - php-sqlite (moteur de base de données, activer si nécessaire le module pdo-sqlite dans le php.ini) |
18 | - un environnement graphique | ||
10 | - zenity (fenêtres GTK pour scripts console) | 19 | - zenity (fenêtres GTK pour scripts console) |
11 | - une distribution LaTeX pour le compiler en fichiers PDF Ã l'aide de la commande pdflatex (j'utilise TeX Live) | 20 | - une distribution LaTeX permettant la compilation en PDF Ã l'aide de la commande pdflatex (j'utilise TeX Live) |
12 | - interpréteurs sh, bash, ksh, csh, tcsh | 21 | - interpréteurs supportés: sh, bash, ksh, csh, tcsh |
22 | |||
23 | dépendances recommandées: | ||
24 | - sqlite (tellement d'applications en ont besoin qu'il serait surprenant qu'il soit absent | ||
13 | 25 | ||
14 | dépendances optionnelles: | 26 | dépendances optionnelles: |
15 | - sqlitebrowser (interface graphique pour sqlite) | 27 | - sqlitebrowser (interface graphique pour sqlite) |
16 | si absent, le script essaie de lancer "sqlite3" dans "xterm" | 28 | si absence de sqlitebrowser, le programme essaiera de lancer "sqlite3" dans le terminal "xterm" |
29 | |||
17 | 30 | ||
18 | 31 | ||
19 | installation: | 32 | installation: |
20 | - placer ce dossier où vous le souhaitez | 33 | - placer ce dossier où vous le souhaitez |
34 | - vérifier les autorisations du dossier "data" et de tout son contenu (normallement il n'y a rien à faire) | ||
21 | - ouvrir le fichier "logiciel compta.desktop" avec un éditeur de texte et adapter les chemins | 35 | - ouvrir le fichier "logiciel compta.desktop" avec un éditeur de texte et adapter les chemins |
22 | - copier le fichier"logiciel compta.desktop" dans le dossier système des entrées du menu ou/et sur le bureau | 36 | - copier le fichier"logiciel compta.desktop" dans le dossier système des entrées du menu ou/et sur le bureau |
23 | - ouvrir le fichier config.php et corriger si nécessaire: $business_name, $db_name, $flyer, $business_card | 37 | - ouvrir le fichier config.php et corriger si nécessaire: $business_name, $db_name, $flyer, $business_card |
@@ -26,10 +40,10 @@ son emplacement est par défaut à la racine de ce programme, tout comme ce fich | |||
26 | 40 | ||
27 | 41 | ||
28 | configuration: | 42 | configuration: |
29 | - veuillez modifier les variables dans config.php | 43 | - ça se passe dans le fichier config.ini |
30 | ATTENTION, si vous ne savez pas ce que vous faîtes, ne faites rien. | 44 | ATTENTION, si vous ne savez pas ce que vous faîtes, ne faites rien. |
31 | Pour réparer la configuration, saisissez une chaîne vide ou la valeur par défaut comme dans les exemples ci-dessous. | 45 | Pour réparer la configuration, saisissez une chaîne vide ou la valeur par défaut comme dans les exemples ci-dessous. |
32 | chaîne vide: | 46 | chaîne vide: |
33 | $receipts = ''; | 47 | receipts = '' |
34 | valeur par défaut: | 48 | valeur par défaut: |
35 | $receipts = '~/ORDIPOLO/factures/'; | 49 | receipts = '~/ORDIPOLO/factures/' |
@@ -6,14 +6,22 @@ | |||
6 | ; ils sont relatifs par rapport au dossier 'src' où s'exécute le programme | 6 | ; ils sont relatifs par rapport au dossier 'src' où s'exécute le programme |
7 | 7 | ||
8 | business_name = ORDIPOLO | 8 | business_name = ORDIPOLO |
9 | business_guy = 'Paul Jusot' | ||
10 | business_address = "2A rue de l'île de Man" | ||
11 | business_postcode = '29000' | ||
12 | business_city = 'Quimper' | ||
9 | 13 | ||
10 | db_name = ordipolo | 14 | ;db_name = ordipolo |
15 | db_name = dev | ||
11 | 16 | ||
12 | ; défaut = racine de l'appli = dossier parent de celui du code source | 17 | ; défaut = racine de l'appli = dossier parent de celui du code source |
13 | db_path = '../data/' | 18 | db_path = '../data/' |
14 | 19 | ||
15 | ; le dossier latex par défaut est celui "inclu" dans ce programme | 20 | ; emplacement où seront mis les documents créés |
21 | ; note: en revanche modifier les "templates" n'est pas possible | ||
22 | ;latex_path = '../data/latex/' | ||
16 | latex_path = '../data/latex/' | 23 | latex_path = '../data/latex/' |
24 | ;pdf_path = '../data/pdf/' | ||
17 | pdf_path = '../data/pdf/' | 25 | pdf_path = '../data/pdf/' |
18 | 26 | ||
19 | ;receipts_latex = '../data/latex/' | 27 | ;receipts_latex = '../data/latex/' |
diff --git a/data/ordipolo.sqlite b/data/dev.sqlite index 29474b5..f74d69d 100644 --- a/data/ordipolo.sqlite +++ b/data/dev.sqlite | |||
Binary files differ | |||
diff --git a/data/ordipolo.png b/data/latex/ordipolo.png index 2acd67d..2acd67d 100644 --- a/data/ordipolo.png +++ b/data/latex/ordipolo.png | |||
Binary files differ | |||
diff --git a/src/Config.php b/src/Config.php index 396b588..1557705 100644 --- a/src/Config.php +++ b/src/Config.php | |||
@@ -5,6 +5,10 @@ class Config | |||
5 | { | 5 | { |
6 | // valeurs par défaut au cas où | 6 | // valeurs par défaut au cas où |
7 | static public $business_name = 'ORDIPOLO'; | 7 | static public $business_name = 'ORDIPOLO'; |
8 | static public $business_guy = 'Paul Jusot'; | ||
9 | static public $business_address = "2A rue de l'île de Man"; | ||
10 | static public $business_postcode = '29000'; | ||
11 | static public $business_city = 'Quimper'; | ||
8 | static public $db_name = "ordipolo"; | 12 | static public $db_name = "ordipolo"; |
9 | static public $db_path = '../data/'; | 13 | static public $db_path = '../data/'; |
10 | static public $latex_path = '../data/latex/'; | 14 | static public $latex_path = '../data/latex/'; |
@@ -107,7 +111,7 @@ class Config | |||
107 | } | 111 | } |
108 | 112 | ||
109 | // Ã faire plus tard | 113 | // Ã faire plus tard |
110 | // transformer les chemins pour qu'ils soient relatif au dossier 'src' où s'exécute le programme | 114 | // transformer les chemins pour qu'ils soient relatifs au dossier 'src' où s'exécute le programme |
111 | static private function adjustRelativePath($input) | 115 | static private function adjustRelativePath($input) |
112 | { | 116 | { |
113 | // chemin windows? | 117 | // chemin windows? |
diff --git a/src/Dates.php b/src/Dates.php index 36b19a8..ff6e318 100644 --- a/src/Dates.php +++ b/src/Dates.php | |||
@@ -1,5 +1,8 @@ | |||
1 | <?php | 1 | <?php |
2 | // php/DateTimestamp.php | 2 | // php/DateTimestamp.php |
3 | // | ||
4 | // attention à strtotime(), php "devine" le format de la date selon qu'elle comporte des slashs / ou des tirets - | ||
5 | // pour php une date avec des slashs / est américaine, mais si on fait comme ça aussi par ici | ||
3 | 6 | ||
4 | class Dates | 7 | class Dates |
5 | { | 8 | { |
@@ -21,27 +24,40 @@ class Dates | |||
21 | elseif(gettype($input) === 'integer' && $input !== 0) | 24 | elseif(gettype($input) === 'integer' && $input !== 0) |
22 | { | 25 | { |
23 | $this->setTimestamp($input); | 26 | $this->setTimestamp($input); |
27 | $this->setDayMonthYear($this->date); | ||
24 | } | 28 | } |
25 | } | 29 | } |
26 | 30 | ||
27 | 31 | ||
32 | // getters | ||
33 | public function getDate(): string | ||
34 | { | ||
35 | return($this->date); | ||
36 | } | ||
37 | public function getDay(): string | ||
38 | { | ||
39 | return($this->day); | ||
40 | } | ||
41 | public function getMonth(): string | ||
42 | { | ||
43 | return($this->month); | ||
44 | } | ||
45 | public function getYear(): string | ||
46 | { | ||
47 | return($this->year); | ||
48 | } | ||
49 | |||
50 | public function getTimestamp(): int | ||
51 | { | ||
52 | return($this->timestamp); | ||
53 | } | ||
54 | |||
55 | |||
56 | // setters | ||
28 | public function setDate(string $input) | 57 | public function setDate(string $input) |
29 | { | 58 | { |
30 | $input = $this->dashOrSlash($input); // pour strtotime() | 59 | $input = $this->dashOrSlash($input); // formate pour strtotime() |
31 | 60 | $this->setDayMonthYear($input); | |
32 | $splitedDate = preg_split('#\D#', $input); // \D = tout sauf chiffre | ||
33 | $this->year = $splitedDate[2]; | ||
34 | |||
35 | if(self::$date_format === 'euro') | ||
36 | { | ||
37 | $this->day = $splitedDate[1]; | ||
38 | $this->month = $splitedDate[0]; | ||
39 | } | ||
40 | else | ||
41 | { | ||
42 | $this->day = $splitedDate[0]; | ||
43 | $this->month = $splitedDate[1]; | ||
44 | } | ||
45 | 61 | ||
46 | //~ if(checkdate($splitedDate[0], $splitedDate[1], $splitedDate[2])) | 62 | //~ if(checkdate($splitedDate[0], $splitedDate[1], $splitedDate[2])) |
47 | if(checkdate($this->day, $this->month, $this->year)) | 63 | if(checkdate($this->day, $this->month, $this->year)) |
@@ -62,33 +78,26 @@ class Dates | |||
62 | public function setTimestamp(int $input) | 78 | public function setTimestamp(int $input) |
63 | { | 79 | { |
64 | $this->timestamp = $input; | 80 | $this->timestamp = $input; |
65 | $this->date = $this->timestamp_to_date($input); // timestamp (int) -> date (string) | 81 | $this->date = $this->timestampToDate($input); // timestamp (int) -> date (string) |
66 | } | 82 | } |
67 | 83 | ||
68 | 84 | public function setDayMonthYear(string $input) | |
69 | public function getDate(): string | ||
70 | { | ||
71 | return($this->date); | ||
72 | } | ||
73 | public function getDay(): string | ||
74 | { | ||
75 | return($this->day); | ||
76 | } | ||
77 | public function getMonth(): string | ||
78 | { | 85 | { |
79 | return($this->month); | 86 | $splitedDate = preg_split('#\D#', $input); // \D = tout sauf chiffre |
80 | } | 87 | |
81 | public function getYear(): string | 88 | if(self::$date_format === 'euro') |
82 | { | 89 | { |
83 | return($this->year); | 90 | $this->day = $splitedDate[1]; |
84 | } | 91 | $this->month = $splitedDate[0]; |
85 | 92 | } | |
86 | public function getTimestamp(): int | 93 | else |
87 | { | 94 | { |
88 | return($this->timestamp); | 95 | $this->day = $splitedDate[0]; |
96 | $this->month = $splitedDate[1]; | ||
97 | } | ||
98 | $this->year = $splitedDate[2]; | ||
89 | } | 99 | } |
90 | 100 | ||
91 | |||
92 | private function dashOrSlash(string $date): string | 101 | private function dashOrSlash(string $date): string |
93 | { | 102 | { |
94 | if(self::$date_format === 'euro') | 103 | if(self::$date_format === 'euro') |
@@ -108,11 +117,11 @@ class Dates | |||
108 | } | 117 | } |
109 | } | 118 | } |
110 | 119 | ||
111 | private function timestamp_to_date(int $timestamp): string | 120 | private function timestampToDate(int $timestamp): string |
112 | { | 121 | { |
113 | if(self::$date_format === 'euro') | 122 | if(self::$date_format === 'euro') |
114 | { | 123 | { |
115 | return(date("j-m-Y", $timestamp)); | 124 | return(date("d-m-Y", $timestamp)); |
116 | } | 125 | } |
117 | elseif(self::$date_format === 'usa') | 126 | elseif(self::$date_format === 'usa') |
118 | { | 127 | { |
diff --git a/src/functions.php b/src/functions.php index b8779e8..89bfbc9 100644 --- a/src/functions.php +++ b/src/functions.php | |||
@@ -1,7 +1,7 @@ | |||
1 | <?php | 1 | <?php |
2 | // src/functions.php | 2 | // src/functions.php |
3 | // | 3 | // |
4 | // gros fourre-tout, à ranger plus tard | 4 | // utilisées par main.php et les fonctions de la boucle principale |
5 | 5 | ||
6 | 6 | ||
7 | // commande pour lancer une application graphique en ouvrant un fichier | 7 | // commande pour lancer une application graphique en ouvrant un fichier |
@@ -40,25 +40,85 @@ function makeFolder(string $path) | |||
40 | if(!file_exists($path)) | 40 | if(!file_exists($path)) |
41 | { | 41 | { |
42 | mkdir($path); | 42 | mkdir($path); |
43 | chmod($path, 0755); | 43 | chmod($path, 0755); // droits en octal |
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | function makeLatexAndPdfDocument($file_name, $template, Clients $Client, Prestations $Presta = null, $Details = null) // $Details peut être de type DevisFactures ou Locations | 47 | function makeLatexAndPdfDocument($documentType, Clients $Client = null, Prestations $Presta = null, $Details = null) // $Details peut être de type DevisFactures ou Locations |
48 | { | 48 | { |
49 | //~ $data = ; // tableau associatif avec des données des différents objets | 49 | $latex = ''; |
50 | $latex = getLatexFromTemplate($template, $data); | 50 | $year = ''; |
51 | file_put_contents($latex_path . $file_name, $latex); // injection des variables & écriture du fichier | 51 | $data = []; |
52 | $file_name = $documentType . '.tex'; | ||
53 | $latex_path = Config::$latex_path; | ||
54 | $pdf_path = Config::$pdf_path; | ||
55 | |||
56 | // tableau associatif avec des données des différents objets | ||
57 | // note: la propriété 'commentaires' de $Presta écrase celle de $Client (pas grave, les clients n'ont pas besoin d'en avoir connaissance) | ||
58 | // encore une fois, ce programme est destiné à un usage privé et hors ligne, sans déclaration CNIL | ||
59 | |||
60 | if($Client == null) // verso d'une enveloppe | ||
61 | { | ||
62 | $data[0] = Config::$business_guy; | ||
63 | $data[1] = Config::$business_address; | ||
64 | $data[2] = implode(str_split(Config::$business_postcode)); | ||
65 | $data[3] = Config::$business_city; | ||
66 | |||
67 | $latex = makeLatex($documentType, $data); // injection des variables | ||
68 | $file_name = 'enveloppe_verso'; | ||
69 | } | ||
70 | else | ||
71 | { | ||
72 | $data = $Client->getAll(); | ||
73 | |||
74 | if($Presta == null) // recto d'une enveloppe | ||
75 | { | ||
76 | $latex_path .= 'enveloppes_recto/'; | ||
77 | $pdf_path .= 'enveloppes_recto/'; | ||
78 | $data['code_postal'] = implode(' \ ', str_split($data['code_postal'])); // code postal avec 2 espaces entre chaque chiffre: 2 \ 9 \ 0 \ 0 \ 0 | ||
79 | $latex = makeLatex($documentType, $data); // injection des variables | ||
80 | $file_name = $Client->getCodeClient() . '.tex'; | ||
81 | } | ||
82 | else // facture, devis, location | ||
83 | { | ||
84 | $data = array_merge($data, $Presta->getAll()); | ||
85 | $Date = new Dates($Presta->getDate()); // entrée = timestamp (doit être un "int"!!) | ||
86 | $year = $Date->getYear(); | ||
87 | |||
88 | // créer un sous-dossier pour la nouvelle année | ||
89 | $latex_path .= $year . '/'; | ||
90 | $pdf_path .= $year . '/'; | ||
91 | |||
92 | if($Details != null) | ||
93 | { | ||
94 | $data = array_merge($data, $Details->getAll()); | ||
95 | } | ||
96 | |||
97 | $latex = makeLatex($documentType, $data, $Date); // injection des variables | ||
98 | $file_name = $Presta->getCodePresta() . '.tex'; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | // création des fichiers | ||
103 | makeFolder($latex_path); | ||
104 | makeFolder($pdf_path); | ||
105 | file_put_contents($latex_path. $file_name, $latex); // écriture du fichier | ||
52 | latexToPdf($latex_path, $file_name, $pdf_path); | 106 | latexToPdf($latex_path, $file_name, $pdf_path); |
53 | } | 107 | } |
54 | 108 | ||
55 | function getLatexFromTemplate(string $template, $data) | 109 | function makeLatex(string $documentType, array $data, Dates $Date = null) |
56 | { | 110 | { |
57 | // variables à injecter | 111 | $date = ''; |
58 | $nom_client = "M. Duchmol"; | 112 | if($Date != null) |
113 | { | ||
114 | $date = $Date->getDate(); | ||
115 | $date = preg_replace('#\D#', '/', $date); // date avec des slashs / parce que j'aime bien | ||
116 | } | ||
59 | 117 | ||
60 | // on obtient la variable $latex avec ob_get_clean() | 118 | // on obtient la variable $latex avec ob_get_clean() |
61 | include('latex_templates/' . $template . '.php'); | 119 | // le include() ici, c'est du génie ou c'est moche ou les deux? |
120 | // un nouveau fichier php est inséré à chaque itération | ||
121 | include('latex_templates/' . $documentType . '.php'); | ||
62 | 122 | ||
63 | // on retourne le buffer | 123 | // on retourne le buffer |
64 | // normallement le code PHP inséré avec include est nettoyé en quittant la fonction | 124 | // normallement le code PHP inséré avec include est nettoyé en quittant la fonction |
@@ -76,7 +136,7 @@ function latexToPdf(string $latexPath, string $fileName, string $pdfPath) | |||
76 | 136 | ||
77 | // compilation | 137 | // compilation |
78 | exec('pdflatex ' . $outputDir . $latexPath . $fileName); | 138 | exec('pdflatex ' . $outputDir . $latexPath . $fileName); |
79 | 139 | ||
80 | // nettoyage | 140 | // nettoyage |
81 | $basename = basename($fileName, '.tex'); | 141 | $basename = basename($fileName, '.tex'); |
82 | unlink($pdfPath . $basename . '.aux'); | 142 | unlink($pdfPath . $basename . '.aux'); |
diff --git a/data/templates/devis.php b/src/latex_templates/devis.php index 8f5e640..bd9c89d 100644 --- a/data/templates/devis.php +++ b/src/latex_templates/devis.php | |||
@@ -23,7 +23,7 @@ ob_start(); | |||
23 | \definecolor{vert}{rgb}{0.07, 0.46, 0.13} % saisie en vert | 23 | \definecolor{vert}{rgb}{0.07, 0.46, 0.13} % saisie en vert |
24 | 24 | ||
25 | \begin{center} | 25 | \begin{center} |
26 | \includegraphics{../ordipolo.png}\\ | 26 | \includegraphics{latex_templates/ordipolo.png}\\ |
27 | \Large\textbf{Dépannage informatique - Assistance à domicile} | 27 | \Large\textbf{Dépannage informatique - Assistance à domicile} |
28 | \end{center} | 28 | \end{center} |
29 | 29 | ||
@@ -45,33 +45,35 @@ ob_start(); | |||
45 | CLIENT\\ | 45 | CLIENT\\ |
46 | 46 | ||
47 | \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} | 47 | \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} |
48 | Mme, MÂ : \textcolor{vert}{<?= $nom_client ?>} & | 48 | Mme, MÂ : \textcolor{vert}{<?= $data['prenom_nom'] ?>} & |
49 | Date du devis : \textcolor{vert}{}\\ | 49 | Date du devis : \textcolor{vert}{<?= $date ?>}\\ |
50 | Adresse : \textcolor{vert}{} & | 50 | Adresse : \textcolor{vert}{<?= $data['adresse'] ?>} & |
51 | Delai de livraison : \textcolor{vert}{}\\ | 51 | Delai de livraison : \textcolor{vert}{<?= $data['delai_livraison'] ?>}\\ |
52 | & | ||
53 | Durée de validité : \textcolor{vert}{<?= $data['validite_devis'] ?>}\\ | ||
52 | \end{tabularx}\\\\ | 54 | \end{tabularx}\\\\ |
53 | 55 | ||
54 | PRESTATION\\ | 56 | PRESTATION\\ |
55 | 57 | ||
56 | \textcolor{vert}{} | 58 | \textcolor{vert}{<?= $data['taches'] ?>} |
57 | 59 | ||
58 | Total main d'oeuvre : \textcolor{vert}{}\\ | 60 | Total main d'oeuvre : \textcolor{vert}{<?= $data['total_main_d_oeuvre'] ?>}\\ |
59 | 61 | ||
60 | PIÈCES\\ | 62 | PIÈCES\\ |
61 | 63 | ||
62 | \textcolor{vert}{} | 64 | \textcolor{vert}{<?= $data['pieces'] ?>} |
63 | 65 | ||
64 | Total pièces : \textcolor{vert}{}\\ | 66 | Total pièces : \textcolor{vert}{<?= $data['total_pieces'] ?>}\\ |
65 | 67 | ||
66 | TOTAL\\ | 68 | TOTAL\\ |
67 | 69 | ||
68 | Déplacement : \textcolor{vert}{} | 70 | Déplacement : \textcolor{vert}{<?= $data['deplacement'] ?>} |
69 | 71 | ||
70 | Total HTÂ : \textcolor{vert}{} | 72 | Total HTÂ : \textcolor{vert}{<?= $data['total_HT'] ?>} |
71 | 73 | ||
72 | \textit{(TVA non applicable, article 293B du code général des impôts)} | 74 | \textit{(TVA non applicable, article 293B du code général des impôts)} |
73 | 75 | ||
74 | Référence du devis : \textcolor{vert}{}\\ | 76 | Référence du devis : \textcolor{vert}{<?= $data['code_presta'] ?>}\\ |
75 | 77 | ||
76 | Devis reçu avant l'exécution des travaux, signature du client :\\ | 78 | Devis reçu avant l'exécution des travaux, signature du client :\\ |
77 | \begin{tikzpicture} | 79 | \begin{tikzpicture} |
diff --git a/data/templates/enveloppe_recto.php b/src/latex_templates/enveloppe_recto.php index 99d65a1..e95589c 100644 --- a/data/templates/enveloppe_recto.php +++ b/src/latex_templates/enveloppe_recto.php | |||
@@ -1,5 +1,7 @@ | |||
1 | <?php | 1 | <?php |
2 | // latex_templates/enveloppe_recto.php | 2 | // src/latex_templates/enveloppe_recto.php |
3 | |||
4 | //~ $data['adresse'] | ||
3 | 5 | ||
4 | ob_start(); | 6 | ob_start(); |
5 | ?> | 7 | ?> |
@@ -15,13 +17,13 @@ ob_start(); | |||
15 | 17 | ||
16 | \begin{document} | 18 | \begin{document} |
17 | \setlength{\parindent}{0cm} | 19 | \setlength{\parindent}{0cm} |
18 | \includegraphics{../ordipolo.png}\\ | 20 | \includegraphics{latex_templates/ordipolo.png}\\ |
19 | \large\textbf{Dépannage informatique - Assistance à domicile} | 21 | \large\textbf{Dépannage informatique - Assistance à domicile} |
20 | 22 | ||
21 | \setlength{\parindent}{7,9cm} | 23 | \setlength{\parindent}{7,9cm} |
22 | \begin{minipage}[b][5,8cm]{12cm} | 24 | \begin{minipage}[b][5,8cm]{12cm} |
23 | \LARGE{M. Truc\\3, rue Machin\\\\\\} | 25 | \LARGE{<?= $data['prenom_nom'] ?>\\<?= $data['adresse'] ?>\\\\\\} |
24 | \LARGE{2 \ 9 \ 0 \ 0 \ 0 \ \ \ \ QUIMPER} | 26 | \LARGE{<?= $data['code_postal'] ?> \ \ \ \ <?= $data['ville'] ?>} |
25 | \end{minipage} | 27 | \end{minipage} |
26 | \end{document} | 28 | \end{document} |
27 | <?php | 29 | <?php |
diff --git a/src/latex_templates/enveloppe_verso.pdf b/src/latex_templates/enveloppe_verso.pdf new file mode 100644 index 0000000..ab2e37c --- /dev/null +++ b/src/latex_templates/enveloppe_verso.pdf | |||
Binary files differ | |||
diff --git a/data/templates/enveloppe_verso.php b/src/latex_templates/enveloppe_verso.php index ae2e716..866fd04 100644 --- a/data/templates/enveloppe_verso.php +++ b/src/latex_templates/enveloppe_verso.php | |||
@@ -1,5 +1,10 @@ | |||
1 | <?php | 1 | <?php |
2 | // latex_templates/enveloppe_verso.php | 2 | // src/latex_templates/enveloppe_verso.php |
3 | |||
4 | $adresse[0] = 'Paul Jusot'; | ||
5 | $adresse[1] = "2A rue de l'île de Man"; | ||
6 | $adresse[2] = '29000'; | ||
7 | $adresse[3] = 'Quimper'; | ||
3 | 8 | ||
4 | ob_start(); | 9 | ob_start(); |
5 | ?> | 10 | ?> |
@@ -14,7 +19,7 @@ ob_start(); | |||
14 | 19 | ||
15 | \begin{document} | 20 | \begin{document} |
16 | \setlength{\parindent}{0cm} | 21 | \setlength{\parindent}{0cm} |
17 | \Large{Paul Jusot\\2A, rue de l'île de Man\\29000 QUIMPER} | 22 | \Large{<?= $data[0] ?>\\<?= $data[1] ?>\\<?= $data[2] ?> <?= $data[3] ?>} |
18 | \end{document} | 23 | \end{document} |
19 | <?php | 24 | <?php |
20 | $latex = ob_get_clean(); | 25 | $latex = ob_get_clean(); |
diff --git a/data/templates/facture.php b/src/latex_templates/facture.php index 5d62b91..2ff4ac6 100644 --- a/data/templates/facture.php +++ b/src/latex_templates/facture.php | |||
@@ -22,7 +22,7 @@ ob_start(); | |||
22 | \definecolor{vert}{rgb}{0.07, 0.46, 0.13} % saisie en vert | 22 | \definecolor{vert}{rgb}{0.07, 0.46, 0.13} % saisie en vert |
23 | 23 | ||
24 | \begin{center} | 24 | \begin{center} |
25 | \includegraphics{../ordipolo.png}\\ | 25 | \includegraphics{latex_templates/ordipolo.png}\\ |
26 | \Large\textbf{Dépannage informatique - Assistance à domicile} | 26 | \Large\textbf{Dépannage informatique - Assistance à domicile} |
27 | \end{center} | 27 | \end{center} |
28 | 28 | ||
@@ -44,40 +44,40 @@ ob_start(); | |||
44 | CLIENT\\ | 44 | CLIENT\\ |
45 | 45 | ||
46 | \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} | 46 | \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} |
47 | Mme, MÂ : \textcolor{vert}{} & | 47 | Mme, MÂ : \textcolor{vert}{<?= $data['prenom_nom'] ?>} & |
48 | Date : \textcolor{vert}{}\\ | 48 | Date : \textcolor{vert}{<?= $date ?>}\\ |
49 | \end{tabularx}\\ | 49 | \end{tabularx}\\ |
50 | Adresse : \textcolor{vert}{}\\ | 50 | Adresse : \textcolor{vert}{<?= $data['adresse'] ?>}\\ |
51 | 51 | ||
52 | PRESTATION\\ | 52 | PRESTATION\\ |
53 | 53 | ||
54 | \textcolor{vert}{} | 54 | \textcolor{vert}{<?= $data['taches'] ?>} |
55 | 55 | ||
56 | Modèle de l'ordinateur : \textcolor{vert}{} | 56 | Modèle de l'ordinateur : \textcolor{vert}{<?= $data['machine'] ?>} |
57 | 57 | ||
58 | Système d'exploitation : \textcolor{vert}{} | 58 | Système d'exploitation : \textcolor{vert}{<?= $data['OS'] ?>} |
59 | 59 | ||
60 | Données à conserver : \textcolor{vert}{} | 60 | Données à conserver : \textcolor{vert}{<?= $data['donnees'] ?>} |
61 | 61 | ||
62 | Clé d'activation : \textcolor{vert}{}\\ | 62 | Clé d'activation : \textcolor{vert}{<?= $data['cles_licences'] ?>}\\ |
63 | 63 | ||
64 | Total main d'oeuvre : \textcolor{vert}{}\\ | 64 | Total main d'oeuvre : \textcolor{vert}{<?= $data['total_main_d_oeuvre'] ?>}\\ |
65 | 65 | ||
66 | PIÈCES\\ | 66 | PIÈCES\\ |
67 | 67 | ||
68 | \textcolor{vert}{} | 68 | \textcolor{vert}{<?= $data['pieces'] ?>} |
69 | 69 | ||
70 | Total pièces : \textcolor{vert}{}\\ | 70 | Total pièces : \textcolor{vert}{<?= $data['total_pieces'] ?>}\\ |
71 | 71 | ||
72 | TOTAL\\ | 72 | TOTAL\\ |
73 | 73 | ||
74 | Déplacement : \textcolor{vert}{} | 74 | Déplacement : \textcolor{vert}{<?= $data['deplacement'] ?>} |
75 | 75 | ||
76 | Total HTÂ : \textcolor{vert}{} | 76 | Total HTÂ : \textcolor{vert}{<?= $data['total_HT'] ?>} |
77 | 77 | ||
78 | \textit{(TVA non applicable, article 293B du code général des impôts)} | 78 | \textit{(TVA non applicable, article 293B du code général des impôts)} |
79 | 79 | ||
80 | Référence de la facture : \textcolor{vert}{}\\ | 80 | Référence de la facture : \textcolor{vert}{<?= $data['code_presta'] ?>}\\ |
81 | 81 | ||
82 | \small{}NOTA BENE\\ | 82 | \small{}NOTA BENE\\ |
83 | 83 | ||
diff --git a/data/templates/location.php b/src/latex_templates/location.php index dbffd0e..dce7f04 100644 --- a/data/templates/location.php +++ b/src/latex_templates/location.php | |||
@@ -23,7 +23,7 @@ ob_start(); | |||
23 | \definecolor{vert}{rgb}{0.07, 0.46, 0.13} % saisie en vert | 23 | \definecolor{vert}{rgb}{0.07, 0.46, 0.13} % saisie en vert |
24 | 24 | ||
25 | \begin{center} | 25 | \begin{center} |
26 | \includegraphics{../ordipolo.png}\\ | 26 | \includegraphics{latex_templates/ordipolo.png}\\ |
27 | \Large\textbf{Dépannage informatique - Assistance à domicile} | 27 | \Large\textbf{Dépannage informatique - Assistance à domicile} |
28 | \end{center} | 28 | \end{center} |
29 | 29 | ||
diff --git a/src/latex_templates/ordipolo.png b/src/latex_templates/ordipolo.png new file mode 100644 index 0000000..2acd67d --- /dev/null +++ b/src/latex_templates/ordipolo.png | |||
Binary files differ | |||
diff --git a/data/originaux pas toucher/devis.tex b/src/latex_templates/originaux_pas_toucher/devis.tex index c5ae6e8..634ade1 100644 --- a/data/originaux pas toucher/devis.tex +++ b/src/latex_templates/originaux_pas_toucher/devis.tex | |||
@@ -44,6 +44,8 @@ | |||
44 | Date du devis : \textcolor{vert}{}\\ | 44 | Date du devis : \textcolor{vert}{}\\ |
45 | Adresse : \textcolor{vert}{} & | 45 | Adresse : \textcolor{vert}{} & |
46 | Delai de livraison : \textcolor{vert}{}\\ | 46 | Delai de livraison : \textcolor{vert}{}\\ |
47 | & | ||
48 | Durée de validité : \textcolor{vert}{}\\ | ||
47 | \end{tabularx}\\\\ | 49 | \end{tabularx}\\\\ |
48 | 50 | ||
49 | PRESTATION\\ | 51 | PRESTATION\\ |
diff --git a/data/originaux pas toucher/enveloppe_recto.tex b/src/latex_templates/originaux_pas_toucher/enveloppe_recto.tex index eab03f8..eab03f8 100644 --- a/data/originaux pas toucher/enveloppe_recto.tex +++ b/src/latex_templates/originaux_pas_toucher/enveloppe_recto.tex | |||
diff --git a/data/originaux pas toucher/enveloppe_verso.tex b/src/latex_templates/originaux_pas_toucher/enveloppe_verso.tex index 24baa8a..bd5c86e 100644 --- a/data/originaux pas toucher/enveloppe_verso.tex +++ b/src/latex_templates/originaux_pas_toucher/enveloppe_verso.tex | |||
@@ -1,3 +1,5 @@ | |||
1 | % contenu "fixe" quelque soit le client | ||
2 | |||
1 | \documentclass[]{report} | 3 | \documentclass[]{report} |
2 | 4 | ||
3 | \usepackage[french]{babel} | 5 | \usepackage[french]{babel} |
diff --git a/data/originaux pas toucher/facture.tex b/src/latex_templates/originaux_pas_toucher/facture.tex index 5c849f5..5c849f5 100644 --- a/data/originaux pas toucher/facture.tex +++ b/src/latex_templates/originaux_pas_toucher/facture.tex | |||
diff --git a/data/originaux pas toucher/location.tex b/src/latex_templates/originaux_pas_toucher/location.tex index 0d525fe..0d525fe 100644 --- a/data/originaux pas toucher/location.tex +++ b/src/latex_templates/originaux_pas_toucher/location.tex | |||
diff --git a/src/main.php b/src/main.php index ee0888e..2b2da84 100755 --- a/src/main.php +++ b/src/main.php | |||
@@ -34,7 +34,7 @@ require('model/Model.php'); // class Model extends DB, requêtes SQL | |||
34 | require('model/StructTablesDB.php'); | 34 | require('model/StructTablesDB.php'); |
35 | Model::createTables(); | 35 | Model::createTables(); |
36 | 36 | ||
37 | require('model/traits.php'); | 37 | //~ require('model/traits.php'); |
38 | require('model/Clients.php'); | 38 | require('model/Clients.php'); |
39 | require('model/Prestations.php'); | 39 | require('model/Prestations.php'); |
40 | require('model/DevisFactures.php'); | 40 | require('model/DevisFactures.php'); |
@@ -70,7 +70,7 @@ while($boucle) | |||
70 | { | 70 | { |
71 | echo("choix: $choix_niv1\n"); | 71 | echo("choix: $choix_niv1\n"); |
72 | $code_retour = newService(); | 72 | $code_retour = newService(); |
73 | echo "hello, code retour: " . $code_retour . "\n"; | 73 | echo "debug: main.php: hello, code retour " . $code_retour . "\n"; |
74 | } | 74 | } |
75 | 75 | ||
76 | // -- SECTION 2: Modifier un enregistrement -- | 76 | // -- SECTION 2: Modifier un enregistrement -- |
diff --git a/src/model/CESU.php b/src/model/CESU.php index 2be89c0..8771607 100644 --- a/src/model/CESU.php +++ b/src/model/CESU.php | |||
@@ -6,30 +6,24 @@ class CESU extends Model | |||
6 | //~ const TABLE = 'cesu'; | 6 | //~ const TABLE = 'cesu'; |
7 | 7 | ||
8 | // lecture des données ou hydratation | 8 | // lecture des données ou hydratation |
9 | private $ID_cesu; | 9 | protected $ID_presta; |
10 | private $taches; | 10 | protected $taches; |
11 | private $duree_travail; | 11 | protected $duree_travail; |
12 | private $salaire; | 12 | protected $salaire; |
13 | 13 | ||
14 | use ModelChildren; | 14 | //~ use ModelChildren; |
15 | 15 | ||
16 | public function __construct(int $client_ID) | 16 | public function __construct() |
17 | { | 17 | { |
18 | parent::__construct($client_ID); | 18 | $this->table = strtolower(__CLASS__); // cesu |
19 | $this->type == 'cesu'; | ||
20 | } | 19 | } |
21 | 20 | ||
22 | // setters | 21 | // setters |
23 | public function setIDCesu(int $value) | 22 | public function setIDPresta(int $value) |
24 | { | 23 | { |
25 | $this->ID_cesu = $value; | 24 | $this->ID_presta = $value; |
26 | return($this); | 25 | return($this); |
27 | } | 26 | } |
28 | //~ public function setIDPresta(int $value) | ||
29 | //~ { | ||
30 | //~ $this->ID_presta = $value; | ||
31 | //~ return($this); | ||
32 | //~ } | ||
33 | public function setTaches(string $value) | 27 | public function setTaches(string $value) |
34 | { | 28 | { |
35 | $this->taches = $value; | 29 | $this->taches = $value; |
@@ -40,9 +34,10 @@ class CESU extends Model | |||
40 | $this->duree_travail = $value; | 34 | $this->duree_travail = $value; |
41 | return($this); | 35 | return($this); |
42 | } | 36 | } |
43 | public function setSalaire(float $value) | 37 | public function setSalaire($value) |
44 | { | 38 | { |
45 | $this->salaire = $value; | 39 | $value = str_replace(',', '.', $value); |
40 | $this->salaire = (float) $value; | ||
46 | return($this); | 41 | return($this); |
47 | } | 42 | } |
48 | } | 43 | } |
diff --git a/src/model/Clients.php b/src/model/Clients.php index 9661562..d841451 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php | |||
@@ -8,23 +8,19 @@ class Clients extends Model | |||
8 | protected $prenom_nom; | 8 | protected $prenom_nom; |
9 | protected $code_client; | 9 | protected $code_client; |
10 | protected $adresse; | 10 | protected $adresse; |
11 | protected $code_postal; | ||
12 | protected $ville; | ||
11 | protected $telephone; | 13 | protected $telephone; |
12 | protected $courriel; | 14 | protected $courriel; |
13 | protected $commentaires; | 15 | protected $apropos; |
14 | 16 | ||
15 | use ModelChildren; // pour hydrateFromForm() | 17 | //~ use ModelChildren; |
16 | 18 | ||
17 | public function __construct() | 19 | public function __construct() |
18 | { | 20 | { |
19 | $this->table = 'clients'; // Ã mettre dans ModelChildren | 21 | $this->table = strtolower(__CLASS__); // clients |
20 | } | 22 | } |
21 | 23 | ||
22 | //~ public function set(string $variable, $value) | ||
23 | //~ { | ||
24 | //~ $this->$variable = $value; | ||
25 | //~ return($this); | ||
26 | //~ } | ||
27 | |||
28 | // getters | 24 | // getters |
29 | public function getID(): int | 25 | public function getID(): int |
30 | { | 26 | { |
@@ -36,8 +32,6 @@ class Clients extends Model | |||
36 | } | 32 | } |
37 | 33 | ||
38 | // setters | 34 | // setters |
39 | //~ public function setID() -> dans le trait ModelChildren | ||
40 | |||
41 | public function setPrenomNom($value) | 35 | public function setPrenomNom($value) |
42 | { | 36 | { |
43 | $this->prenom_nom = (string) $value; | 37 | $this->prenom_nom = (string) $value; |
@@ -53,6 +47,17 @@ class Clients extends Model | |||
53 | $this->adresse = (string) $value; | 47 | $this->adresse = (string) $value; |
54 | return($this); | 48 | return($this); |
55 | } | 49 | } |
50 | public function setCodePostal($value) | ||
51 | { | ||
52 | $this->code_postal = (string) $value; | ||
53 | return($this); | ||
54 | } | ||
55 | public function setVille($value) | ||
56 | { | ||
57 | $this->ville = (string) $value; | ||
58 | return($this); | ||
59 | } | ||
60 | |||
56 | public function setTelephone($value) // chaine parce que zenity renvoie une chaine et parce qu'on garde le 0 au début | 61 | public function setTelephone($value) // chaine parce que zenity renvoie une chaine et parce qu'on garde le 0 au début |
57 | { | 62 | { |
58 | if(is_numeric($value)) | 63 | if(is_numeric($value)) |
@@ -71,9 +76,9 @@ class Clients extends Model | |||
71 | $this->courriel = (string) $value; | 76 | $this->courriel = (string) $value; |
72 | return($this); | 77 | return($this); |
73 | } | 78 | } |
74 | public function setCommentaires($value) | 79 | public function setApropos($value) |
75 | { | 80 | { |
76 | $this->commentaires = (string) $value; | 81 | $this->apropos = (string) $value; |
77 | return($this); | 82 | return($this); |
78 | } | 83 | } |
79 | 84 | ||
diff --git a/src/model/DB.php b/src/model/DB.php index 381623b..52d6479 100644 --- a/src/model/DB.php +++ b/src/model/DB.php | |||
@@ -1,7 +1,7 @@ | |||
1 | <?php | 1 | <?php |
2 | // php/DB.php | 2 | // php/DB.php |
3 | 3 | ||
4 | // cette classe suit le pattern "singleton" | 4 | // cette classe applique le pattern "singleton" |
5 | // but: ne permettre qu'une seule instance de la classe (laquelle sera éventuellement globale) | 5 | // but: ne permettre qu'une seule instance de la classe (laquelle sera éventuellement globale) |
6 | 6 | ||
7 | // comment? | 7 | // comment? |
diff --git a/src/model/DevisFactures.php b/src/model/DevisFactures.php index ff80960..92a5443 100644 --- a/src/model/DevisFactures.php +++ b/src/model/DevisFactures.php | |||
@@ -13,41 +13,28 @@ class DevisFactures extends Model | |||
13 | protected $OS; | 13 | protected $OS; |
14 | protected $donnees; | 14 | protected $donnees; |
15 | protected $cles_licences; | 15 | protected $cles_licences; |
16 | protected $temps; | ||
17 | protected $total_main_d_oeuvre; | 16 | protected $total_main_d_oeuvre; |
18 | protected $pieces; | 17 | protected $pieces; |
19 | protected $total_pieces; | 18 | protected $total_pieces; |
20 | protected $deplacement; | 19 | protected $deplacement; |
21 | protected $total_HT; | 20 | protected $total_HT; |
21 | protected $delai_livraison; | ||
22 | protected $validite_devis; | 22 | protected $validite_devis; |
23 | protected $signature_devis; | 23 | protected $signature_devis; |
24 | 24 | ||
25 | use ModelChildren; // pour hydrateFromForm() | 25 | //~ use ModelChildren; |
26 | 26 | ||
27 | public function __construct(int $ID_presta, string $table) | 27 | public function __construct(string $table) |
28 | { | 28 | { |
29 | $this->ID_presta = $ID_presta; | ||
30 | $this->table = $table; // deux tables séparées devis et factures | 29 | $this->table = $table; // deux tables séparées devis et factures |
31 | } | 30 | } |
32 | 31 | ||
33 | // setters | 32 | // setters |
34 | //~ public function setID() -> dans le trait ModelChildren | ||
35 | |||
36 | public function setIDPresta(int $value) | 33 | public function setIDPresta(int $value) |
37 | { | 34 | { |
38 | $this->ID_presta = $value; | 35 | $this->ID_presta = $value; |
39 | return($this); | 36 | return($this); |
40 | } | 37 | } |
41 | public function setValiditedevis(string $value) | ||
42 | { | ||
43 | $this->validite_devis = $value; | ||
44 | return($this); | ||
45 | } | ||
46 | public function setSignatureDevis(string $value) | ||
47 | { | ||
48 | $this->signature_devis = $value; | ||
49 | return($this); | ||
50 | } | ||
51 | public function setTaches(string $value) | 38 | public function setTaches(string $value) |
52 | { | 39 | { |
53 | $this->taches = $value; | 40 | $this->taches = $value; |
@@ -73,11 +60,11 @@ class DevisFactures extends Model | |||
73 | $this->cles_licences = $value; | 60 | $this->cles_licences = $value; |
74 | return($this); | 61 | return($this); |
75 | } | 62 | } |
76 | public function setTemps(string $value) | 63 | //~ public function setTemps(string $value) |
77 | { | 64 | //~ { |
78 | $this->temps = $value; | 65 | //~ $this->temps = $value; |
79 | return($this); | 66 | //~ return($this); |
80 | } | 67 | //~ } |
81 | public function setTotalMainDOeuvre($value) | 68 | public function setTotalMainDOeuvre($value) |
82 | { | 69 | { |
83 | $value = str_replace(',', '.', $value); | 70 | $value = str_replace(',', '.', $value); |
@@ -107,6 +94,21 @@ class DevisFactures extends Model | |||
107 | $this->total_HT = (float) $value; | 94 | $this->total_HT = (float) $value; |
108 | return($this); | 95 | return($this); |
109 | } | 96 | } |
97 | public function setDelaiLivraison(string $value) | ||
98 | { | ||
99 | $this->delai_livraison = $value; | ||
100 | return($this); | ||
101 | } | ||
102 | public function setValiditedevis(string $value) | ||
103 | { | ||
104 | $this->validite_devis = $value; | ||
105 | return($this); | ||
106 | } | ||
107 | public function setSignatureDevis(string $value) | ||
108 | { | ||
109 | $this->signature_devis = $value; | ||
110 | return($this); | ||
111 | } | ||
110 | 112 | ||
111 | //~ public function newRow(array $input) | 113 | //~ public function newRow(array $input) |
112 | //~ { | 114 | //~ { |
diff --git a/src/model/Locations.php b/src/model/Locations.php index 21e9b09..8ebf757 100644 --- a/src/model/Locations.php +++ b/src/model/Locations.php | |||
@@ -4,48 +4,44 @@ | |||
4 | class Locations extends Model | 4 | class Locations extends Model |
5 | { | 5 | { |
6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
7 | private $ID_location; | 7 | protected $ID_presta; |
8 | private $nature_bien; | 8 | protected $designation; |
9 | private $modele; | 9 | protected $modele_description; |
10 | private $valeur; | 10 | protected $valeur; |
11 | private $etat_des_lieux_debut; | 11 | protected $etat_des_lieux_debut; |
12 | private $etat_des_lieux_fin; | 12 | protected $etat_des_lieux_fin; |
13 | private $duree_location; | 13 | protected $duree_location; |
14 | private $loyer_mensuel; | 14 | protected $loyer_mensuel; |
15 | private $total_HT; | 15 | protected $loyers_payes; |
16 | protected $caution; | ||
16 | 17 | ||
17 | use ModelChildren; | 18 | //~ use ModelChildren; |
18 | 19 | ||
19 | public function __construct(int $client_ID) | 20 | public function __construct() |
20 | { | 21 | { |
21 | parent::__construct($client_ID); | 22 | $this->table = strtolower(__CLASS__); // locations |
22 | $this->type == 'location'; | ||
23 | } | 23 | } |
24 | 24 | ||
25 | // setters | 25 | // setters |
26 | public function setIDLocation(int $value) | 26 | public function setIDPresta(int $value) |
27 | { | 27 | { |
28 | $this->ID_location = $value; | 28 | $this->ID_presta = $value; |
29 | return($this); | 29 | return($this); |
30 | } | 30 | } |
31 | //~ public function setIDPresta(int $value) | 31 | public function setDesignation(string $value) |
32 | //~ { | ||
33 | //~ $this->ID_presta = $value; | ||
34 | //~ return($this); | ||
35 | //~ } | ||
36 | public function setNatureBien(string $value) | ||
37 | { | 32 | { |
38 | $this->nature_bien = $value; | 33 | $this->designation = $value; |
39 | return($this); | 34 | return($this); |
40 | } | 35 | } |
41 | public function setModele(string $value) | 36 | public function setModeleDescription(string $value) |
42 | { | 37 | { |
43 | $this->modele = $value; | 38 | $this->modele_description = $value; |
44 | return($this); | 39 | return($this); |
45 | } | 40 | } |
46 | public function setValeur(float $value) | 41 | public function setValeur($value) |
47 | { | 42 | { |
48 | $this->valeur = $value; | 43 | $value = str_replace(',', '.', $value); |
44 | $this->valeur = (float) $value; | ||
49 | return($this); | 45 | return($this); |
50 | } | 46 | } |
51 | public function setEtatDesLieuxDebut(string $value) | 47 | public function setEtatDesLieuxDebut(string $value) |
@@ -58,19 +54,28 @@ class Locations extends Model | |||
58 | $this->etat_des_lieux_fin = $value; | 54 | $this->etat_des_lieux_fin = $value; |
59 | return($this); | 55 | return($this); |
60 | } | 56 | } |
61 | public function setDureeLocation(string $value) | 57 | public function setDureeLocation($value) |
62 | { | 58 | { |
63 | $this->duree_location = $value; | 59 | $value = str_replace(',', '.', $value); |
60 | $this->duree_location = (float) $value; | ||
64 | return($this); | 61 | return($this); |
65 | } | 62 | } |
66 | public function setlLyerMensuel(float $value) | 63 | public function setLoyerMensuel($value) |
67 | { | 64 | { |
68 | $this->loyer_mensuel = $value; | 65 | $value = str_replace(',', '.', $value); |
66 | $this->loyer_mensuel = (float) $value; | ||
69 | return($this); | 67 | return($this); |
70 | } | 68 | } |
71 | public function setTotalHT(float $value) | 69 | public function setLoyersPayes($value) |
72 | { | 70 | { |
73 | $this->total_HT = $value; | 71 | $value = str_replace(',', '.', $value); |
72 | $this->loyers_payes = (float) $value; | ||
73 | return($this); | ||
74 | } | ||
75 | public function setCaution($value) | ||
76 | { | ||
77 | $value = str_replace(',', '.', $value); | ||
78 | $this->caution = (float) $value; | ||
74 | return($this); | 79 | return($this); |
75 | } | 80 | } |
76 | } | 81 | } |
diff --git a/src/model/Model.php b/src/model/Model.php index 4c1fb4d..6a7907c 100644 --- a/src/model/Model.php +++ b/src/model/Model.php | |||
@@ -1,16 +1,16 @@ | |||
1 | <?php | 1 | <?php |
2 | // php/Model.php | 2 | // php/Model.php |
3 | 3 | ||
4 | class Model extends DB | 4 | abstract class Model extends DB |
5 | { | 5 | { |
6 | protected $db; // instance de PDO | 6 | protected $db; // instance de PDO |
7 | protected $table; // <= enfant | 7 | protected $table; // <= enfant |
8 | //static protected $tableStructure; | 8 | //static protected $tableStructure; |
9 | 9 | ||
10 | public function __construct() | 10 | public function __construct() // Ã surcharger |
11 | { | 11 | { |
12 | //~ $this->db = parent::getInstance(); // connexion | ||
13 | //~ $this->table = strtolower(__CLASS__); | 12 | //~ $this->table = strtolower(__CLASS__); |
13 | //~ echo "TABLE = " . $this->table . "\n"; | ||
14 | } | 14 | } |
15 | 15 | ||
16 | // getters | 16 | // getters |
@@ -19,7 +19,25 @@ class Model extends DB | |||
19 | return($this->table); | 19 | return($this->table); |
20 | } | 20 | } |
21 | 21 | ||
22 | public function getAll(): array | ||
23 | { | ||
24 | return get_object_vars($this); // retourne les propriétés de l'objet | ||
25 | } | ||
26 | |||
22 | // setters | 27 | // setters |
28 | public function setID(int $value = 0) | ||
29 | { | ||
30 | if($value === 0) | ||
31 | { | ||
32 | $this->ID = $this->db->lastInsertId(); // méthode de PDO (attention ne gère pas la concurence) | ||
33 | } | ||
34 | else | ||
35 | { | ||
36 | $this->ID = $value; | ||
37 | } | ||
38 | return($this); | ||
39 | } | ||
40 | |||
23 | public function hydrate(array $data): bool // $data = tableau associatif en entrée: nom_du_champ => valeur | 41 | public function hydrate(array $data): bool // $data = tableau associatif en entrée: nom_du_champ => valeur |
24 | { | 42 | { |
25 | foreach($data as $key => $value) | 43 | foreach($data as $key => $value) |
@@ -41,6 +59,71 @@ class Model extends DB | |||
41 | return true; | 59 | return true; |
42 | } | 60 | } |
43 | 61 | ||
62 | // cette fonction reçoit des données d'un tableau simple, permettant d'associer des champs de formulaires aux noms différents des champs de la BDD | ||
63 | function hydrateFromForm(string $data_string, Object $Presta = NULL): bool // quand l'objet est $Details, on hydrate aussi $Presta | ||
64 | { | ||
65 | //~ $tableSize = count(StructTablesDB::$structureOfTables[$this->getTable()]); // int | ||
66 | |||
67 | if($data_string !== '') | ||
68 | { | ||
69 | $data_array = explode('|', $data_string); // array | ||
70 | $check = false; | ||
71 | switch($this->getTable()) | ||
72 | { | ||
73 | case 'clients'; | ||
74 | if($data_array[0] == '') | ||
75 | { | ||
76 | echo "debug: données insuffisantes, le nom du client doit au minimum être renseigné\n"; | ||
77 | return false; | ||
78 | } | ||
79 | else | ||
80 | { | ||
81 | $check = $this->hydrate(['prenom_nom' => $data_array[0], 'code_client' => $data_array[1], 'adresse' => $data_array[2], 'code_postal' => $data_array[3], 'ville' => $data_array[4], 'telephone' => $data_array[5], 'courriel' => $data_array[6], 'apropos' => $data_array[7]]); | ||
82 | } | ||
83 | break; | ||
84 | case 'prestations'; // inutilisé | ||
85 | break; | ||
86 | case 'devis'; | ||
87 | $check = $Presta->hydrate(['mode_paiement' => $data_array[6]]); | ||
88 | if($check) | ||
89 | { | ||
90 | $check = $this->hydrate(['taches' => $data_array[0], 'total_main_d_oeuvre' => $data_array[1], 'pieces' => $data_array[2], 'total_pieces' => $data_array[3], 'deplacement' => $data_array[4], 'total_HT' => $data_array[5], 'delai_livraison' => $data_array[7], 'validite_devis' => $data_array[8], 'signature_devis' => $data_array[9]]); | ||
91 | } | ||
92 | break; | ||
93 | case 'factures'; | ||
94 | $check = $Presta->hydrate(['mode_paiement' => $data_array[10]]); | ||
95 | if($check) | ||
96 | { | ||
97 | $check = $this->hydrate(['taches' => $data_array[0], 'machine' => $data_array[1], 'OS' => $data_array[2], 'donnees' => $data_array[3], 'cles_licences' => $data_array[4], 'total_main_d_oeuvre' => $data_array[5], 'pieces' => $data_array[6], 'total_pieces' => $data_array[7], 'deplacement' => $data_array[8], 'total_HT' => $data_array[9]]); | ||
98 | } | ||
99 | break; | ||
100 | case 'cesu'; | ||
101 | $check = $Presta->hydrate(['mode_paiement' => $data_array[3]]); | ||
102 | if($check) | ||
103 | { | ||
104 | $check = $this->hydrate(['taches' => $data_array[0], 'duree_travail' => $data_array[1], 'salaire' => $data_array[2]]); | ||
105 | } | ||
106 | break; | ||
107 | case 'locations'; | ||
108 | //~ $check = $Presta->hydrate(['mode_paiement' => $data_array[11]]); | ||
109 | //~ if($check) | ||
110 | //~ { | ||
111 | $check = $this->hydrate(['designation' => $data_array[0], 'modele_description' => $data_array[1], 'valeur' => $data_array[2], 'etat_des_lieux_debut' => $data_array[3], 'etat_des_lieux_fin' => $data_array[4], 'duree_location' => $data_array[5], 'loyer_mensuel' => $data_array[6], 'loyers_payes' => $data_array[7], 'caution' => $data_array[8]]); | ||
112 | //~ } | ||
113 | break; | ||
114 | default: // inutilisé | ||
115 | echo "debug: table inconnue hydrateFromForm()"; | ||
116 | return false; | ||
117 | } | ||
118 | return $check; | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | echo "debug: annulation lors du formulaire\n"; | ||
123 | return false; | ||
124 | } | ||
125 | } | ||
126 | |||
44 | 127 | ||
45 | // exécuter le SQL | 128 | // exécuter le SQL |
46 | // les attributs correspondent aux ? dans les requêtes préparées | 129 | // les attributs correspondent aux ? dans les requêtes préparées |
@@ -51,8 +134,8 @@ class Model extends DB | |||
51 | 134 | ||
52 | if($attributes !== null) // requête préparée | 135 | if($attributes !== null) // requête préparée |
53 | { | 136 | { |
54 | var_dump($sql); | 137 | //~ var_dump($sql); |
55 | var_dump($attributes); | 138 | //~ var_dump($attributes); |
56 | $query = $this->db->prepare($sql); | 139 | $query = $this->db->prepare($sql); |
57 | $query->execute($attributes); | 140 | $query->execute($attributes); |
58 | return $query; | 141 | return $query; |
@@ -75,7 +158,7 @@ class Model extends DB | |||
75 | //~ var_dump($this); | 158 | //~ var_dump($this); |
76 | foreach($this as $field => $value) | 159 | foreach($this as $field => $value) |
77 | { | 160 | { |
78 | var_dump($field); var_dump($value); | 161 | //~ var_dump($field); var_dump($value); |
79 | // champs non renseignées et variables de l'objet qui ne sont pas des champs | 162 | // champs non renseignées et variables de l'objet qui ne sont pas des champs |
80 | // note: avec le !== (au lieu de !=) une valeur 0 est différente de null | 163 | // note: avec le !== (au lieu de !=) une valeur 0 est différente de null |
81 | if($value !== null && $field != 'db' && $field != 'table') | 164 | if($value !== null && $field != 'db' && $field != 'table') |
diff --git a/src/model/Prestations.php b/src/model/Prestations.php index 2f84daa..ddd785b 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php | |||
@@ -6,20 +6,18 @@ class Prestations extends Model | |||
6 | // lecture des données ou hydratation | 6 | // lecture des données ou hydratation |
7 | protected $ID; // auto-incrémentée | 7 | protected $ID; // auto-incrémentée |
8 | protected $ID_client = 0; | 8 | protected $ID_client = 0; |
9 | //~ protected $combientieme_fois = 0; | ||
10 | protected $code_presta = ''; | 9 | protected $code_presta = ''; |
11 | protected $date = 0; // timestamp unix | 10 | protected $date = 0; // timestamp unix |
12 | protected $type_presta = ''; | 11 | protected $type_presta = ''; |
13 | protected $mode_paiement = ''; | 12 | protected $mode_paiement = ''; |
14 | protected $commentaires = ''; | 13 | protected $commentaires = ''; |
15 | 14 | ||
16 | use ModelChildren; | 15 | //~ use ModelChildren; |
17 | 16 | ||
18 | public function __construct(int $ID_client) | 17 | public function __construct(int $ID_client) |
19 | { | 18 | { |
20 | $this->table = 'prestations'; | ||
21 | $this->ID_client = $ID_client; | 19 | $this->ID_client = $ID_client; |
22 | //~ $this->combientiemeFois(); | 20 | $this->table = strtolower(__CLASS__); // prestations |
23 | } | 21 | } |
24 | 22 | ||
25 | // getters | 23 | // getters |
@@ -31,10 +29,10 @@ class Prestations extends Model | |||
31 | { | 29 | { |
32 | return $this->ID_client; | 30 | return $this->ID_client; |
33 | } | 31 | } |
34 | //~ public function getCombientiemeFois(): int | 32 | public function getCodePresta(): string |
35 | //~ { | 33 | { |
36 | //~ return $this->combientieme_fois; | 34 | return $this->code_presta; |
37 | //~ } | 35 | } |
38 | public function getDate(): int | 36 | public function getDate(): int |
39 | { | 37 | { |
40 | return $this->date; | 38 | return $this->date; |
diff --git a/src/model/StructTablesDB.php b/src/model/StructTablesDB.php index 00c5321..32ae92d 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/StructTablesDB.php | |||
@@ -9,10 +9,10 @@ class StructTablesDB | |||
9 | static public $structureOfTables = [ | 9 | static public $structureOfTables = [ |
10 | // la table prestations est liée à la table clients | 10 | // la table prestations est liée à la table clients |
11 | // les tables devis_factures, cesu et locations sont liées à la table prestations | 11 | // les tables devis_factures, cesu et locations sont liées à la table prestations |
12 | 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'commentaires' => 'TEXT'], | 12 | 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'code_postal' => 'TEXT', 'ville' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'apropos' => 'TEXT'], |
13 | 'prestations' => ['ID' => 'INTEGER', 'ID_client' => 'INTEGER', 'code_presta' => 'TEXT', 'date' => 'INTEGER', 'type_presta' => 'TEXT', 'mode_paiement' => 'TEXT', 'commentaires' => 'TEXT'], | 13 | 'prestations' => ['ID' => 'INTEGER', 'ID_client' => 'INTEGER', 'code_presta' => 'TEXT', 'date' => 'INTEGER', 'type_presta' => 'TEXT', 'mode_paiement' => 'TEXT', 'commentaires' => 'TEXT'], |
14 | 'devis' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'machine' => 'TEXT', 'OS' => 'TEXT', 'donnees' => 'TEXT', 'cles_licences' => 'TEXT', 'temps' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT'], | 14 | 'devis' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT'], |
15 | 'factures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'machine' => 'TEXT', 'OS' => 'TEXT', 'donnees' => 'TEXT', 'cles_licences' => 'TEXT', 'temps' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL'], | 15 | 'factures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'machine' => 'TEXT', 'OS' => 'TEXT', 'donnees' => 'TEXT', 'cles_licences' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL'], |
16 | 'cesu' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], | 16 | 'cesu' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], |
17 | 'locations' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'designation' => 'TEXT', 'modele_description' => 'TEXT', 'valeur' => 'REAL', 'etat_des_lieux_debut' => 'TEXT', 'etat_des_lieux_fin' => 'TEXT', 'duree_location' => 'INTEGER', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] | 17 | 'locations' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'designation' => 'TEXT', 'modele_description' => 'TEXT', 'valeur' => 'REAL', 'etat_des_lieux_debut' => 'TEXT', 'etat_des_lieux_fin' => 'TEXT', 'duree_location' => 'INTEGER', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] |
18 | ]; | 18 | ]; |
diff --git a/src/model/traits.php b/src/model/traits.php index 41f1c35..a00032e 100644 --- a/src/model/traits.php +++ b/src/model/traits.php | |||
@@ -8,90 +8,6 @@ trait ModelChildren | |||
8 | //~ public function __construct() | 8 | //~ public function __construct() |
9 | //~ { | 9 | //~ { |
10 | //~ $this->table = strtolower(__CLASS__); | 10 | //~ $this->table = strtolower(__CLASS__); |
11 | //~ echo "TABLE = " . $this->table . "\n"; | ||
11 | //~ } | 12 | //~ } |
12 | |||
13 | //~ public function setIdFromLastInsertID() // à faire juste après l'écriture d'une nouvelle entrée | ||
14 | //~ { | ||
15 | //~ $this->db = parent::getInstance(); | ||
16 | //~ $this->ID = $this->db->lastInsertId(); // méthode de PDO | ||
17 | //~ } | ||
18 | |||
19 | public function setID(int $value = 0) | ||
20 | { | ||
21 | if($value === 0) | ||
22 | { | ||
23 | $this->ID = $this->db->lastInsertId(); // méthode de PDO | ||
24 | } | ||
25 | else | ||
26 | { | ||
27 | $this->ID = $value; | ||
28 | } | ||
29 | return($this); | ||
30 | } | ||
31 | |||
32 | function hydrateFromForm(string $data_string, Object $Presta = NULL): bool // quand l'objet est $DetailsPresta, on hydrate aussi $Presta | ||
33 | { | ||
34 | //~ $tableSize = count(StructTablesDB::$structureOfTables[$this->getTable()]); // int | ||
35 | |||
36 | if($data_string !== '') | ||
37 | { | ||
38 | $data_array = explode('|', $data_string); // array | ||
39 | //~ var_dump($data_array); | ||
40 | //~ if(count($data_array) === $tableSize - 1) // nombre de champs sauf ID qui est auto-incrémenté automatiquement | ||
41 | //~ { | ||
42 | //~ var_dump($this->getTable()); | ||
43 | //~ var_dump($data_array); | ||
44 | $check = false; | ||
45 | switch($this->getTable()) | ||
46 | { | ||
47 | case 'clients'; | ||
48 | if($data_array[0] == '') | ||
49 | { | ||
50 | echo "debug: données insuffisantes, le nom du client doit au minimum être renseigné\n"; | ||
51 | return false; | ||
52 | } | ||
53 | else | ||
54 | { | ||
55 | $check = $this->hydrate(['prenom_nom' => $data_array[0], 'code_client' => $data_array[1], 'adresse' => $data_array[2], 'telephone' => $data_array[3], 'courriel' => $data_array[4], 'commentaires' => $data_array[5]]); | ||
56 | } | ||
57 | break; | ||
58 | case 'prestations'; // inutilisé | ||
59 | break; | ||
60 | case 'devis'; | ||
61 | $check = $Presta->hydrate(['mode_paiement' => $data_array[11]]); | ||
62 | if($check) | ||
63 | { | ||
64 | $check = $this->hydrate(['taches' => $data_array[0], 'machine' => $data_array[1], 'OS' => $data_array[2], 'donnees' => $data_array[3], 'cles_licences' => $data_array[4], 'temps' => $data_array[5], 'total_main_d_oeuvre' => $data_array[6], 'pieces' => $data_array[7], 'total_pieces' => $data_array[8], 'deplacement' => $data_array[9], 'total_HT' => $data_array[10], | ||
65 | 'validite_devis' => $data_array[12], 'signature_devis' => $data_array[13]]); | ||
66 | } | ||
67 | break; | ||
68 | case 'factures'; | ||
69 | $check = $Presta->hydrate(['mode_paiement' => $data_array[11]]); | ||
70 | if($check) | ||
71 | { | ||
72 | $check = $this->hydrate(['taches' => $data_array[0], 'machine' => $data_array[1], 'OS' => $data_array[2], 'donnees' => $data_array[3], 'cles_licences' => $data_array[4], 'temps' => $data_array[5], 'total_main_d_oeuvre' => $data_array[6], 'pieces' => $data_array[7], 'total_pieces' => $data_array[8], 'deplacement' => $data_array[9], 'total_HT' => $data_array[10]]); | ||
73 | } | ||
74 | break; | ||
75 | case 'cesu'; | ||
76 | break; | ||
77 | case 'locations'; | ||
78 | break; | ||
79 | default: // inutilisé | ||
80 | echo "debug: table inconnue hydrateFromForm()"; | ||
81 | return false; | ||
82 | } | ||
83 | return $check; | ||
84 | //~ } | ||
85 | //~ else | ||
86 | //~ { | ||
87 | //~ echo "debug: mauvais tableau, il doit avoir " . $tableSize - 1 . " cases\n"; // ou -3 pour les factures | ||
88 | //~ return false; | ||
89 | //~ } | ||
90 | } | ||
91 | else | ||
92 | { | ||
93 | echo "debug: annulation lors du formulaire\n"; | ||
94 | return false; | ||
95 | } | ||
96 | } | ||
97 | } | 13 | } |
diff --git a/src/sections/1_new_service.php b/src/sections/1_new_service.php index 656b45f..d516329 100644 --- a/src/sections/1_new_service.php +++ b/src/sections/1_new_service.php | |||
@@ -12,7 +12,7 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
12 | $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); | 12 | $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); |
13 | $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement_text, ZenitySetup::$menu_enregistrement_entrees); | 13 | $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement_text, ZenitySetup::$menu_enregistrement_entrees); |
14 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar_text); | 14 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar_text); |
15 | $FormulaireDevis = new ZenityForms(ZenitySetup::$formulaire_text, array_merge(ZenitySetup::$formulaire_facture_entrees, ZenitySetup::$formulaire_devis_entrees)); | 15 | $FormulaireDevis = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_devis_entrees); |
16 | $FormulaireFacture = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_facture_entrees); | 16 | $FormulaireFacture = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_facture_entrees); |
17 | $FormulaireCesu = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_cesu_entrees); | 17 | $FormulaireCesu = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_cesu_entrees); |
18 | $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_location_entrees); | 18 | $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_location_entrees); |
@@ -29,7 +29,7 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
29 | $client_inconnu = true; | 29 | $client_inconnu = true; |
30 | if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage | 30 | if(exec($QuestionNouveauClient->get()) == '0') // $? = 0 signifie oui, double égal == pour le transtypage |
31 | { | 31 | { |
32 | echo "debug: recherche souhaitée\n"; | 32 | echo "choix: recherche d'une client\n"; |
33 | $input = exec($RechercheClient->get()); | 33 | $input = exec($RechercheClient->get()); |
34 | if($input == '') | 34 | if($input == '') |
35 | { | 35 | { |
@@ -57,7 +57,7 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
57 | } | 57 | } |
58 | else | 58 | else |
59 | { | 59 | { |
60 | echo "debug: nouveau client\n"; | 60 | echo "choix: nouveau client\n"; |
61 | } | 61 | } |
62 | 62 | ||
63 | // on n'a pas cherché OU on n'a pas trouvé | 63 | // on n'a pas cherché OU on n'a pas trouvé |
@@ -108,22 +108,22 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
108 | { | 108 | { |
109 | // formulaire - étape 2/3 | 109 | // formulaire - étape 2/3 |
110 | case ZenitySetup::$menu_enregistrement_entrees[0]: // "Devis" | 110 | case ZenitySetup::$menu_enregistrement_entrees[0]: // "Devis" |
111 | $Details = new DevisFactures($Client->getID(), 'devis'); | 111 | $Details = new DevisFactures('devis'); |
112 | $Presta->setTypePresta('devis'); | 112 | $Presta->setTypePresta('devis'); |
113 | $input = exec($FormulaireDevis->get()); | 113 | $input = exec($FormulaireDevis->get()); |
114 | break; | 114 | break; |
115 | case ZenitySetup::$menu_enregistrement_entrees[1]: // "Facture" | 115 | case ZenitySetup::$menu_enregistrement_entrees[1]: // "Facture" |
116 | $Details = new DevisFactures($Client->getID(), 'factures'); // 'factures' est le nom de la table, pas le type de presta | 116 | $Details = new DevisFactures('factures'); // 'factures' est le nom de la table, pas le type de presta |
117 | $Presta->setTypePresta('facture'); | 117 | $Presta->setTypePresta('facture'); |
118 | $input =exec($FormulaireFacture->get()); | 118 | $input =exec($FormulaireFacture->get()); |
119 | break; | 119 | break; |
120 | case ZenitySetup::$menu_enregistrement_entrees[2]: // "CESU" | 120 | case ZenitySetup::$menu_enregistrement_entrees[2]: // "CESU" |
121 | $Details = new CESU($Client->getID()); | 121 | $Details = new CESU(); |
122 | $Presta->setTypePresta('cesu'); | 122 | $Presta->setTypePresta('cesu'); |
123 | $input = exec($FormulaireCesu->get()); | 123 | $input = exec($FormulaireCesu->get()); |
124 | break; | 124 | break; |
125 | case ZenitySetup::$menu_enregistrement_entrees[3]: // "Location" | 125 | case ZenitySetup::$menu_enregistrement_entrees[3]: // "Location" |
126 | $Details = new Locations($Client->getID()); | 126 | $Details = new Locations(); |
127 | $Presta->setTypePresta('location'); | 127 | $Presta->setTypePresta('location'); |
128 | $input = exec($FormulaireLocation->get()); | 128 | $input = exec($FormulaireLocation->get()); |
129 | break; | 129 | break; |
@@ -140,16 +140,27 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
140 | echo "debug: annulation lors de l'enregistrement des détails de la prestation\n"; | 140 | echo "debug: annulation lors de l'enregistrement des détails de la prestation\n"; |
141 | return(0); | 141 | return(0); |
142 | } | 142 | } |
143 | elseif(isset($Details) && !$Details->hydrateFromForm($input, $Presta)) | 143 | elseif(isset($Details) && !$Details->hydrateFromForm($input, $Presta)) // echec de l'hydratation |
144 | { | 144 | { |
145 | // messages d'erreur dans hydrateFromForm() | 145 | echo "debug: erreur de hydrateFromForm()\n"; // messages d'erreur à mettre ici ou dans hydrateFromForm()? |
146 | return(0); | 146 | return(0); |
147 | } | 147 | } |
148 | unset($input); | 148 | unset($input); |
149 | 149 | ||
150 | // commentaire - étape 3/3 | 150 | // commentaire - étape 3/3 |
151 | $input = exec($CommentairePrestation->get()); | 151 | $input = exec($CommentairePrestation->get()); |
152 | //~ if($input == '') | 152 | if($input == '') |
153 | { | ||
154 | echo "debug: pas de commentaire saisi\n"; | ||
155 | // on n'interrompt pas le script et on enregistre dans tous les cas (annulatation, chaîne vide) | ||
156 | } | ||
157 | // Cliquer sur annuler (ou appuyer sur échap) revient dont à valider avec une chaîne vide et enregistrer la prestation | ||
158 | // la commande 'echo $?' ($? est le code de sortie de la commande précédente) renvoit 1 si on annule avec la touche échap () | ||
159 | // elle renvoit 0 si la fenêtre est fermée correctement, qu'on valide une chaîne vide ou qu'on clique sur Annuler (on ne peut pas savoir) | ||
160 | // malheureusement, si les deux commandes sont liées par un '&&' et qu'on annule la saisie, la 2è commande n'est pas exécutée | ||
161 | // solution partielle si echo $? ne renvoit rien, c'est qu'echo n'a pas été exécuté parce qu'on a appuyé sur échap (ou que le programme) | ||
162 | // 2>&1 semble inutile, pas de sortie d'erreur de zenity --entry | ||
163 | //~ if(exec('echo $?') != 1) | ||
153 | //~ { | 164 | //~ { |
154 | //~ echo "debug: annulation à la saisie d'un commentaire\n"; | 165 | //~ echo "debug: annulation à la saisie d'un commentaire\n"; |
155 | //~ return(0); | 166 | //~ return(0); |
@@ -167,33 +178,23 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
167 | 178 | ||
168 | // -- partie 3: LaTeX -- | 179 | // -- partie 3: LaTeX -- |
169 | 180 | ||
170 | // créer le chemin et un sous-dossier avec l'année en cours | ||
171 | $latex_year_folder = Config::$latex_path . date('Y') . '/'; | ||
172 | makeFolder($latex_year_folder); | ||
173 | |||
174 | $pdf_year_folder = Config::$pdf_path . date('Y') . '/'; | ||
175 | makeFolder($pdf_year_folder); | ||
176 | |||
177 | // document de la prestation | 181 | // document de la prestation |
178 | switch($choix_niv2) | 182 | switch($choix_niv2) |
179 | { | 183 | { |
180 | case ZenitySetup::$menu_enregistrement_entrees[0]: // "Devis" | 184 | case ZenitySetup::$menu_enregistrement_entrees[0]: // "Devis" |
181 | $file_name = 'devis.tex'; | 185 | $type = 'devis'; |
182 | $template = 'devis'; | 186 | makeLatexAndPdfDocument($type, $Client, $Presta, $Details); |
183 | makeLatexAndPdfDocument($file_name, $template, $Client, $Presta, $Details); | ||
184 | break; | 187 | break; |
185 | case ZenitySetup::$menu_enregistrement_entrees[1]: // "Facture" | 188 | case ZenitySetup::$menu_enregistrement_entrees[1]: // "Facture" |
186 | $file_name = 'facture.tex'; | 189 | $type = 'facture'; |
187 | $template = 'facture'; | 190 | makeLatexAndPdfDocument($type, $Client, $Presta, $Details); |
188 | makeLatexAndPdfDocument($file_name, $template, $Client, $Presta, $Details); | ||
189 | break; | 191 | break; |
190 | case ZenitySetup::$menu_enregistrement_entrees[2]: // "CESU" | 192 | case ZenitySetup::$menu_enregistrement_entrees[2]: // "CESU" |
191 | // pas de facture | 193 | // pas de facture |
192 | break; | 194 | break; |
193 | case ZenitySetup::$menu_enregistrement_entrees[3]: // "Location" | 195 | case ZenitySetup::$menu_enregistrement_entrees[3]: // "Location" |
194 | $file_name = 'location.tex'; | 196 | $type = 'location'; |
195 | $template = 'location'; | 197 | makeLatexAndPdfDocument($type, $Client, $Presta, $Details); |
196 | makeLatexAndPdfDocument($file_name, $template, $Client, $Presta, $Details); | ||
197 | break; | 198 | break; |
198 | case ZenitySetup::$menu_enregistrement_entrees[4]: // "Prestation non vendue" | 199 | case ZenitySetup::$menu_enregistrement_entrees[4]: // "Prestation non vendue" |
199 | // pas de facture | 200 | // pas de facture |
@@ -203,13 +204,13 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
203 | return(0); | 204 | return(0); |
204 | } | 205 | } |
205 | 206 | ||
206 | // enveloppe | 207 | // enveloppe recto |
207 | $file_name = 'enveloppe_recto.tex'; | 208 | $type = 'enveloppe_recto'; |
208 | $template = 'enveloppe_recto'; | 209 | makeLatexAndPdfDocument($type, $Client); |
209 | makeLatexAndPdfDocument($file_name, $template, $Client); | 210 | |
210 | $file_name = 'enveloppe_verso.tex'; | 211 | // le verso ne dépend pas du client mais de l'entreprise |
211 | $template = 'enveloppe_verso'; | 212 | $type = 'enveloppe_verso'; |
212 | makeLatexAndPdfDocument($file_name, $template, $Client); | 213 | makeLatexAndPdfDocument($type); |
213 | 214 | ||
214 | 215 | ||
215 | // -- partie 4: récapitulatif -- | 216 | // -- partie 4: récapitulatif -- |
@@ -221,6 +222,7 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a | |||
221 | //~ $imprimer_facture = exec('zenity --question --width=250 --title="Base de données mise à jour" --text="Imprimer la facture?"'); | 222 | //~ $imprimer_facture = exec('zenity --question --width=250 --title="Base de données mise à jour" --text="Imprimer la facture?"'); |
222 | //~ $imprimer_enveloppe = exec('zenity --question --width=250 --title="Base de données mise à jour" --text="Imprimer l\'adresse sur une enveloppe? (insérer une enveloppe DL sans fenêtre dans l\'imprimante"'); | 223 | //~ $imprimer_enveloppe = exec('zenity --question --width=250 --title="Base de données mise à jour" --text="Imprimer l\'adresse sur une enveloppe? (insérer une enveloppe DL sans fenêtre dans l\'imprimante"'); |
223 | 224 | ||
225 | |||
224 | // possibilité de modification | 226 | // possibilité de modification |
225 | // zenityQuestion | 227 | // zenityQuestion |
226 | if(exec($QuestionModifierPrestation->get()) == '0') | 228 | if(exec($QuestionModifierPrestation->get()) == '0') |
diff --git a/src/view/ZenitySetup.php b/src/view/ZenitySetup.php index 518cfbb..b03f2bd 100644 --- a/src/view/ZenitySetup.php +++ b/src/view/ZenitySetup.php | |||
@@ -19,12 +19,12 @@ class ZenitySetup | |||
19 | static public $recherche_client_text = "Recherche d'un client avec son nom ou son code client"; | 19 | static public $recherche_client_text = "Recherche d'un client avec son nom ou son code client"; |
20 | static public $resultats_recherche_client_text = "Résultats de la recherche, sélectionner un client"; | 20 | static public $resultats_recherche_client_text = "Résultats de la recherche, sélectionner un client"; |
21 | static public $nouveau_client_text = "Nouveau client"; | 21 | static public $nouveau_client_text = "Nouveau client"; |
22 | static public $nouveau_client_entrees = ["Prénom Nom:", "Code client, exemple: J.P.Duchmol", "Adresse::", "Telephone:", "Courriel:", "Commentaires:"]; | 22 | static public $nouveau_client_entrees = ["Prénom Nom:", "Code client, exemple: J.P.Duchmol:", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:"]; |
23 | static public $calendar_text = 'Nouvelle prestation étape 1/3 - Choisir une date'; | 23 | static public $calendar_text = 'Nouvelle prestation étape 1/3 - Choisir une date'; |
24 | static public $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; | 24 | static public $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; |
25 | static public $formulaire_devis_entrees = ["Durée de validite du devis:", "Devis signé (oui ou non):"]; | 25 | static public $formulaire_devis_entrees = ["Tâches effectuées:", "Total main d\'oeuvre (euros):", "Détail des pièces:", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):", "Mode de paiement", "Delai de livraison", "Durée de validite du devis:", "Devis signé (oui ou non):"]; |
26 | static public $formulaire_facture_entrees = ["Tâches effectuées:", "Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Nombre d'heures:", "Total main d\'oeuvre (euros):", "Détail des pièces:", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):", "Mode de paiement"]; | 26 | static public $formulaire_facture_entrees = ["Tâches effectuées:", "Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Total main d\'oeuvre (euros):", "Détail des pièces:", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):", "Mode de paiement"]; |
27 | static public $formulaire_cesu_entrees = ["Tâches effectuées:", "Duree de travail:", "Salaire net"]; | 27 | static public $formulaire_cesu_entrees = ["Tâches effectuées:", "Duree de travail:", "Salaire net", "Mode de paiement"]; // en fait je pourrais ajouter plein d'autres trucs |
28 | static public $formulaire_location_entrees = ["Désignation du bien", "Modèle, numéro de série, description:", "Valeur", "État des lieux du début:", "État des lieux de fin:", "Durée de la location en mois:", "Loyer mensuel:", "Nombre de loyers déjà payés:", "Montant du chèque de caution:"]; | 28 | static public $formulaire_location_entrees = ["Désignation du bien", "Modèle, numéro de série, description:", "Valeur", "État des lieux du début:", "État des lieux de fin:", "Durée de la location en mois:", "Loyer mensuel:", "Nombre de loyers déjà payés:", "Montant du chèque de caution:"]; |
29 | static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; | 29 | static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; |
30 | static public $recapitulatif_text = "voici toutes les informations enregistrées"; | 30 | static public $recapitulatif_text = "voici toutes les informations enregistrées"; |