95c8063083
FossilOrigin-Name: bf921ff8922652b165537fd1a2e9cf7661becaab65484213c9f93f9685ef66c4
73 lines
2.4 KiB
PHP
73 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace Garradin;
|
|
use Garradin\Files\Files;
|
|
use Garradin\Entities\Files\File;
|
|
|
|
$session->requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN);
|
|
$art_sel=f('articlesCGI') ? : [];
|
|
$taux_sel = f('tauxReduction') ? : [];
|
|
|
|
$path = qg('path') ?: File::CONTEXT_CONFIG;
|
|
$context = Files::getContext($path);
|
|
$context_ref = Files::getContextRef($path);
|
|
|
|
if (f('save') && $form->check('recusfiscaux_config'))
|
|
{
|
|
try {
|
|
// objet de l'association
|
|
$plugin->setConfig('objet_asso', trim(f('objet_asso')));
|
|
|
|
// articles du CGI
|
|
$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;
|
|
}
|
|
$plugin->setConfig("articlesCGI", $confArticles);
|
|
|
|
// taux de réduction
|
|
$confTaux = $plugin->getConfig('reduction');
|
|
// effacer l'ancienne configuration
|
|
for ($i = 0; $i < count($confTaux); ++$i) {
|
|
$confTaux[$i]->valeur = 0;
|
|
}
|
|
// et copier la nouvelle
|
|
foreach ($taux_sel as $taux) {
|
|
$confTaux[$taux]->valeur = 1;
|
|
}
|
|
$plugin->setConfig("reduction", $confTaux);
|
|
|
|
// nom, fonction et signature du responsable
|
|
$plugin->setConfig('nom_responsable', trim(f('nom_responsable')));
|
|
$plugin->setConfig('fonction_responsable', trim(f('fonction_responsable')));
|
|
if (isset($_SESSION['sig_file']) && count($_SESSION['sig_file']) > 0)
|
|
{
|
|
// supprimer la signature précédente, si besoin
|
|
if (null !== $plugin->getConfig('signature'))
|
|
{
|
|
\Garradin\Files\Files::get($plugin->getConfig('signature'))->delete();
|
|
}
|
|
// puis installer la nouvelle
|
|
$plugin->setConfig('signature', $_SESSION['sig_file'][0]->path);
|
|
}
|
|
|
|
\Garradin\Utils::redirect(PLUGIN_URL . 'config.php?ok');
|
|
}
|
|
catch (UserException $e)
|
|
{
|
|
$form->addError($e->getMessage());
|
|
}
|
|
}
|
|
|
|
$tpl->assign('ok', qg('ok') !== null);
|
|
$tpl->assign('path', $path);
|
|
$tpl->assign('default_signature', \Garradin\WWW_URL . "plugin/recusfiscaux/default_signature.png");
|
|
$tpl->assign('plugin_config', $plugin->getConfig());
|
|
$tpl->assign('plugin_css', ['style.css']);
|
|
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');
|