Prestashop saving invoices manually and automatically

风流意气都作罢 提交于 2020-01-05 04:21:10

问题


My invoices are saving to my server automatically when I press "view invoice" button from admin panel. The automatic saving works, but when I try to save invoice manually.. It will save it and when I open it.. I will have an blank(white) pdf page.

I'm using two overrides to accomplysh automatic save

PDF.php

class PDF extends PDFCore
{
    public function render($display = true)
    {
        if($this->template == PDF::TEMPLATE_INVOICE)
            parent::render('F', true);

        return parent::render($display);
    }
}

PDFGenerator.php

class PDFGenerator extends PDFGeneratorCore
{
    public function render($filename, $display = true)
    {
        if (empty($filename)) {
            throw new PrestaShopException('Missing filename.');
        }

        $this->lastPage();

        if ($display === true) {
            $output = 'D';
        } elseif ($display === false) {
            $output = 'S';
        } elseif ($display == 'D') {
            $output = 'D';
        } elseif ($display == 'S') {
            $output = 'S';
        } elseif ($display == 'F') {
            $output = 'F';
            $filename = '/home/repoadmin/Dropbox/print_it/'.str_replace("#", "", $filename);
        } else {
            $output = 'I';
        }

        return $this->output($filename, $output);
    }
}

I tried to use two render like this:

class PDF extends PDFCore
{
    public function render($display = true)
    {
        if($this->template == PDF::TEMPLATE_INVOICE)
            parent::render('F', true);
            parent::render('I', true);
        return parent::render($display);
    }
}

But of course it wont work, because I'm returning only one render

Soo.. my question is how can I make it save manually and automatically?

来源:https://stackoverflow.com/questions/43544165/prestashop-saving-invoices-manually-and-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!