Compare commits

..

No commits in common. "rel_2.x" and "master" have entirely different histories.

12 changed files with 58 additions and 63 deletions

View File

@ -23,7 +23,7 @@ class orderOverviewPdfGenerator
* @param int $iSelLang * @param int $iSelLang
* @throws noPdfHandlerFoundException * @throws noPdfHandlerFoundException
*/ */
public function generatePdf(Order $order, int $iSelLang = 0) public function generatePdf(Order $order, $iSelLang = 0)
{ {
$Pdf= $this->getPdfClass(); $Pdf= $this->getPdfClass();

View File

@ -18,13 +18,16 @@ 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\TemplateEngineInterface;
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;
@ -43,7 +46,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
public $filenameExtension = 'pdf'; public $filenameExtension = 'pdf';
/** @var TemplateEngineInterface */ /** @var Smarty */
public $oTemplateEngine; public $oTemplateEngine;
/** @var string */ /** @var string */
@ -87,7 +90,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
* @param $sFilename * @param $sFilename
* @param int $iSelLang * @param int $iSelLang
* @param string $target * @param string $target
* @return string|null * @return mixed|string|null
* @throws Html2PdfException * @throws Html2PdfException
*/ */
public function genPdf($sFilename, $iSelLang = 0, $target = self::PDF_DESTINATION_STDOUT) public function genPdf($sFilename, $iSelLang = 0, $target = self::PDF_DESTINATION_STDOUT)
@ -115,7 +118,10 @@ 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|InvalidArgumentException $e) { } catch (pdfGeneratorExceptionAbstract $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
} catch (InvalidArgumentException $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e); Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e); Registry::getLogger()->error($e);
} }
@ -138,7 +144,10 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
self::PDF_DESTINATION_FILE self::PDF_DESTINATION_FILE
); );
$this->runPostAction(); $this->runPostAction();
} catch (pdfGeneratorExceptionAbstract|InvalidArgumentException $e) { } catch (pdfGeneratorExceptionAbstract $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
} catch (InvalidArgumentException $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e); Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e); Registry::getLogger()->error($e);
} }
@ -158,7 +167,10 @@ 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|InvalidArgumentException $e) { } catch (pdfGeneratorExceptionAbstract $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
} catch (InvalidArgumentException $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e); Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e); Registry::getLogger()->error($e);
} }
@ -169,7 +181,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
/** /**
* @param int $iSelLang * @param int $iSelLang
*/ */
public function setTemplateEngineVars(int $iSelLang) public function setTemplateEngineVars($iSelLang)
{ {
unset($iSelLang); unset($iSelLang);
@ -186,7 +198,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
* @return mixed * @return mixed
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function getHTMLContent(int $iSelLang = 0) public function getHTMLContent($iSelLang = 0)
{ {
$blCurrentRenderFromAdmin = self::$_blIsAdmin; $blCurrentRenderFromAdmin = self::$_blIsAdmin;
self::$_blIsAdmin = $this->renderTemplateFromAdmin(); self::$_blIsAdmin = $this->renderTemplateFromAdmin();
@ -204,7 +216,8 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
//Registry::getLogger()->error(dumpVar(__METHOD__." ".__LINE__), [$error->getFile()]); //Registry::getLogger()->error(dumpVar(__METHOD__." ".__LINE__), [$error->getFile()]);
throw oxNew(StandardException::class, $error->getMessage()); $error = oxNew(StandardException::class, $error->getMessage());
throw $error;
} }
$lang->setTplLanguage($currTplLang); $lang->setTplLanguage($currTplLang);
@ -311,12 +324,14 @@ 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);
return mb_strcut( $filename = 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

@ -116,7 +116,7 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
} }
/** /**
* @return false|int * @return false|string
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function getPayableUntilDate() public function getPayableUntilDate()

View File

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

View File

@ -31,7 +31,7 @@ abstract class registryAbstract implements registryGenericInterface
*/ */
public function addGenerator($className) public function addGenerator($className)
{ {
if ( ! $this->hasGenerator( $className ) ) { if (false == $this->hasGenerator($className)) {
/** @var pdfdocumentsGenericInterface $generator */ /** @var pdfdocumentsGenericInterface $generator */
$generator = oxNew( $className ); $generator = oxNew( $className );
@ -49,7 +49,7 @@ abstract class registryAbstract implements registryGenericInterface
{ {
$requiredInterface = $this->getRequiredGeneratorInterfaceClassName(); $requiredInterface = $this->getRequiredGeneratorInterfaceClassName();
if ( ! $item instanceof $requiredInterface ) { if (false == $item instanceof $requiredInterface) {
throw oxNew(wrongPdfGeneratorInterface::class, $requiredInterface); throw oxNew(wrongPdfGeneratorInterface::class, $requiredInterface);
} }

View File

@ -14,57 +14,37 @@ 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\Registries\registryOrderoverview; use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
use Doctrine\DBAL\Driver\Exception; use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview;
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 Exception * @throws DatabaseConnectionException
*/ */
public function d3CanExport(): bool public function d3CanExport()
{ {
try { // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
$sOrderId = $this->getEditObjectId(); $masterDb = DatabaseProvider::getMaster();
$sOrderId = $this->getEditObjectId();
$viewNameGenerator = Registry::get( TableViewNameGenerator::class ); $viewNameGenerator = Registry::get(TableViewNameGenerator::class);
$sTable = $viewNameGenerator->getViewName( "oxorderarticles" ); $sTable = $viewNameGenerator->getViewName("oxorderarticles");
/** @var QueryBuilder $queryBuilder */ $sQ = "select count(oxid) from $sTable where oxorderid = " . $masterDb->quote($sOrderId) . " and oxstorno = 0";
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get( QueryBuilderFactoryInterface::class )->create(); return (bool) $masterDb->getOne($sQ);
$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(): void public function d3CreatePDF()
{ {
$soxId = $this->getEditObjectId(); $soxId = $this->getEditObjectId();
if ($soxId != "-1" && isset($soxId)) { if ($soxId != "-1" && isset($soxId)) {
@ -77,7 +57,10 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
} }
} }
public function d3getGeneratorList(): registryOrderoverview /**
* @return registryOrderoverview
*/
public function d3getGeneratorList()
{ {
return oxNew(registryOrderoverview::class); return oxNew(registryOrderoverview::class);
} }

View File

@ -5,7 +5,7 @@
PDF-Dokumentgenerator fĂĽr OXID eShop PDF-Dokumentgenerator fĂĽr OXID eShop
Erstellen Sie unterschiedliche statische oder dynamische PDF-Dokumente auf Knopfdruck. Der Dokumentinhalt wird aus Templates (Smarty bzw. Twig) erstellt. Erstellen Sie unterschiedliche statische oder dynamische PDF-Dokumente auf Kopfdruck. 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.

View File

@ -10,14 +10,13 @@
"PDF", "PDF",
"documents", "documents",
"invoice", "invoice",
"delivery note", "delivery note"
"d3ac"
], ],
"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": "https://www.d3data.de", "homepage": "http://www.d3data.de",
"role": "Owner" "role": "Owner"
} }
], ],
@ -27,7 +26,7 @@
], ],
"require": { "require": {
"php": "^8.0", "php": "^8.0",
"oxid-esales/oxideshop-ce": "7.0 - 7.2", "oxid-esales/oxideshop-ce": "7.0 - 7.1",
"spipu/html2pdf": "~5.2.8", "spipu/html2pdf": "~5.2.8",
"beberlei/assert": "^3.3.2" "beberlei/assert": "^3.3.2"
}, },

View File

@ -8,7 +8,6 @@ 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

@ -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" }) }} {{ "now"|date_format(dateFormat) }} {{ translate({ ident: "D3_PDFDOCUMENTS_DATE", suffix: "COLON" }) }} {{ smarty.now|date_format(dateFormat) }}
</div> </div>
{% endblock %} {% endblock %}
</div> </div>

View File

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

View File

@ -14,7 +14,6 @@
{% 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 %}