2022-01-26 12:12:42 +01:00
|
|
|
<?php
|
|
|
|
|
2023-09-28 13:20:36 +02:00
|
|
|
namespace Paheko;
|
2022-01-26 12:12:42 +01:00
|
|
|
|
2023-09-28 13:20:36 +02:00
|
|
|
use Paheko\Plugin\RecusFiscaux\Personne;
|
|
|
|
use Paheko\Plugin\RecusFiscaux\Utils;
|
2022-01-26 12:12:42 +01:00
|
|
|
|
2022-05-18 12:29:19 +02:00
|
|
|
// ------------------------------------------------------------
|
2022-02-07 15:13:22 +01:00
|
|
|
// récupérer les infos du formulaire
|
2022-05-18 12:29:19 +02:00
|
|
|
// ------------------------------------------------------------
|
|
|
|
|
2023-02-04 16:32:03 +01:00
|
|
|
// vérifier qu'on a bien sélectionné une activité ou un compte
|
|
|
|
if (! isset($_SESSION['tauxSelectionnes'])
|
|
|
|
&&
|
|
|
|
null === f('tarifs')
|
|
|
|
&&
|
|
|
|
null === f('comptes'))
|
2022-05-20 21:42:57 +02:00
|
|
|
{
|
2023-11-10 12:31:18 +01:00
|
|
|
\Paheko\Utils::redirect(\Paheko\Utils::plugin_url() . 'index.php');
|
2022-05-20 21:42:57 +02:00
|
|
|
}
|
|
|
|
|
2022-05-18 12:29:19 +02:00
|
|
|
// tarifs sélectionnés
|
2023-02-04 16:32:03 +01:00
|
|
|
if (null !== f('tarifs')) {
|
|
|
|
$tarifsSelectionnes = f('tarifs');
|
|
|
|
} else if (! isset($_SESSION['tauxSelectionnes'])) {
|
|
|
|
$tarifsSelectionnes = [];
|
|
|
|
}
|
2023-11-10 12:31:18 +01:00
|
|
|
// error_log("\ntarifsSelectionnes=" . print_r($tarifsSelectionnes, true));
|
2022-05-18 12:29:19 +02:00
|
|
|
// comptes sélectionnés
|
2023-02-04 16:32:03 +01:00
|
|
|
if (null !== f('comptes')) {
|
|
|
|
$_SESSION['comptesSelectionnes'] = f('comptes');
|
2023-11-10 12:31:18 +01:00
|
|
|
// error_log("\ncomptesSelectionnes=" . print_r($_SESSION['comptesSelectionnes'], true));
|
2023-02-04 16:32:03 +01:00
|
|
|
} /*
|
|
|
|
else if (! isset($_SESSION['tauxSelectionnes'])) {
|
|
|
|
$_SESSION['comptesSelectionnes'] = [];
|
|
|
|
}
|
|
|
|
*/
|
2022-05-18 12:29:19 +02:00
|
|
|
|
2022-02-07 14:32:17 +01:00
|
|
|
// taux de réduction associés
|
2023-04-05 14:45:24 +02:00
|
|
|
$tauxSelectionnes = array();
|
|
|
|
if (isset($tarifsSelectionnes))
|
2022-05-18 12:29:19 +02:00
|
|
|
{
|
2023-02-04 16:32:03 +01:00
|
|
|
foreach ($tarifsSelectionnes as $idTarif)
|
|
|
|
{
|
|
|
|
$nomRadio = "taux_reduction_" . $idTarif;
|
|
|
|
$tauxSelectionnes[$idTarif] = f("$nomRadio");
|
|
|
|
}
|
2023-04-05 14:45:24 +02:00
|
|
|
}
|
|
|
|
if (isset($_SESSION['comptesSelectionnes']))
|
|
|
|
{
|
2023-02-04 16:32:03 +01:00
|
|
|
foreach ($_SESSION['comptesSelectionnes'] as $idCompte)
|
|
|
|
{
|
|
|
|
$nomRadio = "taux_reduction_" . $idCompte;
|
|
|
|
$tauxSelectionnes[$idCompte] = f("$nomRadio");
|
|
|
|
}
|
2022-02-10 17:05:24 +01:00
|
|
|
}
|
2023-04-05 14:45:24 +02:00
|
|
|
$_SESSION['tauxSelectionnes'] = $tauxSelectionnes;
|
2022-02-07 14:32:17 +01:00
|
|
|
|
2023-04-07 11:38:25 +02:00
|
|
|
$lesTarifs = array_map(fn($elem) : string =>
|
|
|
|
strpos($elem, '_') !== false ? substr($elem, 0, strpos($elem, '_')) : "",
|
|
|
|
$tarifsSelectionnes);
|
|
|
|
$lesComptes = array_map(fn($elem) : string =>
|
|
|
|
strpos($elem, '_') !== false ? substr($elem, 1 + strpos($elem, '_')) : "",
|
|
|
|
$tarifsSelectionnes);
|
|
|
|
|
2023-04-06 18:16:46 +02:00
|
|
|
# versements des tarifs sélectionnées et de leur compte associé
|
2023-04-08 10:44:31 +02:00
|
|
|
if (count($lesTarifs) != 0)
|
|
|
|
{
|
|
|
|
$_SESSION['lesVersements'] =
|
2022-05-18 12:29:19 +02:00
|
|
|
Utils::getVersementsTarifsComptes(
|
|
|
|
$_SESSION['annee_recu'],
|
2023-04-07 11:38:25 +02:00
|
|
|
$lesTarifs,
|
|
|
|
$lesComptes,
|
2022-05-18 12:29:19 +02:00
|
|
|
$champsNom);
|
2023-11-10 12:31:18 +01:00
|
|
|
// error_log("lesVersements=" . print_r($_SESSION['lesVersements'], true));
|
2023-04-08 10:44:31 +02:00
|
|
|
}
|
2022-05-18 12:29:19 +02:00
|
|
|
|
|
|
|
// ajouter les versements sans tarif (tri par nom, compte, date)
|
2023-04-05 14:45:24 +02:00
|
|
|
if (isset($_SESSION['comptesSelectionnes']))
|
2022-05-18 12:29:19 +02:00
|
|
|
{
|
2023-04-05 14:45:24 +02:00
|
|
|
$versementsSansTarif = Utils::getVersementsComptes($_SESSION['annee_recu'],
|
|
|
|
$_SESSION['comptesSelectionnes'],
|
|
|
|
$champsNom);
|
|
|
|
foreach ($versementsSansTarif as $versement)
|
|
|
|
{
|
|
|
|
$_SESSION['lesVersements'][] = $versement;
|
|
|
|
}
|
2022-02-10 17:05:24 +01:00
|
|
|
}
|
2023-11-10 12:31:18 +01:00
|
|
|
//error_log("lesVersements=" . print_r($_SESSION['lesVersements'], true));
|
2023-09-28 11:08:46 +02:00
|
|
|
|
2022-01-26 12:12:42 +01:00
|
|
|
// préparation de l'affichage
|
|
|
|
$tpl->assign('lesVersements', $_SESSION['lesVersements']);
|
2023-02-04 16:32:03 +01:00
|
|
|
$tpl->assign('annee_recu', $_SESSION['annee_recu']);
|
2022-01-26 12:12:42 +01:00
|
|
|
$tpl->assign('plugin_css', ['style.css']);
|
|
|
|
|
|
|
|
// envoyer au template
|
2022-01-29 15:03:41 +01:00
|
|
|
$tpl->display(PLUGIN_ROOT . '/templates/versements_activites.tpl');
|
2022-05-18 12:29:19 +02:00
|
|
|
|