<?php

namespace KupShop\OrderingBundle\Attachment;

use KupShop\KupShopBundle\Email\EmailGroupTypeEnum;
use KupShop\OrderingBundle\Util\Invoice\PdfGenerator;

class SummaryPDFAttachment extends BaseAttachment
{
    protected static $name = 'Rekapitulace objednávky';
    protected static $type = 'order_summary';
    protected static $group = EmailGroupTypeEnum::ORDER;
    protected static $priority = 480;

    protected $filename = 'Rekapitulace_{KOD}.pdf';
    protected $template = 'summaryPDF';

    private $pdfGenerator;

    public function __construct(PdfGenerator $pdfGenerator)
    {
        $this->pdfGenerator = $pdfGenerator;
    }

    public function getFilename(): string
    {
        return $this->order->replacePlaceholders(translate_shop('summary_filename', 'attachments'));
    }

    public function getContent()
    {
        return $this->pdfGenerator->setTemplate($this->getTemplate())->getInvoicePDFContent($this->order->id);
    }
}
