diff options
Diffstat (limited to 'src/sections/3_modify_data.php')
| -rw-r--r-- | src/sections/3_modify_data.php | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/sections/3_modify_data.php b/src/sections/3_modify_data.php index 607638b..af40ebd 100644 --- a/src/sections/3_modify_data.php +++ b/src/sections/3_modify_data.php | |||
| @@ -100,8 +100,8 @@ function modifyData(?Client $Client = null): array | |||
| 100 | return [3, $Client]; // menu précédent | 100 | return [3, $Client]; // menu précédent |
| 101 | } | 101 | } |
| 102 | $type_presta = $Presta->getTypePresta(); | 102 | $type_presta = $Presta->getTypePresta(); |
| 103 | switch($type_presta) | 103 | $classe = ''; |
| 104 | { | 104 | switch($type_presta){ |
| 105 | case 'facture': | 105 | case 'facture': |
| 106 | $classe = 'Facture'; | 106 | $classe = 'Facture'; |
| 107 | break; | 107 | break; |
| @@ -117,6 +117,8 @@ function modifyData(?Client $Client = null): array | |||
| 117 | case 'non_vendue': | 117 | case 'non_vendue': |
| 118 | $PrestaDetails = null; | 118 | $PrestaDetails = null; |
| 119 | break; | 119 | break; |
| 120 | default: | ||
| 121 | echo "erreur: type de prestation buggué\n"; | ||
| 120 | } | 122 | } |
| 121 | if($type_presta != 'non_vendue') | 123 | if($type_presta != 'non_vendue') |
| 122 | { | 124 | { |
| @@ -134,29 +136,27 @@ function modifyData(?Client $Client = null): array | |||
| 134 | 136 | ||
| 135 | if($choix_niv3 === 'Date:') | 137 | if($choix_niv3 === 'Date:') |
| 136 | { | 138 | { |
| 137 | $Date = new Dates(exec($Calendrier->get())); // exec() renvoie soit une chaîne soit un false | 139 | $date_array = explode('/', exec($Calendrier->get())); // 17/10/2026 |
| 138 | if($Date->getDate() == '') // clic sur "annuler", touche "échap" | 140 | if(count($date_array) === 1){ |
| 139 | { | ||
| 140 | echo "debug: annulation à la saisie d'une date\n"; | 141 | echo "debug: annulation à la saisie d'une date\n"; |
| 142 | return [3, $Client]; | ||
| 141 | } | 143 | } |
| 142 | else | 144 | |
| 145 | // entités et BDD | ||
| 146 | $Presta->set($choix_niv3, $date_array[2] . '-' . $date_array[1] . '-' . $date_array[0]); // 2026-10-09 | ||
| 147 | $old_code = $Presta->getCodePresta(); | ||
| 148 | $Presta->setCodePresta(0); | ||
| 149 | $Presta::$entityManager->flush(); | ||
| 150 | |||
| 151 | // documents | ||
| 152 | if($type_presta === 'devis' || $type_presta === 'facture' || $type_presta === 'location') | ||
| 143 | { | 153 | { |
| 144 | // entités et BDD | 154 | $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location |
| 145 | $Presta->set($choix_niv3, $Date); | 155 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); |
| 146 | $old_code = $Presta->getCodePresta(); | 156 | $DocumentPresta->makeLatex(); // en mémoire |
| 147 | $Presta->setCodePresta(0); | ||
| 148 | $Presta::$entityManager->flush(); | ||
| 149 | 157 | ||
| 150 | // documents | 158 | renameFiles($DocumentPresta, $old_code, $Presta->getCodePresta()); |
| 151 | if($type_presta === 'devis' || $type_presta === 'facture' || $type_presta === 'location') | 159 | makeTexAndPdf($DocumentPresta); // une nouvelle facture est créée, supprimer l'ancienne ou la renommer avec la nouvelle date |
| 152 | { | ||
| 153 | $DocumentPresta = Latex::makeInstance($Presta->getTypePresta()); // $type = facture, devis, location | ||
| 154 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); | ||
| 155 | $DocumentPresta->makeLatex(); // en mémoire | ||
| 156 | |||
| 157 | renameFiles($DocumentPresta, $old_code, $Presta->getCodePresta()); | ||
| 158 | makeTexAndPdf($DocumentPresta); // une nouvelle facture est créée, supprimer l'ancienne ou la renommer avec la nouvelle date | ||
| 159 | } | ||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | return [3, $Client]; // menu précédent | 162 | return [3, $Client]; // menu précédent |
| @@ -191,7 +191,7 @@ function modifyData(?Client $Client = null): array | |||
| 191 | if($type_presta === 'devis' || $type_presta === 'facture' || $type_presta === 'location') | 191 | if($type_presta === 'devis' || $type_presta === 'facture' || $type_presta === 'location') |
| 192 | { | 192 | { |
| 193 | $DocumentPresta = Latex::makeInstance($type_presta); | 193 | $DocumentPresta = Latex::makeInstance($type_presta); |
| 194 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); | 194 | $DocumentPresta->setData($Client)->setData($Presta)->setData($PrestaDetails); // polymorphisme |
| 195 | $DocumentPresta->makeLatex(); | 195 | $DocumentPresta->makeLatex(); |
| 196 | 196 | ||
| 197 | renameFiles($DocumentPresta, $old_code, $Presta->getCodePresta()); | 197 | renameFiles($DocumentPresta, $old_code, $Presta->getCodePresta()); |
