From b9c74de6d12ef40ab4baf67303ab22a10fcd5b32 Mon Sep 17 00:00:00 2001 From: polo Date: Sat, 25 Feb 2023 17:30:20 +0100 Subject: =?UTF-8?q?document=20locations,=20correction=20de=20pas=20mal=20d?= =?UTF-8?q?e=20probl=C3=A8mes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/dev.sqlite | Bin 36864 -> 36864 bytes src/functions.php | 9 +---- src/latex_templates/devis.php | 21 +++++++++- src/latex_templates/enveloppe_verso.php | 7 +--- src/latex_templates/facture.php | 19 ++++++++- src/latex_templates/location.php | 38 +++++++++++------- .../originaux_pas_toucher/devis.tex | 2 +- .../originaux_pas_toucher/location.tex | 44 ++++++++++++++++++--- src/model/Locations.php | 5 +-- src/model/Model.php | 6 +-- src/model/Prestations.php | 2 +- src/model/StructTablesDB.php | 2 +- src/sections/1_new_service.php | 42 ++++++++++++-------- 13 files changed, 136 insertions(+), 61 deletions(-) diff --git a/data/dev.sqlite b/data/dev.sqlite index f74d69d..337e5da 100644 Binary files a/data/dev.sqlite and b/data/dev.sqlite differ diff --git a/src/functions.php b/src/functions.php index 89bfbc9..bd91ddf 100644 --- a/src/functions.php +++ b/src/functions.php @@ -59,12 +59,7 @@ function makeLatexAndPdfDocument($documentType, Clients $Client = null, Prestati if($Client == null) // verso d'une enveloppe { - $data[0] = Config::$business_guy; - $data[1] = Config::$business_address; - $data[2] = implode(str_split(Config::$business_postcode)); - $data[3] = Config::$business_city; - - $latex = makeLatex($documentType, $data); // injection des variables + $latex = makeLatex($documentType); // pas de données transmises, elles sont dans la classe Config $file_name = 'enveloppe_verso'; } else @@ -106,7 +101,7 @@ function makeLatexAndPdfDocument($documentType, Clients $Client = null, Prestati latexToPdf($latex_path, $file_name, $pdf_path); } -function makeLatex(string $documentType, array $data, Dates $Date = null) +function makeLatex(string $documentType, array $data = [], Dates $Date = null) { $date = ''; if($Date != null) diff --git a/src/latex_templates/devis.php b/src/latex_templates/devis.php index bd9c89d..7f1c8f7 100644 --- a/src/latex_templates/devis.php +++ b/src/latex_templates/devis.php @@ -1,6 +1,23 @@ \documentclass{report} @@ -47,11 +64,11 @@ ob_start(); \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} Mme, M : \textcolor{vert}{} & Date du devis : \textcolor{vert}{}\\ - Adresse : \textcolor{vert}{} & + Adresse : \textcolor{vert}{} & Delai de livraison : \textcolor{vert}{}\\ & Durée de validité : \textcolor{vert}{}\\ - \end{tabularx}\\\\ + \end{tabularx}\\ PRESTATION\\ diff --git a/src/latex_templates/enveloppe_verso.php b/src/latex_templates/enveloppe_verso.php index 866fd04..81f6271 100644 --- a/src/latex_templates/enveloppe_verso.php +++ b/src/latex_templates/enveloppe_verso.php @@ -1,11 +1,6 @@ \documentclass[]{report} @@ -19,7 +14,7 @@ ob_start(); \begin{document} \setlength{\parindent}{0cm} - \Large{\\\\ } + \Large{\\\\ } \end{document} \documentclass{report} @@ -47,7 +64,7 @@ ob_start(); Mme, M : \textcolor{vert}{} & Date : \textcolor{vert}{}\\ \end{tabularx}\\ - Adresse : \textcolor{vert}{}\\ + Adresse : \textcolor{vert}{}\\ PRESTATION\\ diff --git a/src/latex_templates/location.php b/src/latex_templates/location.php index dce7f04..2f7eb52 100644 --- a/src/latex_templates/location.php +++ b/src/latex_templates/location.php @@ -1,6 +1,15 @@ \documentclass{report} @@ -44,40 +53,39 @@ ob_start(); PROPRIÉTAIRE\\ - Mme, M : \textcolor{vert}{Paul Jusot}\\ - Adresse : \textcolor{vert}{2A, rue de l'île de Man, 29000 Quimper}\\ + Mme, M : \textcolor{vert}{}\\ + Adresse : \textcolor{vert}{}\\ LOCATAIRE\\ \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} - Mme, M : \textcolor{vert}{} & tel : \textcolor{vert}{}\\ - Adresse : \textcolor{vert}{} & courriel : \textcolor{vert}{} + Mme, M : \textcolor{vert}{} & tel : \textcolor{vert}{}\\ + Adresse : \textcolor{vert}{} & courriel : \textcolor{vert}{} \end{tabularx}\\\\ BIEN LOUÉ\\ - Désignation : \textcolor{vert}{}\\ - Modèle, description : \textcolor{vert}{}\\ - - État des lieux initial : \textcolor{vert}{}\\\\ - - État des lieux final : \textcolor{vert}{}\\\\ + Désignation : \textcolor{vert}{}\\ + Modèle, description : \textcolor{vert}{}\\ + Valeur : \textcolor{vert}{}\\\\ + État des lieux initial : \textcolor{vert}{}\\\\\\ + État des lieux final : \textcolor{vert}{}\\\\ CLAUSES\\ - Durée du prêt : \textcolor{vert}{}\\ - Loyer mensuel : \textcolor{vert}{}\\ + Durée du prêt : \textcolor{vert}{}\\ + Loyer mensuel : \textcolor{vert}{}\\ \textbf{Le bénéficiaire de cette location s’engage à prendre soin du bien désigné et à en faire un usage strictement personnel.}\\ \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} - Fait en deux exemplaires à : \textcolor{vert}{} & le : \textcolor{vert}{} \\ + Fait en deux exemplaires à : \textcolor{vert}{} & le : \textcolor{vert}{} \\ \end{tabularx}\\ \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} - Le bénéficiaire du prêt : \textcolor{vert}{} & - Le loueur : \textcolor{vert}{}\\ + Le bénéficiaire du prêt : \textcolor{vert}{} & + Le loueur : \textcolor{vert}{}\\ \end{tabularx}\\ \normalsize(précéder la signature de la mention « lu et approuvé ») diff --git a/src/latex_templates/originaux_pas_toucher/devis.tex b/src/latex_templates/originaux_pas_toucher/devis.tex index 634ade1..bc44694 100644 --- a/src/latex_templates/originaux_pas_toucher/devis.tex +++ b/src/latex_templates/originaux_pas_toucher/devis.tex @@ -46,7 +46,7 @@ Delai de livraison : \textcolor{vert}{}\\ & Durée de validité : \textcolor{vert}{}\\ - \end{tabularx}\\\\ + \end{tabularx}\\ PRESTATION\\ diff --git a/src/latex_templates/originaux_pas_toucher/location.tex b/src/latex_templates/originaux_pas_toucher/location.tex index 0d525fe..5be9e47 100644 --- a/src/latex_templates/originaux_pas_toucher/location.tex +++ b/src/latex_templates/originaux_pas_toucher/location.tex @@ -33,12 +33,46 @@ Plus d'infos sur le site web: https\string://ordipolo.fr\\ % \string supprime l'espace devant les : - CLIENT\\ + \begin{center} + \large\textbf{CONTRAT DE LOCATION} + \end{center} - \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} - Mme, M : \textcolor{vert}{} & - Date : \textcolor{vert}{}\\ - \end{tabularx}\\ + PROPRIÉTAIRE\\ + + Mme, M : \textcolor{vert}{}\\ Adresse : \textcolor{vert}{}\\ + LOCATAIRE\\ + + \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} + Mme, M : \textcolor{vert}{} & tel : \textcolor{vert}{}\\ + Adresse : \textcolor{vert}{} & courriel : \textcolor{vert}{} + \end{tabularx}\\\\ + + BIEN LOUÉ\\ + + Désignation : \textcolor{vert}{}\\ + Modèle, description : \textcolor{vert}{}\\ + Valeur : \textcolor{vert}{}\\\\ + État des lieux initial : \textcolor{vert}{}\\\\\\ + État des lieux final : \textcolor{vert}{}\\\\ + + CLAUSES\\ + + Durée du prêt : \textcolor{vert}{}\\ + Loyer mensuel : \textcolor{vert}{}\\ + + + \textbf{Le bénéficiaire de cette location s’engage à prendre soin du bien désigné et à en faire un usage strictement personnel.}\\ + + \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} + Fait en deux exemplaires à : \textcolor{vert}{} & le : \textcolor{vert}{} \\ + \end{tabularx}\\ + + \begin{tabularx}{\linewidth}{@{}X@{}@{}X@{}} + Le bénéficiaire du prêt : \textcolor{vert}{} & + Le loueur : \textcolor{vert}{}\\ + \end{tabularx}\\ + \normalsize(précéder la signature de la mention « lu et approuvé ») + \end{document} \ No newline at end of file diff --git a/src/model/Locations.php b/src/model/Locations.php index 8ebf757..149c1f1 100644 --- a/src/model/Locations.php +++ b/src/model/Locations.php @@ -54,10 +54,9 @@ class Locations extends Model $this->etat_des_lieux_fin = $value; return($this); } - public function setDureeLocation($value) + public function setDureeLocation(string $value) { - $value = str_replace(',', '.', $value); - $this->duree_location = (float) $value; + $this->duree_location = $value; return($this); } public function setLoyerMensuel($value) diff --git a/src/model/Model.php b/src/model/Model.php index 6a7907c..9039aa6 100644 --- a/src/model/Model.php +++ b/src/model/Model.php @@ -7,11 +7,11 @@ abstract class Model extends DB protected $table; // <= enfant //static protected $tableStructure; - public function __construct() // à surcharger - { + //~ public function __construct() // à surcharger + //~ { //~ $this->table = strtolower(__CLASS__); //~ echo "TABLE = " . $this->table . "\n"; - } + //~ } // getters public function getTable(): string diff --git a/src/model/Prestations.php b/src/model/Prestations.php index ddd785b..2011dbe 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php @@ -95,7 +95,7 @@ class Prestations extends Model // on récupère un tableau contenant toutes les prestations d'un client tous types confondus (devis, facture, cesu, location, enregistrement sans vente) $combientieme_fois = count($this->find(['ID_client' => $this->ID_client])) + 1; - $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $combientieme_fois]; + $array_code = [$Date->getYear(), $Date->getMonth(), $Date->getDay(), $code_client, $this->type_presta, $combientieme_fois]; $this->code_presta = implode('-', $array_code); } } diff --git a/src/model/StructTablesDB.php b/src/model/StructTablesDB.php index 32ae92d..b1e3c7a 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/StructTablesDB.php @@ -14,7 +14,7 @@ class StructTablesDB 'devis' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT'], 'factures' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'machine' => 'TEXT', 'OS' => 'TEXT', 'donnees' => 'TEXT', 'cles_licences' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'total_HT' => 'REAL'], 'cesu' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'duree_travail' => 'TEXT', 'salaire' => 'REAL'], - 'locations' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'designation' => 'TEXT', 'modele_description' => 'TEXT', 'valeur' => 'REAL', 'etat_des_lieux_debut' => 'TEXT', 'etat_des_lieux_fin' => 'TEXT', 'duree_location' => 'INTEGER', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] + 'locations' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'designation' => 'TEXT', 'modele_description' => 'TEXT', 'valeur' => 'REAL', 'etat_des_lieux_debut' => 'TEXT', 'etat_des_lieux_fin' => 'TEXT', 'duree_location' => 'TEXT', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] ]; // les types de variables de sqlite sont peu nombreux et autorisent un typage automatique diff --git a/src/sections/1_new_service.php b/src/sections/1_new_service.php index d516329..ae2d2ef 100644 --- a/src/sections/1_new_service.php +++ b/src/sections/1_new_service.php @@ -102,7 +102,6 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a } $Presta->setDate($Date->getTimestamp()); // un entier pour la BDD - $Presta->makeCodePresta($Date, $Client->getCodeClient()); // d'un objet à l'autre switch($choix_niv2) { @@ -135,17 +134,22 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a return(0); } - if($input == '') - { - echo "debug: annulation lors de l'enregistrement des détails de la prestation\n"; - return(0); - } - elseif(isset($Details) && !$Details->hydrateFromForm($input, $Presta)) // echec de l'hydratation + $Presta->makeCodePresta($Date, $Client->getCodeClient()); // d'un objet à l'autre + + if($choix_niv2 != ZenitySetup::$menu_enregistrement_entrees[4]) // si presta non vendue, saut étape 3/3 { - echo "debug: erreur de hydrateFromForm()\n"; // messages d'erreur à mettre ici ou dans hydrateFromForm()? - return(0); + if($input == '') // annulation + { + echo "debug: annulation lors de l'enregistrement des détails de la prestation\n"; + return(0); + } + elseif(isset($Details) && !$Details->hydrateFromForm($input, $Presta)) // echec de l'hydratation + { + echo "debug: erreur de hydrateFromForm()\n"; // messages d'erreur à mettre ici ou dans hydrateFromForm()? + return(0); + } + unset($input); } - unset($input); // commentaire - étape 3/3 $input = exec($CommentairePrestation->get()); @@ -171,9 +175,12 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a $Presta->create(); $Presta->setID(); // sans paramètre, exécute un $this->db->lastInsertId() - $Details->setIDPresta($Presta->getID()); // d'un objet à l'autre - $Details->create(); - $Details->setID(); // sans paramètre, exécute un $this->db->lastInsertId() + if(isset($Details)) // presta non vendue + { + $Details->setIDPresta($Presta->getID()); // d'un objet à l'autre + $Details->create(); + $Details->setID(); // sans paramètre, exécute un $this->db->lastInsertId() + } // -- partie 3: LaTeX -- @@ -208,9 +215,12 @@ function newService(): int // code de retour, si 0 retour menu principal, si 2 a $type = 'enveloppe_recto'; makeLatexAndPdfDocument($type, $Client); - // le verso ne dépend pas du client mais de l'entreprise - $type = 'enveloppe_verso'; - makeLatexAndPdfDocument($type); + // le verso ne dépend pas du client mais de l'entreprise, dans la classe Config + if(!file_exists(Config::$pdf_path . 'enveloppe_verso.pdf')) + { + $type = 'enveloppe_verso'; + makeLatexAndPdfDocument($type); + } // -- partie 4: récapitulatif -- -- cgit v1.2.3