2022-01-29 15:03:41 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Garradin;
|
|
|
|
|
2022-02-17 10:21:33 +01:00
|
|
|
use Garradin\Plugin\RecusFiscaux\Personne;
|
2022-01-29 15:03:41 +01:00
|
|
|
use Garradin\Plugin\RecusFiscaux\Utils;
|
|
|
|
|
2022-02-07 15:13:22 +01:00
|
|
|
// vérifier si l'année a bien été sélectionnée au préalable
|
2022-02-07 14:32:17 +01:00
|
|
|
$_SESSION['annee_recu'] = f('annee_recu');
|
2022-02-07 15:13:22 +01:00
|
|
|
if (! isset($_SESSION['annee_recu']) || $_SESSION['annee_recu'] == "") {
|
|
|
|
\Garradin\Utils::redirect(PLUGIN_URL . 'index.php');
|
|
|
|
}
|
2022-02-19 14:35:13 +01:00
|
|
|
$_SESSION['taux_reduction'] = $_POST['taux_reduction'];
|
2022-02-17 10:21:33 +01:00
|
|
|
|
2022-03-18 20:39:02 +01:00
|
|
|
// 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; }
|
|
|
|
}
|
|
|
|
|
2022-03-24 19:00:39 +01:00
|
|
|
// versements par personne
|
|
|
|
$_SESSION['lesVersements'] = Utils::getVersementsPersonnes($_SESSION['annee_recu'],
|
|
|
|
$champsNom);
|
2022-01-29 15:03:41 +01:00
|
|
|
|
2022-02-17 10:21:33 +01:00
|
|
|
// membres donateurs
|
2022-03-25 16:09:55 +01:00
|
|
|
$_SESSION['membresDonateurs'] = Utils::getDonateurs($_SESSION['annee_recu'],
|
2022-03-18 20:39:02 +01:00
|
|
|
$champsNom);
|
2022-03-24 19:00:39 +01:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// fonctions pour l'affichage
|
|
|
|
|
|
|
|
// afficher les informations d'une personne
|
|
|
|
$tpl->register_function('afficher_debut_personne', function ($params)
|
|
|
|
{
|
|
|
|
$versement = $params['versement'];
|
|
|
|
$idUser = $versement->idUser;
|
|
|
|
$personne = $_SESSION['membresDonateurs'][$idUser];
|
|
|
|
$idVersement = $versement->idUser;
|
|
|
|
$out = sprintf('<h3 class="personne">Versements de %s : <span id="total_%s">0,00 €</span></h3>',
|
|
|
|
$personne->nomPrenom,
|
|
|
|
$idVersement);
|
|
|
|
$out .= sprintf('
|
|
|
|
<fieldset class="versements" id="versements_%s">',
|
|
|
|
$idVersement);
|
|
|
|
$out .= sprintf('
|
|
|
|
<input type="checkbox" class="check_%s" id="check_%s"',
|
|
|
|
$idVersement,
|
|
|
|
$idVersement);
|
|
|
|
$out .= sprintf(' onclick="cocherDecocherPersonne(check_%s, total_%s)" />',
|
|
|
|
$idVersement,
|
|
|
|
$idVersement);
|
|
|
|
$out .= sprintf('
|
|
|
|
<label for="check_%s">Cliquer pour cocher toutes les lignes</label>',
|
|
|
|
$idVersement);
|
|
|
|
$out .= '<br />
|
|
|
|
<hr>';
|
|
|
|
return $out;
|
|
|
|
});
|
|
|
|
|
|
|
|
// afficher un versement
|
|
|
|
$tpl->register_function('afficher_versement', function ($params)
|
|
|
|
{
|
|
|
|
$versement = $params['versement'];
|
|
|
|
$rang = $params['rang'];
|
|
|
|
$idVersement = $versement->idUser;
|
|
|
|
$out = '<div class="';
|
|
|
|
$out .= ($rang%2==0) ? 'pair">' : 'impair">';
|
|
|
|
$out .= sprintf('
|
|
|
|
<input type="checkbox" class="check_%s" id="check_%s_%s"
|
|
|
|
name="selected[]" value="%s"
|
|
|
|
onclick="cocherDecocherVersement(check_%s_%s, total_%s)" />
|
|
|
|
<label for="check_%s_%s"></label>
|
|
|
|
<span class="montant">%.2f</span>
|
|
|
|
<span>%s</span>
|
|
|
|
</div>',
|
|
|
|
$idVersement, $idVersement,
|
|
|
|
$rang, $rang,
|
|
|
|
$idVersement, $rang, $idVersement, $idVersement, $rang,
|
|
|
|
$versement->versement/100,
|
|
|
|
date_format(date_create($versement->date),"d/m/Y"));
|
|
|
|
return $out;
|
|
|
|
});
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
2022-01-29 15:03:41 +01:00
|
|
|
// préparation de l'affichage
|
2022-03-24 19:00:39 +01:00
|
|
|
$tpl->assign('lesVersements', $_SESSION['lesVersements']);
|
2022-01-29 15:03:41 +01:00
|
|
|
$tpl->assign('plugin_css', ['style.css']);
|
|
|
|
|
|
|
|
// envoyer au template
|
|
|
|
$tpl->display(PLUGIN_ROOT . '/templates/versements_personnes.tpl');
|