diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /src/sections/2_service.php | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'src/sections/2_service.php')
| -rw-r--r-- | src/sections/2_service.php | 103 |
1 files changed, 48 insertions, 55 deletions
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 | } |
