bilingual-invoice-generator/show.php

29 lines
620 B
PHP
Raw Normal View History

2020-01-31 01:04:13 +00:00
<?php
require_once __DIR__.'/vendor/autoload.php';
use App\Generator\InvoiceGenerator;
use App\Invoice\InvoiceData;
use App\Kernel;
2020-01-31 01:04:13 +00:00
use Mpdf\Mpdf;
use Symfony\Component\Yaml\Yaml;
$config = Yaml::parseFile(Kernel::getProjectRoot().'/config/parameters.yaml');
$invoice = new InvoiceData(
123,
new \DateTime(),
new \DateTime($config['contract']['date_from']),
new \DateTime
);
2020-01-31 01:04:13 +00:00
$pdf = $_GET['pdf'] ?? false;
if ($pdf) {
$mpdf = new Mpdf();
$mpdf->WriteHTML(InvoiceGenerator::generate($invoice, $config));
2020-01-31 01:04:13 +00:00
$mpdf->Output();
} else {
echo InvoiceGenerator::generate($invoice, $config);
2020-01-31 01:04:13 +00:00
}