From a4d88fd1913758cc95b395eefcf5e9d730450382 Mon Sep 17 00:00:00 2001 From: polo Date: Sat, 23 Dec 2023 10:00:24 +0100 Subject: =?UTF-8?q?devis=20payant,=20cr=C3=A9er=20devis=20depuis=20facture?= =?UTF-8?q?,=20changement=20dans=20getIDsByIdClient(),=20suppression=20d?= =?UTF-8?q?=C3=A9pendance=20paquet=20latex=20"ulem",=20(string)=20dans=20s?= =?UTF-8?q?etTelephone()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/dev.sqlite | Bin 36864 -> 36864 bytes src/dependances.php | 18 ++-- src/functions.php | 7 +- src/latex_templates/devis.php | 7 +- .../originaux_pas_toucher/devis.tex | 3 +- src/main.php | 9 +- src/main_loop.php | 5 - src/model/Clients.php | 14 +-- src/model/DevisFactures.php | 32 ++++-- src/model/Model.php | 35 +++--- src/model/Prestations.php | 24 +++-- src/model/StructTablesDB.php | 2 +- src/sections/1_customer.php | 14 +-- src/sections/2_service.php | 118 +++++++++++---------- src/sections/3-1_windows.php | 2 +- src/sections/3_modify_data.php | 39 ++++--- src/view/ZenitySetup.php | 31 +++--- 17 files changed, 199 insertions(+), 161 deletions(-) diff --git a/data/dev.sqlite b/data/dev.sqlite index 3762c69..b4f0774 100644 Binary files a/data/dev.sqlite and b/data/dev.sqlite differ diff --git a/src/dependances.php b/src/dependances.php index a3dd320..ab37b3a 100644 --- a/src/dependances.php +++ b/src/dependances.php @@ -1,19 +1,23 @@ /dev/null") === '') // commande qui n'ouvre pas de fenêtre, erreur si la chaine est vide parce que la sortie d'erreur va dans /dev/null { - printf("Impossible de lancer zenity. Veuillez installer le paquet zenity\n"); + printf("Impossible de lancer zenity. Veuillez installer le paquet zenity.\nUn environnemet graphique est également nécéssaire.\n"); exit(); } diff --git a/src/functions.php b/src/functions.php index 47961f2..9bb59d6 100644 --- a/src/functions.php +++ b/src/functions.php @@ -96,13 +96,14 @@ function searchCustomer(string $input, Clients $Client): array } -function getServices(Clients $Client) +function getServices(Clients $Client, string $type = '') { echo "debug: recherche d'une prestation\n"; - // recherche dans la table 'prestations' avec 'ID_client' les ID des prestas + // on recherche les ID des prestas dans la table 'prestations' avec 'ID_client' $Presta = new Prestations($Client->getID()); - $IDs = $Presta->getIDsByIdClient(); + $Presta->setTypePresta($type); + $IDs = $Presta->getIDsByIdClient(); // comportement différent si le type est connu unset($Presta); // mettres toutes les données dans un tableau diff --git a/src/latex_templates/devis.php b/src/latex_templates/devis.php index 1bf2f94..ba6b635 100644 --- a/src/latex_templates/devis.php +++ b/src/latex_templates/devis.php @@ -13,6 +13,10 @@ if($data['deplacement'] != 0) { $data['deplacement'] = ((string) $data['deplacement']) . '€'; } +if($data['prix_devis'] != 0) +{ + $data['prix_devis'] = ((string) $data['prix_devis']) . '€'; +} if($data['total_HT'] != 0) { $data['total_HT'] = ((string) $data['total_HT']) . '€'; @@ -32,7 +36,6 @@ ob_start(); \usepackage{xcolor} % texte en couleur \usepackage{tabularx} % dimensions des tableaux automatique \usepackage{tikz} % le rectangle -\usepackage{ulem} % pour barrer \begin{document} \setlength{\parindent}{0cm} % supprimer les alinéas @@ -87,6 +90,8 @@ ob_start(); Déplacement : \textcolor{vert}{} + Devis Payant : \textcolor{vert}{} + Total HT : \textcolor{vert}{} \textit{(TVA non applicable, article 293B du code général des impôts)} diff --git a/src/latex_templates/originaux_pas_toucher/devis.tex b/src/latex_templates/originaux_pas_toucher/devis.tex index fa8ca79..e069308 100644 --- a/src/latex_templates/originaux_pas_toucher/devis.tex +++ b/src/latex_templates/originaux_pas_toucher/devis.tex @@ -10,7 +10,6 @@ \usepackage{xcolor} % texte en couleur \usepackage{tabularx} % dimensions des tableaux automatique \usepackage{tikz} % le rectangle -\usepackage{ulem} % pour barrer \begin{document} \setlength{\parindent}{0cm} % supprimer les alinéas @@ -65,6 +64,8 @@ Déplacement : \textcolor{vert}{} + Devis Payant : \textcolor{vert}{} + Total HT : \textcolor{vert}{} \textit{(TVA non applicable, article 293B du code général des impôts)} diff --git a/src/main.php b/src/main.php index d176b56..c5b1950 100755 --- a/src/main.php +++ b/src/main.php @@ -48,6 +48,9 @@ require('view/ZenitySetup.php'); // texte dans les fenêtres ET instanciation (u require('Latex.php'); // générer le code LaTeX - -// action !! -require('main_loop.php'); +// boucle principale +require('sections/1_customer.php'); +require('sections/2_service.php'); +require('sections/3_modify_data.php'); +require('sections/4_get_document.php'); +require('main_loop.php'); // action !! diff --git a/src/main_loop.php b/src/main_loop.php index f68c251..23f6235 100644 --- a/src/main_loop.php +++ b/src/main_loop.php @@ -3,11 +3,6 @@ // // -- BOUCLE PRINCIPALE -- -require('sections/1_customer.php'); -require('sections/2_service.php'); -require('sections/3_modify_data.php'); -require('sections/4_get_document.php'); - $main_loop = true; $section = [0, null]; // [code de retour, éventuelles données] diff --git a/src/model/Clients.php b/src/model/Clients.php index 524070a..a5cc276 100644 --- a/src/model/Clients.php +++ b/src/model/Clients.php @@ -102,17 +102,11 @@ class Clients extends Model $this->ville = (string) $value; return $this; } - public function setTelephone($value) // chaine parce que zenity renvoie une chaine et parce qu'on garde le 0 au début + public function setTelephone($value) { - if(is_numeric($value)) - { - $this->telephone = (string) $value; - } - else - { - $this->telephone = ''; - echo 'debug: le champ "telephone" ne doit comporter que des nombres, aucun numéro ne sera utilisé' . "\n"; - } + // type string parce que + // zenity renvoie une chaine, on peut ainsi garder le 0 au début et avoir plusieurs numéros (séparés par virgule et espace) + $this->telephone = (string) $value; return $this; } public function setCourriel($value) diff --git a/src/model/DevisFactures.php b/src/model/DevisFactures.php index 259690b..7c31f13 100644 --- a/src/model/DevisFactures.php +++ b/src/model/DevisFactures.php @@ -17,6 +17,7 @@ class DevisFactures extends Model protected $pieces; protected $total_pieces; protected $deplacement; + protected $prix_devis; protected $total_HT; protected $delai_livraison; protected $validite_devis; @@ -26,6 +27,7 @@ class DevisFactures extends Model { $this->table = $table; // deux tables séparées devis et factures } + public function getAllWithWindowFields(): array // différent de Model::getAll() qui retourne get_object_vars($this) { $taches = ["Tâches:" => $this->taches]; @@ -60,7 +62,8 @@ class DevisFactures extends Model return []; } } - public function set(string $entry, string $input) + + public function set(string $entry, string $input) // trouve la bonne méthode { switch($entry) { @@ -91,6 +94,9 @@ class DevisFactures extends Model case "Déplacement:": $this->setDeplacement($input); break; + case "Prix du devis:": + $this->setPrixDevis($input); + break; case "Total HT:": $this->setTotalHT($input); break; @@ -142,11 +148,6 @@ class DevisFactures extends Model $this->cles_licences = $value; return($this); } - //~ public function setTemps(string $value) - //~ { - //~ $this->temps = $value; - //~ return($this); - //~ } public function setTotalMainDOeuvre($value) { $value = str_replace(',', '.', $value); @@ -176,6 +177,12 @@ class DevisFactures extends Model $this->total_HT = (float) $value; return($this); } + public function setPrixDevis($value) + { + $value = str_replace(',', '.', $value); + $this->prix_devis = (float) $value; + return($this); + } public function setDelaiLivraison(string $value) { $this->delai_livraison = $value; @@ -192,6 +199,19 @@ class DevisFactures extends Model return($this); } + // création d'une facture à partir d'un devis + public function hydrateReceiptWithQuotation($ReceiptDetails) + { + $ReceiptDetails->hydrate([ + 'taches' => $this->taches, + 'total_main_d_oeuvre' => $this->total_main_d_oeuvre, + 'pieces' => $this->pieces, + 'total_pieces' => $this->total_pieces, + 'deplacement' => $this->deplacement, + 'total_HT' => $this->total_HT + ]); + } + //~ public function newRow(array $input) //~ { //~ if($this->table === 'devis') // comme la table 'factures' avec deux champs en plus diff --git a/src/model/Model.php b/src/model/Model.php index 07826af..d6597f0 100644 --- a/src/model/Model.php +++ b/src/model/Model.php @@ -37,6 +37,11 @@ abstract class Model extends DB } return $this; } + public function setTable(string $value) + { + $this->table = $value; + return($this); + } public function hydrate(array $data): bool // $data = tableau associatif en entrée: nom_du_champ => valeur { @@ -60,6 +65,7 @@ abstract class Model extends DB } // cette fonction reçoit des données d'un tableau simple, permettant d'associer des champs de formulaires aux noms différents des champs de la BDD + // méthode lancée par des objets de type enfants function hydrateFromForm(string $data_string, Object $Presta = NULL): bool // quand l'objet est $Details, on hydrate aussi $Presta { //~ $tableSize = count(StructTablesDB::$structureOfTables[$this->getTable()]); // int @@ -84,18 +90,25 @@ abstract class Model extends DB case 'prestations'; // inutilisé break; case 'devis'; - //~ $check = $Presta->hydrate(['mode_paiement' => $data_array[6]]); - //~ if($check) - //~ { - //~ $check = $this->hydrate(['taches' => $data_array[0], 'total_main_d_oeuvre' => $data_array[1], 'pieces' => $data_array[2], 'total_pieces' => $data_array[3], 'deplacement' => $data_array[4], 'total_HT' => $data_array[5], 'delai_livraison' => $data_array[7], 'validite_devis' => $data_array[8], 'signature_devis' => $data_array[9]]); - $check = $this->hydrate(['taches' => $data_array[0], 'total_main_d_oeuvre' => $data_array[1], 'pieces' => $data_array[2], 'total_pieces' => $data_array[3], 'deplacement' => $data_array[4], 'total_HT' => $data_array[5], 'delai_livraison' => $data_array[6], 'validite_devis' => $data_array[7]]); - //~ } + $check = $this->hydrate(['taches' => $data_array[0], 'total_main_d_oeuvre' => $data_array[1], 'pieces' => $data_array[2], 'total_pieces' => $data_array[3], 'deplacement' => $data_array[4], 'prix_devis' => $data_array[5], 'total_HT' => $data_array[6], 'delai_livraison' => $data_array[7], 'validite_devis' => $data_array[8]]); break; case 'factures'; - $check = $Presta->hydrate(['mode_paiement' => $data_array[10]]); - if($check) + if(count($data_array) === 11) + { + $check = $Presta->hydrate(['mode_paiement' => $data_array[10]]); + if($check) + { + $check = $this->hydrate(['taches' => $data_array[0], 'machine' => $data_array[1], 'OS' => $data_array[2], 'donnees' => $data_array[3], 'cles_licences' => $data_array[4], 'total_main_d_oeuvre' => $data_array[5], 'pieces' => $data_array[6], 'total_pieces' => $data_array[7], 'deplacement' => $data_array[8], 'total_HT' => $data_array[9]]); + } + } + elseif(count($data_array) === 5) { - $check = $this->hydrate(['taches' => $data_array[0], 'machine' => $data_array[1], 'OS' => $data_array[2], 'donnees' => $data_array[3], 'cles_licences' => $data_array[4], 'total_main_d_oeuvre' => $data_array[5], 'pieces' => $data_array[6], 'total_pieces' => $data_array[7], 'deplacement' => $data_array[8], 'total_HT' => $data_array[9]]); + $check = $this->hydrate(['machine' => $data_array[1], 'OS' => $data_array[2], 'donnees' => $data_array[3], 'cles_licences' => $data_array[4]]); + } + else + { + echo "debug: le tableau \$data_array n'a pas la taille attendue.\n"; + return false; } break; case 'cesu'; @@ -106,11 +119,7 @@ abstract class Model extends DB } break; case 'locations'; - //~ $check = $Presta->hydrate(['mode_paiement' => $data_array[11]]); - //~ if($check) - //~ { $check = $this->hydrate(['designation' => $data_array[0], 'modele_description' => $data_array[1], 'valeur' => $data_array[2], 'etat_des_lieux_debut' => $data_array[3], 'etat_des_lieux_fin' => $data_array[4], 'duree_location' => $data_array[5], 'loyer_mensuel' => $data_array[6], 'loyers_payes' => $data_array[7], 'caution' => $data_array[8]]); - //~ } break; default: // inutilisé echo "debug: table inconnue hydrateFromForm()"; diff --git a/src/model/Prestations.php b/src/model/Prestations.php index 54ad4b7..8591e83 100644 --- a/src/model/Prestations.php +++ b/src/model/Prestations.php @@ -28,13 +28,19 @@ class Prestations extends Model { return $this->ID_client; } - public function getIDsByIdClient() // obtenir une entrée avec son ID_client + public function getIDsByIdClient() // obtenir une entrée avec son ID_client, comportement différent si le type est connu { - $IDs = $this->execQuery('SELECT id FROM ' . $this->table . ' WHERE id_client = ' . $this->ID_client)->fetchAll(); - // changer le tableau de tableaux en tableau simple - for($i = 0; $i < count($IDs); $i++) + $sql = 'SELECT id FROM ' . $this->table . ' WHERE id_client = ' . $this->ID_client; + if($this->type_presta != '') { - $IDs[$i] = $IDs[$i]['ID']; + $sql .= " AND type_presta = '" . $this->type_presta . "'"; + } + $data = $this->execQuery($sql)->fetchAll(); // tableau de tableaux + + $IDs = []; // si $IDs reste vide, ne pas être de type NULL + for($i = 0; $i < count($data); $i++) + { + $IDs[$i] = $data[$i]['ID']; // tableau simple } return($IDs); } @@ -152,7 +158,7 @@ class Prestations extends Model } } -class CodePresta extends Prestations -{ - protected $numero_presta; -} +//~ class CodePresta extends Prestations +//~ { + //~ protected $numero_presta; +//~ } diff --git a/src/model/StructTablesDB.php b/src/model/StructTablesDB.php index 679adde..48bf8e5 100644 --- a/src/model/StructTablesDB.php +++ b/src/model/StructTablesDB.php @@ -11,7 +11,7 @@ class StructTablesDB // les tables devis_factures, cesu et locations sont liées à la table prestations 'clients' => ['ID' => 'INTEGER', 'prenom_nom' => 'TEXT', 'code_client' => 'TEXT', 'adresse' => 'TEXT', 'code_postal' => 'TEXT', 'ville' => 'TEXT', 'telephone' => 'TEXT', 'courriel' => 'TEXT', 'apropos' => 'TEXT', 'type' => 'TEXT DEFAULT prospect'], 'prestations' => ['ID' => 'INTEGER', 'ID_client' => 'INTEGER', 'code_presta' => 'TEXT', 'date' => 'INTEGER', 'type_presta' => 'TEXT', 'mode_paiement' => 'TEXT', 'commentaires' => 'TEXT'], - '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 DEFAULT non'], + 'devis' => ['ID' => 'INTEGER', 'ID_presta' => 'INTEGER', 'taches' => 'TEXT', 'total_main_d_oeuvre' => 'REAL', 'pieces' => 'TEXT', 'total_pieces' => 'REAL', 'deplacement' => 'REAL', 'prix_devis' => 'REAL', 'total_HT' => 'REAL', 'delai_livraison' => 'TEXT', 'validite_devis' => 'TEXT', 'signature_devis' => 'TEXT DEFAULT non'], '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' => 'TEXT', 'loyer_mensuel' => 'REAL', 'loyers_payes' => 'INTEGER', 'caution' => 'INTEGER'] diff --git a/src/sections/1_customer.php b/src/sections/1_customer.php index ca20d08..ae8067f 100644 --- a/src/sections/1_customer.php +++ b/src/sections/1_customer.php @@ -6,19 +6,19 @@ function newCustomer(): array { // fenêtres - $TypeDeClient = new ZenityList(ZenitySetup::$type_client_text, ZenitySetup::$type_client_entrees); + $TypeDeClient = new ZenityList(ZenitySetup::$type_client['text'], ZenitySetup::$type_client['entrees']); //~ $NouveauClient = new ZenityForms(ZenitySetup::$nouveau_client_text, ZenitySetup::$nouveau_client_entrees); - $FinSection1 = new ZenityList(ZenitySetup::$fin_section_1_text, ZenitySetup::$fin_section_1_entrees); + $FinSection1 = new ZenityList(ZenitySetup::$fin_section_1['text'], ZenitySetup::$fin_section_1['entrees']); // -- partie 1: client ou prospect? -- $Client = new Clients; $choix_niv2 = exec($TypeDeClient->get()); - if($choix_niv2 === ZenitySetup::$type_client_entrees[0]) + if($choix_niv2 === ZenitySetup::$type_client['entrees'][0]) { echo "choix: " . $choix_niv2 . "\n"; $Client->setType('client'); } - elseif($choix_niv2 === ZenitySetup::$type_client_entrees[1]) + elseif($choix_niv2 === ZenitySetup::$type_client['entrees'][1]) { echo "choix: " . $choix_niv2 . "\n"; $Client->setType('prospect'); @@ -33,15 +33,15 @@ function newCustomer(): array { // -- partie 3: on fait quoi maintenant -- $choix_niv3 = exec($FinSection1->get()); - if($choix_niv3 === ZenitySetup::$fin_section_1_entrees[0]) + if($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][0]) { return [2, $Client]; // section 2: newService() } - elseif($choix_niv3 === ZenitySetup::$fin_section_1_entrees[1]) + elseif($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][1]) { return [3, $Client]; // section 3: modifyData() } - elseif($choix_niv3 === ZenitySetup::$fin_section_1_entrees[2]) + elseif($choix_niv3 === ZenitySetup::$fin_section_1['entrees'][2]) { return [1, null]; // relancer section 1: newCustomer() } diff --git a/src/sections/2_service.php b/src/sections/2_service.php index 1d58606..9683ef9 100644 --- a/src/sections/2_service.php +++ b/src/sections/2_service.php @@ -8,13 +8,14 @@ function newService($Client): array // $Client est un Client ou null // fenêtres $MenuEnregistrement = new ZenityList(ZenitySetup::$menu_enregistrement_text, ZenitySetup::$menu_enregistrement_entrees); $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section2']); - $FormulaireDevis = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_devis_entrees); - $FormulaireFacture = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_facture_entrees); - $FormulaireCesu = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_cesu_entrees); - $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire_text, ZenitySetup::$formulaire_location_entrees); + $FormulaireDevis = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['devis_entrees']); + $FormulaireFacture = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['facture_entrees']); + $FormulaireFactureReduit = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['facture_entrees_reduit']); + $FormulaireCesu = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['cesu_entrees']); + $FormulaireLocation = new ZenityForms(ZenitySetup::$formulaire['text'], ZenitySetup::$formulaire['location_entrees']); $CommentairePrestation = new ZenityEntry(ZenitySetup::$commentaire_prestation_text); //$Recapitulatif = new ZenityList(ZenitySetup::$recapitulatif_text, ZenitySetup::$recapitulatif_entrees); // tableau à multiples colonnes - $FinSection2 = new ZenityList(ZenitySetup::$fin_section_2_text, ZenitySetup::$fin_section_2_entrees); + $FinSection2 = new ZenityList(ZenitySetup::$fin_section_2['text'], ZenitySetup::$fin_section_2['entrees']); // -- partie 1: le client -- @@ -57,44 +58,38 @@ function newService($Client): array // $Client est un Client ou null case ZenitySetup::$menu_enregistrement_entrees[0]: // "Devis" $PrestaDetails = new DevisFactures('devis'); $Presta->setTypePresta('devis'); - $input = exec($FormulaireDevis->get()); + $answers = exec($FormulaireDevis->get()); break; case ZenitySetup::$menu_enregistrement_entrees[1]: // "Facture" + $PrestaDetails = new DevisFactures('factures'); // attention! type "facture" mais table "factures" + $Presta->setTypePresta('facture'); + $answers = exec($FormulaireFacture->get()); + break; + case ZenitySetup::$menu_enregistrement_entrees[2]: // "Facture à partir d'un devis" + // recherche du devis + $Quotation = getServices($Client, 'devis'); // rechercher un devis, type 'devis' spécifié pour $Presta->getIDsByIdClient() + if(!is_object($Quotation) || get_class($Quotation) != 'Prestations' || $Quotation->getTypePresta() != 'devis') + { + echo "debug: annulation sélection client\n"; + return [2, $Client]; // menu précédent + } + $QuotationDetails = new DevisFactures('devis'); + // facture: objet vide et formulaire $PrestaDetails = new DevisFactures('factures'); $Presta->setTypePresta('facture'); - $input =exec($FormulaireFacture->get()); + $answers = exec($FormulaireFactureReduit->get()); + //$answers = '' + answers[0], answers[1], answers[2], answers[3], '', '', '', '', '', answers[4]; + //var_dump($answers); break; - - //~ case ZenitySetup::$menu_enregistrement_entrees[2]: // "Facture à partir d'un devis" - //~ $PrestaDetails = new DevisFactures('facture'); - //~ $Presta->setTypePresta('facture'); - // 1 choix d'un devis - //makeObjectService(); // liste les devis existants pour ce client - // - // 2 hydratation - // - // 3 préremplissage du formulaire - //$FormulaireFacture->set($Data) - // - // et plus loin: - // 4 édition de la facture - //$input = exec($FormulaireFacture->get()); - // - // 5 hydratation avec les changements - // - //echo $FormulaireFacture->get() . "\n"; - //~ $input = exec($FormulaireFacture->get()); - //~ break; - case ZenitySetup::$menu_enregistrement_entrees[3]: // "CESU" $PrestaDetails = new CESU(); $Presta->setTypePresta('cesu'); - $input = exec($FormulaireCesu->get()); + $answers = exec($FormulaireCesu->get()); break; case ZenitySetup::$menu_enregistrement_entrees[4]: // "Location" $PrestaDetails = new Locations(); $Presta->setTypePresta('location'); - $input = exec($FormulaireLocation->get()); + $answers = exec($FormulaireLocation->get()); break; case ZenitySetup::$menu_enregistrement_entrees[5]: // "Prestation non vendue" $Presta->setTypePresta('non_vendue'); @@ -106,28 +101,12 @@ function newService($Client): array // $Client est un Client ou null $Presta->makeCodePresta($Date, $Client->getCodeClient()); // d'un objet à l'autre - // hydratation ou saut étape 3/3 si presta non vendu - if($choix_niv2 != ZenitySetup::$menu_enregistrement_entrees[5]) - { - if($input == '') // annulation - { - echo "debug: annulation lors de l'enregistrement des détails de la prestation\n"; - return [0, null]; - } - elseif(isset($PrestaDetails) && !$PrestaDetails->hydrateFromForm($input, $Presta)) // echec de l'hydratation - { - echo "debug: erreur de hydrateFromForm()\n"; // messages d'erreur à mettre ici ou dans hydrateFromForm()? - return [0, null]; - } - unset($input); - } - // commentaire - étape 3/3 - $input = exec($CommentairePrestation->get()); - if($input == '') + $comment = exec($CommentairePrestation->get()); + if($comment == '') { echo "debug: pas de commentaire saisi\n"; - // on n'interrompt pas le script et on enregistre dans tous les cas (annulatation, chaîne vide) + // on n'interrompt pas le script et on enregistre dans tous les cas (annulatation comprise) } // Cliquer sur annuler (ou appuyer sur échap) revient dont à valider avec une chaîne vide et enregistrer la prestation // la commande 'echo $?' ($? est le code de sortie de la commande précédente) renvoit 1 si on annule avec la touche échap () @@ -140,13 +119,39 @@ function newService($Client): array // $Client est un Client ou null //~ echo "debug: annulation à la saisie d'un commentaire\n"; //~ return 0; //~ } - $Presta->setCommentaires($input); - unset($input); + $Presta->setCommentaires($comment); + + // hydratation d'une facture à partir d'un devis + if($choix_niv2 === ZenitySetup::$menu_enregistrement_entrees[2]) // cas: facture à partir d'un devis + { + // devis retrouvé ($Quotation est déjà hydraté) + $QuotationDetails->setIDPresta($Quotation->getID()); + $QuotationDetails->hydrate($QuotationDetails->getDetailsByIdPresta()); + + // facture avec le devis + $QuotationDetails->hydrateReceiptWithQuotation($PrestaDetails); + } + + // hydratation avec la saisie du formulaire + if($choix_niv2 != ZenitySetup::$menu_enregistrement_entrees[5]) // cas: tous les cas sauf presta non vendue + { + if($answers == '') // annulation + { + echo "debug: annulation lors de l'enregistrement des détails de la prestation\n"; + return [0, null]; + } + elseif(isset($PrestaDetails) && !$PrestaDetails->hydrateFromForm($answers, $Presta)) // echec de l'hydratation + { + echo "debug: erreur de hydrateFromForm()\n"; // messages d'erreur à mettre ici ou dans hydrateFromForm()? + return [0, null]; + } + } + // mise à jour base de données $Presta->create(); $Presta->setID(); // sans paramètre, exécute un $this->db->lastInsertId() - if(isset($PrestaDetails)) // presta non vendue + if(isset($PrestaDetails)) // presta vendue { $PrestaDetails->setIDPresta($Presta->getID()); // d'un objet à l'autre $PrestaDetails->create(); @@ -210,18 +215,19 @@ function newService($Client): array // $Client est un Client ou null //~ $imprimer_facture = exec('zenity --question --width=250 --title="Base de données mise à jour" --text="Imprimer la facture?"'); //~ $imprimer_enveloppe = exec('zenity --question --width=250 --title="Base de données mise à jour" --text="Imprimer l\'adresse sur une enveloppe? (insérer une enveloppe DL sans fenêtre dans l\'imprimante"'); + // ? modifications avec le menu de la section 3 obtenu avec makeModifyCustomerWindow() // -- partie 5: on fait quoi maintenant -- $choix_niv2 = exec($FinSection2->get()); - if($choix_niv2 === ZenitySetup::$fin_section_2_entrees[0]) + if($choix_niv2 === ZenitySetup::$fin_section_2['entrees'][0]) // afficher le document { return [4, null]; // section 4: getDocument() } - elseif($choix_niv2 === ZenitySetup::$fin_section_2_entrees[1]) + elseif($choix_niv2 === ZenitySetup::$fin_section_2['entrees'][1]) // modifier les informations { return [3, $Client]; // section 3: modifyData() } - elseif($choix_niv2 === ZenitySetup::$fin_section_2_entrees[2]) + elseif($choix_niv2 === ZenitySetup::$fin_section_2['entrees'][2]) // enregistrer une autre prestation { return [2, null]; // relancer section 2: newService() } diff --git a/src/sections/3-1_windows.php b/src/sections/3-1_windows.php index 7952f6d..7e7367b 100644 --- a/src/sections/3-1_windows.php +++ b/src/sections/3-1_windows.php @@ -55,7 +55,7 @@ function makeModifyServiceWindow(Prestations $Service, $ServiceDetails = null): if($Service->getTypePresta() === 'devis') { - $entrees[$i][] = ZenitySetup::$modification_presta['devis_facture']; // option changer le devis en facture + $entrees[$i][] = ZenitySetup::$modification_presta['devis_facture']; // option créer une facture à partir du devis $entrees[$i][] = ''; //~ $i++; } diff --git a/src/sections/3_modify_data.php b/src/sections/3_modify_data.php index 5da7ed9..0a67cea 100644 --- a/src/sections/3_modify_data.php +++ b/src/sections/3_modify_data.php @@ -7,6 +7,11 @@ require('3-1_windows.php'); function modifyData($Client): array { + // fenêtres fixes + $TypeDeClient = new ZenityList(ZenitySetup::$type_client['text'], ZenitySetup::$type_client['entrees']); + $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section3']); + + // -- partie 1: rechercher un client -- if($Client == null || get_class($Client) !== 'Clients') // étape sautable { @@ -25,22 +30,21 @@ function modifyData($Client): array $ModificationClientMenu = makeModifyCustomerWindow($Client); $choix_niv2 = exec($ModificationClientMenu->get()); - if($choix_niv2 === ZenitySetup::$modification_client['service']) // ne pas modifier le client mais une prestation + if($choix_niv2 === ZenitySetup::$modification_client['service']) // clic sur "Modifier une prestation" { echo "choix: modifier une prestation\n"; - // on passe à la suite + // ne rien faire dans cette partie et passer à la suite } - elseif($choix_niv2 === "Client ou Prospect?") // modifier type de client + elseif($choix_niv2 === "Client ou Prospect?") { echo "choix: modifier" . $choix_niv2 . "\n"; - $TypeDeClient = new ZenityList(ZenitySetup::$type_client_text, ZenitySetup::$type_client_entrees); $input = exec($TypeDeClient->get()); - if($input === ZenitySetup::$type_client_entrees[0]) + if($input === ZenitySetup::$type_client['entrees'][0]) { echo "choix: " . $input . "\n"; $Client->setType('client'); } - elseif($input === ZenitySetup::$type_client_entrees[1]) + elseif($input === ZenitySetup::$type_client['entrees'][1]) { echo "choix: " . $input . "\n"; $Client->setType('prospect'); @@ -52,7 +56,7 @@ function modifyData($Client): array $Client->update(); return [3, $Client]; // menu précédent } - elseif(is_string($choix_niv2) && $choix_niv2 != '') // modifier une valeur + elseif(is_string($choix_niv2) && $choix_niv2 != '') // autres choix, modifier une valeur { echo "choix: modifier" . $choix_niv2 . "\n"; $ModificationClient = new ZenityEntry($choix_niv2); @@ -74,7 +78,7 @@ function modifyData($Client): array } return [3, $Client]; // menu précédent } - else // annuler + else { echo "annulation: retour au menu principal\n"; return [0, null]; // menu principal @@ -95,7 +99,6 @@ function modifyData($Client): array case 'facture': $PrestaDetails = new DevisFactures('factures'); break; - case 'devis': $PrestaDetails = new DevisFactures('devis'); break; @@ -122,16 +125,13 @@ function modifyData($Client): array $ModificationPrestaMenu = makeModifyServiceWindow($Presta, $PrestaDetails); $choix_niv3 = exec($ModificationPrestaMenu->get()); - if($choix_niv3 === ZenitySetup::$modification_presta['devis_facture']) // devis -> facture - { - echo "choix: changer un devis en facture\n"; - return [3, $Client]; // menu "client" - } - elseif($choix_niv3 === 'Date:') + //~ if($choix_niv3 === ZenitySetup::$modification_presta['devis_facture']) // devis -> facture + //~ { + //~ echo "choix: changer un devis en facture\n"; + //~ return [2, $Client]; // menu "client" + //~ } + if($choix_niv3 === 'Date:') { - // fenêtre - $Calendrier = new ZenityCalendar(ZenitySetup::$calendar['section3']); - $Date = new Dates(exec($Calendrier->get())); // exec() renvoie soit une chaîne soit un false if($Date->getDate() == '') // clic sur "annuler", touche "échap" { @@ -157,7 +157,7 @@ function modifyData($Client): array } //~ elseif($choix_niv3 === 'Type de Presta:') // choix impossible pour le moment //~ { - //~ echo "choix: Impossible de modifier le type de prestation\n"; + //~ echo "choix: changer le type de prestation (devis, facture, etc)\n"; //~ return [3, $Client]; // menu "client" //~ } elseif(is_string($choix_niv3) && $choix_niv3 != '') // modifier une valeur @@ -179,7 +179,6 @@ function modifyData($Client): array } // mettre à jour les documents - //$type = $Presta->getTypePresta(); if($type === 'devis' || $type === 'facture' || $type === 'location') { $DocumentPresta = Latex::makeInstance($type); diff --git a/src/view/ZenitySetup.php b/src/view/ZenitySetup.php index d2b5796..a876c04 100644 --- a/src/view/ZenitySetup.php +++ b/src/view/ZenitySetup.php @@ -13,9 +13,8 @@ class ZenitySetup { static public $menu_principal_text = "Gestion d'une micro-entreprise"; 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"]; - //~ static public $question_nouveau_client_text = "Ce client figure t\'il déjà dans le fichier clients?"; - static public $type_client_text = "Client ou prospect?"; - static public $type_client_entrees = ["Client", "Prospect"]; + static public $type_client = ['text' => "Client ou prospect?", + 'entrees' => ["Client", "Prospect"]]; static public $menu_enregistrement_text = "Type d\'enregistrement?"; static public $menu_enregistrement_entrees = ["Devis", "Facture", "Facture à partir d'un devis", "CESU", "Location", "Prestation non vendue"]; //~ static public $menu_enregistrement_entrees = ["Devis", "Facture", "CESU", "Location", "Prestation non vendue"]; @@ -28,32 +27,28 @@ class ZenitySetup static public $resultats_recherche_presta_text = "Sélectionner une prestation"; static public $nouveau_client_text = "Nouveau client"; static public $nouveau_client_entrees = ["Prénom Nom:", "Code client (J.C.Dusse):", "Adresse:", "Code postal:", "Ville:", "Telephone:", "Courriel:", "À propos:"]; - static public $calendar = ['section2' => 'Nouvelle prestation étape 1/3 - Choisir une date', 'section3' => 'Choisir une nouvelle date']; - - static public $formulaire_text = 'Nouvelle prestation 2/3 - Détail des travaux'; - static public $formulaire_devis_entrees = ["Tâches effectuées:", "Total main d\'oeuvre (euros):", "Détail des pièces:", "Total pièces (euros):", "Déplacement (euros):", "Total HT (euros):", "Delai de livraison", "Durée de validite du devis:"]; - static public $formulaire_facture_entrees = ["Tâches effectuées:", "Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Total main d\'oeuvre (euros):", "Détail des pièces:", "Total pièces (euros):", "Déplacement (euros)", "Total HT (euros):", "Mode de paiement:"]; - static public $formulaire_cesu_entrees = ["Tâches effectuées:", "Duree de travail:", "Salaire net:", "Mode de paiement:"]; // en fait je pourrais ajouter plein d'autres trucs - static public $formulaire_location_entrees = ["Désignation du bien:", "Modèle, numéro de série, description:", "Valeur:", "État des lieux du début:", "État des lieux de fin:", "Durée de la location en mois:", "Loyer mensuel:", "Nombre de loyers déjà payés:", "Montant du chèque de caution:"]; + static public $formulaire = ['text' => 'Nouvelle prestation 2/3 - Détail des travaux', + 'devis_entrees' => ["Tâches effectuées:", "Total main d\'oeuvre (euros):", "Détail des pièces:", "Total pièces (euros):", "Déplacement (euros):", "Prix du devis (euros):", "Total HT (euros):", "Delai de livraison", "Durée de validite du devis:"], + '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:"], + 'facture_entrees_reduit' => ["Modèle du PC:", "OS:", "Données sauvegardées:", "Clés d\'activation:", "Mode de paiement:"], + 'cesu_entrees' => ["Tâches effectuées:", "Duree de travail:", "Salaire net:", "Mode de paiement:"], // en fait je pourrais ajouter plein d'autres trucs + '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:"]]; static public $commentaire_prestation_text = 'Nouvelle prestation 3/3 - Commentaires'; - static public $modification_client = ['text' => 'Modifier une information concernant un client', 'service' => "Modifier une prestation"]; //'return' => "Retour menu principal"]; static public $modification_presta = ['text' => 'Modifier une prestation', - 'devis_facture' => "Changer ce devis en facture"]; + 'devis_facture' => "Créer une facture à partir d'un devis"]; //'service' => "Modifier une autre prestation", //'return' => "Retour menu précédent"]; //~ static public $recapitulatif_text = "voici toutes les informations enregistrées"; //~ static public $recapitulatif_entrees = []; - //static public $question_modification_text = "Prestation enregistrée. Modifier les informations?"; - - static public $fin_section_1_text = "Client enregistré"; - static public $fin_section_1_entrees = ["Ajouter une prestation pour ce client", "Modifier les informations", "Enregistrer un autre client", "Menu principal"]; - static public $fin_section_2_text = "Prestation/devis enregistré(e)"; - static public $fin_section_2_entrees = ["Afficher le document", "Modifier les informations", "Enregistrer une autre prestation/devis", "Menu principal"]; + static public $fin_section_1 = ['text' => "Client enregistré", + 'entrees' => ["Ajouter une prestation pour ce client", "Modifier les informations", "Enregistrer un autre client", "Menu principal"]]; + static public $fin_section_2 = ['text' => "Prestation/devis enregistré(e)", + 'entrees' => ["Afficher le document", "Modifier les informations", "Enregistrer une autre prestation/devis", "Menu principal"]]; } -- cgit v1.2.3