10 Commits

Author SHA1 Message Date
35f6048a37 update documentation 2025-01-20 14:47:27 +01:00
14aa855bb7 fix typo 2024-12-10 11:36:54 +01:00
40fb77b376 improve code 2024-12-10 10:27:53 +01:00
c34a9067a6 add Composer availability check tag 2024-12-10 08:57:52 +01:00
ec914da45e make installable in OXID 7.2 2024-12-10 08:46:50 +01:00
2f72319820 fix Twig templates 2024-10-04 15:59:17 +02:00
79ec86cdda adjust version information 2024-10-04 10:39:52 +02:00
28d7e692a2 fix tax note syntax in Twig template 2024-10-04 10:36:37 +02:00
99810c9cba add language switch 2024-10-01 09:48:00 +02:00
9a4d09678c complete documentation 2024-10-01 09:32:44 +02:00
22 changed files with 99 additions and 78 deletions

View File

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

View File

@ -18,16 +18,13 @@ use OxidEsales\Eshop\Core\Base;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\UtilsView;
use OxidEsales\EshopCommunity\Core\Di\ContainerFacade;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
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\TemplateRendererBridgeInterface;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateNotInChainException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Smarty;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Html2Pdf;
use Twig\Error\Error;
@ -46,7 +43,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
public $filenameExtension = 'pdf';
/** @var Smarty */
/** @var TemplateEngineInterface */
public $oTemplateEngine;
/** @var string */
@ -90,7 +87,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
* @param $sFilename
* @param int $iSelLang
* @param string $target
* @return mixed|string|null
* @return string|null
* @throws Html2PdfException
*/
public function genPdf($sFilename, $iSelLang = 0, $target = self::PDF_DESTINATION_STDOUT)
@ -118,10 +115,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
$this->genPdf($sFilename, $iLanguage, self::PDF_DESTINATION_DOWNLOAD);
$this->runPostAction();
Registry::getUtils()->showMessageAndExit('');
} catch (pdfGeneratorExceptionAbstract $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
} catch (InvalidArgumentException $e) {
} catch (pdfGeneratorExceptionAbstract|InvalidArgumentException $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
}
@ -144,10 +138,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
self::PDF_DESTINATION_FILE
);
$this->runPostAction();
} catch (pdfGeneratorExceptionAbstract $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
} catch (InvalidArgumentException $e) {
} catch (pdfGeneratorExceptionAbstract|InvalidArgumentException $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
}
@ -167,10 +158,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
$ret = $this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STRING );
$this->runPostAction();
return $ret;
} catch (pdfGeneratorExceptionAbstract $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
} catch (InvalidArgumentException $e) {
} catch (pdfGeneratorExceptionAbstract|InvalidArgumentException $e) {
Registry::get(UtilsView::class)->addErrorToDisplay($e);
Registry::getLogger()->error($e);
}
@ -181,7 +169,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
/**
* @param int $iSelLang
*/
public function setTemplateEngineVars($iSelLang)
public function setTemplateEngineVars(int $iSelLang)
{
unset($iSelLang);
@ -198,7 +186,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
* @return mixed
* @throws InvalidArgumentException
*/
public function getHTMLContent($iSelLang = 0)
public function getHTMLContent(int $iSelLang = 0)
{
$blCurrentRenderFromAdmin = self::$_blIsAdmin;
self::$_blIsAdmin = $this->renderTemplateFromAdmin();
@ -216,8 +204,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
//Registry::getLogger()->error(dumpVar(__METHOD__." ".__LINE__), [$error->getFile()]);
$error = oxNew(StandardException::class, $error->getMessage());
throw $error;
throw oxNew(StandardException::class, $error->getMessage());
}
$lang->setTplLanguage($currTplLang);
@ -324,14 +311,12 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
// maximize filename length to 255 bytes
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$filename = mb_strcut(
return mb_strcut(
pathinfo($filename, PATHINFO_FILENAME),
0,
255 - ($ext ? strlen($ext) + 1 : 0),
mb_detect_encoding($filename)
) . ($ext ? '.' . $ext : '');
return $filename;
}
public function beautifyFilename($filename)

View File

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

View File

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

View File

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

View File

@ -14,37 +14,57 @@ use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract;
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\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Registry;
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
{
/**
/**
* @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).
$masterDb = DatabaseProvider::getMaster();
$sOrderId = $this->getEditObjectId();
try {
$sOrderId = $this->getEditObjectId();
$viewNameGenerator = Registry::get(TableViewNameGenerator::class);
$sTable = $viewNameGenerator->getViewName("oxorderarticles");
$viewNameGenerator = Registry::get( TableViewNameGenerator::class );
$sTable = $viewNameGenerator->getViewName( "oxorderarticles" );
$sQ = "select count(oxid) from $sTable where oxorderid = " . $masterDb->quote($sOrderId) . " and oxstorno = 0";
return (bool) $masterDb->getOne($sQ);
/** @var QueryBuilder $queryBuilder */
$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 pdfGeneratorExceptionAbstract
*/
public function d3CreatePDF()
public function d3CreatePDF(): void
{
$soxId = $this->getEditObjectId();
if ($soxId != "-1" && isset($soxId)) {
@ -57,10 +77,7 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
}
}
/**
* @return registryOrderoverview
*/
public function d3getGeneratorList()
public function d3getGeneratorList(): registryOrderoverview
{
return oxNew(registryOrderoverview::class);
}

View File

@ -1,4 +1,9 @@
> [german version](README.md)
![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)
[![english version](https://logos.oxidmodule.com/en2_xs.svg)](README.en.md)
# PDF Documents

View File

@ -1,10 +1,15 @@
> [english version](README.en.md)
![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)
[![english version](https://logos.oxidmodule.com/en2_xs.svg)](README.en.md)
# PDF-Dokumente
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.

View File

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

View File

@ -7,7 +7,15 @@ 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/),
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.0...rel_2.x)
## [Unreleased](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.1.1...rel_2.x)
### Added
- installierbar in OXID 7.2
### Fixed
- Syntaxfehler in Twig Templates
## [2.0.1.1](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.1.0...2.0.1.1) - 2024-10-04
### Fixed
- Syntax der Steuerangaben in Twig-Templates
## [2.0.1.0](https://git.d3data.de/D3Public/pdfdokumente/compare/2.0.0.0...2.0.1.0) - 2024-10-01
### Added

View File

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

View File

@ -8,10 +8,10 @@ title: Systemanforderungen
* OXID eShop Community Edition (CE), Professional Edition (PE) oder Enterprise Edition (EE) in Compilation Version
* 7.0.x
* 7.1.x
* 7.2.x
* Themes
* Diese Modul bindet sich nicht in Frontendthemes ein und ist daher davon unabhängig
* (D3) Modul-Connector ([kostenfrei bei D3 erhältlich](https://www.oxidmodule.com/connector/)) ab Version 7.1
* Template-Engine
* Smarty ( Ungetestet! )
* Smarty
* Twig
* Installation via [Composer](https://getcomposer.org)

View File

@ -2,4 +2,4 @@
title: Kompatibilität mit anderen Modulen
---
Das PDF Dokumente-Modul integriert sich auch in die Erweiterung "Auftragsmanager" von (D3) Data Development, sofern dieses im Shop installiert wurde. Diese Integration wurde fĂĽr die Version 4.0.0.0 des "Auftragsmanager"-Moduls entwickelt.
Das PDF Dokumente-Modul integriert sich auch in die Erweiterung "Auftragsmanager" von (D3) Data Development, sofern dieses im Shop installiert wurde. Diese Integration wurde fĂĽr die Version 6.0.0.0 des "Auftragsmanager"-Moduls entwickelt.

View File

@ -2,8 +2,7 @@
title: Dateien löschen
---
Löschen Sie den Ordner `{$modulefolder}` und seine enthaltenen Elemente aus dem Verzeichnis `source/modules/d3` Ihres Shops.
Bestätigen Sie anschließend im Shopadmin unter [ Erweiterungen ] -> [ Module ] -> [ Installierte Shop-Module ] die Nachricht:
Sofern nötig, bestätigen Sie im Shopadmin unter [ Erweiterungen ] -> [ Module ] -> [ Installierte Shop-Module ] die Nachricht:
> Es gibt registrierte Erweiterungen im eShop, deren Verzeichnis nicht vorhanden ist.
> Möchten Sie alle Modulinformationen einschließlich Konfigurationseinstellungen und Blockinformationen für Templates löschen?

View File

@ -2,8 +2,8 @@
title: Funktionen
---
Erstellen Sie unterschiedlichste statische oder dynamische PDF-Dokument auf Kopfdruck. Der Dokumentinhalt wird aus Twigtemplates erstellt.
Erstellen Sie unterschiedlichste statische oder dynamische PDF-Dokument 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.
Das Modul kann einfach erweitert werden, um bestehende Dokumente anzupassen oder Neue hinzuzufĂĽgen.
Das Modul kann einfach erweitert werden, um bestehende Dokumente anzupassen oder Neue hinzuzufĂĽgen.

View File

@ -2,7 +2,7 @@
title: Anpassungen an bestehenden Dokumenten
---
Die Dokumente werden aus Twigtemplates erstellt, die Sie im `views/twig/documents` finden. Die entsprechenden Smarty Pendants sind unter `views/smarty/documents`.
Die Dokumente werden aus Templates (Smarty bzw. Twig) erstellt, die Sie im Ordner `views/smarty/documents` bzw. `views/twig/documents` finden.
Für Änderungen einzelner Dokumentbereiche können Sie die darin notierten Templateblöcke in einem eigenen Modul überladen und deren Inhalt so verändern oder ergänzen. So müssen Sie das Originalmodul nicht verändern.

View File

@ -14,10 +14,9 @@ Layouts können mit inline CSS-Styles definiert werden. Die Einbindung externer
Beachten Sie bitte, dass auch nur ein CSS-Subset unterstützt wird. Mit etwas CSS-Kreativität sollten sich die üblichen Formatierungen dennoch deutlich einfacher umsetzen lassen, als dies direkt in PHP-Programmierung möglich wäre.
## Twig
## Templates
Innerhalb der Templates steht Ihnen die komplette Twig-Funktionalität zur Verfügung.
Smarty wird perspektivisch noch nachgereich.
Innerhalb der Templates steht Ihnen die komplette Twig- bzw. Smarty-Funktionalität zur Verfügung.
## Debug

View File

@ -26,7 +26,7 @@ $aModule = [
'de' => '(D3) PDF-Dokumente',
'en' => '(D3) PDF documents',
],
'version' => '2.0.1.0',
'version' => '2.0.1.1',
'author' => 'D3 Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/',

View File

@ -3,7 +3,7 @@
{% block pdfDocumentInformations %}
<div>
{% 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>
{% endblock %}
</div>

View File

@ -32,7 +32,7 @@
<tr class="producttax">
<td class="indent"></td>
<td class="description">
{{ translate({ ident: "D3_PDFDOCUMENTS_TAX", args: VatKey, suffix: "COLON" }) }}
{{ translate({ ident: "D3_PDFDOCUMENTS_TAX", suffix: "COLON" }) | format( VatKey ) }}
</td>
<td class="values">
{{ lang.formatCurrency(oVat, currency) }} {{ currency.name }}
@ -104,7 +104,7 @@
<td class="indent"></td>
<td class="description">
{% if config.getConfigParam('sAdditionalServVATCalcMethod') != 'proportional' %}
{{ translate({ ident: "D3_PDFDOCUMENTS_TAX", args: order.getFieldData('oxdelvat'), suffix: "COLON" }) }}
{{ translate({ ident: "D3_PDFDOCUMENTS_TAX", suffix: "COLON" }) | format( order.getFieldData('oxdelvat') ) }}
{% else %}
{{ translate({ ident: "D3_PDFDOCUMENTS_PROPORTIONAL_TAX", suffix: "COLON" }) }}
{% endif %}
@ -142,7 +142,7 @@
<td class="indent"></td>
<td class="description">
{% if config.getConfigParam('sAdditionalServVATCalcMethod') != 'proportional' %}
{{ translate({ ident: "D3_PDFDOCUMENTS_TAX", args: order.getFieldData('oxpayvat'), suffix: "COLON" }) }}
{{ translate({ ident: "D3_PDFDOCUMENTS_TAX", suffix: "COLON" }) | format( order.getFieldData('oxpayvat') ) }}
{% else %}
{{ translate({ ident: "D3_PDFDOCUMENTS_PROPORTIONAL_TAX", suffix: "COLON" }) }}
{% endif %}

View File

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

View File

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