adjusting: modifying files

This commit is contained in:
MaxBUhe 2020-05-20 11:51:48 +02:00 committed by Daniel Seifert
parent 2389109fdb
commit 1cf4a612e9
3 changed files with 33 additions and 29 deletions

View File

@ -35,7 +35,6 @@ class d3_Order_PdfDocuments extends d3_Order_PdfDocuments_parent
public function genPdf($sFilename, $iSelLang = 0, $target = 'I') public function genPdf($sFilename, $iSelLang = 0, $target = 'I')
{ {
$Pdf= $this->getPdfClass(); $Pdf= $this->getPdfClass();
die();
$Pdf->setOrder($this); $Pdf->setOrder($this);
$Pdf->genPdf($sFilename, $iSelLang = 0, $target = 'I'); $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')) { switch (Registry::getRequest()->getRequestParameter('pdftype')) {
case ('dnote'): case ('dnote'):
case ('dnote_without_logo'): case ('dnote_without_logo'):
return oxNew(deliverynotePdf::class); $pdfInstance= oxNew(deliverynotePdf::class);
$pdfInstance->setOrder($this);
return $pdfInstance;
case ('standart'): case ('standart'):
case('standart_without_logo'): case('standart_without_logo'):
return oxNew(invoicePdf::class); $pdfInvoice= oxNew(invoicePdf::class);
$pdfInvoice->setOrder($this);
return $pdfInvoice;
default: default:
dumpVar(get_class($this));
return $this->getCustomPdfClass(); return $this->getCustomPdfClass();
} }
} }
@ -61,6 +63,8 @@ class d3_Order_PdfDocuments extends d3_Order_PdfDocuments_parent
*/ */
public function getCustomPdfClass() public function getCustomPdfClass()
{ {
return oxNew(invoicePdf::class); $pdfInvoice= oxNew(invoicePdf::class);
$pdfInvoice->setOrder($this);
return $pdfInvoice;
} }
} }

View File

@ -2,18 +2,23 @@
namespace D3\PdfDocuments\Modules\Application\Model; namespace D3\PdfDocuments\Modules\Application\Model;
use \OxidEsales\Eshop\Application\Model\Order; 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 abstract class pdfDocuments implements albatros
{ {
public $oOrder;
protected $blIsNewOrder;
public function genPdf($sFilename, $iSelLang = 0, $target = 'I') public function genPdf($sFilename, $iSelLang = 0, $target = 'I')
{ {
self::$_blIsAdmin = 0;
$oSmarty = Registry::getUtilsView()->getSmarty(); $oSmarty = Registry::getUtilsView()->getSmarty();
$oSmarty->assign('oConfig', Registry::getSession()->getConfig()); $oSmarty->assign('oConfig', Registry::getSession()->getConfig());
$oSmarty->assign('oViewConf', Registry::getSession()->getConfig()->getActiveView()->getViewConfig()); $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('shop', Registry::getSession()->getConfig()->getActiveShop());
$oSmarty->assign('lang', Registry::getLang()); $oSmarty->assign('lang', Registry::getLang());
@ -29,14 +34,8 @@ abstract class pdfDocuments implements albatros
$this->setInvoiceDate(); $this->setInvoiceDate();
$this->saveOrderOnChanges(); $this->saveOrderOnChanges();
switch (Registry::getRequest()->getRequestParameter('pdftype')) {
case ('dnote'):
case ('dnote_without_logo'):
$sContent = $oSmarty->fetch($this->getTemplate()); $sContent = $oSmarty->fetch($this->getTemplate());
break; $this->setFilename($sContent, $target, $sFilename);
default:
$sContent = $oSmarty->fetch($this->getTemplate());
}
} }
/** /**
@ -48,7 +47,7 @@ abstract class pdfDocuments implements albatros
} }
/** /**
* @return OrderModel * @return Order
*/ */
public function getOrder() public function getOrder()
{ {

View File

@ -1,15 +1,20 @@
<?php <?php
namespace D3\PdfDocuments\Modules\Application\controllers; namespace D3\PdfDocuments\Modules\Application\controllers;
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\TableViewNameGenerator;
class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent
{ {
public function canExport() public function canExport()
{ {
// We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804). // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
$masterDb = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(); $masterDb = DatabaseProvider::getMaster();
$sOrderId = $this->getEditObjectId(); $sOrderId = $this->getEditObjectId();
$viewNameGenerator = \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Core\TableViewNameGenerator::class); $viewNameGenerator = Registry::get(TableViewNameGenerator::class);
$sTable = $viewNameGenerator->getViewName("oxorderarticles"); $sTable = $viewNameGenerator->getViewName("oxorderarticles");
$sQ = "select count(oxid) from {$sTable} where oxorderid = " . $masterDb->quote($sOrderId) . " and oxstorno = 0"; $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() public function createPDF()
{ {
echo __LINE__;
$soxId = $this->getEditObjectId(); $soxId = $this->getEditObjectId();
if ($soxId != "-1" && isset($soxId)) { if ($soxId != "-1" && isset($soxId)) {
echo __LINE__;
// load object // load object
$oOrder = oxNew(\OxidEsales\Eshop\Application\Model\Order::class); $oOrder = oxNew(Order::class);
if ($oOrder->load($soxId)) { if ($oOrder->load($soxId)) {
echo __LINE__; self::$_blIsAdmin = 0;
$oUtils = \OxidEsales\Eshop\Core\Registry::getUtils(); $oUtils = Registry::getUtils();
$sTrimmedBillName = trim($oOrder->oxorder__oxbilllname->getRawValue()); $sTrimmedBillName = trim($oOrder->oxorder__oxbilllname->getRawValue());
$sFilename = $oOrder->oxorder__oxordernr->value . "_" . $sTrimmedBillName . ".pdf"; $sFilename = $oOrder->oxorder__oxordernr->value . "_" . $sTrimmedBillName . ".pdf";
$sFilename = $this->makeValidFileName($sFilename); $sFilename = $this->makeValidFileName($sFilename);
//ob_start(); ob_start();
echo __LINE__; $oOrder->genPDF($sFilename, Registry::getConfig()->getRequestParameter("pdflanguage"));
$oOrder->genPDF($sFilename, \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("pdflanguage"));
die();
$sPDF = ob_get_contents(); $sPDF = ob_get_contents();
ob_end_clean(); ob_end_clean();
$oUtils->setHeader("Pragma: public"); $oUtils->setHeader("Pragma: public");
@ -43,7 +44,7 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
$oUtils->setHeader("Expires: 0"); $oUtils->setHeader("Expires: 0");
$oUtils->setHeader("Content-type: application/pdf"); $oUtils->setHeader("Content-type: application/pdf");
$oUtils->setHeader("Content-Disposition: attachment; filename=" . $sFilename); $oUtils->setHeader("Content-Disposition: attachment; filename=" . $sFilename);
\OxidEsales\Eshop\Core\Registry::getUtils()->showMessageAndExit($sPDF); Registry::getUtils()->showMessageAndExit($sPDF);
} }
} }
} }