From 2faca7406dd4de3d6a3ef6660ea8902a46f12301 Mon Sep 17 00:00:00 2001
From: Henning Leutz <leutz@pcsg.de>
Date: Tue, 19 Nov 2024 09:26:57 +0100
Subject: [PATCH] feat(ArticleListUnique): toHTML() can be passed to template
 engine and thus settings / variables can be passed on

Related: quiqqer/order-simple-checkout#12
---
 src/QUI/ERP/Accounting/ArticleListUnique.php | 21 +++++++++-----------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/QUI/ERP/Accounting/ArticleListUnique.php b/src/QUI/ERP/Accounting/ArticleListUnique.php
index 64a421d..e25db6c 100644
--- a/src/QUI/ERP/Accounting/ArticleListUnique.php
+++ b/src/QUI/ERP/Accounting/ArticleListUnique.php
@@ -388,17 +388,17 @@ public function setExchangeRate(float $rate): void
     /**
      * Return the Article List as HTML, without CSS
      *
-     * @param bool|string $template - custom template
-     * @param bool|string $articleTemplate
-     * @return string
-     *
      * @throws Exception
      */
     public function toHTML(
         bool|string $template = false,
-        bool|string $articleTemplate = false
+        bool|string $articleTemplate = false,
+        ?QUI\Interfaces\Template\EngineInterface $Engine = null
     ): string {
-        $Engine = QUI::getTemplateManager()->getEngine();
+        if ($Engine === null) {
+            $Engine = QUI::getTemplateManager()->getEngine();
+        }
+
         $vatArray = [];
 
         if (!$this->count()) {
@@ -551,21 +551,18 @@ public function toMailHTML(): string
     /**
      * Return the Article List as HTML, with CSS
      *
-     * @param bool|string $template
-     * @param bool|string $articleTemplate
-     * @return string
-     *
      * @throws Exception
      */
     public function toHTMLWithCSS(
         bool|string $template = false,
-        bool|string $articleTemplate = false
+        bool|string $articleTemplate = false,
+        ?QUI\Interfaces\Template\EngineInterface $Engine = null
     ): string {
         $style = '<style>';
         $style .= file_get_contents(dirname(__FILE__) . '/ArticleList.css');
         $style .= '</style>';
 
-        return $style . $this->toHTML($template, $articleTemplate);
+        return $style . $this->toHTML($template, $articleTemplate, $Engine);
     }
 
     /**
-- 
GitLab