intégration comptes
FossilOrigin-Name: d81e13438cbc9ed585e76b36e2950615b8da359697f2c577673c77460b59064d
This commit is contained in:
parent
4958b88538
commit
68e6afed11
9 changed files with 609 additions and 421 deletions
|
|
@ -64,31 +64,43 @@ $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 = sprintf('
|
||||
<details class="activite" open="open">
|
||||
<summary class="activite">
|
||||
<div class="activite">
|
||||
<input type="checkbox" id="check_%1$s"
|
||||
onclick="cocherDecocherTarif(check_%1$s)" />
|
||||
<label for="check_%1$s">
|
||||
<h3 class="activite">Activité « %2$s »</h3>',
|
||||
$idTarif,
|
||||
$activite->label);
|
||||
|
||||
if (!empty($activite->description)) {
|
||||
onclick="cocherDecocherTarif(check_%1$s)" />',
|
||||
$idTarif);
|
||||
if ($idTarif == 0) {
|
||||
// versement sur un compte non rattaché à une activité
|
||||
$out .= sprintf('
|
||||
<p class="activite">%s</p>', $activite->description);
|
||||
<label for="check_%s">
|
||||
<h3 class="activite">Versements non rattachés à une activité</h3>',
|
||||
$idTarif);
|
||||
}
|
||||
$out .= sprintf('
|
||||
else {
|
||||
$tarif = $_SESSION['lesTarifs'][$idTarif];
|
||||
$idActivite = $tarif->idActivite;
|
||||
$activite = $_SESSION['lesActivites'][$idActivite];
|
||||
|
||||
$out .= sprintf('
|
||||
<label for="check_%s">
|
||||
<h3 class="activite">Activité « %s »</h3>',
|
||||
$idTarif,
|
||||
$activite->label);
|
||||
|
||||
if (!empty($activite->description)) {
|
||||
$out .= sprintf('
|
||||
<p class="activite">%s</p>', $activite->description);
|
||||
}
|
||||
$out .= sprintf('
|
||||
<p class="activite">tarif « %s »', $tarif->label);
|
||||
if ($tarif->montant > 0) {
|
||||
$out .= sprintf(' montant : %.2f €</p>', $tarif->montant/100);
|
||||
} else {
|
||||
$out .= ' montant : libre</p>';
|
||||
if ($tarif->montant > 0) {
|
||||
$out .= sprintf(' montant : %.2f €</p>', $tarif->montant/100);
|
||||
} else {
|
||||
$out .= ' montant : libre</p>';
|
||||
}
|
||||
}
|
||||
$out .= '
|
||||
</label>
|
||||
|
|
@ -115,14 +127,25 @@ $tpl->register_function('afficher_debut_personne', function ($params)
|
|||
</label>
|
||||
</div>
|
||||
</summary>
|
||||
|
||||
<fieldset class="versements" id="versements_%1$s">',
|
||||
<div class="versements">',
|
||||
$idVersement,
|
||||
$personne->nomPrenom
|
||||
);
|
||||
return $out;
|
||||
});
|
||||
|
||||
// afficher infos compte
|
||||
$tpl->register_function('afficher_debut_compte', function ($params)
|
||||
{
|
||||
$idCompte = $params['idCompte'];
|
||||
$out = sprintf('
|
||||
<fieldset class="versements">
|
||||
<div><p>Compte N° %1$s : %2$s</p></div>',
|
||||
$_SESSION['comptes'][$idCompte]->codeCompte,
|
||||
$_SESSION['comptes'][$idCompte]->nomCompte);
|
||||
return $out;
|
||||
});
|
||||
|
||||
// afficher un versement
|
||||
$tpl->register_function('afficher_versement', function ($params)
|
||||
{
|
||||
|
|
@ -140,24 +163,34 @@ $tpl->register_function('afficher_versement', function ($params)
|
|||
name="selected[]"
|
||||
value="%2$s"
|
||||
onclick="cocherDecocherVersement(check_%1$s_%2$s, total_%1$s)" />
|
||||
<label for="check_%1$s_%2$s"><span class="montant">%3$.2f</span>
|
||||
<label for="check_%1$s_%2$s"><span class="montant">%3$s</span>
|
||||
<span>%4$s</span>
|
||||
<span>%5$s</span>
|
||||
</label>
|
||||
</div>',
|
||||
$idVersement,
|
||||
$rang,
|
||||
$versement->versement/100,
|
||||
date_format(date_create($versement->date),"d/m/Y"),
|
||||
$versement->compte
|
||||
number_format(
|
||||
$versement->versement/100,
|
||||
2,
|
||||
",",
|
||||
" "
|
||||
),
|
||||
date_format(date_create($versement->date),"d/m/Y")
|
||||
);
|
||||
return $out;
|
||||
});
|
||||
|
||||
$tpl->register_function('fin_personne', function ($params)
|
||||
$tpl->register_function('fin_compte', function ()
|
||||
{
|
||||
$out = '
|
||||
</fieldset>
|
||||
</fieldset>';
|
||||
return $out;
|
||||
});
|
||||
|
||||
$tpl->register_function('fin_personne', function ()
|
||||
{
|
||||
$out = '
|
||||
</div>
|
||||
</details>';
|
||||
return $out;
|
||||
});
|
||||
|
|
@ -175,6 +208,8 @@ $tpl->register_function('fin_tarif', function ($params)
|
|||
|
||||
if ($_GET['action'] == 'personne') {
|
||||
require('versements_personnes.php');
|
||||
} else {
|
||||
} else if ($_GET['action'] == 'compte') {
|
||||
require('versements_personnes.php');
|
||||
} else if ($_GET['action'] == 'activite') {
|
||||
require('versements_activites.php');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ if (! isset($_SESSION['annee_recu']) || $_SESSION['annee_recu'] == "")
|
|||
$_SESSION['annee_recu'] = date("Y") - 1;
|
||||
}
|
||||
|
||||
// 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
|
||||
// nombre de taux de réduction activés
|
||||
$nbTaux = 0;
|
||||
foreach ($plugin->getConfig('reduction') as $taux)
|
||||
{
|
||||
|
|
@ -23,7 +20,6 @@ foreach ($plugin->getConfig('reduction') as $taux)
|
|||
// idem avec les champs nom/prénom
|
||||
$nbChamps = 0;
|
||||
$champsNom = Utils::getChampsNom($config, $plugin);
|
||||
|
||||
if (null !== $champsNom)
|
||||
{
|
||||
foreach ($champsNom as $nom => $champ)
|
||||
|
|
@ -32,13 +28,36 @@ if (null !== $champsNom)
|
|||
}
|
||||
}
|
||||
|
||||
// comptes sur lesquels des versements de membres ont été faits
|
||||
// pendant l'année fiscale choisie
|
||||
$_SESSION['comptes'] = Utils::getComptes($_SESSION['annee_recu'], 'like', '7%');
|
||||
|
||||
// liste des activités, cotisations et comptes associés
|
||||
$activitesTarifsComptes = Utils::getActivitesTarifsEtComptes();
|
||||
$activitesTarifsComptes = Utils::getTarifsComptes($_SESSION['annee_recu'], 'like', '7%');
|
||||
$_SESSION['lesTarifs'] = Utils::getTarifs();
|
||||
$_SESSION['lesActivites'] = Utils::getActivites();
|
||||
|
||||
// liste des comptes associés à aucune activité
|
||||
$comptesSansActivite = array();
|
||||
foreach ($_SESSION['comptes'] as $id => $elem)
|
||||
{
|
||||
$trouve = false;
|
||||
foreach ($activitesTarifsComptes as $elem)
|
||||
{
|
||||
if ($id == $elem->idCompte) { $trouve = true ; break; }
|
||||
}
|
||||
if (! $trouve) { $comptesSansActivite[] = $id; }
|
||||
}
|
||||
|
||||
// préparation de l'affichage
|
||||
$tpl->assign('annee_recu', $_SESSION['annee_recu']);
|
||||
$tpl->assign('lesComptes', $_SESSION['comptes']);
|
||||
$tpl->assign('lesTarifs', $_SESSION['lesTarifs']);
|
||||
$tpl->assign('lesActivites', $_SESSION['lesActivites']);
|
||||
$tpl->assign('activitesTarifsComptes', $activitesTarifsComptes);
|
||||
$tpl->assign('comptesSansActivite', $comptesSansActivite);
|
||||
$tpl->assign('nbTarifs', count($activitesTarifsComptes));
|
||||
$tpl->assign('nbComptes', count($_SESSION['comptes']));
|
||||
$tpl->assign('plugin_config', $plugin->getConfig());
|
||||
$tpl->assign('nbTaux', $nbTaux);
|
||||
$tpl->assign('nbChamps', $nbChamps);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ summary.personne
|
|||
}
|
||||
div.activite
|
||||
{
|
||||
font-weight : normal;
|
||||
background-color: rgba(var(--gSecondColor), 0.4);
|
||||
}
|
||||
div.personne
|
||||
|
|
@ -101,3 +100,13 @@ div.infos
|
|||
margin-left : 1em;
|
||||
width : 20em;
|
||||
}
|
||||
ul#liste_activites dd
|
||||
{
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
ul.reduction span.radio-btn
|
||||
{
|
||||
margin-left : 2em;
|
||||
border-spacing : 0.1em;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,42 +7,57 @@ use Garradin\Plugin\RecusFiscaux\Personne;
|
|||
use Garradin\Plugin\RecusFiscaux\Tarif;
|
||||
use Garradin\Plugin\RecusFiscaux\Utils;
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// récupérer les infos du formulaire
|
||||
// ------------------------------------------------------------
|
||||
|
||||
// tarifs sélectionnés
|
||||
$tarifsSelectionnes = f('tarifs') ?: [];
|
||||
|
||||
// comptes sélectionnés
|
||||
$comptesSelectionnes = f('comptes') ?: [];
|
||||
|
||||
// taux de réduction associés
|
||||
$tauxSelectionnes = array();
|
||||
foreach ($tarifsSelectionnes as $idTarif) {
|
||||
foreach ($tarifsSelectionnes as $idTarif)
|
||||
{
|
||||
$nomRadio = "taux_reduction_" . $idTarif;
|
||||
$valRadio = f("$nomRadio");
|
||||
$tauxSelectionnes[$idTarif] = $valRadio;
|
||||
}
|
||||
foreach ($comptesSelectionnes as $idCompte)
|
||||
{
|
||||
$nomRadio = "taux_reduction_" . $idCompte;
|
||||
$valRadio = f("$nomRadio");
|
||||
$tauxSelectionnes[$idCompte] = $valRadio;
|
||||
}
|
||||
$_SESSION['tauxSelectionnes'] = $tauxSelectionnes;
|
||||
|
||||
// obtenir les instances de tarifs correspondant à la sélection
|
||||
$lesTarifs = array();
|
||||
foreach (Utils::getTarifs($tarifsSelectionnes) as $ot) {
|
||||
$lesTarifs[$ot->id] = $ot;
|
||||
}
|
||||
$_SESSION['lesTarifs'] = $lesTarifs;
|
||||
// versements correspondants à la sélection, triés par tarif, nom, compte, date
|
||||
$lesTarifs = array_map(fn($elem) : string => substr($elem, 0, strpos($elem, '_')),
|
||||
$tarifsSelectionnes);
|
||||
$lesComptes = array_map(fn($elem) : string => substr($elem, 1 + strpos($elem, '_')),
|
||||
$tarifsSelectionnes);
|
||||
$_SESSION['lesVersements'] =
|
||||
Utils::getVersementsTarifsComptes(
|
||||
$_SESSION['annee_recu'],
|
||||
$lesTarifs,
|
||||
$lesComptes,
|
||||
$champsNom);
|
||||
|
||||
// activités correspondants aux tarifs sélectionnés
|
||||
$lesActivites = array();
|
||||
foreach (Utils::getActivites($tarifsSelectionnes) as $activite) {
|
||||
$lesActivites[$activite->id] = $activite;
|
||||
// ajouter les versements sans tarif (tri par nom, compte, date)
|
||||
$versementsSansTarif = Utils::getVersementsComptes($_SESSION['annee_recu'],
|
||||
$comptesSelectionnes,
|
||||
$champsNom);
|
||||
foreach ($versementsSansTarif as $versement)
|
||||
{
|
||||
$_SESSION['lesVersements'][] = $versement;
|
||||
}
|
||||
$_SESSION['lesActivites'] = $lesActivites;
|
||||
|
||||
// versements correspondants aux tarifs sélectionnés
|
||||
$_SESSION['lesVersements'] = Utils::getVersementsTarifs($_SESSION['annee_recu'],
|
||||
$tarifsSelectionnes,
|
||||
$champsNom);
|
||||
|
||||
// préparation de l'affichage
|
||||
$tpl->assign('lesActivites', $lesActivites);
|
||||
$tpl->assign('lesTarifs', $lesTarifs);
|
||||
$tpl->assign('lesVersements', $_SESSION['lesVersements']);
|
||||
$tpl->assign('plugin_css', ['style.css']);
|
||||
|
||||
// envoyer au template
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/versements_activites.tpl');
|
||||
|
||||
|
|
|
|||
|
|
@ -5,81 +5,23 @@ namespace Garradin;
|
|||
use Garradin\Plugin\RecusFiscaux\Personne;
|
||||
use Garradin\Plugin\RecusFiscaux\Utils;
|
||||
|
||||
$_SESSION['taux_reduction'] = $_POST['taux_reduction'];
|
||||
// vérifier si le taux de réduction a été sélectionné au préalable
|
||||
$_SESSION['taux_reduction'] = f('taux_reduction');
|
||||
if (! isset($_SESSION['taux_reduction']) || $_SESSION['taux_reduction'] == "") {
|
||||
\Garradin\Utils::redirect(PLUGIN_URL . 'index.php');
|
||||
}
|
||||
|
||||
// versements par personne
|
||||
$_SESSION['lesVersements'] = Utils::getVersementsComptes($_SESSION['annee_recu'],
|
||||
"like",
|
||||
'7%',
|
||||
$champsNom);
|
||||
|
||||
// Utils::getVersementsPersonnes($_SESSION['annee_recu'],
|
||||
// $champsNom);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// tests
|
||||
// ------------------------------------------------------------------------
|
||||
/*
|
||||
$versementsComptes = Utils::getVersementsComptes("2021",
|
||||
// "in",
|
||||
// ['706', '7780', '756'],
|
||||
"like",
|
||||
'7%',
|
||||
$champsNom);
|
||||
// table triée par nom, date
|
||||
// error_log("versementsComptes triée par nom, date = " . print_r($versementsComptes, true));
|
||||
|
||||
// comparer 2 lignes selon le nom
|
||||
function comparerNoms($ligne1, $ligne2)
|
||||
{
|
||||
return
|
||||
$_SESSION['membresDonateurs'][$ligne1->idUser]->rang
|
||||
-
|
||||
$_SESSION['membresDonateurs'][$ligne2->idUser]->rang;
|
||||
}
|
||||
|
||||
// comparer 2 lignes selon la date
|
||||
function comparerDate($ligne1, $ligne2)
|
||||
{
|
||||
return
|
||||
strtotime($ligne1->date) - strtotime($ligne2->date);
|
||||
}
|
||||
|
||||
// comparer 2 lignes selon un champ
|
||||
function comparerChamp($ligne1, $ligne2, $champ)
|
||||
{
|
||||
return $ligne1->$champ - $ligne2->$champ;
|
||||
}
|
||||
|
||||
// autres tris
|
||||
// par tarif, nom, date
|
||||
usort($versementsComptes, function($ligne1, $ligne2)
|
||||
{
|
||||
$result = comparerChamp($ligne1, $ligne2, 'idTarif'); //$ligne1->idTarif - $ligne2->idTarif;
|
||||
if ($result == 0) { $result = comparerNoms($ligne1, $ligne2); }
|
||||
if ($result == 0) { $result = comparerDate($ligne1, $ligne2); }
|
||||
return $result;
|
||||
});
|
||||
// error_log("versementsComptes triée par tarif, nom, date = " . print_r($versementsComptes, true));
|
||||
|
||||
// par nom, compte, date...
|
||||
usort($versementsComptes, function($ligne1, $ligne2)
|
||||
{
|
||||
$result = comparerNoms($ligne1, $ligne2);
|
||||
if ($result == 0) { $result = comparerChamp($ligne1, $ligne2, 'compte'); }
|
||||
if ($result == 0) { $result = comparerDate($ligne1, $ligne2); }
|
||||
return $result;
|
||||
});
|
||||
|
||||
// error_log("versementsComptes triée par nom, compte, date = " . print_r($versementsComptes, true));
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
// fin tests
|
||||
// ------------------------------------------------------------------------
|
||||
$_SESSION['lesVersements'] = Utils::getVersementsPersonnes(
|
||||
$_SESSION['annee_recu'],
|
||||
'like',
|
||||
'7%',
|
||||
$champsNom);
|
||||
|
||||
// préparation de l'affichage
|
||||
$tpl->assign('lesVersements', $_SESSION['lesVersements']);
|
||||
$tpl->assign('plugin_css', ['style.css']);
|
||||
|
||||
// envoyer au template
|
||||
$tpl->assign('plugin_config', $plugin->getConfig());
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/versements_personnes.tpl');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue