Skip to content
Code-Schnipsel Gruppen Projekte
Bestätigt Commit c260c07d erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: own template for articles at the article list

related: #102
Übergeordneter 43cee957
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!82feat: own template for articles at the article list,!81feat: own template for articles at the article list
......@@ -37,7 +37,7 @@
<tbody>
{foreach $articles as $Article}
{$Article->toHTML()}
{$Article->toHTML($articleTemplate)}
{/foreach}
</tbody>
</table>
......
......@@ -392,8 +392,10 @@ public function setExchangeRate(float $rate): void
*
* @throws QUI\Exception
*/
public function toHTML(bool|string $template = false): string
{
public function toHTML(
bool|string $template = false,
bool|string $articleTemplate = false
): string {
$Engine = QUI::getTemplateManager()->getEngine();
$vatArray = [];
......@@ -458,7 +460,10 @@ public function toHTML(bool|string $template = false): string
$Currency->setExchangeRate($this->exchangeRate);
}
if ($Currency instanceof QUI\ERP\CryptoCurrency\Currency) {
if (
class_exists('QUI\ERP\CryptoCurrency\Currency')
&& $Currency instanceof QUI\ERP\CryptoCurrency\Currency
) {
$ExchangeCurrency->setExchangeRate($this->exchangeRate);
$exchangeRate = $Currency->convertFormat(1, $ExchangeCurrency);
} else {
......@@ -479,7 +484,10 @@ public function toHTML(bool|string $template = false): string
$showExchangeRate = true;
$DefaultCurrency = QUI\ERP\Defaults::getCurrency();
if ($Currency instanceof QUI\ERP\CryptoCurrency\Currency) {
if (
class_exists('QUI\ERP\CryptoCurrency\Currency')
&& $Currency instanceof QUI\ERP\CryptoCurrency\Currency
) {
$DefaultCurrency->setExchangeRate($this->exchangeRate);
$exchangeRate = $Currency->convertFormat(1, $DefaultCurrency);
} else {
......@@ -512,6 +520,7 @@ public function toHTML(bool|string $template = false): string
'showHeader' => $this->showHeader,
'this' => $this,
'articles' => $articles,
'articleTemplate' => $articleTemplate,
'calculations' => $this->calculations,
'vatArray' => $vatArray,
'Locale' => $this->Locale,
......
......@@ -9,7 +9,13 @@
use QUI;
use QUI\ERP\Accounting\Calc as ErpCalc;
use QUI\Exception;
use function dirname;
use function file_exists;
use function implode;
use function is_array;
use function is_string;
/**
* Class ArticleView
......@@ -29,9 +35,9 @@ class ArticleView extends QUI\QDOM
protected Article $Article;
/**
* @var QUI\ERP\Currency\Currency
* @var ?QUI\ERP\Currency\Currency
*/
protected QUI\ERP\Currency\Currency $Currency;
protected ?QUI\ERP\Currency\Currency $Currency = null;
/**
* ArticleView constructor.
......@@ -110,7 +116,7 @@ public function getCustomFields(): array
}
if (isset($field['custom_calc']['valueText'])) {
if (!\is_string($field['custom_calc']['valueText'])) {
if (!is_string($field['custom_calc']['valueText'])) {
if (isset($field['custom_calc']['valueText'][$current])) {
$field['custom_calc']['valueText'] = $field['custom_calc']['valueText'][$current];
} else {
......@@ -175,11 +181,12 @@ public function getPrice(): string
/**
* Create the html
*
* @param string|bool $template
* @return string
*
* @throws QUI\Exception
* @throws Exception
*/
public function toHTML(): string
public function toHTML(string|bool $template = false): string
{
$Engine = QUI::getTemplateManager()->getEngine();
$Currency = $this->getCurrency();
......@@ -189,7 +196,7 @@ public function toHTML(): string
$calc = $article['calculated'];
// quantity unit
if (isset($article['quantityUnit']) && \is_array($article['quantityUnit'])) {
if (isset($article['quantityUnit']) && is_array($article['quantityUnit'])) {
$article['quantityUnit'] = $article['quantityUnit']['title'];
}
......@@ -237,10 +244,14 @@ public function toHTML(): string
'hasAppliedVat' => !empty($articleData['calculated']['vatArray']['vat'])
]);
if ($template && file_exists($template)) {
return $Engine->fetch($template);
}
if ($this->Article instanceof QUI\ERP\Accounting\Articles\Text) {
return $Engine->fetch(\dirname(__FILE__) . '/ArticleViewText.html');
return $Engine->fetch(dirname(__FILE__) . '/ArticleViewText.html');
}
return $Engine->fetch(\dirname(__FILE__) . '/ArticleView.html');
return $Engine->fetch(dirname(__FILE__) . '/ArticleView.html');
}
}
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren