diff --git a/templates/config.tpl b/templates/config.tpl new file mode 100644 index 0000000..3728eea --- /dev/null +++ b/templates/config.tpl @@ -0,0 +1,40 @@ + +{include file="%s/templates/_nav.tpl"|args:$plugin_root current_nav="config"} + +

Configuration

+ +{if $ok && !$form->hasErrors()} +

+ La configuration a bien été enregistrée. +

+{/if} + +{form_errors} + +
+
+ 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} +
+
+ +
+ 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} +
+
+

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

+
diff --git a/www/admin/config.php b/www/admin/config.php new file mode 100644 index 0000000..494046c --- /dev/null +++ b/www/admin/config.php @@ -0,0 +1,28 @@ +requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN); + +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')); + \Garradin\Utils::redirect(PLUGIN_URL . 'config.php?ok'); + } + catch (UserException $e) + { + $form->addError($e->getMessage()); + } +} + +$tpl->assign('ok', qg('ok') !== null); +$tpl->assign('plugin_config', $plugin->getConfig()); +$tpl->assign('plugin_css', ['style.css']); + +$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');