diff options
Diffstat (limited to 'src')
28 files changed, 1789 insertions, 442 deletions
diff --git a/src/Latex.php b/src/Latex.php index f7f18ea..b254551 100644 --- a/src/Latex.php +++ b/src/Latex.php | |||
@@ -5,12 +5,12 @@ | |||
5 | 5 | ||
6 | abstract class Latex | 6 | abstract class Latex |
7 | { | 7 | { |
8 | protected $type = ''; | 8 | protected string $type; |
9 | protected $file_name = ''; | 9 | protected string $file_name; |
10 | protected $latex_path = ''; | 10 | protected string $latex_path; |
11 | protected $pdf_path = ''; | 11 | protected string $pdf_path; |
12 | protected $data = []; // données à insérer dans le template | 12 | protected array $data = []; // données à insérer dans le template |
13 | protected $latex = ''; // latex pur | 13 | protected string $latex; // latex pur |
14 | 14 | ||
15 | static function makeInstance(string $type) | 15 | static function makeInstance(string $type) |
16 | { | 16 | { |
@@ -98,16 +98,13 @@ abstract class Latex | |||
98 | 98 | ||
99 | abstract class PrestaLatex extends Latex | 99 | abstract class PrestaLatex extends Latex |
100 | { | 100 | { |
101 | protected $Date; // sera un type "Dates" | 101 | protected Dates $Date; |
102 | |||
103 | //~ public function __construct() | ||
104 | //~ {} | ||
105 | 102 | ||
106 | public function setData(Object $Object): self | 103 | public function setData(Object $Object): self |
107 | { | 104 | { |
108 | $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs | 105 | $this->data = array_merge($this->data, $Object->getAll()); // nécessite des tableaux associatifs |
109 | 106 | ||
110 | if(get_class($Object) === 'Prestations') | 107 | if(get_class($Object) === 'Prestation') |
111 | { | 108 | { |
112 | $this->file_name = $Object->getCodePresta() . '.tex'; | 109 | $this->file_name = $Object->getCodePresta() . '.tex'; |
113 | $this->makeDateInstance($Object->getDate()); // paramètre = int | 110 | $this->makeDateInstance($Object->getDate()); // paramètre = int |
diff --git a/src/files.php b/src/files.php index 0bda901..ad20ee0 100644 --- a/src/files.php +++ b/src/files.php | |||
@@ -5,53 +5,58 @@ | |||
5 | 5 | ||
6 | function makeFile($path, $file_name, $data) | 6 | function makeFile($path, $file_name, $data) |
7 | { | 7 | { |
8 | //~ if(is_writable('../' . $path)) | 8 | //~ if(is_writable('../' . $path)) |
9 | //~ { | 9 | //~ { |
10 | file_put_contents($path. $file_name, $data); | 10 | file_put_contents($path. $file_name, $data); |
11 | chmod($path . $file_name, 0644); // droits en octal | 11 | chmod($path . $file_name, 0644); // droits en octal |
12 | //~ } | 12 | //~ } |
13 | 13 | ||
14 | //~ protected function createFile(string $latex, string $file_name, string $latexPath) | 14 | //~ protected function createFile(string $latex, string $file_name, string $latexPath) |
15 | //~ { | 15 | //~ { |
16 | //~ // nom du fichier créé = nom.tex | 16 | //~ // nom du fichier créé = nom.tex |
17 | //~ // pour les devis, factures et enveloppes, le nom est le code la prestation | 17 | //~ // pour les devis, factures et enveloppes, le nom est le code la prestation |
18 | //~ // pour les livre de recettes et registres des achats mensuels: | 18 | //~ // pour les livre de recettes et registres des achats mensuels: |
19 | //~ // le nom du fichier suit cet exemple: "Recettes-2022-06-Juin.tex" | 19 | //~ // le nom du fichier suit cet exemple: "Recettes-2022-06-Juin.tex" |
20 | //~ // pour le livre de recette ou le registre des achats annuel, même principe: "Achats-2022.tex" | 20 | //~ // pour le livre de recette ou le registre des achats annuel, même principe: "Achats-2022.tex" |
21 | //~ // pour le bilan comptable annuel, ça donne: "Bilan-2022.tex" | 21 | //~ // pour le bilan comptable annuel, ça donne: "Bilan-2022.tex" |
22 | //~ $fichier = fopen($latexPath . $file_name, "w+"); | 22 | //~ $fichier = fopen($latexPath . $file_name, "w+"); |
23 | //~ fputs($fichier, $latex); | 23 | //~ fputs($fichier, $latex); |
24 | //~ fclose($fichier); | 24 | //~ fclose($fichier); |
25 | //~ } | 25 | //~ } |
26 | } | 26 | } |
27 | 27 | ||
28 | //~ function deleteFile($path, $file_name) | ||
29 | //~ { | ||
30 | //~ unlink() | ||
31 | //~ } | ||
32 | |||
28 | function makeFolder(string $path) | 33 | function makeFolder(string $path) |
29 | { | 34 | { |
30 | $rights = 0755; // droits en octal | 35 | $rights = 0755; // droits en octal |
31 | 36 | ||
32 | if(!file_exists($path)) | 37 | if(!file_exists($path)) |
33 | { | 38 | { |
34 | //~ if(is_writable('../' . $path)) | 39 | //~ if(is_writable('../' . $path)) |
35 | //~ { | 40 | //~ { |
36 | mkdir($path); | 41 | mkdir($path); |
37 | chmod($path, $rights); | 42 | chmod($path, $rights); |
38 | //~ } | 43 | //~ } |
39 | //~ else | 44 | //~ else |
40 | //~ { | 45 | //~ { |
41 | //~ echo "debug: la création du dossier " . $path . " est impossible\n"; | 46 | //~ echo "debug: la création du dossier " . $path . " est impossible\n"; |
42 | //~ } | 47 | //~ } |
43 | } | 48 | } |
44 | else | 49 | else |
45 | { | 50 | { |
46 | //~ if(is_writable($path)) | 51 | //~ if(is_writable($path)) |
47 | //~ { | 52 | //~ { |
48 | chmod($path, $rights); | 53 | chmod($path, $rights); |
49 | //~ } | 54 | //~ } |
50 | //~ else | 55 | //~ else |
51 | //~ { | 56 | //~ { |
52 | //~ echo "debug: la modification des droits du dossier " . $path . " est impossible\n"; | 57 | //~ echo "debug: la modification des droits du dossier " . $path . " est impossible\n"; |
53 | //~ } | 58 | //~ } |
54 | } | 59 | } |
55 | } | 60 | } |
56 | 61 | ||
57 | // commande système pdflatex | 62 | // commande système pdflatex |
@@ -75,6 +80,15 @@ function latexToPdf(string $latex_path, string $file_name, string $pdf_path) | |||
75 | unlink($pdf_path . $basename . '.log'); | 80 | unlink($pdf_path . $basename . '.log'); |
76 | } | 81 | } |
77 | 82 | ||
83 | // équivalent de la commande mv | ||
84 | function renameFiles(Object $Object, string $old_code, string $new_code) | ||
85 | { | ||
86 | rename($Object->getLatexPath() . $old_code . '.tex', | ||
87 | $Object->getLatexPath() . $new_code . '.tex'); | ||
88 | rename($Object->getPdfPath() . $old_code . '.pdf', | ||
89 | $Object->getPdfPath() . $new_code . '.pdf'); | ||
90 | } | ||
91 | |||
78 | function makeTexAndPdf(Object $Object) // paramètre = enfant de Latex | 92 | function makeTexAndPdf(Object $Object) // paramètre = enfant de Latex |
79 | { | 93 | { |
80 | if(get_class($Object) !== 'EnveloppeVersoLatex') | 94 | if(get_class($Object) !== 'EnveloppeVersoLatex') |
diff --git a/src/functions.php b/src/functions.php index 47cea42..d9fbfca 100644 --- a/src/functions.php +++ b/src/functions.php | |||
@@ -1,7 +1,5 @@ | |||
1 | <?php | 1 | <?php |
2 | // src/functions.php | 2 | // src/functions.php |
3 | // | ||
4 | // utilisées par main.php et les fonctions de la boucle principale | ||
5 | 3 | ||
6 | 4 | ||
7 | // commande pour lancer une application graphique en ouvrant un fichier | 5 | // commande pour lancer une application graphique en ouvrant un fichier |
@@ -20,124 +18,3 @@ function windowAppCommand(string $app, string $path = ''): string | |||
20 | // stderr > stdout pour cacher un message inutile | 18 | // stderr > stdout pour cacher un message inutile |
21 | return $command; | 19 | return $command; |
22 | } | 20 | } |
23 | |||
24 | function enterCustomer($Client): bool | ||
25 | { | ||
26 | // fenêtre | ||
27 | $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client['text'], ZenitySetup::$nouveau_client['entrees']); | ||
28 | |||
29 | $input = exec($NouveauClient->get()); | ||
30 | if($input == '') | ||
31 | { | ||
32 | echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; | ||
33 | return false; | ||
34 | } | ||
35 | if(!$Client->hydrateFromForm($input)) | ||
36 | { | ||
37 | // messages d'erreur dans hydrateFromForm() | ||
38 | return false; | ||
39 | } | ||
40 | unset($input); | ||
41 | |||
42 | $Client->create(); // écrire dans la base | ||
43 | $Client->setId(); // sans paramètre, exécute un $this->db->lastInsertId() | ||
44 | |||
45 | return true; | ||
46 | } | ||
47 | |||
48 | function makeObjectClient() | ||
49 | { | ||
50 | // fenêtres | ||
51 | $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client_text); | ||
52 | $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client_text, []); | ||
53 | |||
54 | $Client = new Clients; | ||
55 | |||
56 | $input = exec($RechercheClient->get()); | ||
57 | if($input == '') | ||
58 | { | ||
59 | echo "debug: recherche annulée ou saisie vide\n"; | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | echo "debug: recherche effectuée\n"; | ||
64 | $ResultatsRechercheClient->setListRows( | ||
65 | searchCustomer($input, $Client), | ||
66 | count(StructTablesDB::$structureOfTables[$Client->getTable()])); // 2è paramètre = nombre de colonnes | ||
67 | |||
68 | // sélection parmi les résultats | ||
69 | $input = exec($ResultatsRechercheClient->get()); // renvoie l'ID de la table 'clients' | ||
70 | $ResultatsRechercheClient->cleanCommand(); | ||
71 | |||
72 | if($input == '') | ||
73 | { | ||
74 | echo "debug: client pas trouvé ou pas sélectionné\n"; | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | echo "debug: client sélectionné\n"; | ||
79 | $Client->setId($input); | ||
80 | $Client->hydrate($Client->findById()); | ||
81 | |||
82 | return $Client; | ||
83 | } | ||
84 | |||
85 | // NOTE 1: en PHP les objets sont passés aux fonctions par référence par défaut, toutefois ce n'est pas entièrement vrai | ||
86 | // NOTE 2: PHP n'a pas de pointeur mais des références, une référence est un alias qui ne contient pas l'objet lui-même | ||
87 | // NOTE 3: la variable créée lors d'un "new" est elle-même une référence contenant un identifiant (= le pointeur?) | ||
88 | // NOTE 4: l'objet est détruit lorsque la dernière référence est supprimée | ||
89 | |||
90 | function searchCustomer(string $input, Clients $Client): array | ||
91 | { | ||
92 | $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre | ||
93 | $result = $Client->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées | ||
94 | //var_dump($result); | ||
95 | return($result); | ||
96 | } | ||
97 | |||
98 | |||
99 | function getServices(Clients $Client, string $type = '') | ||
100 | { | ||
101 | echo "debug: recherche d'une prestation\n"; | ||
102 | |||
103 | // on recherche les ID des prestas dans la table 'prestations' avec 'id_client' | ||
104 | $Presta = new Prestations($Client->getId()); | ||
105 | $Presta->setTypePresta($type); | ||
106 | $IDs = $Presta->getIdsByIdClient(); // comportement différent si le type est connu | ||
107 | unset($Presta); | ||
108 | |||
109 | // mettres toutes les données dans un tableau | ||
110 | $PrestaList = []; | ||
111 | foreach($IDs as $id) | ||
112 | { | ||
113 | $PrestaList[$id] = new Prestations($Client->getId()); // renseigne 'id_client' | ||
114 | $PrestaList[$id]->setId($id); // ID de la prestation = clé du tableau | ||
115 | $PrestaList[$id]->hydrate($PrestaList[$id]->findById()); // données copiés de la table à l'objet | ||
116 | } | ||
117 | |||
118 | // fenêtre | ||
119 | $entrees = []; | ||
120 | foreach($PrestaList as $Presta) | ||
121 | { | ||
122 | $id = $Presta->getId(); | ||
123 | $entrees[$id][] = $id; | ||
124 | $Date = new Dates((int)$Presta->getDate()); // envoi du timestamp, (int) est là par sécurité | ||
125 | $entrees[$id][] = $Date->getDate(); | ||
126 | $entrees[$id][] = $Presta->getTypePresta(); | ||
127 | $entrees[$id][] = $Presta->getCodePresta(); | ||
128 | } | ||
129 | $ResultatsRecherchePresta = new ZenityList(ZenitySetup::$resultats_recherche_presta_text, []); | ||
130 | $ResultatsRecherchePresta->setListRows($entrees, 4); | ||
131 | |||
132 | // choix de l'utilisateur | ||
133 | $input = exec($ResultatsRecherchePresta->get()); // $input est l'ID de la prestation | ||
134 | if($input == '') | ||
135 | { | ||
136 | echo "debug: recherche annulée ou saisie vide\n"; | ||
137 | return 0; | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | return $PrestaList[$input]; | ||
142 | } | ||
143 | } | ||
diff --git a/src/latex_templates/location.php b/src/latex_templates/location.php index 4b6cfcb..3c9eefc 100644 --- a/src/latex_templates/location.php +++ b/src/latex_templates/location.php | |||
@@ -5,9 +5,9 @@ if($data['valeur'] != 0) | |||
5 | { | 5 | { |
6 | $data['valeur'] = ((string) $data['valeur']) . '€'; | 6 | $data['valeur'] = ((string) $data['valeur']) . '€'; |
7 | } | 7 | } |
8 | if($data['loyer_mensuel'] != 0) | 8 | if($data['loyer_hebdo'] != 0) |
9 | { | 9 | { |
10 | $data['loyer_mensuel'] = ((string) $data['loyer_mensuel']) . '€'; | 10 | $data['loyer_hebdo'] = ((string) $data['loyer_hebdo']) . '€'; |
11 | } | 11 | } |
12 | 12 | ||
13 | ob_start(); | 13 | ob_start(); |
@@ -74,7 +74,7 @@ ob_start(); | |||
74 | CLAUSES\\ | 74 | CLAUSES\\ |
75 | 75 | ||
76 | Durée du prêt : \textcolor{vert}{<?= $data['duree_location'] ?>}\\ | 76 | Durée du prêt : \textcolor{vert}{<?= $data['duree_location'] ?>}\\ |
77 | Loyer mensuel : \textcolor{vert}{<?= $data['loyer_mensuel'] ?>}\\ | 77 | Loyer mensuel : \textcolor{vert}{<?= $data['loyer_hebdo'] ?>}\\ |
78 | 78 | ||
79 | 79 | ||
80 | \textbf{Le bénéficiaire de cette location s’engage à prendre soin du bien désigné et à en faire un usage strictement personnel.}\\ | 80 | \textbf{Le bénéficiaire de cette location s’engage à prendre soin du bien désigné et à en faire un usage strictement personnel.}\\ |
diff --git a/src/main.php b/src/main.php index 4dfdaab..45f6c43 100644 --- a/src/main.php +++ b/src/main.php | |||
@@ -2,11 +2,10 @@ | |||
2 | // src/main.php | 2 | // src/main.php |
3 | 3 | ||
4 | //require('model/File.php'); // utilité d'une classe File? | 4 | //require('model/File.php'); // utilité d'une classe File? |
5 | require('src/files.php'); | 5 | require 'src/files.php'; |
6 | require('src/functions.php'); | ||
7 | 6 | ||
8 | // configuration de l'utilisateur | 7 | // configuration de l'utilisateur |
9 | require('src/Config.php'); // lit le config.ini et gère certaines erreurs (exemple les / aux chemins manquants) | 8 | require 'src/Config.php'; // lit le config.ini et gère certaines erreurs (exemple les / aux chemins manquants) |
10 | Config::readFile('config/config.ini'); | 9 | Config::readFile('config/config.ini'); |
11 | Config::hydrate(); | 10 | Config::hydrate(); |
12 | // et à coder peut-être plus tard | 11 | // et à coder peut-être plus tard |
@@ -27,11 +26,32 @@ $sqlitebrowser_enable = false; | |||
27 | $sqlite_cli = ''; // commande sqlite ou sqlite3 | 26 | $sqlite_cli = ''; // commande sqlite ou sqlite3 |
28 | $x_term_command = ''; // commande terminal en mode graphique | 27 | $x_term_command = ''; // commande terminal en mode graphique |
29 | 28 | ||
30 | require('src/dependances.php'); // vérification des dépendances | 29 | require 'src/dependances.php'; // vérification des dépendances |
31 | require('src/Dates.php'); // gère dates et timestamps | 30 | require 'src/Dates.php'; // gère dates et timestamps |
32 | Dates::$date_format = Config::$date_format; // dates européennes ou américaines | 31 | Dates::$date_format = Config::$date_format; // dates européennes ou américaines |
33 | 32 | ||
34 | require('src/model/DB.php'); // connexion en héritant de PDO | 33 | // entités doctrine |
34 | require 'src/model/doctrine-bootstrap.php'; | ||
35 | include 'src/model/entities/Client.php'; | ||
36 | include 'src/model/entities/Prestation.php'; | ||
37 | include 'src/model/entities/Devis.php'; | ||
38 | include 'src/model/entities/Facture.php'; | ||
39 | include 'src/model/entities/CESU.php'; | ||
40 | include 'src/model/entities/Location.php'; | ||
41 | |||
42 | // utiliser plus tard de nouvelles classes Manager au lieu des entités | ||
43 | // ET les faire hériter d'un unique parent | ||
44 | Client::$entityManager = $entityManager; | ||
45 | Prestation::$entityManager = $entityManager; | ||
46 | Devis::$entityManager = $entityManager; | ||
47 | Facture::$entityManager = $entityManager; | ||
48 | CESU::$entityManager = $entityManager; | ||
49 | Location::$entityManager = $entityManager; | ||
50 | |||
51 | require 'src/functions.php'; | ||
52 | |||
53 | |||
54 | /*require('src/model/DB.php'); // connexion en héritant de PDO | ||
35 | // création du DSN à mettre ailleurs (dans Model?) | 55 | // création du DSN à mettre ailleurs (dans Model?) |
36 | DB::$dsn = 'sqlite:' . Config::$db_path; // Data Source Name = 1er paramètre du constructeur de PDO: $bdd = new PDO($dsn); | 56 | DB::$dsn = 'sqlite:' . Config::$db_path; // Data Source Name = 1er paramètre du constructeur de PDO: $bdd = new PDO($dsn); |
37 | 57 | ||
@@ -43,17 +63,18 @@ require('src/model/Clients.php'); | |||
43 | require('src/model/Prestations.php'); | 63 | require('src/model/Prestations.php'); |
44 | require('src/model/DevisFactures.php'); | 64 | require('src/model/DevisFactures.php'); |
45 | require('src/model/CESU.php'); | 65 | require('src/model/CESU.php'); |
46 | require('src/model/Locations.php'); | 66 | require('src/model/Locations.php');*/ |
67 | |||
47 | 68 | ||
48 | require('src/view/Zenity.php'); // générer ler commandes système zenity | 69 | require 'src/view/Zenity.php'; // générer ler commandes système zenity |
49 | require('src/view/ZenitySetup.php'); // texte dans les fenêtres ET instanciation (un objet = une commande) | 70 | require 'src/view/ZenitySetup.php'; // texte dans les fenêtres ET instanciation (un objet = une commande) |
50 | 71 | ||
51 | require('src/Latex.php'); // générer le code LaTeX | 72 | require 'src/Latex.php'; // générer le code LaTeX |
52 | 73 | ||
53 | // boucle principale | 74 | // boucle principale |
54 | require('src/sections/1_customer.php'); | 75 | require 'src/sections/1_customer.php'; |
55 | require('src/sections/2_service.php'); | 76 | require 'src/sections/2_service.php'; |
56 | require('src/sections/3_modify_data.php'); | 77 | require 'src/sections/3_modify_data.php'; |
57 | require('src/sections/4_get_document.php'); | 78 | require 'src/sections/4_get_document.php'; |
58 | require('src/sections/5_view_data.php'); | 79 | require 'src/sections/5_view_data.php'; |
59 | require('src/main_loop.php'); // action !! | 80 | require 'src/main_loop.php'; // action !! |
diff --git a/src/main_loop.php b/src/main_loop.php index 645a7ee..8dac901 100644 --- a/src/main_loop.php +++ b/src/main_loop.php | |||
@@ -12,7 +12,7 @@ while($main_loop) | |||
12 | if($section[0] === 0) | 12 | if($section[0] === 0) |
13 | { | 13 | { |
14 | echo("Menu principal\n"); | 14 | echo("Menu principal\n"); |
15 | $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); | 15 | $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal['text'], ZenitySetup::$menu_principal['entrees']); |
16 | $choix_niv1 = exec($MenuPrincipal->get()); | 16 | $choix_niv1 = exec($MenuPrincipal->get()); |
17 | } | 17 | } |
18 | else | 18 | else |
@@ -23,58 +23,58 @@ while($main_loop) | |||
23 | // comparaison du retour de $MenuPrincipal->get() avec les noms des entrées du même menu | 23 | // comparaison du retour de $MenuPrincipal->get() avec les noms des entrées du même menu |
24 | 24 | ||
25 | // -- SECTION 1: Clients et prospects -- | 25 | // -- SECTION 1: Clients et prospects -- |
26 | if($choix_niv1 === ZenitySetup::$menu_principal_entrees[0] || $section[0] === 1) | 26 | if($choix_niv1 === ZenitySetup::$menu_principal['entrees'][0] || $section[0] === 1) |
27 | { | 27 | { |
28 | echo("choix: ". ZenitySetup::$menu_principal_entrees[0] . "\n"); | 28 | echo("choix: ". ZenitySetup::$menu_principal['entrees'][0] . "\n"); |
29 | $section = newCustomer(); | 29 | $section = newCustomer(); |
30 | } | 30 | } |
31 | 31 | ||
32 | // -- SECTION 2: Prestations et devis -- | 32 | // -- SECTION 2: Prestations et devis -- |
33 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[1] || $section[0] === 2) | 33 | elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][1] || $section[0] === 2) |
34 | { | 34 | { |
35 | echo("choix: ". ZenitySetup::$menu_principal_entrees[1] . "\n"); | 35 | echo("choix: ". ZenitySetup::$menu_principal['entrees'][1] . "\n"); |
36 | $section = newService($section[1]); // $section[1] vaut un type Clients ou null | 36 | $section = newService($section[1]); // $section[1] vaut un type Client ou null |
37 | } | 37 | } |
38 | 38 | ||
39 | // -- SECTION 3: Modifier un enregistrement -- | 39 | // -- SECTION 3: Modifier un enregistrement -- |
40 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[2] || $section[0] === 3) | 40 | elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][2] || $section[0] === 3) |
41 | { | 41 | { |
42 | echo("choix: " . ZenitySetup::$menu_principal_entrees[2] . "\n"); | 42 | echo("choix: " . ZenitySetup::$menu_principal['entrees'][2] . "\n"); |
43 | $section = modifyData($section[1]); // $section[1] vaut un type Clients ou null | 43 | $section = modifyData($section[1]); // $section[1] vaut un type Client ou null |
44 | } | 44 | } |
45 | 45 | ||
46 | // -- SECTION 4: Consulter, Imprimer un document -- | 46 | // -- SECTION 4: Consulter, Imprimer un document -- |
47 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[3] || $section[0] === 4) // = Imprimer un document | 47 | elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][3] || $section[0] === 4) // = Imprimer un document |
48 | { | 48 | { |
49 | echo("choix: ". ZenitySetup::$menu_principal_entrees[3] . "\n"); | 49 | echo("choix: ". ZenitySetup::$menu_principal['entrees'][3] . "\n"); |
50 | $section = getOrPrintDocument(); | 50 | $section = getOrPrintDocument(); |
51 | } | 51 | } |
52 | 52 | ||
53 | // -- SECTION 5: Consulter/analyser les données -- | 53 | // -- SECTION 5: Consulter/analyser les données -- |
54 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[4] || $section[0] === 5) | 54 | elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][4] || $section[0] === 5) |
55 | { | 55 | { |
56 | echo("choix: ". ZenitySetup::$menu_principal_entrees[4] . "\n"); | 56 | echo("choix: ". ZenitySetup::$menu_principal['entrees'][4] . "\n"); |
57 | // quel affichage? des tableaux avec zenity? LaTeX? une page web? un autre outil servant à faire des tableaux et graphiques | 57 | // quel affichage? des tableaux avec zenity? LaTeX? une page web? un autre outil servant à faire des tableaux et graphiques |
58 | $section = viewData(); | 58 | $section = viewData(); |
59 | } | 59 | } |
60 | 60 | ||
61 | // -- SECTION 6: Supports de communication -- | 61 | // -- SECTION 6: Supports de communication -- |
62 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[5] || $section[0] === 6) // = Communication | 62 | elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][5] || $section[0] === 6) // = Communication |
63 | { | 63 | { |
64 | echo("choix: ". ZenitySetup::$menu_principal_entrees[5] . "\n"); | 64 | echo("choix: ". ZenitySetup::$menu_principal['entrees'][5] . "\n"); |
65 | $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication_text, ZenitySetup::$menu_communication_entrees); | 65 | $MenuCommunication = new ZenityList(ZenitySetup::$menu_communication['text'], ZenitySetup::$menu_communication['entrees']); |
66 | $choix_niv2 = exec($MenuCommunication->get()); | 66 | $choix_niv2 = exec($MenuCommunication->get()); |
67 | if($choix_niv2 === ZenitySetup::$menu_communication_entrees[0]) // = Flyer (nécessite gimp) | 67 | if($choix_niv2 === ZenitySetup::$menu_communication['entrees'][0]) // = Flyer (nécessite gimp) |
68 | { | 68 | { |
69 | exec(windowAppCommand($image_editor, $flyer)); | 69 | exec(windowAppCommand(Config::$image_editor, $flyer)); |
70 | } | 70 | } |
71 | elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[1]) // = Carte de visite (nécessite scribus) | 71 | elseif($choix_niv2 === ZenitySetup::$menu_communication['entrees'][1]) // = Carte de visite (nécessite scribus) |
72 | { | 72 | { |
73 | exec(windowAppCommand($publishing, $business_card)); | 73 | exec(windowAppCommand(Config::$publishing, $business_card)); |
74 | } | 74 | } |
75 | elseif($choix_niv2 === ZenitySetup::$menu_communication_entrees[2]) // = Explorateur de fichiers | 75 | elseif($choix_niv2 === ZenitySetup::$menu_communication['entrees'][2]) // = Explorateur de fichiers |
76 | { | 76 | { |
77 | exec(windowAppCommand($file_explorer, $pub)); | 77 | exec(windowAppCommand($file_explorer, Config::$pub_path)); |
78 | } | 78 | } |
79 | else | 79 | else |
80 | { | 80 | { |
@@ -83,9 +83,9 @@ while($main_loop) | |||
83 | } | 83 | } |
84 | 84 | ||
85 | // -- SECTION 7: BDD -- | 85 | // -- SECTION 7: BDD -- |
86 | elseif($choix_niv1 === ZenitySetup::$menu_principal_entrees[6] || $section[0] === 7) // = Base de données | 86 | elseif($choix_niv1 === ZenitySetup::$menu_principal['entrees'][6] || $section[0] === 7) // = Base de données |
87 | { | 87 | { |
88 | echo("choix: ". ZenitySetup::$menu_principal_entrees[6] . "\n"); | 88 | echo("choix: ". ZenitySetup::$menu_principal['entrees'][6] . "\n"); |
89 | if($sqlitebrowser_enable) | 89 | if($sqlitebrowser_enable) |
90 | { | 90 | { |
91 | exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path)); | 91 | exec(windowAppCommand(Config::$sqlite_gui, Config::$db_path)); |
diff --git a/src/model/doctrine-bootstrap.php b/src/model/doctrine-bootstrap.php new file mode 100644 index 0000000..029b1b1 --- /dev/null +++ b/src/model/doctrine-bootstrap.php | |||
@@ -0,0 +1,31 @@ | |||
1 | <?php | ||
2 | // src/model/doctrine-bootstrap.php | ||
3 | |||
4 | use Doctrine\DBAL\DriverManager; | ||
5 | use Doctrine\ORM\EntityManager; | ||
6 | use Doctrine\ORM\ORMSetup; | ||
7 | |||
8 | require_once "vendor/autoload.php"; | ||
9 | |||
10 | // Create a simple "default" Doctrine ORM configuration for Attributes | ||
11 | $config = ORMSetup::createAttributeMetadataConfiguration( | ||
12 | //paths: array(__DIR__.'/entities'), | ||
13 | paths: array('src/model/entities'), | ||
14 | isDevMode: true, | ||
15 | ); | ||
16 | // or if you prefer XML | ||
17 | // $config = ORMSetup::createXMLMetadataConfiguration( | ||
18 | // paths: array(__DIR__."/config/xml"), | ||
19 | // isDevMode: true, | ||
20 | //); | ||
21 | |||
22 | // configuring the database connection | ||
23 | $connection = DriverManager::getConnection([ | ||
24 | 'driver' => 'pdo_sqlite', | ||
25 | //'path' => __DIR__ . '/../../data/' . Config::$db_name . '.sqlite', | ||
26 | 'path' => 'data/' . Config::$db_name . '.sqlite', | ||
27 | ], $config); | ||
28 | |||
29 | // obtaining the entity manager | ||
30 | $entityManager = new EntityManager($connection, $config); | ||
31 | |||
diff --git a/src/model/entities/CESU.php b/src/model/entities/CESU.php new file mode 100644 index 0000000..09a2542 --- /dev/null +++ b/src/model/entities/CESU.php | |||
@@ -0,0 +1,131 @@ | |||
1 | <?php | ||
2 | // src/entities/CESU.php | ||
3 | |||
4 | use Doctrine\ORM\Mapping as ORM; | ||
5 | use Doctrine\ORM\EntityManager; | ||
6 | |||
7 | #[ORM\Entity] | ||
8 | #[ORM\Table(name: 'cesu')] | ||
9 | class CESU | ||
10 | { | ||
11 | #[ORM\Id] | ||
12 | #[ORM\Column(type: 'integer')] | ||
13 | #[ORM\GeneratedValue] | ||
14 | private int|null $id = null; | ||
15 | |||
16 | #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] | ||
17 | #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
18 | private Prestation|null $presta = null; | ||
19 | |||
20 | #[ORM\Column] | ||
21 | private string $taches; | ||
22 | #[ORM\Column] | ||
23 | private string $duree_travail; | ||
24 | #[ORM\Column] | ||
25 | private float $salaire; | ||
26 | |||
27 | public static EntityManager $entityManager; | ||
28 | |||
29 | public function __construct(Prestation $presta = null) | ||
30 | { | ||
31 | if($presta != null) | ||
32 | { | ||
33 | $this->setPresta($presta); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | // getters | ||
38 | public function getPresta(): Prestation | ||
39 | { | ||
40 | return $this->presta; | ||
41 | } | ||
42 | |||
43 | public function getAllWithWindowFields(): array | ||
44 | { | ||
45 | return [ | ||
46 | "Tâche effectuée:" => $this->taches, | ||
47 | "Durée du travail:" => $this->duree_travail, | ||
48 | "Salaire:" => $this->salaire]; | ||
49 | } | ||
50 | |||
51 | // setters | ||
52 | public function set(string $entry, string $input) | ||
53 | { | ||
54 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaîne vide | ||
55 | switch($entry) | ||
56 | { | ||
57 | case "Tâche effectuée:": | ||
58 | $this->setTaches($input); | ||
59 | break; | ||
60 | case "Durée du travail:": | ||
61 | $this->setDureeTravail($input); | ||
62 | break; | ||
63 | case "Salaire:": | ||
64 | $this->setSalaire($input); | ||
65 | break; | ||
66 | } | ||
67 | } | ||
68 | private function setPresta(Prestation $input) // private? | ||
69 | { | ||
70 | $this->presta = $input; | ||
71 | } | ||
72 | public function setTaches(string $value) | ||
73 | { | ||
74 | $this->taches = $value; | ||
75 | return($this); | ||
76 | } | ||
77 | public function setDureeTravail(string $value) | ||
78 | { | ||
79 | $this->duree_travail = $value; | ||
80 | return($this); | ||
81 | } | ||
82 | public function setSalaire($value) | ||
83 | { | ||
84 | $value = str_replace(',', '.', $value); | ||
85 | $this->salaire = (float) $value; | ||
86 | return($this); | ||
87 | } | ||
88 | |||
89 | private function setAll(array $input) // private? | ||
90 | { | ||
91 | $this->taches = $input[0]; | ||
92 | $this->duree_travail = $input[1]; | ||
93 | $this->salaire = (float)$input[2]; | ||
94 | } | ||
95 | |||
96 | // à mettre plus tard dans une classe mère | ||
97 | protected function cleanSpecialChars(string $data): string | ||
98 | { | ||
99 | $search = ['"']; | ||
100 | return str_replace($search, '', $data); | ||
101 | } | ||
102 | // à mettre plus tard dans une classe mère | ||
103 | public function hydrate(string $answers) | ||
104 | { | ||
105 | $answers = $this->cleanSpecialChars($answers); // possibilité que $answers devienne une chaine vide | ||
106 | if($answers == '') | ||
107 | { | ||
108 | echo "erreur de CESU::hydrate(), la chaine \$answers est vide.\n"; | ||
109 | return false; | ||
110 | } | ||
111 | $data_array = explode('|', $answers); // array | ||
112 | |||
113 | $check = false; | ||
114 | if(count($data_array) === 4) // facture normale | ||
115 | { | ||
116 | $this->getPresta()->setModePaiement($data_array[3]); | ||
117 | //array_pop($data_array); // supprime la dernière case | ||
118 | unset($data_array[3]); | ||
119 | $this->setAll($data_array); | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | echo "erreur de CESU::hydrate(), le tableau \$data_array n'a pas la taille attendue.\n"; | ||
124 | return false; | ||
125 | } | ||
126 | |||
127 | //self::$entityManager->persist('Prestation'); | ||
128 | self::$entityManager->persist($this); // $Presta avec en cascade! | ||
129 | self::$entityManager->flush(); | ||
130 | } | ||
131 | } | ||
diff --git a/src/model/entities/Client.php b/src/model/entities/Client.php new file mode 100644 index 0000000..7dd3be6 --- /dev/null +++ b/src/model/entities/Client.php | |||
@@ -0,0 +1,314 @@ | |||
1 | <?php | ||
2 | // src/entities/Client.php | ||
3 | |||
4 | use Doctrine\ORM\Mapping as ORM; | ||
5 | use Doctrine\ORM\EntityManager; // pour ClientManager? | ||
6 | |||
7 | #[ORM\Entity] | ||
8 | #[ORM\Table(name: 'clients')] | ||
9 | class Client | ||
10 | { | ||
11 | #[ORM\Id] | ||
12 | #[ORM\Column(type: 'integer')] | ||
13 | #[ORM\GeneratedValue] | ||
14 | private int|null $id = null; | ||
15 | #[ORM\Column] | ||
16 | private string $prenom_nom; | ||
17 | #[ORM\Column] | ||
18 | private string $code_client; | ||
19 | #[ORM\Column] | ||
20 | private string $adresse; | ||
21 | #[ORM\Column] | ||
22 | private string $code_postal; | ||
23 | #[ORM\Column] | ||
24 | private string $ville; | ||
25 | #[ORM\Column] | ||
26 | private string $telephone; | ||
27 | #[ORM\Column] | ||
28 | private string $courriel; | ||
29 | #[ORM\Column] | ||
30 | private string $apropos; | ||
31 | #[ORM\Column(options: ['default' => 'prospect'])] | ||
32 | private string $type = 'prospect'; // valeur par défaut utilisée à l'instanciation, pas par doctrine | ||
33 | |||
34 | public static EntityManager $entityManager; | ||
35 | |||
36 | /*public function __construct() | ||
37 | { | ||
38 | global $entityManager; | ||
39 | self::$entityManager = $entityManager; | ||
40 | }*/ | ||
41 | |||
42 | |||
43 | // getters | ||
44 | public function getId(): int | ||
45 | { | ||
46 | return $this->id; | ||
47 | } | ||
48 | public function getPrenomNom(): string | ||
49 | { | ||
50 | return $this->prenom_nom; | ||
51 | } | ||
52 | public function getCodeClient(): string | ||
53 | { | ||
54 | return $this->code_client; | ||
55 | } | ||
56 | public function getAll(): array | ||
57 | { | ||
58 | // n'utiliser get_object_vars() qu'avec une entité parce qu'on maîtrise le nombre de propriétés | ||
59 | return get_object_vars($this); | ||
60 | } | ||
61 | |||
62 | // pour le GUI | ||
63 | public function getAllWithWindowFields(): array // différent de getAll() | ||
64 | { | ||
65 | return [ | ||
66 | "Prénom Nom:" => $this->prenom_nom, | ||
67 | "Code client (J.C.Dusse):" => $this->code_client, | ||
68 | "Adresse:" => $this->adresse, | ||
69 | "Code postal:" => $this->code_postal, | ||
70 | "Ville:" => $this->ville, | ||
71 | "Telephone:" => $this->telephone, | ||
72 | "Courriel:" => $this->courriel, | ||
73 | "À propos:" => $this->apropos, | ||
74 | "Client ou Prospect?" => $this->type]; | ||
75 | } | ||
76 | |||
77 | // setters | ||
78 | public function set(string $entry, string $input) | ||
79 | { | ||
80 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide | ||
81 | switch($entry) | ||
82 | { | ||
83 | case "Prénom Nom:": | ||
84 | $this->setPrenomNom($input); | ||
85 | break; | ||
86 | case "Code client (J.C.Dusse):": | ||
87 | $this->setCodeClient($input); | ||
88 | break; | ||
89 | case "Adresse:": | ||
90 | $this->setAdresse($input); | ||
91 | break; | ||
92 | case "Code postal:": | ||
93 | $this->setCodePostal($input); | ||
94 | break; | ||
95 | case "Ville:": | ||
96 | $this->setVille($input); | ||
97 | break; | ||
98 | case "Telephone:": | ||
99 | $this->setTelephone($input); | ||
100 | break; | ||
101 | case "Courriel:": | ||
102 | $this->setCourriel($input); | ||
103 | break; | ||
104 | case "À propos:": | ||
105 | $this->setApropos($input); | ||
106 | break; | ||
107 | case "Client ou Prospect?": | ||
108 | $this->setType($input); | ||
109 | break; | ||
110 | } | ||
111 | //self::$entityManager->flush(); | ||
112 | } | ||
113 | public function setPrenomNom($value) | ||
114 | { | ||
115 | $this->prenom_nom = (string) $value; | ||
116 | return $this; | ||
117 | } | ||
118 | public function setCodeClient($value) | ||
119 | { | ||
120 | $this->code_client = (string) $value; | ||
121 | return $this; | ||
122 | } | ||
123 | public function setAdresse($value) | ||
124 | { | ||
125 | $this->adresse = (string) $value; | ||
126 | return $this; | ||
127 | } | ||
128 | public function setCodePostal($value) | ||
129 | { | ||
130 | $this->code_postal = (string) $value; | ||
131 | return $this; | ||
132 | } | ||
133 | public function setVille($value) | ||
134 | { | ||
135 | $this->ville = (string) $value; | ||
136 | return $this; | ||
137 | } | ||
138 | public function setTelephone($value) | ||
139 | { | ||
140 | // type string parce que: | ||
141 | // - zenity renvoie une chaine | ||
142 | // - permet de garder le 0 au début et d'inscrire plusieurs numéros | ||
143 | $this->telephone = (string) $value; | ||
144 | return $this; | ||
145 | } | ||
146 | public function setCourriel($value) | ||
147 | { | ||
148 | $this->courriel = (string) $value; | ||
149 | return $this; | ||
150 | } | ||
151 | public function setApropos($value) | ||
152 | { | ||
153 | $this->apropos = (string) $value; | ||
154 | return $this; | ||
155 | } | ||
156 | public function setType($value) | ||
157 | { | ||
158 | $this->type = (string) $value; | ||
159 | return $this; | ||
160 | } | ||
161 | |||
162 | public function typeToClient() | ||
163 | { | ||
164 | if($this->type != 'client') | ||
165 | { | ||
166 | $this->type = 'client'; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | private function setAll(array $input) | ||
171 | { | ||
172 | $this->prenom_nom = $input[0]; | ||
173 | $this->code_client = $input[1]; | ||
174 | $this->adresse = $input[2]; | ||
175 | $this->code_postal = $input[3]; | ||
176 | $this->ville = $input[4]; | ||
177 | $this->telephone = $input[5]; | ||
178 | $this->courriel = $input[6]; | ||
179 | $this->apropos = $input[7]; | ||
180 | } | ||
181 | |||
182 | // à mettre dans une classe mère Model? | ||
183 | protected function cleanSpecialChars(string $data): string | ||
184 | { | ||
185 | $search = ['"']; | ||
186 | return str_replace($search, '', $data); | ||
187 | } | ||
188 | |||
189 | // une partie du code vient de Model::hydrateFromForm() | ||
190 | // Ã mettre dans une classe ClientManager? | ||
191 | public function enterCustomer(ZenityForms $Form): bool | ||
192 | { | ||
193 | $input = exec($Form->get()); | ||
194 | if($input == '') | ||
195 | { | ||
196 | echo "debug: annulation lors de l'enregistrement d'un nouveau client\n"; | ||
197 | return false; | ||
198 | } | ||
199 | |||
200 | $data_array = explode('|', $input); // array | ||
201 | if($data_array[0] == '') | ||
202 | { | ||
203 | echo "debug: données insuffisantes, le nom du client doit au minimum être renseigné\n"; | ||
204 | return false; | ||
205 | } | ||
206 | else | ||
207 | { | ||
208 | $this->setAll($data_array); | ||
209 | } | ||
210 | |||
211 | self::$entityManager->persist($this); | ||
212 | self::$entityManager->flush(); | ||
213 | |||
214 | //$this->id = $this->db->lastInsertId(); // synchro automatique avec doctrine | ||
215 | |||
216 | return true; | ||
217 | } | ||
218 | |||
219 | public static function getObject(ZenityEntry $SearchCustomerForm, ZenityList $SearchCustomerResults) // renvoie un Client ou 0 | ||
220 | { | ||
221 | // fenêtres | ||
222 | /*$SearchCustomerForm = new ZenityEntry(ZenitySetup::$recherche_client_text); | ||
223 | $SearchCustomerResults = new ZenityList(ZenitySetup::$resultats_recherche_client_text, []);*/ | ||
224 | |||
225 | $Customer = new self; // se serait bien d'hériter d'EntityManager? | ||
226 | |||
227 | $input = exec($SearchCustomerForm->get()); | ||
228 | if($input == '') // commenter ce if pour qu'une saisie vide permette d'obtenir tous les clients | ||
229 | { | ||
230 | echo "debug: recherche annulée ou saisie vide\n"; | ||
231 | return 0; | ||
232 | } | ||
233 | echo "debug: recherche effectuée\n"; | ||
234 | |||
235 | $MatchedObjects = self::searchCustomer($input, $Customer); | ||
236 | if(count($MatchedObjects) === 0) // si aucun client ne correspond, les prendre tous! | ||
237 | { | ||
238 | $repository = self::$entityManager->getRepository('Client'); | ||
239 | $MatchedObjects = $repository->findAll(); | ||
240 | |||
241 | if(count($MatchedObjects) === 0) // toujours rien | ||
242 | { | ||
243 | echo "debug: aucun client dans la base de données\n"; | ||
244 | return 0; | ||
245 | } | ||
246 | } | ||
247 | |||
248 | $clients_array = []; | ||
249 | foreach($MatchedObjects as $object) // d'objets en tableaux | ||
250 | { | ||
251 | $clients_array[] = get_object_vars($object); | ||
252 | } | ||
253 | |||
254 | $SearchCustomerResults->setListRows( | ||
255 | $clients_array, | ||
256 | //count($clients_array[$id])); | ||
257 | count($clients_array[0])); | ||
258 | |||
259 | // sélection parmi les résultats | ||
260 | $input = exec($SearchCustomerResults->get()); // renvoie l'id de la table 'clients' | ||
261 | if($input == '') | ||
262 | { | ||
263 | echo "debug: client pas trouvé ou pas sélectionné\n"; | ||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | echo "debug: client sélectionné\n"; | ||
268 | //$Customer->setId($input); | ||
269 | //$Customer->hydrate($Customer->findById()); | ||
270 | $Customer = $MatchedObjects[$input]; | ||
271 | //var_dump($Customer); | ||
272 | |||
273 | return $Customer; | ||
274 | } | ||
275 | |||
276 | private static function searchCustomer(string $input, Client $Customer): array | ||
277 | { | ||
278 | $input_array = explode(' ', $input); // si plusieurs mot, on les recherche tous l'un après l'autre | ||
279 | return $Customer->findByKeywords($input_array, 'prenom_nom'); // on obtient un tableau à deux dimensions avec les entrées trouvées | ||
280 | } | ||
281 | |||
282 | private function findByKeywords(array $keywords, string $field): array // renvoie un tableau d'objets | ||
283 | { | ||
284 | $results = []; | ||
285 | for($i = 0; $i < count($keywords); $i++) | ||
286 | { | ||
287 | // tableau à deux dimensions obtenu pour un mot clé | ||
288 | //$query_result = $this->execQuery('SELECT * FROM ' . $this->table . ' WHERE ' . $field . ' LIKE "%' . $keywords[$i] . '%"')->fetchAll(); | ||
289 | $query = self::$entityManager->createQuery('SELECT u FROM Client u WHERE u.' . $field . ' LIKE :expression'); | ||
290 | $query->setParameter('expression', '%' . $keywords[$i] . '%'); | ||
291 | $query_result = $query->getResult(); | ||
292 | |||
293 | foreach($query_result as $object) | ||
294 | { | ||
295 | $id = $object->getId(); | ||
296 | $already_exist = false; | ||
297 | //for($j = 0; $j < count($results); $j++) | ||
298 | foreach($results as $one_result) // pour chaque tableau déjà enregistré dans le tableau $results | ||
299 | { | ||
300 | if($one_result->getId() === $id) | ||
301 | { | ||
302 | $already_exist = true; | ||
303 | } | ||
304 | } | ||
305 | if(!$already_exist) | ||
306 | { | ||
307 | $results[$id] = $object; | ||
308 | } | ||
309 | } | ||
310 | } | ||
311 | //var_dump($results); | ||
312 | return $results; | ||
313 | } | ||
314 | } | ||
diff --git a/src/model/entities/Devis.php b/src/model/entities/Devis.php new file mode 100644 index 0000000..7383410 --- /dev/null +++ b/src/model/entities/Devis.php | |||
@@ -0,0 +1,241 @@ | |||
1 | <?php | ||
2 | // src/entities/Devis.php | ||
3 | |||
4 | use Doctrine\ORM\Mapping as ORM; | ||
5 | use Doctrine\ORM\EntityManager; | ||
6 | |||
7 | #[ORM\Entity] | ||
8 | #[ORM\Table(name: 'devis')] | ||
9 | class Devis | ||
10 | { | ||
11 | #[ORM\Id] | ||
12 | #[ORM\Column(type: 'integer')] | ||
13 | #[ORM\GeneratedValue] | ||
14 | private int|null $id = null; | ||
15 | |||
16 | #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] | ||
17 | #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
18 | private Prestation|null $presta = null; | ||
19 | |||
20 | #[ORM\Column] | ||
21 | private string $taches; | ||
22 | #[ORM\Column] | ||
23 | private float $total_main_d_oeuvre; | ||
24 | #[ORM\Column] | ||
25 | private string $pieces; | ||
26 | #[ORM\Column] | ||
27 | private float $total_pieces; | ||
28 | #[ORM\Column] | ||
29 | private float $deplacement; | ||
30 | #[ORM\Column] | ||
31 | private float $prix_devis; | ||
32 | #[ORM\Column] | ||
33 | private float $total_HT; | ||
34 | #[ORM\Column] | ||
35 | private string $delai_livraison; | ||
36 | #[ORM\Column] | ||
37 | private string $validite_devis; | ||
38 | #[ORM\Column (options: ['default' => 'non'])] | ||
39 | private string $signature_devis = 'non'; | ||
40 | |||
41 | public static EntityManager $entityManager; | ||
42 | |||
43 | public function __construct(Prestation $presta = null) | ||
44 | { | ||
45 | if($presta != null) | ||
46 | { | ||
47 | $this->setPresta($presta); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | // getters | ||
52 | public function getPresta(): Prestation | ||
53 | { | ||
54 | return $this->presta; | ||
55 | } | ||
56 | public function getAll(): array | ||
57 | { | ||
58 | // n'utiliser get_object_vars() qu'avec une entité parce qu'on maîtrise le nombre de propriétés | ||
59 | return get_object_vars($this); | ||
60 | } | ||
61 | |||
62 | public function getAllWithWindowFields(): array | ||
63 | { | ||
64 | //~ $taches = ["Tâches:" => $this->taches]; | ||
65 | //~ $champs_communs = [ | ||
66 | //~ "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, | ||
67 | //~ "Pièces:" => $this->pieces, | ||
68 | //~ "Total des pièces:" => $this->total_pieces, | ||
69 | //~ "Déplacement:" => $this->deplacement, | ||
70 | //~ "Total HT:" => $this->total_HT]; | ||
71 | //~ $champs_devis = [ | ||
72 | //~ "Delai de livraison:" => $this->delai_livraison, | ||
73 | //~ "Durée de validité:" => $this->validite_devis, | ||
74 | //~ "Devis signé:" => $this->signature_devis]; | ||
75 | //~ return $champs_communs + $champs_devis; | ||
76 | return [ | ||
77 | "Tâches:" => $this->taches, // JUSTE AJOUTÉ | ||
78 | "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, | ||
79 | "Pièces:" => $this->pieces, | ||
80 | "Total des pièces:" => $this->total_pieces, | ||
81 | "Déplacement:" => $this->deplacement, | ||
82 | "Total HT:" => $this->total_HT, | ||
83 | "Delai de livraison:" => $this->delai_livraison, | ||
84 | "Durée de validité:" => $this->validite_devis, | ||
85 | "Devis signé:" => $this->signature_devis]; | ||
86 | } | ||
87 | |||
88 | // setters | ||
89 | public function set(string $entry, string $input) // trouve la bonne méthode | ||
90 | { | ||
91 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaîne vide | ||
92 | switch($entry) | ||
93 | { | ||
94 | case "Tâches:": | ||
95 | $this->setTaches($input); | ||
96 | break; | ||
97 | case "Total Main d'oeuvre:": | ||
98 | $this->setTotalMainDOeuvre($input); | ||
99 | break; | ||
100 | case "Pièces:": | ||
101 | $this->setPieces($input); | ||
102 | break; | ||
103 | case "Total des pièces:": | ||
104 | $this->setTotalPieces($input); | ||
105 | break; | ||
106 | case "Déplacement:": | ||
107 | $this->setDeplacement($input); | ||
108 | break; | ||
109 | case "Prix du devis:": | ||
110 | $this->setPrixDevis($input); | ||
111 | break; | ||
112 | case "Total HT:": | ||
113 | $this->setTotalHT($input); | ||
114 | break; | ||
115 | case "Delai de livraison:": | ||
116 | $this->setDelaiLivraison($input); | ||
117 | break; | ||
118 | case "Durée de validité:": | ||
119 | $this->setValiditedevis($input); | ||
120 | break; | ||
121 | case "Devis signé:": | ||
122 | $this->setSignatureDevis($input); | ||
123 | break; | ||
124 | } | ||
125 | } | ||
126 | private function setPresta(Prestation $input) // private? | ||
127 | { | ||
128 | $this->presta = $input; | ||
129 | } | ||
130 | public function setTaches(string $value) | ||
131 | { | ||
132 | $this->taches = $value; | ||
133 | return($this); | ||
134 | } | ||
135 | public function setTotalMainDOeuvre($value) | ||
136 | { | ||
137 | $value = str_replace(',', '.', $value); | ||
138 | $this->total_main_d_oeuvre = (float) $value; // float "nettoie" tous les caractères après le dernier chiffre trouvé (ex: 50€ => 50, abc => 0) | ||
139 | return($this); | ||
140 | } | ||
141 | public function setPieces(string $value) | ||
142 | { | ||
143 | $this->pieces = $value; | ||
144 | return($this); | ||
145 | } | ||
146 | public function setTotalPieces($value) | ||
147 | { | ||
148 | $value = str_replace(',', '.', $value); | ||
149 | $this->total_pieces = (float) $value; | ||
150 | return($this); | ||
151 | } | ||
152 | public function setDeplacement($value) | ||
153 | { | ||
154 | $value = str_replace(',', '.', $value); | ||
155 | $this->deplacement = (float) $value; | ||
156 | return($this); | ||
157 | } | ||
158 | public function setTotalHT($value) | ||
159 | { | ||
160 | $value = str_replace(',', '.', $value); | ||
161 | $this->total_HT = (float) $value; | ||
162 | return($this); | ||
163 | } | ||
164 | public function setPrixDevis($value) | ||
165 | { | ||
166 | $value = str_replace(',', '.', $value); | ||
167 | $this->prix_devis = (float) $value; | ||
168 | return($this); | ||
169 | } | ||
170 | public function setDelaiLivraison(string $value) | ||
171 | { | ||
172 | $this->delai_livraison = $value; | ||
173 | return($this); | ||
174 | } | ||
175 | public function setValiditedevis(string $value) | ||
176 | { | ||
177 | $this->validite_devis = $value; | ||
178 | return($this); | ||
179 | } | ||
180 | public function setSignatureDevis(string $value) | ||
181 | { | ||
182 | $this->signature_devis = $value; | ||
183 | return($this); | ||
184 | } | ||
185 | |||
186 | private function setAll(array $input) // private? | ||
187 | { | ||
188 | $this->taches = $input[0]; | ||
189 | $this->total_main_d_oeuvre = (float)$input[1]; | ||
190 | $this->pieces = $input[2]; | ||
191 | $this->total_pieces = (float)$input[3]; | ||
192 | $this->deplacement = (float)$input[4]; | ||
193 | $this->prix_devis = (float)$input[5]; | ||
194 | $this->total_HT = (float)$input[6]; | ||
195 | $this->delai_livraison = $input[7]; | ||
196 | $this->validite_devis = $input[8]; | ||
197 | |||
198 | // $signature_devis est renseigné plus tard en modifiant le devis | ||
199 | } | ||
200 | |||
201 | // à mettre plus tard dans une classe mère | ||
202 | protected function cleanSpecialChars(string $data): string | ||
203 | { | ||
204 | $search = ['"']; | ||
205 | return str_replace($search, '', $data); | ||
206 | } | ||
207 | // à mettre plus tard dans une classe mère | ||
208 | public function hydrate(string $answers) | ||
209 | { | ||
210 | $answers = $this->cleanSpecialChars($answers); // possibilité que $answers devienne une chaine vide | ||
211 | if($answers == '') | ||
212 | { | ||
213 | echo "erreur de Devis::hydrate(), la chaine \$answers est vide.\n"; | ||
214 | return false; | ||
215 | } | ||
216 | $data_array = explode('|', $answers); // array | ||
217 | |||
218 | $check = false; | ||
219 | if(count($data_array) === 9) // facture normale | ||
220 | { | ||
221 | $this->getPresta()->setModePaiement(''); // sécurité, doctrine plante si "null" | ||
222 | $this->setAll($data_array); | ||
223 | } | ||
224 | else | ||
225 | { | ||
226 | echo "erreur de Devis::hydrate(), le tableau \$data_array n'a pas la taille attendue.\n"; | ||
227 | return false; | ||
228 | } | ||
229 | |||
230 | //self::$entityManager->persist('Prestation'); | ||
231 | self::$entityManager->persist($this); // $Presta avec en cascade! | ||
232 | self::$entityManager->flush(); | ||
233 | } | ||
234 | |||
235 | // création d'une facture à partir d'un devis | ||
236 | public static function getQuotation(Prestation $Quotation) | ||
237 | { | ||
238 | $repository = self::$entityManager->getRepository('Devis'); | ||
239 | return $repository->findOneBy(['presta' => $Quotation->getId()]); // ne peut y en avoir deux | ||
240 | } | ||
241 | } | ||
diff --git a/src/model/entities/Facture.php b/src/model/entities/Facture.php new file mode 100644 index 0000000..3a8a551 --- /dev/null +++ b/src/model/entities/Facture.php | |||
@@ -0,0 +1,261 @@ | |||
1 | <?php | ||
2 | // src/entities/Facture.php | ||
3 | |||
4 | use Doctrine\ORM\Mapping as ORM; | ||
5 | use Doctrine\ORM\EntityManager; | ||
6 | |||
7 | #[ORM\Entity] | ||
8 | #[ORM\Table(name: 'factures')] | ||
9 | class Facture | ||
10 | { | ||
11 | #[ORM\Id] | ||
12 | #[ORM\Column(type: 'integer')] | ||
13 | #[ORM\GeneratedValue] | ||
14 | private int|null $id = null; | ||
15 | |||
16 | #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] | ||
17 | #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
18 | private Prestation|null $presta = null; | ||
19 | |||
20 | #[ORM\Column] | ||
21 | private string $taches; | ||
22 | #[ORM\Column] | ||
23 | private string $machine; | ||
24 | #[ORM\Column] | ||
25 | private string $OS; | ||
26 | #[ORM\Column] | ||
27 | private string $donnees; | ||
28 | #[ORM\Column] | ||
29 | private string $cles_licences; | ||
30 | #[ORM\Column] | ||
31 | private float $total_main_d_oeuvre; | ||
32 | #[ORM\Column] | ||
33 | private string $pieces; | ||
34 | #[ORM\Column] | ||
35 | private float $total_pieces; | ||
36 | #[ORM\Column] | ||
37 | private float $deplacement; | ||
38 | #[ORM\Column] | ||
39 | private float $total_HT; | ||
40 | |||
41 | public static EntityManager $entityManager; | ||
42 | |||
43 | public function __construct(Prestation $presta = null) | ||
44 | { | ||
45 | if($presta != null) | ||
46 | { | ||
47 | $this->setPresta($presta); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | // getters | ||
52 | public function getPresta(): Prestation | ||
53 | { | ||
54 | return $this->presta; | ||
55 | } | ||
56 | public function getAll(): array | ||
57 | { | ||
58 | // n'utiliser get_object_vars() qu'avec une entité parce qu'on maîtrise le nombre de propriétés | ||
59 | return get_object_vars($this); | ||
60 | } | ||
61 | |||
62 | public function getAllWithWindowFields(): array | ||
63 | { | ||
64 | //~ $taches = ["Tâches:" => $this->taches]; | ||
65 | //~ $champs_facture = [ | ||
66 | //~ "PC:" => $this->machine, | ||
67 | //~ "OS:" => $this->OS, | ||
68 | //~ "Données:" => $this->donnees, | ||
69 | //~ "Clés de licences:" => $this->cles_licences]; | ||
70 | //~ $champs_communs = [ | ||
71 | //~ "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, | ||
72 | //~ "Pièces:" => $this->pieces, | ||
73 | //~ "Total des pièces:" => $this->total_pieces, | ||
74 | //~ "Déplacement:" => $this->deplacement, | ||
75 | //~ "Total HT:" => $this->total_HT]; | ||
76 | //return $taches + $champs_facture + $champs_communs; | ||
77 | return [ | ||
78 | "Tâches:" => $this->taches, | ||
79 | "PC:" => $this->machine, | ||
80 | "OS:" => $this->OS, | ||
81 | "Données:" => $this->donnees, | ||
82 | "Clés de licences:" => $this->cles_licences, | ||
83 | "Total Main d'oeuvre:" => $this->total_main_d_oeuvre, | ||
84 | "Pièces:" => $this->pieces, | ||
85 | "Total des pièces:" => $this->total_pieces, | ||
86 | "Déplacement:" => $this->deplacement, | ||
87 | "Total HT:" => $this->total_HT]; | ||
88 | } | ||
89 | |||
90 | // setters | ||
91 | public function set(string $entry, string $input) // trouve la bonne méthode | ||
92 | { | ||
93 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaîne vide | ||
94 | switch($entry) | ||
95 | { | ||
96 | case "Tâches:": | ||
97 | $this->setTaches($input); | ||
98 | break; | ||
99 | case "PC:": | ||
100 | $this->setMachine($input); | ||
101 | break; | ||
102 | case "OS:": | ||
103 | $this->setOS($input); | ||
104 | break; | ||
105 | case "Données:": | ||
106 | $this->setDonnees($input); | ||
107 | break; | ||
108 | case "Clés de licences:": | ||
109 | $this->setClesLicences($input); | ||
110 | break; | ||
111 | case "Total Main d'oeuvre:": | ||
112 | $this->setTotalMainDOeuvre($input); | ||
113 | break; | ||
114 | case "Pièces:": | ||
115 | $this->setPieces($input); | ||
116 | break; | ||
117 | case "Total des pièces:": | ||
118 | $this->setTotalPieces($input); | ||
119 | break; | ||
120 | case "Déplacement:": | ||
121 | $this->setDeplacement($input); | ||
122 | break; | ||
123 | case "Total HT:": | ||
124 | $this->setTotalHT($input); | ||
125 | break; | ||
126 | } | ||
127 | } | ||
128 | public function setPresta(Prestation $input) // private? | ||
129 | { | ||
130 | $this->presta = $input; | ||
131 | } | ||
132 | public function setTaches(string $value) | ||
133 | { | ||
134 | $this->taches = $value; | ||
135 | return($this); | ||
136 | } | ||
137 | public function setMachine(string $value) | ||
138 | { | ||
139 | $this->machine = $value; | ||
140 | return($this); | ||
141 | } | ||
142 | public function setOS(string $value) | ||
143 | { | ||
144 | $this->OS = $value; | ||
145 | return($this); | ||
146 | } | ||
147 | public function setDonnees(string $value) | ||
148 | { | ||
149 | $this->donnees = $value; | ||
150 | return($this); | ||
151 | } | ||
152 | public function setClesLicences(string $value) | ||
153 | { | ||
154 | $this->cles_licences = $value; | ||
155 | return($this); | ||
156 | } | ||
157 | public function setTotalMainDOeuvre($value) | ||
158 | { | ||
159 | $value = str_replace(',', '.', $value); | ||
160 | $this->total_main_d_oeuvre = (float) $value; // float "nettoie" tous les caractères après le dernier chiffre trouvé (ex: 50€ => 50, abc => 0) | ||
161 | return($this); | ||
162 | } | ||
163 | public function setPieces(string $value) | ||
164 | { | ||
165 | $this->pieces = $value; | ||
166 | return($this); | ||
167 | } | ||
168 | public function setTotalPieces($value) | ||
169 | { | ||
170 | $value = str_replace(',', '.', $value); | ||
171 | $this->total_pieces = (float) $value; | ||
172 | return($this); | ||
173 | } | ||
174 | public function setDeplacement($value) | ||
175 | { | ||
176 | $value = str_replace(',', '.', $value); | ||
177 | $this->deplacement = (float) $value; | ||
178 | return($this); | ||
179 | } | ||
180 | public function setTotalHT($value) | ||
181 | { | ||
182 | $value = str_replace(',', '.', $value); | ||
183 | $this->total_HT = (float) $value; | ||
184 | return($this); | ||
185 | } | ||
186 | |||
187 | private function setAll(array $input) // private? | ||
188 | { | ||
189 | $this->taches = $input[0]; | ||
190 | $this->machine = $input[1]; | ||
191 | $this->OS = $input[2]; | ||
192 | $this->donnees = $input[3]; | ||
193 | $this->cles_licences = $input[4]; | ||
194 | $this->total_main_d_oeuvre = (float)$input[5]; | ||
195 | $this->pieces = $input[6]; | ||
196 | $this->total_pieces = (float)$input[7]; | ||
197 | $this->deplacement = (float)$input[8]; | ||
198 | $this->total_HT = (float)$input[9]; | ||
199 | } | ||
200 | private function setServiceFromQuotation(array $input) // private? | ||
201 | { | ||
202 | $this->machine = $input[0]; | ||
203 | $this->OS = $input[1]; | ||
204 | $this->donnees = $input[2]; | ||
205 | $this->cles_licences = $input[3]; | ||
206 | } | ||
207 | |||
208 | // à mettre plus tard dans une classe mère | ||
209 | protected function cleanSpecialChars(string $data): string | ||
210 | { | ||
211 | $search = ['"']; | ||
212 | return str_replace($search, '', $data); | ||
213 | } | ||
214 | // à mettre plus tard dans une classe mère | ||
215 | public function hydrate(string $answers) | ||
216 | { | ||
217 | $answers = $this->cleanSpecialChars($answers); // possibilité que $answers devienne une chaine vide | ||
218 | if($answers == '') | ||
219 | { | ||
220 | echo "erreur de Facture::hydrate(), la chaine \$answers est vide.\n"; | ||
221 | return false; | ||
222 | } | ||
223 | $data_array = explode('|', $answers); // array | ||
224 | |||
225 | $check = false; | ||
226 | if(count($data_array) === 11) // facture normale | ||
227 | { | ||
228 | $this->getPresta()->setModePaiement($data_array[10]); | ||
229 | //array_pop($data_array); // supprime la dernière case | ||
230 | unset($data_array[10]); | ||
231 | $this->setAll($data_array); | ||
232 | } | ||
233 | elseif(count($data_array) === 5) // facture à partir d'un devis | ||
234 | { | ||
235 | $this->getPresta()->setModePaiement($data_array[4]); | ||
236 | unset($data_array[4]); | ||
237 | $this->setServiceFromQuotation($data_array); | ||
238 | } | ||
239 | else | ||
240 | { | ||
241 | echo "erreur de Facture::hydrate(), le tableau \$data_array n'a pas la taille attendue.\n"; | ||
242 | return false; | ||
243 | } | ||
244 | |||
245 | //self::$entityManager->persist('Prestation'); | ||
246 | self::$entityManager->persist($this); // $Presta avec en cascade! | ||
247 | self::$entityManager->flush(); | ||
248 | } | ||
249 | |||
250 | public function hydrateWithQuotation(Devis $QuotationDetails) | ||
251 | { | ||
252 | $data = $QuotationDetails->getAll(); | ||
253 | //var_dump($data);die; | ||
254 | $this->taches = $data['taches']; | ||
255 | $this->total_main_d_oeuvre = $data['total_main_d_oeuvre']; | ||
256 | $this->pieces = $data['pieces']; | ||
257 | $this->total_pieces = $data['total_pieces']; | ||
258 | $this->deplacement = $data['deplacement']; | ||
259 | $this->total_HT = $data['total_HT']; | ||
260 | } | ||
261 | } | ||
diff --git a/src/model/entities/Location.php b/src/model/entities/Location.php new file mode 100644 index 0000000..7ce6f0d --- /dev/null +++ b/src/model/entities/Location.php | |||
@@ -0,0 +1,209 @@ | |||
1 | <?php | ||
2 | // src/entities/Location.php | ||
3 | |||
4 | use Doctrine\ORM\Mapping as ORM; | ||
5 | use Doctrine\ORM\EntityManager; | ||
6 | |||
7 | #[ORM\Entity] | ||
8 | #[ORM\Table(name: 'locations')] | ||
9 | class Location | ||
10 | { | ||
11 | #[ORM\Id] | ||
12 | #[ORM\Column(type: 'integer')] | ||
13 | #[ORM\GeneratedValue] | ||
14 | private int|null $id = null; | ||
15 | |||
16 | #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] | ||
17 | #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
18 | private Prestation|null $presta = null; | ||
19 | |||
20 | #[ORM\Column] | ||
21 | protected string $designation; | ||
22 | #[ORM\Column] | ||
23 | protected string $modele_description; | ||
24 | #[ORM\Column] | ||
25 | protected float $valeur; | ||
26 | #[ORM\Column] | ||
27 | protected string $etat_des_lieux_debut; | ||
28 | #[ORM\Column] | ||
29 | protected string $etat_des_lieux_fin = ''; | ||
30 | #[ORM\Column] | ||
31 | protected string $duree_location; | ||
32 | #[ORM\Column] | ||
33 | protected float $loyer_hebdo; | ||
34 | #[ORM\Column] | ||
35 | protected int $loyers_payes; | ||
36 | #[ORM\Column] | ||
37 | protected int $caution; | ||
38 | |||
39 | public static EntityManager $entityManager; | ||
40 | |||
41 | public function __construct(Prestation $presta = null) | ||
42 | { | ||
43 | if($presta != null) | ||
44 | { | ||
45 | $this->setPresta($presta); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | // getters | ||
50 | public function getPresta(): Prestation | ||
51 | { | ||
52 | return $this->presta; | ||
53 | } | ||
54 | public function getAll(): array | ||
55 | { | ||
56 | // n'utiliser get_object_vars() qu'avec une entité parce qu'on maîtrise le nombre de propriétés | ||
57 | return get_object_vars($this); | ||
58 | } | ||
59 | |||
60 | public function getAllWithWindowFields(): array | ||
61 | { | ||
62 | return [ | ||
63 | "Désignation:" => $this->designation, | ||
64 | "Description du modèle:" => $this->modele_description, | ||
65 | "Valeur:" => $this->valeur, | ||
66 | "État des lieux de début:" => $this->etat_des_lieux_debut, | ||
67 | "État des lieux de fin:" => $this->etat_des_lieux_fin, | ||
68 | "Durée de la location:" => $this->duree_location, | ||
69 | "Loyer Hebdomadaire:" => $this->loyer_hebdo, | ||
70 | "Loyers Payés:" => $this->loyers_payes, | ||
71 | "Caution:" => $this->caution]; | ||
72 | } | ||
73 | |||
74 | // setters | ||
75 | public function set(string $entry, string $input) | ||
76 | { | ||
77 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaîne vide | ||
78 | switch($entry) | ||
79 | { | ||
80 | case "Désignation:": | ||
81 | $this->setDesignation($input); | ||
82 | break; | ||
83 | case "Description du modèle:": | ||
84 | $this->setModeleDescription($input); | ||
85 | break; | ||
86 | case "Valeur:": | ||
87 | $this->setValeur($input); | ||
88 | break; | ||
89 | case "État des lieux de début:": | ||
90 | $this->setEtatDesLieuxDebut($input); | ||
91 | break; | ||
92 | case "État des lieux de fin:": | ||
93 | $this->setEtatDesLieuxFin($input); | ||
94 | break; | ||
95 | case "Durée de la location:": | ||
96 | $this->setDureeLocation($input); | ||
97 | break; | ||
98 | case "Loyer Hebdomadaire:": | ||
99 | $this->setLoyerHebdo($input); | ||
100 | break; | ||
101 | case "Loyers Payés:": | ||
102 | $this->setLoyersPayes($input); | ||
103 | break; | ||
104 | case "Caution:": | ||
105 | $this->setCaution($input); | ||
106 | break; | ||
107 | } | ||
108 | } | ||
109 | private function setPresta(Prestation $input) // private? | ||
110 | { | ||
111 | $this->presta = $input; | ||
112 | } | ||
113 | public function setDesignation(string $value) | ||
114 | { | ||
115 | $this->designation = $value; | ||
116 | return($this); | ||
117 | } | ||
118 | public function setModeleDescription(string $value) | ||
119 | { | ||
120 | $this->modele_description = $value; | ||
121 | return($this); | ||
122 | } | ||
123 | public function setValeur($value) | ||
124 | { | ||
125 | $value = str_replace(',', '.', $value); | ||
126 | $this->valeur = (float) $value; | ||
127 | return($this); | ||
128 | } | ||
129 | public function setEtatDesLieuxDebut(string $value) | ||
130 | { | ||
131 | $this->etat_des_lieux_debut = $value; | ||
132 | return($this); | ||
133 | } | ||
134 | public function setEtatDesLieuxFin(string $value) | ||
135 | { | ||
136 | $this->etat_des_lieux_fin = $value; | ||
137 | return($this); | ||
138 | } | ||
139 | public function setDureeLocation(string $value) | ||
140 | { | ||
141 | $this->duree_location = $value; | ||
142 | return($this); | ||
143 | } | ||
144 | public function setLoyerMensuel($value) | ||
145 | { | ||
146 | $value = str_replace(',', '.', $value); | ||
147 | $this->loyer_mensuel = (float) $value; | ||
148 | return($this); | ||
149 | } | ||
150 | public function setLoyersPayes($value) | ||
151 | { | ||
152 | $value = str_replace(',', '.', $value); | ||
153 | $this->loyers_payes = (float) $value; | ||
154 | return($this); | ||
155 | } | ||
156 | public function setCaution($value) | ||
157 | { | ||
158 | $value = str_replace(',', '.', $value); | ||
159 | $this->caution = (float) $value; | ||
160 | return($this); | ||
161 | } | ||
162 | |||
163 | private function setAll(array $input) // private? | ||
164 | { | ||
165 | $this->designation = $input[0]; | ||
166 | $this->modele_description = $input[1]; | ||
167 | $this->valeur = (float)$input[2]; | ||
168 | $this->etat_des_lieux_debut = $input[3]; | ||
169 | $this->etat_des_lieux_fin = ''; // sécurité | ||
170 | $this->duree_location = $input[4]; | ||
171 | $this->loyer_hebdo = (float)$input[5]; | ||
172 | $this->loyers_payes = (int)$input[6]; | ||
173 | $this->caution = (int)$input[7]; | ||
174 | } | ||
175 | |||
176 | // à mettre plus tard dans une classe mère | ||
177 | protected function cleanSpecialChars(string $data): string | ||
178 | { | ||
179 | $search = ['"']; | ||
180 | return str_replace($search, '', $data); | ||
181 | } | ||
182 | // à mettre plus tard dans une classe mère | ||
183 | public function hydrate(string $answers) | ||
184 | { | ||
185 | $answers = $this->cleanSpecialChars($answers); // possibilité que $answers devienne une chaine vide | ||
186 | if($answers == '') | ||
187 | { | ||
188 | echo "erreur de Location::hydrate(), la chaine \$answers est vide.\n"; | ||
189 | return false; | ||
190 | } | ||
191 | $data_array = explode('|', $answers); // array | ||
192 | |||
193 | $check = false; | ||
194 | if(count($data_array) === 8) | ||
195 | { | ||
196 | $this->getPresta()->setModePaiement(''); // sécurité, doctrine plante si "null" | ||
197 | $this->setAll($data_array); | ||
198 | } | ||
199 | else | ||
200 | { | ||
201 | echo "erreur de Location::hydrate(), le tableau \$data_array n'a pas la taille attendue.\n"; | ||
202 | return false; | ||
203 | } | ||
204 | |||
205 | //self::$entityManager->persist('Prestation'); | ||
206 | self::$entityManager->persist($this); // $Presta avec en cascade! | ||
207 | self::$entityManager->flush(); | ||
208 | } | ||
209 | } | ||
diff --git a/src/model/entities/Prestation.php b/src/model/entities/Prestation.php new file mode 100644 index 0000000..6d014d8 --- /dev/null +++ b/src/model/entities/Prestation.php | |||
@@ -0,0 +1,252 @@ | |||
1 | <?php | ||
2 | // src/entities/Prestation.php | ||
3 | |||
4 | use Doctrine\ORM\Mapping as ORM; | ||
5 | use Doctrine\ORM\EntityManager; | ||
6 | |||
7 | #[ORM\Entity] | ||
8 | #[ORM\Table(name: 'prestations')] | ||
9 | class Prestation | ||
10 | { | ||
11 | #[ORM\Id] | ||
12 | #[ORM\Column(type: 'integer')] | ||
13 | #[ORM\GeneratedValue] | ||
14 | private int|null $id = null; | ||
15 | |||
16 | #[ORM\ManyToOne(targetEntity: Client::class, cascade: ['persist'])] | ||
17 | #[ORM\JoinColumn(name: 'id_client', referencedColumnName: 'id')] | ||
18 | private Client|null $client = null; // type int en SQL et dans la base | ||
19 | |||
20 | #[ORM\Column] | ||
21 | private string $code_presta; | ||
22 | #[ORM\Column] | ||
23 | private int $date; // timestamp unix | ||
24 | #[ORM\Column] | ||
25 | private string $type_presta; | ||
26 | #[ORM\Column] | ||
27 | private string $mode_paiement = ''; // non renseigné quand on fait un devis | ||
28 | #[ORM\Column] | ||
29 | private string $commentaires; | ||
30 | |||
31 | public static EntityManager $entityManager; | ||
32 | |||
33 | |||
34 | public function __construct(Client $client = null) | ||
35 | { | ||
36 | if($client != null) | ||
37 | { | ||
38 | $this->setClient($client); | ||
39 | } | ||
40 | } | ||
41 | |||
42 | // getters | ||
43 | public function getId(): int | ||
44 | { | ||
45 | return $this->id; | ||
46 | } | ||
47 | public function getCodePresta(): string | ||
48 | { | ||
49 | return $this->code_presta; | ||
50 | } | ||
51 | public function getDate(): int | ||
52 | { | ||
53 | return $this->date; | ||
54 | } | ||
55 | public function getTypePresta(): string | ||
56 | { | ||
57 | return $this->type_presta; | ||
58 | } | ||
59 | public function getClient(): Client | ||
60 | { | ||
61 | return $this->client; | ||
62 | } | ||
63 | public function getAll(): array | ||
64 | { | ||
65 | // n'utiliser get_object_vars() qu'avec une entité parce qu'on maîtrise le nombre de propriétés | ||
66 | return get_object_vars($this); | ||
67 | } | ||
68 | |||
69 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | ||
70 | { | ||
71 | $code_presta_tableau = explode('-', $this->code_presta); | ||
72 | $Date = new Dates($this->date); | ||
73 | |||
74 | return [ | ||
75 | //"Numéro prestation:" => end($code_presta_tableau), // crée des conflits, calcul automatique par setCodePresta() | ||
76 | "Date:" => $Date->getDate(), | ||
77 | //"Type de Presta:" => $this->type_presta, // choix impossible pour le moment | ||
78 | "Mode de paiement:" => $this->mode_paiement, // non pertinent pour un devis | ||
79 | "Commentaires:" => $this->commentaires]; | ||
80 | } | ||
81 | |||
82 | // setters | ||
83 | //~ public function setCodePresta(string $value) | ||
84 | //~ { | ||
85 | //~ $this->code_presta = $value; | ||
86 | //~ return $this; | ||
87 | //~ } | ||
88 | //public function setDate(int $value) | ||
89 | public function setDate(Dates $Date) | ||
90 | { | ||
91 | //$this->date = (int)$value; // attend un timestamp | ||
92 | $this->date = $Date->getTimestamp(); | ||
93 | return $this; | ||
94 | /*if($set_code_presta) | ||
95 | { | ||
96 | $code_presta_tableau = explode('-', $this->code_presta); | ||
97 | $Date = new Dates($value); | ||
98 | $code_presta_tableau[0] = $Date->getYear(); | ||
99 | $code_presta_tableau[1] = $Date->getMonth(); | ||
100 | $code_presta_tableau[2] = $Date->getDay(); | ||
101 | $this->code_presta = implode('-', $code_presta_tableau); | ||
102 | }*/ | ||
103 | } | ||
104 | |||
105 | public function setTypePresta(string $value) // appelée dans la section 2 uniquement, pour la 3 on verra plus tard | ||
106 | { | ||
107 | $this->type_presta = $value; | ||
108 | return $this; | ||
109 | } | ||
110 | public function setModePaiement(string $value) | ||
111 | { | ||
112 | $this->mode_paiement = $value; | ||
113 | return $this; | ||
114 | } | ||
115 | public function setCommentaires(string $input) | ||
116 | { | ||
117 | $this->commentaires = $input; | ||
118 | } | ||
119 | /*public function setAll(array $input) | ||
120 | { | ||
121 | $this->code_presta = $input[0]; | ||
122 | $this->date = $input[1]; | ||
123 | $this->type_presta = $input[2]; | ||
124 | $this->mode_paiement = $input[3]; | ||
125 | $this->commentaires = $input[4]; | ||
126 | }*/ | ||
127 | |||
128 | private function setClient(Client $input) // private? | ||
129 | { | ||
130 | $this->client = $input; | ||
131 | //$input->typeToClient(); // on modifie $client ici (merci les références PHP) | ||
132 | } | ||
133 | |||
134 | public function set(string $entry, $input) // $input = chaîne ou entier | ||
135 | { | ||
136 | if(gettype($input) === 'string') | ||
137 | { | ||
138 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide | ||
139 | } | ||
140 | switch($entry) | ||
141 | { | ||
142 | // pas de cas "code presta" qui généré par setCodePresta, on peut modifier la date (ici) et le code client (ailleurs) | ||
143 | //~ case "Numéro prestation:": | ||
144 | //~ $this->setNumeroPresta($input); | ||
145 | //~ // modifier le code presta en conséquence | ||
146 | //~ break; | ||
147 | case "Date:": // inutile, setDate() est appelé directement après choix fenêtre calendrier | ||
148 | $this->setDate($input); | ||
149 | break; | ||
150 | //~ case "Type de Presta:": // choix impossible pour le moment | ||
151 | //~ $this->setTypePresta($input); | ||
152 | //~ break; | ||
153 | case "Mode de paiement:": | ||
154 | $this->setModePaiement($input); | ||
155 | break; | ||
156 | case "Commentaires:": | ||
157 | $this->setCommentaires($input); | ||
158 | break; | ||
159 | } | ||
160 | } | ||
161 | |||
162 | // code presta = année-mois-jour-codeclient-typedepresta-combientièmefois | ||
163 | public function setCodePresta(int $increment) // 0 pour modif, 1 pour nouvelle presta | ||
164 | { | ||
165 | $Date = new Dates($this->date); | ||
166 | $repository = self::$entityManager->getRepository('Prestation'); // prestas de tout type d'un client | ||
167 | // attention: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer | ||
168 | $combientieme_fois = count($repository->findBy(['client' => $this->client->getId()])) + $increment; | ||
169 | //var_dump($combientieme_fois); | ||
170 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $this->client->getCodeClient(), $this->type_presta, $combientieme_fois]; | ||
171 | //~ $array_code[0] = $Date->getYear(); | ||
172 | //~ $array_code[1] = $Date->getMonth(); | ||
173 | //~ $array_code[2] = $Date->getDay(); | ||
174 | //~ $array_code[3] = $this->client->getCodeClient(); // mise à jour éventuelle | ||
175 | //~ $array_code[4] = $this->type_presta; | ||
176 | $this->code_presta = implode('-', $array_code); | ||
177 | return $this; | ||
178 | } | ||
179 | // combientième fois au choix (ne fonctionne pas avec setCodePresta qui recalculera ce numéro automatiquement à la prochaine modification) | ||
180 | //~ public function setNumeroPresta($value) | ||
181 | //~ { | ||
182 | //~ // modifier le code presta, on pourrait aussi utiliser une regex | ||
183 | //~ $code_presta_tableau = explode('-', $this->code_presta); | ||
184 | //~ $code_presta_tableau[count($code_presta_tableau) - 1] = (int) $value; // dernière case du tableau | ||
185 | //~ $this->code_presta = implode('-', $code_presta_tableau); | ||
186 | //~ return $this; | ||
187 | //~ } | ||
188 | |||
189 | public static function getServices(Client $Customer, string $type = '') | ||
190 | { | ||
191 | echo "debug: recherche d'une prestation\n"; | ||
192 | |||
193 | // requête DQL qui fait la même chose que le findBy plus bas | ||
194 | /*$query = self::$entityManager->createQuery('SELECT u FROM Prestation u WHERE u.client = :id_client AND u.type_presta = :type_presta'); | ||
195 | $query->setParameter('id_client', $Customer->getId()); | ||
196 | $query->setParameter('type_presta', $type); | ||
197 | $query_result = $query->getResult(); | ||
198 | var_dump($query_result);die;*/ | ||
199 | |||
200 | $repository = self::$entityManager->getRepository('Prestation'); | ||
201 | $find_by = ['client' => $Customer->getId()]; | ||
202 | if($type != '') | ||
203 | { | ||
204 | $find_by['type_presta'] = 'devis'; | ||
205 | } | ||
206 | $PrestaList = $repository->findBy($find_by); | ||
207 | |||
208 | // le même tableau avec pour clés les id des objets | ||
209 | $PrestaListIdKeys = []; | ||
210 | foreach($PrestaList as $Presta) | ||
211 | { | ||
212 | $id = $Presta->getId(); | ||
213 | $PrestaListIdKeys[$id] = $Presta; | ||
214 | } | ||
215 | |||
216 | // fenêtre | ||
217 | $entrees = []; | ||
218 | foreach($PrestaListIdKeys as $Presta) | ||
219 | { | ||
220 | $id = $Presta->getId(); | ||
221 | $entrees[$id][] = $id; | ||
222 | $Date = new Dates((int)$Presta->getDate()); // envoi du timestamp, (int) est là par sécurité | ||
223 | $entrees[$id][] = $Date->getDate(); | ||
224 | $entrees[$id][] = $Presta->getTypePresta(); | ||
225 | $entrees[$id][] = $Presta->getCodePresta(); | ||
226 | } | ||
227 | |||
228 | // pas à la bonne place, couper la fonction en deux et mettre ça ailleurs! | ||
229 | $ResultatsRecherchePresta = new ZenityList(ZenitySetup::$resultats_recherche_presta['text'], []); | ||
230 | $ResultatsRecherchePresta->setListRows($entrees, 4); | ||
231 | |||
232 | // choix de l'utilisateur | ||
233 | $input = exec($ResultatsRecherchePresta->get()); // $input est l'ID de la prestation | ||
234 | //echo "input = " . $input . "\n"; | ||
235 | if($input == '') | ||
236 | { | ||
237 | echo "debug: recherche annulée ou saisie vide\n"; | ||
238 | return 0; | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | return $PrestaListIdKeys[$input]; | ||
243 | } | ||
244 | } | ||
245 | |||
246 | // à mettre plus tard dans une classe mère | ||
247 | private function cleanSpecialChars(string $data): string | ||
248 | { | ||
249 | $search = ['"']; | ||
250 | return str_replace($search, '', $data); | ||
251 | } | ||
252 | } | ||
diff --git a/src/model/CESU.php b/src/model/version 0.1/CESU.php index 2768b8f..2768b8f 100644 --- a/src/model/CESU.php +++ b/src/model/version 0.1/CESU.php | |||
diff --git a/src/model/Clients.php b/src/model/version 0.1/Clients.php index 32cf0c5..32cf0c5 100644 --- a/src/model/Clients.php +++ b/src/model/version 0.1/Clients.php | |||
diff --git a/src/model/DB.php b/src/model/version 0.1/DB.php index 47407ba..47407ba 100644 --- a/src/model/DB.php +++ b/src/model/version 0.1/DB.php | |||
diff --git a/src/model/DevisFactures.php b/src/model/version 0.1/DevisFactures.php index 06a0a59..06a0a59 100644 --- a/src/model/DevisFactures.php +++ b/src/model/version 0.1/DevisFactures.php | |||
diff --git a/src/model/Locations.php b/src/model/version 0.1/Locations.php index c6b8deb..c6b8deb 100644 --- a/src/model/Locations.php +++ b/src/model/version 0.1/Locations.php | |||
diff --git a/src/model/Model.php b/src/model/version 0.1/Model.php index b3d157d..b3d157d 100644 --- a/src/model/Model.php +++ b/src/model/version 0.1/Model.php | |||
diff --git a/src/model/Prestations.php b/src/model/version 0.1/Prestations.php index 3a415be..18bc787 100644 --- a/src/model/Prestations.php +++ b/src/model/version 0.1/Prestations.php | |||
@@ -14,8 +14,7 @@ class Prestations extends Model | |||
14 | //protected $numero_presta = 0; | 14 | //protected $numero_presta = 0; |
15 | 15 | ||
16 | public function __construct(int $id_client) | 16 | public function __construct(int $id_client) |
17 | { | 17 | { $this->id_client = $id_client; |
18 | $this->id_client = $id_client; | ||
19 | $this->table = strtolower(__CLASS__); // prestations | 18 | $this->table = strtolower(__CLASS__); // prestations |
20 | } | 19 | } |
21 | 20 | ||
@@ -30,19 +29,19 @@ class Prestations extends Model | |||
30 | } | 29 | } |
31 | public function getIdsByIdClient() // obtenir une entrée avec son id_client, comportement différent si le type est connu | 30 | public function getIdsByIdClient() // obtenir une entrée avec son id_client, comportement différent si le type est connu |
32 | { | 31 | { |
33 | $sql = 'SELECT id FROM ' . $this->table . ' WHERE id_client = ' . $this->id_client; | 32 | $sql = 'SELECT id FROM ' . $this->table . ' WHERE id_client = ' . $this->id_client; |
34 | if($this->type_presta != '') | 33 | if($this->type_presta != '') |
35 | { | 34 | { |
36 | $sql .= " AND type_presta = '" . $this->type_presta . "'"; | 35 | $sql .= " AND type_presta = '" . $this->type_presta . "'"; |
37 | } | 36 | } |
38 | $data = $this->execQuery($sql)->fetchAll(); // tableau de tableaux | 37 | $data = $this->execQuery($sql)->fetchAll(); // tableau de tableaux |
39 | 38 | ||
40 | $IDs = []; // si $IDs reste vide, ne pas être de type NULL | 39 | $IDs = []; // si $IDs reste vide, ne pas être de type NULL |
41 | for($i = 0; $i < count($data); $i++) | 40 | for($i = 0; $i < count($data); $i++) |
42 | { | 41 | { |
43 | $IDs[$i] = $data[$i]['id']; // tableau simple | 42 | $IDs[$i] = $data[$i]['id']; // tableau simple |
44 | } | 43 | } |
45 | return($IDs); | 44 | return($IDs); |
46 | } | 45 | } |
47 | public function getCodePresta(): string | 46 | public function getCodePresta(): string |
48 | { | 47 | { |
@@ -58,8 +57,8 @@ class Prestations extends Model | |||
58 | } | 57 | } |
59 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) | 58 | public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) |
60 | { | 59 | { |
61 | $code_presta_tableau = explode('-', $this->code_presta); | 60 | $code_presta_tableau = explode('-', $this->code_presta); |
62 | $Date = new Dates($this->date); | 61 | $Date = new Dates($this->date); |
63 | 62 | ||
64 | return [ | 63 | return [ |
65 | "Numéro prestation:" => end($code_presta_tableau), // dernière case | 64 | "Numéro prestation:" => end($code_presta_tableau), // dernière case |
@@ -71,7 +70,7 @@ class Prestations extends Model | |||
71 | public function set(string $entry, string $input) | 70 | public function set(string $entry, string $input) |
72 | { | 71 | { |
73 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide | 72 | $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide |
74 | switch($entry) | 73 | switch($entry) |
75 | { | 74 | { |
76 | case "Numéro prestation:": | 75 | case "Numéro prestation:": |
77 | $this->setNumeroPresta($input); | 76 | $this->setNumeroPresta($input); |
@@ -94,8 +93,8 @@ class Prestations extends Model | |||
94 | // setters | 93 | // setters |
95 | public function setIdClient(int $value) | 94 | public function setIdClient(int $value) |
96 | { | 95 | { |
97 | $this->id_client = $value; | 96 | $this->id_client = $value; |
98 | return $this; | 97 | return $this; |
99 | } | 98 | } |
100 | //~ public function setCombientiemeFois(int $value) | 99 | //~ public function setCombientiemeFois(int $value) |
101 | //~ { | 100 | //~ { |
@@ -104,62 +103,57 @@ class Prestations extends Model | |||
104 | //~ } | 103 | //~ } |
105 | public function setCodePresta(string $value) | 104 | public function setCodePresta(string $value) |
106 | { | 105 | { |
107 | $this->code_presta = $value; | 106 | $this->code_presta = $value; |
108 | return $this; | 107 | return $this; |
109 | } | 108 | } |
110 | public function setDate($value, bool $set_code_presta = false) // attend un timestamp | 109 | public function setDate($value, bool $set_code_presta = false) // attend un timestamp |
111 | { | 110 | { |
112 | $this->date = (int) $value; | 111 | $this->date = (int) $value; |
113 | 112 | ||
114 | if($set_code_presta) | 113 | if($set_code_presta) |
115 | { | 114 | { |
116 | $code_presta_tableau = explode('-', $this->code_presta); | 115 | $code_presta_tableau = explode('-', $this->code_presta); |
117 | $Date = new Dates($value); | 116 | $Date = new Dates($value); |
118 | $code_presta_tableau[0] = $Date->getYear(); | 117 | $code_presta_tableau[0] = $Date->getYear(); |
119 | $code_presta_tableau[1] = $Date->getMonth(); | 118 | $code_presta_tableau[1] = $Date->getMonth(); |
120 | $code_presta_tableau[2] = $Date->getDay(); | 119 | $code_presta_tableau[2] = $Date->getDay(); |
121 | $this->code_presta = implode('-', $code_presta_tableau); | 120 | $this->code_presta = implode('-', $code_presta_tableau); |
122 | } | 121 | } |
123 | 122 | ||
124 | return $this; | 123 | return $this; |
125 | } | 124 | } |
126 | public function setTypePresta(string $value) | 125 | public function setTypePresta(string $value) |
127 | { | 126 | { |
128 | $this->type_presta = $value; | 127 | $this->type_presta = $value; |
129 | return $this; | 128 | return $this; |
130 | } | 129 | } |
131 | public function setModePaiement(string $value) | 130 | public function setModePaiement(string $value) |
132 | { | 131 | { |
133 | $this->mode_paiement = $value; | 132 | $this->mode_paiement = $value; |
134 | return $this; | 133 | return $this; |
135 | } | 134 | } |
136 | public function setCommentaires(string $value) | 135 | public function setCommentaires(string $value) |
137 | { | 136 | { |
138 | $this->commentaires = $this->cleanSpecialChars($value); // nettoyage ici parce que pas possible ailleurs | 137 | $this->commentaires = $this->cleanSpecialChars($value); // nettoyage ici parce que pas possible ailleurs |
139 | return $this; | 138 | return $this; |
140 | } | 139 | } |
141 | public function setNumeroPresta($value) | 140 | public function setNumeroPresta($value) |
142 | { | 141 | { |
143 | // modifier le code presta, on pourrait aussi utiliser une regex | 142 | // modifier le code presta, on pourrait aussi utiliser une regex |
144 | $code_presta_tableau = explode('-', $this->code_presta); | 143 | $code_presta_tableau = explode('-', $this->code_presta); |
145 | $code_presta_tableau[count($code_presta_tableau) - 1] = (int) $value; | 144 | $code_presta_tableau[count($code_presta_tableau) - 1] = (int) $value; |
146 | $this->code_presta = implode('-', $code_presta_tableau); | 145 | $this->code_presta = implode('-', $code_presta_tableau); |
147 | return $this; | 146 | return $this; |
148 | } | 147 | } |
149 | 148 | ||
150 | // code client = année-mois-jour-codeclient-typedepresta-combientièmefois | 149 | // code presta = année-mois-jour-codeclient-typedepresta-combientièmefois |
151 | public function makeCodePresta(Dates $Date, string $code_client) | 150 | public function makeCodePresta(Dates $Date, string $code_client) |
152 | { | 151 | { |
153 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) | 152 | // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) |
154 | // inconvénient: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer | 153 | // inconvénient: il peut y avoir plusieurs prestations avec le même numéro au compteur, à améliorer |
155 | $combientieme_fois = count($this->find(['id_client' => $this->id_client])) + 1; | 154 | $combientieme_fois = count($this->find(['id_client' => $this->id_client])) + 1; |
156 | 155 | ||
157 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->type_presta, $combientieme_fois]; | 156 | $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->type_presta, $combientieme_fois]; |
158 | $this->code_presta = implode('-', $array_code); | 157 | $this->code_presta = implode('-', $array_code); |
159 | } | 158 | } |
160 | } | 159 | } |
161 | |||
162 | //~ class CodePresta extends Prestations | ||
163 | //~ { | ||
164 | //~ protected $numero_presta; | ||
165 | //~ } | ||
diff --git a/src/model/StructTablesDB.php b/src/model/version 0.1/StructTablesDB.php index 303af46..303af46 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/version 0.1/StructTablesDB.php | |||
diff --git a/src/sections/1_customer.php b/src/sections/1_customer.php index b0e3283..db5c448 100644 --- a/src/sections/1_customer.php +++ b/src/sections/1_customer.php | |||
@@ -3,42 +3,46 @@ | |||
3 | // | 3 | // |
4 | // -- SECTION 1: Fichier clients et propects -- | 4 | // -- SECTION 1: Fichier clients et propects -- |
5 | 5 | ||
6 | use Doctrine\ORM\EntityManager; | ||
7 | |||
6 | function newCustomer(): array | 8 | function newCustomer(): array |
7 | { | 9 | { |
8 | // fenêtres | 10 | // fenêtres |
9 | $TypeDeClient = new ZenityList(ZenitySetup::$type_client['text'], ZenitySetup::$type_client['entrees']); | 11 | //$TypeDeClient = new ZenityList(ZenitySetup::$type_client['text'], ZenitySetup::$type_client['entrees']); |
12 | $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client['text'], ZenitySetup::$nouveau_client['entrees']); | ||
10 | $FinSection1 = new ZenityList(ZenitySetup::$fin_section_1['text'], ZenitySetup::$fin_section_1['entrees']); | 13 | $FinSection1 = new ZenityList(ZenitySetup::$fin_section_1['text'], ZenitySetup::$fin_section_1['entrees']); |
11 | 14 | ||
15 | $Customer = new Client; | ||
16 | |||
12 | // -- partie 1: client ou prospect? -- | 17 | // -- partie 1: client ou prospect? -- |
13 | $Client = new Clients; | 18 | //~ $choix_niv2 = exec($TypeDeClient->get()); |
14 | $choix_niv2 = exec($TypeDeClient->get()); | 19 | //~ if($choix_niv2 === ZenitySetup::$type_client['entrees'][0]) |
15 | if($choix_niv2 === ZenitySetup::$type_client['entrees'][0]) | 20 | //~ { |
16 | { | 21 | //~ echo "choix: " . $choix_niv2 . "\n"; |
17 | echo "choix: " . $choix_niv2 . "\n"; | 22 | //~ $Customer->setType('client'); |
18 | $Client->setType('client'); | 23 | //~ } |
19 | } | 24 | //~ elseif($choix_niv2 === ZenitySetup::$type_client['entrees'][1]) |
20 | elseif($choix_niv2 === ZenitySetup::$type_client['entrees'][1]) | 25 | //~ { |
21 | { | 26 | //~ echo "choix: " . $choix_niv2 . "\n"; |
22 | echo "choix: " . $choix_niv2 . "\n"; | 27 | //~ $Customer->setType('prospect'); |
23 | $Client->setType('prospect'); | 28 | //~ } |
24 | } | 29 | //~ else |
25 | else | 30 | //~ { |
26 | { | 31 | //~ return [0, null]; // menu principal |
27 | return [0, null]; // menu principal | 32 | //~ } |
28 | } | ||
29 | 33 | ||
30 | // -- partie 2: saisie des infos -- | 34 | // -- partie 2: saisie des infos -- |
31 | if(enterCustomer($Client)) | 35 | if($Customer->enterCustomer($NouveauClient)) |
32 | { | 36 | { |
33 | // -- partie 3: on fait quoi maintenant -- | 37 | // -- partie 3: on fait quoi maintenant -- |
34 | $choix_niv3 = exec($FinSection1->get()); | 38 | $choix_niv3 = exec($FinSection1->get()); |
35 | if($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][0]) | 39 | if($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][0]) |
36 | { | 40 | { |
37 | return [2, $Client]; // section 2: newService() | 41 | return [2, $Customer]; // section 2: newService() |
38 | } | 42 | } |
39 | elseif($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][1]) | 43 | elseif($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][1]) |
40 | { | 44 | { |
41 | return [3, $Client]; // section 3: modifyData() | 45 | return [3, $Customer]; // section 3: modifyData() |
42 | } | 46 | } |
43 | elseif($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][2]) | 47 | elseif($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][2]) |
44 | { | 48 | { |
diff --git a/src/sections/2_service.php b/src/sections/2_service.php index 3dd620d..e25d677 100644 --- a/src/sections/2_service.php +++ b/src/sections/2_service.php | |||
@@ -3,26 +3,33 @@ | |||
3 | // | 3 | // |
4 | // -- SECTION 2: Prestation et devis -- | 4 | // -- SECTION 2: Prestation et devis -- |
5 | 5 | ||
6 | use Doctrine\ORM\EntityManager; | ||
7 | |||
6 | function newService($Client): array // $Client est un Client ou null | 8 | function newService($Client): array // $Client est un Client ou null |
7 | { | 9 | { |
10 | // fenêtres recherche d'un client | ||
11 | $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client['text']); | ||
12 | $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client['text'], []); | ||
13 | |||
8 | // fenêtres | 14 | // fenêtres |
9 | $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement_text, ZenitySetup::$menu_enregistrement_entrees); | 15 | $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement['text'], ZenitySetup::$menu_enregistrement['entrees']); |
10 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section2']); | 16 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section2']); |
11 | $FormulaireDevis = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['devis_entrees']); | 17 | $FormulaireDevis = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['devis_entrees']); |
12 | $FormulaireFacture = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['facture_entrees']); | 18 | $FormulaireFacture = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['facture_entrees']); |
13 | $FormulaireFactureReduit = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['facture_entrees_reduit']); | 19 | $FormulaireFactureReduit = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['facture_entrees_reduit']); |
14 | $FormulaireCesu = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['cesu_entrees']); | 20 | $FormulaireCesu = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['cesu_entrees']); |
15 | $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['location_entrees']); | 21 | $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['location_entrees']); |
16 | $CommentairePrestation = new ZenityEntry(ZenitySetup::$commentaire_prestation_text); | 22 | $CommentairePrestation = new ZenityEntry(ZenitySetup::$commentaire_prestation['text']); |
17 | //$Recapitulatif = new ZenityList(ZenitySetup::$recapitulatif_text, ZenitySetup::$recapitulatif_entrees); // tableau à multiples colonnes | 23 | //$Recapitulatif = new ZenityList(ZenitySetup::$recapitulatif_text, ZenitySetup::$recapitulatif_entrees); // tableau à multiples colonnes |
18 | $FinSection2 = new ZenityList(ZenitySetup::$fin_section_2['text'], ZenitySetup::$fin_section_2['entrees']); | 24 | $FinSection2 = new ZenityList(ZenitySetup::$fin_section_2['text'], ZenitySetup::$fin_section_2['entrees']); |
19 | 25 | ||
20 | 26 | ||
21 | // -- partie 1: le client -- | 27 | // -- partie 1: le client -- |
22 | if($Client == null || get_class($Client) !== 'Clients') | 28 | if($Client == null || get_class($Client) !== 'Client') |
23 | { | 29 | { |
24 | $Client = makeObjectClient(); // retourne 0 ou un objet "Clients" | 30 | $Client = Client::getObject($RechercheClient, $ResultatsRechercheClient); // retourne un Client ou 0 |
25 | if($Client == 0) | 31 | //$ResultatsRechercheClient->cleanCommand(); // inutile parce qu'on ne boucle pas dans cette fonction |
32 | if($Client === 0) | ||
26 | { | 33 | { |
27 | echo "debug: annulation sélection client\n"; | 34 | echo "debug: annulation sélection client\n"; |
28 | return [0, null]; // menu principal | 35 | return [0, null]; // menu principal |
@@ -48,49 +55,50 @@ function newService($Client): array // $Client est un Client ou null | |||
48 | return [0, null]; // menu principal | 55 | return [0, null]; // menu principal |
49 | } | 56 | } |
50 | 57 | ||
51 | $Presta = new Prestations($Client->getId()); | 58 | $Presta = new Prestation($Client); |
52 | $Presta->setDate($Date->getTimestamp()); // un entier pour la BDD | 59 | //var_dump($Client);die; |
60 | //$Presta->setDate($Date->getTimestamp()); | ||
61 | $Presta->setDate($Date); // envoi d'un objet, la BDD gardera le timestamp | ||
53 | 62 | ||
54 | // formulaire - étape 2/3 | 63 | // formulaire - étape 2/3 |
55 | switch($choix_niv2) | 64 | switch($choix_niv2) |
56 | { | 65 | { |
57 | // comparaison retour de $MenuEnregistrement->get() avec les noms des entrées du même menu | 66 | // comparaison retour de $MenuEnregistrement->get() avec les noms des entrées du même menu |
58 | case ZenitySetup::$menu_enregistrement_entrees[0]: // "Devis" | 67 | case ZenitySetup::$menu_enregistrement['entrees'][0]: // "Devis" |
59 | $PrestaDetails = new DevisFactures('devis'); | 68 | $PrestaDetails = new Devis($Presta); |
60 | $Presta->setTypePresta('devis'); | 69 | $Presta->setTypePresta('devis'); |
61 | $answers = exec($FormulaireDevis->get()); | 70 | $answers = exec($FormulaireDevis->get()); |
62 | break; | 71 | break; |
63 | case ZenitySetup::$menu_enregistrement_entrees[1]: // "Facture" | 72 | case ZenitySetup::$menu_enregistrement['entrees'][1]: // "Facture" |
64 | $PrestaDetails = new DevisFactures('factures'); // attention! type "facture" mais table "factures" | 73 | $PrestaDetails = new Facture($Presta); |
65 | $Presta->setTypePresta('facture'); | 74 | $Presta->setTypePresta('facture'); |
66 | $answers = exec($FormulaireFacture->get()); | 75 | $answers = exec($FormulaireFacture->get()); |
67 | break; | 76 | break; |
68 | case ZenitySetup::$menu_enregistrement_entrees[2]: // "Facture à partir d'un devis" | 77 | case ZenitySetup::$menu_enregistrement['entrees'][2]: // "Facture à partir d'un devis" |
69 | // recherche du devis | 78 | // recherche du devis |
70 | $Quotation = getServices($Client, 'devis'); // rechercher un devis, type 'devis' spécifié pour $Presta->getIdsByIdClient() | 79 | $Quotation = Prestation::getServices($Client, 'devis'); // rechercher un devis, type 'devis' spécifié |
71 | if(!is_object($Quotation) || get_class($Quotation) != 'Prestations' || $Quotation->getTypePresta() != 'devis') | 80 | if(!is_object($Quotation) || get_class($Quotation) != 'Prestation' || $Quotation->getTypePresta() != 'devis') |
72 | { | 81 | { |
73 | echo "debug: annulation sélection client\n"; | 82 | echo "debug: annulation sélection client\n"; |
74 | return [2, $Client]; // menu précédent | 83 | return [2, $Client]; // menu précédent |
75 | } | 84 | } |
76 | $QuotationDetails = new DevisFactures('devis'); | 85 | $QuotationDetails = Devis::getQuotation($Quotation); |
77 | // facture: objet vide et formulaire | 86 | $PrestaDetails = new Facture($Presta); |
78 | $PrestaDetails = new DevisFactures('factures'); | 87 | $PrestaDetails->hydrateWithQuotation($QuotationDetails); // du devis à la facture |
79 | $Presta->setTypePresta('facture'); | 88 | $Presta->setTypePresta('facture'); |
80 | $answers = exec($FormulaireFactureReduit->get()); | 89 | $answers = exec($FormulaireFactureReduit->get()); |
81 | //var_dump($answers); | ||
82 | break; | 90 | break; |
83 | case ZenitySetup::$menu_enregistrement_entrees[3]: // "CESU" | 91 | case ZenitySetup::$menu_enregistrement['entrees'][3]: // "CESU" |
84 | $PrestaDetails = new CESU(); | 92 | $PrestaDetails = new CESU($Presta); |
85 | $Presta->setTypePresta('cesu'); | 93 | $Presta->setTypePresta('cesu'); |
86 | $answers = exec($FormulaireCesu->get()); | 94 | $answers = exec($FormulaireCesu->get()); |
87 | break; | 95 | break; |
88 | case ZenitySetup::$menu_enregistrement_entrees[4]: // "Location" | 96 | case ZenitySetup::$menu_enregistrement['entrees'][4]: // "Location" |
89 | $PrestaDetails = new Locations(); | 97 | $PrestaDetails = new Location($Presta); |
90 | $Presta->setTypePresta('location'); | 98 | $Presta->setTypePresta('location'); |
91 | $answers = exec($FormulaireLocation->get()); | 99 | $answers = exec($FormulaireLocation->get()); |
92 | break; | 100 | break; |
93 | case ZenitySetup::$menu_enregistrement_entrees[5]: // "Prestation non vendue" | 101 | case ZenitySetup::$menu_enregistrement['entrees'][5]: // "Prestation non vendue" |
94 | $Presta->setTypePresta('non_vendue'); | 102 | $Presta->setTypePresta('non_vendue'); |
95 | break; | 103 | break; |
96 | default: // inutile normallement, cas déjà géré avant | 104 | default: // inutile normallement, cas déjà géré avant |
@@ -98,7 +106,9 @@ function newService($Client): array // $Client est un Client ou null | |||
98 | return [0, null]; | 106 | return [0, null]; |
99 | } | 107 | } |
100 | 108 | ||
101 | $Presta->makeCodePresta($Date, $Client->getCodeClient()); // d'un objet à l'autre | 109 | //$Presta->makeCodePresta($Date, $Client->getCodeClient()); // d'un objet à l'autre |
110 | //$Presta->makeCodePresta($Client->getCodeClient()); // d'un objet à l'autre | ||
111 | $Presta->setCodePresta(1); // d'un objet à l'autre | ||
102 | 112 | ||
103 | // commentaire - étape 3/3 | 113 | // commentaire - étape 3/3 |
104 | $comment = exec($CommentairePrestation->get()); | 114 | $comment = exec($CommentairePrestation->get()); |
@@ -120,48 +130,27 @@ function newService($Client): array // $Client est un Client ou null | |||
120 | //~ } | 130 | //~ } |
121 | $Presta->setCommentaires($comment); | 131 | $Presta->setCommentaires($comment); |
122 | 132 | ||
123 | // hydratation d'une facture à partir d'un devis | ||
124 | if($choix_niv2 === ZenitySetup::$menu_enregistrement_entrees[2]) // cas: facture à partir d'un devis | ||
125 | { | ||
126 | // devis retrouvé ($Quotation est déjà hydraté) | ||
127 | $QuotationDetails->setIdPresta($Quotation->getId()); | ||
128 | $QuotationDetails->hydrate($QuotationDetails->getDetailsByIdPresta()); | ||
129 | |||
130 | // facture avec le devis | ||
131 | $QuotationDetails->hydrateReceiptWithQuotation($PrestaDetails); | ||
132 | } | ||
133 | |||
134 | // hydratation avec la saisie du formulaire | 133 | // hydratation avec la saisie du formulaire |
135 | if($choix_niv2 != ZenitySetup::$menu_enregistrement_entrees[5]) // cas: tous les cas sauf presta non vendue | 134 | if($choix_niv2 != ZenitySetup::$menu_enregistrement['entrees'][5]) // cas: tous les cas sauf presta non vendue |
136 | { | 135 | { |
136 | //var_dump($answers); | ||
137 | $Client->typeToClient(); | ||
137 | if($answers == '') // annulation | 138 | if($answers == '') // annulation |
138 | { | 139 | { |
139 | 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"; |
140 | return [0, null]; | 141 | return [0, null]; |
141 | } | 142 | } |
142 | elseif(isset($PrestaDetails) && !$PrestaDetails->hydrateFromForm($answers, $Presta)) // echec de l'hydratation | 143 | $PrestaDetails->hydrate($answers); |
143 | { | 144 | |
144 | echo "debug: erreur de hydrateFromForm()\n"; // messages d'erreur à mettre ici ou dans hydrateFromForm()? | 145 | // déléguer la synchronisation (flush) avec la BDD à une classe "Manager" |
145 | return [0, null]; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | // mise à jour base de données | ||
150 | $Presta->create(); | ||
151 | $Presta->setId(); // sans paramètre, exécute un $this->db->lastInsertId() | ||
152 | |||
153 | if(isset($PrestaDetails)) // presta vendue | ||
154 | { | ||
155 | $PrestaDetails->setIdPresta($Presta->getId()); // d'un objet à l'autre | ||
156 | $PrestaDetails->create(); | ||
157 | $PrestaDetails->setId(); // sans paramètre, exécute un $this->db->lastInsertId() | ||
158 | } | 146 | } |
159 | 147 | ||
160 | // si encore de type prospect, devient un type client | 148 | // si encore de type prospect, devient un type client |
161 | if($Client->typeToClient()) // utile si $Client est renvoyé dans le "return" | 149 | // déjà fait ailleurs je crois! |
150 | /*if($Client->typeToClient()) // utile si $Client est renvoyé dans le "return" | ||
162 | { | 151 | { |
163 | $Client->updateOneValue('type', 'client'); // base synchronisée | 152 | $Client->updateOneValue('type', 'client'); // base synchronisée |
164 | } | 153 | }*/ |
165 | 154 | ||
166 | 155 | ||
167 | // -- partie 3: LaTeX -- | 156 | // -- partie 3: LaTeX -- |
@@ -213,7 +202,11 @@ function newService($Client): array // $Client est un Client ou null | |||
213 | { | 202 | { |
214 | return [3, $Client]; // section 3: modifyData() | 203 | return [3, $Client]; // section 3: modifyData() |
215 | } | 204 | } |
216 | elseif($choix_niv2 === ZenitySetup::$fin_section_2['entrees'][2]) // enregistrer une autre prestation | 205 | elseif($choix_niv2 === ZenitySetup::$fin_section_2['entrees'][2]) // enregistrer une autre prestation (même client) |
206 | { | ||
207 | return [2, $Client]; // relancer section 2: newService() | ||
208 | } | ||
209 | elseif($choix_niv2 === ZenitySetup::$fin_section_2['entrees'][3]) // enregistrer une autre prestation (autre client) | ||
217 | { | 210 | { |
218 | return [2, null]; // relancer section 2: newService() | 211 | return [2, null]; // relancer section 2: newService() |
219 | } | 212 | } |
diff --git a/src/sections/3-1_windows.php b/src/sections/3-1_windows.php index 31c6cee..76d01dd 100644 --- a/src/sections/3-1_windows.php +++ b/src/sections/3-1_windows.php | |||
@@ -1,9 +1,9 @@ | |||
1 | <?php | 1 | <?php |
2 | // src/sections/3-1_windows.php | 2 | // src/sections/3-1_windows.php |
3 | // | 3 | // |
4 | // fonctions pour 3_modify_data.php | 4 | // fonctions pour src/sections/3_modify_data.php |
5 | 5 | ||
6 | function makeModifyCustomerWindow(Clients $Customer): ZenityList | 6 | function makeModifyCustomerWindow(Client $Customer): ZenityList |
7 | { | 7 | { |
8 | // fenêtre | 8 | // fenêtre |
9 | $ModifyCustomer = new ZenityList(ZenitySetup::$modification_client['text'], []); | 9 | $ModifyCustomer = new ZenityList(ZenitySetup::$modification_client['text'], []); |
@@ -27,7 +27,7 @@ function makeModifyCustomerWindow(Clients $Customer): ZenityList | |||
27 | return $ModifyCustomer; | 27 | return $ModifyCustomer; |
28 | } | 28 | } |
29 | 29 | ||
30 | function makeModifyServiceWindow(Prestations $Service, $ServiceDetails = null): ZenityList | 30 | function makeModifyServiceWindow(Prestation $Service, $ServiceDetails = null): ZenityList |
31 | { | 31 | { |
32 | // fenêtre | 32 | // fenêtre |
33 | $ModifyService = new ZenityList(ZenitySetup::$modification_presta['text'], []); | 33 | $ModifyService = new ZenityList(ZenitySetup::$modification_presta['text'], []); |
diff --git a/src/sections/3_modify_data.php b/src/sections/3_modify_data.php index c2f683a..00fe220 100644 --- a/src/sections/3_modify_data.php +++ b/src/sections/3_modify_data.php | |||
@@ -5,18 +5,26 @@ | |||
5 | 5 | ||
6 | require('3-1_windows.php'); | 6 | require('3-1_windows.php'); |
7 | 7 | ||
8 | use Doctrine\ORM\EntityManager; | ||
9 | |||
8 | function modifyData($Client): array | 10 | function modifyData($Client): array |
9 | { | 11 | { |
10 | // fenêtres fixes | 12 | // -- partie 1: rechercher un client -- |
13 | |||
14 | // fenêtres statiques | ||
15 | // recherche d'un client | ||
16 | $RechercheClient = new zenityEntry(ZenitySetup::$recherche_client['text']); | ||
17 | $ResultatsRechercheClient = new ZenityList(ZenitySetup::$resultats_recherche_client['text'], []); | ||
18 | // modification de données | ||
11 | $TypeDeClient = new ZenityList(ZenitySetup::$type_client['text'], ZenitySetup::$type_client['entrees']); | 19 | $TypeDeClient = new ZenityList(ZenitySetup::$type_client['text'], ZenitySetup::$type_client['entrees']); |
12 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section3']); | 20 | $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section3']); |
13 | 21 | ||
14 | 22 | if($Client == null || get_class($Client) !== 'Client') // étape sautable | |
15 | // -- partie 1: rechercher un client -- | ||
16 | if($Client == null || get_class($Client) !== 'Clients') // étape sautable | ||
17 | { | 23 | { |
18 | $Client = makeObjectClient(); // = 0 ou type "Clients" | 24 | $Client = Client::getObject($RechercheClient, $ResultatsRechercheClient); // = 0 ou type "Client" |
19 | if(!is_object($Client) || !get_class($Client) == 'Clients') | 25 | //$ResultatsRechercheClient->cleanCommand(); // inutile parce qu'on ne boucle pas dans cette fonction |
26 | //if(!is_object($Client) || !get_class($Client) == 'Client') | ||
27 | if($Client === 0) | ||
20 | { | 28 | { |
21 | echo "debug: annulation sélection client\n"; | 29 | echo "debug: annulation sélection client\n"; |
22 | return [0, null]; // menu principal | 30 | return [0, null]; // menu principal |
@@ -26,7 +34,7 @@ function modifyData($Client): array | |||
26 | 34 | ||
27 | // -- partie 2: modifier un client -- | 35 | // -- partie 2: modifier un client -- |
28 | 36 | ||
29 | // fenêtre | 37 | // fenêtre dynamique |
30 | $ModificationClientMenu = makeModifyCustomerWindow($Client); | 38 | $ModificationClientMenu = makeModifyCustomerWindow($Client); |
31 | 39 | ||
32 | $choix_niv2 = exec($ModificationClientMenu->get()); | 40 | $choix_niv2 = exec($ModificationClientMenu->get()); |
@@ -53,20 +61,22 @@ function modifyData($Client): array | |||
53 | { | 61 | { |
54 | echo "choix: annulation\n"; | 62 | echo "choix: annulation\n"; |
55 | } | 63 | } |
56 | $Client->update(); | 64 | Client::$entityManager->flush(); // Ã mettre dans une classe Manager |
65 | |||
57 | return [3, $Client]; // menu précédent | 66 | return [3, $Client]; // menu précédent |
58 | } | 67 | } |
59 | elseif(is_string($choix_niv2) && $choix_niv2 != '') // autres choix, modifier une valeur | 68 | elseif(is_string($choix_niv2) && $choix_niv2 != '') // modifier autre chose chez le client |
60 | { | 69 | { |
61 | echo "choix: modifier" . $choix_niv2 . "\n"; | 70 | echo "choix: modifier " . $choix_niv2 . "\n"; |
62 | $ModificationClient = new ZenityEntry($choix_niv2); | 71 | $ModificationClient = new ZenityEntry($choix_niv2); |
63 | $input = exec($ModificationClient->get()); | 72 | $input = exec($ModificationClient->get()); |
64 | if(is_string($input) && $input != '') | 73 | if(is_string($input) && $input != '') |
65 | { | 74 | { |
75 | // entités et BDD | ||
66 | $Client->set($choix_niv2, $input); | 76 | $Client->set($choix_niv2, $input); |
67 | $Client->update(); | 77 | $Client::$entityManager->flush(); |
68 | 78 | ||
69 | // mettre à jour les documents (il faudrait modifier tous les documents!!) | 79 | // documents (les factures, etc, ne sont pas modifiées ici) |
70 | $EnveloppeRecto = Latex::makeInstance('enveloppe_recto'); | 80 | $EnveloppeRecto = Latex::makeInstance('enveloppe_recto'); |
71 | $EnveloppeRecto->setData($Client); | 81 | $EnveloppeRecto->setData($Client); |
72 | $EnveloppeRecto->makeLatex(); | 82 | $EnveloppeRecto->makeLatex(); |
@@ -86,36 +96,35 @@ function modifyData($Client): array | |||
86 | 96 | ||
87 | 97 | ||
88 | // -- partie 3: rechercher une prestation -- | 98 | // -- partie 3: rechercher une prestation -- |
89 | $Presta = getServices($Client); // = 0 ou type "Prestations" | 99 | $Presta = Prestation::getServices($Client); // = 0 ou type "Prestation" |
90 | if(!is_object($Presta) || !get_class($Presta) == 'Prestations') | 100 | if(!is_object($Presta) || !get_class($Presta) == 'Prestation') |
91 | { | 101 | { |
92 | echo "debug: annulation sélection client\n"; | 102 | echo "debug: annulation sélection d'une prestation\n"; |
93 | return [3, $Client]; // menu précédent | 103 | return [3, $Client]; // menu précédent |
94 | } | 104 | } |
95 | 105 | $type_presta = $Presta->getTypePresta(); | |
96 | $type = $Presta->getTypePresta(); | 106 | switch($type_presta) |
97 | switch($type) | ||
98 | { | 107 | { |
99 | case 'facture': | 108 | case 'facture': |
100 | $PrestaDetails = new DevisFactures('factures'); | 109 | $classe = 'Facture'; |
101 | break; | 110 | break; |
102 | case 'devis': | 111 | case 'devis': |
103 | $PrestaDetails = new DevisFactures('devis'); | 112 | $classe = 'Devis'; |
104 | break; | 113 | break; |
105 | case 'cesu': | 114 | case 'cesu': |
106 | $PrestaDetails = new CESU(); | 115 | $classe = 'CESU'; |
107 | break; | 116 | break; |
108 | case 'location': | 117 | case 'location': |
109 | $PrestaDetails = new Locations(); | 118 | $classe = 'Location'; |
110 | break; | 119 | break; |
111 | case 'non_vendue': | 120 | case 'non_vendue': |
112 | $PrestaDetails = null; | 121 | $PrestaDetails = null; |
113 | break; | 122 | break; |
114 | } | 123 | } |
115 | if($type != 'non_vendue') | 124 | if($type_presta != 'non_vendue') |
116 | { | 125 | { |
117 | $PrestaDetails->setIdPresta($Presta->getId()); | 126 | $repository = $classe::$entityManager->getRepository($classe); |
118 | $PrestaDetails->hydrate($PrestaDetails->getDetailsByIdPresta()); | 127 | $PrestaDetails = $repository->findOneBy(['presta' => $Presta->getId()]); |
119 | } | 128 | } |
120 | 129 | ||
121 | 130 | ||
@@ -125,11 +134,7 @@ function modifyData($Client): array | |||
125 | $ModificationPrestaMenu = makeModifyServiceWindow($Presta, $PrestaDetails); | 134 | $ModificationPrestaMenu = makeModifyServiceWindow($Presta, $PrestaDetails); |
126 | 135 | ||
127 | $choix_niv3 = exec($ModificationPrestaMenu->get()); | 136 | $choix_niv3 = exec($ModificationPrestaMenu->get()); |
128 | //~ if($choix_niv3 === ZenitySetup::$modification_presta['devis_facture']) // devis -> facture | 137 | |
129 | //~ { | ||
130 | //~ echo "choix: changer un devis en facture\n"; | ||
131 | //~ return [2, $Client]; // menu "client" | ||
132 | //~ } | ||
133 | if($choix_niv3 === 'Date:') | 138 | if($choix_niv3 === 'Date:') |
134 | { | 139 | { |
135 | $Date = new Dates(exec($Calendrier->get())); // exec() renvoie soit une chaîne soit un false | 140 | $Date = new Dates(exec($Calendrier->get())); // exec() renvoie soit une chaîne soit un false |
@@ -139,50 +144,60 @@ function modifyData($Client): array | |||
139 | } | 144 | } |
140 | else | 145 | else |
141 | { | 146 | { |
142 | // mettre à jour la base de données | 147 | // entités et BDD |
143 | $Presta->setDate($Date->getTimestamp(), true); // un entier pour la BDD, "true" pour modifier le code_presta | 148 | $Presta->set($choix_niv3, $Date); |
144 | $Presta->update(); | 149 | $old_code = $Presta->getCodePresta(); |
150 | $Presta->setCodePresta(0); | ||
151 | $Presta::$entityManager->flush(); | ||
145 | 152 | ||
146 | // mettre à jour les documents | 153 | // documents |
147 | if($type === 'devis' || $type === 'facture' || $type === 'location') | 154 | if($type_presta === 'devis' || $type_presta === 'facture' || $type_presta === 'location') |
148 | { | 155 | { |
149 | $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location | 156 | $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location |
150 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); | 157 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); |
151 | $DocumentPresta->makeLatex(); | 158 | $DocumentPresta->makeLatex(); // en mémoire |
152 | makeTexAndPdf($DocumentPresta); | 159 | |
160 | renameFiles($DocumentPresta, $old_code, $Presta->getCodePresta()); | ||
161 | makeTexAndPdf($DocumentPresta); // une nouvelle facture est créée, supprimer l'ancienne ou la renommer avec la nouvelle date | ||
153 | } | 162 | } |
154 | } | 163 | } |
155 | 164 | ||
156 | return [3, $Client]; // menu précédent | 165 | return [3, $Client]; // menu précédent |
157 | } | 166 | } |
158 | //~ elseif($choix_niv3 === 'Type de Presta:') // choix impossible pour le moment | 167 | //~ elseif($choix_niv3 === 'Type de Presta:') // compliqué! choix impossible pour le moment |
159 | //~ { | 168 | //~ { |
160 | //~ echo "choix: changer le type de prestation (devis, facture, etc)\n"; | 169 | //~ echo "choix: changer le type de prestation (devis, facture, etc)\n"; |
161 | //~ return [3, $Client]; // menu "client" | 170 | //~ return [3, $Client]; // menu "client" |
162 | //~ } | 171 | //~ } |
163 | elseif(is_string($choix_niv3) && $choix_niv3 != '') // modifier une valeur | 172 | elseif(is_string($choix_niv3) && $choix_niv3 != '') // modifier une valeur |
164 | { | 173 | { |
165 | echo "choix: modifier" . $choix_niv3 . "\n"; | 174 | echo "choix: modifier " . $choix_niv3 . "\n"; |
166 | $ModificationPrestaForm = new ZenityEntry($choix_niv3); | 175 | $ModificationPrestaForm = new ZenityEntry($choix_niv3); |
167 | $input = shell_exec($ModificationPrestaForm->get()); // shell_exec() retourne null si la commande échoue, exec() retourne la dernière ligne de texte en sortie ou null si aucune commande ne réussit | 176 | $input = shell_exec($ModificationPrestaForm->get()); // shell_exec() retourne null si la commande échoue, exec() retourne la dernière ligne de texte en sortie ou null si aucune commande ne réussit |
168 | if(is_string($input)) // chaine vide autorisée | 177 | if(is_string($input)) // chaîne vide autorisée |
169 | { | 178 | { |
170 | // mettre à jour la base de données | 179 | // entités et BDD |
171 | $Presta->set($choix_niv3, $input); | 180 | $Presta->set($choix_niv3, $input); |
172 | $Presta->update(); | 181 | $old_code = $Presta->getCodePresta(); |
173 | 182 | $Presta->setCodePresta(0); | |
174 | if($type != 'non_vendue') | 183 | if($type_presta != 'non_vendue') |
175 | { | 184 | { |
176 | $PrestaDetails->set($choix_niv3, $input); | 185 | $PrestaDetails->set($choix_niv3, $input); |
177 | $PrestaDetails->update(); | 186 | $PrestaDetails::$entityManager->flush(); |
187 | } | ||
188 | else | ||
189 | { | ||
190 | $Presta::$entityManager->flush(); | ||
178 | } | 191 | } |
179 | 192 | ||
180 | // mettre à jour les documents | 193 | // documents |
181 | if($type === 'devis' || $type === 'facture' || $type === 'location') | 194 | if($type_presta === 'devis' || $type_presta === 'facture' || $type_presta === 'location') |
182 | { | 195 | { |
183 | $DocumentPresta = Latex::makeInstance($type); | 196 | $DocumentPresta = Latex::makeInstance($type_presta); |
184 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); | 197 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); |
185 | $DocumentPresta->makeLatex(); | 198 | $DocumentPresta->makeLatex(); |
199 | |||
200 | renameFiles($DocumentPresta, $old_code, $Presta->getCodePresta()); | ||
186 | makeTexAndPdf($DocumentPresta); | 201 | makeTexAndPdf($DocumentPresta); |
187 | } | 202 | } |
188 | } | 203 | } |
diff --git a/src/sections/4_get_document.php b/src/sections/4_get_document.php index baad117..e682d26 100644 --- a/src/sections/4_get_document.php +++ b/src/sections/4_get_document.php | |||
@@ -5,32 +5,32 @@ | |||
5 | 5 | ||
6 | function getOrPrintDocument(): array | 6 | function getOrPrintDocument(): array |
7 | { | 7 | { |
8 | $MenuDocuments = new ZenityList(ZenitySetup::$menu_documents_text, ZenitySetup::$menu_documents_entrees); | 8 | $MenuDocuments = new ZenityList(ZenitySetup::$menu_documents['text'], ZenitySetup::$menu_documents['entrees']); |
9 | 9 | ||
10 | // -- partie 1: type de document -- | 10 | // -- partie 1: type de document -- |
11 | 11 | ||
12 | $choix_niv2 = exec($MenuDocuments->get()); | 12 | $choix_niv2 = exec($MenuDocuments->get()); |
13 | if($choix_niv2 === ZenitySetup::$menu_documents_entrees[0]) | 13 | if($choix_niv2 === ZenitySetup::$menu_documents['entrees'][0]) |
14 | { | 14 | { |
15 | 15 | ||
16 | } | 16 | } |
17 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[1]) // = Facture | 17 | elseif($choix_niv2 === ZenitySetup::$menu_documents['entrees'][1]) // = Facture, devis, etc |
18 | { | 18 | { |
19 | 19 | ||
20 | } | 20 | } |
21 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[2]) // = Lettre avec adresse | 21 | elseif($choix_niv2 === ZenitySetup::$menu_documents['entrees'][2]) // = Lettre avec adresse |
22 | { | 22 | { |
23 | 23 | ||
24 | } | 24 | } |
25 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[3]) // = Livre des recettes | 25 | elseif($choix_niv2 === ZenitySetup::$menu_documents['entrees'][3]) // = Livre des recettes |
26 | { | 26 | { |
27 | 27 | ||
28 | } | 28 | } |
29 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[4]) // = Registre des achats | 29 | elseif($choix_niv2 === ZenitySetup::$menu_documents['entrees'][4]) // = Registre des achats |
30 | { | 30 | { |
31 | 31 | ||
32 | } | 32 | } |
33 | elseif($choix_niv2 === ZenitySetup::$menu_documents_entrees[5]) // = Bilan annuel | 33 | elseif($choix_niv2 === ZenitySetup::$menu_documents['entrees'][5]) // = Bilan annuel |
34 | { | 34 | { |
35 | 35 | ||
36 | } | 36 | } |
diff --git a/src/view/Zenity.php b/src/view/Zenity.php index 858dfa9..9e0fd1c 100644 --- a/src/view/Zenity.php +++ b/src/view/Zenity.php | |||
@@ -6,12 +6,12 @@ | |||
6 | 6 | ||
7 | abstract class ZenityCmd | 7 | abstract class ZenityCmd |
8 | { | 8 | { |
9 | protected $command = 'zenity'; | 9 | protected string $command = 'zenity'; |
10 | protected $command_type = ''; | 10 | protected string $command_type; |
11 | protected $rows = []; | 11 | protected array $rows; |
12 | protected $text = ''; | 12 | protected string $text; |
13 | protected $width = 300; | 13 | protected int $width = 300; |
14 | protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 | 14 | protected int $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 |
15 | 15 | ||
16 | protected function __construct(string $text, array $rows = []) // $rows est optionnel | 16 | protected function __construct(string $text, array $rows = []) // $rows est optionnel |
17 | { | 17 | { |
@@ -22,15 +22,11 @@ abstract class ZenityCmd | |||
22 | $this->command .= ' --text="' . $this->text . '"'; | 22 | $this->command .= ' --text="' . $this->text . '"'; |
23 | } | 23 | } |
24 | 24 | ||
25 | public function get() | 25 | public function get(): string |
26 | { | 26 | { |
27 | //echo $this->command . "\n"; | ||
27 | return($this->command); | 28 | return($this->command); |
28 | } | 29 | } |
29 | // pré-remlir un formulaire zenity --forms | ||
30 | //~ public function formSet() | ||
31 | //~ { | ||
32 | //~ return($this->command); | ||
33 | //~ } | ||
34 | } | 30 | } |
35 | 31 | ||
36 | 32 | ||
@@ -46,7 +42,7 @@ class ZenityList extends ZenityCmd | |||
46 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text | 42 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text |
47 | if($this->rows !== []) | 43 | if($this->rows !== []) |
48 | { | 44 | { |
49 | $this->command .= ' --width=' . $this->width; | 45 | $this->command .= ' --width=' . (string)$this->width; |
50 | $this->height = 80 + count($this->rows) * 25; | 46 | $this->height = 80 + count($this->rows) * 25; |
51 | $this->command .= ' --height=' . $this->height; | 47 | $this->command .= ' --height=' . $this->height; |
52 | $this->fillZenityList(); | 48 | $this->fillZenityList(); |
@@ -65,8 +61,8 @@ class ZenityList extends ZenityCmd | |||
65 | $this->width = $this->columns * 120 * $widen; | 61 | $this->width = $this->columns * 120 * $widen; |
66 | $this->height = 91 + count($this->rows) * 25; // inclut les lignes et la barre de défilement horizontale | 62 | $this->height = 91 + count($this->rows) * 25; // inclut les lignes et la barre de défilement horizontale |
67 | 63 | ||
68 | $this->command .= ' --width=' . $this->width; | 64 | $this->command .= ' --width=' . (string)$this->width; |
69 | $this->command .= ' --height=' . $this->height; | 65 | $this->command .= ' --height=' . (string)$this->height; |
70 | $this->fillZenityList(); | 66 | $this->fillZenityList(); |
71 | } | 67 | } |
72 | 68 | ||
@@ -103,11 +99,11 @@ class ZenityList extends ZenityCmd | |||
103 | $this->command .= $output; | 99 | $this->command .= $output; |
104 | } | 100 | } |
105 | 101 | ||
106 | public function cleanCommand() | 102 | /*public function cleanCommand() |
107 | { | 103 | { |
108 | $this->command = 'zenity'; | 104 | $this->command = 'zenity'; |
109 | $this->__construct($this->text); | 105 | $this->__construct($this->text); |
110 | } | 106 | }*/ |
111 | } | 107 | } |
112 | 108 | ||
113 | class ZenityQuestion extends ZenityCmd | 109 | class ZenityQuestion extends ZenityCmd |
@@ -131,7 +127,7 @@ class ZenityForms extends ZenityCmd | |||
131 | $this->command_type = ' --forms'; | 127 | $this->command_type = ' --forms'; |
132 | parent::__construct($text, $rows); | 128 | parent::__construct($text, $rows); |
133 | //$this->height = 80 + count($this->rows) * 25; // Ã tester, mais devrait produire le rendu attendu | 129 | //$this->height = 80 + count($this->rows) * 25; // Ã tester, mais devrait produire le rendu attendu |
134 | self::entriesZenityForms($this->rows); | 130 | $this->entriesZenityForms($this->rows); |
135 | } | 131 | } |
136 | 132 | ||
137 | private function entriesZenityForms(array $input) | 133 | private function entriesZenityForms(array $input) |
diff --git a/src/view/ZenitySetup.php b/src/view/ZenitySetup.php index 88621bf..956c4f0 100644 --- a/src/view/ZenitySetup.php +++ b/src/view/ZenitySetup.php | |||
@@ -6,29 +6,24 @@ | |||
6 | // $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); | 6 | // $MenuPrincipal = new ZenityList(ZenitySetup::$menu_principal_text, ZenitySetup::$menu_principal_entrees); |
7 | 7 | ||
8 | // pense-bête | 8 | // pense-bête |
9 | // rassembler les 'text' et 'entrées' | 9 | // améliorer les noms "resultats_recherche" |
10 | // ce serait plus logique que ce fichier soit en JSON | 10 | // ce serait plus logique que ce fichier soit en JSON |
11 | 11 | ||
12 | class ZenitySetup | 12 | class ZenitySetup |
13 | { | 13 | { |
14 | static public $menu_principal_text = "Gestion d'une micro-entreprise"; | 14 | static public $menu_principal = ['text' => "Gestion d'une micro-entreprise", |
15 | static public $menu_principal_entrees = ["Clients et prospects", "Prestations et devis", "Modifier un enregistrement", "Consulter, imprimer un document", "Consulter/analyser les données", "Communication", "Base de données"]; | 15 | 'entrees' => ["Clients et prospects", "Prestations et devis", "Modifier un enregistrement", "Consulter, imprimer un document", "Consulter, analyser les données", "Communication", "Base de données"]]; |
16 | static public $type_client = ['text' => "Client ou prospect?", | 16 | static public $menu_enregistrement = ['text' => "Type d\'enregistrement?", |
17 | 'entrees' => ["Client", "Prospect"]]; | 17 | 'entrees' => ["Devis", "Facture", "Facture à partir d'un devis", "CESU", "Location", "Prestation non vendue"]]; |
18 | static public $menu_enregistrement_text = "Type d\'enregistrement?"; | 18 | static public $menu_documents = ['text' => "Consulter, imprimer un document LaTeX", |
19 | static public $menu_enregistrement_entrees = ["Devis", "Facture", "Facture à partir d'un devis", "CESU", "Location", "Prestation non vendue"]; | 19 | 'entrees' => ["Devis", "Facture", "Lettre avec adresse", "Livre des recettes", "Registre des achats", "Bilan annuel"]]; |
20 | //~ static public $menu_enregistrement_entrees = ["Devis", "Facture", "CESU", "Location", "Prestation non vendue"]; | 20 | static public $menu_communication = ['text' => "Imprimer un support de communication", |
21 | static public $menu_documents_text = "Consulter, imprimer un document LaTeX"; | 21 | 'entrees' => ["Flyer (nécessite gimp)", "Carte de visite (nécessite scribus)", "Explorateur de fichiers"]]; |
22 | static public $menu_documents_entrees = ["Devis", "Facture", "Lettre avec adresse", "Livre des recettes", "Registre des achats", "Bilan annuel"]; | 22 | static public $recherche_client = ['text' => "Recherche d'un client avec son nom ou son code client"]; |
23 | static public $menu_communication_text = "Imprimer un support de communication"; | 23 | static public $resultats_recherche_client = ['text' => "Résultats de la recherche, sélectionner un client"]; |
24 | static public $menu_communication_entrees = ["Flyer (nécessite gimp)", "Carte de visite (nécessite scribus)", "Explorateur de fichiers"]; | 24 | static public $resultats_recherche_presta = ['text' => "Sélectionner une prestation"]; |
25 | static public $recherche_client_text = "Recherche d'un client avec son nom ou son code client"; | ||
26 | static public $resultats_recherche_client_text = "Résultats de la recherche, sélectionner un client"; | ||
27 | static public $resultats_recherche_presta_text = "Sélectionner une prestation"; | ||
28 | static public $nouveau_client = ['text' => "Nouveau client", | 25 | static public $nouveau_client = ['text' => "Nouveau client", |
29 | 'entrees' => ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:"]]; | 26 | 'entrees' => ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:"]]; |
30 | //~ static public $nouveau_client_text = "Nouveau client"; | ||
31 | //~ static public $nouveau_client_entrees = ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:"]; | ||
32 | static public $calendar = ['section2' => 'Nouvelle prestation étape 1/3 - Choisir une date', | 27 | static public $calendar = ['section2' => 'Nouvelle prestation étape 1/3 - Choisir une date', |
33 | 'section3' => 'Choisir une nouvelle date']; | 28 | 'section3' => 'Choisir une nouvelle date']; |
34 | static public $formulaire = ['text' => 'Nouvelle prestation 2/3 - Détail des travaux', | 29 | static public $formulaire = ['text' => 'Nouvelle prestation 2/3 - Détail des travaux', |
@@ -36,11 +31,13 @@ class ZenitySetup | |||
36 | '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:"], | 31 | '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:"], |
37 | 'facture_entrees_reduit' => ["Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Mode de paiement:"], | 32 | 'facture_entrees_reduit' => ["Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Mode de paiement:"], |
38 | 'cesu_entrees' => ["Tâches effectuées:", "Duree de travail:", "Salaire net:", "Mode de paiement:"], // en fait je pourrais ajouter plein d'autres trucs | 33 | 'cesu_entrees' => ["Tâches effectuées:", "Duree de travail:", "Salaire net:", "Mode de paiement:"], // en fait je pourrais ajouter plein d'autres trucs |
39 | '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:"]]; | 34 | 'location_entrees' => ["Désignation du bien:", "Modèle, numéro de série, description:", "Valeur:", "État des lieux du début:", "Durée de la location en semaines:", "Loyer hebdomadaire:", "Nombre de loyers déjà payés:", "Montant du chèque de caution:"]]; |
40 | static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; | 35 | static public $commentaire_prestation = ['text' => 'Nouvelle prestation 3/3 - Commentaires']; |
41 | static public $modification_client = ['text' => 'Modifier une information concernant un client', | 36 | static public $modification_client = ['text' => 'Modifier une information concernant un client', |
42 | 'service' => "Modifier une prestation"]; | 37 | 'service' => "Modifier une prestation"]; |
43 | //'return' => "Retour menu principal"]; | 38 | //'return' => "Retour menu principal"]; |
39 | static public $type_client = ['text' => "Client ou prospect?", | ||
40 | 'entrees' => ["Client", "Prospect"]]; | ||
44 | static public $modification_presta = ['text' => 'Modifier une prestation']; | 41 | static public $modification_presta = ['text' => 'Modifier une prestation']; |
45 | //'devis_facture' => "Créer une facture à partir d'un devis"]; | 42 | //'devis_facture' => "Créer une facture à partir d'un devis"]; |
46 | //'service' => "Modifier une autre prestation", | 43 | //'service' => "Modifier une autre prestation", |
@@ -52,5 +49,5 @@ class ZenitySetup | |||
52 | static public $fin_section_1 = ['text' => "Client enregistré", | 49 | static public $fin_section_1 = ['text' => "Client enregistré", |
53 | 'entrees' => ["Ajouter une prestation pour ce client", "Modifier les informations", "Enregistrer un autre client", "Menu principal"]]; | 50 | 'entrees' => ["Ajouter une prestation pour ce client", "Modifier les informations", "Enregistrer un autre client", "Menu principal"]]; |
54 | static public $fin_section_2 = ['text' => "Prestation/devis enregistré(e)", | 51 | static public $fin_section_2 = ['text' => "Prestation/devis enregistré(e)", |
55 | 'entrees' => ["Afficher le document", "Modifier les informations", "Enregistrer une autre prestation/devis", "Menu principal"]]; | 52 | 'entrees' => ["Afficher le document", "Modifier les informations", "Enregistrer une autre prestation (même client)", "Enregistrer une autre prestation (autre client)", "Menu principal"]]; |
56 | } | 53 | } |