ajout case tarif ; réorganisation code
FossilOrigin-Name: 80c6f13938d5f02786155717bf1ab8b89c6ade3c58bba572bf8c471b54886666
This commit is contained in:
parent
7ca41ea6b7
commit
6165ff531e
6 changed files with 177 additions and 126 deletions
|
|
@ -68,23 +68,32 @@ $tpl->register_function('afficher_debut_tarif', function ($params)
|
|||
$idActivite = $tarif->idActivite;
|
||||
$activite = $_SESSION['lesActivites'][$idActivite];
|
||||
|
||||
$out = '<details class="activite" open="open">
|
||||
<summary class="activite">';
|
||||
$out .= sprintf('
|
||||
<h3>Activité « %s »</h3>', $activite->label);
|
||||
$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)" />
|
||||
<label for="check_%1$s">
|
||||
<h3 class="activite">Activité « %2$s »</h3>',
|
||||
$idTarif,
|
||||
$activite->label);
|
||||
|
||||
if (!empty($activite->description)) {
|
||||
$out .= sprintf('
|
||||
<h4>%s</h4>', $activite->description);
|
||||
<p class="activite">%s</p>', $activite->description);
|
||||
}
|
||||
$out .= sprintf('
|
||||
<h4>tarif « %s »', $tarif->label);
|
||||
<p class="activite">tarif « %s »', $tarif->label);
|
||||
if ($tarif->montant > 0) {
|
||||
$out .= sprintf(' montant : %.2f €', $tarif->montant/100);
|
||||
$out .= sprintf(' montant : %.2f €</p>', $tarif->montant/100);
|
||||
} else {
|
||||
$out .= ' montant : libre';
|
||||
$out .= ' montant : libre</p>';
|
||||
}
|
||||
$out .= '</h4>
|
||||
</summary>';
|
||||
$out .= '
|
||||
</label>
|
||||
</div>
|
||||
</summary>';
|
||||
return $out;
|
||||
});
|
||||
|
||||
|
|
@ -95,25 +104,22 @@ $tpl->register_function('afficher_debut_personne', function ($params)
|
|||
$idVersement = $params['idVersement'];
|
||||
|
||||
$personne = $_SESSION['membresDonateurs'][$idUser];
|
||||
$out = '<details class="personne" open="open">
|
||||
<summary class="personne">
|
||||
<h4 class="personne">';
|
||||
$out .= sprintf('
|
||||
<input type="checkbox" id="check_%s"',
|
||||
$idVersement);
|
||||
$out .= sprintf(' onclick="cocherDecocherPersonne(check_%s, total_%s)" />',
|
||||
$idVersement,
|
||||
$idVersement);
|
||||
$out .= sprintf('
|
||||
<label for="check_%s">',
|
||||
$idVersement);
|
||||
$out .= sprintf('%s : <span class="total" id="total_%s">0,00 €</span>',
|
||||
$personne->nomPrenom,
|
||||
$idVersement);
|
||||
$out .= '</label></h4></summary>';
|
||||
$out .= sprintf('
|
||||
<fieldset class="versements" id="versements_%s">',
|
||||
$idVersement);
|
||||
$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>
|
||||
|
||||
<fieldset class="versements" id="versements_%1$s">',
|
||||
$idVersement,
|
||||
$personne->nomPrenom
|
||||
);
|
||||
return $out;
|
||||
});
|
||||
|
||||
|
|
@ -122,42 +128,47 @@ $tpl->register_function('afficher_versement', function ($params)
|
|||
{
|
||||
$versement = $params['versement'];
|
||||
$idVersement = $params['idVersement'];
|
||||
$num = $params['num'];
|
||||
$rang = $params['rang'];
|
||||
$pair = $params['pair'];
|
||||
|
||||
$out = '<div class="';
|
||||
$out .= ($rang%2==0) ? 'pair">' : 'impair">';
|
||||
$out .= $pair ? 'pair">' : 'impair">';
|
||||
$out .= sprintf('
|
||||
<input type="checkbox"
|
||||
class="check_%s"
|
||||
id="check_%s_%s"
|
||||
name="selected[]"
|
||||
value="%s"
|
||||
onclick="cocherDecocherVersement(check_%s_%s, total_%s)" />',
|
||||
$idVersement,
|
||||
$idVersement, $rang,
|
||||
$num,
|
||||
$idVersement, $rang, $idVersement
|
||||
);
|
||||
$out .= sprintf('
|
||||
<label for="check_%s_%s"><span class="montant">%.2f</span>',
|
||||
<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$.2f</span>
|
||||
<span>%4$s</span>
|
||||
<span>%5$s</span>
|
||||
</label>
|
||||
</div>',
|
||||
$idVersement,
|
||||
$rang,
|
||||
$versement->versement/100
|
||||
);
|
||||
$out .= sprintf('
|
||||
<span>%s</span>',
|
||||
date_format(date_create($versement->date),"d/m/Y"));
|
||||
$out .= sprintf('
|
||||
<span>%s</span>',
|
||||
$versement->compte);
|
||||
$out .= sprintf('
|
||||
</label>
|
||||
</div>'
|
||||
$versement->versement/100,
|
||||
date_format(date_create($versement->date),"d/m/Y"),
|
||||
$versement->compte
|
||||
);
|
||||
return $out;
|
||||
});
|
||||
|
||||
$tpl->register_function('fin_personne', function ($params)
|
||||
{
|
||||
$out = '
|
||||
</fieldset>
|
||||
</details>';
|
||||
return $out;
|
||||
});
|
||||
|
||||
$tpl->register_function('fin_tarif', function ($params)
|
||||
{
|
||||
$out = '
|
||||
</details>';
|
||||
return $out;
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// aiguillage
|
||||
// ------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
/**
|
||||
* Fonction appelée quand on (dé)coche la case de sélection globale
|
||||
* (dé)sélectionner toutes les cases à cocher de toutes les activités
|
||||
* 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)
|
||||
|
|
@ -11,21 +11,32 @@ function cocherDecocherTout(idCaseGlobale)
|
|||
let lesDetails = document.querySelectorAll("details.activite");
|
||||
for (let i = 0; i < lesDetails.length; ++i)
|
||||
{
|
||||
// itérer sur les personnes
|
||||
let lesPersonnes = lesDetails[i].querySelectorAll("h4.personne");
|
||||
cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes);
|
||||
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 à cocher 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 de la case globale
|
||||
* @param {HTMLInputElement} idCaseGlobale id case à cocher d'une personne
|
||||
*/
|
||||
function cocherDecocherToutesLesPersonnes(idCaseGlobale)
|
||||
{
|
||||
let lesPersonnes = document.querySelectorAll("h4.personne");
|
||||
let lesPersonnes = document.querySelectorAll("div.personne");
|
||||
cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes);
|
||||
changerMessage(idCaseGlobale.nextElementSibling, idCaseGlobale);
|
||||
}
|
||||
|
|
@ -49,7 +60,7 @@ function cocherDecocherLesPersonnes(idCaseGlobale, lesPersonnes)
|
|||
}
|
||||
|
||||
/**
|
||||
* Fonction appelée quand on (dé)coche la case globale d'une personne
|
||||
* 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
|
||||
|
|
@ -63,10 +74,8 @@ function cocherDecocherPersonne(idCase, idTotal)
|
|||
for (let i = 0; i < listeCases.length; ++i)
|
||||
{
|
||||
listeCases[i].checked = idCase.checked;
|
||||
cocherDecocherVersement(listeCases[i], idTotal);
|
||||
}
|
||||
// calculer et afficher le total
|
||||
let listeMontants = fieldset.querySelectorAll("span.montant");
|
||||
calculerTotal(listeCases, listeMontants, idTotal);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
div.impair {
|
||||
background: rgba(var(--gSecondColor), 0.15);
|
||||
}
|
||||
fieldset {
|
||||
fieldset.versements
|
||||
{
|
||||
margin-left : 4em;
|
||||
-webkit-border-radius:8px;
|
||||
border-radius:8px;
|
||||
}
|
||||
|
|
@ -23,7 +25,6 @@ span.total
|
|||
}
|
||||
summary.activite
|
||||
{
|
||||
background: rgba(var(--gSecondColor), 0.5);
|
||||
margin-bottom : 0.5em;
|
||||
}
|
||||
summary.personne
|
||||
|
|
@ -32,11 +33,19 @@ summary.personne
|
|||
padding-top : 0;
|
||||
padding-bottom : 0;
|
||||
}
|
||||
h3.personne, h4.personne
|
||||
div.personne, div.activite
|
||||
{
|
||||
font-weight : normal;
|
||||
background: rgba(var(--gSecondColor), 0.25);
|
||||
}
|
||||
h3.activite
|
||||
{
|
||||
display : inline;
|
||||
}
|
||||
p.activite
|
||||
{
|
||||
margin-left : 2.5em;
|
||||
}
|
||||
#signature
|
||||
{
|
||||
padding : 1em 0.5em 0 0.5em;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue