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

@ -1,33 +0,0 @@
<?php
namespace Garradin\Plugin\RecusFiscaux;
/*
* information d'une activité
*/
class Activite
{
public $id;
public $label;
public $description;
public function __construct(
$id,
$label,
$description)
{
$this->id = $id;
$this->label = $label;
$this->description = $description;
}
/*
* @return instance de Activite initialisée avec l'objet o
*/
public static function copier($o)
{
return new Activite(
$o->id,
$o->label,
$o->description);
}
}

View File

@ -8,29 +8,29 @@ namespace Garradin\Plugin\RecusFiscaux;
class Personne class Personne
{ {
public $id; public $id;
public $rang; // par ordre alpha de nomPrenom ; sert aux tris
public $nomPrenom; public $nomPrenom;
public $adresse; public $adresse;
public $codePostal; public $codePostal;
public $ville; public $ville;
public $courriel;
public $versements; // versements par taux de réduction public $versements; // versements par taux de réduction
public function __construct( public function __construct(
$id, $id,
$rang,
$nomPrenom, $nomPrenom,
$adresse, $adresse,
$codePostal, $codePostal,
$ville, $ville
$courriel = ""
) )
{ {
$this->id = $id; $this->id = $id;
$this->rang = $rang;
$this->nomPrenom = $nomPrenom; $this->nomPrenom = $nomPrenom;
$this->adresse = $adresse; $this->adresse = $adresse;
$this->codePostal = $codePostal; $this->codePostal = $codePostal;
$this->ville = $ville; $this->ville = $ville;
$this->courriel = $courriel; $this->versements = array(); // clé = tarif, valeur = Versement
$this->versements = array(); // clé = tarif, valeur = montant
} }
/** /**
@ -40,30 +40,35 @@ class Personne
{ {
return new Personne( return new Personne(
$this->id, $this->id,
$this->rang,
$this->nomPrenom, $this->nomPrenom,
$this->adresse, $this->adresse,
$this->codePostal, $this->codePostal,
$this->ville, $this->ville);
$this->courriel);
} }
/** /**
* ajouter un versement * ajouter un versement
* @param $tauxReduction * @param $tauxReduction
* @param $montant * @param $montant
* @param $dateMin
* @param $dateMax
*/ */
public function ajouterVersement( public function ajouterVersement(
$tauxReduction, $tauxReduction,
$montant $montant,
$dateMin,
$dateMax
) )
{ {
if (array_key_exists($tauxReduction, $this->versements)) if (array_key_exists($tauxReduction, $this->versements))
{ {
$this->versements[$tauxReduction] += $montant; $this->versements[$tauxReduction]->ajouter($montant, $dateMin, $dateMax);
} }
else else
{ {
$this->versements[$tauxReduction] = $montant; $this->versements[$tauxReduction] = new Versement($montant, $dateMin, $dateMax);
} }
} }
} }

View File

@ -1,41 +0,0 @@
<?php
namespace Garradin\Plugin\RecusFiscaux;
/*
* information d'un tarif
*/
class Tarif
{
public $id;
public $idActivite; // activité associée
public $label;
public $description;
public $montant;
public function __construct(
$id,
$idActivite,
$label,
$description,
$montant)
{
$this->id = $id;
$this->idActivite = $idActivite;
$this->label = $label;
$this->description = $description;
$this->montant = $montant;
}
/*
* @return instance de Tarif initialisée avec l'objet o
*/
public static function copier($o)
{
return new Tarif(
$o->id,
$o->idActivite,
$o->label,
$o->description,
$o->montant);
}
}

View File

@ -8,158 +8,299 @@ use KD2\ZipWriter;
class Utils class Utils
{ {
/** /**
* @return tarifs demandés * @return informations sur les tarifs
* @param $tarifs
*/ */
public static function getTarifs(array $tarifs) : array public static function getTarifs()
{ {
$db = DB::getInstance(); $db = DB::getInstance();
$sql = sprintf( $sql = sprintf(
'SELECT id, id_service as idActivite, label, description, amount as montant 'SELECT
FROM services_fees id,
WHERE services_fees.%s', id_service as idActivite,
$db->where('id', $tarifs)); label,
description,
amount as montant
FROM services_fees');
return Utils::toAssoc($db->get($sql), 'id');
}
/**
* @return informations sur les activités
*/
public static function getActivites()
{
$db = DB::getInstance();
$sql = sprintf(
'SELECT
services.id,
services.label,
services.description
FROM services');
return Utils::toAssoc($db->get($sql), 'id');
}
/**
* @return comptes sur lesquels des versements de membres ont été faits
* @param string $annee
* @param $op : opérateur de combinaison des comptes
* @param array $comptes
*/
public static function getComptes($annee, $op, $comptes)
{
$db = DB::getInstance();
$sql = sprintf(
'SELECT
acc_accounts.id,
acc_accounts.code as codeCompte,
acc_accounts.label as nomCompte
FROM acc_transactions_users
INNER JOIN membres
ON acc_transactions_users.id_user = membres.id
INNER JOIN acc_transactions
ON acc_transactions_users.id_transaction = acc_transactions.id
INNER JOIN acc_transactions_lines
ON acc_transactions_lines.id_transaction = acc_transactions.id
INNER JOIN acc_accounts
ON acc_transactions_lines.id_account = acc_accounts.id
WHERE
(strftime(%s, acc_transactions.date) = "%d"
AND
acc_accounts.%s
)
GROUP by acc_accounts.id
ORDER by acc_accounts.id',
'"%Y"',
$annee,
$db->where('code', $op, $comptes)
);
return Utils::toAssoc($db->get($sql), 'id');
}
/**
* @return tarifs des activités et comptes ayant des versements de
* membres dans l'année
* @param string $annee
* @param $op : opérateur de combinaison des comptes
* @param array $comptes
*/
public static function getTarifsComptes($annee, $op, $comptes)
{
$db = DB::getInstance();
$sql = sprintf(
'
SELECT
services_users.id_fee as idTarif,
acc_accounts.id as idCompte,
acc_accounts.code as codeCompte
FROM acc_transactions_users
INNER JOIN acc_transactions
ON acc_transactions_users.id_transaction = acc_transactions.id
INNER JOIN services_users
ON acc_transactions_users.id_service_user = services_users.id
INNER JOIN services_fees
ON services_users.id_fee = services_fees.id
INNER JOIN acc_transactions_lines
ON acc_transactions_lines.id_transaction = acc_transactions.id
INNER JOIN acc_accounts
ON acc_transactions_lines.id_account = acc_accounts.id
WHERE
(strftime(%s, acc_transactions.date) = "%d"
AND
acc_accounts.%s
)
GROUP BY services_fees.id,acc_accounts.id
',
'"%Y"',
$annee,
$db->where('code', $op, $comptes)
);
return $db->get($sql); return $db->get($sql);
} }
/** /**
* @return activités correspondant aux tarifs demandés * faire un tableau associatif avec le résultat d'une requête
* @param $tarifs
*/ */
public static function getActivites(array $tarifs) : array static function toAssoc($array, $nomCle)
{ {
$db = DB::getInstance(); $assoc = array();
$sql = sprintf( foreach ($array as $elem)
'SELECT services.id, services.label, services.description {
FROM services $ro = new \ReflectionObject($elem);
LEFT JOIN services_fees ON services_fees.id_service = services.id $proprietes = $ro->getProperties();
WHERE services_fees.%s $obj = new \stdClass();
GROUP BY services.id', foreach ($proprietes as $p)
$db->where('id', $tarifs)); {
return $db->get($sql); $pname = $p->getName();
if ($pname == $nomCle) {
$key = $p->getValue($elem);
}
else {
$obj->$pname = $p->getValue($elem);
}
}
$assoc[$key] = $obj;
}
return $assoc;
} }
/** /**
* @return versements correspondants à l'année donnée * @return versements correspondants à l'année donnée
* @param $annee * @param $annee
* @param $champsNom : liste non vide des champs de nom/prénom * @param array $champsNom : liste non vide des champs de nom/prénom
*/ */
public static function getVersementsPersonnes($annee, array $champsNom) : array public static function getVersementsPersonnes($annee, $op, $comptes, $champsNom)
{ {
$db = DB::getInstance(); $db = DB::getInstance();
$tri = Utils::combinerTri($champsNom); $tri = Utils::combinerTri($champsNom);
$sql = sprintf( $sql = sprintf(
'SELECT 'SELECT
membres.id as idUser, membres.id as idUser,
acc_accounts.id as idCompte,
acc_accounts.code as codeCompte,
acc_transactions_lines.credit as versement, acc_transactions_lines.credit as versement,
acc_transactions.date acc_transactions.date
FROM acc_transactions_users FROM acc_transactions_users
INNER JOIN membres on acc_transactions_users.id_user = membres.id INNER JOIN membres
INNER JOIN acc_transactions on acc_transactions_users.id_transaction = acc_transactions.id ON acc_transactions_users.id_user = membres.id
INNER JOIN services_users on acc_transactions_users.id_service_user = services_users.id INNER JOIN acc_transactions
INNER JOIN acc_transactions_lines on acc_transactions_lines.id_transaction = acc_transactions.id ON acc_transactions_users.id_transaction = acc_transactions.id
INNER JOIN acc_transactions_lines
ON acc_transactions_lines.id_transaction = acc_transactions.id
INNER JOIN acc_accounts
ON acc_transactions_lines.id_account = acc_accounts.id
WHERE WHERE
(strftime(%s, acc_transactions.date) = "%d" (strftime(%s, acc_transactions.date) = "%d"
AND AND
acc_transactions_lines.credit > 0) acc_accounts.%s
ORDER by %s, acc_transactions.date', )
ORDER by %s, acc_accounts.id, acc_transactions.date',
'"%Y"', '"%Y"',
$annee, $annee,
$db->where('code', $op, $comptes),
$tri $tri
); );
return $db->get($sql); return $db->get($sql);
} }
/** /**
* @return versements correspondants à l'année et aux tarifs donnés * @return versements correspondants à :
* triés par tarif, nom, date * @param $annee : année fiscale
* @param $annee * @param $tarifs : tarifs sélectionnés
* @param $tarifs * @param array $comptes : comptes associés aux tarifs
* @param $champsNom : liste non vide des champs de nom/prénom * @param array $champsNom : liste non vide des champs de nom/prénom
* @remarks tri par tarif, nom, compte, date
*/ */
public static function getVersementsTarifs($annee, public static function getVersementsTarifsComptes($annee,
array $tarifs, $tarifs,
array $champsNom) : array $comptes,
$champsNom)
{ {
$db = DB::getInstance(); $db = DB::getInstance();
$tri = Utils::combinerTri($champsNom); $tri = Utils::combinerTri($champsNom);
$sql = sprintf( $sql = sprintf(
'SELECT 'SELECT
services_fees.id as idTarif, services_fees.id as idTarif,
membres.id as idUser, acc_accounts.id as idCompte,
acc_transactions_lines.credit as versement, acc_accounts.code as codeCompte,
acc_transactions.date membres.id as idUser,
acc_transactions_lines.credit as versement,
acc_transactions.date
FROM acc_transactions_users FROM acc_transactions_users
INNER JOIN membres on acc_transactions_users.id_user = membres.id INNER JOIN membres
INNER JOIN acc_transactions on acc_transactions_users.id_transaction = acc_transactions.id ON acc_transactions_users.id_user = membres.id
INNER JOIN services_users on acc_transactions_users.id_service_user = services_users.id INNER JOIN acc_transactions
INNER JOIN services_fees on services_users.id_fee = services_fees.id ON acc_transactions_users.id_transaction = acc_transactions.id
INNER JOIN acc_transactions_lines on acc_transactions_lines.id_transaction = acc_transactions.id INNER JOIN services_users
ON acc_transactions_users.id_service_user = services_users.id
INNER JOIN services_fees
ON services_users.id_fee = services_fees.id
INNER JOIN acc_transactions_lines
ON acc_transactions_lines.id_transaction = acc_transactions.id
INNER JOIN acc_accounts
ON acc_transactions_lines.id_account = acc_accounts.id
WHERE WHERE
(strftime(%s, acc_transactions.date) = "%d" (strftime(%s, acc_transactions.date) = "%d"
AND AND
services_fees.%s services_fees.%s
AND AND
acc_transactions_lines.credit > 0) acc_accounts.%s
ORDER by services_fees.id, %s, acc_transactions.date', )
ORDER by services_fees.id, %s, acc_accounts.id, acc_transactions.date',
'"%Y"', '"%Y"',
$annee, $annee,
$db->where('id', $tarifs), $db->where('id', 'in', $tarifs),
$db->where('id', 'in', $comptes),
$tri $tri
); );
return $db->get($sql); return $db->get($sql);
} }
/** /**
* @return versements correspondants à l'année et aux comptes donnés * @return versements correspondants à :
* @param $annee * @param $annee année fiscale
* @param $comptes * @param $comptesIsoles comptes NON associés à un tarif
* @param $champsNom : liste non vide des champs de nom/prénom * @param array $champsNom : liste non vide des champs de nom/prénom
* @remarks tri par nom, compte, date
*/ */
public static function getVersementsComptes($annee, public static function getVersementsComptes($annee,
array $comptes, $comptesIsoles,
array $champsNom) : array $champsNom)
{ {
$db = DB::getInstance(); $db = DB::getInstance();
$tri = Utils::combinerTri($champsNom); $tri = Utils::combinerTri($champsNom);
$sql = sprintf( $sql = sprintf(
'SELECT '
acc_accounts.code as compte, SELECT
0 as idTarif,
acc_accounts.id as idCompte,
acc_accounts.code as codeCompte,
membres.id as idUser, membres.id as idUser,
acc_transactions_lines.credit as versement, acc_transactions_lines.credit as versement,
acc_transactions.date acc_transactions.date
FROM acc_transactions_users FROM acc_transactions_users
INNER JOIN membres on acc_transactions_users.id_user = membres.id INNER JOIN membres
INNER JOIN acc_transactions on acc_transactions_users.id_transaction = acc_transactions.id ON acc_transactions_users.id_user = membres.id
INNER JOIN services_users on acc_transactions_users.id_service_user = services_users.id INNER JOIN acc_transactions
INNER JOIN acc_transactions_lines on acc_transactions_lines.id_transaction = acc_transactions.id ON acc_transactions_users.id_transaction = acc_transactions.id
INNER JOIN acc_transactions_lines
ON acc_transactions_lines.id_transaction = acc_transactions.id
INNER JOIN acc_accounts
ON acc_transactions_lines.id_account = acc_accounts.id
WHERE WHERE
(strftime(%s, acc_transactions.date) = "%d" (strftime(%s, acc_transactions.date) = "%d"
AND AND
acc_accounts.%s acc_accounts.%s
AND )
acc_transactions_lines.credit > 0)
ORDER by acc_accounts.code, %s, acc_transactions.date', ORDER by %s, acc_accounts.id, acc_transactions.date
',
'"%Y"', '"%Y"',
$annee, $annee,
$db->where('code', $comptes), $db->where('id', 'in', $comptesIsoles),
$tri $tri
); );
return $db->get($sql); return $db->get($sql);
} }
/** /**
* Versements totaux par personne pour une année donnée * @return personnes ayant versé des dons pour une année donnée
* @param année * @param $annee
* @param $champsNom : liste non vide des champs de nom/prénom * @param array $champsNom : champs qui définissent le nom et le prénom d'une personne
*/ */
public static function getVersementsTotaux($annee, array $champsNom) : array public static function getDonateurs($annee, $champsNom) : array
{ {
// concaténer les champs nom/prénoms pour la sélection
$nom = Utils::combinerChamps($champsNom);
// et pour le tri
$tri = Utils::combinerTri($champsNom); $tri = Utils::combinerTri($champsNom);
$sql = sprintf( $sql = sprintf(
'SELECT 'SELECT
membres.id as idUser, membres.id as idUser,
sum(acc_transactions_lines.credit) AS versement row_number() over(order by %s) as rang,
%s as nom,
membres.adresse as adresse,
membres.code_postal as codePostal,
membres.ville as ville
FROM FROM
acc_transactions_users, acc_transactions_users,
membres, membres,
@ -168,27 +309,38 @@ class Utils
ON acc_transactions_lines.id_transaction = acc_transactions.id ON acc_transactions_lines.id_transaction = acc_transactions.id
WHERE ( WHERE (
strftime(%s, acc_transactions.date) = "%d" strftime(%s, acc_transactions.date) = "%d"
AND
acc_transactions_lines.credit > 0
AND AND
acc_transactions_users.id_transaction = acc_transactions.id acc_transactions_users.id_transaction = acc_transactions.id
AND AND
acc_transactions_users.id_user = membres.id acc_transactions_users.id_user = membres.id
) )
GROUP by acc_transactions_users.id_user GROUP by membres.id
ORDER by %s COLLATE U_NOCASE', ORDER by %1$s COLLATE U_NOCASE
',
$tri,
$nom,
'"%Y"', '"%Y"',
$annee, $annee
$tri); );
return DB::getInstance()->get($sql); $donateurs = array();
foreach (DB::getInstance()->iterate($sql) as $personne)
{
$donateurs[$personne->idUser] = new Personne($personne->idUser,
$personne->rang,
$personne->nom,
$personne->adresse,
$personne->codePostal,
$personne->ville);
}
return $donateurs;
} }
/** /**
* combiner les champs avec un opérateur * combiner les champs avec un opérateur
* @param $champs : liste (non vide) de champs * @param array $champs : liste (non vide) de champs
* @return chaîne combinée * @return chaîne combinée
*/ */
private static function combinerChamps(array $champs) : string private static function combinerChamps($champs)
{ {
$op = ' || " " || '; $op = ' || " " || ';
$result = 'ifnull(membres.' . $champs[0] . ', "")'; $result = 'ifnull(membres.' . $champs[0] . ', "")';
@ -196,7 +348,7 @@ class Utils
{ {
$result .= $op . 'ifnull(membres.' . $champs[$i] . ', "")'; $result .= $op . 'ifnull(membres.' . $champs[$i] . ', "")';
} }
return $result; return 'trim(' . $result . ')';
} }
/** /**
@ -215,102 +367,7 @@ class Utils
} }
/** /**
* @return personnes ayant versé des dons pour une année donnée * @return liste des années fiscales
* @param $annee
* @param $champsNom : champs qui définissent le nom et le prénom d'une personne
*/
public static function getDonateurs($annee, array $champsNom) : array
{
// concaténer les champs nom/prénoms pour la sélection
$nom = 'trim(' . Utils::combinerChamps($champsNom) . ') as nom,';
// et pour le tri
$tri = Utils::combinerTri($champsNom);
$sql =
"SELECT
membres.id as idUser,
" .
$nom . "
membres.adresse as adresse,
membres.code_postal as codePostal,
membres.ville as ville
FROM
acc_transactions_users,
membres,
acc_transactions
INNER JOIN acc_transactions_lines
ON acc_transactions_lines.id_transaction = acc_transactions.id
WHERE (
strftime('%Y', acc_transactions.date) = ?
AND
acc_transactions_lines.credit > 0
AND
acc_transactions_users.id_transaction = acc_transactions.id
AND
acc_transactions_users.id_user = membres.id
)
GROUP by membres.id
ORDER by " . $tri . " COLLATE U_NOCASE
";
$donateurs = array();
foreach (DB::getInstance()->iterate($sql, $annee) as $personne)
{
$donateurs[$personne->idUser] = new Personne($personne->idUser,
$personne->nom,
$personne->adresse,
$personne->codePostal,
$personne->ville);
}
return $donateurs;
}
/**
* renvoie un tableau avec les remarques de chaque taux de réduction
*/
public static function getLignesReduction(array $lesTaux) : array
{
foreach ($lesTaux as $elem)
{
/*
$ligne = "taux " . $elem->taux . ", ligne " . $elem->ligne;
if ($elem->remarque != "") {
$ligne .= ", " . $elem->remarque;
}
$lignes[$elem->taux] = $ligne;
*/
$lignes[$elem->taux] = $elem->remarque;
}
return $lignes;
}
public static function getLigneReduction($taux)
{
return $_SESSION['ligneReduction'][$taux];
}
/**
* @return array liste de toutes les activités, tarifs et comptes associés
*/
public static function getActivitesTarifsEtComptes()
{
return DB::getInstance()->get(
"SELECT
services.id as idActivite,
services.label as titreActivite,
services.description as descActivite,
services_fees.id as idTarif,
services_fees.label as titreTarif,
services_fees.description as descTarif,
acc_accounts.code as numeroCpt,
acc_accounts.label as nomCpt
FROM services
LEFT JOIN services_fees ON services_fees.id_service = services.id
LEFT JOIN acc_accounts ON services_fees.id_account = acc_accounts.id
ORDER BY services.label"
);
}
/**
* @return array liste des années fiscales
*/ */
public static function getAnneesFiscales() : array public static function getAnneesFiscales() : array
{ {
@ -326,6 +383,15 @@ class Utils
return $anneesFiscales; return $anneesFiscales;
} }
public static function getLignesReduction($lesTaux)
{
foreach ($lesTaux as $elem)
{
$lignes[$elem->taux] = $elem->remarque;
}
return $lignes;
}
/** /**
* récupérer dans la config du plugin les champs des membres * récupérer dans la config du plugin les champs des membres
* utilisés pour le nom et le prénom ; ajouter/supprimer les * utilisés pour le nom et le prénom ; ajouter/supprimer les

View File

@ -4,21 +4,37 @@ namespace Garradin\Plugin\RecusFiscaux;
class Versement class Versement
{ {
public $idActivite; public $montant;
public $idTarif; public $dateMin; // estampille
public $montant; public $dateMax; // estampille
public $tauxReduction;
public function __construct( public function __construct(
$idActivite,
$idTarif,
$montant, $montant,
$tauxReduction $dateMin,
$dateMax
) )
{ {
$this->idActivite = $idActivite;
$this->idTarif = $idTarif;
$this->montant = $montant; $this->montant = $montant;
$this->tauxReduction = $tauxReduction; $this->dateMin = $dateMin;
$this->dateMax = $dateMax;
} }
/**
* ajouter un versement en fixant les dates min et max
* @param $montant
* @param $dateMin
* @param $dateMax
*/
public function ajouter($montant, $dateMin, $dateMax)
{
$this->montant += $montant;
if ($dateMin < $this->dateMin)
{
$this->dateMin = $dateMin;
}
if ($dateMax > $this->dateMax)
{
$this->dateMax = $dateMax;
}
}
} }

View File

@ -6,7 +6,7 @@
<ul> <ul>
<li{if $current_nav == 'index'} class="current"{/if}><a href="{plugin_url}">Accueil</a></li> <li{if $current_nav == 'index'} class="current"{/if}><a href="{plugin_url}">Accueil</a></li>
<li{if $current_nav == 'personne'} class="current"{/if}><a href="{plugin_url file="action.php?action=personne"}">Versements par personne</a></li> <li{if $current_nav == 'personne'} class="current"{/if}><a href="{plugin_url file="action.php?action=personne"}">Versements par personne</a></li>
<li{if $current_nav == 'versements'} class="current"{/if}><a href="{plugin_url file="action.php?action=activite"}">Versements par activité et tarif</a></li> <li{if $current_nav == 'activite'} class="current"{/if}><a href="{plugin_url file="action.php?action=activite"}">Versements par activité et tarif</a></li>
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)} {if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)}
<li{if $current_nav == 'config'} class="current"{/if}><a href="{plugin_url file="config.php"}">Configuration</a></li> <li{if $current_nav == 'config'} class="current"{/if}><a href="{plugin_url file="config.php"}">Configuration</a></li>
{/if} {/if}

20
templates/choix_annee.tpl Normal file
View File

@ -0,0 +1,20 @@
{include file="admin/_head.tpl" title="Changer d'année fiscale"}
<form method="post" action="{$self_url}" data-focus="1">
<fieldset>
<legend>Changer l'année fiscale des reçus</legend>
<select id="annee_recu" name="annee_recu">
{foreach from=$anneesFiscales item="annee"}
<option value="{$annee}" {if $annee == $annee_recu} selected{/if}>{$annee}
</option>
{/foreach}
</select>
</fieldset>
<p class="submit">
{csrf_field key="acc_select_year"}
<input type="hidden" name="from" value="{$from}" />
{button type="submit" name="change" label="Changer" shape="right" class="main"}
</p>
</form>
{include file="admin/_foot.tpl"}

View File

@ -29,9 +29,9 @@
{input type="checkbox" name="articlesCGI[]" value=$key label=$article.titre} {input type="checkbox" name="articlesCGI[]" value=$key label=$article.titre}
*} *}
<div> <div>
<input type="checkbox" name="articlesCGI[]" value="{$key}" class="choix" <input type="checkbox" name="articlesCGI[]" id="article_{$key}" value="{$key}" class="choix"
{if $article.valeur == 1}checked{/if} /> {if $article.valeur == 1}checked{/if} />
<label>Article {$article.titre}</label> <label for="article_{$key}">Article {$article.titre}</label>
</div> </div>
{/foreach} {/foreach}
</dl> </dl>
@ -43,9 +43,9 @@
</dt> </dt>
{foreach from=$plugin_config->reduction key="key" item="taux"} {foreach from=$plugin_config->reduction key="key" item="taux"}
<div> <div>
<input type="checkbox" name="tauxReduction[]" value="{$key}" class="choix" <input type="checkbox" name="tauxReduction[]" id="taux_{$key}" value="{$key}" class="choix"
{if $taux.valeur == 1}checked{/if} /> {if $taux.valeur == 1}checked{/if} />
<label>Taux {$taux.taux}, ligne {$taux.ligne} de la déclaration <label for="taux_{$key}">Taux {$taux.taux}, ligne {$taux.ligne} de la déclaration
{if $taux.remarque !== ""}({$taux.remarque})</label>{/if} {if $taux.remarque !== ""}({$taux.remarque})</label>{/if}
</div> </div>
{/foreach} {/foreach}
@ -92,10 +92,11 @@
<div> <div>
{foreach from=$champsNom key="nom" item="champ"} {foreach from=$champsNom key="nom" item="champ"}
<div> <div class="champnom">
<input type="checkbox" name="champsNom[]" value={$nom} class="choix" {if $nbChamps == 1 || $champ.position != 0}checked{/if} /> <div class="actions"></div>
<label>{$champ.titre}</label> <div class="infos">
<div class="actions"> <input type="checkbox" name="champsNom[]" id="champ_{$nom}" value={$nom} class="choix" {if $nbChamps == 1 || $champ.position != 0}checked{/if} />
<label for="champ_{$nom}">{$champ.titre}</label>
</div> </div>
</div> </div>
{/foreach} {/foreach}

View File

@ -1,53 +1,42 @@
<!-- nav bar --> <!-- nav bar -->
{include file="%s/templates/_nav.tpl"|args:$plugin_root current_nav="index"} {include file="%s/templates/_nav.tpl"|args:$plugin_root current_nav="index"}
<h2>Choisir l'année fiscale</h2> <nav class="acc-year">
<h4>Année fiscale sélectionnée&nbsp;:</h4>
<h3>{$annee_recu}</h3>
<footer>{linkbutton label="Changer d'année fiscale" href="%s/choix_annee.php?from=%s"|args:PLUGIN_URL,rawurlencode($self_url) shape="settings"}</footer>
</nav>
<form id="formulaire_saisie" method="post" action="action.php"> <form id="formulaire_saisie" method="post" action="action.php">
<fieldset>
{* <legend>Choisir l'année fiscale</legend> *}
<select id="annee_recu" name="annee_recu">
{foreach from=$anneesFiscales item="annee"}
<option value="{$annee}" {if $annee == $anneeCourante - 1} selected{/if}>{$annee}
</option>
{/foreach}
</select>
</fieldset>
<div id="choix_methode"> <div id="choix_methode">
<h2>Choisir une méthode de génération des reçus</h2> <h3>Sélectionner les versements pour les reçus</h3>
<fieldset> <fieldset>
{* <legend>Choisir une des méthodes</legend> *} {* <legend>Choisir une des méthodes</legend> *}
<dl> <dl id="menu">
<dd class="radio-btn"> <dd class="radio-btn">
<input type="radio" id="radio_versements_personne" name="choix_versements" value="personne" <input type="radio" id="radio_versements_personne" name="choix_versements" value="personne"
onclick="choixMethodeGeneration(this.form, 'personne', '.tous', '.activites');" /> onclick="choixMethodeGeneration(this.form, 'personne', 'menu_versements', '.menu');" />
<label for="radio_versements_personne"> <label for="radio_versements_personne">
<div class="explications"> <div class="explications">
<h5> <h5>
Tous les versements des membres font l'objet d'un reçu, sans Seuls les versements des personnes importent.
tenir compte des activités et tarifs
</h5> </h5>
<p>Choisissez cette option si vous voulez sélectionner les versements d'une, plusieurs <p class="help">Choisissez cette option si vous n'avez pas besoin des activités ni des tarifs</p>
ou toutes les personnes</p>
</div> </div>
</label> </label>
</dd> </dd>
<dd class="radio-btn"> <dd class="radio-btn">
<input type="radio" id="radio_versements_activites" name="choix_versements" <input type="radio" id="radio_versements_activites" name="choix_versements" value="activite"
value="activite" onclick="choixMethodeGeneration(this.form, 'activite', '.activites', '.tous');" /> onclick="choixMethodeGeneration(this.form, 'activite', 'menu_activites_tarifs', '.menu');" />
<label for="radio_versements_activites"> <label for="radio_versements_activites">
<div class="explications"> <div class="explications">
<h5> <h5>
Seuls les versements de certaines activités et tarifs font Certaines activités, certains tarifs ou certains comptes importent.
l'objet d'un reçu
</h5> </h5>
<p>Choisissez cette option si vous voulez sélectionner :</p> <p class="help">Choisissez cette option pour classer les versements par activités, tarifs et comptes</p>
<ul>
<li>certaines activités ou certains tarifs</li>
<li>certains versements de certaines personnes</li>
</ul>
</div> </div>
</label> </label>
</dd> </dd>
@ -55,109 +44,146 @@
</fieldset> </fieldset>
</div> </div>
{* Toutes les personnes *} {* Tous les versements *}
<div id="div_taux_reduc" class="tous hidden"> <div id="menu_versements" class="menu hidden">
<h2>Choisir le taux de réduction</h2> <h3>Choisir le taux de réduction</h3>
<fieldset> <fieldset>
{if $nbTaux == 0} {if $nbTaux == 0}
<h3 class="warning">Vous devez d'abord sélectionner au moins un taux de réduction dans l'onglet de <h3 class="warning">Vous devez d'abord sélectionner au moins un taux de réduction dans l'onglet de configuration</h3>
configuration</h3>
{/if} {/if}
{if $nbChamps == 0} {if $nbChamps == 0}
<h3 class="warning">Vous devez d'abord sélectionner au moins un champ pour le nom et le prénom dans l'onglet <h3 class="warning">Vous devez d'abord sélectionner au moins un champ pour le nom et le prénom dans l'onglet de configuration</h3>
de configuration</h3>
{/if} {/if}
{if $nbTaux > 0 && $nbChamps > 0} {if $nbTaux > 0 && $nbChamps > 0}
<ul class="reduction">
{foreach from=$plugin_config->reduction item="reduc"} {foreach from=$plugin_config->reduction item="reduc"}
{if $reduc->valeur == 1} {if $reduc->valeur == 1}
<li>
<span class="radio-btn"> <span class="radio-btn">
<input type="radio" id="{$reduc->taux}" name="taux_reduction" value="{$reduc->taux}" <input
{if $nbTaux == 1}checked{/if} /> type="radio"
id="{$reduc->taux}"
name="taux_reduction"
value="{$reduc->taux}"
{if $nbTaux == 1}checked{/if}
/>
<label for="{$reduc->taux}">{$reduc->taux}{if $reduc->remarque != ""} - {$reduc->remarque}{/if}</label> <label for="{$reduc->taux}">{$reduc->taux}{if $reduc->remarque != ""} - {$reduc->remarque}{/if}</label>
</span> </span>
</li>
{/if} {/if}
{/foreach} {/foreach}
</ul>
{/if} {/if}
</fieldset> </fieldset>
</div>
<div id="generer_tous" class="tous hidden"> <p class="submit">
<p class=" submit">
{csrf_field key="generer_tous_recus"} {csrf_field key="generer_tous_recus"}
{button type="submit" name="generer_tous" label="Poursuivre" shape="right" class="main" onclick="return verifierRadio('div_taux_reduc');" } {button type="submit" name="generer_tous" label="Poursuivre" shape="right" class="main" onclick="return verifierRadio('menu_versements');" }
</p> </p>
</div> </div>
{* Activités et tarifs *} {* Activités, tarifs et comptes *}
<div id="liste_activites_tarifs" class="activites hidden"> <div id="menu_activites_tarifs" class="menu hidden">
<h2>Choisir les activités et tarifs concernés par les reçus ainsi que le taux de réduction</h2> <h3>Choisir les activités, tarifs et comptes concernés ainsi que le taux de réduction</h3>
<fieldset> <fieldset>
{if $nbTaux == 0} {if $nbTaux == 0}
<h3 class="warning">Vous devez d'abord sélectionner au moins un taux de réduction dans l'onglet de <h3 class="warning">Vous devez d'abord sélectionner au moins un taux de réduction dans l'onglet de configuration</h3>
configuration</h3>
{/if} {/if}
{if $nbChamps == 0} {if $nbChamps == 0}
<h3 class="warning">Vous devez d'abord sélectionner au moins un champ pour le nom et le prénom dans l'onglet <h3 class="warning">Vous devez d'abord sélectionner au moins un champ pour le nom et le prénom dans l'onglet de configuration</h3>
de configuration</h3 {/if} {if $nbTaux > 0 && $nbChamps > 0} <table class="list"> {/if}
<thead> {if $nbTaux > 0 && $nbChamps > 0}
<tr> <ul id="liste_activites">
<th>Activité et Tarif</th> {foreach from=$activitesTarifsComptes item="elem"}
<th>Cocher</th> <li>
<th>Taux de réduction</th> <?php
<th>Caractéristiques activité</th> $tarif = $lesTarifs[$elem->idTarif];
<th>N° et Compte</th> $compte = $lesComptes[$elem->idCompte];
</tr> $activite = $lesActivites[$tarif->idActivite];
</thead> ?>
<tbody> <div class="activite">
{foreach from=$activitesTarifsComptes item="activite"} {if $nbTarifs == 1}
<tr> {input
<td> type="checkbox"
<span>{$activite.titreActivite} - {$activite.titreTarif}</span> name="tarifs[]"
</td> value="%s_%s"|args:$elem.idTarif,$elem.idCompte
<td> label="Activité « %s » - tarif « %s » ;"|args:$activite.label,$tarif.label
{if $nbTarifs == 1} checked="checked"
{input }
type="checkbox" {else}
name="tarifs[]" {input
value=$activite.idTarif type="checkbox"
checked="checked" name="tarifs[]"
} value="%s_%s"|args:$elem.idTarif,$elem.idCompte
{else} label="Activité « %s » - tarif « %s » ;"|args:$activite.label,$tarif.label
{input }
type="checkbox" {/if}
name="tarifs[]" <span>compte : {$elem.codeCompte} ({$compte->nomCompte})</span>
value=$activite.idTarif </div>
} <ul class="reduction">
{/if}
</td>
<td>
{foreach from=$plugin_config->reduction item="reduc"} {foreach from=$plugin_config->reduction item="reduc"}
{if $reduc->valeur == 1} {if $reduc->valeur == 1}
<li>
<span class="radio-btn"> <span class="radio-btn">
<input type="radio" id="taux_{$reduc->taux}_{$activite.idTarif}" <input
name="taux_reduction_{$activite.idTarif}" value="{$reduc->taux}" type="radio"
{if $nbTarifs > 1}disabled{/if} {if $nbTaux == 1}checked{/if} /> id="taux_{$reduc->taux}_{$elem.idTarif}_{$elem.idCompte}"
<label name="taux_reduction_{$elem.idTarif}_{$elem.idCompte}"
for="taux_{$reduc->taux}_{$activite.idTarif}">{$reduc->taux}{if $reduc->remarque != ""} value="{$reduc->taux}"
- {$reduc->remarque}{/if}</label> {if $nbTarifs > 1}disabled{/if}
{if $nbTaux == 1}checked{/if}
/>
<label for="taux_{$reduc->taux}_{$elem.idTarif}_{$elem.idCompte}">
{$reduc->taux}{if $reduc->remarque != ""} - {$reduc->remarque}{/if}</label>
</span> </span>
</li>
{/if} {/if}
{/foreach} {/foreach}
</td> </ul>
<td>{if $activite.descActivite != ""}{$activite.descActivite} ; {/if}{$activite.descTarif}</td> </li>
<td>{$activite.numeroCpt} : {$activite.nomCpt}</td>
</tr>
{/foreach} {/foreach}
</tbody> {* comptes non rattachés à une activité *}
</table> {foreach from=$comptesSansActivite item="idCompte"}
<li>
<div class="activite">
{input
type="checkbox"
name="comptes[]"
value="%s"|args:$idCompte
label="Versements non rattachés à une activité ;"
}
<?php $compte = $lesComptes[$idCompte]; ?>
<span>compte : {$compte.codeCompte} ({$compte.nomCompte})</span>
</div>
<ul class="reduction">
{foreach from=$plugin_config->reduction item="reduc"}
{if $reduc->valeur == 1}
<li>
<span class="radio-btn">
<input
type="radio"
id="taux_{$reduc->taux}_{$idCompte}"
name="taux_reduction_{$idCompte}"
value="{$reduc->taux}"
disabled
{if $nbTaux == 1}checked{/if}
/>
<label for="taux_{$reduc->taux}_{$idCompte}">
{$reduc->taux}{if $reduc->remarque != ""} - {$reduc->remarque}{/if}</label>
</span>
</li>
{/if}
{/foreach}
</ul>
</li>
{/foreach}
</ul>
{/if} {/if}
</fieldset> </fieldset>
</div>
<div id="generer_activites" class="activites hidden"> <p class="submit">
<p class=" submit">
{csrf_field key="generer_recus_activites"} {csrf_field key="generer_recus_activites"}
{button type="submit" name="generer_activites" label="Poursuivre" shape="right" class="main" onclick="return verifierCases('liste_activites_tarifs');" } {button type="submit" name="generer_activites" label="Poursuivre" shape="right" class="main" onclick="return verifierCases('menu_activites_tarifs');" }
</p> </p>
</div> </div>
</form> </form>
@ -169,8 +195,8 @@
for (var laCase of document.querySelectorAll("input[type=checkbox]")) { for (var laCase of document.querySelectorAll("input[type=checkbox]")) {
laCase.addEventListener('change', (evt) => { laCase.addEventListener('change', (evt) => {
var idCase = evt.target; var idCase = evt.target;
// chercher la ligne englobante (<tr>) // chercher la ligne englobante (<li>)
var ligne = idCase.closest("tr"); var ligne = idCase.closest("li");
// itérer sur les radio de cette ligne // itérer sur les radio de cette ligne
var lesRadios = ligne.querySelectorAll('input[type=radio]'); var lesRadios = ligne.querySelectorAll('input[type=radio]');
for (var idRadio of lesRadios) { for (var idRadio of lesRadios) {

View File

@ -117,7 +117,14 @@
{{if $libelle != ""}} {{if $libelle != ""}}
({{$libelle}}) ({{$libelle}})
{{/if}} {{/if}}
<br />date des versements :
{{if $dateMin == $dateMax}}
le {{$dateMin}}
{{else}}
du {{$dateMin}} au {{$dateMax}}
{{/if}}
</li> </li>
<br />
{{/versements}} {{/versements}}
</ul> </ul>

View File

@ -1,65 +1,78 @@
<!-- nav bar --> <!-- nav bar -->
{include file="%s/templates/_nav.tpl"|args:$plugin_root current_nav="versements"} {include file="%s/templates/_nav.tpl"|args:$plugin_root current_nav="activite"}
<h2>Versements par activité et tarif</h2> <h2>Versements par activité et tarif</h2>
<fieldset class="noprint"> <fieldset class="noprint">
<input type="checkbox" class="check_global" id="check_global" onclick="cocherDecocherTout(check_global)" /> <input type="checkbox" class="check_global" id="check_global" onclick="cocherDecocherTout(check_global)" />
<label for="check_global">Cliquer pour cocher toutes les lignes</label> <label for="check_global">Cliquer pour cocher toutes les lignes</label>
<button type="button" data-icon="↑" class="icn-btn" id="close_details_activite" onclick="montrerMasquerDetails(this.id, 'details.activite', 'toutes les activités')">Replier toutes les activités</button> <button type="button" data-icon="↑" class="icn-btn" id="close_details_activite"
<button type="button" data-icon="↑" class="icn-btn" id="close_details_personne" onclick="montrerMasquerDetails(this.id, 'details.personne', 'toutes les personnes')">Replier toutes les personnes</button> onclick="montrerMasquerDetails(this.id, 'details.activite', 'toutes les activités')">Replier toutes les
<input type="submit" value="Générer les reçus" form="versements_activites" onclick="return verifierChoix(this.form)" /> activités</button>
<button type="button" data-icon="↑" class="icn-btn" id="close_details_personne"
onclick="montrerMasquerDetails(this.id, 'details.personne', 'toutes les personnes')">Replier toutes les
personnes</button>
<input type="submit" value="Générer les reçus" form="versements_activites"
onclick="return verifierChoix(this.form)" />
</fieldset> </fieldset>
<form method="post" id="versements_activites" action="generer_recus.php?type=activite"> <form method="post" id="versements_activites" action="generer_recus.php?type=activite">
{* Itération sur les versements *} {* Itération sur les versements *}
<?php $rang = 0; ?> {foreach from=$lesVersements key="rang" item="versement"}
{foreach from=$lesVersements key="num" item="versement"}
{if $rang == 0} {if $rang == 0}
{* premier versement *} {* premier versement *}
<?php <?php
$tarifCourant = $versement->idTarif; $pair = true;
$personneCourante = $versement->idUser; $tarifCourant = $versement->idTarif;
$personneCourante = $versement->idUser;
$compteCourant = $versement->idCompte;
?> ?>
{afficher_debut_tarif versement=$versement} {afficher_debut_tarif versement=$versement}
{afficher_debut_personne user=$personneCourante idVersement="%s_%s"|args:$tarifCourant,$personneCourante} {afficher_debut_personne user=$personneCourante idVersement="%s_%s"|args:$tarifCourant,$personneCourante}
{afficher_versement versement=$versement idVersement="%s_%s"|args:$tarifCourant,$personneCourante num=$num rang=$rang} {afficher_debut_compte idCompte=$compteCourant}
{else} {elseif $versement.idTarif != $tarifCourant}
{* autre versement *} {* changement de tarif *}
{if $versement.idTarif != $tarifCourant} {fin_compte}
{* changement de tarif *} {fin_personne}
</fieldset> {* fin versements d'une personne *} {fin_tarif}
</details> {* fin versements d'une personne *} <?php
</details> {* fin tarif *} $pair = true;
<?php
$rang=0;
$tarifCourant = $versement->idTarif; $tarifCourant = $versement->idTarif;
$personneCourante = $versement->idUser; $personneCourante = $versement->idUser;
?> $compteCourant = $versement->idCompte;
{afficher_debut_tarif versement=$versement} ?>
{afficher_debut_personne user=$personneCourante idVersement="%s_%s"|args:$tarifCourant,$personneCourante} {afficher_debut_tarif versement=$versement}
{afficher_versement versement=$versement idVersement="%s_%s"|args:$tarifCourant,$personneCourante num=$num rang=$rang} {afficher_debut_personne user=$personneCourante idVersement="%s_%s"|args:$tarifCourant,$personneCourante}
{elseif $versement.idUser != $personneCourante} {afficher_debut_compte idCompte=$compteCourant}
{* changement de personne *} {elseif $versement.idUser != $personneCourante}
<?php $rang = 0; ?> {* changement de personne *}
</fieldset> {fin_compte}
</details> {fin_personne}
<?php <?php
$pair = true;
$personneCourante = $versement->idUser; $personneCourante = $versement->idUser;
?> $compteCourant = $versement->idCompte;
{afficher_debut_personne user=$personneCourante idVersement="%s_%s"|args:$tarifCourant,$personneCourante} ?>
{afficher_versement versement=$versement idVersement="%s_%s"|args:$tarifCourant,$personneCourante num=$num rang=$rang} {afficher_debut_personne user=$personneCourante idVersement="%s_%s"|args:$tarifCourant,$personneCourante}
{else} {afficher_debut_compte idCompte=$compteCourant}
{* même personne *} {elseif $versement.idCompte != $compteCourant}
{afficher_versement versement=$versement idVersement="%s_%s"|args:$tarifCourant,$personneCourante num=$num rang=$rang} {fin_compte}
{/if} {* changement de compte *}
<?php
$pair = true;
$compteCourant = $versement->idCompte;
?>
{afficher_debut_compte idCompte=$compteCourant}
{else}
{* même personne, même compte *}
{/if} {/if}
<?php ++$rang; ?> {afficher_versement versement=$versement idVersement="%s_%s"|args:$tarifCourant,$personneCourante rang=$rang pair=$pair}
{/foreach} {* Itération sur les versements *} <?php $pair = ! $pair; ?>
</fieldset> {* fin versements d'une personne *} {/foreach} {* Itération sur les versements *}
</details> {* fin versements d'une personne *} {fin_compte}
</details> {* fin tarif *} {fin_personne}
{fin_tarif}
<input type="submit" value="Générer les reçus" onclick="return verifierChoix(this.form)" /> <input type="submit" value="Générer les reçus" onclick="return verifierChoix(this.form)" />
</form> </form>

View File

@ -14,36 +14,46 @@
onclick="return verifierChoix(this.form)" /> onclick="return verifierChoix(this.form)" />
</fieldset> </fieldset>
<form method="post" id="versements_personnes" action="generer_recus.php?type=personne"> <form method="post" id="versements_personnes" class="" action="generer_recus.php?type=personne">
{* Itération sur les personnes *} {* Itération sur les personnes *}
<?php $rang = 0; ?> {foreach from=$lesVersements key="rang" item="versement"}
{foreach from=$lesVersements key="num" item="versement"}
{if $rang == 0} {if $rang == 0}
{* 1ère personne *} {* 1ère personne *}
<?php <?php
$personneCourante = $versement->idUser; $pair = true;
$personneCourante = $versement->idUser;
$compteCourant = $versement->idCompte;
?> ?>
{afficher_debut_personne user=$personneCourante idVersement=$personneCourante} {afficher_debut_personne user=$personneCourante idVersement=$personneCourante}
{afficher_versement versement=$versement idVersement=$personneCourante num=$num rang=$rang} {afficher_debut_compte idCompte=$compteCourant}
{elseif $versement.idUser != $personneCourante} {elseif $versement.idUser != $personneCourante}
{* changement de personne *} {* changement de personne *}
<?php $rang = 0; ?> {fin_compte}
</fieldset> {fin_personne}
</details>
<?php <?php
$personneCourante = $versement->idUser; $pair = true;
$personneCourante = $versement->idUser;
$compteCourant = $versement->idCompte;
?> ?>
{afficher_debut_personne user=$personneCourante idVersement=$personneCourante} {afficher_debut_personne user=$personneCourante idVersement=$personneCourante}
{afficher_versement versement=$versement idVersement=$personneCourante num=$num rang=$rang} {afficher_debut_compte idCompte=$compteCourant}
{elseif $versement.idCompte != $compteCourant}
{fin_compte}
{* changement de compte *}
<?php
$pair = true;
$compteCourant = $versement->idCompte;
?>
{afficher_debut_compte idCompte=$compteCourant}
{else} {else}
{* même personne *} {* même personne, même compte *}
{afficher_versement versement=$versement idVersement=$personneCourante num=$num rang=$rang}
{/if} {/if}
<?php ++$rang; ?> {afficher_versement versement=$versement idVersement=$personneCourante rang=$rang pair=$pair}
<?php $pair = ! $pair; ?>
{/foreach} {* Itération sur les personnes *} {/foreach} {* Itération sur les personnes *}
</fieldset> {fin_compte}
</details> {fin_personne}
<input type="submit" value="Générer les reçus" onclick="return verifierChoix(this.form)" /> <input type="submit" value="Générer les reçus" onclick="return verifierChoix(this.form)" />
</form> </form>

View File

@ -8,12 +8,6 @@ use Garradin\Plugin\RecusFiscaux\Utils;
// opérations communes // opérations communes
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// vérifier si l'année a bien été sélectionnée au préalable
$_SESSION['annee_recu'] = f('annee_recu');
if (! isset($_SESSION['annee_recu']) || $_SESSION['annee_recu'] == "") {
\Garradin\Utils::redirect(PLUGIN_URL . 'index.php');
}
// champs pour le nom et prénom // champs pour le nom et prénom
$confNoms = Utils::getChampsNom($config, $plugin); $confNoms = Utils::getChampsNom($config, $plugin);
uasort($confNoms, function ($a, $b) uasort($confNoms, function ($a, $b)
@ -30,6 +24,37 @@ foreach ($confNoms as $nom => $champ)
$_SESSION['membresDonateurs'] = Utils::getDonateurs($_SESSION['annee_recu'], $_SESSION['membresDonateurs'] = Utils::getDonateurs($_SESSION['annee_recu'],
$champsNom); $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 // fonctions pour l'affichage
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -39,27 +64,48 @@ $tpl->register_function('afficher_debut_tarif', function ($params)
{ {
$versement = $params['versement']; $versement = $params['versement'];
$idTarif = $versement->idTarif; $idTarif = $versement->idTarif;
$tarif = $_SESSION['lesTarifs'][$idTarif];
$idActivite = $tarif->idActivite; $out = sprintf('
$activite = $_SESSION['lesActivites'][$idActivite]; <details class="activite" open="open">
<summary class="activite">
$out = '<details class="activite" open="open"> <div class="activite">
<summary class="activite">'; <input type="checkbox" id="check_%1$s"
$out .= sprintf(' onclick="cocherDecocherTarif(check_%1$s)" />',
<h3>Activité « %s »</h3>', $activite->label); $idTarif);
if (!empty($activite->description)) { if ($idTarif == 0) {
// versement sur un compte non rattaché à une activité
$out .= sprintf(' $out .= sprintf('
<h4>%s</h4>', $activite->description); <label for="check_%s">
<h3 class="activite">Versements non rattachés à une activité</h3>',
$idTarif);
} }
$out .= sprintf(' else {
<h4>tarif « %s »', $tarif->label); $tarif = $_SESSION['lesTarifs'][$idTarif];
if ($tarif->montant > 0) { $idActivite = $tarif->idActivite;
$out .= sprintf(' montant : %.2f €', $tarif->montant/100); $activite = $_SESSION['lesActivites'][$idActivite];
} else {
$out .= ' montant : libre'; $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 .= '</h4> $out .= '
</summary>'; </label>
</div>
</summary>';
return $out; return $out;
}); });
@ -70,25 +116,33 @@ $tpl->register_function('afficher_debut_personne', function ($params)
$idVersement = $params['idVersement']; $idVersement = $params['idVersement'];
$personne = $_SESSION['membresDonateurs'][$idUser]; $personne = $_SESSION['membresDonateurs'][$idUser];
$out = '<details class="personne" open="open"> $out = sprintf('
<summary class="personne"> <details class="personne" open="open">
<h4 class="personne">'; <summary class="personne">
$out .= sprintf(' <div class="personne">
<input type="checkbox" id="check_%s"', <input type="checkbox" id="check_%1$s"
$idVersement); onclick="cocherDecocherPersonne(check_%1$s, total_%1$s)" />
$out .= sprintf(' onclick="cocherDecocherPersonne(check_%s, total_%s)" />', <label for="check_%1$s">
$idVersement, %2$s : <span class="total" id="total_%1$s">0,00 </span>
$idVersement); </label>
$out .= sprintf(' </div>
<label for="check_%s">', </summary>
$idVersement); <div class="versements">',
$out .= sprintf('%s : <span class="total" id="total_%s">0,00 €</span>', $idVersement,
$personne->nomPrenom, $personne->nomPrenom
$idVersement); );
$out .= '</label></h4></summary>'; return $out;
$out .= sprintf(' });
<fieldset class="versements" id="versements_%s">',
$idVersement); // afficher infos compte
$tpl->register_function('afficher_debut_compte', function ($params)
{
$idCompte = $params['idCompte'];
$out = sprintf('
<fieldset class="versements">
<div><p>Compte %1$s : %2$s</p></div>',
$_SESSION['comptes'][$idCompte]->codeCompte,
$_SESSION['comptes'][$idCompte]->nomCompte);
return $out; return $out;
}); });
@ -97,45 +151,65 @@ $tpl->register_function('afficher_versement', function ($params)
{ {
$versement = $params['versement']; $versement = $params['versement'];
$idVersement = $params['idVersement']; $idVersement = $params['idVersement'];
$num = $params['num'];
$rang = $params['rang']; $rang = $params['rang'];
$pair = $params['pair'];
$out = '<div class="'; $out = '<div class="';
$out .= ($rang%2==0) ? 'pair">' : 'impair">'; $out .= $pair ? 'pair">' : 'impair">';
$out .= sprintf(' $out .= sprintf('
<input type="checkbox" <input type="checkbox"
class="check_%s" class="check_%1$s"
id="check_%s_%s" id="check_%1$s_%2$s"
name="selected[]" name="selected[]"
value="%s" value="%2$s"
onclick="cocherDecocherVersement(check_%s_%s, total_%s)" />', onclick="cocherDecocherVersement(check_%1$s_%2$s, total_%1$s)" />
$idVersement, <label for="check_%1$s_%2$s"><span class="montant">%3$s</span>
$idVersement, $rang, <span>%4$s</span>
$num, </label>
$idVersement, $rang, $idVersement </div>',
);
$out .= sprintf('
<label for="check_%s_%s"><span class="montant">%.2f</span>',
$idVersement, $idVersement,
$rang, $rang,
$versement->versement/100 number_format(
); $versement->versement/100,
$out .= sprintf(' 2,
<span>%s</span>', ",",
date_format(date_create($versement->date),"d/m/Y")); "&nbsp;"
$out .= sprintf(' ),
</label> date_format(date_create($versement->date),"d/m/Y")
</div>'
); );
return $out; 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 // aiguillage
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
if ($_GET['action'] == 'personne') { if ($_GET['action'] == 'personne') {
require('versements_personnes.php'); require('versements_personnes.php');
} else { } else if ($_GET['action'] == 'compte') {
require('versements_personnes.php');
} else if ($_GET['action'] == 'activite') {
require('versements_activites.php'); require('versements_activites.php');
} }

24
www/admin/choix_annee.php Normal file
View File

@ -0,0 +1,24 @@
<?php
namespace Garradin;
use Garradin\Plugin\RecusFiscaux\Utils;
// liste des années fiscales
$anneeCourante = date("Y");
$anneesFiscales = Utils::getAnneesFiscales();
if ($anneesFiscales[0] < $anneeCourante) {
array_unshift($anneesFiscales, $anneeCourante);
}
if (f('change'))
{
$_SESSION['annee_recu'] = f('annee_recu');
\Garradin\Utils::redirect(f('from') ?: PLUGIN_URL);
}
$tpl->assign('anneesFiscales', $anneesFiscales);
$tpl->assign('annee_recu', $_SESSION['annee_recu']);
$tpl->assign('from', qg('from'));
$tpl->display(PLUGIN_ROOT . '/templates/choix_annee.tpl');

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

View File

@ -4,17 +4,13 @@ namespace Garradin;
use Garradin\Plugin\RecusFiscaux\Utils; use Garradin\Plugin\RecusFiscaux\Utils;
// première année d'exercice // Année fiscale par défaut
$anneeCourante = date("Y"); if (! isset($_SESSION['annee_recu']) || $_SESSION['annee_recu'] == "")
$anneesFiscales = Utils::getAnneesFiscales(); {
if ($anneesFiscales[0] < $anneeCourante) { $_SESSION['annee_recu'] = date("Y") - 1;
array_unshift($anneesFiscales, $anneeCourante);
} }
// libellés pour les taux de réduction // nombre de taux de réduction activés
$_SESSION['ligneReduction'] = Utils::getLignesReduction($plugin->getConfig('reduction'));
// compter le nombre de taux de réduction activés
$nbTaux = 0; $nbTaux = 0;
foreach ($plugin->getConfig('reduction') as $taux) foreach ($plugin->getConfig('reduction') as $taux)
{ {
@ -24,7 +20,6 @@ foreach ($plugin->getConfig('reduction') as $taux)
// idem avec les champs nom/prénom // idem avec les champs nom/prénom
$nbChamps = 0; $nbChamps = 0;
$champsNom = Utils::getChampsNom($config, $plugin); $champsNom = Utils::getChampsNom($config, $plugin);
if (null !== $champsNom) if (null !== $champsNom)
{ {
foreach ($champsNom as $nom => $champ) foreach ($champsNom as $nom => $champ)
@ -33,14 +28,36 @@ if (null !== $champsNom)
} }
} }
// 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, cotisations et comptes associés // liste des activités, cotisations et comptes associés
$activitesTarifsComptes = Utils::getActivitesTarifsEtComptes(); $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 // préparation de l'affichage
$tpl->assign('anneesFiscales', $anneesFiscales); $tpl->assign('annee_recu', $_SESSION['annee_recu']);
$tpl->assign('anneeCourante', $anneeCourante); $tpl->assign('lesComptes', $_SESSION['comptes']);
$tpl->assign('lesTarifs', $_SESSION['lesTarifs']);
$tpl->assign('lesActivites', $_SESSION['lesActivites']);
$tpl->assign('activitesTarifsComptes', $activitesTarifsComptes); $tpl->assign('activitesTarifsComptes', $activitesTarifsComptes);
$tpl->assign('comptesSansActivite', $comptesSansActivite);
$tpl->assign('nbTarifs', count($activitesTarifsComptes)); $tpl->assign('nbTarifs', count($activitesTarifsComptes));
$tpl->assign('nbComptes', count($_SESSION['comptes']));
$tpl->assign('plugin_config', $plugin->getConfig()); $tpl->assign('plugin_config', $plugin->getConfig());
$tpl->assign('nbTaux', $nbTaux); $tpl->assign('nbTaux', $nbTaux);
$tpl->assign('nbChamps', $nbChamps); $tpl->assign('nbChamps', $nbChamps);

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
/** /**
* Fonction appelée quand on ()coche la case de sélection globale * Fonction appelée quand on ()coche la case globale
* ()sélectionner toutes les cases à cocher de toutes les activités * ()sélectionner toutes les cases de toutes les activités
* @param {HTMLInputElement} idCaseGlobale id de la case globale * @param {HTMLInputElement} idCaseGlobale id de la case globale
*/ */
function cocherDecocherTout(idCaseGlobale) function cocherDecocherTout(idCaseGlobale)
@ -11,21 +11,32 @@ function cocherDecocherTout(idCaseGlobale)
let lesDetails = document.querySelectorAll("details.activite"); let lesDetails = document.querySelectorAll("details.activite");
for (let i = 0; i < lesDetails.length; ++i) for (let i = 0; i < lesDetails.length; ++i)
{ {
// itérer sur les personnes let idCase = lesDetails[i].querySelector("input[type=checkbox]");
let lesPersonnes = lesDetails[i].querySelectorAll("h4.personne"); idCase.checked = idCaseGlobale.checked;
cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes); cocherDecocherTarif(idCase);
} }
// changer le message // changer le message
changerMessage(idCaseGlobale.nextElementSibling, idCaseGlobale); changerMessage(idCaseGlobale.nextElementSibling, idCaseGlobale);
} }
/**
* Fonction appelée quand on ()coche la case d'activité
* ()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 * idem dans le cas des versements des personnes
* @param {HTMLInputElement} idCaseGlobale id de la case globale * @param {HTMLInputElement} idCaseGlobale id case à cocher d'une personne
*/ */
function cocherDecocherToutesLesPersonnes(idCaseGlobale) function cocherDecocherToutesLesPersonnes(idCaseGlobale)
{ {
let lesPersonnes = document.querySelectorAll("h4.personne"); let lesPersonnes = document.querySelectorAll("div.personne");
cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes); cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes);
changerMessage(idCaseGlobale.nextElementSibling, idCaseGlobale); changerMessage(idCaseGlobale.nextElementSibling, idCaseGlobale);
} }
@ -49,7 +60,7 @@ function cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes)
} }
/** /**
* Fonction appelée quand on ()coche la case globale d'une personne * Fonction appelée quand on ()coche la case d'une personne
* - ()sélectionner toutes les cases à cocher * - ()sélectionner toutes les cases à cocher
* - faire le total des cases cochées et l'afficher * - faire le total des cases cochées et l'afficher
* @param {HTMLInputElement} idCase id de la case qui a été cochée * @param {HTMLInputElement} idCase id de la case qui a été cochée
@ -58,15 +69,13 @@ function cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes)
function cocherDecocherPersonne(idCase, idTotal) function cocherDecocherPersonne(idCase, idTotal)
{ {
// chercher le fieldset des versements // chercher le fieldset des versements
let fieldset = idCase.closest("details").querySelector("fieldset"); let fieldset = idCase.closest("details").querySelector("div.versements");
let listeCases = fieldset.querySelectorAll("input[type=checkbox]"); let listeCases = fieldset.querySelectorAll("input[type=checkbox]");
for (let i = 0; i < listeCases.length; ++i) for (let i = 0; i < listeCases.length; ++i)
{ {
listeCases[i].checked = idCase.checked; listeCases[i].checked = idCase.checked;
cocherDecocherVersement(listeCases[i], idTotal);
} }
// calculer et afficher le total
let listeMontants = fieldset.querySelectorAll("span.montant");
calculerTotal(listeCases, listeMontants, idTotal);
} }
/** /**
@ -78,7 +87,7 @@ function cocherDecocherPersonne(idCase, idTotal)
*/ */
function cocherDecocherVersement(idCase, idTotal) function cocherDecocherVersement(idCase, idTotal)
{ {
let fieldset = idCase.closest("fieldset"); let fieldset = idCase.closest("div.versements");
let listeCases = fieldset.querySelectorAll("input[type=checkbox]"); let listeCases = fieldset.querySelectorAll("input[type=checkbox]");
let listeMontants = fieldset.querySelectorAll("span.montant"); let listeMontants = fieldset.querySelectorAll("span.montant");
calculerTotal(listeCases, listeMontants, idTotal); calculerTotal(listeCases, listeMontants, idTotal);
@ -144,31 +153,26 @@ function verifierChoix(formulaire)
} }
/** /**
* positionner l'action déclenchée par l'envoi du formulaire
* afficher et masquer des portions de formulaire selon l'action * afficher et masquer des portions de formulaire selon l'action
* @param {HTMLFormElement} formulaire * @param {HTMLFormElement} formulaire
* @param {string} action après envoi du formulaire * @param {string} action après envoi du formulaire
* @param {any} nomClasse1 classe des éléments à afficher * @param {any} idElem id de l'élément à afficher
* @param {any} nomClasse2 classe des éléments à masquer * @param {any} nomClasse classe des éléments à masquer (sauf idElem)
*/ */
function choixMethodeGeneration(formulaire, action, nomClasse1, nomClasse2) function choixMethodeGeneration(formulaire, action, idElem, nomClasse)
{ {
formulaire.setAttribute('action', 'action.php?action=' + action); formulaire.setAttribute('action', 'action.php?action=' + action);
afficherMasquer(formulaire, nomClasse1, nomClasse2); for (let elem of formulaire.querySelectorAll(nomClasse))
} {
if (elem.id == idElem)
/** {
* afficher et masquer des portions de formulaire elem.classList.remove('hidden');
* @param {HTMLFormElement} formulaire }
* @param {any} nomClasse1 classe des éléments à afficher else
* @param {any} nomClasse2 classe des éléments à masquer {
*/ elem.classList.add('hidden');
function afficherMasquer(formulaire, nomClasse1, nomClasse2) }
{
for (let elem of formulaire.querySelectorAll(nomClasse1)) {
elem.classList.remove('hidden');
}
for (let elem of formulaire.querySelectorAll(nomClasse2)) {
elem.classList.add('hidden');
} }
} }
@ -190,7 +194,7 @@ function verifierCases(idElem)
// vérifier qu'un radio de la même ligne est sélectionné // vérifier qu'un radio de la même ligne est sélectionné
let ligneCorrecte = false; let ligneCorrecte = false;
// trouver la ligne englobante // trouver la ligne englobante
let ligne = idCase.closest("tr"); let ligne = idCase.closest("li");
for (let idRadio of ligne.querySelectorAll('input[type=radio]')) for (let idRadio of ligne.querySelectorAll('input[type=radio]'))
{ {
if (idRadio.checked) { ligneCorrecte = true; break; } if (idRadio.checked) { ligneCorrecte = true; break; }
@ -202,7 +206,7 @@ function verifierCases(idElem)
} }
} }
if (nbChoix == 0) { if (nbChoix == 0) {
alert("Erreur : il faut sélectionner au moins une activité/tarif"); alert("Erreur : il faut sélectionner au moins une ligne");
} }
return nbChoix != 0; return nbChoix != 0;
} }

View File

@ -1,8 +1,11 @@
/* liste des versements */ /* liste des versements */
div.impair { div.pair {
background: rgba(var(--gSecondColor), 0.15); background-color: rgba(var(--gSecondColor), 0.15);
} }
fieldset { fieldset.versements
{
margin-bottom : 0;
margin-right : 0.5em;
-webkit-border-radius:8px; -webkit-border-radius:8px;
border-radius:8px; border-radius:8px;
} }
@ -23,7 +26,6 @@ span.total
} }
summary.activite summary.activite
{ {
background: rgba(var(--gSecondColor), 0.5);
margin-bottom : 0.5em; margin-bottom : 0.5em;
} }
summary.personne summary.personne
@ -32,10 +34,22 @@ summary.personne
padding-top : 0; padding-top : 0;
padding-bottom : 0; padding-bottom : 0;
} }
h3.personne, h4.personne div.activite
{
background-color: rgba(var(--gSecondColor), 0.3);
}
div.personne
{ {
font-weight : normal; font-weight : normal;
background: rgba(var(--gSecondColor), 0.25); background-color: rgba(var(--gSecondColor), 0.25);
}
h3.activite
{
display : inline;
}
p.activite
{
margin-left : 2.5em;
} }
#signature #signature
{ {
@ -43,10 +57,6 @@ h3.personne, h4.personne
max-width: 300px; max-width: 300px;
max-height: 150px; max-height: 150px;
} }
dl.config
{
padding : 1ex 0;
}
div.explications ul div.explications ul
{ {
@ -61,3 +71,42 @@ input.check_global
{ {
margin : 0.2em 0.5em; margin : 0.2em 0.5em;
} }
dl#menu
{
min-width : 40em;
width : 50%;
}
div.versements
{
margin-left : 4em;
display: flex;
flex-wrap: wrap;
}
/* config */
dl.config
{
padding : 1ex 0;
}
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;
}

View File

@ -2,47 +2,66 @@
namespace Garradin; namespace Garradin;
use Garradin\Plugin\RecusFiscaux\Activite;
use Garradin\Plugin\RecusFiscaux\Personne; use Garradin\Plugin\RecusFiscaux\Personne;
use Garradin\Plugin\RecusFiscaux\Tarif;
use Garradin\Plugin\RecusFiscaux\Utils; use Garradin\Plugin\RecusFiscaux\Utils;
// ------------------------------------------------------------
// récupérer les infos du formulaire // récupérer les infos du formulaire
// ------------------------------------------------------------
// vérifier qu'on a bien sélectionné une activité ou un compe
if (null === f('tarifs') && null === f('comptes'))
{
\Garradin\Utils::redirect(PLUGIN_URL . 'index.php');
}
// tarifs sélectionnés
$tarifsSelectionnes = f('tarifs') ?: []; $tarifsSelectionnes = f('tarifs') ?: [];
// comptes sélectionnés
$comptesSelectionnes = f('comptes') ?: [];
// taux de réduction associés // taux de réduction associés
$tauxSelectionnes = array(); $tauxSelectionnes = array();
foreach ($tarifsSelectionnes as $idTarif) { foreach ($tarifsSelectionnes as $idTarif)
{
$nomRadio = "taux_reduction_" . $idTarif; $nomRadio = "taux_reduction_" . $idTarif;
$valRadio = f("$nomRadio"); $valRadio = f("$nomRadio");
$tauxSelectionnes[$idTarif] = $valRadio; $tauxSelectionnes[$idTarif] = $valRadio;
} }
foreach ($comptesSelectionnes as $idCompte)
{
$nomRadio = "taux_reduction_" . $idCompte;
$valRadio = f("$nomRadio");
$tauxSelectionnes[$idCompte] = $valRadio;
}
$_SESSION['tauxSelectionnes'] = $tauxSelectionnes; $_SESSION['tauxSelectionnes'] = $tauxSelectionnes;
// obtenir les instances de tarifs correspondant à la sélection // versements correspondants à la sélection, triés par tarif, nom, compte, date
$lesTarifs = array(); $lesTarifs = array_map(fn($elem) : string => substr($elem, 0, strpos($elem, '_')),
foreach (Utils::getTarifs($tarifsSelectionnes) as $ot) { $tarifsSelectionnes);
$lesTarifs[$ot->id] = $ot; $lesComptes = array_map(fn($elem) : string => substr($elem, 1 + strpos($elem, '_')),
} $tarifsSelectionnes);
$_SESSION['lesTarifs'] = $lesTarifs; $_SESSION['lesVersements'] =
Utils::getVersementsTarifsComptes(
$_SESSION['annee_recu'],
$lesTarifs,
$lesComptes,
$champsNom);
// activités correspondants aux tarifs sélectionnés // ajouter les versements sans tarif (tri par nom, compte, date)
$lesActivites = array(); $versementsSansTarif = Utils::getVersementsComptes($_SESSION['annee_recu'],
foreach (Utils::getActivites($tarifsSelectionnes) as $activite) { $comptesSelectionnes,
$lesActivites[$activite->id] = $activite; $champsNom);
foreach ($versementsSansTarif as $versement)
{
$_SESSION['lesVersements'][] = $versement;
} }
$_SESSION['lesActivites'] = $lesActivites;
// versements correspondants aux tarifs sélectionnés
$_SESSION['lesVersements'] = Utils::getVersementsTarifs($_SESSION['annee_recu'],
$tarifsSelectionnes,
$champsNom);
// préparation de l'affichage // préparation de l'affichage
$tpl->assign('lesActivites', $lesActivites);
$tpl->assign('lesTarifs', $lesTarifs);
$tpl->assign('lesVersements', $_SESSION['lesVersements']); $tpl->assign('lesVersements', $_SESSION['lesVersements']);
$tpl->assign('plugin_css', ['style.css']); $tpl->assign('plugin_css', ['style.css']);
// envoyer au template // envoyer au template
$tpl->display(PLUGIN_ROOT . '/templates/versements_activites.tpl'); $tpl->display(PLUGIN_ROOT . '/templates/versements_activites.tpl');

View File

@ -5,15 +5,24 @@ namespace Garradin;
use Garradin\Plugin\RecusFiscaux\Personne; use Garradin\Plugin\RecusFiscaux\Personne;
use Garradin\Plugin\RecusFiscaux\Utils; use Garradin\Plugin\RecusFiscaux\Utils;
$_SESSION['taux_reduction'] = $_POST['taux_reduction']; // vérifier si le taux de réduction a été sélectionné au préalable
$_SESSION['taux_reduction'] = f('taux_reduction');
if (! isset($_SESSION['taux_reduction']) || $_SESSION['taux_reduction'] == "")
{
\Garradin\Utils::redirect(PLUGIN_URL . 'index.php');
}
// versements par personne // versements par personne
$_SESSION['lesVersements'] = Utils::getVersementsPersonnes($_SESSION['annee_recu'], $_SESSION['lesVersements'] = Utils::getVersementsPersonnes(
$champsNom); $_SESSION['annee_recu'],
'like',
'7%',
$champsNom);
// préparation de l'affichage // préparation de l'affichage
$tpl->assign('lesVersements', $_SESSION['lesVersements']); $tpl->assign('lesVersements', $_SESSION['lesVersements']);
$tpl->assign('plugin_css', ['style.css']); $tpl->assign('plugin_css', ['style.css']);
// envoyer au template // envoyer au template
$tpl->assign('plugin_config', $plugin->getConfig());
$tpl->display(PLUGIN_ROOT . '/templates/versements_personnes.tpl'); $tpl->display(PLUGIN_ROOT . '/templates/versements_personnes.tpl');