From 78996c35ddc88605d90d2261475946d9f81fcc07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Sat, 9 Jan 2021 18:24:16 +0300 Subject: [PATCH] Document text dynamic fixed.. --- .../View/Components/DocumentForm.php | 19 ++++++++------ .../View/Components/DocumentIndex.php | 25 ++++++++++++++----- .../View/Components/DocumentShow.php | 10 ++++---- .../View/Components/DocumentTemplate.php | 13 +++++++++- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentForm.php b/app/Abstracts/View/Components/DocumentForm.php index c105fdbed..25e704ee4 100644 --- a/app/Abstracts/View/Components/DocumentForm.php +++ b/app/Abstracts/View/Components/DocumentForm.php @@ -8,6 +8,7 @@ use App\Models\Document\Document; use App\Traits\Documents; use Date; use Illuminate\Support\Str; + abstract class DocumentForm extends Base { use Documents; @@ -405,7 +406,9 @@ abstract class DocumentForm extends Base return $textAddContact; } - $translation = $this->getTextFromConfig($type, 'add_contact', Str::plural($this->contactType, 2), 'trans_choice'); + $default_key = Str::plural(config('type.' . $type . '.contact_type'), 2); + + $translation = $this->getTextFromConfig($type, 'add_contact', $default_key, 'trans_choice'); if (!empty($translation)) { return [ @@ -426,9 +429,9 @@ abstract class DocumentForm extends Base return $textCreateNewContact; } - $contact_type = Str::plural(config('type.' . $type . '.contact_type'), 2); + $default_key = Str::plural(config('type.' . $type . '.contact_type'), 2); - $translation = $this->getTextFromConfig($type, 'create_new_contact', $contact_type, 'trans_choice'); + $translation = $this->getTextFromConfig($type, 'create_new_contact', $default_key, 'trans_choice'); if (!empty($translation)) { return [ @@ -490,7 +493,9 @@ abstract class DocumentForm extends Base return $textChooseDifferentContact; } - $translation = $this->getTextFromConfig($type, 'choose_different_contact', Str::plural($this->contactType, 2), 'trans_choice'); + $default_key = Str::plural(config('type.' . $type . '.contact_type'), 2); + + $translation = $this->getTextFromConfig($type, 'choose_different_contact', $default_key, 'trans_choice'); if (!empty($translation)) { return [ @@ -732,10 +737,10 @@ abstract class DocumentForm extends Base return 'invoices.price'; } - protected function getTextAmount($type, $text_amount) + protected function getTextAmount($type, $textAmount) { - if (!empty($text_amount)) { - return $text_amount; + if (!empty($textAmount)) { + return $textAmount; } $translation = $this->getTextFromConfig($type, 'amount'); diff --git a/app/Abstracts/View/Components/DocumentIndex.php b/app/Abstracts/View/Components/DocumentIndex.php index 4e72d5a3c..38b4be305 100644 --- a/app/Abstracts/View/Components/DocumentIndex.php +++ b/app/Abstracts/View/Components/DocumentIndex.php @@ -427,8 +427,10 @@ abstract class DocumentIndex extends Base if (!empty($textBulkAction)) { return $textBulkAction; } + + $default_key = config('type.' . $type . '.translation.prefix'); - $translation = $this->getTextFromConfig($type, 'bulk_action', Str::plural($type, 2)); + $translation = $this->getTextFromConfig($type, 'bulk_action', $default_key, 'trans_choice'); if (!empty($translation)) { return $translation; @@ -529,9 +531,9 @@ abstract class DocumentIndex extends Base return $textContactName; } - $contact_type = Str::plural(config('type.' . $type . '.contact_type'), 2); + $default_key = Str::plural(config('type.' . $type . '.contact_type'), 2); - $translation = $this->getTextFromConfig($type, 'contact_name', $contact_type, 'trans_choice'); + $translation = $this->getTextFromConfig($type, 'contact_name', $default_key, 'trans_choice'); if (!empty($translation)) { return $translation; @@ -572,7 +574,18 @@ abstract class DocumentIndex extends Base return $textIssuedAt; } - $translation = $this->getTextFromConfig($type, 'issued_at'); + switch ($type) { + case 'bill': + case 'expense': + case 'purchase': + $default_key = 'bill_date'; + break; + default: + $default_key = 'invoice_date'; + break; + } + + $translation = $this->getTextFromConfig($type, 'issued_at', $default_key); if (!empty($translation)) { return $translation; @@ -600,7 +613,7 @@ abstract class DocumentIndex extends Base return $textDueAt; } - $translation = $this->getTextFromConfig($type, 'due_at'); + $translation = $this->getTextFromConfig($type, 'due_at', 'due_date'); if (!empty($translation)) { return $translation; @@ -628,7 +641,7 @@ abstract class DocumentIndex extends Base return $textDocumentStatus; } - $default_key = config("type.' . $type . '.translation.prefix") . '.statuses.'; + $default_key = config('type.' . $type . '.translation.prefix') . '.statuses.'; $translation = $this->getTextFromConfig($type, 'document_status', $default_key); diff --git a/app/Abstracts/View/Components/DocumentShow.php b/app/Abstracts/View/Components/DocumentShow.php index 22bf9cdea..9663d56a5 100644 --- a/app/Abstracts/View/Components/DocumentShow.php +++ b/app/Abstracts/View/Components/DocumentShow.php @@ -521,7 +521,7 @@ abstract class DocumentShow extends Base return $textRecurringType; } - $default_key = config("type.' . $type . '.translation.prefix"); + $default_key = config('type.' . $type . '.translation.prefix'); $translation = $this->getTextFromConfig($type, 'recurring_tye', $default_key); @@ -538,7 +538,7 @@ abstract class DocumentShow extends Base return $textStatusMessage; } - $default_key = config("type.' . $type . '.translation.prefix") . '.messages.draft'; + $default_key = config('type.' . $type . '.translation.prefix') . '.messages.draft'; $translation = $this->getTextFromConfig($type, 'status_message', $default_key); @@ -628,7 +628,7 @@ abstract class DocumentShow extends Base return $textHistories; } - $default_key = config("type.' . $type . '.translation.prefix") . '.histories'; + $default_key = config('type.' . $type . '.translation.prefix') . '.histories'; $translation = $this->getTextFromConfig($type, 'histories', $default_key); @@ -645,9 +645,9 @@ abstract class DocumentShow extends Base return $textHistoryStatus; } - $default_key = config("type.' . $type . '.translation.prefix") . '.statuses.'; + $default_key = config('type.' . $type . '.translation.prefix') . '.statuses.'; - $translation = $this->getTextFromConfig($type, 'statuses', $default_key); + $translation = $this->getTextFromConfig($type, 'history_status', $default_key); if (!empty($translation)) { return $translation; diff --git a/app/Abstracts/View/Components/DocumentTemplate.php b/app/Abstracts/View/Components/DocumentTemplate.php index d9a4dfe97..be651ab39 100644 --- a/app/Abstracts/View/Components/DocumentTemplate.php +++ b/app/Abstracts/View/Components/DocumentTemplate.php @@ -251,7 +251,18 @@ abstract class DocumentTemplate extends Base return $textDocumentNumber; } - $translation = $this->getTextFromConfig($type, 'document_number', 'numbers'); + switch ($type) { + case 'bill': + case 'expense': + case 'purchase': + $default_key = 'bill_number'; + break; + default: + $default_key = 'invoice_number'; + break; + } + + $translation = $this->getTextFromConfig($type, 'document_number', $default_key); if (!empty($translation)) { return $translation;