From b06343c6473c89361216fc0e7a5aa4dee4280402 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 9 Feb 2022 19:09:41 +1100 Subject: [PATCH] Add variable for invoices --- app/Models/GatewayType.php | 2 +- app/Utils/HtmlEngine.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Models/GatewayType.php b/app/Models/GatewayType.php index da847e587d8e..ecbe094fd6b5 100644 --- a/app/Models/GatewayType.php +++ b/app/Models/GatewayType.php @@ -96,7 +96,7 @@ class GatewayType extends StaticModel case self::FPX: return ctrans('texts.fpx'); default: - return 'Undefined.'; + return ' '; break; } } diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 3e659cb3024f..c96e526d5859 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -14,11 +14,13 @@ namespace App\Utils; use App\Models\Country; use App\Models\CreditInvitation; +use App\Models\GatewayType; use App\Models\InvoiceInvitation; use App\Models\QuoteInvitation; use App\Models\RecurringInvoiceInvitation; use App\Services\PdfMaker\Designs\Utilities\DesignHelpers; use App\Utils\Ninja; +use App\Utils\Number; use App\Utils\Traits\MakesDates; use App\Utils\transformTranslations; use Exception; @@ -512,6 +514,20 @@ class HtmlEngine $data['$entity_images'] = ['value' => $this->generateEntityImagesMarkup(), 'label' => '']; + $data['$payments'] = ['value' => '', 'label' => ctrans('texts.payments')]; + + if ($this->entity_string == 'invoice' && $this->entity->payments()->exists()) { + + $payment_list = '

'; + + foreach ($this->entity->payments as $payment) { + $payment_list .= ctrans('texts.payment_subject') . ": " . $this->formatDate($payment->date, $this->client->date_format()) . " :: " . Number::formatMoney($payment->amount, $this->client) ." :: ". GatewayType::getAlias($payment->gateway_type_id) . "
"; + } + + $data['$payments'] = ['value' => $payment_list, 'label' => ctrans('texts.payments')]; + } + + $arrKeysLength = array_map('strlen', array_keys($data)); array_multisort($arrKeysLength, SORT_DESC, $data);