Remplissage du PDF
This commit is contained in:
parent
b18cd91aa4
commit
0ab5fa5ad0
@ -3,6 +3,8 @@ namespace Garradin;
|
||||
|
||||
$session->requireAccess('compta', Membres::DROIT_ADMIN);
|
||||
|
||||
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.");
|
||||
}
|
||||
@ -10,125 +12,93 @@ if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||
$id = (int) $_GET['id'];
|
||||
|
||||
$gendon = new Plugin\RecuDon\GenDon;
|
||||
|
||||
$recu = $gendon->get($id);
|
||||
|
||||
require_once PLUGIN_ROOT . '/lib/MPDF/vendor/autoload.php';
|
||||
|
||||
// require_once(PLUGIN_ROOT . '/lib/fpdf/fpdf.php');
|
||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/pdf_context.php');
|
||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/pdf_parser.php');
|
||||
// require_once(PLUGIN_ROOT . '/lib/FPDI/fpdi_pdf_parser.php');
|
||||
// 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 = new \Mpdf\Mpdf([
|
||||
'default_font_size' => 10,
|
||||
'default_font' => 'Helvetica',
|
||||
]);
|
||||
]);
|
||||
|
||||
$pdf->AddPage();
|
||||
$pdf->setSourceFile(PLUGIN_ROOT . '/data/11580-03.pdf');
|
||||
$pdf->useTemplate(
|
||||
$pdf->AddPage();
|
||||
$pdf->setSourceFile(PLUGIN_ROOT . '/data/11580-03.pdf');
|
||||
$pdf->useTemplate(
|
||||
$pdf->importPage(1)
|
||||
);
|
||||
);
|
||||
|
||||
$pdf->SetTextColor(0);
|
||||
$pdf->WriteText(180, 18, $recu->gen_ordre);
|
||||
$pdf->WriteText(20, 43, $config->get('nom_asso'));
|
||||
$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->SetTextColor(0);
|
||||
$pdf->WriteText(180, 18, $recu->gen_ordre);
|
||||
$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->AddPage();
|
||||
$pdf->useTemplate(
|
||||
$pdf->importPage(2)
|
||||
);
|
||||
);
|
||||
|
||||
$pdf->SetXY(18,25);
|
||||
$pdf->Write(0, $recu->nom);
|
||||
$pdf->SetXY(108,25);
|
||||
$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->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."***"));
|
||||
$pdf->WriteText(62, 80, utf8_decode(numfmt_create('fr_FR', \NumberFormatter::SPELLOUT)->format($recu->montant)) . ' euros');
|
||||
$date = date_parse($recu->date);
|
||||
|
||||
$pdf->SetXY(70,88); // Jour du don
|
||||
$pdf->Write(0, $date['day']);
|
||||
$pdf->SetXY(81,88); // Mois du don
|
||||
$pdf->Write(0, $date['month']);
|
||||
$pdf->SetXY(97,88); // Année du don
|
||||
$pdf->Write(0, $date['year']);
|
||||
if($plugin->getConfig('droit_art200')){
|
||||
$pdf->SetXY(56.5,103); // 200
|
||||
$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){
|
||||
$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->SetXY(19,165); // Remise d'espèces
|
||||
$pdf->Write(0, "X");
|
||||
$pdf->WriteText(19.9, 165.9, "X");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$pdf->SetXY(61.5,165); // Chèque
|
||||
$pdf->Write(0, "X");
|
||||
$pdf->WriteText(62, 165, "X");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$pdf->SetXY(119,165); // Virement, prélèvement, carte bancaire
|
||||
$pdf->Write(0, "X");
|
||||
$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'));
|
||||
|
||||
$pdf->SetXY(143,245); // Jour de l'édition du document
|
||||
$pdf->Write(0, date('d'));
|
||||
$pdf->SetXY(151,245); // Mois de l'édition du document
|
||||
$pdf->Write(0, date('m'));
|
||||
$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;
|
||||
if (!Static_Cache::exists($cache_id))
|
||||
{
|
||||
// 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, 140, 247, 50, 0, 'PNG' ); // Emplacement de la signature avec restriction de largeur pour tenir dans sur la case.
|
||||
$pdf->Output($recu->gen_ordre.".pdf", "I");
|
||||
}
|
||||
$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
Block a user