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;