Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
899 B
4
Indexable
Never
    /**
     * Save the PDF to the temporary directory to zip later
     * @param  object $object    the data object, e.q. invoice, estimate
     * @param  mixed $pdf       the actual PDF
     * @param  string file name for thee PDF file
     * @return null
     */
    private function save_to_dir($object, $pdf, $file_name)
    {
        $dir = $this->dir . '/';
        if ($this->in_folder) {
            $dir .= $this->in_folder . '/';
        }
        $dateColumn = str_replace('`', '', $this->get_date_column());

        if (strpos($dateColumn, '.') !== false) {
            $dateColumn = strafter($dateColumn, '.');
        }
        if (!empty($object->{$dateColumn})) {
            $dir .= date('Y', strtotime($object->{$dateColumn})) . '/';
        }

        $dir .= $file_name;

        $this->pdf_zip = $pdf;
        $this->pdf_zip->Output($dir, 'F');
    }