feat(Customer/BillingEventSusbriber): Ajoute les CGV aux emails d'avis.

🎨 style(PaymentPdf): Améliore la mise en page et le pied de page du PDF.

 feat(CustomerController): Ajoute l'appel de PaymentPdf dans CustomerController.
This commit is contained in:
Serreau Jovann
2025-09-29 11:25:28 +02:00
parent 29f6a79d43
commit c1bd2b1862
6 changed files with 78 additions and 59 deletions

BIN
public/assets/logos2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
public/assets/logos2.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
public/cgv.pdf Normal file

Binary file not shown.

View File

@@ -3,6 +3,7 @@
namespace App\Controller\Artemis\Intranet;
use App\Service\Pdf\EmailListPdf;
use App\Service\Pdf\PaymentPdf;
use App\Entity\{
Customer,
CustomerAdvertPayment,

View File

@@ -91,9 +91,11 @@ class BillingEventSusbriber
public function onCreatedAvisEventSend(CreateAvisEventSend $createAvisEventSend)
{
$createAvis = $createAvisEventSend->getCustomerAdvertPayment();
$contentCgv = file_get_contents($this->kernel->getProjectDir()."/public/cgv.pdf");
$files =[];
$files[] = new DataPart(file_get_contents($this->kernel->getProjectDir()."/public".$this->uploaderHelper->asset($createAvis,"file")),"Avis de paiement - ".$createAvis->getNumAvis().".pdf");
$files[] = new DataPart($contentCgv,"Conditions Générale de Vente.pdf");
$amountHt=0;
$amount=0;
@@ -143,15 +145,18 @@ class BillingEventSusbriber
$tmpname = Uuid::v4().".pdf";
$dir = sys_get_temp_dir().'/'.$tmpname;
$content = $pdf->Output('S');
file_put_contents($dir,$content);
$upload = new UploadedFile($dir,"avis-".$createAvis->getNumAvis().".pdf","application/pdf",0,true);
$createAvis->setFile($upload);
$this->entityManager->persist($createAvis);
$this->entityManager->flush();
$contentCgv = file_get_contents($this->kernel->getProjectDir()."/public/cgv.pdf");
if($createAvisEvent->isSend()) {
$files =[];
$files[] = new DataPart($content,"Avis de paiement - ".$createAvis->getNumAvis().".pdf");
$files[] = new DataPart($contentCgv,"Conditions Générale de Vente.pdf");
$amountHt=0;
$amount=0;

View File

@@ -9,10 +9,11 @@ use Endroid\QrCode\Label\Font\OpenSans;
use Endroid\QrCode\Label\LabelAlignment;
use Endroid\QrCode\Writer\PngWriter;
use Fpdf\Fpdf;
use IntlDateFormatter;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Uid\Uuid;
define('EURO_AVIS', chr(128));
define('EURO_ADVERT', chr(128));
class PaymentPdf extends Fpdf
{
@@ -44,67 +45,61 @@ class PaymentPdf extends Fpdf
public function Header(): void
{
$this->Image($this->kernel->getProjectDir() . "/public/assets/logo_siteconseil.png", 5, 5, 25);
$this->SetFont('Arial', '', 10);
$this->Image($this->kernel->getProjectDir() . "/public/assets/logo_siteconseil.png", 90, 5, 25);
$formatter = new IntlDateFormatter(
'fr_FR',
IntlDateFormatter::FULL,
IntlDateFormatter::NONE,
'Europe/Paris',
IntlDateFormatter::GREGORIAN
);
$numDevisText = mb_convert_encoding("DEVIS N° " . $this->customerDevis->getNumAvis(), 'ISO-8859-1', 'UTF-8');
$dateText = mb_convert_encoding("Saint-Quentin, " . $formatter->format($this->customerDevis->getCreateAt()), 'ISO-8859-1', 'UTF-8');
$this->Text(15, 80, $numDevisText);
$this->Text(15, 85, $dateText);
$this->SetFont('Arial', 'B', 12);
$this->Text(30, 10, mb_convert_encoding("SITECONSEIL", 'ISO-8859-1', 'UTF-8'));
$this->SetFont('Arial', '', 12);
$this->Text(30, 15, mb_convert_encoding("27 rue le sérurier", 'ISO-8859-1', 'UTF-8'));
$this->Text(30, 20, mb_convert_encoding("02100 SAINT-QUENTIN", 'ISO-8859-1', 'UTF-8'));
$this->Text(30, 25, mb_convert_encoding("s.com@siteconseil.fr", 'ISO-8859-1', 'UTF-8'));
$this->Text(30, 30, mb_convert_encoding("03 23 05 62 43", 'ISO-8859-1', 'UTF-8'));
$this->Text(8, 35, mb_convert_encoding("SIRET: 41866405800025", 'ISO-8859-1', 'UTF-8'));
$this->Text(8, 40, mb_convert_encoding("RCS: RCS St-Quentin 418 664 058", 'ISO-8859-1', 'UTF-8'));
$this->Text(8, 45, mb_convert_encoding("TVA: FR05418664058", 'ISO-8859-1', 'UTF-8'));
$this->SetFont('Arial', 'B', 12);
$this->Text(125, 10, mb_convert_encoding("AVIS DE PAIEMENT N° " . $this->customerDevis->getNumAvis(), 'ISO-8859-1', 'UTF-8'));
$this->Text(125, 15, mb_convert_encoding("Date: " . $this->customerDevis->getCreateAt()->format('d/m/Y'), 'ISO-8859-1', 'UTF-8'));
$y = 40;
$y = 60;
$customer = $this->customerDevis->getCustomer();
$this->Text(120, $y, mb_convert_encoding($customer->getRaisonSocial(), 'ISO-8859-1', 'UTF-8'));
$this->Text(110, $y, mb_convert_encoding($customer->getRaisonSocial(), 'ISO-8859-1', 'UTF-8'));
$y += 5;
$this->Text(120, $y, mb_convert_encoding($customer->getAddress(), 'ISO-8859-1', 'UTF-8'));
$this->Text(110, $y, mb_convert_encoding($customer->getAddress(), 'ISO-8859-1', 'UTF-8'));
if ($address2 = $customer->getAddress2()) {
$y += 5;
$this->Text(120, $y, mb_convert_encoding($address2, 'ISO-8859-1', 'UTF-8'));
$this->Text(110, $y, mb_convert_encoding($address2, 'ISO-8859-1', 'UTF-8'));
}
if ($address3 = $customer->getAddress3()) {
$y += 5;
$this->Text(120, $y, mb_convert_encoding($address3, 'ISO-8859-1', 'UTF-8'));
$this->Text(110, $y, mb_convert_encoding($address3, 'ISO-8859-1', 'UTF-8'));
}
$y += 5;
$this->Text(120, $y, mb_convert_encoding($customer->getZipcode() . " " . $customer->getCity(), 'ISO-8859-1', 'UTF-8'));
$cityLine = $customer->getZipcode() . " " . $customer->getCity();
$this->Text(110, $y, mb_convert_encoding($cityLine, 'ISO-8859-1', 'UTF-8'));
$this->body();
}
public function Footer(): void
{
$this->SetY(-20);
$this->SetFont('Arial', 'I', 8);
$this->Cell(0, 5, 'SITECONSEIL - 27 rue le serrurier - 02100 SAINT-QUENTIN - s.com@siteconseil.fr', 0, 0, 'C');
$this->Ln(5);
$this->Cell(0, 5, '03 23 05 62 43 - SIRET: 41866405800025 - RCS: RCS St-Quentin - TVA: FR05418664058', 0, 0, 'C');
$this->Ln(5);
$this->Cell(0, 5, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
}
private function body(): void
{
$this->SetFont('Arial', 'B', 10);
$this->SetY(65);
$this->SetX(120);
$this->Cell(40, 5, mb_convert_encoding("PRIX HT", "ISO-8859-1", "UTF-8"), 0, 0, 'R');
$this->Cell(40, 5, mb_convert_encoding("PRIX TTC", "ISO-8859-1", "UTF-8"), 0, 1, 'R');
$this->Line(10, 70, 200, 70);
$this->SetXY(145, 100);
$this->Cell(40, 5, mb_convert_encoding("PRIX HT", "ISO-8859-1", "UTF-8"), 0, 0, 'C');
$this->Line(145, 110, 145, 220);
$this->Line(185, 110, 185, 220);
$this->Line(0, 100, 5, 100);
$this->Line(0, 200, 5, 200);
}
public function generate(): void
@@ -113,35 +108,34 @@ class PaymentPdf extends Fpdf
$this->AddPage();
$this->SetFont('Arial', '', 12);
$startY = 75;
$startY = 110;
$this->SetY($startY);
$contentBottomLimit = 220;
foreach ($this->items as $item) {
if ($this->GetY() + 30 > $contentBottomLimit) {
$this->AddPage();
$this->body();
$this->body(); // redraw table headers
$this->SetY($startY);
}
$currentY = $this->GetY();
// Title
$this->SetX(10);
$this->SetFont('Arial', 'B', 12);
$this->Cell(110, 10, mb_convert_encoding($item['title'], 'ISO-8859-1', 'UTF-8'), 0, 0);
$this->SetX(20);
$this->SetFont('Arial', 'B', 11);
$this->Cell(95, 10, mb_convert_encoding($item['title'], 'ISO-8859-1', 'UTF-8'), 0, 0);
// Prices HT and TTC
$this->SetFont('Arial', '', 12);
$this->SetXY(120, $currentY);
$this->Cell(40, 10, number_format($item['priceHt'], 2, ",") . " " . EURO_AVIS, 0, 0, 'R');
$this->SetXY(160, $currentY);
$this->Cell(40, 10, number_format($item['priceTTC'], 2, ",") . " " . EURO_AVIS, 0, 1, 'R');
// Prices
$this->SetFont('Arial', '', 11);
$this->SetXY(142, $currentY);
$this->SetFont('Arial', 'B', 11);
$this->Cell(39, 8, number_format($item['priceHt'], 2, ",") . " " . EURO_ADVERT, 0, 1, 'R');
$this->SetFont('Arial', '', 11);
// Content description
$this->SetX(10);
$this->MultiCell(110, 5, mb_convert_encoding($item['content'], 'ISO-8859-1', 'UTF-8'), 0, 'L');
$this->SetX(30);
$this->MultiCell(90, 5, mb_convert_encoding($item['content'], 'ISO-8859-1', 'UTF-8'), 0, 'L');
$this->Ln(5);
}
@@ -149,6 +143,23 @@ class PaymentPdf extends Fpdf
$this->displaySummary();
}
public function Footer()
{
$this->Ln(10);
$this->SetFont('Arial', 'B', 8);
$this->SetTextColor(253, 140,4);
$this->SetDrawColor(253, 140,4);
$this->Cell(190, 5, mb_convert_encoding("Partenaire de vos projects de puis 1997", 'ISO-8859-1', 'UTF-8'), 0, 1,'C');
$this->Line(15,$this->GetY(),195,$this->GetY());
$this->SetFont('Arial', '', 8);
$this->SetTextColor(0, 0, 0);
$this->Ln(2);
$this->Cell(190, 4, mb_convert_encoding("27, rue le Sérurier - 02100 SAINT-QUENTIN - Tél: 03 23 05 62 43 - Réglement par virement: FR76 1020 6006 7198 7497 7981 061", 'ISO-8859-1', 'UTF-8'), 0, 1,'C');
$this->Cell(190, 4, mb_convert_encoding("e-mail : s.com@siteconseil.fr - www.siteconseil.fr", 'ISO-8859-1', 'UTF-8'), 0, 1,'C');
$this->Cell(190, 4, mb_convert_encoding("S.A.R.L aux captial de 71400 ", 'ISO-8859-1', 'UTF-8').EURO_ADVERT." - ".mb_convert_encoding("N°SIRET 418 664 058 00025 - N° TVA FR 05 418 664 058 - CODE APE 6201 Z - R.C. St-Quentin 418 664 058", 'ISO-8859-1', 'UTF-8'), 0,0 ,'C');
}
private function displaySummary(): void
{
$builder = new Builder(
@@ -177,15 +188,17 @@ class PaymentPdf extends Fpdf
$totalTTC = $totalHT + $totalTVA;
$this->SetY(-60);
$this->Cell(30, 10, "", 0, 0, 'L');
$this->SetFont('Arial', '', 12);
$this->Cell(100, 10, mb_convert_encoding('Total HT :', 'ISO-8859-1', 'UTF-8'), 0, 0, 'R');
$this->Cell(40, 10, number_format($totalHT, 2, ",") . " " . EURO_ADVERT, 0, 1, 'R');
$this->Cell(135, 10, mb_convert_encoding('TVA (20%) :', 'ISO-8859-1', 'UTF-8'), 0, 0, 'R');
$this->Cell(35, 10, number_format($totalTVA, 2, ",") . " " . EURO_ADVERT, 0, 1, 'R');
$this->SetFont('Arial', 'B', 12);
$this->Cell(150, 10, mb_convert_encoding('Total HT:', 'ISO-8859-1', 'UTF-8'), 0, 0, 'R');
$this->Cell(40, 10, number_format($totalHT, 2, ",") . " " . EURO_AVIS, 0, 1, 'R');
$this->Cell(150, 10, mb_convert_encoding('TVA (20%):', 'ISO-8859-1', 'UTF-8'), 0, 0, 'R');
$this->Cell(40, 10, number_format($totalTVA, 2, ",") . " " . EURO_AVIS, 0, 1, 'R');
$this->Cell(150, 10, mb_convert_encoding('Total TTC:', 'ISO-8859-1', 'UTF-8'), 0, 0, 'R');
$this->Cell(40, 10, number_format($totalTTC, 2, ",") . " " . EURO_AVIS, 0, 1, 'R');
$this->Cell(135, 10, mb_convert_encoding('Total :', 'ISO-8859-1', 'UTF-8'), 0, 0, 'R');
$this->Cell(35, 10, number_format($totalTTC, 2, ",") . " " . EURO_ADVERT, 0, 1, 'R');
}
}