Integration contrib @DDgallo sur CERFA

This commit is contained in:
Noizette 2022-01-07 01:24:32 +01:00
parent 637c493671
commit 61f40e100d
8 changed files with 218 additions and 42 deletions

View file

@ -35,6 +35,12 @@ if (qg('copy') !== null && $f = $facture->get((int)qg('copy'))) {
$doc['base_receveur'] = $f->receveur_membre ? 'membre' : 'client';
$doc['client'] = $f->receveur_id;
$doc['membre'] = $f->receveur_id;
if ( $f->type_facture == CERFA ) {
$doc['forme_don'] = $f->contenu['forme'];
$doc['nature_don'] = $f->contenu['nature'];
$doc['texte_don'] = $f->contenu['texte'];
}
}
$tpl->assign('require_number', $require_number);
@ -43,6 +49,15 @@ $tpl->assign('number_pattern', PATTERNS_LIST[$plugin->getConfig('pattern')]);
$tpl->assign('moyens_paiement', $moyens_paiement);
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
$tpl->assign('formes_don', array('1' => 'Acte authentique',
'2' => 'Acte sous seing privé',
'3' => 'Don manuel',
'4' => 'Autres'));
$tpl->assign('natures_don', array('1' => 'Numéraire',
'2' => 'Chèque',
'3' => 'Virement, CB; ...'));
$tpl->assign('textes_don', $facture->listTextesCerfa());
if (f('save'))
{
$form->check($csrf_key, [
@ -78,21 +93,29 @@ if (f('save'))
'moyen_paiement' => f('moyen_paiement'),
'toto' => 0
];
if (in_array(f('type'), [DEVIS, FACT, CERFA]))
$truc['type_facture'] = f('type');
if (in_array(f('type'), [DEVIS, FACT]))
{
$truc['type_facture'] = f('type');
}
foreach(f('designation') as $k=>$value)
{
$truc['contenu'][$k]['designation'] = $value;
$truc['contenu'][$k]['prix'] = Utils::moneyToInteger(f('prix')[$k]);
$truc['toto'] += Utils::moneyToInteger(f('prix')[$k]);
}
$truc['total'] = $truc['toto'];
unset($truc['toto']);
foreach(f('designation') as $k=>$value)
{
$truc['contenu'][$k]['designation'] = $value;
$truc['contenu'][$k]['prix'] = Utils::moneyToInteger(f('prix')[$k]);
$truc['toto'] += Utils::moneyToInteger(f('prix')[$k]);
}
$truc['total'] = $truc['toto'];
unset($truc['toto']);
}
elseif (f('type') == CERFA)
{
$truc['contenu'] = [
'forme' => f('forme_don'),
'nature' => f('nature_don'),
'texte' => f('texte_don')];
unset($truc['toto']);
$truc['total'] = Utils::moneyToInteger(f('total'));
}
if (f('base_receveur') == 'client')
{
$truc['receveur_membre'] = 0;

View file

@ -18,6 +18,15 @@ $moyens_paiement = $facture->listMoyensPaiement(true);
$tpl->assign('moyens_paiement', $moyens_paiement);
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
$tpl->assign('formes_don', array('1' => 'Acte authentique',
'2' => 'Acte sous seing privé',
'3' => 'Don manuel',
'4' => 'Autres'));
$tpl->assign('natures_don', array('1' => 'Numéraire',
'2' => 'Chèque',
'3' => 'Virement, CB; ...'));
$tpl->assign('textes_don', $facture->listTextesCerfa());
qv(['id' => 'required|numeric']);
$id = (int) qg('id');
@ -66,21 +75,30 @@ if(f('save'))
'moyen_paiement' => f('moyen_paiement'),
'toto' => 0
];
$truc['type_facture'] = f('type');
if (in_array(f('type'), [DEVIS, FACT, CERFA]))
if (in_array(f('type'), [DEVIS, FACT]))
{
$truc['type_facture'] = f('type');
foreach(f('designation') as $k=>$value)
{
$truc['contenu'][$k]['designation'] = $value;
$truc['contenu'][$k]['prix'] = Utils::moneyToInteger(f('prix')[$k]);
$truc['toto'] += Utils::moneyToInteger(f('prix')[$k]);
}
$truc['total'] = $truc['toto'];
unset($truc['toto']);
}
elseif ( f('type') == CERFA )
{
$truc['contenu'] = [
'forme' => f('forme_don'),
'nature' => f('nature_don'),
'texte' => f('texte_don')];
$truc['total'] = Utils::moneyToInteger(f('total'));
unset($truc['toto']);
}
foreach(f('designation') as $k=>$value)
{
$truc['contenu'][$k]['designation'] = $value;
$truc['contenu'][$k]['prix'] = Utils::moneyToInteger(f('prix')[$k]);
$truc['toto'] += Utils::moneyToInteger(f('prix')[$k]);
}
$truc['total'] = $truc['toto'];
unset($truc['toto']);
if (f('base_receveur') == 'client')
{
@ -206,7 +224,13 @@ $doc['membre'] = $f->receveur_id;
$doc['date_emission'] = strtotime(f('date_emission')) ?: $f->date_emission;
$doc['date_echeance'] = strtotime(f('date_echeance')) ?: $f->date_echeance; // Smarty m'a saoulé pour utiliser form_field|date_fr:---
/* modif DD -- CERFA -------------------------------------- */
if ( $f->type_facture == CERFA ) {
$doc['total'] = $f->total;
$doc['forme_don'] = $f->contenu['forme'];
$doc['nature_don'] = $f->contenu['nature'];
$doc['texte_don'] = $f->contenu['texte'];
}
$tpl->assign('doc', $doc);
$radio['type'] = f('type')??$doc['type'];
@ -223,7 +247,7 @@ $prix = [];
// C'est un peu l'équivalent de form_field, mais j'avais écrit ça avant
// et oulala, c'est un peu complexe, faudrait réfléchir keskivomieux
$from_user = false;
if ($f->type_facture != COTIS)
if (in_array($f->type_facture, [DEVIS, FACT]))
{
if (($d = f('designation')) && ($p = f('prix')))
{

View file

@ -309,6 +309,7 @@ elseif ($f->type_facture == CERFA)
$doc = 'Reçu de don n°'. $f->numero;
$url = WWW_URL;
$libelles = $facture->listTextesCerfa(false);
$t['numero'] = $f->numero;
$t['nom_asso'] = $config->get('nom_asso');
@ -332,6 +333,10 @@ elseif ($f->type_facture == CERFA)
$t['m'] = utf8_decode($f->date_emission->format('m'));
$t['Y'] = utf8_decode($f->date_emission->format('Y'));
$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';
@ -343,15 +348,41 @@ elseif ($f->type_facture == CERFA)
$t['art885'] = 'X';
}
// forme du don
switch ($t['forme']){
case '1':
$t['frm'] = 'left: 15mm;';
break;
case '2':
$t['frm'] = 'left: 57.3mm;';
break;
case '3':
$t['frm'] = 'left: 115.2mm;';
break;
case '4':
$t['frm'] = 'left: 175.2mm;';
}
// nature du don
switch ($t['nature']){
case '1':
$t['nat'] = 'left: 15mm;';
break;
case '2':
$t['nat'] = 'left: 57.3mm;';
break;
case '3':
$t['nat'] = 'left: 115.2mm;';
}
// moyen de paiement
switch ($f->moyen_paiement){
case 'ES':
$t['pos'] = ' top: 158.2mm; left: 15mm;';
$t['pos'] = 'left: 15mm;';
break;
case 'CH':
$t['pos'] = ' top: 158.2mm; left: 57.3mm;';
$t['pos'] = 'left: 57.3mm;';
break;
default:
$t['pos'] = ' top: 158.2mm; left: 115.2mm;';
$t['pos'] = 'left: 115.2mm;';
}
$t['d2'] = utf8_decode($f->date_echeance->format('d'));
@ -436,11 +467,10 @@ elseif ($f->type_facture == CERFA)
<div style="top: 96mm; left: 53mm;">${t['art200']}</div>
<div style="top: 96mm; left: 103mm;">${t['art238']}</div>
<div style="top: 96mm; left: 153.0mm;">${t['art885']}</div>
<div style="top: 113mm; left: 115mm;">X</div>
<div style="top: 136mm; left: 15mm;">X</div>
<div style="${t['pos']}">X</div>
<div style="top: 113mm; ${t['frm']}">X</div>
<div style="top: 136mm; ${t['nat']}">X</div>
<div style="top: 142mm; left: 25mm;">${t['texte']}</div>
<div style="top: 158.2mm; ${t['pos']}">X</div>
<div style="top: 239mm; left: 139mm;">${t['d2']}</div>
<div style="top: 239mm; left: 148mm;">${t['m2']}</div>