Merge branch 'modules/rel_mod_pdfDocumentsFull' of git.d3data.de:Customers/elektroversand-schmidt.de into modules/rel_mod_pdfDocumentsFull
This commit is contained in:
commit
5135e63a6b
@ -17,18 +17,24 @@
|
|||||||
|
|
||||||
namespace D3\PdfDocuments\Application\Model\AbstractClasses;
|
namespace D3\PdfDocuments\Application\Model\AbstractClasses;
|
||||||
|
|
||||||
use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException;
|
|
||||||
use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract;
|
use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract;
|
||||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface;
|
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface;
|
||||||
use OxidEsales\Eshop\Core\Base;
|
use OxidEsales\Eshop\Core\Base;
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
use OxidEsales\Eshop\Core\UtilsView;
|
use OxidEsales\Eshop\Core\UtilsView;
|
||||||
use Smarty;
|
use Smarty;
|
||||||
|
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||||
use Spipu\Html2Pdf\Html2Pdf;
|
use Spipu\Html2Pdf\Html2Pdf;
|
||||||
|
|
||||||
abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
||||||
{
|
{
|
||||||
const PDF_DOWNLOAD = 'I';
|
const PDF_DESTINATION_DOWNLOAD = 'D'; // force download in browser
|
||||||
|
const PDF_DESTINATION_STDOUT = 'I'; // show in browser plugin if available, otherwise download
|
||||||
|
const PDF_DESTINATION_FILE = 'F'; // save as local file
|
||||||
|
const PDF_DESTINATION_STRING = 'S'; // output as string
|
||||||
|
|
||||||
|
const PDF_ORIENTATION_PORTRAIT = 'P';
|
||||||
|
const PDF_ORIENTATION_LANDSCAPE = 'L';
|
||||||
|
|
||||||
/** @var Smarty */
|
/** @var Smarty */
|
||||||
public $oSmarty;
|
public $oSmarty;
|
||||||
@ -48,9 +54,9 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
* @param $sFilename
|
* @param $sFilename
|
||||||
* @param int $iSelLang
|
* @param int $iSelLang
|
||||||
* @param string $target
|
* @param string $target
|
||||||
* @throws noBaseObjectSetException
|
* @throws Html2PdfException
|
||||||
*/
|
*/
|
||||||
public function genPdf($sFilename, $iSelLang = 0, $target = 'I')
|
public function genPdf($sFilename, $iSelLang = 0, $target = self::PDF_DESTINATION_STDOUT)
|
||||||
{
|
{
|
||||||
$sFilename = $this->getFilename();
|
$sFilename = $this->getFilename();
|
||||||
$oPdf = oxNew(Html2Pdf::class, ...$this->getPdfProperties());
|
$oPdf = oxNew(Html2Pdf::class, ...$this->getPdfProperties());
|
||||||
@ -58,21 +64,15 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
$oPdf->output($sFilename, $target);
|
$oPdf->output($sFilename, $target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $iLanguage
|
||||||
|
*/
|
||||||
public function downloadPdf($iLanguage = 0)
|
public function downloadPdf($iLanguage = 0)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$oUtils = Registry::getUtils();
|
$sFilename = $this->getFilename();
|
||||||
$sFilename = $this->makeValidFileName($this->getFilename());
|
$this->genPdf($sFilename, $iLanguage, self::PDF_DESTINATION_DOWNLOAD);
|
||||||
ob_start();
|
Registry::getUtils()->showMessageAndExit('');
|
||||||
$this->genPdf($sFilename, $iLanguage, self::PDF_DOWNLOAD);
|
|
||||||
$sPDF = ob_get_contents();
|
|
||||||
ob_end_clean();
|
|
||||||
$oUtils->setHeader("Pragma: public");
|
|
||||||
$oUtils->setHeader("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
|
||||||
$oUtils->setHeader("Expires: 0");
|
|
||||||
$oUtils->setHeader("Content-type: application/pdf");
|
|
||||||
$oUtils->setHeader("Content-Disposition: attachment; filename=" . $sFilename);
|
|
||||||
Registry::getUtils()->showMessageAndExit($sPDF);
|
|
||||||
} 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);
|
||||||
@ -123,7 +123,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
*/
|
*/
|
||||||
public function getPdfProperties()
|
public function getPdfProperties()
|
||||||
{
|
{
|
||||||
return ['P', 'A4', 'de'];
|
return [self::PDF_ORIENTATION_PORTRAIT, 'A4', 'de'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +80,9 @@ class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceIn
|
|||||||
public function setInvoiceDate()
|
public function setInvoiceDate()
|
||||||
{
|
{
|
||||||
if ($this->getOrder()->getFieldData('oxbilldate') == '0000-00-00') {
|
if ($this->getOrder()->getFieldData('oxbilldate') == '0000-00-00') {
|
||||||
$this->getOrder()->assign([date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')))]);
|
$this->getOrder()->assign([
|
||||||
|
"oxbilldate" => date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')))
|
||||||
|
]);
|
||||||
|
|
||||||
$this->blIsNewOrder = true;
|
$this->blIsNewOrder = true;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
|
|||||||
/** @var d3_Order_PdfDocuments $oOrder */
|
/** @var d3_Order_PdfDocuments $oOrder */
|
||||||
$oOrder = oxNew(Order::class);
|
$oOrder = oxNew(Order::class);
|
||||||
if ($oOrder->load($soxId)) {
|
if ($oOrder->load($soxId)) {
|
||||||
self::$_blIsAdmin = 0;
|
|
||||||
$generator = oxNew( orderOverviewPdfGenerator::class );
|
$generator = oxNew( orderOverviewPdfGenerator::class );
|
||||||
$generator->generatePdf($oOrder, Registry::getRequest()->getRequestEscapedParameter("pdflanguage"));
|
$generator->generatePdf($oOrder, Registry::getRequest()->getRequestEscapedParameter("pdflanguage"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user