fusion branche dev

FossilOrigin-Name: a6a3f6587f6e2d271f439c11230a84a263b03383d2d9842472102dbd88fb2ac5
This commit is contained in:
engel 2022-05-21 08:02:48 +00:00
commit 3347ca7743
20 changed files with 924 additions and 599 deletions

View file

@ -49,6 +49,9 @@ elseif ($nbArticles > 1)
}
}
// libellés pour les taux de réduction
$libelles_taux = Utils::getLignesReduction($plugin->getConfig('reduction'));
// filtrer les versements sélectionnés
$lesLignes = f('selected');
$versementsSelectionnes = array();
@ -88,19 +91,20 @@ foreach ($totalPersonnes as $idPersonne => $personne)
// les versements
$tpl->registerSection('versements',
function () use($personne)
function () use($personne, $libelles_taux)
{
foreach ($personne->versements as $taux => $montant)
foreach ($personne->versements as $taux => $versement)
{
$ligne['montant'] = $montant;
$ligne['libelle'] = Utils::getLigneReduction($taux);
$ligne['montant'] = $versement->montant;
$ligne['libelle'] = $libelles_taux[$taux];
$ligne['dateMin'] = date("d/m/Y", $versement->dateMin);
$ligne['dateMax'] = date("d/m/Y", $versement->dateMax);
yield $ligne;
}
});
// mentions complémentaires
$donnees = array(
'Date des versements : ' => "année " . $_SESSION['annee_recu'],
'Nature du don : ' => "Numéraire",
'Mode de versement : ' => "chèque et/ou virement"
);
@ -150,6 +154,12 @@ $fichierZip = Utils::makeArchive(
// unlink($f);
// }
//supprimer les fichiers pdf (utile ?)
// foreach ($listeFichiersPDF as $f)
// {
// unlink($f);
// }
/**
* Cumuler les versements de chaque personne
* @param tableau des versements triés par idUser, date
@ -159,6 +169,8 @@ function cumulerVersementsPersonne($versements)
{
$totalPersonnes = array();
$idPersonneCourant = -1;
$dateMin = PHP_INT_MAX;
$dateMax = -1;
$totalVersements = 0;
foreach ($versements as $ligne)
{
@ -169,9 +181,13 @@ function cumulerVersementsPersonne($versements)
{
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
$_SESSION['taux_reduction'],
$totalVersements
$totalVersements,
$dateMin,
$dateMax
);
}
$dateMin = strtotime($ligne->date);
$dateMax = strtotime($ligne->date);
$idPersonneCourant = $ligne->idUser;
$totalVersements = $ligne->versement;
// créer les infos de la personne, sauf si elle est déjà présente
@ -180,14 +196,18 @@ function cumulerVersementsPersonne($versements)
$totalPersonnes["$idPersonneCourant"] = $_SESSION['membresDonateurs'][$ligne->idUser]->clone();
}
} else {
// cumuler versements
// même personne : cumuler versements et mettre à jour les dates
$totalVersements += $ligne->versement;
if (strtotime($ligne->date) < $dateMin) { $dateMin = strtotime($ligne->date); }
if (strtotime($ligne->date) > $dateMax) { $dateMax = strtotime($ligne->date); }
}
}
// et le dernier
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
$_SESSION['taux_reduction'],
$totalVersements
$totalVersements,
$dateMin,
$dateMax
);
return $totalPersonnes;
}
@ -202,39 +222,58 @@ function cumulerVersementsTarif($versements)
$totalPersonnes = array();
$idTarifCourant = -1;
$idPersonneCourant = -1;
$idCompteCourant = -1;
$dateMin = PHP_INT_MAX;
$dateMax = -1;
$totalVersements = 0;
foreach ($versements as $ligne)
{
if (
$ligne->idTarif != $idTarifCourant ||
$ligne->idUser != $idPersonneCourant
$ligne->idTarif != $idTarifCourant ||
$ligne->idUser != $idPersonneCourant ||
$ligne->idCompte != $idCompteCourant
)
{
if ($idTarifCourant != -1)
{
// changement de tarif ou de personne
// changement de tarif, de personne ou de compte
$tarifCompte = ($idTarifCourant == 0) ?
$idCompteCourant :
$idTarifCourant . "_" . $idCompteCourant;
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
$_SESSION['tauxSelectionnes'][$idTarifCourant],
$totalVersements
$_SESSION['tauxSelectionnes'][$tarifCompte],
$totalVersements,
$dateMin,
$dateMax
);
}
$idTarifCourant = $ligne->idTarif;
$dateMin = strtotime($ligne->date);
$dateMax = strtotime($ligne->date);
$idTarifCourant = $ligne->idTarif;
$idPersonneCourant = $ligne->idUser;
$totalVersements = $ligne->versement;
$idCompteCourant = $ligne->idCompte;
$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]->clone();
}
} else {
// cumuler versements
// même personne : cumuler versements et mettre à jour les dates
$totalVersements += $ligne->versement;
if (strtotime($ligne->date) < $dateMin) { $dateMin = strtotime($ligne->date); }
if (strtotime($ligne->date) > $dateMax) { $dateMax = strtotime($ligne->date); }
}
}
// et le dernier
$tarifCompte = ($idTarifCourant == 0) ?
$idCompteCourant :
$idTarifCourant . "_" . $idCompteCourant;
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
$_SESSION['tauxSelectionnes'][$idTarifCourant],
$totalVersements
$_SESSION['tauxSelectionnes'][$tarifCompte],
$totalVersements,
$dateMin,
$dateMax
);
return $totalPersonnes;
}