prise en compte de différents champs nom et prénom

FossilOrigin-Name: 2895a7a5054d102c3262500e9e67557129592b607830a406d30fd3596cdfe6a9
This commit is contained in:
engel 2022-03-18 19:39:02 +00:00
parent 5995f33efd
commit a3aa6fa200
8 changed files with 271 additions and 108 deletions

View file

@ -5,8 +5,27 @@ use Garradin\Files\Files;
use Garradin\Entities\Files\File;
$session->requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN);
$art_sel=f('articlesCGI') ? : [];
$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);
}
$path = qg('path') ?: File::CONTEXT_CONFIG;
$context = Files::getContext($path);
@ -63,6 +82,19 @@ if (f('save') && $form->check('recusfiscaux_config'))
// ville
$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)
{
$champ->position = 0;
}
$i = -count($noms_sel);
foreach ($noms_sel as $nom)
{
$confNoms[$nom]->position = $i++;
}
$plugin->setConfig('nomChamps', $confNoms);
\Garradin\Utils::redirect(PLUGIN_URL . 'config.php?ok');
}
catch (UserException $e)
@ -71,9 +103,17 @@ 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)
{
return $a->position - $b->position;
});
$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('nomChamps', $nomChamps);
$tpl->assign('plugin_css', ['style.css']);
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');

View file

@ -13,6 +13,7 @@ if ($anneesFiscales[0] < $anneeCourante) {
// libellés pour les taux de réduction
$_SESSION['ligneReduction'] = Utils::getLignesReduction($plugin->getConfig('reduction'));
// compter le nombre de taux de réduction activés
$nbTaux = 0;
foreach ($plugin->getConfig('reduction') as $taux)
@ -20,6 +21,16 @@ foreach ($plugin->getConfig('reduction') as $taux)
if ($taux->valeur == 1) { ++$nbTaux; }
}
// idem avec les champs nom/prénom
$nbChamps = 0;
if (null !== $plugin->getConfig('nomChamps'))
{
foreach ($plugin->getConfig('nomChamps') as $nom => $champ)
{
if ($champ->position != 0) { ++$nbChamps; }
}
}
// liste des activités, cotisations et comptes associés
$activitesTarifsComptes = Utils::getActivitesTarifsEtComptes();
@ -30,6 +41,7 @@ $tpl->assign('activitesTarifsComptes', $activitesTarifsComptes);
$tpl->assign('nbTarifs', count($activitesTarifsComptes));
$tpl->assign('plugin_config', $plugin->getConfig());
$tpl->assign('nbTaux', $nbTaux);
$tpl->assign('nbChamps', $nbChamps);
$tpl->assign('plugin_css', ['style.css']);
// envoyer au template

View file

@ -39,3 +39,8 @@ div.explications ul
{
list-style : initial;
}
div.actions
{
display : inline;
}

View file

@ -12,6 +12,19 @@ $_SESSION['annee_recu'] = f('annee_recu');
if (! isset($_SESSION['annee_recu']) || $_SESSION['annee_recu'] == "") {
\Garradin\Utils::redirect(PLUGIN_URL . 'index.php');
}
// champs pour le nom et prénom
$confNoms = (array) $plugin->getConfig('nomChamps');
uasort($confNoms, function ($a, $b)
{
return $a->position - $b->position;
});
$champsNom = array();
foreach ($confNoms as $nom => $champ)
{
if ($champ->position != 0) { $champsNom[] = $nom; }
}
// récupérer les infos du formulaire
$tarifsSelectionnes = f('tarifs') ?: [];
@ -39,11 +52,14 @@ foreach (Utils::getActivites($tarifsSelectionnes) as $activite) {
$_SESSION['lesActivites'] = $lesActivites;
// versements correspondants aux tarifs sélectionnés
$_SESSION['lesVersements'] = Utils::getVersementsTarifs($_SESSION['annee_recu'], $tarifsSelectionnes);
$_SESSION['lesVersements'] = Utils::getVersementsTarifs($_SESSION['annee_recu'],
$tarifsSelectionnes,
$champsNom);
// membres donateurs
$versementsMembres = Utils::getDonateurs($_SESSION['annee_recu'],
$champsNom);
$membresDonateurs = array();
$versementsMembres = Utils::getDonateurs($_SESSION['annee_recu']);
foreach ($versementsMembres as $versement) {
$membresDonateurs[$versement->idUser] = new Personne($versement->idUser,
$versement->nom,

View file

@ -12,12 +12,27 @@ 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');
uasort($confNoms, function ($a, $b)
{
return $a->position - $b->position;
});
$champsNom = array();
foreach ($confNoms as $nom => $champ)
{
if ($champ->position != 0) { $champsNom[] = $nom; }
}
// versements totaux par personne
$_SESSION['lesVersementsTotaux'] = Utils::getVersementsTotaux($_SESSION['annee_recu']);
$_SESSION['lesVersementsTotaux'] =
Utils::getVersementsTotaux($_SESSION['annee_recu'],
$champsNom);
// membres donateurs
$versementsMembres = Utils::getDonateurs($_SESSION['annee_recu'],
$champsNom);
$membresDonateurs = array();
$versementsMembres = Utils::getDonateurs($_SESSION['annee_recu']);
foreach ($versementsMembres as $versement) {
$membresDonateurs[$versement->idUser] = new Personne($versement->idUser,
$versement->nom,