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
|
2022-03-29 14:50:25 +02:00
|
|
|
$confNoms = Utils::getChampsNom($config, $plugin);
|
2022-03-18 20:39:02 +01:00
|
|
|
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
|
|
|
|
|
2022-03-29 14:50:25 +02:00
|
|
|
// Afficher les informations d'une personne
|
2022-03-24 19:00:39 +01:00
|
|
|
$tpl->register_function('afficher_debut_personne', function ($params)
|
|
|
|
{
|
|
|
|
$versement = $params['versement'];
|
|
|
|
$idUser = $versement->idUser;
|
|
|
|
$personne = $_SESSION['membresDonateurs'][$idUser];
|
|
|
|
$idVersement = $versement->idUser;
|
2022-03-29 14:50:25 +02:00
|
|
|
$out = '<details class="personne" open="open">
|
|
|
|
<summary class="personne">';
|
2022-03-30 09:52:41 +02:00
|
|
|
$out .= sprintf('<h4 class="personne">Versements de %s : <span class="total" id="total_%s">0,00 €</span></h4>',
|
2022-03-24 19:00:39 +01:00
|
|
|
$personne->nomPrenom,
|
|
|
|
$idVersement);
|
2022-03-29 14:50:25 +02:00
|
|
|
$out .= '</summary>';
|
2022-03-24 19:00:39 +01:00
|
|
|
$out .= sprintf('
|
|
|
|
<fieldset class="versements" id="versements_%s">',
|
|
|
|
$idVersement);
|
|
|
|
$out .= sprintf('
|
2022-03-29 14:50:25 +02:00
|
|
|
<input type="checkbox" id="check_%s"',
|
2022-03-24 19:00:39 +01:00
|
|
|
$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('
|
2022-03-29 14:50:25 +02:00
|
|
|
<input type="checkbox"
|
|
|
|
class="check_%s"
|
|
|
|
id="check_%s_%s"
|
|
|
|
name="selected[]"
|
|
|
|
value="%s"
|
|
|
|
onclick="cocherDecocherVersement(check_%s_%s, total_%s)" />',
|
|
|
|
$idVersement,
|
|
|
|
$idVersement, $rang,
|
|
|
|
$rang,
|
|
|
|
$idVersement, $rang, $idVersement
|
|
|
|
);
|
|
|
|
$out .= sprintf('
|
|
|
|
<label for="check_%s_%s"></label>',
|
|
|
|
$idVersement, $rang
|
|
|
|
);
|
|
|
|
$out .= sprintf('
|
|
|
|
<span class="montant">%.2f</span>',
|
|
|
|
$versement->versement/100
|
|
|
|
);
|
|
|
|
$out .= sprintf('
|
2022-03-24 19:00:39 +01:00
|
|
|
<span>%s</span>
|
|
|
|
</div>',
|
|
|
|
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');
|