début refonte gestion versements

FossilOrigin-Name: 1be54b8a985d3fb24895bae4cc5481743edf0a68dbb0eb4278580df3ce7f530d
This commit is contained in:
engel 2022-03-24 18:00:39 +00:00
parent 2e8eb26e5a
commit af7816d97f
11 changed files with 322 additions and 112 deletions

View File

@ -35,7 +35,6 @@ class Personne
/** /**
* return copie d'une personne * return copie d'une personne
*/
public function clone() public function clone()
{ {
return new Personne( return new Personne(
@ -46,6 +45,7 @@ class Personne
$this->ville, $this->ville,
$this->courriel); $this->courriel);
} }
*/
/** /**
* ajouter un versement * ajouter un versement

View File

@ -39,6 +39,37 @@ class Utils
return $db->get($sql); return $db->get($sql);
} }
/**
* @return versements correspondants à l'année donnée
* @param $annee
* @param array $champsNom : liste non vide des champs de nom/prénom
*/
public static function getVersementsPersonnes($annee, $champsNom)
{
$db = DB::getInstance();
$tri = Utils::combinerTri($champsNom);
$sql = sprintf(
'SELECT
membres.id as idUser,
acc_transactions_lines.credit as versement,
acc_transactions.date
FROM acc_transactions_users
INNER JOIN membres on acc_transactions_users.id_user = membres.id
INNER JOIN acc_transactions on acc_transactions_users.id_transaction = acc_transactions.id
INNER JOIN services_users on acc_transactions_users.id_service_user = services_users.id
INNER JOIN acc_transactions_lines on acc_transactions_lines.id_transaction = acc_transactions.id
WHERE
(strftime(%s, acc_transactions.date) = "%d"
AND
acc_transactions_lines.credit > 0)
ORDER by %s, acc_transactions.date',
'"%Y"',
$annee,
$tri
);
return $db->get($sql);
}
/** /**
* @return versements correspondants à l'année et aux tarifs donnés * @return versements correspondants à l'année et aux tarifs donnés
* @param $annee * @param $annee
@ -76,6 +107,42 @@ class Utils
return $db->get($sql); return $db->get($sql);
} }
/**
* @return versements correspondants à l'année et aux comptes donnés
* @param $annee
* @param array $comptes
* @param array $champsNom : liste non vide des champs de nom/prénom
*/
public static function getVersementsComptes($annee, $comptes, $champsNom)
{
$db = DB::getInstance();
$tri = Utils::combinerTri($champsNom);
$sql = sprintf(
'SELECT
acc_accounts.code as compte,
membres.id as idUser,
acc_transactions_lines.credit as versement,
acc_transactions.date
FROM acc_transactions_users
INNER JOIN membres on acc_transactions_users.id_user = membres.id
INNER JOIN acc_transactions on acc_transactions_users.id_transaction = acc_transactions.id
INNER JOIN services_users on acc_transactions_users.id_service_user = services_users.id
INNER JOIN acc_transactions_lines on acc_transactions_lines.id_transaction = acc_transactions.id
WHERE
(strftime(%s, acc_transactions.date) = "%d"
AND
acc_accounts.%s
AND
acc_transactions_lines.credit > 0)
ORDER by acc_accounts.code, %s, acc_transactions.date',
'"%Y"',
$annee,
$db->where('code', $comptes),
$tri
);
return $db->get($sql);
}
/** /**
* Versements totaux par personne pour une année donnée * Versements totaux par personne pour une année donnée
* @param année * @param année

View File

@ -5,7 +5,7 @@
<nav class="tabs"> <nav class="tabs">
<ul> <ul>
<li{if $current_nav == 'index'} class="current"{/if}><a href="{plugin_url}">Accueil</a></li> <li{if $current_nav == 'index'} class="current"{/if}><a href="{plugin_url}">Accueil</a></li>
<li{if $current_nav == 'personne'} class="current"{/if}><a href="{plugin_url file="versements_personnes.php"}">Versements totaux par personne</a></li> <li{if $current_nav == 'personne'} class="current"{/if}><a href="{plugin_url file="versements_personnes.php"}">Versements par personne</a></li>
<li{if $current_nav == 'versements'} class="current"{/if}><a href="{plugin_url file="versements_activites.php"}">Versements par activité et tarif</a></li> <li{if $current_nav == 'versements'} class="current"{/if}><a href="{plugin_url file="versements_activites.php"}">Versements par activité et tarif</a></li>
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)} {if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)}
<li{if $current_nav == 'config'} class="current"{/if}><a href="{plugin_url file="config.php"}">Configuration</a></li> <li{if $current_nav == 'config'} class="current"{/if}><a href="{plugin_url file="config.php"}">Configuration</a></li>

View File

@ -1,45 +1,38 @@
<!-- nav bar --> <!-- nav bar -->
{include file="%s/templates/_nav.tpl"|args:$plugin_root current_nav="personne"} {include file="%s/templates/_nav.tpl"|args:$plugin_root current_nav="personne"}
<h2>Versements totaux par personne</h2> <h2>Versements par personne</h2>
<form method="post" action="generer_personnes.php"> <form method="post" id="versements_personnes" action="generer_personnes.php">
<fieldset class="versements" id="versements_global">
<input type="checkbox" class="check_global" id="check_global" onclick="cocherDecocherToutesLesPersonnes(this.form, check_global)" />
<label for="check_global">Cliquer pour cocher toutes les lignes</label>
</fieldset>
{* Itération sur les personnes *} {* Itération sur les personnes *}
<table class="list"> {foreach from=$lesVersements key="i" item="versement"}
<thead> {if $i == 0}
<tr> {* 1ère personne *}
<th class="check"> <?php
<input type="checkbox" title="Tout cocher / décocher" id="f_all" /> $personneCourante = $versement->idUser;
<label for="f_all"></label> ?>
</th> {afficher_debut_personne versement=$versement}
<th>Id</th> {afficher_versement versement=$versement rang=$i}
<th>Nom Prénom</th> {elseif $versement.idUser != $personneCourante}
<th>Montant</th> {* changement de personne *}
<th>Adresse</th> </fieldset>
<th>Code postal</th> <?php
<th>Ville</th> $personneCourante = $versement->idUser;
</tr> ?>
</thead> {afficher_debut_personne versement=$versement}
<tbody> {afficher_versement versement=$versement rang=$i}
{foreach from=$lesVersementsTotaux key=rang item="versement"} {else}
<tr> {* même personne *}
<td class="check"> {afficher_versement versement=$versement rang=$i}
{input {/if}
type="checkbox" {/foreach} {* Itération sur les personnes *}
name="selected[]" </fieldset>
value=$rang}
</td>
<td>{$versement.idUser}</td>
<td>{$lesDonateurs[$versement.idUser]->nomPrenom}</td>
<td class="montant">{$versement.versement|raw|money}</td>
<td>{$lesDonateurs[$versement.idUser]->adresse}</td>
<td>{$lesDonateurs[$versement.idUser]->codePostal}</td>
<td>{$lesDonateurs[$versement.idUser]->ville}</td>
</tr>
{/foreach}
</tbody>
</table>
<input type="submit" value="Générer les reçus" onclick="return verifierChoix(this.form)"> <input type="submit" value="Générer les reçus" onclick="return verifierChoix(this.form)">
</form> </form>
@ -48,4 +41,4 @@
<script src="script.js"></script> <script src="script.js"></script>
<!-- footer --> <!-- footer -->
{include file="admin/_foot.tpl"} {include file="admin/_foot.tpl"}

View File

@ -27,10 +27,6 @@ if (! isset($confNoms))
$plugin->setConfig('nomChamps', $nomChamps); $plugin->setConfig('nomChamps', $nomChamps);
} }
$path = qg('path') ?: File::CONTEXT_CONFIG;
$context = Files::getContext($path);
$context_ref = Files::getContextRef($path);
if (f('save') && $form->check('recusfiscaux_config')) if (f('save') && $form->check('recusfiscaux_config'))
{ {
try { try {
@ -111,6 +107,7 @@ uasort($nomChamps, function ($a, $b)
}); });
$tpl->assign('ok', qg('ok') !== null); $tpl->assign('ok', qg('ok') !== null);
$path = qg('path') ?: File::CONTEXT_CONFIG;
$tpl->assign('path', $path); $tpl->assign('path', $path);
$tpl->assign('default_signature', \Garradin\WWW_URL . "plugin/recusfiscaux/default_signature.png"); $tpl->assign('default_signature', \Garradin\WWW_URL . "plugin/recusfiscaux/default_signature.png");
$tpl->assign('plugin_config', $plugin->getConfig()); $tpl->assign('plugin_config', $plugin->getConfig());

View File

@ -2,6 +2,9 @@
namespace Garradin; namespace Garradin;
use Garradin\Files\Files;
use Garradin\Entities\Files\File;
use Garradin\Plugin\RecusFiscaux\RecusHTML; use Garradin\Plugin\RecusFiscaux\RecusHTML;
use Garradin\Plugin\RecusFiscaux\Utils; use Garradin\Plugin\RecusFiscaux\Utils;
use Garradin\Plugin\RecusFiscaux\Personne; use Garradin\Plugin\RecusFiscaux\Personne;
@ -14,22 +17,28 @@ $versementsSelectionnes = array();
foreach ($lesLignes as $ligne) { foreach ($lesLignes as $ligne) {
$versementsSelectionnes[] = $_SESSION['lesVersements'][$ligne]; $versementsSelectionnes[] = $_SESSION['lesVersements'][$ligne];
} }
// cumuler les versements d'une personne
// cumuler les versements d'une personne : id => Personne
$totalPersonnes = cumulerVersements($versementsSelectionnes); $totalPersonnes = cumulerVersements($versementsSelectionnes);
// informations pour les reçus // informations pour les reçus
$nomAsso = Utils::getNomAsso(); $nomAsso = $config->get('nom_asso');
$adresseAsso = Utils::getAdresseAsso(); $adresseAsso = $config->get('adresse_asso');
$signature = $signature =
(null !== $plugin->getConfig('signature')) ? (null !== $plugin->getConfig('signature'))
\Garradin\Files\Files::get($plugin->getConfig('signature'))->fullpath() : ?
\Garradin\Files\Files::get($plugin->getConfig('signature'))->fullpath()
:
""; "";
// logo // logo
$logo_file = Files::get(File::CONTEXT_CONFIG . '/logo.png');
$logoAsso = $logoAsso =
(null !== $config->fileURL('logo')) ? (null !== $logo_file)
$config->fileURL('logo') : ?
\Garradin\Files\Files::get('skel/plugin/recusfiscaux/default_logo.png'); Files::get($logo_file->path)->fullpath()
:
"";
// articles du CGI // articles du CGI
$articlesCGI = array(); $articlesCGI = array();
@ -39,6 +48,7 @@ foreach ($plugin->getConfig('articlesCGI') as $article)
$articlesCGI[] = $article->titre; $articlesCGI[] = $article->titre;
} }
} }
$listeFichiers = array(); // fichiers pdf générés $listeFichiers = array(); // fichiers pdf générés
foreach ($totalPersonnes as $idPersonne => $personne) foreach ($totalPersonnes as $idPersonne => $personne)
{ {
@ -100,31 +110,32 @@ $fichierZip = Utils::makeArchive(
function cumulerVersements($versements) function cumulerVersements($versements)
{ {
$totalPersonnes = array(); $totalPersonnes = array();
$idTarif_courant = -1; $idTarifCourant = -1;
$idPersonne_courant = -1; $idPersonneCourant = -1;
$totalVersements = 0; $totalVersements = 0;
foreach ($versements as $ligne) foreach ($versements as $ligne)
{ {
if ( if (
$ligne->idTarif != $idTarif_courant || $ligne->idTarif != $idTarifCourant ||
$ligne->idUser != $idPersonne_courant $ligne->idUser != $idPersonneCourant
) )
{ {
if ($idTarif_courant != -1) { if ($idTarifCourant != -1) {
$totalPersonnes[$idPersonne_courant]->ajouterVersement( $totalPersonnes[$idPersonneCourant]->ajouterVersement(
$_SESSION['lesTarifs'][$idTarif_courant]->idActivite, $_SESSION['lesTarifs'][$idTarifCourant]->idActivite,
$idTarif_courant, $idTarifCourant,
$totalVersements/100, $totalVersements/100,
$_SESSION['tauxSelectionnes'][$idTarif_courant] $_SESSION['tauxSelectionnes'][$idTarifCourant]
); );
} }
$idTarif_courant = $ligne->idTarif; $idTarifCourant = $ligne->idTarif;
$idPersonne_courant = $ligne->idUser; $idPersonneCourant = $ligne->idUser;
$totalVersements = $ligne->versement; $totalVersements = $ligne->versement;
// créer les infos de la personne, sauf si elle est déjà présente // créer les infos de la personne, sauf si elle est déjà présente
if (!array_key_exists($idPersonne_courant, $totalPersonnes)) if (!array_key_exists($idPersonneCourant, $totalPersonnes))
{ {
$totalPersonnes["$idPersonne_courant"] = $_SESSION['membresDonateurs'][$ligne->idUser]->clone(); // $totalPersonnes["$idPersonneCourant"] = $_SESSION['membresDonateurs'][$ligne->idUser]->clone();
$totalPersonnes["$idPersonneCourant"] = $_SESSION['membresDonateurs'][$ligne->idUser];
} }
} else { } else {
// cumuler versements // cumuler versements
@ -132,12 +143,11 @@ function cumulerVersements($versements)
} }
} }
// et le dernier // et le dernier
$totalPersonnes[$idPersonne_courant]->ajouterVersement( $totalPersonnes[$idPersonneCourant]->ajouterVersement(
$_SESSION['lesTarifs'][$idTarif_courant]->idActivite, $_SESSION['lesTarifs'][$idTarifCourant]->idActivite,
$idTarif_courant, $idTarifCourant,
$totalVersements/100, $totalVersements/100,
$_SESSION['tauxSelectionnes'][$idTarif_courant] $_SESSION['tauxSelectionnes'][$idTarifCourant]
); );
return $totalPersonnes; return $totalPersonnes;
} }

View File

@ -2,6 +2,9 @@
namespace Garradin; namespace Garradin;
use Garradin\Files\Files;
use Garradin\Entities\Files\File;
use Garradin\Plugin\RecusFiscaux\RecusHTML; use Garradin\Plugin\RecusFiscaux\RecusHTML;
use Garradin\Plugin\RecusFiscaux\Utils; use Garradin\Plugin\RecusFiscaux\Utils;
use Garradin\Plugin\RecusFiscaux\Personne; use Garradin\Plugin\RecusFiscaux\Personne;
@ -12,21 +15,29 @@ $lesLignes = f('selected');
// filtrer les versements sélectionnés // filtrer les versements sélectionnés
$versementsSelectionnes = array(); $versementsSelectionnes = array();
foreach ($lesLignes as $ligne) { foreach ($lesLignes as $ligne) {
$versementsSelectionnes[] = $_SESSION['lesVersementsTotaux'][$ligne]; $versementsSelectionnes[] = $_SESSION['lesVersements'][$ligne];
} }
// cumuler les versements d'une personne : id => Personne
$totalPersonnes = cumulerVersements($versementsSelectionnes);
// informations pour les reçus // informations pour les reçus
$nomAsso = Utils::getNomAsso(); $nomAsso = $config->get('nom_asso');
$adresseAsso = Utils::getAdresseAsso(); $adresseAsso = $config->get('adresse_asso');
$signature = $signature =
(null !== $plugin->getConfig('signature')) ? (null !== $plugin->getConfig('signature'))
\Garradin\Files\Files::get($plugin->getConfig('signature'))->fullpath() : ?
Files::get($plugin->getConfig('signature'))->fullpath()
:
""; "";
// logo // logo
$logo_file = Files::get(File::CONTEXT_CONFIG . '/logo.png');
$logoAsso = $logoAsso =
(null !== $config->fileURL('logo')) ? (null !== $logo_file)
$config->fileURL('logo') : ?
\Garradin\Files\Files::get('skel/plugin/recusfiscaux/default_logo.png'); Files::get($logo_file->path)->fullpath()
:
"";
// articles du CGI // articles du CGI
$articlesCGI = array(); $articlesCGI = array();
@ -36,8 +47,9 @@ foreach ($plugin->getConfig('articlesCGI') as $article)
$articlesCGI[] = $article->titre; $articlesCGI[] = $article->titre;
} }
} }
$listeFichiers = array(); // fichiers pdf générés $listeFichiers = array(); // fichiers pdf générés
foreach ($versementsSelectionnes as $ligne) foreach ($totalPersonnes as $idPersonne => $personne)
{ {
// générer un fichier par reçu // générer un fichier par reçu
$html = new RecusHTML( $html = new RecusHTML(
@ -53,8 +65,16 @@ foreach ($versementsSelectionnes as $ligne)
); );
// extraire les montants des versements // extraire les montants des versements
$lesMontants[$_SESSION['taux_reduction']] = $ligne->versement/100; $lesMontants = array();
$personne = $_SESSION['membresDonateurs'][$ligne->idUser]; foreach ($personne->versements as $versement)
{
if (array_key_exists($versement->tauxReduction, $lesMontants)) {
$lesMontants[$versement->tauxReduction] += $versement->montant;
}
else {
$lesMontants[$versement->tauxReduction] = $versement->montant;
}
}
$html->imprimer_recu( $html->imprimer_recu(
$_SESSION['annee_recu'], $_SESSION['annee_recu'],
$personne->id, $personne->id,
@ -81,3 +101,49 @@ $fichierZip = Utils::makeArchive(
$_SESSION['annee_recu'], $_SESSION['annee_recu'],
PLUGIN_ROOT . "/zip" PLUGIN_ROOT . "/zip"
); );
/**
* Cumuler les versements de chaque personne
* @param tableau des versements triés par idUser, date
* @return tableau des versements cumulés : id => Personne
*/
function cumulerVersements($versements)
{
$totalPersonnes = array();
$idPersonneCourant = -1;
$totalVersements = 0;
foreach ($versements as $ligne)
{
if ($ligne->idUser != $idPersonneCourant)
{
// changement de personne
if ($idPersonneCourant != -1)
{
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
0,
0,
$totalVersements/100,
$_SESSION['taux_reduction']
);
}
$idPersonneCourant = $ligne->idUser;
$totalVersements = $ligne->versement;
// créer les infos de la personne, sauf si elle est déjà présente
if (!array_key_exists($idPersonneCourant, $totalPersonnes))
{
$totalPersonnes["$idPersonneCourant"] = $_SESSION['membresDonateurs'][$ligne->idUser];
}
} else {
// cumuler versements
$totalVersements += $ligne->versement;
}
}
// et le dernier
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
0,
0,
$totalVersements/100,
$_SESSION['taux_reduction']
);
return $totalPersonnes;
}

View File

@ -9,31 +9,43 @@ function cocherDecocherTout(idCaseGlobale)
var formulaire = idCaseGlobale.closest("form"); var formulaire = idCaseGlobale.closest("form");
// itérer sur la liste des éléments détails : 1 par couple <activité, tarif> // itérer sur la liste des éléments détails : 1 par couple <activité, tarif>
var lesDetails = formulaire.querySelectorAll("details"); var lesDetails = formulaire.querySelectorAll("details");
for (var i = 0; i < lesDetails.length; ++i) { for (var i = 0; i < lesDetails.length; ++i)
{
// itérer sur les personnes // itérer sur les personnes
var lesH3 = lesDetails[i].querySelectorAll("h3.personne"); var lesH3 = lesDetails[i].querySelectorAll("h3.personne");
for (var j = 0; j < lesH3.length; ++j) { cocherDecocherLesPersonnes(idCaseGlobale, lesH3);
// trouver l'élément total de la personne
var idTotal = lesH3[j].querySelector("span");
// puis la case à cocher
var fieldset = lesH3[j].nextElementSibling;
var idCase = fieldset.querySelector("input");
idCase.checked = idCaseGlobale.checked;
// puis traiter toutes les cases de la personne
cocherDecocherPersonne(idCase, idTotal);
}
} }
// changer le message // changer le message
var message = idCaseGlobale.nextElementSibling; changerMessage(idCaseGlobale.nextElementSibling, idCaseGlobale);
if (idCase.checked) { }
message.innerHTML = "Cliquer pour dé-cocher toutes les lignes";
} else { /**
message.innerHTML = "Cliquer pour cocher toutes les lignes"; * idem dans le cas des versements des personnes
*/
function cocherDecocherToutesLesPersonnes(formulaire, idCaseGlobale)
{
var lesH3 = formulaire.querySelectorAll("h3.personne");
cocherDecocherLesPersonnes(idCaseGlobale, lesH3);
changerMessage(idCaseGlobale.nextElementSibling, idCaseGlobale);
}
function cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes)
{
for (var j = 0; j < lesPersonnes.length; ++j)
{
// trouver l'élément total de la personne
var idTotal = lesPersonnes[j].querySelector("span");
// puis la case à cocher
var fieldset = lesPersonnes[j].nextElementSibling;
var idCase = fieldset.querySelector("input");
idCase.checked = idCaseGlobale.checked;
// puis traiter toutes les cases de la personne
cocherDecocherPersonne(idCase, idTotal);
} }
} }
/** /**
* Fonction appelée quand on ()coche la case d'une personne * Fonction appelée quand on ()coche la case globale d'une personne
* - ()sélectionner toutes les cases à cocher * - ()sélectionner toutes les cases à cocher
* - faire le total des cases cochées et l'afficher * - faire le total des cases cochées et l'afficher
* *
@ -49,16 +61,11 @@ function cocherDecocherPersonne(idCase, idTotal)
{ {
listeCases[i].checked = idCase.checked; listeCases[i].checked = idCase.checked;
} }
// changer le message
var message = idCase.nextElementSibling;
if (idCase.checked) {
message.innerHTML = "Cliquer pour dé-cocher toutes les lignes";
} else {
message.innerHTML = "Cliquer pour cocher toutes les lignes";
}
// calculer et afficher le total // calculer et afficher le total
var listeMontants = fieldset.querySelectorAll("span.montant"); var listeMontants = fieldset.querySelectorAll("span.montant");
calculerTotal(listeCases, listeMontants, idTotal); calculerTotal(listeCases, listeMontants, idTotal);
// changer le message
changerMessage(idCase.nextElementSibling, idCase);
} }
/** /**
@ -98,6 +105,18 @@ function calculerTotal(listeCases, listeMontants, idTotal)
minimumFractionDigits: 2}); minimumFractionDigits: 2});
} }
/**
* changer le message en fonction de l'état coché de la case
*/
function changerMessage(message, idCase)
{
if (idCase.checked) {
message.innerHTML = "Cliquer pour dé-cocher toutes les lignes";
} else {
message.innerHTML = "Cliquer pour cocher toutes les lignes";
}
}
/** /**
* fonction appelée lors de la validation du formulaire * fonction appelée lors de la validation du formulaire
* @return vrai si au moins un choix a été fait * @return vrai si au moins un choix a été fait

View File

@ -18,6 +18,10 @@ div span {
td.montant { td.montant {
text-align : right; text-align : right;
} }
span.montant {
width : 5em;
text-align : right;
}
summary.activite { summary.activite {
background: rgba(var(--gMainColor), 0.25); background: rgba(var(--gMainColor), 0.25);
} }

View File

@ -107,7 +107,7 @@ $tpl->register_function('afficher_debut_personne', function ($params)
$versement = $params['versement']; $versement = $params['versement'];
$idUser = $versement->idUser; $idUser = $versement->idUser;
$personne = $_SESSION['membresDonateurs'][$idUser]; $personne = $_SESSION['membresDonateurs'][$idUser];
$idVersement = $versement->idTarif . "_" . $versement->idUser; $idVersement = $versement->idTarif . "_" . $versement->idUser;
$out = sprintf('<h3 class="personne">Versements de %s : <span id="total_%s">0,00 €</span></h3>', $out = sprintf('<h3 class="personne">Versements de %s : <span id="total_%s">0,00 €</span></h3>',
$personne->nomPrenom, $personne->nomPrenom,
$idVersement); $idVersement);
@ -134,7 +134,7 @@ $tpl->register_function('afficher_versement', function ($params)
{ {
$versement = $params['versement']; $versement = $params['versement'];
$rang = $params['rang']; $rang = $params['rang'];
$idVersement = $versement->idTarif . "_" . $versement->idUser; $idVersement = $versement->idTarif . "_" . $versement->idUser;
$out = '<div class="'; $out = '<div class="';
$out .= ($rang%2==0) ? 'pair">' : 'impair">'; $out .= ($rang%2==0) ? 'pair">' : 'impair">';
$out .= sprintf(' $out .= sprintf('

View File

@ -24,10 +24,9 @@ foreach ($confNoms as $nom => $champ)
if ($champ->position != 0) { $champsNom[] = $nom; } if ($champ->position != 0) { $champsNom[] = $nom; }
} }
// versements totaux par personne // versements par personne
$_SESSION['lesVersementsTotaux'] = $_SESSION['lesVersements'] = Utils::getVersementsPersonnes($_SESSION['annee_recu'],
Utils::getVersementsTotaux($_SESSION['annee_recu'], $champsNom);
$champsNom);
// membres donateurs // membres donateurs
$versementsMembres = Utils::getDonateurs($_SESSION['annee_recu'], $versementsMembres = Utils::getDonateurs($_SESSION['annee_recu'],
@ -42,9 +41,64 @@ foreach ($versementsMembres as $versement) {
} }
$_SESSION['membresDonateurs'] = $membresDonateurs; $_SESSION['membresDonateurs'] = $membresDonateurs;
// ------------------------------------------------------------------------
// 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;
});
// ------------------------------------------------------------------------
// préparation de l'affichage // préparation de l'affichage
$tpl->assign('lesVersementsTotaux', $_SESSION['lesVersementsTotaux']); $tpl->assign('lesVersements', $_SESSION['lesVersements']);
$tpl->assign('lesDonateurs', $membresDonateurs);
$tpl->assign('plugin_css', ['style.css']); $tpl->assign('plugin_css', ['style.css']);
// envoyer au template // envoyer au template