fusion branche evolution : version compatible paheko 1.3
FossilOrigin-Name: 0c32e638c1e3aa705a7b1b4b48ffda7c7decf74bcd4af9f2257edd9e480f08de
This commit is contained in:
commit
4fd56bf12d
30 changed files with 1079 additions and 994 deletions
217
admin/action.php
Normal file
217
admin/action.php
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
<?php
|
||||
|
||||
namespace Paheko;
|
||||
session_start();
|
||||
|
||||
use Paheko\Plugin\RecusFiscaux\Utils;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// opérations communes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// champs pour le nom et prénom
|
||||
$confNoms = Utils::getChampsNom($config, $plugin);
|
||||
uasort($confNoms, function ($a, $b)
|
||||
{
|
||||
return $a->position - $b->position;
|
||||
});
|
||||
$champsNom = array();
|
||||
foreach ($confNoms as $nom => $champ)
|
||||
{
|
||||
if ($champ->position != 0) { $champsNom[] = $nom; }
|
||||
}
|
||||
|
||||
// membres donateurs
|
||||
$_SESSION['membresDonateurs'] = Utils::getDonateurs($_SESSION['annee_recu'],
|
||||
$champsNom);
|
||||
|
||||
// comparaison de lignes de versements
|
||||
// comparer 2 lignes selon le nom
|
||||
function comparerNoms($ligne1, $ligne2)
|
||||
{
|
||||
return
|
||||
$_SESSION['membresDonateurs'][$ligne1->idUser]->rang
|
||||
-
|
||||
$_SESSION['membresDonateurs'][$ligne2->idUser]->rang;
|
||||
}
|
||||
|
||||
// comparer 2 activités par leur libellé
|
||||
function comparerActivites($ligne1, $ligne2)
|
||||
{
|
||||
return strcoll(
|
||||
$_SESSION['lesActivites'][$_SESSION['lesTarifs'][$ligne1->idTarif]->idActivite]->label,
|
||||
$_SESSION['lesActivites'][$_SESSION['lesTarifs'][$ligne2->idTarif]->idActivite]->label);
|
||||
}
|
||||
|
||||
// comparer 2 lignes selon la date
|
||||
function comparerDate($ligne1, $ligne2)
|
||||
{
|
||||
return
|
||||
strtotime($ligne1->date) - strtotime($ligne2->date);
|
||||
}
|
||||
|
||||
// comparer 2 lignes selon un champ numérique entier
|
||||
function comparerChamp($ligne1, $ligne2, $champ)
|
||||
{
|
||||
return $ligne1->$champ - $ligne2->$champ;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// fonctions pour l'affichage
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// afficher les informations d'une activité et d'un tarif
|
||||
$tpl->register_function('afficher_debut_tarif', function ($params)
|
||||
{
|
||||
$versement = $params['versement'];
|
||||
$idTarif = $versement->idTarif;
|
||||
|
||||
$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)" />',
|
||||
$idTarif);
|
||||
if ($idTarif == 0) {
|
||||
// versement sur un compte non rattaché à une activité
|
||||
$out .= sprintf('
|
||||
<label for="check_%s">
|
||||
<h3 class="activite">Versements non rattachés à une activité</h3>',
|
||||
$idTarif);
|
||||
}
|
||||
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>';
|
||||
}
|
||||
}
|
||||
$out .= '
|
||||
</label>
|
||||
</div>
|
||||
</summary>';
|
||||
return $out;
|
||||
});
|
||||
|
||||
// Afficher les informations d'une personne
|
||||
$tpl->register_function('afficher_debut_personne', function ($params)
|
||||
{
|
||||
$idUser = $params['user'];
|
||||
$idVersement = $params['idVersement'];
|
||||
|
||||
$personne = $_SESSION['membresDonateurs'][$idUser];
|
||||
$out = sprintf('
|
||||
<details class="personne" open="open">
|
||||
<summary class="personne">
|
||||
<div class="personne">
|
||||
<input type="checkbox" id="check_%1$s"
|
||||
onclick="cocherDecocherPersonne(check_%1$s, total_%1$s)" />
|
||||
<label for="check_%1$s">
|
||||
%2$s : <span class="total" id="total_%1$s">0,00 €</span>
|
||||
</label>
|
||||
</div>
|
||||
</summary>
|
||||
<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)
|
||||
{
|
||||
$versement = $params['versement'];
|
||||
$idVersement = $params['idVersement'];
|
||||
$rang = $params['rang'];
|
||||
$pair = $params['pair'];
|
||||
|
||||
$out = '<div class="';
|
||||
$out .= $pair ? 'pair">' : 'impair">';
|
||||
$out .= sprintf('
|
||||
<input type="checkbox"
|
||||
class="check_%1$s"
|
||||
id="check_%1$s_%2$s"
|
||||
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$s</span>
|
||||
<span>%4$s</span>
|
||||
</label>
|
||||
</div>',
|
||||
$idVersement,
|
||||
$rang,
|
||||
number_format(
|
||||
$versement->versement/100,
|
||||
2,
|
||||
",",
|
||||
" "
|
||||
),
|
||||
date_format(date_create($versement->date),"d/m/Y")
|
||||
);
|
||||
return $out;
|
||||
});
|
||||
|
||||
$tpl->register_function('fin_compte', function ()
|
||||
{
|
||||
$out = '
|
||||
</fieldset>';
|
||||
return $out;
|
||||
});
|
||||
|
||||
$tpl->register_function('fin_personne', function ()
|
||||
{
|
||||
$out = '
|
||||
</div>
|
||||
</details>';
|
||||
return $out;
|
||||
});
|
||||
|
||||
$tpl->register_function('fin_tarif', function ($params)
|
||||
{
|
||||
$out = '
|
||||
</details>';
|
||||
return $out;
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// aiguillage
|
||||
// ------------------------------------------------------------------------
|
||||
unset($_SESSION['comptesSelectionnes']);
|
||||
unset($_SESSION['tauxSelectionnes']);
|
||||
unset($_SESSION['lesVersements']);
|
||||
|
||||
if ($_GET['action'] == 'personne') {
|
||||
require('versements_personnes.php');
|
||||
} else if ($_GET['action'] == 'activite') {
|
||||
require('versements_activites.php');
|
||||
}
|
||||
24
admin/choix_annee.php
Normal file
24
admin/choix_annee.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Paheko;
|
||||
session_start();
|
||||
|
||||
use Paheko\Plugin\RecusFiscaux\Utils;
|
||||
|
||||
// liste des années fiscales
|
||||
$anneeCourante = date("Y");
|
||||
$anneesFiscales = Utils::getAnneesFiscales();
|
||||
if ($anneesFiscales[0] < $anneeCourante) {
|
||||
array_unshift($anneesFiscales, $anneeCourante);
|
||||
}
|
||||
|
||||
$csrf_key = 'acc_select_year';
|
||||
$form->runIf('change', function () {
|
||||
$_SESSION['annee_recu'] = f('annee_recu');
|
||||
}, $csrf_key, PLUGIN_ROOT . '/admin/index.php');
|
||||
|
||||
$tpl->assign(compact('anneesFiscales', 'csrf_key'));
|
||||
|
||||
$tpl->assign('annee_recu', $_SESSION['annee_recu']);
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/choix_annee.tpl');
|
||||
123
admin/config.php
Normal file
123
admin/config.php
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
namespace Paheko;
|
||||
session_start();
|
||||
|
||||
use Paheko\Files\Files;
|
||||
use Paheko\Entities\Files\File;
|
||||
use Paheko\Plugin\RecusFiscaux\Utils;
|
||||
|
||||
$session->requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN);
|
||||
|
||||
// récupérer les champs des noms
|
||||
$champsNom = Utils::getChampsNom($config, $plugin);
|
||||
|
||||
$csrf_key = 'recusfiscaux_config';
|
||||
|
||||
$form->runIf('save', function () use ($plugin, $champsNom) {
|
||||
// Objet de l'asso
|
||||
$plugin->setConfigProperty('objet_asso', trim(f('objet_asso')));
|
||||
|
||||
// Articles du CGI
|
||||
$confArticles = $plugin->getConfig('articlesCGI');
|
||||
// effacer l'ancienne configuration
|
||||
for ($i = 0; $i < count($confArticles); ++$i) {
|
||||
$confArticles[$i]->valeur = false;
|
||||
}
|
||||
// et copier la nouvelle
|
||||
$art_sel = f('articlesCGI') ?: [];
|
||||
foreach ($art_sel as $article) {
|
||||
$confArticles[$article]->valeur = true;
|
||||
}
|
||||
$plugin->setConfigProperty('articlesCGI', $confArticles);
|
||||
|
||||
// Taux de réduction
|
||||
$confTaux = $plugin->getConfig('reduction');
|
||||
// effacer l'ancienne configuration
|
||||
for ($i = 0; $i < count($confTaux); ++$i) {
|
||||
$confTaux[$i]->valeur = false;
|
||||
}
|
||||
// et copier la nouvelle
|
||||
$taux_sel = f('tauxReduction') ?: [];
|
||||
foreach ($taux_sel as $taux) {
|
||||
$confTaux[$taux]->valeur = true;
|
||||
}
|
||||
$plugin->setConfigProperty("reduction", $confTaux);
|
||||
|
||||
// Informations au sujet du responsable
|
||||
$plugin->setConfigProperty('nom_responsable', trim(f('nom_responsable') ?: '') ?: null);
|
||||
$plugin->setConfigProperty('fonction_responsable', trim(f('fonction_responsable') ?: '') ?: null);
|
||||
$plugin->setConfigProperty('ville_asso', trim(f('ville_asso') ?: '') ?: null);
|
||||
|
||||
// signature
|
||||
if (isset($_SESSION['sig_file']) && count($_SESSION['sig_file']) > 0) {
|
||||
// supprimer la signature précédente, si besoin
|
||||
if (
|
||||
null !== $plugin->getConfig('signature')
|
||||
&&
|
||||
$plugin->getConfig('signature') != $_SESSION['sig_file'][0]->path
|
||||
) {
|
||||
$sig_file = \Paheko\Files\Files::get($plugin->getConfig('signature'));
|
||||
if (null !== $sig_file) {
|
||||
$sig_file->delete();
|
||||
}
|
||||
}
|
||||
// puis installer la nouvelle
|
||||
$plugin->setConfigProperty('signature', $_SESSION['sig_file'][0]->path);
|
||||
}
|
||||
|
||||
// Numérotation des reçus
|
||||
$configNum = $plugin->getConfig('numerotation');
|
||||
$formNum = clone $configNum;
|
||||
if ($configNum->prefixe != trim(f('prefixe'))) {
|
||||
$formNum->prefixe = trim(f('prefixe'));
|
||||
}
|
||||
$formNum->annee = f('annee');
|
||||
$formNum->membre = f('membre');
|
||||
$formNum->sequentiel = f('sequentiel');
|
||||
$formNum->valeur_init = f('valeur_init');
|
||||
$plugin->setConfigProperty('numerotation', $formNum);
|
||||
|
||||
// Impression des adresses de courriel
|
||||
$plugin->setConfigProperty('imprimerCourriel', trim(f('imprimerCourriel') ?: '') ?: null);
|
||||
|
||||
// champs pour le nom et prénom
|
||||
foreach ($champsNom as $nom => $champ) {
|
||||
$champ->position = 0;
|
||||
}
|
||||
$noms_sel = f('champsNom') ?: [];
|
||||
$i = -count($noms_sel);
|
||||
foreach ($noms_sel as $nom) {
|
||||
$champsNom[$nom]->position = $i++;
|
||||
}
|
||||
$plugin->setConfigProperty('champsNom', $champsNom);
|
||||
|
||||
// enregistrer la nouvelle config
|
||||
$plugin->save();
|
||||
}, $csrf_key, PLUGIN_ADMIN_URL . 'config.php?ok');
|
||||
|
||||
|
||||
// test fonctions fichiers : voir files.sor
|
||||
// $fichiers = Files::list('config');
|
||||
// error_log("fichiers config = " . print_r($fichiers, true));
|
||||
// $fichiers = Files::list('ext/recusfiscaux');
|
||||
// error_log("fichiers ext/recusfiscaux = " . print_r($fichiers, true));
|
||||
$sig_file = Files::get('ext/recusfiscaux/default_signature.png');
|
||||
// error_log("sig_file = " . print_r($sig_file, true));
|
||||
|
||||
//error_log("config.php::config=" . print_r($plugin->getConfig(), true));
|
||||
|
||||
|
||||
// trier les champs de nom pour l'affichage
|
||||
uasort($champsNom, function ($a, $b) {
|
||||
return $a->position - $b->position;
|
||||
});
|
||||
|
||||
$path = qg('path') ?: File::CONTEXT_CONFIG;
|
||||
$tpl->assign('default_signature', '/' . 'ext/recusfiscaux/default_signature.png');
|
||||
// $tpl->assign('default_signature', \Paheko\WWW_URL . "plugin/recusfiscaux/default_signature.png");
|
||||
$tpl->assign('plugin_config', $plugin->getConfig());
|
||||
$tpl->assign('plugin_css', ['style.css']);
|
||||
$tpl->assign('numerotation', $plugin->getConfig('numerotation'));
|
||||
$tpl->assign(compact('csrf_key', 'path', 'champsNom'));
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');
|
||||
475
admin/generer_recus.php
Normal file
475
admin/generer_recus.php
Normal file
|
|
@ -0,0 +1,475 @@
|
|||
<?php
|
||||
|
||||
namespace Paheko;
|
||||
session_start();
|
||||
|
||||
use Paheko\Files\Files;
|
||||
use Paheko\Entities\Files\File;
|
||||
use Paheko\UserTemplate\UserTemplate;
|
||||
|
||||
use Paheko\Plugin\RecusFiscaux\Utils;
|
||||
use Paheko\Plugin\RecusFiscaux\Personne;
|
||||
|
||||
// forcer mode dialog pour ouvrir le squelette des reçus dans un nouvel onglet
|
||||
// à combiner avec target="_blank" ou target="_dialog" dans le fichier tpl
|
||||
$_GET['_dialog'] = true;
|
||||
|
||||
// signature
|
||||
$signature =
|
||||
(null !== $config->fileURL('signature')) ?
|
||||
$config->fileURL('signature') :
|
||||
((null !== $plugin->getConfig('signature')) ?
|
||||
\KD2\HTTP::getScheme() . '://' . \KD2\HTTP::getHost() . WWW_URI . $plugin->getConfig('signature') :
|
||||
"");
|
||||
|
||||
// http://test.paheko.bzh/config/cavalier.png
|
||||
error_log('signature = ' . $signature);
|
||||
// logo
|
||||
$config = Config::getInstance();
|
||||
$logo_asso =
|
||||
(null !== $config->fileURL('logo')) ?
|
||||
$config->fileURL('logo') :
|
||||
"";
|
||||
|
||||
// articles du CGI
|
||||
$articlesCGI = array();
|
||||
foreach ($plugin->getConfig('articlesCGI') as $article) {
|
||||
if ($article->valeur == 1) {
|
||||
$articlesCGI[] = $article->titre;
|
||||
}
|
||||
}
|
||||
$nbArticles = count($articlesCGI);
|
||||
if ($nbArticles == 1) {
|
||||
$texteArticles = 'à l’article ' . $articlesCGI[0];
|
||||
} elseif ($nbArticles > 1) {
|
||||
$texteArticles = 'aux articles ';
|
||||
for ($i = 0; $i < $nbArticles; ++$i) {
|
||||
$texteArticles .= $articlesCGI[$i];
|
||||
if ($i < $nbArticles - 2) {
|
||||
$texteArticles .= ", ";
|
||||
} else if ($i == $nbArticles - 2) {
|
||||
$texteArticles .= " et ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// libellés pour les taux de réduction
|
||||
$libelles_taux = Utils::getLignesReduction($plugin->getConfig('reduction'));
|
||||
|
||||
// numérotation des reçus
|
||||
$configNum = $plugin->getConfig('numerotation');
|
||||
|
||||
// filtrer les versements sélectionnés
|
||||
$lesLignes = f('selected');
|
||||
$versementsSelectionnes = array();
|
||||
foreach ($lesLignes as $ligne) {
|
||||
$versementsSelectionnes[] = $_SESSION['lesVersements'][$ligne];
|
||||
}
|
||||
|
||||
// cumuler les versements
|
||||
if ($_GET['type'] == 'personne') {
|
||||
$totalPersonnes = cumulerVersementsPersonne($versementsSelectionnes);
|
||||
} elseif ($_GET['type'] == 'activite') {
|
||||
$totalPersonnes = cumulerVersementsTarif($versementsSelectionnes);
|
||||
}
|
||||
|
||||
// générer les reçus
|
||||
if ($_GET['format'] == 'pdf') {
|
||||
genererRecusPDF($totalPersonnes,
|
||||
$signature,
|
||||
$logo_asso,
|
||||
$texteArticles,
|
||||
$plugin,
|
||||
$configNum,
|
||||
$libelles_taux
|
||||
);
|
||||
} else if ($_GET['format'] == 'print') {
|
||||
generererRecusHTML($tpl,
|
||||
$totalPersonnes,
|
||||
$signature,
|
||||
$logo_asso,
|
||||
$texteArticles,
|
||||
$plugin,
|
||||
$configNum,
|
||||
$libelles_taux
|
||||
);
|
||||
} else {
|
||||
// Erreur : format inconnu ; ne devrait pas se produire
|
||||
}
|
||||
|
||||
function genererRecusPDF($totalPersonnes,
|
||||
$signature,
|
||||
$logo_asso,
|
||||
$texteArticles,
|
||||
$plugin,
|
||||
$configNum,
|
||||
$libelles_taux
|
||||
)
|
||||
{
|
||||
// <TEST>
|
||||
$fichierHTML = sprintf('%s/print-%s.html', CACHE_ROOT, md5(random_bytes(16)));
|
||||
// </TEST>
|
||||
$listeFichiersPDF = array();
|
||||
$fmt = new \NumberFormatter('fr_FR', \NumberFormatter::SPELLOUT);
|
||||
$prefixeNum = getNumPrefixe($configNum);
|
||||
$numero_sequentiel = getNumSequentiel($configNum);
|
||||
foreach ($totalPersonnes as $idPersonne => $personne) {
|
||||
$tpl = new UserTemplate(null);
|
||||
/* $tpl->setSource(PLUGIN_ROOT . '/templates/recu.skel'); */
|
||||
$tpl->setSourcePath(PLUGIN_ROOT . '/templates/recu.skel');
|
||||
|
||||
$tpl->assignArray(compact('signature', 'logo_asso', 'texteArticles'));
|
||||
$tpl->assign('objet_asso', $plugin->getConfig('objet_asso'));
|
||||
$tpl->assign('nom_responsable', $plugin->getConfig('nom_responsable'));
|
||||
$tpl->assign('fonction_responsable', $plugin->getConfig('fonction_responsable'));
|
||||
$tpl->assign('ville_asso', $plugin->getConfig('ville_asso'));
|
||||
$tpl->assign('nom', $personne->nomPrenom);
|
||||
$tpl->assign('adresse', $personne->adresse);
|
||||
$tpl->assign('code_postal', $personne->codePostal);
|
||||
$tpl->assign('ville', $personne->ville);
|
||||
$tpl->assign('date', date("j/m/Y"));
|
||||
|
||||
// numéro de reçu
|
||||
$tpl->assign('numero',
|
||||
faireNumeroRecu($prefixeNum,
|
||||
$configNum->membre,
|
||||
$personne->numero,
|
||||
$numero_sequentiel));
|
||||
|
||||
// adresse de courriel
|
||||
if ($plugin->getConfig('imprimerCourriel')) {
|
||||
$courriel = $personne->courriel;
|
||||
} else {
|
||||
$courriel = "";
|
||||
}
|
||||
$tpl->assign('courriel', $courriel);
|
||||
|
||||
// les versements
|
||||
$tpl->registerSection(
|
||||
'versements',
|
||||
function () use ($personne, $libelles_taux, $fmt) {
|
||||
foreach ($personne->versements as $taux => $versement) {
|
||||
$ligne['montant'] = $versement->montant;
|
||||
$ligne['euros'] = $fmt->format((int)($versement->montant / 100));
|
||||
if ($versement->montant % 100 != 0) {
|
||||
$ligne['cents'] = $fmt->format($versement->montant % 100);
|
||||
} else {
|
||||
$ligne['cents'] = "";
|
||||
}
|
||||
$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
|
||||
$complements = mentionsComplémentaires();
|
||||
|
||||
$tpl->registerSection(
|
||||
'informations',
|
||||
function () use ($complements) {
|
||||
foreach ($complements as $elem) {
|
||||
yield (array) $elem;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// <TEST>
|
||||
// récupérer les reçus au format html
|
||||
$recuHTML = $tpl->fetch();
|
||||
// enregistrer dans le fichier
|
||||
file_put_contents($fichierHTML, $recuHTML, FILE_APPEND);
|
||||
// </TEST>
|
||||
|
||||
// fabriquer le fichier PDF
|
||||
genererPDF($tpl->fetch(), $personne->nomPrenom, $listeFichiersPDF);
|
||||
}
|
||||
|
||||
// afficher dans un dialog
|
||||
//marche pas
|
||||
// printf('
|
||||
// <dialog id="dialog" open="" style="" class="loaded">
|
||||
// <button class="icn-btn closeBtn" data-icon="✘" type="button">Fermer
|
||||
// </button>
|
||||
// <iframe src="%s" name="dialog" id="frameDialog" scrolling="yes" data-height="%s" style="height: %s;" width="0" height="0">
|
||||
// </iframe>
|
||||
// </dialog>
|
||||
// ', $fichierHTML, "90%", "90%");
|
||||
|
||||
// affiche une page vide
|
||||
// $link = "<script>window.open('$fichierHTML', '_blank')</script>";
|
||||
// echo $link;
|
||||
|
||||
// faire une archive zip
|
||||
$fichierZip = Utils::makeArchive(
|
||||
$listeFichiersPDF,
|
||||
$_SESSION['annee_recu'],
|
||||
PLUGIN_ROOT . "/zip"
|
||||
);
|
||||
|
||||
//supprimer les fichiers pdf
|
||||
// foreach ($listeFichiersPDF as $f) {
|
||||
// \Paheko\Utils::safe_unlink($f);
|
||||
// }
|
||||
} // genererRecusPDF
|
||||
|
||||
function generererRecusHTML($tpl,
|
||||
$totalPersonnes,
|
||||
$signature,
|
||||
$logo_asso,
|
||||
$texteArticles,
|
||||
$plugin,
|
||||
$configNum,
|
||||
$libelles_taux
|
||||
)
|
||||
{
|
||||
$tpl->register_function('afficher_numero_recu', function($params)
|
||||
{
|
||||
$prefixeNum = $params['prefixe'];
|
||||
$membre = $params['membre'];
|
||||
$numero_personne = $params['numero_personne'];
|
||||
$numero_sequentiel = $params['numero_sequentiel'];
|
||||
$numero = faireNumeroRecu($prefixeNum,
|
||||
$membre,
|
||||
$numero_personne,
|
||||
$numero_sequentiel);
|
||||
$out = sprintf('
|
||||
<p class="important">Reçu %s</p>',
|
||||
$numero
|
||||
);
|
||||
return $out;
|
||||
});
|
||||
|
||||
$tpl->assign(compact(
|
||||
'totalPersonnes',
|
||||
'logo_asso',
|
||||
'signature',
|
||||
'libelles_taux',
|
||||
'texteArticles'
|
||||
));
|
||||
$tpl->assign('prefixeNum', getNumPrefixe($configNum));
|
||||
$tpl->assign('membre', $configNum->membre);
|
||||
$tpl->assign('numero_sequentiel', getNumSequentiel($configNum));
|
||||
$tpl->assign('org_name', Config::getInstance()->get('org_name'));
|
||||
$tpl->assign('org_address', Config::getInstance()->get('org_address'));
|
||||
$tpl->assign('objet_asso', $plugin->getConfig('objet_asso'));
|
||||
$tpl->assign('courriel', $plugin->getConfig('imprimerCourriel'));
|
||||
$tpl->assign('complements', mentionsComplémentaires());
|
||||
$tpl->assign('ville_asso', $plugin->getConfig('ville_asso'));
|
||||
$tpl->assign('date', date("j/m/Y"));
|
||||
$tpl->assign('nom_responsable', $plugin->getConfig('nom_responsable'));
|
||||
$tpl->assign('fonction_responsable', $plugin->getConfig('fonction_responsable'));
|
||||
|
||||
$tpl->assign('plugin_css', ['previs_recu.css', 'imprimer_recu.css']);
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/recu_html.tpl');
|
||||
} // generererRecusHTML
|
||||
|
||||
/**
|
||||
* Cumuler les versements de chaque personne
|
||||
* @param tableau des versements triés par idUser, date
|
||||
* @return tableau des versements cumulés : id => Personne
|
||||
*/
|
||||
function cumulerVersementsPersonne($versements)
|
||||
{
|
||||
$totalPersonnes = array();
|
||||
$idPersonneCourant = -1;
|
||||
$dateMin = PHP_INT_MAX;
|
||||
$dateMax = -1;
|
||||
$totalVersements = 0;
|
||||
foreach ($versements as $ligne) {
|
||||
if ($ligne->idUser != $idPersonneCourant) {
|
||||
// changement de personne
|
||||
if ($idPersonneCourant != -1) {
|
||||
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
|
||||
$_SESSION['taux_reduction'],
|
||||
$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
|
||||
if (!array_key_exists($idPersonneCourant, $totalPersonnes)) {
|
||||
$totalPersonnes[$idPersonneCourant] = $_SESSION['membresDonateurs'][$ligne->idUser]->clone();
|
||||
}
|
||||
} else {
|
||||
// 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,
|
||||
$dateMin,
|
||||
$dateMax
|
||||
);
|
||||
return $totalPersonnes;
|
||||
} // cumulerVersementsPersonne
|
||||
|
||||
/**
|
||||
* Cumuler les versements de chaque personne par tarif
|
||||
* @param tableau des versements triés par idTarif, idUser, date
|
||||
* @return tableau des versements cumulés : id => Personne
|
||||
*/
|
||||
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->idCompte != $idCompteCourant
|
||||
) {
|
||||
if ($idTarifCourant != -1) {
|
||||
// changement de tarif, de personne ou de compte
|
||||
$tarifCompte = ($idTarifCourant == 0) ?
|
||||
$idCompteCourant :
|
||||
$idTarifCourant . "_" . $idCompteCourant;
|
||||
$totalPersonnes[$idPersonneCourant]->ajouterVersement(
|
||||
$_SESSION['tauxSelectionnes'][$tarifCompte],
|
||||
$totalVersements,
|
||||
$dateMin,
|
||||
$dateMax
|
||||
);
|
||||
}
|
||||
$dateMin = strtotime($ligne->date);
|
||||
$dateMax = strtotime($ligne->date);
|
||||
$idTarifCourant = $ligne->idTarif;
|
||||
$idPersonneCourant = $ligne->idUser;
|
||||
$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 {
|
||||
// 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'][$tarifCompte],
|
||||
$totalVersements,
|
||||
$dateMin,
|
||||
$dateMax
|
||||
);
|
||||
return $totalPersonnes;
|
||||
} // cumulerVersementsTarif
|
||||
|
||||
/**
|
||||
* génère un fichier PDF à partir d'un document html
|
||||
* ajoute son nom à la liste de fichiers
|
||||
*/
|
||||
function genererPDF($docHTML, $nomPersonne, &$listeFichiersPDF)
|
||||
{
|
||||
// fabriquer le fichier PDF
|
||||
$nomPDF = \Paheko\Utils::filePDF($docHTML);
|
||||
// changer le nom du fichier
|
||||
$nom = str_replace(' ', '_', $nomPersonne);
|
||||
$nom = str_replace("'", "", $nom);
|
||||
$nomFichier = sprintf(
|
||||
'%s/recu_%s_%s.pdf',
|
||||
dirname($nomPDF),
|
||||
$_SESSION['annee_recu'],
|
||||
$nom
|
||||
);
|
||||
rename($nomPDF, $nomFichier);
|
||||
// ajouter le nom du fichier à la liste pour mettre dans une archive
|
||||
$listeFichiersPDF[] = $nomFichier;
|
||||
} // genererPDF
|
||||
|
||||
function faireNumeroRecu($prefixeNum, $membre, $numero, &$numero_sequentiel)
|
||||
{
|
||||
if (isset($membre) && $membre) {
|
||||
if ($prefixeNum != "") {
|
||||
$prefixeNum .= "-";
|
||||
}
|
||||
$prefixeNum .= $numero;
|
||||
}
|
||||
if ($numero_sequentiel) {
|
||||
if ($prefixeNum != "") {
|
||||
$prefixeNum .= "-";
|
||||
}
|
||||
$prefixeNum .= $numero_sequentiel;
|
||||
++$numero_sequentiel;
|
||||
}
|
||||
return $prefixeNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* renvoyer le préfixe du numéro de reçu
|
||||
*/
|
||||
function getNumPrefixe($configNum)
|
||||
{
|
||||
$prefixeNum = "";
|
||||
if (isset($configNum->prefixe) && $configNum->prefixe != "") {
|
||||
$prefixeNum = $configNum->prefixe;
|
||||
}
|
||||
if (isset($configNum->annee) && $configNum->annee) {
|
||||
if ($prefixeNum != "") {
|
||||
$prefixeNum .= "-";
|
||||
}
|
||||
$prefixeNum .= $_SESSION['annee_recu'];
|
||||
}
|
||||
return $prefixeNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* renvoyer le premier numéro de la numérotation séquentielle
|
||||
* renvoie false si pas de numérotation séquentielle
|
||||
*/
|
||||
function getNumSequentiel($configNum)
|
||||
{
|
||||
if (isset($configNum->sequentiel) && $configNum->sequentiel) {
|
||||
if (isset($configNum->valeur_init) && $configNum->valeur_init != "") {
|
||||
$numero_sequentiel = $configNum->valeur_init;
|
||||
} else {
|
||||
$numero_sequentiel = 1;
|
||||
}
|
||||
}
|
||||
return isset($numero_sequentiel) ? $numero_sequentiel : false;
|
||||
}
|
||||
|
||||
function mentionsComplémentaires()
|
||||
{
|
||||
$donnees = array(
|
||||
'Nature du don : ' => "Numéraire",
|
||||
'Mode de versement : ' => "chèque et/ou virement"
|
||||
);
|
||||
$complements = array();
|
||||
foreach ($donnees as $titre => $libelle) {
|
||||
$elem = new \stdClass();
|
||||
$elem->titre = $titre;
|
||||
$elem->libelle = $libelle;
|
||||
$complements[] = $elem;
|
||||
}
|
||||
return $complements;
|
||||
}
|
||||
38
admin/imprimer_recu.css
Normal file
38
admin/imprimer_recu.css
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* impression
|
||||
*/
|
||||
@page
|
||||
{
|
||||
size: A4 portrait;
|
||||
}
|
||||
|
||||
header.header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #fff;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.noprint {
|
||||
display: none;
|
||||
}
|
||||
|
||||
nav.tabs
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
main {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.previs_recu
|
||||
{
|
||||
font-family: Serif;
|
||||
font-size: 11pt;
|
||||
background-color: white;
|
||||
page-break-after: always;
|
||||
}
|
||||
75
admin/index.php
Normal file
75
admin/index.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace Paheko;
|
||||
session_start();
|
||||
|
||||
use Paheko\Plugin\RecusFiscaux\Utils;
|
||||
|
||||
// mettre à jour le plugin si besoin
|
||||
if ($plugin->needUpgrade()) {
|
||||
$plugin->upgrade();
|
||||
}
|
||||
|
||||
// Année fiscale par défaut
|
||||
if (! isset($_SESSION['annee_recu']) || $_SESSION['annee_recu'] == "")
|
||||
{
|
||||
$_SESSION['annee_recu'] = date("Y") - 1;
|
||||
}
|
||||
|
||||
// nombre de taux de réduction activés
|
||||
$nbTaux = 0;
|
||||
foreach ($plugin->getConfig('reduction') as $taux)
|
||||
{
|
||||
if ($taux->valeur) { ++$nbTaux; }
|
||||
}
|
||||
|
||||
// idem avec les champs nom/prénom
|
||||
$nbChamps = 0;
|
||||
$champsNom = Utils::getChampsNom($config, $plugin);
|
||||
if (null !== $champsNom)
|
||||
{
|
||||
foreach ($champsNom as $nom => $champ)
|
||||
{
|
||||
if ($champ->position != 0) { ++$nbChamps; }
|
||||
}
|
||||
}
|
||||
|
||||
// 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, tarifs et comptes associés
|
||||
$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('nbComptesSansActivite',count($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);
|
||||
$tpl->assign('plugin_css', ['style.css']);
|
||||
$tpl->assign('plugin_url', \Paheko\Utils::plugin_url());
|
||||
|
||||
// envoyer au template
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/index.tpl');
|
||||
103
admin/previs_recu.css
Normal file
103
admin/previs_recu.css
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* prévisualisation reçu au format HTML
|
||||
*/
|
||||
|
||||
div.previs_recu
|
||||
{
|
||||
width : 18.5cm;
|
||||
}
|
||||
|
||||
#logo
|
||||
{
|
||||
max-height : 4cm;
|
||||
}
|
||||
|
||||
#titre
|
||||
{
|
||||
margin : 0 2cm 0 2cm;
|
||||
text-align : center;
|
||||
font-size : 14pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#articles
|
||||
{
|
||||
margin-bottom: 0.5cm;
|
||||
text-align : center;
|
||||
}
|
||||
|
||||
#numRecu
|
||||
{
|
||||
text-align : right;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
#versements
|
||||
{
|
||||
border-top: 1px solid rgb(0, 0, 128);
|
||||
border-bottom: 1px solid rgb(0, 0, 128);
|
||||
padding-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.cartouche
|
||||
{
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
.rubrique
|
||||
{
|
||||
background-color : rgb(200, 200, 250);
|
||||
padding : 0 0 0 1mm;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.titre, .important
|
||||
{
|
||||
font-weight:bold;
|
||||
}
|
||||
.libelle
|
||||
{
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#ville
|
||||
{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#signature
|
||||
{
|
||||
display: block;
|
||||
max-width : 7cm;
|
||||
max-height : 4cm;
|
||||
margin: 0 auto;
|
||||
padding-bottom : 2mm;
|
||||
}
|
||||
|
||||
#versements > ul
|
||||
{
|
||||
list-style: inside;
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
#date_versements
|
||||
{
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
p.complements
|
||||
{
|
||||
margin-top : 1em;
|
||||
}
|
||||
|
||||
span.titre, span.libelle
|
||||
{
|
||||
display : inline;
|
||||
}
|
||||
|
||||
/* Ne pas imprimer le bandeau des boutons du profiler */
|
||||
#__profiler
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
276
admin/script.js
Normal file
276
admin/script.js
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
"use strict";
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// actions sur la liste des versements
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fonction appelée quand on (dé)coche la case globale
|
||||
* (dé)sélectionner toutes les cases de toutes les activités
|
||||
* @param {HTMLInputElement} idCaseGlobale id de la case globale
|
||||
*/
|
||||
function cocherDecocherTout(idCaseGlobale) {
|
||||
// itérer sur la liste des éléments détails : 1 par couple <activité, tarif>
|
||||
let lesDetails = document.querySelectorAll("details.activite");
|
||||
for (let i = 0; i < lesDetails.length; ++i) {
|
||||
let idCase = lesDetails[i].querySelector("input[type=checkbox]");
|
||||
idCase.checked = idCaseGlobale.checked;
|
||||
cocherDecocherTarif(idCase);
|
||||
}
|
||||
// changer le message
|
||||
changerMessage(idCaseGlobale.nextElementSibling, idCaseGlobale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction appelée quand on (dé)coche la case d'activité
|
||||
* (dé)sélectionner toutes les cases de cette activité
|
||||
* @param {HTMLInputElement} idCaseGlobale id de la case d'activité
|
||||
*/
|
||||
function cocherDecocherTarif(idCaseGlobale) {
|
||||
let lesPersonnes = idCaseGlobale.closest("details").querySelectorAll("div.personne");
|
||||
cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes);
|
||||
}
|
||||
|
||||
/**
|
||||
* idem dans le cas des versements des personnes
|
||||
* @param {HTMLInputElement} idCaseGlobale id case à cocher d'une personne
|
||||
*/
|
||||
function cocherDecocherToutesLesPersonnes(idCaseGlobale) {
|
||||
let lesPersonnes = document.querySelectorAll("div.personne");
|
||||
cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes);
|
||||
changerMessage(idCaseGlobale.nextElementSibling, idCaseGlobale);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLInputElement} idCaseGlobale
|
||||
* @param {NodeListOf<Element>} lesPersonnes
|
||||
*/
|
||||
function cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes) {
|
||||
for (let j = 0; j < lesPersonnes.length; ++j) {
|
||||
// trouver l'élément total de la personne
|
||||
let idTotal = lesPersonnes[j].querySelector("span");
|
||||
// puis la case à cocher
|
||||
let idCase = lesPersonnes[j].closest("summary").querySelector("input");
|
||||
idCase.checked = idCaseGlobale.checked;
|
||||
// puis traiter toutes les cases de la personne
|
||||
cocherDecocherPersonne(idCase, idTotal);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction appelée quand on (dé)coche la case d'une personne
|
||||
* - (dé)sélectionner toutes les cases à cocher
|
||||
* - faire le total des cases cochées et l'afficher
|
||||
* @param {HTMLInputElement} idCase id de la case qui a été cochée
|
||||
* @param {HTMLSpanElement} idTotal id de l'élément où afficher le total
|
||||
*/
|
||||
function cocherDecocherPersonne(idCase, idTotal) {
|
||||
// chercher le fieldset des versements
|
||||
let fieldset = idCase.closest("details").querySelector("div.versements");
|
||||
let listeCases = fieldset.querySelectorAll("input[type=checkbox]");
|
||||
for (let i = 0; i < listeCases.length; ++i) {
|
||||
listeCases[i].checked = idCase.checked;
|
||||
cocherDecocherVersement(listeCases[i], idTotal);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction appelée quand on (dé)coche la case d'un versement
|
||||
* Faire le total des cases cochées et l'afficher
|
||||
*
|
||||
* @param {HTMLInputElement} idCase id de la case qui a été cochée
|
||||
* @param {HTMLSpanElement} idTotal id de l'élément où afficher le total
|
||||
*/
|
||||
function cocherDecocherVersement(idCase, idTotal) {
|
||||
let fieldset = idCase.closest("div.versements");
|
||||
let listeCases = fieldset.querySelectorAll("input[type=checkbox]");
|
||||
let listeMontants = fieldset.querySelectorAll("span.montant");
|
||||
calculerTotal(listeCases, listeMontants, idTotal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Faire le total des cases cochées et l'afficher
|
||||
* @param {NodeListOf<Element>} listeCases liste des cases
|
||||
* @param {NodeListOf<Element>} listeMontants liste des montants associés
|
||||
* @param {HTMLSpanElement} idTotal id de l'élément où afficher le total
|
||||
*/
|
||||
function calculerTotal(listeCases, listeMontants, idTotal) {
|
||||
let total = 0;
|
||||
for (let i = 0; i < listeCases.length; ++i) {
|
||||
if (listeCases[i].checked) {
|
||||
total += parseFloat(listeMontants[i].textContent.replace(/\s/g, "").replace(",", "."));
|
||||
}
|
||||
}
|
||||
// afficher le total
|
||||
idTotal.innerHTML =
|
||||
total.toLocaleString('fr-FR', {
|
||||
style: 'currency', currency: 'EUR',
|
||||
minimumFractionDigits: 2
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* changer le message en fonction de l'état coché de la case
|
||||
* @param {Element} message
|
||||
* @param {HTMLInputElement} idCase
|
||||
*/
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* afficher/masquer les détails
|
||||
* @param {string} idElem bouton de masquage/affichage
|
||||
* @param {string} classe des détails à afficher/masquer
|
||||
* @param {string} texte du bouton
|
||||
*/
|
||||
function montrerMasquerDetails(idElem, classe, texte) {
|
||||
let lesDetails = document.querySelectorAll(classe);
|
||||
if (lesDetails.length > 0) {
|
||||
let leBouton = document.getElementById(idElem);
|
||||
if (leBouton.textContent.includes('Replier')) {
|
||||
// masquer
|
||||
lesDetails.forEach((e) => {
|
||||
e.removeAttribute('open');
|
||||
});
|
||||
leBouton.textContent = "Déplier " + texte;
|
||||
leBouton.setAttribute('data-icon', '↓');
|
||||
}
|
||||
else {
|
||||
// montrer
|
||||
lesDetails.forEach((e) => {
|
||||
e.setAttribute('open', 'open');
|
||||
});
|
||||
leBouton.textContent = "Replier " + texte;
|
||||
leBouton.setAttribute('data-icon', '↑');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fonction appelée lors de la demande de génération des reçus
|
||||
* vérifier qu'au moins un versement a été sélectionné
|
||||
* @return vrai si au moins un choix a été fait
|
||||
* @param {HTMLFormElement} formulaire
|
||||
*/
|
||||
function verifierChoix(formulaire) {
|
||||
return verifierCases(formulaire, 'checkbox', "au moins un versement");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// actions sur la page d'accueil
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* positionner l'action déclenchée par l'envoi du formulaire
|
||||
* afficher et masquer des portions de formulaire selon l'action
|
||||
* @param {HTMLFormElement} formulaire
|
||||
* @param {string} action après envoi du formulaire
|
||||
* @param {any} idElem id de l'élément à afficher
|
||||
* @param {any} nomClasse classe des éléments à masquer (sauf idElem)
|
||||
*/
|
||||
function choixMethodeGeneration(formulaire, action, idElem, nomClasse) {
|
||||
formulaire.setAttribute('action', 'action.php?action=' + action);
|
||||
for (let elem of formulaire.querySelectorAll(nomClasse)) {
|
||||
if (elem.id == idElem) {
|
||||
elem.classList.remove('hidden');
|
||||
}
|
||||
else {
|
||||
elem.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* vérifier
|
||||
* - qu'au moins une activité/tarif est sélectionnée
|
||||
* - qu'un radio de chaque activité/tarif sélectionné a été sélectionné :)
|
||||
* @param conteneur des cases à vérifier
|
||||
*/
|
||||
function verifierActivitésTaux(conteneur) {
|
||||
let nbChoix = 0;
|
||||
// parcourir les cases à cocher
|
||||
for (let idCase of conteneur.querySelectorAll("input[type=checkbox]")) {
|
||||
if (idCase.checked) {
|
||||
++nbChoix;
|
||||
// vérifier qu'un radio de la même ligne est sélectionné
|
||||
let ligneCorrecte = false;
|
||||
// trouver la ligne englobante
|
||||
let ligne = idCase.closest("li");
|
||||
for (let idRadio of ligne.querySelectorAll('input[type=radio]')) {
|
||||
if (idRadio.checked) { ligneCorrecte = true; break; }
|
||||
}
|
||||
if (!ligneCorrecte) {
|
||||
alert("Erreur : il faut sélectionner un taux de réduction dans chaque ligne cochée");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nbChoix == 0) {
|
||||
alert("Erreur : il faut sélectionner au moins une ligne");
|
||||
}
|
||||
return nbChoix != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* vérifier qu'un taux a été sélectionné dans le conteneur paramètre
|
||||
*/
|
||||
function verifierTaux(conteneur) {
|
||||
return verifierCases(conteneur, 'radio', "un taux de réduction");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// actions sur la config
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* vérifier les données saisies dans le formulaire de configuration
|
||||
*/
|
||||
function verifierConfig(divArticles, divTauxReduc) {
|
||||
// articles
|
||||
if (!verifierCases(divArticles, "checkbox", "au moins un article")) { return false; }
|
||||
|
||||
// taux de réduction
|
||||
if (!verifierCases(divTauxReduc, "checkbox", "au moins un taux de réduction")) { return false; }
|
||||
|
||||
// Nom, fonction, signature
|
||||
|
||||
|
||||
// alert("Erreur : il faut sélectionner au moins un versement");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifier qu'au moins une case est cochée dans le conteneur
|
||||
* @param conteneur
|
||||
* @param type de case à vérifier (radio, checkbox)
|
||||
* @param message à afficher si erreur
|
||||
*/
|
||||
function verifierCases(conteneur, type, message) {
|
||||
let selecteur = "input[type=" + type + "]";
|
||||
let listeCheck = conteneur.querySelectorAll(selecteur);
|
||||
for (let elem of listeCheck) {
|
||||
if (elem.checked) { return true; }
|
||||
}
|
||||
alert("Erreur : il faut sélectionner " + message);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* petite bidouille pour utiliser ma feuille de style pour imprimer les reçus
|
||||
* à la place de la feuille de style de paheko
|
||||
* @param {*} document
|
||||
*/
|
||||
function changerStyle(document) {
|
||||
let styles = document.querySelectorAll('link[rel="stylesheet"]');
|
||||
// console.log(styles);
|
||||
for (let sheet of styles) {
|
||||
if (sheet.href.includes('print.css')) { sheet.media = "tv"; sheet.remove; }
|
||||
if (sheet.href.includes('imprimer_recu.css')) { sheet.media = 'print'; }
|
||||
}
|
||||
// console.log(styles);
|
||||
}
|
||||
174
admin/style.css
Normal file
174
admin/style.css
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* liste des versements
|
||||
*/
|
||||
|
||||
div.pair {
|
||||
background-color: rgba(var(--gSecondColor), 0.15);
|
||||
}
|
||||
|
||||
fieldset.versements
|
||||
{
|
||||
margin-bottom : 0;
|
||||
margin-right : 0.5em;
|
||||
-webkit-border-radius:8px;
|
||||
border-radius:8px;
|
||||
}
|
||||
|
||||
div span {
|
||||
padding-left : 0.5em;
|
||||
padding-right : 0.5em;
|
||||
}
|
||||
|
||||
td.montant {
|
||||
text-align : right;
|
||||
}
|
||||
|
||||
span.montant {
|
||||
width : 5em;
|
||||
text-align : right;
|
||||
}
|
||||
|
||||
span.total
|
||||
{
|
||||
font-weight : bold;
|
||||
}
|
||||
|
||||
summary.activite
|
||||
{
|
||||
margin-bottom : 0.5em;
|
||||
}
|
||||
|
||||
summary.personne
|
||||
{
|
||||
margin-bottom : 0.5em;
|
||||
padding-top : 0;
|
||||
padding-bottom : 0;
|
||||
}
|
||||
|
||||
div.activite
|
||||
{
|
||||
background-color: rgba(var(--gSecondColor), 0.3);
|
||||
}
|
||||
|
||||
div.personne
|
||||
{
|
||||
font-weight : normal;
|
||||
background-color: rgba(var(--gSecondColor), 0.25);
|
||||
}
|
||||
|
||||
h3.activite
|
||||
{
|
||||
display : inline;
|
||||
}
|
||||
|
||||
p.activite
|
||||
{
|
||||
margin-left : 2.5em;
|
||||
}
|
||||
|
||||
input.check_global
|
||||
{
|
||||
margin : 0.2em 0.5em;
|
||||
}
|
||||
|
||||
div.versements
|
||||
{
|
||||
margin-left : 4em;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/*
|
||||
* page d'accueil
|
||||
*/
|
||||
|
||||
div.explications ul
|
||||
{
|
||||
list-style : initial;
|
||||
}
|
||||
|
||||
dl#menu
|
||||
{
|
||||
min-width : 40em;
|
||||
width : 50%;
|
||||
}
|
||||
|
||||
/*
|
||||
* configuration
|
||||
*/
|
||||
|
||||
#signature
|
||||
{
|
||||
padding : 1em 0.5em 0 0.5em;
|
||||
max-width: 300px;
|
||||
max-height: 120px;
|
||||
}
|
||||
|
||||
div.actions
|
||||
{
|
||||
display : inline;
|
||||
}
|
||||
|
||||
a.icn-btn {
|
||||
font-family: "paheko", sans-serif;
|
||||
font-size : 1.2em;
|
||||
}
|
||||
|
||||
dl.config
|
||||
{
|
||||
padding-bottom : 1ex;
|
||||
padding-right : 1em;
|
||||
}
|
||||
|
||||
div#articles_cgi, div#config_nom_fonction, div#numero_recus
|
||||
{
|
||||
display: flex;
|
||||
}
|
||||
|
||||
div.article
|
||||
{
|
||||
margin-right : 3em;
|
||||
}
|
||||
/*
|
||||
div#config_nom_fonction
|
||||
{
|
||||
display: flex;
|
||||
}
|
||||
|
||||
div#numero_recus
|
||||
{
|
||||
display:flex;
|
||||
}
|
||||
*/
|
||||
div.champnom
|
||||
{
|
||||
display : flex;
|
||||
margin-top : 0.25rem;
|
||||
}
|
||||
div.infos
|
||||
{
|
||||
border : 1px solid rgba(var(--gMainColor));
|
||||
border-radius : 0.25rem;
|
||||
padding : 0.4rem;
|
||||
margin-left : 1em;
|
||||
width : 20em;
|
||||
}
|
||||
ul#liste_activites dd
|
||||
{
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
ul.reduction span.radio-btn
|
||||
{
|
||||
margin-left : 2em;
|
||||
border-spacing : 0.1em;
|
||||
}
|
||||
input#f_prefixe
|
||||
{
|
||||
width : 8em;
|
||||
min-width : 8em;
|
||||
}
|
||||
input#f_valeur_init
|
||||
{
|
||||
max-width: 4em;
|
||||
}
|
||||
24
admin/upload.php
Normal file
24
admin/upload.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
namespace Paheko;
|
||||
session_start();
|
||||
|
||||
use Paheko\Entities\Files\File;
|
||||
use Paheko\Files\Files;
|
||||
|
||||
$parent = qg('p');
|
||||
/*
|
||||
if (!File::checkCreateAccess($parent, $session)) {
|
||||
throw new UserException('Vous n\'avez pas le droit d\'ajouter de fichier.');
|
||||
}
|
||||
// checkCreateAccess n'existe plus...
|
||||
*/
|
||||
|
||||
$csrf_key = 'upload_file_' . md5($parent);
|
||||
|
||||
$form->runIf('upload', function () use ($parent) {
|
||||
$_SESSION['sig_file'] = \Paheko\Files\Files::uploadMultiple($parent, 'file');
|
||||
}, $csrf_key, PLUGIN_ROOT . '/admin/config.php');
|
||||
|
||||
$tpl->assign(compact('parent', 'csrf_key'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/upload.tpl');
|
||||
98
admin/versements_activites.php
Normal file
98
admin/versements_activites.php
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
namespace Paheko;
|
||||
|
||||
use Paheko\Plugin\RecusFiscaux\Personne;
|
||||
use Paheko\Plugin\RecusFiscaux\Utils;
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// récupérer les infos du formulaire
|
||||
// ------------------------------------------------------------
|
||||
|
||||
// vérifier qu'on a bien sélectionné une activité ou un compte
|
||||
if (! isset($_SESSION['tauxSelectionnes'])
|
||||
&&
|
||||
null === f('tarifs')
|
||||
&&
|
||||
null === f('comptes'))
|
||||
{
|
||||
\Paheko\Utils::redirect(\Paheko\Utils::plugin_url() . 'index.php');
|
||||
}
|
||||
|
||||
// tarifs sélectionnés
|
||||
if (null !== f('tarifs')) {
|
||||
$tarifsSelectionnes = f('tarifs');
|
||||
} else if (! isset($_SESSION['tauxSelectionnes'])) {
|
||||
$tarifsSelectionnes = [];
|
||||
}
|
||||
// error_log("\ntarifsSelectionnes=" . print_r($tarifsSelectionnes, true));
|
||||
// comptes sélectionnés
|
||||
if (null !== f('comptes')) {
|
||||
$_SESSION['comptesSelectionnes'] = f('comptes');
|
||||
// error_log("\ncomptesSelectionnes=" . print_r($_SESSION['comptesSelectionnes'], true));
|
||||
} /*
|
||||
else if (! isset($_SESSION['tauxSelectionnes'])) {
|
||||
$_SESSION['comptesSelectionnes'] = [];
|
||||
}
|
||||
*/
|
||||
|
||||
// taux de réduction associés
|
||||
$tauxSelectionnes = array();
|
||||
if (isset($tarifsSelectionnes))
|
||||
{
|
||||
foreach ($tarifsSelectionnes as $idTarif)
|
||||
{
|
||||
$nomRadio = "taux_reduction_" . $idTarif;
|
||||
$tauxSelectionnes[$idTarif] = f("$nomRadio");
|
||||
}
|
||||
}
|
||||
if (isset($_SESSION['comptesSelectionnes']))
|
||||
{
|
||||
foreach ($_SESSION['comptesSelectionnes'] as $idCompte)
|
||||
{
|
||||
$nomRadio = "taux_reduction_" . $idCompte;
|
||||
$tauxSelectionnes[$idCompte] = f("$nomRadio");
|
||||
}
|
||||
}
|
||||
$_SESSION['tauxSelectionnes'] = $tauxSelectionnes;
|
||||
|
||||
$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);
|
||||
|
||||
# versements des tarifs sélectionnées et de leur compte associé
|
||||
if (count($lesTarifs) != 0)
|
||||
{
|
||||
$_SESSION['lesVersements'] =
|
||||
Utils::getVersementsTarifsComptes(
|
||||
$_SESSION['annee_recu'],
|
||||
$lesTarifs,
|
||||
$lesComptes,
|
||||
$champsNom);
|
||||
// error_log("lesVersements=" . print_r($_SESSION['lesVersements'], true));
|
||||
}
|
||||
|
||||
// ajouter les versements sans tarif (tri par nom, compte, date)
|
||||
if (isset($_SESSION['comptesSelectionnes']))
|
||||
{
|
||||
$versementsSansTarif = Utils::getVersementsComptes($_SESSION['annee_recu'],
|
||||
$_SESSION['comptesSelectionnes'],
|
||||
$champsNom);
|
||||
foreach ($versementsSansTarif as $versement)
|
||||
{
|
||||
$_SESSION['lesVersements'][] = $versement;
|
||||
}
|
||||
}
|
||||
//error_log("lesVersements=" . print_r($_SESSION['lesVersements'], true));
|
||||
|
||||
// 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->display(PLUGIN_ROOT . '/templates/versements_activites.tpl');
|
||||
|
||||
34
admin/versements_personnes.php
Normal file
34
admin/versements_personnes.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?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');
|
||||
Loading…
Add table
Add a link
Reference in a new issue