<?php

namespace Paheko;

use Paheko\Plugin\RecusFiscaux\Personne;
use Paheko\Plugin\RecusFiscaux\Utils;

// vérifier si le taux de réduction a été sélectionné au préalable
$taux = f('taux_reduction');
if (! isset($_SESSION['taux_reduction'])
    &&
    null === $taux)
{
    \Paheko\Utils::redirect(\Paheko\Utils::plugin_url() . 'index.php');
}
if (null !== $taux) {
    $_SESSION['taux_reduction'] = $taux;
}

// versements par personne
$_SESSION['lesVersements'] = Utils::getVersementsPersonnes(
    $_SESSION['annee_recu'],
    'like',
    '7%',
    $champsNom);

// préparation de l'affichage
$tpl->assign('lesVersements', $_SESSION['lesVersements']);
$tpl->assign('annee_recu', $_SESSION['annee_recu']);
$tpl->assign('plugin_css', ['style.css']);

// envoyer au template
$tpl->assign('plugin_config', $plugin->getConfig());
$tpl->display(PLUGIN_ROOT . '/templates/versements_personnes.tpl');