amélioration gestion champs nom
FossilOrigin-Name: 2e194af9739c1603c6471619fe3b9720beb014d8d11442d01a42fc722ca9e790
This commit is contained in:
parent
7d4d305cfa
commit
3e53f19453
8 changed files with 72 additions and 38 deletions
|
|
@ -3,29 +3,15 @@
|
|||
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 +65,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 +85,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 +95,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');
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ foreach ($plugin->getConfig('reduction') as $taux)
|
|||
|
||||
// idem avec les champs nom/prénom
|
||||
$nbChamps = 0;
|
||||
if (null !== $plugin->getConfig('nomChamps'))
|
||||
if (null !== $plugin->getConfig('champsNom'))
|
||||
{
|
||||
foreach ($plugin->getConfig('nomChamps') as $nom => $champ)
|
||||
foreach ($plugin->getConfig('champsNom') as $nom => $champ)
|
||||
{
|
||||
if ($champ->position != 0) { ++$nbChamps; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ if (! isset($_SESSION['annee_recu']) || $_SESSION['annee_recu'] == "") {
|
|||
}
|
||||
|
||||
// champs pour le nom et prénom
|
||||
$confNoms = (array) $plugin->getConfig('nomChamps');
|
||||
$confNoms = (array) $plugin->getConfig('champsNom');
|
||||
uasort($confNoms, function ($a, $b)
|
||||
{
|
||||
return $a->position - $b->position;
|
||||
|
|
@ -40,14 +40,14 @@ $_SESSION['tauxSelectionnes'] = $tauxSelectionnes;
|
|||
// obtenir les instances de tarifs correspondant à la sélection
|
||||
$lesTarifs = array();
|
||||
foreach (Utils::getTarifs($tarifsSelectionnes) as $ot) {
|
||||
$lesTarifs[$ot->id] = Tarif::copier($ot);
|
||||
$lesTarifs[$ot->id] = $ot;
|
||||
}
|
||||
$_SESSION['lesTarifs'] = $lesTarifs;
|
||||
|
||||
// activités correspondants aux tarifs sélectionnés
|
||||
$lesActivites = array();
|
||||
foreach (Utils::getActivites($tarifsSelectionnes) as $activite) {
|
||||
$lesActivites[$activite->id] = Activite::copier($activite);
|
||||
$lesActivites[$activite->id] = $activite;
|
||||
}
|
||||
$_SESSION['lesActivites'] = $lesActivites;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ if (! isset($_SESSION['annee_recu']) || $_SESSION['annee_recu'] == "") {
|
|||
$_SESSION['taux_reduction'] = $_POST['taux_reduction'];
|
||||
|
||||
// champs pour le nom et prénom
|
||||
$confNoms = (array) $plugin->getConfig('nomChamps');
|
||||
$confNoms = (array) $plugin->getConfig('champsNom');
|
||||
uasort($confNoms, function ($a, $b)
|
||||
{
|
||||
return $a->position - $b->position;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue