add preAction and postAction calls to prevent wrong filenames because unset values
This commit is contained in:
parent
fc51664700
commit
de22f5dd71
@ -50,6 +50,14 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
$this->oSmarty = Registry::getUtilsView()->getSmarty();
|
$this->oSmarty = Registry::getUtilsView()->getSmarty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function runPreAction()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function runPostAction()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $sFilename
|
* @param $sFilename
|
||||||
* @param int $iSelLang
|
* @param int $iSelLang
|
||||||
@ -77,8 +85,10 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
public function downloadPdf($iLanguage = 0)
|
public function downloadPdf($iLanguage = 0)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$this->runPreAction();
|
||||||
$sFilename = $this->getFilename();
|
$sFilename = $this->getFilename();
|
||||||
$this->genPdf($sFilename, $iLanguage, self::PDF_DESTINATION_DOWNLOAD);
|
$this->genPdf($sFilename, $iLanguage, self::PDF_DESTINATION_DOWNLOAD);
|
||||||
|
$this->runPostAction();
|
||||||
Registry::getUtils()->showMessageAndExit('');
|
Registry::getUtils()->showMessageAndExit('');
|
||||||
} catch (pdfGeneratorExceptionAbstract $e) {
|
} catch (pdfGeneratorExceptionAbstract $e) {
|
||||||
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
||||||
@ -95,12 +105,14 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
public function savePdfFile($path, $iLanguage = 0)
|
public function savePdfFile($path, $iLanguage = 0)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$this->runPreAction();
|
||||||
$sFilename = $this->getFilename();
|
$sFilename = $this->getFilename();
|
||||||
$this->genPdf(
|
$this->genPdf(
|
||||||
rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$sFilename,
|
rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$sFilename,
|
||||||
$iLanguage,
|
$iLanguage,
|
||||||
self::PDF_DESTINATION_FILE
|
self::PDF_DESTINATION_FILE
|
||||||
);
|
);
|
||||||
|
$this->runPostAction();
|
||||||
} catch (pdfGeneratorExceptionAbstract $e) {
|
} catch (pdfGeneratorExceptionAbstract $e) {
|
||||||
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
||||||
Registry::getLogger()->error($e);
|
Registry::getLogger()->error($e);
|
||||||
@ -116,8 +128,11 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
public function getPdfContent($iLanguage = 0)
|
public function getPdfContent($iLanguage = 0)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$this->runPreAction();
|
||||||
$sFilename = $this->getFilename();
|
$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) {
|
} catch (pdfGeneratorExceptionAbstract $e) {
|
||||||
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
Registry::get(UtilsView::class)->addErrorToDisplay($e);
|
||||||
Registry::getLogger()->error($e);
|
Registry::getLogger()->error($e);
|
||||||
|
@ -43,22 +43,13 @@ class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceIn
|
|||||||
return 'invoice';
|
return 'invoice';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function runPreAction()
|
||||||
* @param $sFilename
|
|
||||||
* @param int $iSelLang
|
|
||||||
* @param string $target
|
|
||||||
*
|
|
||||||
* @return mixed|string|void
|
|
||||||
* @throws Html2PdfException
|
|
||||||
* @throws noBaseObjectSetException
|
|
||||||
*/
|
|
||||||
public function genPdf( $sFilename, $iSelLang = 0, $target = 'I' )
|
|
||||||
{
|
{
|
||||||
|
parent::runPreAction();
|
||||||
|
|
||||||
$this->setInvoiceNumber();
|
$this->setInvoiceNumber();
|
||||||
$this->setInvoiceDate();
|
$this->setInvoiceDate();
|
||||||
$this->saveOrderOnChanges();
|
$this->saveOrderOnChanges();
|
||||||
|
|
||||||
return parent::genPdf( $sFilename, $iSelLang, $target );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setInvoiceNumber()
|
public function setInvoiceNumber()
|
||||||
|
Loading…
Reference in New Issue
Block a user