Prestashop saving invoices manually and automatica

2019-08-03 09:30发布

问题:

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?