2022-01-19 16:04:42 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Garradin;
|
|
|
|
|
2022-03-31 10:27:31 +02:00
|
|
|
use Garradin\Plugin\RecusFiscaux\Utils;
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// opérations communes
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// vérifier si l'année a bien été sélectionnée au préalable
|
|
|
|
$_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 = Utils::getChampsNom($config, $plugin);
|
|
|
|
uasort($confNoms, function ($a, $b)
|
|
|
|
{
|
|
|
|
return $a->position - $b->position;
|
|
|
|
});
|
|
|
|
$champsNom = array();
|
|
|
|
foreach ($confNoms as $nom => $champ)
|
|
|
|
{
|
|
|
|
if ($champ->position != 0) { $champsNom[] = $nom; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// membres donateurs
|
|
|
|
$_SESSION['membresDonateurs'] = Utils::getDonateurs($_SESSION['annee_recu'],
|
|
|
|
$champsNom);
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// fonctions pour l'affichage
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// afficher les informations d'une activité et d'un tarif
|
|
|
|
$tpl->register_function('afficher_debut_tarif', function ($params)
|
|
|
|
{
|
|
|
|
$versement = $params['versement'];
|
|
|
|
$idTarif = $versement->idTarif;
|
|
|
|
$tarif = $_SESSION['lesTarifs'][$idTarif];
|
|
|
|
$idActivite = $tarif->idActivite;
|
|
|
|
$activite = $_SESSION['lesActivites'][$idActivite];
|
|
|
|
|
|
|
|
$out = '<details class="activite" open="open">
|
|
|
|
<summary class="activite">';
|
|
|
|
$out .= sprintf('
|
|
|
|
<h3>Activité « %s »</h3>', $activite->label);
|
|
|
|
if (!empty($activite->description)) {
|
|
|
|
$out .= sprintf('
|
|
|
|
<h4>%s</h4>', $activite->description);
|
|
|
|
}
|
|
|
|
$out .= sprintf('
|
|
|
|
<h4>tarif « %s »', $tarif->label);
|
|
|
|
if ($tarif->montant > 0) {
|
|
|
|
$out .= sprintf(' montant : %.2f €', $tarif->montant/100);
|
|
|
|
} else {
|
|
|
|
$out .= ' montant : libre';
|
|
|
|
}
|
|
|
|
$out .= '</h4>
|
|
|
|
</summary>';
|
|
|
|
return $out;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Afficher les informations d'une personne
|
|
|
|
$tpl->register_function('afficher_debut_personne', function ($params)
|
|
|
|
{
|
|
|
|
$idUser = $params['user'];
|
|
|
|
$idVersement = $params['idVersement'];
|
|
|
|
|
|
|
|
$personne = $_SESSION['membresDonateurs'][$idUser];
|
|
|
|
$out = '<details class="personne" open="open">
|
|
|
|
<summary class="personne">';
|
|
|
|
$out .= sprintf('<h4 class="personne">Versements de %s : <span class="total" id="total_%s">0,00 €</span></h4>',
|
|
|
|
$personne->nomPrenom,
|
|
|
|
$idVersement);
|
|
|
|
$out .= '</summary>';
|
|
|
|
$out .= sprintf('
|
|
|
|
<fieldset class="versements" id="versements_%s">',
|
|
|
|
$idVersement);
|
|
|
|
$out .= sprintf('
|
|
|
|
<input type="checkbox" id="check_%s"',
|
|
|
|
$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'];
|
|
|
|
$idVersement = $params['idVersement'];
|
|
|
|
$rang = $params['rang'];
|
|
|
|
|
|
|
|
$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)" />',
|
|
|
|
$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('
|
|
|
|
<span>%s</span>
|
|
|
|
</div>',
|
|
|
|
date_format(date_create($versement->date),"d/m/Y"));
|
|
|
|
return $out;
|
|
|
|
});
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
2022-01-29 15:03:41 +01:00
|
|
|
if ($_POST['choix_versements'] == 'tous_versements') {
|
|
|
|
require('versements_personnes.php');
|
|
|
|
} else {
|
|
|
|
require('versements_activites.php');
|
2022-01-25 17:19:31 +01:00
|
|
|
}
|