diff --git a/source/modules/d3/pdfdocuments/src/Modules/Application/Model/d3_Order_PdfDocuments.php b/source/modules/d3/pdfdocuments/src/Modules/Application/Model/d3_Order_PdfDocuments.php index 643937e..aee3e9c 100644 --- a/source/modules/d3/pdfdocuments/src/Modules/Application/Model/d3_Order_PdfDocuments.php +++ b/source/modules/d3/pdfdocuments/src/Modules/Application/Model/d3_Order_PdfDocuments.php @@ -35,7 +35,6 @@ class d3_Order_PdfDocuments extends d3_Order_PdfDocuments_parent public function genPdf($sFilename, $iSelLang = 0, $target = 'I') { $Pdf= $this->getPdfClass(); - die(); $Pdf->setOrder($this); $Pdf->genPdf($sFilename, $iSelLang = 0, $target = 'I'); @@ -44,12 +43,15 @@ class d3_Order_PdfDocuments extends d3_Order_PdfDocuments_parent switch (Registry::getRequest()->getRequestParameter('pdftype')) { case ('dnote'): case ('dnote_without_logo'): - return oxNew(deliverynotePdf::class); + $pdfInstance= oxNew(deliverynotePdf::class); + $pdfInstance->setOrder($this); + return $pdfInstance; case ('standart'): case('standart_without_logo'): - return oxNew(invoicePdf::class); + $pdfInvoice= oxNew(invoicePdf::class); + $pdfInvoice->setOrder($this); + return $pdfInvoice; default: - dumpVar(get_class($this)); return $this->getCustomPdfClass(); } } @@ -61,6 +63,8 @@ class d3_Order_PdfDocuments extends d3_Order_PdfDocuments_parent */ public function getCustomPdfClass() { - return oxNew(invoicePdf::class); + $pdfInvoice= oxNew(invoicePdf::class); + $pdfInvoice->setOrder($this); + return $pdfInvoice; } } diff --git a/source/modules/d3/pdfdocuments/src/Modules/Application/Model/pdfDocuments.php b/source/modules/d3/pdfdocuments/src/Modules/Application/Model/pdfDocuments.php index e053c21..091d33e 100644 --- a/source/modules/d3/pdfdocuments/src/Modules/Application/Model/pdfDocuments.php +++ b/source/modules/d3/pdfdocuments/src/Modules/Application/Model/pdfDocuments.php @@ -2,18 +2,23 @@ namespace D3\PdfDocuments\Modules\Application\Model; use \OxidEsales\Eshop\Application\Model\Order; +use OxidEsales\Eshop\Application\Model\Payment; +use OxidEsales\Eshop\Application\Model\User; +use OxidEsales\Eshop\Core\Base; +use OxidEsales\Eshop\Core\Registry; +use Spipu\Html2Pdf\Html2Pdf; abstract class pdfDocuments implements albatros { + public $oOrder; + protected $blIsNewOrder; public function genPdf($sFilename, $iSelLang = 0, $target = 'I') { - self::$_blIsAdmin = 0; - $oSmarty = Registry::getUtilsView()->getSmarty(); $oSmarty->assign('oConfig', Registry::getSession()->getConfig()); $oSmarty->assign('oViewConf', Registry::getSession()->getConfig()->getActiveView()->getViewConfig()); - $oSmarty->assign('order', $this); + $oSmarty->assign('order', $this->getOrder()); $oSmarty->assign('shop', Registry::getSession()->getConfig()->getActiveShop()); $oSmarty->assign('lang', Registry::getLang()); @@ -29,14 +34,8 @@ abstract class pdfDocuments implements albatros $this->setInvoiceDate(); $this->saveOrderOnChanges(); - switch (Registry::getRequest()->getRequestParameter('pdftype')) { - case ('dnote'): - case ('dnote_without_logo'): - $sContent = $oSmarty->fetch($this->getTemplate()); - break; - default: - $sContent = $oSmarty->fetch($this->getTemplate()); - } + $sContent = $oSmarty->fetch($this->getTemplate()); + $this->setFilename($sContent, $target, $sFilename); } /** @@ -48,7 +47,7 @@ abstract class pdfDocuments implements albatros } /** - * @return OrderModel + * @return Order */ public function getOrder() { diff --git a/source/modules/d3/pdfdocuments/src/Modules/Application/controllers/d3_overview_controller_pdfdocuments.php b/source/modules/d3/pdfdocuments/src/Modules/Application/controllers/d3_overview_controller_pdfdocuments.php index b0d13df..f54a45e 100644 --- a/source/modules/d3/pdfdocuments/src/Modules/Application/controllers/d3_overview_controller_pdfdocuments.php +++ b/source/modules/d3/pdfdocuments/src/Modules/Application/controllers/d3_overview_controller_pdfdocuments.php @@ -1,15 +1,20 @@ getEditObjectId(); - $viewNameGenerator = \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Core\TableViewNameGenerator::class); + $viewNameGenerator = Registry::get(TableViewNameGenerator::class); $sTable = $viewNameGenerator->getViewName("oxorderarticles"); $sQ = "select count(oxid) from {$sTable} where oxorderid = " . $masterDb->quote($sOrderId) . " and oxstorno = 0"; @@ -20,22 +25,18 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu public function createPDF() { - echo __LINE__; $soxId = $this->getEditObjectId(); if ($soxId != "-1" && isset($soxId)) { - echo __LINE__; // load object - $oOrder = oxNew(\OxidEsales\Eshop\Application\Model\Order::class); + $oOrder = oxNew(Order::class); if ($oOrder->load($soxId)) { - echo __LINE__; - $oUtils = \OxidEsales\Eshop\Core\Registry::getUtils(); + self::$_blIsAdmin = 0; + $oUtils = Registry::getUtils(); $sTrimmedBillName = trim($oOrder->oxorder__oxbilllname->getRawValue()); $sFilename = $oOrder->oxorder__oxordernr->value . "_" . $sTrimmedBillName . ".pdf"; $sFilename = $this->makeValidFileName($sFilename); - //ob_start(); - echo __LINE__; - $oOrder->genPDF($sFilename, \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("pdflanguage")); - die(); + ob_start(); + $oOrder->genPDF($sFilename, Registry::getConfig()->getRequestParameter("pdflanguage")); $sPDF = ob_get_contents(); ob_end_clean(); $oUtils->setHeader("Pragma: public"); @@ -43,7 +44,7 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu $oUtils->setHeader("Expires: 0"); $oUtils->setHeader("Content-type: application/pdf"); $oUtils->setHeader("Content-Disposition: attachment; filename=" . $sFilename); - \OxidEsales\Eshop\Core\Registry::getUtils()->showMessageAndExit($sPDF); + Registry::getUtils()->showMessageAndExit($sPDF); } } }