2022-01-29 15:00:04 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Garradin;
|
2022-02-24 11:28:08 +01:00
|
|
|
use Garradin\Files\Files;
|
|
|
|
use Garradin\Entities\Files\File;
|
|
|
|
|
2022-01-29 15:00:04 +01:00
|
|
|
$session->requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN);
|
2022-03-18 20:39:02 +01:00
|
|
|
$art_sel = f('articlesCGI') ? : [];
|
2022-03-03 12:09:52 +01:00
|
|
|
$taux_sel = f('tauxReduction') ? : [];
|
2022-03-18 20:39:02 +01:00
|
|
|
$noms_sel = f('champsNom') ? : [];
|
|
|
|
|
|
|
|
$confNoms = $plugin->getConfig('nomChamps');
|
|
|
|
if (! isset($confNoms))
|
|
|
|
{
|
|
|
|
// récupérer les champs des membres utilisés pour le nom et le prénom
|
|
|
|
$nomChamps = array();
|
|
|
|
foreach ($config->get('champs_membres')->listAssocNames() as $name => $title)
|
|
|
|
{
|
|
|
|
if (stristr($title, 'nom'))
|
|
|
|
{
|
|
|
|
$champ = new \stdClass();
|
|
|
|
$champ->titre = $title;
|
|
|
|
$champ->position = 0;
|
|
|
|
$nomChamps[$name] = $champ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$plugin->setConfig('nomChamps', $nomChamps);
|
|
|
|
}
|
2022-02-18 12:51:13 +01:00
|
|
|
|
2022-02-24 11:28:08 +01:00
|
|
|
$path = qg('path') ?: File::CONTEXT_CONFIG;
|
|
|
|
$context = Files::getContext($path);
|
|
|
|
$context_ref = Files::getContextRef($path);
|
|
|
|
|
2022-01-29 15:00:04 +01:00
|
|
|
if (f('save') && $form->check('recusfiscaux_config'))
|
|
|
|
{
|
|
|
|
try {
|
2022-02-24 11:28:08 +01:00
|
|
|
// objet de l'association
|
2022-02-07 14:32:17 +01:00
|
|
|
$plugin->setConfig('objet_asso', trim(f('objet_asso')));
|
2022-02-24 11:28:08 +01:00
|
|
|
|
|
|
|
// articles du CGI
|
2022-02-07 14:32:17 +01:00
|
|
|
$confArticles = $plugin->getConfig('articlesCGI');
|
|
|
|
// effacer l'ancienne configuration
|
|
|
|
for ($i = 0; $i < count($confArticles); ++$i) {
|
2022-03-03 12:09:52 +01:00
|
|
|
$confArticles[$i]->valeur = 0;
|
2022-02-07 14:32:17 +01:00
|
|
|
}
|
|
|
|
// et copier la nouvelle
|
|
|
|
foreach ($art_sel as $article) {
|
|
|
|
$confArticles[$article]->valeur = 1;
|
|
|
|
}
|
|
|
|
$plugin->setConfig("articlesCGI", $confArticles);
|
2022-02-24 11:28:08 +01:00
|
|
|
|
2022-03-03 12:09:52 +01:00
|
|
|
// 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);
|
|
|
|
|
2022-02-25 15:51:48 +01:00
|
|
|
// nom, fonction et signature du responsable
|
|
|
|
$plugin->setConfig('nom_responsable', trim(f('nom_responsable')));
|
|
|
|
$plugin->setConfig('fonction_responsable', trim(f('fonction_responsable')));
|
2022-03-03 12:09:52 +01:00
|
|
|
if (isset($_SESSION['sig_file']) && count($_SESSION['sig_file']) > 0)
|
|
|
|
{
|
|
|
|
// supprimer la signature précédente, si besoin
|
|
|
|
if (null !== $plugin->getConfig('signature'))
|
|
|
|
{
|
2022-03-03 14:15:48 +01:00
|
|
|
$sig_file = \Garradin\Files\Files::get($plugin->getConfig('signature'));
|
|
|
|
if (null !== $sig_file) {
|
|
|
|
$sig_file->delete();
|
|
|
|
}
|
2022-03-03 12:09:52 +01:00
|
|
|
}
|
|
|
|
// puis installer la nouvelle
|
2022-02-24 11:28:08 +01:00
|
|
|
$plugin->setConfig('signature', $_SESSION['sig_file'][0]->path);
|
|
|
|
}
|
|
|
|
|
2022-03-17 15:55:54 +01:00
|
|
|
// autres informations
|
|
|
|
// ville
|
2022-03-17 16:00:35 +01:00
|
|
|
$plugin->setConfig('ville_asso', trim(f('ville_asso')));
|
2022-03-17 15:55:54 +01:00
|
|
|
|
2022-03-18 20:39:02 +01:00
|
|
|
// champs pour le nom et prénom
|
|
|
|
$confNoms = (array)$plugin->getConfig('nomChamps');
|
|
|
|
foreach ($confNoms as $nom => $champ)
|
|
|
|
{
|
|
|
|
$champ->position = 0;
|
|
|
|
}
|
|
|
|
$i = -count($noms_sel);
|
|
|
|
foreach ($noms_sel as $nom)
|
|
|
|
{
|
|
|
|
$confNoms[$nom]->position = $i++;
|
|
|
|
}
|
|
|
|
$plugin->setConfig('nomChamps', $confNoms);
|
|
|
|
|
2022-01-29 15:00:04 +01:00
|
|
|
\Garradin\Utils::redirect(PLUGIN_URL . 'config.php?ok');
|
|
|
|
}
|
|
|
|
catch (UserException $e)
|
|
|
|
{
|
|
|
|
$form->addError($e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-18 20:39:02 +01:00
|
|
|
// trier les champs de nom pour l'affichage
|
|
|
|
$nomChamps = (array) $plugin->getConfig('nomChamps');
|
|
|
|
uasort($nomChamps, function ($a, $b)
|
|
|
|
{
|
|
|
|
return $a->position - $b->position;
|
|
|
|
});
|
|
|
|
|
2022-01-29 15:00:04 +01:00
|
|
|
$tpl->assign('ok', qg('ok') !== null);
|
2022-02-24 11:28:08 +01:00
|
|
|
$tpl->assign('path', $path);
|
2022-03-02 13:38:15 +01:00
|
|
|
$tpl->assign('default_signature', \Garradin\WWW_URL . "plugin/recusfiscaux/default_signature.png");
|
2022-01-29 15:00:04 +01:00
|
|
|
$tpl->assign('plugin_config', $plugin->getConfig());
|
2022-03-18 20:39:02 +01:00
|
|
|
$tpl->assign('nomChamps', $nomChamps);
|
2022-01-29 15:00:04 +01:00
|
|
|
$tpl->assign('plugin_css', ['style.css']);
|
|
|
|
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');
|