feat(certificat): Implémente le téléchargement PDF du certificat de mise en ligne.

This commit is contained in:
Serreau Jovann
2026-02-06 17:48:42 +01:00
parent c650b8fa20
commit 65e3045cbc
3 changed files with 140 additions and 2 deletions

View File

@@ -14,6 +14,8 @@ use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use App\Service\Pdf\CertificatOnlinePdfService;
#[Route('/crm')]
class HomeController extends AbstractController
{
@@ -32,6 +34,17 @@ class HomeController extends AbstractController
) {
}
#[Route('/certificat/online', name: 'app_crm_certificat_online', methods: ['GET'])]
public function downloadCertificat(CertificatOnlinePdfService $pdfService): Response
{
$content = $pdfService->generate();
return new Response($content, 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="certificat_mise_en_ligne.pdf"'
]);
}
#[Route('', name: 'app_crm', options: ['sitemap' => false], methods: ['GET'])]
public function index(): Response
{

View File

@@ -0,0 +1,125 @@
<?php
namespace App\Service\Pdf;
use Fpdf\Fpdf;
use Symfony\Component\HttpKernel\KernelInterface;
class CertificatOnlinePdfService extends Fpdf
{
private string $logo;
public function __construct(KernelInterface $kernel, $orientation = 'P', $unit = 'mm', $size = 'A4')
{
parent::__construct($orientation, $unit, $size);
$this->logo = $kernel->getProjectDir()."/public/provider/images/favicon.png";
$this->AliasNbPages();
$this->SetAutoPageBreak(true, 35);
}
private function clean(?string $text): string
{
if (!$text) return '';
$text = iconv('UTF-8', 'windows-1252//TRANSLIT//IGNORE', $text);
return str_replace('€', chr(128), $text);
}
public function Header()
{
$this->SetY(10);
if (file_exists($this->logo)) {
$this->Image($this->logo, 10, 10, 12);
$this->SetX(25);
}
$this->SetFont('Arial', 'B', 14);
$this->SetTextColor(0, 0, 0);
$this->Cell(0, 7, $this->clean('CERTIFICAT DE MISE EN LIGNE'), 0, 1, 'L');
$this->SetDrawColor(37, 99, 235);
$this->SetLineWidth(0.5);
$this->Line(10, 25, 200, 25);
}
public function generate(): string
{
$this->AddPage();
$this->SetY(40);
// --- PRESTATAIRE ---
$this->SetFont('Arial', 'B', 12);
$this->SetTextColor(37, 99, 235);
$this->Cell(0, 7, $this->clean('PRESTATAIRE'), 0, 1, 'L');
$this->SetFont('Arial', '', 10);
$this->SetTextColor(0, 0, 0);
$this->MultiCell(0, 5, $this->clean("SARL SITECONSEIL
27 RUE LE Sérurier
02100 Saint-Quentin
s.com@siteconseil.fr
Siret : 41866405800025
Représenté par M. Legrand Philippe"), 0, 'L');
$this->Ln(10);
// --- CLIENT ---
$this->SetFont('Arial', 'B', 12);
$this->SetTextColor(37, 99, 235);
$this->Cell(0, 7, $this->clean('CLIENT'), 0, 1, 'L');
$this->SetFont('Arial', '', 10);
$this->SetTextColor(0, 0, 0);
$this->MultiCell(0, 5, $this->clean("SEGARD LILIAN - LUDIKEVENT
6, rue du Château
02800 DANIZY
06 14 17 24 47
lilian@ludikevent.fr
Représenté par SEGARD Lilian
Siret : 93048840800012"), 0, 'L');
$this->Ln(15);
// --- OBJET ---
$this->SetFont('Arial', 'B', 12);
$this->SetTextColor(37, 99, 235);
$this->Cell(0, 7, $this->clean('OBJET DU CERTIFICAT'), 0, 1, 'L');
$this->SetFont('Arial', '', 10);
$this->SetTextColor(0, 0, 0);
$this->MultiCell(0, 5, $this->clean("Le présent certificat atteste de la mise en ligne officielle du site intranet développé pour le Client.
En signant ce document, le Client reconnaît :
- Que le développement de l'intranet est terminé.
- Que le livrable est conforme au cahier des charges établi.
- Qu'à compter de cette signature, toute modification ou intervention supplémentaire sera soumise à facturation."), 0, 'L');
$this->Ln(20);
// --- SIGNATURES ---
$ySign = $this->GetY();
$this->SetXY(15, $ySign);
$this->SetFont('Arial', 'B', 10);
$this->Cell(85, 8, $this->clean("Le Prestataire (SARL SITECONSEIL)"), 0, 1, 'C');
$this->SetX(15);
$this->Cell(85, 45, "", 1, 0);
$this->SetXY(110, $ySign);
$this->SetFont('Arial', 'B', 10);
$this->Cell(85, 8, $this->clean("Le Client (LUDIKEVENT)"), 0, 1, 'C');
$this->SetX(110);
$this->Cell(85, 45, "", 1, 0);
$this->SetXY(110, $ySign + 8);
$this->SetFont('Arial', 'I', 8);
$this->Cell(85, 5, $this->clean("Date et Signature, précédées de la mention 'Lu et approuvé'"), 0, 1, 'C');
return $this->Output('S');
}
public function Footer(): void
{
$this->SetY(-15);
$this->SetFont('Arial', 'I', 8);
$this->SetTextColor(128);
$this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
}
}

View File

@@ -29,7 +29,7 @@
<div class="flex items-center justify-between p-4 rounded-2xl bg-white/5 border border-white/5 hover:bg-white/10 transition-colors">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-xl bg-{{ color }}-500/20 flex items-center justify-center text-{{ color }}-400">
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24"><path d="{{ icon_path }}"/></svg>
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24"><path d="{{ icon_path }}"/></svg>
</div>
<div>
<p class="text-[9px] font-black text-slate-400 uppercase tracking-widest mb-0.5">{{ label }}</p>
@@ -151,4 +151,4 @@
</section>
</div>
</div>
{% endblock %}
{% endblock %}