<?php
namespace App\Controller\Alis;
use App\Entity\RoutageJustif;
use App\Services\EnvDetector;
use App\Services\MontageService;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Knp\Component\Pager\PaginatorInterface;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Annonce;
use App\Entity\Parution;
use App\Entity\Greffe\Demat as GreffeDemat;
use App\Entity\Departement;
use App\Repository\AnnonceRepository;
use App\Repository\DepartementRepository;
use App\Repository\ParutionRepository;
use App\Repository\Greffe\DematRepository as GreffeDematRepository;
use App\Repository\Annonce\TypeRepository;
use App\Repository\Annonce\TypeChapitreRepository;
use App\Repository\Greffe\ImportRepository as ImportGreffeRepository;
use App\Services\LignageService;
use App\Services\FileService;
use App\Services\XtagService;
use App\Services\EmailSender;
use App\Services\FactureService;
use App\Services\PdfService;
use App\Factory\AnnonceFactory;
#[Route('/alis/parution')]
class ParutionController extends AbstractController
{
private ParutionRepository $parRepo;
public function __construct(ParutionRepository $parRepo)
{
$this->parRepo = $parRepo;
}
#[Route('/', methods: ['GET'])]
public function index(Request $request): Response
{
return $this->render('alis/parution/index.html.twig', []);
}
#[Route('/infos/{type}', methods: ['GET'])]
public function infos(
DepartementRepository $depRepo, AnnonceRepository $annRepo,
GreffeDematRepository $greffeDematRepo, Request $request, $type=""): Response
{
$depsWeb = [];
if(!$type || $type=="web") {
$depsWeb = $depRepo->findAllWeb();
}
$parutions_open = [];
if(!$type || $type=="open") {
$parutions_open = $this->parRepo->findAllOpenArray(); //findAllOpen();
}
$parutions_closed = [];
if(!$type || $type=="closed") {
$limit = 12;
if(!$type=="closed") {
$limit = 30;
}
$parutions_closed = $this->parRepo->findAllClosed($limit);
}
$webDepartements = [];
foreach($depsWeb as $dep) {
$annonces = $annRepo->findForWebDep($dep->getCode(), false, true)->getQuery()->getResult();
$bodaccs = count($annRepo->findWithBodaccForWebDep($dep->getCode()));
$bodaccsB255 = count($annRepo->findWithBodaccB255ForWebDep($dep->getCode()));
$greffes = $greffeDematRepo->findDepActive($dep);
$webDepartements[$dep->getCode()] = [
"departement" => $dep,
"annonces" => $annonces,
"bodaccs" => $bodaccs,
"bodaccsB255" => $bodaccsB255,
"greffes" => $greffes
];
}
$xtag_du = new \DateTime("last thursday");
$xtag_au = new \DateTime("yesterday");
if($xtag_du == $xtag_au) {
$xtag_du->sub(new \DateInterval("P7D"));
$xtag_au->sub(new \DateInterval("P1D"));
}
$xtag55_du = new \DateTime("last friday");
$xtag55_au = new \DateTime("yesterday");
$montage_au = new \DateTime("last sunday");
$montage_du = new \DateTime("last sunday");
$montage_du->sub(new \DateInterval("P6D"));
return $this->render('alis/parution/infos.html.twig', [
'webDepartements' => $webDepartements,
'parutions_open' => $parutions_open,
'parutions_closed' => $parutions_closed,
'xtag_du' => $xtag_du,
'xtag_au' => $xtag_au,
'xtag55_du' => $xtag55_du,
'xtag55_au' => $xtag55_au,
'montage_du' => $montage_du,
'montage_au' => $montage_au,
]);
}
#[Route('/info/{dep}', methods: ['GET'])]
public function info(AnnonceRepository $annRepo, GreffeDematRepository $greffeDematRepo, Request $request, Departement $dep): Response
{
$annonces = $annRepo->findForWebDep($dep->getCode())->getQuery()->getResult();
$bodaccs = $annRepo->findWithBodaccForWebDep($dep->getCode());
$bodaccsB255 = $annRepo->findWithBodaccB255ForWebDep($dep->getCode());
$greffes = $greffeDematRepo->findDepActive($dep);
$webDepartement = [
"departement" => $dep,
"annonces" => $annonces,
"bodaccs" => $bodaccs,
"bodaccsB255" => $bodaccsB255,
"greffes" => $greffes
];
return $this->render('alis/parution/info.html.twig', [
'webDepartement' => $webDepartement
]);
}
#[Route('/show_id/{id}', methods: ['GET'])]
public function show_id(Request $request, Parution $parution): Response
{
$dep = $parution->getDepartement()->getCode();
$num = $parution->getNum();
return $this->redirectToRoute('app_alis_parution_show', ['dep'=>$dep, 'num'=>$num]);
}
#[Route('/recalcXtag/{dep}/{num}/', methods: ['GET','POST'])]
public function recalXtag(Request $request, $dep, $num): Response
{
$parution = $this->parRepo->findOneByDepNum($dep, $num);
foreach ($parution->getAnnonces() as $annonce) {
$annonce->getEditeur()?->setTexteBalise();
}
$this->getDoctrine()->getManager()->flush();
return new Response('OK');
}
#[Route('/show/{dep}/{num}/{conducteur}', methods: ['GET','POST'])]
public function show(
AnnonceRepository $annRepo, PaginatorInterface $paginator, XtagService $xtagService,
TypeChapitreRepository $typeChapitreRepo, ImportGreffeRepository $importGreffeRepo,
Request $request, $dep, $num, $conducteur=null): Response
{
$form = null; //conducteur
$parution = null;
$annonces = [];
$type = 'papier';
$label = '';
$show_planned = false;
$show_conducteur = false;
$show_corrigee = false;
$chapitres = [];
$greffe_demats = [];
$array_stats = [];
$recherche_enabled = true;
if($num == "web") {
$annonces = $annRepo->findForWebDep($dep);
$type = 'web';
$label = 'Parution web '.$dep;
$show_planned = true;
$show_corrigee = true;
$array_stats = $annRepo->findForWebDepStat($dep);
}
elseif($num == "external") {
$annonces = $annRepo->findExternalEnCours();
$type = "external";
$dep = $parution = null;
$label = "Annonces extérieures en cours";
$show_corrigee = false;
}
else {
$show_corrigee = true;
$parution = $this->parRepo->findOneByDepNum($dep, $num);
if(!$parution) {
throw new \Exception("NOT found parution ".$dep." ".$num);
}
$annonces = $annRepo->findForParution($parution);
if($conducteur === "1") {
$annonces = $annRepo->getAnnoncesOrdered($parution, true);
}
$label = 'Edition '.$dep." n. ".$num." du ".$parution->getDate()->format("d/m/Y");
$array_stats = $annRepo->findForParutionStat($parution);
}
if($conducteur === "1") {
$recherche_enabled = false;
$array_stats = [];
$chapitres = $typeChapitreRepo->findAll();
if($parution) {
$greffe_demats = $importGreffeRepo->findOnParution($parution);
}
$show_conducteur = true;
$show_corrigee = false;
$model = [];
$form = $this->createForm(\App\Form\Parution\ConducteurType::class, $model, ['attr' => ['target' => '_blank']]);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()) {
$annonces_all = $annonces_xtag = [];
if($parution) {
$annonces_all = $annRepo->getAnnoncesOrdered($parution);
} else {
$annonces_all = $paginator->paginate($annonces, 1, 1000)->getItems();
}
$selected = $form->get("selected")->getData();
//if($selected) {
$ids = explode(",", $selected);
foreach($annonces_all as $annonce) {
if(in_array($annonce->getId(), $ids)) {
array_push($annonces_xtag, $annonce);
}
}
/*} else {
$annonces_xtag = $annonces_all;
}*/
$xtag = $xtagService->getXtagForAnnonces($annonces_xtag);
return $this->xtagResponse($xtag);
}
//era così prima
/*if($request->get("xtag")) {
$annonces_xtag = null;
if($parution) {
//per avere ordine corretto e quindi sempre tutti non + i selezionati in questo caso
$annonces_xtag = $annRepo->getAnnoncesOrdered($parution);
} else {
$annonces_xtag = $paginator->paginate($annonces, 1, 1000)->getItems();
}
$xtag = $xtagService->getXtagForAnnonces($annonces_xtag);
return $this->xtagResponse($xtag);
}*/
}
$pagination = $paginator->paginate(
$annonces,
$request->query->getInt('page', 1),
500
);
return $this->render('alis/parution/show.html.twig', [
//'clients' => $clientRepository->findAll(),
'pagination' => $pagination,
'parution' => $parution,
'type' => $type,
'dep' => $dep,
'label' => $label,
'show_planned' => $show_planned,
'show_conducteur' => $show_conducteur,
'show_corrigee' => $show_corrigee,
'form' => $form ? $form->createView() : null,
'chapitres' => $chapitres,
'greffe_demats' => $greffe_demats,
'array_stats' => $array_stats,
'recherche_enabled' => $recherche_enabled
]);
}
#[Route('/external', methods: ['GET'])]
public function external(AnnonceRepository $annRepo, PaginatorInterface $paginator, Request $request): Response
{
return $this->redirectToRoute("app_alis_parution_show", ["dep"=>"0","num"=>"external"]);
}
#[Route('/menu', methods: ['GET'])]
public function menu(DepartementRepository $depRepo, Request $request): Response
{
//rendered by menu
$depsPapier = $depRepo->findAllPapier();
$depsWeb = $depRepo->findAllWeb();
$parutions = [];
foreach($depsPapier as $dep) {
$par = $this->parRepo->findCurrent($dep->getCode());
if($par) {
array_push($parutions, $par);
}
}
return $this->render('alis/parution/menu.html.twig', [
'parutions' => $parutions,
'depsWeb' => $depsWeb
]);
}
#[Route('/conducteur/{id}', methods: ['GET'])]
public function conducteur(Request $request, Parution $parution): Response
{
$dep = $parution->getDepartement()->getCode();
$num = $parution->getNum();
return $this->redirectToRoute('app_alis_parution_show', ['dep'=>$dep, 'num'=>$num, 'conducteur'=>'1']);
}
#[Route('/close/{id}', methods: ['GET'])]
public function close(Request $request, Parution $parution): Response
{
try {
if(!$parution->isClosable()) {
throw new \Exception("Parution ".$parution." NOT closable");
}
$parution->close();
$this->getDoctrine()->getManager()->flush();
$this->addFlash('success', 'parution clôturée');
} catch(\Exception $ex) {
$this->addFlash('danger', $ex->getMessage());
}
return $this->redirectToRoute('app_alis_parution_show_id', ['id'=>$parution->getId()]);
}
#[Route('/lignages/extl', methods: ['GET'])]
public function lignages(LignageService $lignageService, AnnonceFactory $annonceFactory, AnnonceRepository $annonceRepo, FactureService $factureService): Response
{
//verfica le parution chiuse se tutti gli annunci sono scritti
//se si calcola il lignage
/*$now = new \DateTime();
if($now > new \DateTime("2023-12-29 00:00:00") && $now < new \DateTime("2024-01-01 05:00:00") ) {
return new Response("script blocked --> invali day ".$now->format("Y-m-d"));
}*/
$tot = $pars = 0;
$parutions = $this->parRepo->findAllClosed(12);
foreach($parutions as $parution) {
if($parution->needsLignage()) {
$callLignage=true;
foreach($parution->getLignageAnnonces() as $annonce) {
if(!$annonce->isSaisie()) {
$callLignage=false;
break;
}
}
if($callLignage) {
$arrPar = $lignageService->calculateParution($parution, $annonceFactory);
$count = $arrPar['count'];
$pars++;
$tot += $count;
}
}
}
$this->getDoctrine()->getManager()->flush();
//app_alis_facture_generate
$annonces = $annonceRepo->findToFactureGeneration();
if(count($annonces) > 0) {
$factureService->generateFactureForAnnonces($annonces, false);
}
return new Response($pars." parution calculated, ".$tot." annonces");
}
#[Route('/lignage/{id}/extl', methods: ['GET'])]
public function lignage(LignageService $lignageService, AnnonceFactory $annonceFactory, Request $request, Parution $parution): Response
{
set_time_limit(-1);
ini_set('memory_limit','4096M');
try {
if(!$parution->isClosed()) {
throw new \Exception("Parution ".$parution." NOT closed");
}
if(!$parution->needsLignage()) {
throw new \Exception("Parution ".$parution." NOT need lignage");
}
$arrPar = $lignageService->calculateParution($parution, $annonceFactory);
$msg = $arrPar['msg'];
$count = $arrPar['count'];
$this->getDoctrine()->getManager()->flush();
$this->addFlash('success', $count.' annonces : lignage calculé');
if($msg) {
$this->addFlash('danger', 'annonce '.$msg.' pas saisie');
} else {
return $this->redirectToRoute("app_alis_facture_generate");
}
} catch(\Exception $ex) {
$this->addFlash('danger', $ex->getMessage());
}
return $this->redirectToRoute('app_alis_parution_show_id', ['id'=>$parution->getId()]);
}
#[Route('/indesign/{id}', methods: ['GET','POST'])]
public function indesign(FileService $fileService, AnnonceFactory $annonceFactory, Request $request, Parution $parution, EnvDetector $envDetector): Response
{
$form = $this->createForm(\App\Form\Parution\IndesignType::class);
try {
if(!$parution->isClosed()) {
throw new \Exception("Parution ".$parution." NOT closed");
}
$parution->checkIfAllReadyForIndesign();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('filename')->getData();
$now = new \DateTime();
$dir = $fileService->getProjectDir()."/var/alis/parution/import/";
$fileName = $parution->getId()."_".$now->format("ymdHis");
$path = $dir.$fileName;
$file->move($dir, $fileName);
$arrayAnnonces = $fileService->importFileIndesign($parution, $path);
foreach($arrayAnnonces as $row) {
$annonce = $row["annonce"];
$numpage = $row["numpage"];
$annonce->getMisenpage()->setNumpage($numpage);
foreach($annonce->getFactures() as $facture) {
if($facture->getEtat() == 0) {
$facture->setEtat(1);
}
$facture->getInfo()->setNumpage($numpage);
}
$annonceFactory->set($annonce)->changeEtat("monte");
}
$parution->setStartPage($form->get('start_page')->getData());
$this->getDoctrine()->getManager()->flush();
$this->addFlash("success", "Importation indesign parution ".$parution." terminée avec succès (".count($arrayAnnonces)." annonces)");
return $this->redirectToRoute('app_alis_parution_index');
}
} catch(\Exception $ex) {
if($envDetector->isTest()) {
throw $ex;
}
$this->addFlash('danger', "<b>Erreur lors de l'importation</b><br/>".$ex->getMessage());
}
return $this->render('alis/parution/indesign.html.twig', [
'form' => $form->createView(),
'parution' => $parution,
]);
}
#[Route('/lignage/{id}/upload', methods: ['GET','POST'])]
public function lignage_upload(FileService $fileService, AnnonceFactory $annonceFactory, Request $request, Parution $parution, EnvDetector $envDetector): Response
{
$form = $this->createForm(\App\Form\Parution\IndesignType::class);
try {
if(!$parution->isClosed()) {
throw new \Exception("Parution ".$parution." NOT closed");
}
if(!$parution->needsUploadLignage()) {
throw new \Exception("Parution ".$parution." NOT neeeds lignage upload");
}
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('filename')->getData();
$now = new \DateTime();
$dir = $fileService->getProjectDir()."/var/alis/parution/import/";
$fileName = "lignage_".$parution->getId()."_".$now->format("ymdHis");
$path = $dir.$fileName;
$file->move($dir, $fileName);
$arrayAnnonces = $fileService->importFileLignage($parution, $path);
if(count($arrayAnnonces) > 0) {
foreach($arrayAnnonces as $row) {
$annonce = $row["annonce"];
$numligs = $row["numligs"];
$annonce->setLignage($numligs);
$annonceFactory->set($annonce)->changeEtat("lignage"); //->flush();
}
$this->getDoctrine()->getManager()->flush();
$this->addFlash("success", "Importation lignage parution ".$parution." terminée avec succès (".count($arrayAnnonces)." annonces)");
return $this->redirectToRoute("app_alis_facture_generate");
}
$this->addFlash("danger", "Importation lignage parution ".$parution." terminée avec 0 annonces");
return $this->redirectToRoute('app_alis_parution_index');
}
} catch(\Exception $ex) {
if($envDetector->isTest()) {
throw $ex;
}
$this->addFlash('danger', "<b>Erreur lors de l'importation</b><br/>".$ex->getMessage());
}
return $this->render('alis/parution/lignage.html.twig', [
'form' => $form->createView(),
'parution' => $parution,
]);
}
#[Route('/lignage/{id}/download', methods: ['GET','POST'])]
public function lignage_download(FileService $fileService, Request $request, Parution $parution): Response
{
if(!$parution->isClosed()) {
throw new \Exception("Parution ".$parution." NOT closed");
}
if(!$parution->needsUploadLignage()) {
throw new \Exception("Parution ".$parution." NOT neeeds lignage upload");
}
$text = "";
foreach($parution->getLignageAnnonces() as $annonce) {
$text .= $annonce->getId()."|\n";
}
return $this->xtagResponse($text, "lignage_".$parution->getNum().".txt");
}
private function xtagResponse($xtag, $filename='xtag.txt') : Response
{
$response = new Response($xtag);
$disposition = $response->headers->makeDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
$filename
);
$response->headers->set('Content-Disposition', $disposition);
return $response;
}
#[Route('/xtag/greffe/{parution}/{greffe}', methods: ['GET'])]
public function xtag_greffe (
AnnonceRepository $annonceRepo, XtagService $xtagService, Request $request,
Parution $parution, GreffeDemat $greffe): Response
{
$annonces = $annonceRepo->getAnnoncesGreffeDematOrdered($parution, $greffe);
//dump($annonces);
$xtag = $xtagService->getXtagForAnnoncesGreffe($greffe, $annonces);
return $this->xtagResponse($xtag);
}
#[Route('/xtag/greffe_demat/{greffe}/{du}/{au}', methods: ['GET'])]
public function xtag_greffe_demat (
AnnonceRepository $annonceRepo, XtagService $xtagService, Request $request,
GreffeDemat $greffe, $du, $au): Response
{
$du = new \DateTime($du." 00:00:00");
$au = new \DateTime($au." 23:59:59");
$annonces = $annonceRepo->getAnnoncesGreffeDematOrdered(null, $greffe, $du, $au);
//dump($annonces);
$xtag = $xtagService->getXtagForAnnoncesGreffe($greffe, $annonces);
return $this->xtagResponse($xtag);
}
#[Route('/xtag/departement/{dep}/{du}/{au}', methods: ['GET'])]
public function xtag_departement (
AnnonceRepository $annonceRepo, XtagService $xtagService, Request $request,
\App\Entity\Departement $dep, $du, $au): Response
{
$du = new \DateTime($du." 00:00:00");
$au = new \DateTime($au." 23:59:59");
//degli annunci pubblicati nel dep nel periodo selezionato
$annonces = $annonceRepo->getAnnoncesDepPulishedOrdered($dep, $du, $au);
//dump($annonces);
$xtag = $xtagService->getXtagForAnnonces($annonces, true);
return $this->xtagResponse($xtag);
}
#[Route('/xtag/parution/{parution}', methods: ['GET'])]
public function xtag(AnnonceRepository $annonceRepo, XtagService $xtagService, Request $request, Parution $parution): Response
{
$annonces = $annonceRepo->getAnnoncesOrdered($parution);
//dump($annonces);
$xtag = $xtagService->getXtagForAnnonces($annonces);
return $this->xtagResponse($xtag);
}
#[Route('/pdf/{id}', methods: ['GET'])]
public function pdf(Request $request, Parution $parution): Response
{
$codedep = $parution->getDepartement()->getCode();
$societe = $parution->getSociete();
$journal_prefix = $societe->getPrefix();
$numparution = $parution->getNum();
$dateparution = $parution->getDate();
$filename = $journal_prefix.'_'.$numparution;
if($codedep == "02" && $numparution > 3866) {
$filename .= '_A';
}
if($codedep == "80" && $numparution > 3866) {
$filename .= '_S';
}
//Since 2023, single file
if($parution->getDate() < new \DateTime('2023-01-01')) {
$filename .= '_al';
}
$filename .= '.pdf';
$filepath = $dateparution->format('Y/m/').$filename;
$ftphost = $societe->getFtpHost();
$ftpuser = $societe->getFtpUser();
$ftppass = $societe->getFtpPsw();
$pdf = @file_get_contents('ftp://'.$ftpuser.':'.$ftppass.'@'.$ftphost.'/'.$filepath);
//return $pdf;
if (empty($pdf)) {
return new Response('PDF NOT FOUND');
}
return new Response($pdf, 200, array(
'Content-Disposition' => 'filename="'.$filename.'"',
'Content-Type' => 'application/pdf'
));
}
#[Route('/mail/{id}/cloture', methods: ['GET'])]
public function mail_cloture(EmailSender $emailSender, Request $request, Parution $parution): Response
{
try {
if(!$parution->isClosed()) {
throw new \Exception("Parution ".$parution." NOT closed");
}
$emailSender->sendEmailCloture($parution);
$this->addFlash('success', 'mail sent');
} catch(\Exception $ex) {
$this->addFlash('danger', $ex->getMessage());
}
return $this->redirectToRoute('app_alis_parution_show_id', ['id'=>$parution->getId()]);
}
#[Route('/parchapitre/{id}/', methods: ['GET'])]
public function parchapitre(Request $request, Parution $parution, TypeChapitreRepository $typeChapitreRepo, TypeRepository $typeRepo, AnnonceRepository $annonceRepo, PdfService $pdfService): Response
{
/*$chapitres = $typeChapitreRepo->findAll();
$types = $typeRepo->findAll();
$annonces = [];
foreach ($chapitres as $chapitre)
{
$annonces[] = [
'chapitre' => $chapitre,
'annonces' => $annonceRepo->findByType($parution, $chapitre)
];
}*/
$annonces = [];
$annonces_all = $annonceRepo->getAnnoncesOrdered($parution, true);
foreach($annonces_all as $annonce) {
$chapitre = $annonce->getType() ? $annonce->getType()->getTypeChapitre() : null;
if($chapitre) {
$idChapitre = $chapitre->getId();
if(!array_key_exists($idChapitre, $annonces)) {
$annonces[$idChapitre] = [
'chapitre' => $chapitre,
'annonces' => []
];
}
$currentAnnonces = $annonces[$idChapitre]['annonces'];
array_push($currentAnnonces, $annonce);
$annonces[$idChapitre] = [
'chapitre' => $chapitre,
'annonces' => $currentAnnonces
];
}
}
$pdf = $pdfService->getPdfParchapitre($parution, $annonces);
return new Response($pdf, 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'filename="parchapitre.pdf"',
]);
}
#[Route('/previsualisation-montage/{dep}/{num}', methods: ['GET','POST'])]
public function montagePreview(ParutionRepository $parutionRepo, $dep, $num, MontageService $ms): Response
{
$parution = $this->parRepo->findOneByDepNum($dep, $num);
if(!$parution) {
throw new \Exception("NOT found parution ".$dep." ".$num);
}
$html = $ms->getMontageParutionHtml($parution);
return new Response($html);
}
#[Route('/previsualisation-montage-web/{dep}/{date1}/{date2}', methods: ['GET','POST'])]
public function montagePreviewWeb(Request $request, $dep, $date1, $date2, MontageService $ms, PdfService $pdfService, GreffeDematRepository $gdRepo): Response
{
$greffes = $gdRepo->findAllActive();
$min = 4; //param per non creare nuovo oneCol se annunci nel capito < min
if($request->get('min')) {
$min = $request->get('min');
}
$xtag = false;
if($request->get('xtag')) {
$xtag = $request->get('xtag') == "1";
}
$html = $ms->getMontageParutionWebHtml($dep, $date1, $date2, $greffes, $min, $xtag);
if($xtag) {
return $this->xtagResponse($html);
}
/*$filename = 'test.pdf';
$pdf = $pdfService->getPdfByHtml($filename, $html);
return new Response($pdf, 200, array(
'Content-Disposition' => 'filename="'.$filename.'"',
'Content-Type' => 'application/pdf'
));*/
return new Response($html);
}
}