C'est crade mais : on peut modifier un doc en reçu et il s'affiche
This commit is contained in:
parent
0ab5fa5ad0
commit
2014dff1a1
8 changed files with 146 additions and 110 deletions
|
|
@ -4,6 +4,7 @@ namespace Garradin;
|
|||
|
||||
use Garradin\Plugin\Facturation\Facture;
|
||||
use Garradin\Plugin\Facturation\Client;
|
||||
use Garradin\Plugin\Facturation\GenDon;
|
||||
|
||||
$client = new Client;
|
||||
$facture = new Facture;
|
||||
|
|
|
|||
|
|
@ -20,30 +20,32 @@ if (!$f)
|
|||
throw new UserException("Ce document n'existe pas.");
|
||||
}
|
||||
|
||||
$cats = new Compta\Categories;
|
||||
$tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
|
||||
$tpl->assign('moyen_paiement', $cats->getMoyenPaiement($f->moyen_paiement));
|
||||
$tpl->assign('type', $f->type_facture);
|
||||
|
||||
// $cats = new Compta\Categories;
|
||||
// $tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
|
||||
// $tpl->assign('moyen_paiement', $cats->getMoyenPaiement($f->moyen_paiement));
|
||||
|
||||
try
|
||||
{
|
||||
if ($f->receveur_membre)
|
||||
{
|
||||
$c = $membres->get($f->receveur_id);
|
||||
foreach(['ville','code_postal','adresse'] as $v)
|
||||
{
|
||||
if($c->$v == '')
|
||||
{
|
||||
$c->$v = '[A RENSEIGNER DANS LA FICHE MEMBRE]';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$c = $client->get($f->receveur_id);
|
||||
}
|
||||
// if ($f->receveur_membre)
|
||||
// {
|
||||
// $c = $membres->get($f->receveur_id);
|
||||
// foreach(['ville','code_postal','adresse'] as $v)
|
||||
// {
|
||||
// if($c->$v == '')
|
||||
// {
|
||||
// $c->$v = '[A RENSEIGNER DANS LA FICHE MEMBRE]';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $c = $client->get($f->receveur_id);
|
||||
// }
|
||||
|
||||
$tpl->assign('facture', $f);
|
||||
$tpl->assign('client', $c);
|
||||
// $tpl->assign('client', $c);
|
||||
}
|
||||
catch(UserException $e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ $tpl->assign('moyen_paiement', f('moyen_paiement') ?: $f->moyen_paiement);
|
|||
if(f('save'))
|
||||
{
|
||||
$form->check('modifier_facture', [
|
||||
'type' => 'required|in:facture,devis',
|
||||
'type' => 'required|in:facture,devis,cerfa,cotis',
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'date_echeance' => 'required|date',
|
||||
|
|
@ -60,13 +60,17 @@ if(f('save'))
|
|||
'toto' => 0
|
||||
];
|
||||
|
||||
if (f('type') == 'facture')
|
||||
if (f('type') == 'devis')
|
||||
{
|
||||
$truc['type_facture'] = 0;
|
||||
}
|
||||
elseif (f('type') == 'facture')
|
||||
{
|
||||
$truc['type_facture'] = 1;
|
||||
}
|
||||
elseif (f('type') == 'devis')
|
||||
elseif (f('type') == 'cerfa')
|
||||
{
|
||||
$truc['type_facture'] = 0;
|
||||
$truc['type_facture'] = 2;
|
||||
}
|
||||
|
||||
foreach(f('designation') as $k=>$value)
|
||||
|
|
@ -101,8 +105,7 @@ if(f('save'))
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$tpl->assign('type', f('type') ?: ($f->type_facture ?'facture':'devis'));
|
||||
$tpl->assign('type', $facture->type[$f->type_facture]);
|
||||
$tpl->assign('numero_facture', f('numero_facture') ?: $f->numero);
|
||||
$tpl->assign('date_emission', strtotime(f('date_emission')) ?: $f->date_emission);
|
||||
$tpl->assign('date_echeance', strtotime(f('date_echeance')) ?: $f->date_echeance);
|
||||
|
|
@ -111,6 +114,7 @@ $tpl->assign('base_receveur', f('base_receveur') ?: ($f->receveur_membre?'membre
|
|||
$tpl->assign('client_id', f('client') ?: $f->receveur_id);
|
||||
$tpl->assign('membre_id', f('membre') ?: $f->receveur_id);
|
||||
|
||||
|
||||
if (($d = f('designation')) && ($p = f('prix')))
|
||||
{
|
||||
foreach($d as $k=>$v)
|
||||
|
|
@ -123,7 +127,7 @@ if (($d = f('designation')) && ($p = f('prix')))
|
|||
$prix[] = $p[$k];
|
||||
}
|
||||
}
|
||||
else
|
||||
else/*if ($f->contenu)*/
|
||||
{
|
||||
foreach($f->contenu as $k=>$v)
|
||||
{
|
||||
|
|
@ -136,7 +140,9 @@ else
|
|||
}
|
||||
}
|
||||
$tpl->assign('designations', $designations);
|
||||
// $tpl->assign('designations', [0=>'',1=>'']);
|
||||
$tpl->assign('prix', $prix);
|
||||
// $tpl->assign('prix', ['','']);
|
||||
|
||||
$tpl->assign('membres', (array)DB::getInstance()->get('SELECT id, nom FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
|
||||
$tpl->assign('clients', $client->listAll());
|
||||
|
|
|
|||
|
|
@ -1,18 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\Plugin\Facturation\GenDon;
|
||||
|
||||
$session->requireAccess('compta', Membres::DROIT_ADMIN);
|
||||
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
require_once PLUGIN_ROOT . '/lib/MPDF/vendor/autoload.php';
|
||||
|
||||
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||
throw new UserException("Le numéro du reçu fiscal est manquant.");
|
||||
qv(['id' => 'required|numeric']);
|
||||
$id = (int) qg('id');
|
||||
|
||||
if (!$recu = $facture->get($id))
|
||||
{
|
||||
throw new UserException("Ce document n'existe pas.");
|
||||
}
|
||||
|
||||
$id = (int) $_GET['id'];
|
||||
$membres = new Membres;
|
||||
|
||||
$gendon = new Plugin\RecuDon\GenDon;
|
||||
$recu = $gendon->get($id);
|
||||
try
|
||||
{
|
||||
if ($recu->receveur_membre)
|
||||
{
|
||||
$c = $membres->get($recu->receveur_id);
|
||||
foreach(['ville','code_postal','adresse'] as $v)
|
||||
{
|
||||
if($c->$v == '')
|
||||
{
|
||||
$c->$v = '[A RENSEIGNER DANS LA FICHE MEMBRE]';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$c = $client->get($recu->receveur_id);
|
||||
}
|
||||
}
|
||||
catch(UserException $e)
|
||||
{
|
||||
$form->addError("Pas de document correspondant à cet id trouvée.");
|
||||
}
|
||||
|
||||
// Oui bon faut juste harmoniser les choses, quoi
|
||||
$recu->nom = $c->nom;
|
||||
$recu->prenom = $c->nom;
|
||||
$recu->adresse = $c->adresse;
|
||||
$recu->codepostal = $c->code_postal;
|
||||
$recu->ville = $c->ville;
|
||||
$recu->montant = $recu->total;
|
||||
$recu->date = $recu->date_emission;
|
||||
$recu->mode_paiement = $recu->moyen_paiement;
|
||||
$recu->gen_ordre = $recu->numero;
|
||||
|
||||
// var_dump($recu->adresse);
|
||||
// die();
|
||||
|
||||
|
||||
// Génération du PDF à partir du cerfa
|
||||
|
||||
$pdf = new \Mpdf\Mpdf([
|
||||
'default_font_size' => 10,
|
||||
|
|
@ -26,7 +71,7 @@ $pdf->useTemplate(
|
|||
);
|
||||
|
||||
$pdf->SetTextColor(0);
|
||||
$pdf->WriteText(180, 18, $recu->gen_ordre);
|
||||
$pdf->WriteText(180, 18, $recu->numero);
|
||||
$pdf->WriteText(20, 43, $config->get('nom_asso'));
|
||||
$pdf->WriteText(25, 54, utf8_decode($plugin->getConfig('numero_rue_asso')));
|
||||
$pdf->WriteText(43, 54, utf8_decode($plugin->getConfig('rue_asso')));
|
||||
|
|
@ -48,6 +93,7 @@ $pdf->WriteText(22, 39, utf8_decode($recu->adresse));
|
|||
$pdf->WriteText(41, 45, $recu->codepostal);
|
||||
$pdf->WriteText(81, 45, utf8_decode($recu->ville));
|
||||
$pdf->WriteText(90, 70, utf8_decode("***".$recu->montant."***"));
|
||||
// numfmt a l'air de patauger avec des valeurs < 1
|
||||
$pdf->WriteText(62, 80, utf8_decode(numfmt_create('fr_FR', \NumberFormatter::SPELLOUT)->format($recu->montant)) . ' euros');
|
||||
$date = date_parse($recu->date);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue