Compare commits

...

10 Commits

21 changed files with 167 additions and 133 deletions

View File

@ -11,6 +11,7 @@
namespace D3\PdfDocuments\Application\Controller; namespace D3\PdfDocuments\Application\Controller;
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException; use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface;
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview; use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Application\Model\Order;
@ -22,8 +23,9 @@ class orderOverviewPdfGenerator
* @param Order $order * @param Order $order
* @param int $iSelLang * @param int $iSelLang
* @throws noPdfHandlerFoundException * @throws noPdfHandlerFoundException
* @throws wrongPdfGeneratorInterface
*/ */
public function generatePdf(Order $order, $iSelLang = 0) public function generatePdf(Order $order, int $iSelLang = 0)
{ {
$Pdf= $this->getPdfClass(); $Pdf= $this->getPdfClass();
@ -34,6 +36,7 @@ class orderOverviewPdfGenerator
/** /**
* @return pdfdocumentsOrderInterface * @return pdfdocumentsOrderInterface
* @throws noPdfHandlerFoundException * @throws noPdfHandlerFoundException
* @throws wrongPdfGeneratorInterface
*/ */
public function getPdfClass() public function getPdfClass()
{ {

View File

@ -12,22 +12,18 @@ namespace D3\PdfDocuments\Application\Model\AbstractClasses;
use Assert\InvalidArgumentException; use Assert\InvalidArgumentException;
use D3\PdfDocuments\Application\Model\Constants; use D3\PdfDocuments\Application\Model\Constants;
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\Exception\StandardException; use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\UtilsView; use OxidEsales\Eshop\Core\UtilsView;
use OxidEsales\EshopCommunity\Core\Di\ContainerFacade;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateEngineInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer; use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface; use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateNotInChainException; use OxidEsales\Twig\Resolver\TemplateChain\TemplateNotInChainException;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
use Smarty;
use Spipu\Html2Pdf\Exception\Html2PdfException; use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Html2Pdf; use Spipu\Html2Pdf\Html2Pdf;
use Twig\Error\Error; use Twig\Error\Error;
@ -46,38 +42,9 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
public $filenameExtension = 'pdf'; public $filenameExtension = 'pdf';
/** @var Smarty */
public $oTemplateEngine;
/** @var string */ /** @var string */
public $filename; public $filename;
/**
* pdfDocumentsGeneric constructor.
*/
public function __construct()
{
parent::__construct();
$this->oTemplateEngine = $this->d3GetTemplateEngine();
}
public function d3GetTemplateEngine() :TemplateEngineInterface
{
$renderer = $this->d3GetTemplateRendererBridge()->getTemplateRenderer();
return $renderer->getTemplateEngine();
}
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function d3GetTemplateRendererBridge(): TemplateRendererBridgeInterface
{
return ContainerFactory::getInstance()->getContainer()
->get(TemplateRendererBridgeInterface::class);
}
public function runPreAction() public function runPreAction()
{ {
} }
@ -87,11 +54,14 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
} }
/** /**
* @param $sFilename * @param string $sFilename
* @param int $iSelLang * @param int $iSelLang
* @param string $target * @param string $target
* @return mixed|string|null *
* @return string|null
* @throws ContainerExceptionInterface
* @throws Html2PdfException * @throws Html2PdfException
* @throws NotFoundExceptionInterface
*/ */
public function genPdf($sFilename, $iSelLang = 0, $target = self::PDF_DESTINATION_STDOUT) public function genPdf($sFilename, $iSelLang = 0, $target = self::PDF_DESTINATION_STDOUT)
{ {
@ -99,10 +69,10 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
$oPdf->setTestIsImage(false); $oPdf->setTestIsImage(false);
$htmlContent = $this->getHTMLContent($iSelLang); $htmlContent = $this->getHTMLContent($iSelLang);
$oPdf->writeHTML($htmlContent); $oPdf->writeHTML($htmlContent);
$oPdf->pdf->SetAuthor(Registry::getConfig()->getActiveShop()->getFieldData('oxname')); $oPdf->pdf->setAuthor( Registry::getConfig()->getActiveShop()->getFieldData( 'oxname'));
$oPdf->pdf->SetTitle(Registry::getLang()->translateString($this->getTitleIdent())); $oPdf->pdf->setTitle( Registry::getLang()->translateString( $this->getTitleIdent()));
$oPdf->pdf->SetCreator('DÂł PDF Documents for OXID eShop'); $oPdf->pdf->setCreator( 'DÂł PDF Documents for OXID eShop');
$oPdf->pdf->SetSubject(NULL); $oPdf->pdf->setSubject( NULL);
return $this->output($oPdf, $sFilename, $target, $htmlContent); return $this->output($oPdf, $sFilename, $target, $htmlContent);
} }
@ -110,6 +80,15 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
* @param int $iLanguage * @param int $iLanguage
* @throws Html2PdfException * @throws Html2PdfException
*/ */
/**
* @param $iLanguage
*
* @return void
* @throws ContainerExceptionInterface
* @throws Html2PdfException
* @throws NotFoundExceptionInterface
*/
public function downloadPdf($iLanguage = 0) public function downloadPdf($iLanguage = 0)
{ {
try { try {
@ -118,12 +97,9 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
$this->genPdf($sFilename, $iLanguage, self::PDF_DESTINATION_DOWNLOAD); $this->genPdf($sFilename, $iLanguage, self::PDF_DESTINATION_DOWNLOAD);
$this->runPostAction(); $this->runPostAction();
Registry::getUtils()->showMessageAndExit(''); Registry::getUtils()->showMessageAndExit('');
} catch (pdfGeneratorExceptionAbstract $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e); Registry::getLogger()->error($e);
Registry::get(UtilsView::class)->addErrorToDisplay($e);
} }
} }
@ -131,7 +107,10 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
* @param string $path * @param string $path
* @param int $iLanguage * @param int $iLanguage
* *
* @return void
* @throws ContainerExceptionInterface
* @throws Html2PdfException * @throws Html2PdfException
* @throws NotFoundExceptionInterface
*/ */
public function savePdfFile($path, $iLanguage = 0) public function savePdfFile($path, $iLanguage = 0)
{ {
@ -144,9 +123,6 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
self::PDF_DESTINATION_FILE self::PDF_DESTINATION_FILE
); );
$this->runPostAction(); $this->runPostAction();
} catch (pdfGeneratorExceptionAbstract $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e); Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e); Registry::getLogger()->error($e);
@ -156,8 +132,10 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
/** /**
* @param int $iLanguage * @param int $iLanguage
* *
* @return null|string * @return string|null
* @throws ContainerExceptionInterface
* @throws Html2PdfException * @throws Html2PdfException
* @throws NotFoundExceptionInterface
*/ */
public function getPdfContent($iLanguage = 0) public function getPdfContent($iLanguage = 0)
{ {
@ -167,9 +145,6 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
$ret = $this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STRING ); $ret = $this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STRING );
$this->runPostAction(); $this->runPostAction();
return $ret; return $ret;
} catch (pdfGeneratorExceptionAbstract $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e); Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e); Registry::getLogger()->error($e);
@ -178,18 +153,17 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
return null; return null;
} }
/** public function getTemplateEngineVars(int $iSelLang): array
* @param int $iSelLang
*/
public function setTemplateEngineVars($iSelLang)
{ {
unset($iSelLang); unset($iSelLang);
$this->oTemplateEngine->addGlobal('config', Registry::getConfig()); return [
$this->oTemplateEngine->addGlobal('oViewConf', Registry::getConfig()->getActiveView()->getViewConfig()); 'config' => Registry::getConfig(),
$this->oTemplateEngine->addGlobal('shop', Registry::getConfig()->getActiveShop()); 'oViewConf' => Registry::getConfig()->getActiveView()->getViewConfig(),
$this->oTemplateEngine->addGlobal('lang', Registry::getLang()); 'shop' => Registry::getConfig()->getActiveShop(),
$this->oTemplateEngine->addGlobal('document', $this); 'lang' => Registry::getLang(),
'document' => $this
];
} }
/** /**
@ -198,7 +172,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
* @return mixed * @return mixed
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function getHTMLContent($iSelLang = 0) public function getHTMLContent(int $iSelLang = 0)
{ {
$blCurrentRenderFromAdmin = self::$_blIsAdmin; $blCurrentRenderFromAdmin = self::$_blIsAdmin;
self::$_blIsAdmin = $this->renderTemplateFromAdmin(); self::$_blIsAdmin = $this->renderTemplateFromAdmin();
@ -208,16 +182,16 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
$currTplLang = $lang->getTplLanguage(); $currTplLang = $lang->getTplLanguage();
$lang->setTplLanguage($iSelLang); $lang->setTplLanguage($iSelLang);
$this->setTemplateEngineVars($iSelLang);
try { try {
$content = $this->oTemplateEngine->render($this->getTemplate(), $this->d3GetTemplateEngine()->getGlobals()); $content = $this->getTemplateRenderer()->renderTemplate(
$this->getTemplate(),
$this->getTemplateEngineVars($iSelLang)
);
} catch (Error|TemplateNotInChainException $error) { } catch (Error|TemplateNotInChainException $error) {
//Registry::getLogger()->error(dumpVar(__METHOD__." ".__LINE__), [$error->getFile()]); //Registry::getLogger()->error(dumpVar(__METHOD__." ".__LINE__), [$error->getFile()]);
$error = oxNew(StandardException::class, $error->getMessage()); throw oxNew(StandardException::class, $error->getMessage());
throw $error;
} }
$lang->setTplLanguage($currTplLang); $lang->setTplLanguage($currTplLang);
@ -227,6 +201,13 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
return $content; return $content;
} }
protected function getTemplateRenderer(): TemplateRenderer
{
return ContainerFactory::getInstance()->getContainer()
->get(TemplateRendererBridgeInterface::class)
->getTemplateRenderer();
}
/** /**
* arguments for Html2Pdf class constructor * arguments for Html2Pdf class constructor
* - $orientation = 'P', * - $orientation = 'P',
@ -324,14 +305,12 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
// maximize filename length to 255 bytes // maximize filename length to 255 bytes
$ext = pathinfo($filename, PATHINFO_EXTENSION); $ext = pathinfo($filename, PATHINFO_EXTENSION);
$filename = mb_strcut( return mb_strcut(
pathinfo($filename, PATHINFO_FILENAME), pathinfo($filename, PATHINFO_FILENAME),
0, 0,
255 - ($ext ? strlen($ext) + 1 : 0), 255 - ($ext ? strlen($ext) + 1 : 0),
mb_detect_encoding($filename) mb_detect_encoding($filename)
) . ($ext ? '.' . $ext : ''); ) . ($ext ? '.' . $ext : '');
return $filename;
} }
public function beautifyFilename($filename) public function beautifyFilename($filename)

View File

@ -57,19 +57,22 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
* @param int $iSelLang * @param int $iSelLang
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function setTemplateEngineVars($iSelLang) public function getTemplateEngineVars($iSelLang): array
{ {
parent::setTemplateEngineVars($iSelLang);
$this->oTemplateEngine->addGlobal('order', $this->getOrder());
$oUser = oxNew(User::Class); $oUser = oxNew(User::Class);
$oUser->load($this->getOrder()->getFieldData('oxuserid')); $oUser->load($this->getOrder()->getFieldData('oxuserid'));
$this->oTemplateEngine->addGlobal('user', $oUser);
$oPayment = oxNew(Payment::class); $oPayment = oxNew(Payment::class);
$oPayment->loadInLang($iSelLang, $this->getOrder()->getFieldData('oxpaymenttype')); $oPayment->loadInLang($iSelLang, $this->getOrder()->getFieldData('oxpaymenttype'));
$this->oTemplateEngine->addGlobal('payment', $oPayment);
return array_merge(
parent::getTemplateEngineVars($iSelLang),
[
'order' => $this->getOrder(),
'user' => $oUser,
'payment' => $oPayment
]
);
} }
/** /**
@ -116,7 +119,7 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
} }
/** /**
* @return false|string * @return false|int
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function getPayableUntilDate() public function getPayableUntilDate()

View File

@ -39,7 +39,8 @@ class invoicewithoutlogoPdf extends invoicePdf
/** /**
* @return string * @return string
*/ */
public function getTemplate(){ public function getTemplate()
{
return '@d3PdfDocuments/documents/invoice/invoiceNoLogo'; return '@d3PdfDocuments/documents/invoice/invoiceNoLogo';
} }
} }

View File

@ -35,29 +35,29 @@ interface pdfdocumentsGenericInterface
/** /**
* @param int $iLanguage * @param int $iLanguage
*/ */
public function downloadPdf($iLanguage = 0); public function downloadPdf(int $iLanguage = 0);
/** /**
* @param int $iLanguage * @param int $iLanguage
* *
* @return string|null * @return string|null
*/ */
public function getPdfContent($iLanguage = 0); public function getPdfContent(int $iLanguage = 0);
/** /**
* @param string $path * @param string $path
* @param int $iLanguage * @param int $iLanguage
*/ */
public function savePdfFile($path, $iLanguage = 0); public function savePdfFile(string $path, int $iLanguage = 0);
/** /**
* @param $sFilename * @param string $sFilename
* @param int $iSelLang * @param int $iSelLang
* @param string $target * @param string $target
* *
* @return mixed * @return mixed
*/ */
public function genPdf($sFilename, $iSelLang = 0, $target = 'I'); public function genPdf(string $sFilename, int $iSelLang = 0, string $target = 'I');
/** /**
* @param string $filename * @param string $filename

View File

@ -28,10 +28,12 @@ abstract class registryAbstract implements registryGenericInterface
/** /**
* @param $className * @param $className
*
* @throws wrongPdfGeneratorInterface
*/ */
public function addGenerator($className) public function addGenerator($className)
{ {
if (false == $this->hasGenerator($className)) { if ( ! $this->hasGenerator( $className ) ) {
/** @var pdfdocumentsGenericInterface $generator */ /** @var pdfdocumentsGenericInterface $generator */
$generator = oxNew( $className ); $generator = oxNew( $className );
@ -44,12 +46,13 @@ abstract class registryAbstract implements registryGenericInterface
/** /**
* @param $className * generator fully qualified class name * @param $className * generator fully qualified class name
* @param pdfdocumentsGenericInterface $item * @param pdfdocumentsGenericInterface $item
* @throws wrongPdfGeneratorInterface
*/ */
protected function addItem($className, pdfdocumentsGenericInterface $item) protected function addItem($className, pdfdocumentsGenericInterface $item)
{ {
$requiredInterface = $this->getRequiredGeneratorInterfaceClassName(); $requiredInterface = $this->getRequiredGeneratorInterfaceClassName();
if (false == $item instanceof $requiredInterface) { if ( ! $item instanceof $requiredInterface ) {
throw oxNew(wrongPdfGeneratorInterface::class, $requiredInterface); throw oxNew(wrongPdfGeneratorInterface::class, $requiredInterface);
} }

View File

@ -14,10 +14,14 @@ use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
use D3\PdfDocuments\Application\Model\Documents\deliverynotewithoutlogoPdf; use D3\PdfDocuments\Application\Model\Documents\deliverynotewithoutlogoPdf;
use D3\PdfDocuments\Application\Model\Documents\invoicePdf; use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf; use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf;
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface;
class registryOrdermanagerActions extends registryAbstract implements registryOrdermanagerActionsInterface class registryOrdermanagerActions extends registryAbstract implements registryOrdermanagerActionsInterface
{ {
/**
* @throws wrongPdfGeneratorInterface
*/
public function __construct() public function __construct()
{ {
$this->addGenerator(invoicePdf::class); $this->addGenerator(invoicePdf::class);

View File

@ -14,10 +14,14 @@ use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
use D3\PdfDocuments\Application\Model\Documents\deliverynotewithoutlogoPdf; use D3\PdfDocuments\Application\Model\Documents\deliverynotewithoutlogoPdf;
use D3\PdfDocuments\Application\Model\Documents\invoicePdf; use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf; use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf;
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface;
class registryOrderoverview extends registryAbstract implements registryOrderoverviewInterface class registryOrderoverview extends registryAbstract implements registryOrderoverviewInterface
{ {
/**
* @throws wrongPdfGeneratorInterface
*/
public function __construct() public function __construct()
{ {
$this->addGenerator(invoicePdf::class); $this->addGenerator(invoicePdf::class);

View File

@ -13,38 +13,59 @@ namespace D3\PdfDocuments\Modules\Application\Controller;
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator; use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException; use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract; use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract;
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview; use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview; use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Query\QueryBuilder;
use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\TableViewNameGenerator; use OxidEsales\Eshop\Core\TableViewNameGenerator;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent
{ {
/** /**
* @return bool * @return bool
* @throws DatabaseConnectionException * @throws Exception
*/ */
public function d3CanExport() public function d3CanExport(): bool
{ {
// We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804). try {
$masterDb = DatabaseProvider::getMaster();
$sOrderId = $this->getEditObjectId(); $sOrderId = $this->getEditObjectId();
$viewNameGenerator = Registry::get( 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"; /** @var QueryBuilder $queryBuilder */
return (bool) $masterDb->getOne($sQ); $queryBuilder = ContainerFactory::getInstance()->getContainer()->get( QueryBuilderFactoryInterface::class )->create();
$queryBuilder
->select( 'oxid' )
->from( $sTable )
->where(
$queryBuilder->expr()->and(
$queryBuilder->expr()->eq( 'oxorderid', $queryBuilder->createNamedParameter( $sOrderId ) ),
$queryBuilder->expr()->eq( 'oxstorno', $queryBuilder->createNamedParameter( 0, ParameterType::INTEGER ) )
)
);
return $queryBuilder->execute()->fetchOne();
} catch (NotFoundExceptionInterface|ContainerExceptionInterface|DBALException) {
return false;
}
} }
/** /**
* @throws noPdfHandlerFoundException * @throws noPdfHandlerFoundException
* @throws pdfGeneratorExceptionAbstract * @throws pdfGeneratorExceptionAbstract
*/ */
public function d3CreatePDF() public function d3CreatePDF(): void
{ {
$soxId = $this->getEditObjectId(); $soxId = $this->getEditObjectId();
if ($soxId != "-1" && isset($soxId)) { if ($soxId != "-1" && isset($soxId)) {
@ -59,8 +80,9 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
/** /**
* @return registryOrderoverview * @return registryOrderoverview
* @throws wrongPdfGeneratorInterface
*/ */
public function d3getGeneratorList() public function d3getGeneratorList(): registryOrderoverview
{ {
return oxNew(registryOrderoverview::class); return oxNew(registryOrderoverview::class);
} }

View File

@ -1,3 +1,7 @@
![stability mature](https://img.shields.io/badge/stability-mature-008000.svg)
[![latest tag](https://img.shields.io/packagist/v/d3/pdfdocuments?label=release)](https://packagist.org/packages/d3/pdfdocuments)
![License](https://img.shields.io/packagist/l/d3/pdfdocuments)
[![deutsche Version](https://logos.oxidmodule.com/de2_xs.svg)](README.md) [![deutsche Version](https://logos.oxidmodule.com/de2_xs.svg)](README.md)
[![english version](https://logos.oxidmodule.com/en2_xs.svg)](README.en.md) [![english version](https://logos.oxidmodule.com/en2_xs.svg)](README.en.md)
@ -13,7 +17,7 @@ The module can be easily extended to adapt existing documents or add new ones. E
## System requirements: ## System requirements:
- installed OXID eShop version from 7.0 - 7.1 - installed OXID eShop version 7.x
- PHP version for which installation packages are available (PHP 8) - PHP version for which installation packages are available (PHP 8)
- Installation via Composer - Installation via Composer

View File

@ -1,3 +1,7 @@
![stability mature](https://img.shields.io/badge/stability-mature-008000.svg)
[![latest tag](https://img.shields.io/packagist/v/d3/pdfdocuments?label=release)](https://packagist.org/packages/d3/pdfdocuments)
![License](https://img.shields.io/packagist/l/d3/pdfdocuments)
[![deutsche Version](https://logos.oxidmodule.com/de2_xs.svg)](README.md) [![deutsche Version](https://logos.oxidmodule.com/de2_xs.svg)](README.md)
[![english version](https://logos.oxidmodule.com/en2_xs.svg)](README.en.md) [![english version](https://logos.oxidmodule.com/en2_xs.svg)](README.en.md)
@ -5,7 +9,7 @@
PDF-Dokumentgenerator fĂĽr OXID eShop PDF-Dokumentgenerator fĂĽr OXID eShop
Erstellen Sie unterschiedliche statische oder dynamische PDF-Dokumente auf Kopfdruck. Der Dokumentinhalt wird aus Templates (Smarty bzw. Twig) erstellt. Erstellen Sie unterschiedliche statische oder dynamische PDF-Dokumente auf Knopfdruck. Der Dokumentinhalt wird aus Templates (Smarty bzw. Twig) erstellt.
An den Bestellungen Ihres OXID-Shops steht Ihnen die Erstellung von Rechnung und Lieferschein zur VerfĂĽgung. An den Bestellungen Ihres OXID-Shops steht Ihnen die Erstellung von Rechnung und Lieferschein zur VerfĂĽgung.
@ -13,7 +17,7 @@ Das Modul kann einfach erweitert werden, um bestehende Dokumente anzupassen oder
## Systemanforderungen: ## Systemanforderungen:
- installierter OXID eShop in Version ab 7.0 - 7.1 - installierter OXID eShop in Version 7.x
- PHP-Version, fĂĽr die Installationspakete verfĂĽgbar sind (PHP 8) - PHP-Version, fĂĽr die Installationspakete verfĂĽgbar sind (PHP 8)
- Installation via Composer - Installation via Composer

View File

@ -10,13 +10,15 @@
"PDF", "PDF",
"documents", "documents",
"invoice", "invoice",
"delivery note" "delivery note",
"d3dependencycheck",
"id_d3PdfDocuments"
], ],
"authors": [ "authors": [
{ {
"name": "D3 Data Development (Inh. Thomas Dartsch)", "name": "D3 Data Development (Inh. Thomas Dartsch)",
"email": "info@shopmodule.com", "email": "info@shopmodule.com",
"homepage": "http://www.d3data.de", "homepage": "https://www.d3data.de",
"role": "Owner" "role": "Owner"
} }
], ],
@ -26,7 +28,7 @@
], ],
"require": { "require": {
"php": "^8.0", "php": "^8.0",
"oxid-esales/oxideshop-ce": "7.0 - 7.1", "oxid-esales/oxideshop-ce": "7.0 - 7.2",
"spipu/html2pdf": "~5.2.8", "spipu/html2pdf": "~5.2.8",
"beberlei/assert": "^3.3.2" "beberlei/assert": "^3.3.2"
}, },

View File

@ -7,7 +7,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.1.1...rel_2.x) ## [Unreleased](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.2.0...rel_2.x)
## [2.0.2.0](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.1.1...2.0.2.0) - 2025-01-21
### Added
- installierbar in OXID 7.2
### Fixed
- Syntaxfehler in Twig Templates
- Wiederverwendung von Captures in unterschiedlichen Templates der selben Rendererinstanz in Smarty behoben
### Changed
- Template Renderer Verwendung
## [2.0.1.1](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.1.0...2.0.1.1) - 2024-10-04 ## [2.0.1.1](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.1.0...2.0.1.1) - 2024-10-04
### Fixed ### Fixed

View File

@ -1,9 +1,9 @@
{ {
"title": "<i class='fab fa-d3 d3fa-color-blue'></i> PDF Dokumente", "title": "<i class='fab fa-d3 d3fa-color-blue'></i> PDF Dokumente",
"moduleversion": "2.0.1.1", "moduleversion": "2.0.2.0",
"titledesc": "fĂĽr den Oxid eShop", "titledesc": "fĂĽr den Oxid eShop",
"author": "DÂł Data Development", "author": "DÂł Data Development",
"moduledate": "04.10.2024", "moduledate": "21.01.2025",
"editors": "", "editors": "",
"tagline": "", "tagline": "",
"image": "", "image": "",

View File

@ -8,6 +8,7 @@ title: Systemanforderungen
* OXID eShop Community Edition (CE), Professional Edition (PE) oder Enterprise Edition (EE) in Compilation Version * OXID eShop Community Edition (CE), Professional Edition (PE) oder Enterprise Edition (EE) in Compilation Version
* 7.0.x * 7.0.x
* 7.1.x * 7.1.x
* 7.2.x
* Themes * Themes
* Diese Modul bindet sich nicht in Frontendthemes ein und ist daher davon unabhängig * Diese Modul bindet sich nicht in Frontendthemes ein und ist daher davon unabhängig
* Template-Engine * Template-Engine

View File

@ -12,21 +12,15 @@ use D3\PdfDocuments\Application\Model\Constants as Constants;
use D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments; use D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments;
use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview; use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview;
/**
* Metadata version
*/
$sMetadataVersion = '2.1'; $sMetadataVersion = '2.1';
/**
* Module information
*/
$aModule = [ $aModule = [
'id' => Constants::OXID_MODULE_ID, 'id' => Constants::OXID_MODULE_ID,
'title' => [ 'title' => [
'de' => '(D3) PDF-Dokumente', 'de' => '(D3) PDF-Dokumente',
'en' => '(D3) PDF documents', 'en' => '(D3) PDF documents',
], ],
'version' => '2.0.1.1', 'version' => '2.0.2.0',
'author' => 'D3 Data Development (Inh.: Thomas Dartsch)', 'author' => 'D3 Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com', 'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/', 'url' => 'https://www.oxidmodule.com/',

View File

@ -1,19 +1,19 @@
[{assign var="pagePadding" value=","|explode:"45,15,30,25"}] [{* top, right, bottom, left *}] [{assign var="pagePadding" value=","|explode:"45,15,30,25"}] [{* top, right, bottom, left *}]
[{assign var="showLogo" value=$showLogo|default:true}] [{assign var="showLogo" value=$showLogo|default:true}]
[{capture append="pdfBlock_style"}] [{capture assign="pdfBlock_style"}]
[{block name="pdfStyles"}] [{block name="pdfStyles"}]
[{include file="@d3PdfDocuments/assets/d3pdfstyles.css.tpl"}] [{include file="@d3PdfDocuments/assets/d3pdfstyles.css.tpl"}]
[{/block}] [{/block}]
[{/capture}] [{/capture}]
[{capture append="pdfBlock_header"}] [{capture assign="pdfBlock_header"}]
[{block name="pdfHeader"}] [{block name="pdfHeader"}]
[{include file="@d3PdfDocuments/documents/inc/page/header.tpl" showLogo=$showLogo}] [{include file="@d3PdfDocuments/documents/inc/page/header.tpl" showLogo=$showLogo}]
[{/block}] [{/block}]
[{/capture}] [{/capture}]
[{capture append="pdfBlock_content"}] [{capture assign="pdfBlock_content"}]
[{include file="@d3PdfDocuments/documents/inc/elements/foldmarks.tpl" pagePadding=$pagePadding}] [{include file="@d3PdfDocuments/documents/inc/elements/foldmarks.tpl" pagePadding=$pagePadding}]
[{block name="pdfAddressArea"}] [{block name="pdfAddressArea"}]
@ -37,7 +37,7 @@
[{/block}] [{/block}]
[{/capture}] [{/capture}]
[{capture append="pdfBlock_footer"}] [{capture assign="pdfBlock_footer"}]
[{block name="pdfFooter"}] [{block name="pdfFooter"}]
[{include file="@d3PdfDocuments/documents/inc/page/footer.tpl" pagePadding=$pagePadding}] [{include file="@d3PdfDocuments/documents/inc/page/footer.tpl" pagePadding=$pagePadding}]
[{/block}] [{/block}]

View File

@ -1,19 +1,19 @@
[{assign var="pagePadding" value=","|explode:"45,15,30,25"}] [{* top, right, bottom, left *}] [{assign var="pagePadding" value=","|explode:"45,15,30,25"}] [{* top, right, bottom, left *}]
[{assign var="showLogo" value=$showLogo|default:true}] [{assign var="showLogo" value=$showLogo|default:true}]
[{capture append="pdfBlock_style"}] [{capture assign="pdfBlock_style"}]
[{block name="pdfStyles"}] [{block name="pdfStyles"}]
[{include file="@d3PdfDocuments/assets/d3pdfstyles.css.tpl"}] [{include file="@d3PdfDocuments/assets/d3pdfstyles.css.tpl"}]
[{/block}] [{/block}]
[{/capture}] [{/capture}]
[{capture append="pdfBlock_header"}] [{capture assign="pdfBlock_header"}]
[{block name="pdfHeader"}] [{block name="pdfHeader"}]
[{include file="@d3PdfDocuments/documents/inc/page/header.tpl" showLogo=$showLogo}] [{include file="@d3PdfDocuments/documents/inc/page/header.tpl" showLogo=$showLogo}]
[{/block}] [{/block}]
[{/capture}] [{/capture}]
[{capture append="pdfBlock_content"}] [{capture assign="pdfBlock_content"}]
[{* include file="@d3PdfDocuments/documents/inc/helper/rulers" pagePadding=$pagePadding *}] [{* include file="@d3PdfDocuments/documents/inc/helper/rulers" pagePadding=$pagePadding *}]
[{include file="@d3PdfDocuments/documents/inc/elements/foldmarks.tpl" pagePadding=$pagePadding}] [{include file="@d3PdfDocuments/documents/inc/elements/foldmarks.tpl" pagePadding=$pagePadding}]
@ -42,7 +42,7 @@
[{/block}] [{/block}]
[{/capture}] [{/capture}]
[{capture append="pdfBlock_footer"}] [{capture assign="pdfBlock_footer"}]
[{block name="pdfFooter"}] [{block name="pdfFooter"}]
[{include file="@d3PdfDocuments/documents/inc/page/footer.tpl" pagePadding=$pagePadding}] [{include file="@d3PdfDocuments/documents/inc/page/footer.tpl" pagePadding=$pagePadding}]
[{/block}] [{/block}]

View File

@ -3,7 +3,7 @@
{% block pdfDocumentInformations %} {% block pdfDocumentInformations %}
<div> <div>
{% set dateFormat = 'D3_PDFDOCUMENTS_DATE_FORMAT'|translate %} {% set dateFormat = 'D3_PDFDOCUMENTS_DATE_FORMAT'|translate %}
{{ translate({ ident: "D3_PDFDOCUMENTS_DATE", suffix: "COLON" }) }} {{ smarty.now|date_format(dateFormat) }} {{ translate({ ident: "D3_PDFDOCUMENTS_DATE", suffix: "COLON" }) }} {{ "now"|date_format(dateFormat) }}
</div> </div>
{% endblock %} {% endblock %}
</div> </div>

View File

@ -22,15 +22,15 @@
</style> </style>
{# horizontal #} {# horizontal #}
{% for rulerItemsHorizontal in 10..600 %} {% for rulerItemsHorizontal in range(10, 600, 10) %}
<div class="rulerItemHorizontal" style="left: {{ smarty.section.rulerItemsHorizontal.index - pagePadding.3 }}mm"> <div class="rulerItemHorizontal" style="left: {{ loop.index0 - pagePadding.3 }}mm">
{{ loop.index0 }} {{ loop.index0 }}
</div> </div>
{% endfor %} {% endfor %}
{# vertical #} {# vertical #}
{% for rulerItemsVertical in 0..600 %} {% for rulerItemsVertical in range(0, 600, 10) %}
<div class="rulerItemVertical" style="top: {{ smarty.section.rulerItemsVertical.index - pagePadding.0 }}mm"> <div class="rulerItemVertical" style="top: {{ loop.index0 - pagePadding.0 }}mm">
{{ loop.index0 }} {{ loop.index0 }}
</div> </div>
{% endfor %} {% endfor %}

View File

@ -14,6 +14,7 @@
{% endset %} {% endset %}
{% set pdfBlock_content %} {% set pdfBlock_content %}
{# {% include "@d3PdfDocuments/documents/inc/helper/rulers.html.twig" with {pagePadding: pagePadding} %}#}
{% include "@d3PdfDocuments/documents/inc/elements/foldmarks.html.twig" with {pagePadding: pagePadding} %} {% include "@d3PdfDocuments/documents/inc/elements/foldmarks.html.twig" with {pagePadding: pagePadding} %}
{% block pdfAddressArea %} {% block pdfAddressArea %}