Amélioration gestion numéro de reçu et impression adresse courriel
FossilOrigin-Name: 7ec287c7e2886a4a91151abf97e5044eb9bf1617063fc3d0c818b5d7ab88eafb
This commit is contained in:
parent
e219afb405
commit
25cba953a7
10 changed files with 249 additions and 126 deletions
|
|
@ -7,15 +7,14 @@ use Garradin\Entities\Files\File;
|
|||
use Garradin\Plugin\RecusFiscaux\Utils;
|
||||
|
||||
$session->requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN);
|
||||
$art_sel = f('articlesCGI') ? : [];
|
||||
$taux_sel = f('tauxReduction') ? : [];
|
||||
$noms_sel = f('champsNom') ? : [];
|
||||
$art_sel = f('articlesCGI') ?: [];
|
||||
$taux_sel = f('tauxReduction') ?: [];
|
||||
$noms_sel = f('champsNom') ?: [];
|
||||
|
||||
// récupérer les champs des noms
|
||||
// récupérer les champs des noms
|
||||
$champsNom = Utils::getChampsNom($config, $plugin);
|
||||
|
||||
if (f('save') && $form->check('recusfiscaux_config'))
|
||||
{
|
||||
if (f('save') && $form->check('recusfiscaux_config')) {
|
||||
try {
|
||||
// objet de l'association
|
||||
if ($plugin->getConfig('objet_asso') != trim(f('objet_asso'))) {
|
||||
|
|
@ -26,11 +25,11 @@ if (f('save') && $form->check('recusfiscaux_config'))
|
|||
$confArticles = $plugin->getConfig('articlesCGI');
|
||||
// effacer l'ancienne configuration
|
||||
for ($i = 0; $i < count($confArticles); ++$i) {
|
||||
$confArticles[$i]->valeur = 0;
|
||||
$confArticles[$i]->valeur = false; // 0
|
||||
}
|
||||
// et copier la nouvelle
|
||||
foreach ($art_sel as $article) {
|
||||
$confArticles[$article]->valeur = 1;
|
||||
$confArticles[$article]->valeur = true; // 1
|
||||
}
|
||||
$plugin->setConfig("articlesCGI", $confArticles);
|
||||
|
||||
|
|
@ -38,28 +37,35 @@ if (f('save') && $form->check('recusfiscaux_config'))
|
|||
$confTaux = $plugin->getConfig('reduction');
|
||||
// effacer l'ancienne configuration
|
||||
for ($i = 0; $i < count($confTaux); ++$i) {
|
||||
$confTaux[$i]->valeur = 0;
|
||||
$confTaux[$i]->valeur = false; // 0
|
||||
}
|
||||
// et copier la nouvelle
|
||||
foreach ($taux_sel as $taux) {
|
||||
$confTaux[$taux]->valeur = 1;
|
||||
$confTaux[$taux]->valeur = true; // 1
|
||||
}
|
||||
$plugin->setConfig("reduction", $confTaux);
|
||||
|
||||
// nom, fonction et signature du responsable
|
||||
// Informations au sujet du responsable
|
||||
if ($plugin->getConfig('nom_responsable') != trim(f('nom_responsable'))) {
|
||||
$plugin->setConfig('nom_responsable', trim(f('nom_responsable')));
|
||||
}
|
||||
if ($plugin->getConfig('fonction_responsable') != trim(f('fonction_responsable'))) {
|
||||
$plugin->setConfig('fonction_responsable', trim(f('fonction_responsable')));
|
||||
}
|
||||
|
||||
// ville
|
||||
if ($plugin->getConfig('ville_asso') != trim(f('ville_asso'))) {
|
||||
$plugin->setConfig('ville_asso', trim(f('ville_asso')));
|
||||
}
|
||||
// signature
|
||||
if (isset($_SESSION['sig_file']) && count($_SESSION['sig_file']) > 0)
|
||||
{
|
||||
// error_log("SESSION['sig_file'] = " . print_r($_SESSION['sig_file'], true));
|
||||
// error_log("plugin->getConfig('signature') = " . $plugin->getConfig('signature'));
|
||||
|
||||
if (isset($_SESSION['sig_file']) && count($_SESSION['sig_file']) > 0) {
|
||||
// supprimer la signature précédente, si besoin
|
||||
if (null !== $plugin->getConfig('signature'))
|
||||
{
|
||||
if (
|
||||
null !== $plugin->getConfig('signature') &&
|
||||
$plugin->getConfig('signature') != $_SESSION['sig_file'][0]->path
|
||||
) {
|
||||
$sig_file = \Garradin\Files\Files::get($plugin->getConfig('signature'));
|
||||
if (null !== $sig_file) {
|
||||
$sig_file->delete();
|
||||
|
|
@ -70,49 +76,48 @@ if (f('save') && $form->check('recusfiscaux_config'))
|
|||
}
|
||||
|
||||
// autres informations
|
||||
// ville
|
||||
if ($plugin->getConfig('ville_asso') != trim(f('ville_asso'))) {
|
||||
$plugin->setConfig('ville_asso', trim(f('ville_asso')));
|
||||
// numérotation des reçus
|
||||
$configNum = $plugin->getConfig('numerotation');
|
||||
error_log("configNum=" . print_r($configNum, true));
|
||||
$formNum = clone $configNum;
|
||||
if ($configNum->prefixe != trim(f('prefixe'))) {
|
||||
$formNum->prefixe = trim(f('prefixe'));
|
||||
}
|
||||
$formNum->annee = f('annee');
|
||||
$formNum->membre = f('membre');
|
||||
$formNum->sequentiel = f('sequentiel');
|
||||
$formNum->valeur_init = f('valeur_init');
|
||||
$plugin->setConfig('numerotation', $formNum);
|
||||
|
||||
// impression des adresses de courriel
|
||||
$plugin->setConfig('imprimerCourriel', f('imprimerCourriel'));
|
||||
|
||||
// champs pour le nom et prénom
|
||||
foreach ($champsNom as $nom => $champ)
|
||||
{
|
||||
foreach ($champsNom as $nom => $champ) {
|
||||
$champ->position = 0;
|
||||
}
|
||||
$i = -count($noms_sel);
|
||||
foreach ($noms_sel as $nom)
|
||||
{
|
||||
foreach ($noms_sel as $nom) {
|
||||
$champsNom[$nom]->position = $i++;
|
||||
}
|
||||
$plugin->setConfig('champsNom', $champsNom);
|
||||
|
||||
\Garradin\Utils::redirect(PLUGIN_URL . 'config.php?ok');
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
} catch (UserException $e) {
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$conf_numerotation = $plugin->getConfig('numerotation');
|
||||
$chaine_numerotation = (isset($conf_numerotation->prefixe) && $conf_numerotation->prefixe != "") ? $conf_numerotation->prefixe : 'XXX';
|
||||
$chaine_numerotation .= $conf_numerotation->separateur . $conf_numerotation->defaut;
|
||||
$afficher_courriel = false;
|
||||
|
||||
// trier les champs de nom pour l'affichage
|
||||
uasort($champsNom, function ($a, $b)
|
||||
{
|
||||
uasort($champsNom, function ($a, $b) {
|
||||
return $a->position - $b->position;
|
||||
});
|
||||
|
||||
$tpl->assign('ok', qg('ok') !== null);
|
||||
$path = qg('path') ?: File::CONTEXT_CONFIG;
|
||||
//$tpl->assign('path', $path);
|
||||
$tpl->assign('default_signature', \Garradin\WWW_URL . "plugin/recusfiscaux/default_signature.png");
|
||||
$tpl->assign('plugin_config', $plugin->getConfig());
|
||||
//$tpl->assign('champsNom', $champsNom);
|
||||
$tpl->assign('plugin_css', ['style.css']);
|
||||
//$tpl->assign('chaine_numerotation', $chaine_numerotation);
|
||||
$tpl->assign(compact('path', 'champsNom', 'chaine_numerotation', 'afficher_courriel'));
|
||||
$tpl->assign('numerotation', $plugin->getConfig('numerotation'));
|
||||
$tpl->assign(compact('path', 'champsNom'));
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');
|
||||
|
|
|
|||
|
|
@ -52,6 +52,24 @@ elseif ($nbArticles > 1)
|
|||
// libellés pour les taux de réduction
|
||||
$libelles_taux = Utils::getLignesReduction($plugin->getConfig('reduction'));
|
||||
|
||||
$configNum = $plugin->getConfig('numerotation');
|
||||
error_log("config num = " . print_r($configNum, true));
|
||||
$prefixeNum = "";
|
||||
if (isset($configNum->prefixe) && $configNum->prefixe != "") {
|
||||
$prefixeNum = $configNum->prefixe;
|
||||
}
|
||||
if (isset($configNum->annee) && $configNum->annee) {
|
||||
if ($prefixeNum != "") { $prefixeNum .= "-"; }
|
||||
$prefixeNum .= $_SESSION['annee_recu'];
|
||||
}
|
||||
if (isset($configNum->sequentiel) && $configNum->sequentiel) {
|
||||
if (isset($configNum->valeur_init) && $configNum->valeur_init !="") {
|
||||
$numero_sequentiel = $configNum->valeur_init;
|
||||
} else {
|
||||
$numero_sequentiel = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// filtrer les versements sélectionnés
|
||||
$lesLignes = f('selected');
|
||||
$versementsSelectionnes = array();
|
||||
|
|
@ -82,14 +100,33 @@ foreach ($totalPersonnes as $idPersonne => $personne)
|
|||
$tpl->assign('nom_responsable', $plugin->getConfig('nom_responsable'));
|
||||
$tpl->assign('fonction_responsable', $plugin->getConfig('fonction_responsable'));
|
||||
$tpl->assign('ville_asso', $plugin->getConfig('ville_asso'));
|
||||
$tpl->assign('annee_recu', $_SESSION['annee_recu']);
|
||||
$tpl->assign('numero', $personne->id);
|
||||
$tpl->assign('nom', $personne->nomPrenom);
|
||||
$tpl->assign('adresse', $personne->adresse);
|
||||
$tpl->assign('code_postal', $personne->codePostal);
|
||||
$tpl->assign('ville', $personne->ville);
|
||||
$tpl->assign('date', date("j/m/Y"));
|
||||
|
||||
// numéro de reçu
|
||||
$chaineNum = $prefixeNum;
|
||||
if (isset($configNum->membre) && $configNum->membre) {
|
||||
if ($chaineNum != "") { $chaineNum .= "-"; }
|
||||
$chaineNum .= $personne->numero;
|
||||
}
|
||||
if (isset($configNum->sequentiel) && $configNum->sequentiel) {
|
||||
if ($chaineNum != "") { $chaineNum .= "-"; }
|
||||
$chaineNum .= $numero_sequentiel;
|
||||
++$numero_sequentiel;
|
||||
}
|
||||
$tpl->assign('numero', $chaineNum);
|
||||
// adresse de courriel
|
||||
if ($plugin->getConfig('imprimerCourriel')) {
|
||||
$courriel = $personne->courriel;
|
||||
}
|
||||
else {
|
||||
$courriel = "";
|
||||
}
|
||||
$tpl->assign('courriel', $courriel);
|
||||
|
||||
// les versements
|
||||
$tpl->registerSection('versements',
|
||||
function () use($personne, $libelles_taux, $fmt)
|
||||
|
|
@ -156,10 +193,10 @@ $fichierZip = Utils::makeArchive(
|
|||
);
|
||||
|
||||
//supprimer les fichiers pdf (utile ?)
|
||||
// foreach ($listeFichiersPDF as $f)
|
||||
// {
|
||||
// unlink($f);
|
||||
// }
|
||||
foreach ($listeFichiersPDF as $f)
|
||||
{
|
||||
unlink($f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cumuler les versements de chaque personne
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ if (! isset($_SESSION['annee_recu']) || $_SESSION['annee_recu'] == "")
|
|||
$nbTaux = 0;
|
||||
foreach ($plugin->getConfig('reduction') as $taux)
|
||||
{
|
||||
if ($taux->valeur == 1) { ++$nbTaux; }
|
||||
if ($taux->valeur) { ++$nbTaux; }
|
||||
}
|
||||
|
||||
// idem avec les champs nom/prénom
|
||||
|
|
|
|||
|
|
@ -258,3 +258,38 @@ function montrerMasquerDetails(idElem, classe, texte)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function aumoinsun(conteneur, message)
|
||||
{
|
||||
let listeCheck = conteneur.querySelectorAll('input[type=checkbox]');
|
||||
for (let elem of listeCheck)
|
||||
{
|
||||
if (elem.checked) { return true; }
|
||||
}
|
||||
alert("Erreur : il faut sélectionner au moins " + message);
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* vérifier les données saisies dans le formulaire de configuration
|
||||
*/
|
||||
function verifierConfig(
|
||||
formulaire,
|
||||
divArticles,
|
||||
divTauxReduc
|
||||
)
|
||||
{
|
||||
// articles
|
||||
if (! aumoinsun(divArticles, "un article")) { return false; }
|
||||
|
||||
// taux de réduction
|
||||
if (! aumoinsun(divTauxReduc, "un taux de réduction")) { return false; }
|
||||
|
||||
// Nom, fonction, signature
|
||||
|
||||
|
||||
// alert("Erreur : il faut sélectionner au moins un versement");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,10 +100,10 @@ div#config_nom_fonction
|
|||
{
|
||||
display: flex;
|
||||
}
|
||||
div#numerotation
|
||||
div#numero_recus
|
||||
{
|
||||
display:flex;
|
||||
align-items: last baseline;
|
||||
/* align-items: last baseline;*/
|
||||
}
|
||||
div.champnom
|
||||
{
|
||||
|
|
@ -128,3 +128,11 @@ ul.reduction span.radio-btn
|
|||
margin-left : 2em;
|
||||
border-spacing : 0.1em;
|
||||
}
|
||||
input#f_prefixe
|
||||
{
|
||||
max-width : 8em;
|
||||
}
|
||||
input#f_valeur_init
|
||||
{
|
||||
max-width: 4em;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue