Début restructuration pour compatibilité version 1.3 de paheko
FossilOrigin-Name: 467790c5738a867592117ea6b3a7ac6c61738dab3b8e29a48fed8f19b9df2b38
This commit is contained in:
parent
e75c56b736
commit
bc4739877c
27 changed files with 77 additions and 46 deletions
216
admin/action.php
Normal file
216
admin/action.php
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\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');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue