Ajout possibilité choisir champs identité et adresse membre

This commit is contained in:
Jean-Christophe Engel 2024-08-30 21:32:13 +02:00
parent 2ecbac159a
commit 57e6ad09f9
7 changed files with 250 additions and 182 deletions

View file

@ -1,11 +1,15 @@
<?php
namespace Paheko;
use Paheko\Users\DynamicFields;
require_once __DIR__ . '/_inc.php';
$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_ADMIN);
$champsPaheko = DynamicFields::getInstance()->listAssocNames();
$champsPaheko = array('' => '- Choisir un champ -') + $champsPaheko;
$form->runIf('save', function () use ($plugin) {
$plugin->setConfigProperty('rna_asso', trim(f('rna_asso')));
$plugin->setConfigProperty('siret_asso', trim(f('siret_asso')));
@ -26,9 +30,14 @@ $form->runIf('save', function () use ($plugin) {
$plugin->setConfigProperty('logo', (bool)f('logo'));
$plugin->setConfigProperty('footer', f('footer'));
$plugin->setConfigProperty('nom_client', f('nom_client'));
$plugin->setConfigProperty('prenom_client', f('prenom_client'));
$plugin->setConfigProperty('adresse_client', f('adresse_client'));
$plugin->setConfigProperty('code_postal_client', f('code_postal_client'));
$plugin->setConfigProperty('ville_client', f('ville_client'));
$plugin->setConfigProperty('validate_cp', (bool)f('validate_cp'));
$plugin->setConfigProperty('unique_client_name', (bool)f('unique_client_name'));
$plugin->setConfigProperty('pattern', f('pattern'));
$plugin->save();
@ -38,5 +47,6 @@ $form->runIf('save', function () use ($plugin) {
$tpl->assign('ok', qg('ok') !== null);
$tpl->assign('conf', $plugin->getConfig());
$tpl->assign('patterns', \Paheko\Plugin\Facturation\PATTERNS_LIST);
$tpl->assign('champsPaheko', $champsPaheko);
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');

View file

@ -24,11 +24,26 @@ try
if ($f->receveur_membre)
{
$c = $users->get($f->receveur_id);
// l'identité du membre peut être redéfinie dans la configuration des membres
$name_fields = \Paheko\Users\DynamicFields::getNameFields();
array_walk($name_fields, function(&$elem) use ($c) {
$elem = $c->$elem ?? '** ABSENT **';
});
$c->nom = implode(" ", $name_fields);
// adresse, code postal et ville peuvent être redéfini(e)s dans la configuration du plugin
$adresse_client = $plugin->getConfig('adresse_client');
if ($adresse_client != null && $c->$adresse_client != null) { $c->adresse = $c->$adresse_client; }
$code_postal_client = $plugin->getConfig('code_postal_client');
if ($code_postal_client != null && $c->$code_postal_client != null) { $c->code_postal = $c->$code_postal_client; }
$ville_client = $plugin->getConfig('ville_client');
if ($ville_client != null && $c->$ville_client != null) { $c->ville = $c->$ville_client; }
foreach(['ville','code_postal','adresse'] as $v)
{
if($c->$v == '')
{
$c->$v = '[A RENSEIGNER DANS LA FICHE MEMBRE]';
$c->$v = '[À RENSEIGNER DANS LA FICHE MEMBRE]';
}
}
}
@ -58,20 +73,20 @@ if ($f->type_facture != CERFA)
switch ($f->type_facture)
{
case FACT:
$doc = 'Facture n° '. $f->numero;
$txtemis = $doc . " - Émise le " . $emission;
$txtdest = "Adressée à :";
break;
$doc = 'Facture n° '. $f->numero;
$txtemis = $doc . " - Émise le " . $emission;
$txtdest = "Adressée à :";
break;
case DEVIS:
$doc = 'Devis n° '. $f->numero;
$txtemis = $doc . " - Émis le " . $emission;
$txtdest = "Adressé à :";
break;
$doc = 'Devis n° '. $f->numero;
$txtemis = $doc . " - Émis le " . $emission;
$txtdest = "Adressé à :";
break;
case COTIS:
$doc = 'Reçu de cotisation n° '. $f->numero;
$txtemis = $doc . " - Émis le " . $emission;
$txtdest = "Adressé à :";
break;
$doc = 'Reçu de cotisation n° '. $f->numero;
$txtemis = $doc . " - Émis le " . $emission;
$txtdest = "Adressé à :";
break;
}
// utiliser l'adresse configurée dans le plugin sinon celle de l'asso sinon rien !
@ -149,7 +164,7 @@ EOF;
$i = 1;
foreach($f->contenu as $k=>$v)
{
{
echo '<tr><td>';
echo str_replace("\n", '<br>', $v['designation']);
echo '</td><td>';
@ -188,7 +203,7 @@ EOF;
{
$lieu = $plugin->getConfig('ville_asso');
$intitule = $f->contenu['intitule'];
$souscription = date('d/m/Y', strtotime($f->contenu['souscription']));
if($f->contenu['expiration'] == '1970-01-01')
@ -224,7 +239,7 @@ EOF;
}
//-- Layout du document
ob_start();
echo <<<EOF
<!DOCTYPE html>
@ -237,7 +252,7 @@ EOF;
size: A4 portrait;
margin: 0;
}
body {
padding: 4mm;
font-family: Helvetica, Arial, sans;
@ -375,7 +390,7 @@ elseif ($f->type_facture == CERFA)
$t['forme'] = $f->contenu['forme'];
$t['nature'] = $f->contenu['nature'];
$t['texte'] = $libelles[$f->contenu['texte']];
$t['art200'] = $t['art238'] = $t['art885'] = '';
if($plugin->getConfig('droit_art200')){
$t['art200'] = 'X';
@ -441,7 +456,7 @@ elseif ($f->type_facture == CERFA)
margin: 0;
padding: 0;
}
body {
font-family: Helvetica, Arial, sans;
font-size: 10pt;
@ -463,11 +478,11 @@ elseif ($f->type_facture == CERFA)
background-size: cover;
background-position: -5mm -4.8mm;
}
#p1 {
background-image: url('{$url}p/facturation/cerfa-1.png');
}
#p2 {
background-image: url('{$url}p/facturation/cerfa-2.png');
position: relative;