Document text dynamic fixed..

This commit is contained in:
Cüneyt Şentürk 2021-01-09 18:24:16 +03:00
parent 3c59a57a8a
commit 78996c35dd
4 changed files with 48 additions and 19 deletions

View File

@ -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');

View File

@ -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);

View File

@ -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;

View File

@ -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;