diff --git a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php index 636bd4f..0551997 100644 --- a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php +++ b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php @@ -50,6 +50,14 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface $this->oSmarty = Registry::getUtilsView()->getSmarty(); } + public function runPreAction() + { + } + + public function runPostAction() + { + } + /** * @param $sFilename * @param int $iSelLang @@ -77,8 +85,10 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface public function downloadPdf($iLanguage = 0) { try { + $this->runPreAction(); $sFilename = $this->getFilename(); $this->genPdf($sFilename, $iLanguage, self::PDF_DESTINATION_DOWNLOAD); + $this->runPostAction(); Registry::getUtils()->showMessageAndExit(''); } catch (pdfGeneratorExceptionAbstract $e) { Registry::get(UtilsView::class)->addErrorToDisplay($e); @@ -95,12 +105,14 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface public function savePdfFile($path, $iLanguage = 0) { try { + $this->runPreAction(); $sFilename = $this->getFilename(); $this->genPdf( rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$sFilename, $iLanguage, self::PDF_DESTINATION_FILE ); + $this->runPostAction(); } catch (pdfGeneratorExceptionAbstract $e) { Registry::get(UtilsView::class)->addErrorToDisplay($e); Registry::getLogger()->error($e); @@ -116,8 +128,11 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface public function getPdfContent($iLanguage = 0) { try { + $this->runPreAction(); $sFilename = $this->getFilename(); - return $this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STRING ); + $ret = $this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STRING ); + $this->runPostAction(); + return $ret; } catch (pdfGeneratorExceptionAbstract $e) { Registry::get(UtilsView::class)->addErrorToDisplay($e); Registry::getLogger()->error($e); diff --git a/Application/Model/Documents/invoicePdf.php b/Application/Model/Documents/invoicePdf.php index c1b2ade..6c49fdf 100644 --- a/Application/Model/Documents/invoicePdf.php +++ b/Application/Model/Documents/invoicePdf.php @@ -43,22 +43,13 @@ class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceIn return 'invoice'; } - /** - * @param $sFilename - * @param int $iSelLang - * @param string $target - * - * @return mixed|string|void - * @throws Html2PdfException - * @throws noBaseObjectSetException - */ - public function genPdf( $sFilename, $iSelLang = 0, $target = 'I' ) + public function runPreAction() { + parent::runPreAction(); + $this->setInvoiceNumber(); $this->setInvoiceDate(); $this->saveOrderOnChanges(); - - return parent::genPdf( $sFilename, $iSelLang, $target ); } public function setInvoiceNumber()