From b6f5394bbd8f65d1e93ee35662d558beb7a57129 Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Wed, 3 Nov 2021 18:37:57 +0300 Subject: [PATCH] connection between docs or transactions added to recurring messages part #1pbthq3 --- .../View/Components/TransactionShow.php | 27 +++++++++++- app/Models/Banking/Transaction.php | 5 +++ app/Models/Document/Document.php | 5 +++ resources/lang/en-GB/recurring.php | 1 + .../show/recurring-message.blade.php | 21 +++++++++ .../transactions/show/content.blade.php | 10 +++++ .../show/recurring-message.blade.php | 44 +++++++++++++++++++ 7 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 resources/views/components/transactions/show/recurring-message.blade.php diff --git a/app/Abstracts/View/Components/TransactionShow.php b/app/Abstracts/View/Components/TransactionShow.php index 2291c17d6..2e4b1111e 100644 --- a/app/Abstracts/View/Components/TransactionShow.php +++ b/app/Abstracts/View/Components/TransactionShow.php @@ -314,6 +314,12 @@ abstract class TransactionShow extends Base /** @var string */ public $classFooterHistories; + /** @var string */ + public $textRecurringType; + + /** @var bool */ + public $hideRecurringMessage; + /** * Create a new component instance. * @@ -346,7 +352,7 @@ abstract class TransactionShow extends Base bool $hideAttachment = false, $attachment = [], bool $hideFooter = false, bool $hideFooterHistories = false, $histories = [], - string $textHistories = '', string $classFooterHistories = '' + string $textHistories = '', string $classFooterHistories = '', string $textRecurringType = '', bool $hideRecurringMessage = false ) { $this->type = $type; $this->transaction = $transaction; @@ -354,6 +360,8 @@ abstract class TransactionShow extends Base $this->logo = $this->getLogo($logo); $this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all'); $this->date_format = $this->getCompanyDateFormat(); + $this->textRecurringType = $this->getTextRecurringType($type, $textRecurringType); + $this->hideRecurringMessage = $hideRecurringMessage; // Navbar Hide $this->hideButtonAddNew = $hideButtonAddNew; @@ -1276,4 +1284,21 @@ abstract class TransactionShow extends Base return 'col-sm-6 col-md-6 col-lg-6 col-xl-6'; } + + protected function getTextRecurringType($type, $textRecurringType) + { + if (!empty($textRecurringType)) { + return $textRecurringType; + } + + $default_key = config('type.' . $type . '.translation.prefix'); + + $translation = $this->getTextFromConfig($type, 'recurring_tye', $default_key); + + if (!empty($translation)) { + return $translation; + } + + return 'general.revenues'; + } } diff --git a/app/Models/Banking/Transaction.php b/app/Models/Banking/Transaction.php index 701747bf7..a9c351479 100644 --- a/app/Models/Banking/Transaction.php +++ b/app/Models/Banking/Transaction.php @@ -126,6 +126,11 @@ class Transaction extends Model return $this->belongsTo('App\Models\Auth\User', 'contact_id', 'id'); } + public function parent() + { + return $this->belongsTo('App\Models\Banking\Transaction', 'parent_id'); + } + /** * Scope to only include contacts of a given type. * diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index c8570e3be..5ece9995b 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -140,6 +140,11 @@ class Document extends Model return $this->totals()->orderBy('sort_order'); } + public function parent() + { + return $this->belongsTo('App\Models\Document\Document', 'parent_id'); + } + public function scopeLatest(Builder $query) { return $query->orderBy('issued_at', 'desc'); diff --git a/resources/lang/en-GB/recurring.php b/resources/lang/en-GB/recurring.php index 79fefa042..8ce404aca 100644 --- a/resources/lang/en-GB/recurring.php +++ b/resources/lang/en-GB/recurring.php @@ -16,5 +16,6 @@ return [ 'months' => 'Month(s)', 'years' => 'Year(s)', 'message' => 'This is a recurring :type and the next :type will be automatically generated on :date', + 'message_parent' => 'This :type was automatically generated from :link', ]; diff --git a/resources/views/components/documents/show/recurring-message.blade.php b/resources/views/components/documents/show/recurring-message.blade.php index 04e36c01d..cb56d6482 100644 --- a/resources/views/components/documents/show/recurring-message.blade.php +++ b/resources/views/components/documents/show/recurring-message.blade.php @@ -20,4 +20,25 @@ @endif +@if ($document->parent) +
+
+ +
+
+@endif @stack('recurring_message_end') diff --git a/resources/views/components/transactions/show/content.blade.php b/resources/views/components/transactions/show/content.blade.php index 833101bae..22b2fb4f4 100644 --- a/resources/views/components/transactions/show/content.blade.php +++ b/resources/views/components/transactions/show/content.blade.php @@ -22,6 +22,16 @@ @endif @stack('content_header_end') +@stack('recurring_message_start') +@if (!$hideRecurringMessage) + +@endif +@stack('recurring_message_end') + @stack('transaction_start') recurring) && ($next = $recurring->getNextRecurring())) +
+
+ +
+
+@endif +@if ($transaction->parent) +
+
+ +
+
+@endif +@stack('recurring_message_end')