From 3e02319484397f1acbfa04df0d15e91869c87aa8 Mon Sep 17 00:00:00 2001 From: engel <> Date: Mon, 7 Feb 2022 13:32:17 +0000 Subject: [PATCH] =?UTF-8?q?am=C3=A9lioration=20gestion=20configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FossilOrigin-Name: dd08bb3079c4797c7944082ca9377c645a73f466048bd3928eb1e83973f4fba3 --- config.json | 15 ++++++++++--- templates/config.tpl | 34 ++++++++++++++++-------------- templates/index.tpl | 4 ++-- www/admin/config.php | 22 +++++++++++++------ www/admin/index.php | 1 + www/admin/versements_activites.php | 15 +++++++++++-- www/admin/versements_personnes.php | 2 +- 7 files changed, 62 insertions(+), 31 deletions(-) diff --git a/config.json b/config.json index c24a1cf..59b6ce7 100644 --- a/config.json +++ b/config.json @@ -1,8 +1,17 @@ { "articlesCGI" : [ - "Article 200", - "Article 228 bis", - "Article 978" + { + "titre" : "Article 200", + "valeur" : 0 + }, + { + "titre" : "Article 228 bis", + "valeur" : 0 + }, + { + "titre" : "Article 978", + "valeur" : 0 + } ], "reduction" : [ { diff --git a/templates/config.tpl b/templates/config.tpl index 3728eea..fef9049 100644 --- a/templates/config.tpl +++ b/templates/config.tpl @@ -13,28 +13,30 @@
- Objet -
-
obligatoire pour reçus fiscaux
- {input type="text" name="objet_0" source=$plugin.config label="Ligne 1" maxlength=95} - {input type="text" name="objet_1" source=$plugin.config label="Ligne 2" maxlength=95} - {input type="text" name="objet_2" source=$plugin.config label="Ligne 3" maxlength=95} -
+ Objet (but) de l'association +
+
obligatoire
+ {input type="text" name="objet_asso" source=$plugin.config label="" maxlength=300} +
Droit à la réduction d'impôt -
-
- obligatoire pour reçus fiscaux -
- {foreach from=$plugin_config->articlesCGI key="num" item="article"} - {input type="checkbox" name="cgi_art_%s"|args:$num value="1" source=$plugin.config label=$article} - {/foreach} -
+
+
+ obligatoire +
+ {foreach from=$plugin_config->articlesCGI key="key" item="article"} +{* {input : checked ne fonctionne pas si l'attribut name est un tableau... + {input type="checkbox" name="articlesCGI[]" value=$key label=$article.titre} +*} + + {/foreach} +

{csrf_field key="recusfiscaux_config"} {button type="submit" name="save" label="Enregistrer" shape="right" class="main"}

-
+ \ No newline at end of file diff --git a/templates/index.tpl b/templates/index.tpl index 2dbab8f..206d592 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -78,12 +78,12 @@ + name="taux_reduction_{$activite.idTarif}" value="{$plugin_config->reduction[0]->taux}" disabled /> + name="taux_reduction_{$activite.idTarif}" value="{$plugin_config->reduction[1]->taux}" disabled /> diff --git a/www/admin/config.php b/www/admin/config.php index 494046c..43c7d7e 100644 --- a/www/admin/config.php +++ b/www/admin/config.php @@ -3,16 +3,24 @@ namespace Garradin; $session->requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN); - +$art_sel=f('articlesCGI'); +error_log("art sel=" . print_r($art_sel, true) . "\n"); if (f('save') && $form->check('recusfiscaux_config')) { try { - $plugin->setConfig('objet_0', trim(f('objet_0'))); - $plugin->setConfig('objet_1', trim(f('objet_1'))); - $plugin->setConfig('objet_2', trim(f('objet_2')));; - $plugin->setConfig('cgi_art1', (bool)f('cgi_art_1')); - $plugin->setConfig('cgi_art2', (bool)f('cgi_art_2')); - $plugin->setConfig('cgi_art3', (bool)f('cgi_art_3')); + $plugin->setConfig('objet_asso', trim(f('objet_asso'))); + $confArticles = $plugin->getConfig('articlesCGI'); + // effacer l'ancienne configuration + for ($i = 0; $i < count($confArticles); ++$i) { + $confArticles[$i]->valeur = 0; + } + // et copier la nouvelle + foreach ($art_sel as $article) { + $confArticles[$article]->valeur = 1; + } + error_log("confArticles=" . print_r($confArticles, true) . "\n"); + $plugin->setConfig("articlesCGI", $confArticles); + error_log("plugin->config=" . print_r($plugin->getConfig("articlesCGI"), true) . "\n"); \Garradin\Utils::redirect(PLUGIN_URL . 'config.php?ok'); } catch (UserException $e) diff --git a/www/admin/index.php b/www/admin/index.php index e23f6a1..521bdea 100644 --- a/www/admin/index.php +++ b/www/admin/index.php @@ -21,6 +21,7 @@ $activitesTarifsComptes = Utils::getActivitesTarifsEtComptes(); $tpl->assign('anneesFiscales', $anneesFiscales); $tpl->assign('anneeCourante', $anneeCourante); $tpl->assign('activitesTarifsComptes', $activitesTarifsComptes); +$tpl->assign('plugin_config', $plugin->getConfig()); $tpl->assign('plugin_css', ['style.css']); // envoyer au template diff --git a/www/admin/versements_activites.php b/www/admin/versements_activites.php index d12b3a6..4dcc5db 100644 --- a/www/admin/versements_activites.php +++ b/www/admin/versements_activites.php @@ -4,9 +4,20 @@ namespace Garradin; use Garradin\Plugin\RecusFiscaux\Utils; -// récupérer les tarifs sélectionnés +// récupérer les infos du formulaire $lesTarifs = f('tarifs'); -$_SESSION['annee_recu'] = strip_tags($_POST['annee_recu']); +$_SESSION['annee_recu'] = f('annee_recu'); + +// taux de réduction associés +$lesTaux = array(); +foreach ($lesTarifs as $idTarif) { + $nomRadio = "taux_reduction_" . $idTarif; + $valRadio = f("$nomRadio"); + $lesTaux[] = $valRadio ? $valRadio: $plugin->getConfig()->reduction[0]->taux; +} +// error_log("Tarifs = " . print_r($lesTarifs, true) . "\n"); +// error_log("Réducs = " . print_r($lesTaux, true) . "\n"); + // liste des versements correspondants $_SESSION['lesVersements'] = Utils::getVersementsActivite($_SESSION['annee_recu'], $lesTarifs); diff --git a/www/admin/versements_personnes.php b/www/admin/versements_personnes.php index 259197a..adabb18 100644 --- a/www/admin/versements_personnes.php +++ b/www/admin/versements_personnes.php @@ -5,7 +5,7 @@ namespace Garradin; use Garradin\Plugin\RecusFiscaux\Utils; // liste des versements totaux par personne -$_SESSION['annee_recu'] = strip_tags($_POST['annee_recu']); +$_SESSION['annee_recu'] = f('annee_recu'); $_SESSION['lesVersementsTotaux'] = Utils::getVersementsTotaux($_SESSION['annee_recu']); // préparation de l'affichage