Remplissage du PDF
This commit is contained in:
parent
b18cd91aa4
commit
0ab5fa5ad0
|
@ -3,6 +3,8 @@ namespace Garradin;
|
||||||
|
|
||||||
$session->requireAccess('compta', Membres::DROIT_ADMIN);
|
$session->requireAccess('compta', Membres::DROIT_ADMIN);
|
||||||
|
|
||||||
|
require_once PLUGIN_ROOT . '/lib/MPDF/vendor/autoload.php';
|
||||||
|
|
||||||
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
|
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||||
throw new UserException("Le numéro du reçu fiscal est manquant.");
|
throw new UserException("Le numéro du reçu fiscal est manquant.");
|
||||||
}
|
}
|
||||||
|
@ -10,125 +12,93 @@ if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||||
$id = (int) $_GET['id'];
|
$id = (int) $_GET['id'];
|
||||||
|
|
||||||
$gendon = new Plugin\RecuDon\GenDon;
|
$gendon = new Plugin\RecuDon\GenDon;
|
||||||
|
|
||||||
$recu = $gendon->get($id);
|
$recu = $gendon->get($id);
|
||||||
|
|
||||||
require_once PLUGIN_ROOT . '/lib/MPDF/vendor/autoload.php';
|
$pdf = new \Mpdf\Mpdf([
|
||||||
|
'default_font_size' => 10,
|
||||||
|
'default_font' => 'Helvetica',
|
||||||
|
]);
|
||||||
|
|
||||||
// require_once(PLUGIN_ROOT . '/lib/fpdf/fpdf.php');
|
$pdf->AddPage();
|
||||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/pdf_context.php');
|
$pdf->setSourceFile(PLUGIN_ROOT . '/data/11580-03.pdf');
|
||||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/pdf_parser.php');
|
$pdf->useTemplate(
|
||||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/fpdi_pdf_parser.php');
|
$pdf->importPage(1)
|
||||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/fpdi_bridge.php');
|
);
|
||||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/fpdf_tpl.php');
|
|
||||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/fpdi.php');
|
|
||||||
|
|
||||||
$pdf = new \Mpdf\Mpdf([
|
$pdf->SetTextColor(0);
|
||||||
'default_font_size' => 10,
|
$pdf->WriteText(180, 18, $recu->gen_ordre);
|
||||||
'default_font' => 'Helvetica',
|
$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->AddPage();
|
$pdf->WriteText(39, 59, utf8_decode($plugin->getConfig('cp_asso')));
|
||||||
$pdf->setSourceFile(PLUGIN_ROOT . '/data/11580-03.pdf');
|
$pdf->WriteText(74, 59, utf8_decode($plugin->getConfig('ville_asso')));
|
||||||
$pdf->useTemplate(
|
$pdf->WriteText(20, 70, utf8_decode($plugin->getConfig('objet_0')));
|
||||||
$pdf->importPage(1)
|
$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->SetTextColor(0);
|
$pdf->AddPage();
|
||||||
$pdf->WriteText(180, 18, $recu->gen_ordre);
|
$pdf->useTemplate(
|
||||||
$pdf->WriteText(20, 43, $config->get('nom_asso'));
|
$pdf->importPage(2)
|
||||||
$pdf->WriteText(24, 53, utf8_decode($plugin->getConfig('numero_rue')));
|
);
|
||||||
$pdf->SetXY(42,53);
|
|
||||||
$pdf->Write(0, utf8_decode($plugin->getConfig('rue')));
|
|
||||||
$pdf->SetXY(38,59);
|
|
||||||
$pdf->Write(0, utf8_decode($plugin->getConfig('codepostal')));
|
|
||||||
$pdf->SetXY(72,59);
|
|
||||||
$pdf->Write(0, utf8_decode($plugin->getConfig('ville')));
|
|
||||||
$pdf->SetXY(20,69);
|
|
||||||
$pdf->Write(0, utf8_decode($plugin->getConfig('objet0')));
|
|
||||||
$pdf->SetXY(20,73);
|
|
||||||
$pdf->Write(0, utf8_decode($plugin->getConfig('objet1')));
|
|
||||||
$pdf->SetXY(20,77);
|
|
||||||
$pdf->Write(0, utf8_decode($plugin->getConfig('objet2')));
|
|
||||||
$pdf->SetXY(19,135);
|
|
||||||
$pdf->Write(0, "X");
|
|
||||||
|
|
||||||
$pdf->AddPage();
|
$pdf->WriteText(22, 26, $recu->nom);
|
||||||
$pdf->useTemplate(
|
$pdf->WriteText(110, 26, $recu->prenom);
|
||||||
$pdf->importPage(2)
|
$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."***"));
|
||||||
|
$pdf->WriteText(62, 80, utf8_decode(numfmt_create('fr_FR', \NumberFormatter::SPELLOUT)->format($recu->montant)) . ' euros');
|
||||||
|
$date = date_parse($recu->date);
|
||||||
|
|
||||||
$pdf->SetXY(18,25);
|
$pdf->WriteText(73, 89.5, utf8_decode($date['day']));
|
||||||
$pdf->Write(0, $recu->nom);
|
$pdf->WriteText(84, 89.5, utf8_decode($date['month']));
|
||||||
$pdf->SetXY(108,25);
|
$pdf->WriteText(100, 89.5, utf8_decode($date['year']));
|
||||||
$pdf->Write(0, $recu->prenom);
|
|
||||||
$pdf->SetXY(18,38);
|
|
||||||
$pdf->Write(0, utf8_decode($recu->adresse));
|
|
||||||
$pdf->SetXY(38,44);
|
|
||||||
$pdf->Write(0, $recu->codepostal);
|
|
||||||
$pdf->SetXY(78,44);
|
|
||||||
$pdf->Write(0, utf8_decode($recu->ville));
|
|
||||||
$pdf->SetXY(85,69); // Somme en chiffre
|
|
||||||
$pdf->Write(0, utf8_decode("***".$recu->montant."***"));
|
|
||||||
$pdf->SetXY(58,79); // Somme en toute lettre
|
|
||||||
$pdf->Write(0, utf8_decode(numfmt_create('fr_FR', \NumberFormatter::SPELLOUT)->format($recu->montant)) . ' euros');
|
|
||||||
$date = date_parse($recu->date);
|
|
||||||
|
|
||||||
$pdf->SetXY(70,88); // Jour du don
|
if($plugin->getConfig('droit_art200')){
|
||||||
$pdf->Write(0, $date['day']);
|
$pdf->WriteText(57.5, 103.5, "X");
|
||||||
$pdf->SetXY(81,88); // Mois du don
|
}
|
||||||
$pdf->Write(0, $date['month']);
|
if($plugin->getConfig('droit_art238bis')){
|
||||||
$pdf->SetXY(97,88); // Année du don
|
$pdf->WriteText(107.6, 103.5, "X");
|
||||||
$pdf->Write(0, $date['year']);
|
}
|
||||||
if($plugin->getConfig('droit_art200')){
|
if($plugin->getConfig('droit_art885-0VbisA')){
|
||||||
$pdf->SetXY(56.5,103); // 200
|
$pdf->WriteText(157.7, 103.5, "X");
|
||||||
$pdf->Write(0, "X");
|
}
|
||||||
}
|
|
||||||
if($plugin->getConfig('droit_art238bis')){
|
|
||||||
$pdf->SetXY(106.5,103); // 238 bis
|
|
||||||
$pdf->Write(0, "X");
|
|
||||||
}
|
|
||||||
if($plugin->getConfig('droit_art885-0VbisA')){
|
|
||||||
$pdf->SetXY(156.5,103); // 885-0 V bis A
|
|
||||||
$pdf->Write(0, "X");
|
|
||||||
}
|
|
||||||
$pdf->SetXY(119,120.5); // Déclaration de don manuel
|
|
||||||
$pdf->Write(0, "X");
|
|
||||||
$pdf->SetXY(19,142.5); // Numéraire
|
|
||||||
$pdf->Write(0, "X");
|
|
||||||
switch ($recu->mode_paiement){
|
|
||||||
case 0:
|
|
||||||
$pdf->SetXY(19,165); // Remise d'espèces
|
|
||||||
$pdf->Write(0, "X");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
// Forme du don
|
||||||
$pdf->SetXY(61.5,165); // Chèque
|
$pdf->WriteText(119.9, 121.2, "X");
|
||||||
$pdf->Write(0, "X");
|
// Nature du don
|
||||||
break;
|
$pdf->WriteText(20, 143.6, "X");
|
||||||
|
|
||||||
case 2:
|
switch ($recu->mode_paiement){
|
||||||
$pdf->SetXY(119,165); // Virement, prélèvement, carte bancaire
|
case 0:
|
||||||
$pdf->Write(0, "X");
|
$pdf->WriteText(19.9, 165.9, "X");
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
case 1:
|
||||||
|
$pdf->WriteText(62, 165, "X");
|
||||||
|
break;
|
||||||
$pdf->SetXY(143,245); // Jour de l'édition du document
|
|
||||||
$pdf->Write(0, date('d'));
|
case 2:
|
||||||
$pdf->SetXY(151,245); // Mois de l'édition du document
|
$pdf->WriteText(119.7, 165, "X");
|
||||||
$pdf->Write(0, date('m'));
|
break;
|
||||||
$pdf->SetXY(158,245); // Année de l'édition du document
|
}
|
||||||
$pdf->Write(0, date('y'));
|
|
||||||
$img = new Fichiers($plugin->getConfig('signaturetxt'));
|
|
||||||
$cache_id = 'fichiers.' . $img->id_contenu;
|
// Date d'édition du document
|
||||||
if (!Static_Cache::exists($cache_id))
|
$pdf->WriteText(144.4, 246.2, date('d'));
|
||||||
{
|
$pdf->WriteText(152.2, 246.2, date('m'));
|
||||||
$blob = DB::getInstance()->openBlob('fichiers_contenu', 'contenu', (int)$img->id_contenu);
|
$pdf->WriteText(160, 246.2, date('Y'));
|
||||||
Static_Cache::storeFromPointer($cache_id, $blob);
|
|
||||||
fclose($blob);
|
// Signature
|
||||||
}
|
$img = new Fichiers($plugin->getConfig('signaturetxt'));
|
||||||
$uri = Static_Cache::getPath($cache_id);
|
$cache_id = 'fichiers.' . $img->id_contenu;
|
||||||
$pdf->Image($uri, 140, 247, 50, 0, 'PNG' ); // Emplacement de la signature avec restriction de largeur pour tenir dans sur la case.
|
if (!Static_Cache::exists($cache_id))
|
||||||
$pdf->Output($recu->gen_ordre.".pdf", "I");
|
{
|
||||||
|
$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");
|
||||||
|
|
Loading…
Reference in New Issue