amélioration gestion champs nom
FossilOrigin-Name: 23841b8b267a439702b01a11c2066c9be6469638b660b334c28d695f2c149f83
This commit is contained in:
parent
b1645828fc
commit
2bdd771a70
3 changed files with 60 additions and 27 deletions
|
|
@ -1,31 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\Files\Files;
|
||||
use Garradin\Entities\Files\File;
|
||||
use Garradin\Plugin\RecusFiscaux\Utils;
|
||||
|
||||
$session->requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN);
|
||||
$art_sel = f('articlesCGI') ? : [];
|
||||
$taux_sel = f('tauxReduction') ? : [];
|
||||
$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);
|
||||
}
|
||||
// récupérer les champs des noms
|
||||
$champsNom = Utils::getChampsNom($config, $plugin);
|
||||
|
||||
if (f('save') && $form->check('recusfiscaux_config'))
|
||||
{
|
||||
|
|
@ -79,17 +66,16 @@ if (f('save') && $form->check('recusfiscaux_config'))
|
|||
$plugin->setConfig('ville_asso', trim(f('ville_asso')));
|
||||
|
||||
// champs pour le nom et prénom
|
||||
$confNoms = (array)$plugin->getConfig('nomChamps');
|
||||
foreach ($confNoms as $nom => $champ)
|
||||
foreach ($champsNom as $nom => $champ)
|
||||
{
|
||||
$champ->position = 0;
|
||||
}
|
||||
$i = -count($noms_sel);
|
||||
foreach ($noms_sel as $nom)
|
||||
{
|
||||
$confNoms[$nom]->position = $i++;
|
||||
$champsNom[$nom]->position = $i++;
|
||||
}
|
||||
$plugin->setConfig('nomChamps', $confNoms);
|
||||
$plugin->setConfig('champsNom', $champsNom);
|
||||
|
||||
\Garradin\Utils::redirect(PLUGIN_URL . 'config.php?ok');
|
||||
}
|
||||
|
|
@ -100,8 +86,7 @@ if (f('save') && $form->check('recusfiscaux_config'))
|
|||
}
|
||||
|
||||
// trier les champs de nom pour l'affichage
|
||||
$nomChamps = (array) $plugin->getConfig('nomChamps');
|
||||
uasort($nomChamps, function ($a, $b)
|
||||
uasort($champsNom, function ($a, $b)
|
||||
{
|
||||
return $a->position - $b->position;
|
||||
});
|
||||
|
|
@ -111,6 +96,6 @@ $path = qg('path') ?: File::CONTEXT_CONFIG;
|
|||
$tpl->assign('path', $path);
|
||||
$tpl->assign('default_signature', \Garradin\WWW_URL . "plugin/recusfiscaux/default_signature.png");
|
||||
$tpl->assign('plugin_config', $plugin->getConfig());
|
||||
$tpl->assign('nomChamps', $nomChamps);
|
||||
$tpl->assign('champsNom', $champsNom);
|
||||
$tpl->assign('plugin_css', ['style.css']);
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue