75 lines
2.1 KiB
PHP
75 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace KupShop\ReclamationsBundle\Attachment;
|
|
|
|
use KupShop\KupShopBundle\Email\EmailGroupTypeEnum;
|
|
use KupShop\KupShopBundle\Util\Pdf\HTMLToPDF;
|
|
use KupShop\OrderingBundle\Attachment\BaseAttachment;
|
|
use KupShop\OrderingBundle\Util\Invoice\PdfGenerator;
|
|
use KupShop\ReclamationsBundle\Entity\ReclamationEntity;
|
|
use KupShop\ReclamationsBundle\Util\ReclamationsUtil;
|
|
|
|
class ReclamationPDFAttachment extends BaseAttachment
|
|
{
|
|
protected static $name = 'Reklamace';
|
|
protected static $type = 'reclamation';
|
|
protected static $group = EmailGroupTypeEnum::RECLAMATION;
|
|
|
|
protected $filename = 'Reklamace_{KOD}.pdf';
|
|
protected $template = 'reclamations/pdf/reclamationPDF.tpl';
|
|
|
|
/** @var ReclamationEntity */
|
|
protected $reclamation;
|
|
|
|
private $pdfGenerator;
|
|
private $reclamationsUtil;
|
|
|
|
public function __construct(PdfGenerator $pdfGenerator, ReclamationsUtil $reclamationsUtil)
|
|
{
|
|
$this->pdfGenerator = $pdfGenerator;
|
|
$this->reclamationsUtil = $reclamationsUtil;
|
|
}
|
|
|
|
public static function isAllowed()
|
|
{
|
|
// aby se nezobrazovala v prilohach k emailum
|
|
return true;
|
|
}
|
|
|
|
public function getFilename(): string
|
|
{
|
|
return $this->reclamationsUtil->replacePlaceholders(translate_shop('reclamation_filename', 'attachments'), ['KOD' => $this->reclamation->getCode()]);
|
|
}
|
|
|
|
public function setReclamation(ReclamationEntity $reclamation)
|
|
{
|
|
$this->reclamation = $reclamation;
|
|
}
|
|
|
|
public function getReclamation(): ReclamationEntity
|
|
{
|
|
return $this->reclamation;
|
|
}
|
|
|
|
public function getContent()
|
|
{
|
|
$order = null;
|
|
if ($this->reclamation->getIdOrder()) {
|
|
$order = new \Order();
|
|
$order->createFromDB($this->reclamation->getIdOrder());
|
|
}
|
|
|
|
$smarty = createSmarty(false, true);
|
|
$smarty->assign([
|
|
'reclamation' => $this->reclamation,
|
|
'order' => $order,
|
|
]);
|
|
|
|
$content = $smarty->fetch($this->template);
|
|
|
|
$html2pdf = new HTMLToPDF();
|
|
|
|
return $html2pdf->generatePDF($content, null, true);
|
|
}
|
|
}
|