- {if $facture.type_facture == 1}Facture{else}Devis{/if} |
+ type_facture) {
+ case 0:
+ echo 'Devis';
+ break;
+ case 1:
+ echo 'Facture';
+ break;
+ case 2:
+ echo 'Reçu fiscal';
+ break;
+ case 3:
+ echo 'Reçu cotisation';
+ break;
+ }
+ ?> |
{$facture.numero} |
{if $facture.receveur_membre}
{$facture.receveur.nom} |
@@ -32,8 +46,8 @@
{$facture.receveur.ville} |
{$facture.date_emission|date_fr:'d/m/Y'} |
{$facture.date_echeance|date_fr:'d/m/Y'} |
- {$facture.reglee} |
- {$facture.archivee} |
+ = $facture->reglee?'Réglée':'Non' ?> |
+ = $facture->archivee?'Archivée':'Non' ?> |
{$facture.moyen_paiement} |
{foreach from=$facture.contenu item=contenu}
diff --git a/www/admin/facture_pdf.php b/www/admin/facture_pdf.php
index eaa4ee6..ff5d8d3 100644
--- a/www/admin/facture_pdf.php
+++ b/www/admin/facture_pdf.php
@@ -12,9 +12,7 @@ $membres = new Membres;
qv(['id' => 'required|numeric']);
$id = (int) qg('id');
-$f = $facture->get($id);
-
-if (!$f)
+if (!$f = $facture->get($id))
{
throw new UserException("Ce document n'existe pas.");
}
@@ -42,46 +40,51 @@ try
}
catch(UserException $e)
{
- $form->addError("Pas de document correspondant à cet id trouvée.");
+ $form->addError($e);
}
+
// Création du PDF
$pdf = new \Mpdf\Mpdf([
'default_font_size' => 10,
'default_font' => 'dejavusans',
- // 'tempDir' => PLUGINS_ROOT . '/mpdf-tmp/'
]);
$pdf->SetAuthor($config->get('nom_asso'));
-ob_start();
-$doc = ($f->type_facture?'Facture':'Devis').' n°'.$f->numero;
-$emission = date('d/m/Y' ,$f->date_emission);
-$pdf->SetTitle($doc.' - '.$emission);
+// Génération factures et devis
-$asso =
- // 'Émis par :
'.
- ''.$config->get('nom_asso')." ".
- str_replace("\n", ' ', $config->get('adresse_asso'))." ".
- (($t = $plugin->getConfig('rna_asso'))?"RNA : $t ":'').
- (($t = $plugin->getConfig('siret_asso'))?"SIRET : $t ":'').
- (($t = $config->get('email_asso'))?"Email : $t ":'').
- (($t = $config->get('site_asso'))?"Site web : $t ":'');
+if ($f->type_facture < 2)
+{
+ ob_start();
-$receveur =
- 'Adressé à :
'.
- ''.$c->nom.' '.
- $c->adresse." ".
- $c->code_postal.' '.$c->ville." ".
- (($t = $c->email)?"Email : $t ":'').
- (($t = $c->telephone)?"Tel : $t ":'');
+ $doc = ($f->type_facture?'Facture':'Devis').' n°'.$f->numero;
+ $emission = date('d/m/Y' ,$f->date_emission);
+ $pdf->SetTitle($doc.' - '.$emission);
-$total = number_format($f->total, 2, ',', ' ');
-$echeance = date('d/m/Y' ,$f->date_echeance);
-$echeance = ($f->type_facture?'Échéance de paiement':'Échéance du devis')." : ".$echeance;
-$reglee = !$f->reglee?'Cette facture est en attente de règlement.':'Cette facture a été reglée.';
-$footer = str_replace("\n", ' ', $plugin->getConfig('footer'));
+ $asso =
+ // 'Émis par :
'.
+ ''.$config->get('nom_asso')." ".
+ str_replace("\n", ' ', $config->get('adresse_asso'))." ".
+ (($t = $plugin->getConfig('rna_asso'))?"RNA : $t ":'').
+ (($t = $plugin->getConfig('siret_asso'))?"SIRET : $t ":'').
+ (($t = $config->get('email_asso'))?"Email : $t ":'').
+ (($t = $config->get('site_asso'))?"Site web : $t ":'');
+
+ $receveur =
+ 'Adressé à :
'.
+ ''.$c->nom.' '.
+ $c->adresse." ".
+ $c->code_postal.' '.$c->ville." ".
+ (($t = $c->email)?"Email : $t ":'').
+ (($t = $c->telephone)?"Tel : $t ":'');
+
+ $total = number_format($f->total, 2, ',', ' ');
+ $echeance = date('d/m/Y' ,$f->date_echeance);
+ $echeance = ($f->type_facture?'Échéance de paiement':'Échéance du devis')." : ".$echeance;
+ $reglee = !$f->reglee?'Cette facture est en attente de règlement.':'Cette facture a été reglée.';
+ $footer = str_replace("\n", ' ', $plugin->getConfig('footer'));
echo <<
EOF;
-$i = 1;
-foreach($f->contenu as $k=>$v)
-{
- echo '';
- echo str_replace("\n", ' ', $v['designation']);
- echo ' | ';
- echo number_format($v['prix'], 2, ',', ' ').'€';
- echo ' | ';
- $i++;
-}
+ $i = 1;
+ foreach($f->contenu as $k=>$v)
+ {
+ echo '';
+ echo str_replace("\n", ' ', $v['designation']);
+ echo ' | ';
+ echo number_format($v['prix'], 2, ',', ' ').'€';
+ echo ' | ';
+ $i++;
+ }
echo <<
@@ -217,8 +220,104 @@ echo <<WriteHTML($html);
+ $html = ob_get_clean();
+ $pdf->WriteHTML($html);
+
+} // End if facture+devis
+elseif ($f->type_facture == 2)
+{
+ // nom prénom ? pas de champs prénoms
+ // date d'émission = date du don
+ // date d'échéance = date d'édition du reçu
+
+ $pdf->AddPage();
+ $pdf->setSourceFile(PLUGIN_ROOT . '/data/11580-03.pdf');
+ $pdf->useTemplate(
+ $pdf->importPage(1)
+ );
+
+ $pdf->SetTextColor(0);
+ $pdf->WriteText(180, 18, $f->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')));
+ $pdf->WriteText(39, 59, utf8_decode($plugin->getConfig('cp_asso')));
+ $pdf->WriteText(74, 59, utf8_decode($plugin->getConfig('ville_asso')));
+ $pdf->WriteText(20, 70, utf8_decode($plugin->getConfig('objet_0')));
+ $pdf->WriteText(20, 74, utf8_decode($plugin->getConfig('objet_1')));
+ $pdf->WriteText(20, 78, utf8_decode($plugin->getConfig('objet_2')));
+ $pdf->WriteText(19.9, 136, "X");
+
+ $pdf->AddPage();
+ $pdf->useTemplate(
+ $pdf->importPage(2)
+ );
+
+ $pdf->WriteText(80, 26, $c->nom); // Nom + prénoms centrés ?
+ // $pdf->WriteText(22, 26, $c->nom); // Nom
+ // $pdf->WriteText(110, 26, $c->nom); // Prénoms
+ $pdf->WriteText(22, 39, $c->adresse);
+ $pdf->WriteText(41, 45, $c->code_postal);
+ $pdf->WriteText(81, 45, $c->ville);
+ $pdf->WriteText(90, 70, utf8_decode("***".$f->total."***"));
+ // numfmt a l'air de patauger avec des valeurs < 1
+ $pdf->WriteText(62, 80, utf8_decode(numfmt_create('fr_FR', \NumberFormatter::SPELLOUT)->format($f->total)) . ' euros');
+
+ $pdf->WriteText(73, 89.5, utf8_decode(strftime('%d', $f->date_emission)));
+ $pdf->WriteText(84, 89.5, utf8_decode(strftime('%m', $f->date_emission)));
+ $pdf->WriteText(100, 89.5, utf8_decode(strftime('%Y', $f->date_emission)));
+
+ if($plugin->getConfig('droit_art200')){
+ $pdf->WriteText(57.5, 103.5, "X");
+ }
+ if($plugin->getConfig('droit_art238bis')){
+ $pdf->WriteText(107.6, 103.5, "X");
+ }
+ if($plugin->getConfig('droit_art885-0VbisA')){
+ $pdf->WriteText(157.7, 103.5, "X");
+ }
+
+ // Forme du don
+ $pdf->WriteText(119.9, 121.2, "X");
+ // Nature du don
+ $pdf->WriteText(20, 143.6, "X");
+
+ switch ($f->moyen_paiement){
+ case 'ES':
+ $pdf->WriteText(19.9, 165.9, "X");
+ break;
+
+ case 'CH':
+ $pdf->WriteText(62.6, 165.9, "X");
+ break;
+
+ default:
+ $pdf->WriteText(119.9, 165.9, "X");
+ break;
+ }
+
+ // Date d'édition du document
+ $pdf->WriteText(144.4, 246.2, utf8_decode(strftime('%d', $f->date_echeance)));
+ $pdf->WriteText(152.2, 246.2, utf8_decode(strftime('%m', $f->date_echeance)));
+ $pdf->WriteText(160, 246.2, utf8_decode(strftime('%Y', $f->date_echeance)));
+
+ // Signature
+ $img = new Fichiers($plugin->getConfig('signaturetxt'));
+ $cache_id = 'fichiers.' . $img->id_contenu;
+ if (!Static_Cache::exists($cache_id))
+ {
+ $blob = DB::getInstance()->openBlob('fichiers_contenu', 'contenu', (int)$img->id_contenu);
+ Static_Cache::storeFromPointer($cache_id, $blob);
+ fclose($blob);
+ }
+ $uri = Static_Cache::getPath($cache_id);
+ $pdf->Image($uri, 150, 245, 32, 0, 'PNG' ); // Emplacement de la signature avec restriction de largeur pour tenir dans sur la case.
+
+} // End if cerfa
+elseif ($f->type_facture == 3)
+{
+
+} // End if reçu cotis
if(qg('d') !== null)
{
@@ -228,6 +327,7 @@ else
{
$t = \Mpdf\Output\Destination::INLINE;
}
+
$pdf->Output(
($f->type_facture?'Facture':'Devis').' '.$f->numero
. ' du '.date('d-m-Y' ,$f->date_emission)
diff --git a/www/admin/generation.php b/www/admin/generation.php
deleted file mode 100644
index a09e9af..0000000
--- a/www/admin/generation.php
+++ /dev/null
@@ -1,150 +0,0 @@
-requireAccess('compta', Membres::DROIT_ADMIN);
-
-require_once __DIR__ . '/_inc.php';
-require_once PLUGIN_ROOT . '/lib/MPDF/vendor/autoload.php';
-
-qv(['id' => 'required|numeric']);
-$id = (int) qg('id');
-
-if (!$recu = $facture->get($id))
-{
- throw new UserException("Ce document n'existe pas.");
-}
-
-$membres = new Membres;
-
-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,
- 'default_font' => 'Helvetica',
-]);
-
-$pdf->AddPage();
-$pdf->setSourceFile(PLUGIN_ROOT . '/data/11580-03.pdf');
-$pdf->useTemplate(
- $pdf->importPage(1)
-);
-
-$pdf->SetTextColor(0);
-$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')));
-$pdf->WriteText(39, 59, utf8_decode($plugin->getConfig('cp_asso')));
-$pdf->WriteText(74, 59, utf8_decode($plugin->getConfig('ville_asso')));
-$pdf->WriteText(20, 70, utf8_decode($plugin->getConfig('objet_0')));
-$pdf->WriteText(20, 74, utf8_decode($plugin->getConfig('objet_1')));
-$pdf->WriteText(20, 78, utf8_decode($plugin->getConfig('objet_2')));
-$pdf->WriteText(19.9, 136, "X");
-
-$pdf->AddPage();
-$pdf->useTemplate(
- $pdf->importPage(2)
-);
-
-$pdf->WriteText(22, 26, $recu->nom);
-$pdf->WriteText(110, 26, $recu->prenom);
-$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);
-
-$pdf->WriteText(73, 89.5, utf8_decode($date['day']));
-$pdf->WriteText(84, 89.5, utf8_decode($date['month']));
-$pdf->WriteText(100, 89.5, utf8_decode($date['year']));
-
-if($plugin->getConfig('droit_art200')){
- $pdf->WriteText(57.5, 103.5, "X");
-}
-if($plugin->getConfig('droit_art238bis')){
- $pdf->WriteText(107.6, 103.5, "X");
-}
-if($plugin->getConfig('droit_art885-0VbisA')){
- $pdf->WriteText(157.7, 103.5, "X");
-}
-
-// Forme du don
-$pdf->WriteText(119.9, 121.2, "X");
-// Nature du don
-$pdf->WriteText(20, 143.6, "X");
-
-switch ($recu->mode_paiement){
- case 0:
- $pdf->WriteText(19.9, 165.9, "X");
- break;
-
- case 1:
- $pdf->WriteText(62, 165, "X");
- break;
-
- case 2:
- $pdf->WriteText(119.7, 165, "X");
- break;
-}
-
-
-// Date d'édition du document
-$pdf->WriteText(144.4, 246.2, date('d'));
-$pdf->WriteText(152.2, 246.2, date('m'));
-$pdf->WriteText(160, 246.2, date('Y'));
-
-// Signature
-$img = new Fichiers($plugin->getConfig('signaturetxt'));
-$cache_id = 'fichiers.' . $img->id_contenu;
-if (!Static_Cache::exists($cache_id))
-{
- $blob = DB::getInstance()->openBlob('fichiers_contenu', 'contenu', (int)$img->id_contenu);
- Static_Cache::storeFromPointer($cache_id, $blob);
- fclose($blob);
-}
-$uri = Static_Cache::getPath($cache_id);
-$pdf->Image($uri, 150, 245, 32, 0, 'PNG' ); // Emplacement de la signature avec restriction de largeur pour tenir dans sur la case.
-$pdf->Output($recu->gen_ordre.".pdf", "I");
|