move document statutes keys..

This commit is contained in:
Cüneyt Şentürk 2021-01-11 11:10:30 +03:00
parent 0f158cdc7e
commit 00ed7bcd49
11 changed files with 81 additions and 35 deletions

View File

@ -713,7 +713,17 @@ abstract class DocumentIndex extends Base
return $translation; return $translation;
} }
return $default_key; $alias = config('type.' . $type . '.alias');
if (!empty($alias)) {
$translation = $alias . '::' . config('type.' . $type . '.translation.prefix') . '.statuses';
if (is_array(trans($$translation))) {
return $translation . '.';
}
}
return 'documents.statuses.';
} }
protected function getClassStatus($type, $classStatus) protected function getClassStatus($type, $classStatus)

View File

@ -641,13 +641,23 @@ abstract class DocumentShow extends Base
$default_key = config('type.' . $type . '.translation.prefix') . '.statuses.'; $default_key = config('type.' . $type . '.translation.prefix') . '.statuses.';
$translation = $this->getTextFromConfig($type, 'history_status', $default_key); $translation = $this->getTextFromConfig($type, 'document_status', $default_key);
if (!empty($translation)) { if (!empty($translation)) {
return $translation; return $translation;
} }
return $default_key; $alias = config('type.' . $type . '.alias');
if (!empty($alias)) {
$translation = $alias . '::' . config('type.' . $type . '.translation.prefix') . '.statuses';
if (is_array(trans($$translation))) {
return $translation . '.';
}
}
return 'documents.statuses.';
} }
protected function getRouteButtonAddNew($type, $routeButtonAddNew) protected function getRouteButtonAddNew($type, $routeButtonAddNew)

View File

@ -104,7 +104,7 @@ class PaymentReceived extends Notification
$this->invoice->document_number, $this->invoice->document_number,
money($this->invoice->amount, $this->invoice->currency_code, true), money($this->invoice->amount, $this->invoice->currency_code, true),
company_date($this->invoice->due_at), company_date($this->invoice->due_at),
trans('invoices.statuses.' . $this->invoice->status), trans('documents.statuses.' . $this->invoice->status),
URL::signedRoute('signed.invoices.show', [$this->invoice->id, 'company_id' => $this->invoice->company_id]), URL::signedRoute('signed.invoices.show', [$this->invoice->id, 'company_id' => $this->invoice->company_id]),
route('invoices.show', $this->invoice->id), route('invoices.show', $this->invoice->id),
route('portal.invoices.show', $this->invoice->id), route('portal.invoices.show', $this->invoice->id),

View File

@ -3,6 +3,7 @@
namespace App\Traits; namespace App\Traits;
use App\Models\Document\Document; use App\Models\Document\Document;
use App\Abstracts\View\Components\Document as DocumentComponent;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -50,10 +51,14 @@ trait Documents
], ],
]; ];
$statuses = collect($list[$type])->each(function ($code) use ($type) { // @todo get dynamic path
//$trans_key = $this->getTextDocumentStatuses($type);
$trans_key = 'documents.statuses.';
$statuses = collect($list[$type])->each(function ($code) use ($type, $trans_key) {
$item = new \stdClass(); $item = new \stdClass();
$item->code = $code; $item->code = $code;
$item->name = trans(Str::plural($type) . '.statuses.' . $code); $item->name = trans($trans_key . $code);
return $item; return $item;
}); });
@ -70,4 +75,27 @@ trait Documents
{ {
return Str::slug($document->document_number, $separator, language()->getShortCode()); return Str::slug($document->document_number, $separator, language()->getShortCode());
} }
protected function getTextDocumentStatuses($type)
{
$default_key = config('type.' . $type . '.translation.prefix') . '.statuses.';
$translation = DocumentComponent::getTextFromConfig($type, 'document_status', $default_key);
if (!empty($translation)) {
return $translation;
}
$alias = config('type.' . $type . '.alias');
if (!empty($alias)) {
$translation = $alias . '::' . config('type.' . $type . '.translation.prefix') . '.statuses';
if (is_array(trans($$translation))) {
return $translation . '.';
}
}
return 'documents.statuses.';
}
} }

View File

@ -38,16 +38,6 @@ return [
'receive_bill' => 'Receive Bill', 'receive_bill' => 'Receive Bill',
'make_payment' => 'Make Payment', 'make_payment' => 'Make Payment',
'statuses' => [
'draft' => 'Draft',
'received' => 'Received',
'partial' => 'Partial',
'paid' => 'Paid',
'overdue' => 'Overdue',
'unpaid' => 'Unpaid',
'cancelled' => 'Cancelled',
],
'messages' => [ 'messages' => [
'draft' => 'This is a <b>DRAFT</b> bill and will be reflected to charts after it gets received.', 'draft' => 'This is a <b>DRAFT</b> bill and will be reflected to charts after it gets received.',

View File

@ -1,6 +1,26 @@
<?php <?php
return [ return [
'statuses' => [
'draft' => 'Draft',
'sent' => 'Sent',
'expired' => 'Expired',
'viewed' => 'Viewed',
'approved' => 'Approved',
'received' => 'Received',
'refused' => 'Refused',
'restored' => 'Restored',
'reversed' => 'Reversed',
'partial' => 'Partial',
'paid' => 'Paid',
'invoiced' => 'Invoiced',
'overdue' => 'Overdue',
'unpaid' => 'Unpaid',
'cancelled' => 'Cancelled',
'void' => 'Void',
],
'messages' => [ 'messages' => [
'email_sent' => ':type email has been sent!', 'email_sent' => ':type email has been sent!',
'marked_sent' => ':type marked as sent!', 'marked_sent' => ':type marked as sent!',

View File

@ -40,18 +40,6 @@ return [
'get_paid' => 'Get Paid', 'get_paid' => 'Get Paid',
'accept_payments' => 'Accept Online Payments', 'accept_payments' => 'Accept Online Payments',
'statuses' => [
'draft' => 'Draft',
'sent' => 'Sent',
'viewed' => 'Viewed',
'approved' => 'Approved',
'partial' => 'Partial',
'paid' => 'Paid',
'overdue' => 'Overdue',
'unpaid' => 'Unpaid',
'cancelled' => 'Cancelled',
],
'messages' => [ 'messages' => [
'email_required' => 'No email address for this customer!', 'email_required' => 'No email address for this customer!',
'draft' => 'This is a <b>DRAFT</b> invoice and will be reflected to charts after it gets sent.', 'draft' => 'This is a <b>DRAFT</b> invoice and will be reflected to charts after it gets sent.',

View File

@ -57,7 +57,7 @@
@if($item->bill) @if($item->bill)
@if ($item->bill->status == 'paid') @if ($item->bill->status == 'paid')
<el-tooltip content="{{ $item->bill->document_number }} / {{ trans('bills.statuses.paid') }}" <el-tooltip content="{{ $item->bill->document_number }} / {{ trans('documents.statuses.paid') }}"
effect="success" effect="success"
:open-delay="100" :open-delay="100"
placement="top"> placement="top">
@ -66,7 +66,7 @@
</span> </span>
</el-tooltip> </el-tooltip>
@elseif ($item->bill->status == 'partial') @elseif ($item->bill->status == 'partial')
<el-tooltip content="{{ $item->bill->document_number }} / {{ trans('bills.statuses.partial') }}" <el-tooltip content="{{ $item->bill->document_number }} / {{ trans('documents.statuses.partial') }}"
effect="info" effect="info"
:open-delay="100" :open-delay="100"
placement="top"> placement="top">

View File

@ -194,7 +194,7 @@
<td class="col-xs-4 col-sm-3 text-right">@money($item->amount, $item->currency_code, true)</td> <td class="col-xs-4 col-sm-3 text-right">@money($item->amount, $item->currency_code, true)</td>
<td class="col-sm-3 d-none d-sm-block text-left">@date($item->issued_at)</td> <td class="col-sm-3 d-none d-sm-block text-left">@date($item->issued_at)</td>
<td class="col-sm-3 d-none d-sm-block text-left">@date($item->due_at)</td> <td class="col-sm-3 d-none d-sm-block text-left">@date($item->due_at)</td>
<td class="col-xs-4 col-sm-2"><span class="badge badge-pill badge-{{ $item->status_label }} my--2">{{ trans('bills.statuses.' . $item->status) }}</span></td> <td class="col-xs-4 col-sm-2"><span class="badge badge-pill badge-{{ $item->status_label }} my--2">{{ trans('documents.statuses.' . $item->status) }}</span></td>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>

View File

@ -194,7 +194,7 @@
<td class="col-xs-4 col-sm-3 text-right">@money($item->amount, $item->currency_code, true)</td> <td class="col-xs-4 col-sm-3 text-right">@money($item->amount, $item->currency_code, true)</td>
<td class="col-sm-3 d-none d-sm-block text-left">@date($item->issued_at)</td> <td class="col-sm-3 d-none d-sm-block text-left">@date($item->issued_at)</td>
<td class="col-sm-3 d-none d-sm-block text-left">@date($item->due_at)</td> <td class="col-sm-3 d-none d-sm-block text-left">@date($item->due_at)</td>
<td class="col-xs-4 col-sm-2"><span class="badge badge-pill badge-{{ $item->status_label }} my--2">{{ trans('invoices.statuses.' . $item->status) }}</span></td> <td class="col-xs-4 col-sm-2"><span class="badge badge-pill badge-{{ $item->status_label }} my--2">{{ trans('documents.statuses.' . $item->status) }}</span></td>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>

View File

@ -57,7 +57,7 @@
@if($item->invoice) @if($item->invoice)
@if ($item->invoice->status == 'paid') @if ($item->invoice->status == 'paid')
<el-tooltip content="{{ $item->invoice->document_number }} / {{ trans('invoices.statuses.paid') }}" <el-tooltip content="{{ $item->invoice->document_number }} / {{ trans('documents.statuses.paid') }}"
effect="success" effect="success"
:open-delay="100" :open-delay="100"
placement="top"> placement="top">
@ -66,7 +66,7 @@
</span> </span>
</el-tooltip> </el-tooltip>
@elseif ($item->invoice->status == 'partial') @elseif ($item->invoice->status == 'partial')
<el-tooltip content="{{ $item->invoice->document_number }} / {{ trans('invoices.statuses.partial') }}" <el-tooltip content="{{ $item->invoice->document_number }} / {{ trans('documents.statuses.partial') }}"
effect="info" effect="info"
:open-delay="100" :open-delay="100"
placement="top"> placement="top">