Document components text get config translation
This commit is contained in:
parent
ad68183987
commit
3c59a57a8a
99
app/Abstracts/View/Components/Document.php
Normal file
99
app/Abstracts/View/Components/Document.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class Document extends Component
|
||||
{
|
||||
public function getTextFromConfig($type, $config_key, $default_key = '', $trans_type = 'trans')
|
||||
{
|
||||
$translation = '';
|
||||
|
||||
// if set config trasnlation config_key
|
||||
if ($translation = config('type.' . $type . '.translation.' . $config_key)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
$alias = config('type.' . $type . '.alias');
|
||||
$prefix = config("type.' . $type . '.translation.prefix");
|
||||
|
||||
if (!empty($alias)) {
|
||||
$alias .= '::';
|
||||
}
|
||||
|
||||
// This magic trans key..
|
||||
$translations = [
|
||||
'general' => $alias . 'general.' . $default_key,
|
||||
'prefix' => $alias . $prefix . '.' . $default_key,
|
||||
'config_general' => $alias . 'general.' . $config_key,
|
||||
'config_prefix' => $alias . $prefix . '.' . $config_key,
|
||||
];
|
||||
|
||||
switch ($trans_type) {
|
||||
case 'trans':
|
||||
foreach ($translations as $trans) {
|
||||
if (trans($trans) !== $trans) {
|
||||
return $trans;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'trans_choice':
|
||||
foreach ($translations as $trans_choice) {
|
||||
if (trans_choice($trans_choice, 1) !== $trans_choice) {
|
||||
return $trans_choice;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $translation;
|
||||
}
|
||||
|
||||
public function getRouteFromConfig($type, $config_key)
|
||||
{
|
||||
$route = '';
|
||||
|
||||
// if set config trasnlation config_key
|
||||
if ($route = config('type.' . $type . '.route.' . $config_key)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
$prefix = config("type.' . $type . '.route.prefix");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getPermissionFromConfig($type, $config_key, $action)
|
||||
{
|
||||
$permission = '';
|
||||
|
||||
// if set config trasnlation config_key
|
||||
if ($permission = config('type.' . $type . '.permission.' . $config_key)) {
|
||||
return $permission;
|
||||
}
|
||||
|
||||
$alias = config('type.' . $type . '.alias');
|
||||
$group = config('type.' . $type . '.group');
|
||||
$prefix = config("type.' . $type . '.permission.prefix");
|
||||
|
||||
$permission = $action . '-';
|
||||
|
||||
// if use module set module alias
|
||||
if (!empty($alias)) {
|
||||
$permission .= $alias . '-';
|
||||
}
|
||||
|
||||
// if controller in folder it must
|
||||
if (!empty($group)) {
|
||||
$permission .= $group . '-';
|
||||
}
|
||||
|
||||
$permission .= $prefix;
|
||||
|
||||
return $permission;
|
||||
}
|
||||
}
|
@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use App\Abstracts\View\Components\Document as Base;
|
||||
use App\Models\Common\Contact;
|
||||
use App\Models\Document\Document;
|
||||
use App\Traits\Documents;
|
||||
use Date;
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
abstract class DocumentForm extends Component
|
||||
abstract class DocumentForm extends Base
|
||||
{
|
||||
use Documents;
|
||||
|
||||
@ -43,7 +43,10 @@ abstract class DocumentForm extends Component
|
||||
|
||||
/** Content Component Start */
|
||||
/** @var string */
|
||||
public $formRoute;
|
||||
public $routeStore;
|
||||
|
||||
/** @var string */
|
||||
public $routeUpdate;
|
||||
|
||||
/** @var string */
|
||||
public $formId;
|
||||
@ -191,7 +194,7 @@ abstract class DocumentForm extends Component
|
||||
bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false,
|
||||
/** Company Component End */
|
||||
/** Content Component Start */
|
||||
string $formRoute = '', string $formId = 'document', string $formSubmit = 'onSubmit',
|
||||
string $routeStore = '', string $routeUpdate = '', string $formId = 'document', string $formSubmit = 'onSubmit',
|
||||
bool $hideCompany = false, bool $hideAdvanced = false, bool $hideFooter = false, bool $hideButtons = false,
|
||||
/** Content Component End */
|
||||
/** Metadata Component Start */
|
||||
@ -226,7 +229,8 @@ abstract class DocumentForm extends Component
|
||||
/** Company Component End */
|
||||
|
||||
/** Content Component Start */
|
||||
$this->formRoute = ($formRoute) ? $formRoute : $this->getRoute($type, $document);
|
||||
$this->routeStore = $this->getRouteStore($type, $routeStore);
|
||||
$this->routeUpdate = $this->getRouteUpdate($type, $routeUpdate, $document);
|
||||
$this->formId = $formId;
|
||||
$this->formSubmit = $formSubmit;
|
||||
|
||||
@ -283,25 +287,66 @@ abstract class DocumentForm extends Component
|
||||
/** Items Component End */
|
||||
}
|
||||
|
||||
protected function getRoute($type, $document, $parameters = [])
|
||||
protected function getRouteStore($type, $routeStore)
|
||||
{
|
||||
$page = config("type.{$type}.route_name");
|
||||
if (!empty($routeStore)) {
|
||||
return $routeStore;
|
||||
}
|
||||
|
||||
$route = $page . '.store';
|
||||
if ($route = config("type.{$type}.route.store")) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
if ($document) {
|
||||
$prefix = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $prefix . '.store';
|
||||
|
||||
try {
|
||||
route($route);
|
||||
} catch (\Exception $e) {
|
||||
try {
|
||||
$route = Str::plural($type, 2) . '.store';
|
||||
|
||||
route($route);
|
||||
} catch (\Exception $e) {
|
||||
$route = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
protected function getRouteUpdate($type, $routeUpdate, $document, $parameters = [])
|
||||
{
|
||||
if (!empty($routeUpdate)) {
|
||||
return $routeUpdate;
|
||||
}
|
||||
|
||||
if ($route = config("type.{$type}.route.update")) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
$prefix = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $prefix . '.update';
|
||||
|
||||
if (!empty($parameters)) {
|
||||
$parameters = [
|
||||
config("type.{$type}.route_parameter") => $document->id
|
||||
config("type.{$type}.route.parameter") => $document->id
|
||||
];
|
||||
|
||||
$route = $page . '.update';
|
||||
}
|
||||
|
||||
try {
|
||||
route($route, $parameters);
|
||||
} catch (\Exception $e) {
|
||||
try {
|
||||
$route = Str::plural($type, 2) . '.update';
|
||||
|
||||
route($route, $parameters);
|
||||
} catch (\Exception $e) {
|
||||
$route = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
@ -344,6 +389,13 @@ abstract class DocumentForm extends Component
|
||||
return $contact_type;
|
||||
}
|
||||
|
||||
if ($contact_type = config("type.{$type}.contact_type")) {
|
||||
return $contact_type;
|
||||
}
|
||||
|
||||
// set default type
|
||||
$type = Document::INVOICE_TYPE;
|
||||
|
||||
return config("type.{$type}.contact_type");
|
||||
}
|
||||
|
||||
@ -353,24 +405,19 @@ abstract class DocumentForm extends Component
|
||||
return $textAddContact;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textAddContact = [
|
||||
$translation = $this->getTextFromConfig($type, 'add_contact', Str::plural($this->contactType, 2), 'trans_choice');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return [
|
||||
'general.form.add',
|
||||
'general.vendors'
|
||||
$translation,
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$textAddContact = [
|
||||
'general.form.add',
|
||||
'general.customers'
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $textAddContact;
|
||||
return [
|
||||
'general.form.add',
|
||||
'general.customers',
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTextCreateNewContact($type, $textCreateNewContact)
|
||||
@ -379,24 +426,21 @@ abstract class DocumentForm extends Component
|
||||
return $textCreateNewContact;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textCreateNewContact = [
|
||||
$contact_type = Str::plural(config('type.' . $type . '.contact_type'), 2);
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'create_new_contact', $contact_type, 'trans_choice');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return [
|
||||
'general.form.add_new',
|
||||
'general.vendors'
|
||||
$translation,
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$textCreateNewContact = [
|
||||
'general.form.add_new',
|
||||
'general.customers'
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $textCreateNewContact;
|
||||
return [
|
||||
'general.form.add_new',
|
||||
'general.customers',
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTextEditContact($type, $textEditContact)
|
||||
@ -405,18 +449,13 @@ abstract class DocumentForm extends Component
|
||||
return $textEditContact;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textEditContact = 'general.form.edit';
|
||||
break;
|
||||
default:
|
||||
$textEditContact = 'general.form.edit';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'edit_contact', 'form.edit');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textEditContact;
|
||||
return 'general.form.edit';
|
||||
}
|
||||
|
||||
protected function getTextContactInfo($type, $textContactInfo)
|
||||
@ -429,14 +468,20 @@ abstract class DocumentForm extends Component
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textContactInfo = 'bills.bill_from';
|
||||
$default_key = 'bill_from';
|
||||
break;
|
||||
default:
|
||||
$textContactInfo = 'invoices.bill_to';
|
||||
$default_key = 'bill_to';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textContactInfo;
|
||||
$translation = $this->getTextFromConfig($type, 'contact_info', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.bill_to';
|
||||
}
|
||||
|
||||
protected function getTextChooseDifferentContact($type, $textChooseDifferentContact)
|
||||
@ -445,24 +490,19 @@ abstract class DocumentForm extends Component
|
||||
return $textChooseDifferentContact;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textChooseDifferentContact = [
|
||||
$translation = $this->getTextFromConfig($type, 'choose_different_contact', Str::plural($this->contactType, 2), 'trans_choice');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return [
|
||||
'general.form.choose_different',
|
||||
'general.vendors'
|
||||
$translation,
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$textChooseDifferentContact = [
|
||||
}
|
||||
|
||||
return [
|
||||
'general.form.choose_different',
|
||||
'general.customers'
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $textChooseDifferentContact;
|
||||
}
|
||||
|
||||
protected function getIssuedAt($type, $document, $issued_at)
|
||||
@ -560,14 +600,20 @@ abstract class DocumentForm extends Component
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textDocumentNumber = 'bills.bill_number';
|
||||
$default_key = 'bill_number';
|
||||
break;
|
||||
default:
|
||||
$textDocumentNumber = 'invoices.invoice_number';
|
||||
$default_key = 'invoice_number';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textDocumentNumber;
|
||||
$translation = $this->getTextFromConfig($type, 'document_number', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.invoice_number';
|
||||
}
|
||||
|
||||
protected function getTextOrderNumber($type, $textOrderNumber)
|
||||
@ -576,18 +622,13 @@ abstract class DocumentForm extends Component
|
||||
return $textOrderNumber;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textOrderNumber = 'bills.order_number';
|
||||
break;
|
||||
default:
|
||||
$textOrderNumber = 'invoices.order_number';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'order_number');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textOrderNumber;
|
||||
return 'invoices.order_number';
|
||||
}
|
||||
|
||||
protected function getTextIssuedAt($type, $textIssuedAt)
|
||||
@ -600,14 +641,20 @@ abstract class DocumentForm extends Component
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textIssuedAt = 'bills.bill_date';
|
||||
$default_key = 'bill_date';
|
||||
break;
|
||||
default:
|
||||
$textIssuedAt = 'invoices.invoice_date';
|
||||
$default_key = 'invoice_date';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textIssuedAt;
|
||||
$translation = $this->getTextFromConfig($type, 'issued_at', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.invoice_date';
|
||||
}
|
||||
|
||||
protected function getTextDueAt($type, $textDueAt)
|
||||
@ -616,90 +663,73 @@ abstract class DocumentForm extends Component
|
||||
return $textDueAt;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textDueAt = 'bills.due_date';
|
||||
break;
|
||||
default:
|
||||
$textDueAt = 'invoices.due_date';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'due_at', 'due_date');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textDueAt;
|
||||
return 'invoices.due_date';
|
||||
}
|
||||
|
||||
protected function getTextItems($type, $text_items)
|
||||
protected function getTextItems($type, $textItems)
|
||||
{
|
||||
if (!empty($text_items)) {
|
||||
return $text_items;
|
||||
if (!empty($textItems)) {
|
||||
return $textItems;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_items = 'general.items';
|
||||
break;
|
||||
default:
|
||||
$text_items = setting('invoice.item_name', 'general.items');
|
||||
|
||||
if ($text_items == 'custom') {
|
||||
$text_items = setting('invoice.item_name_input');
|
||||
}
|
||||
break;
|
||||
// if you use settting translation
|
||||
if (setting($type . '.item_name', 'items') == 'custom') {
|
||||
return setting($type . '.item_name_input');
|
||||
}
|
||||
|
||||
return $text_items;
|
||||
$translation = $this->getTextFromConfig($type, 'items');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
protected function getTextQuantity($type, $text_quantity)
|
||||
return 'general.items';
|
||||
}
|
||||
|
||||
protected function getTextQuantity($type, $textQuantity)
|
||||
{
|
||||
if (!empty($text_quantity)) {
|
||||
return $text_quantity;
|
||||
if (!empty($textQuantity)) {
|
||||
return $textQuantity;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_quantity = 'bills.quantity';
|
||||
break;
|
||||
default:
|
||||
$text_quantity = setting('invoice.quantity_name', 'invoices.quantity');
|
||||
|
||||
if ($text_quantity == 'custom') {
|
||||
$text_quantity = setting('invoice.quantity_name_input');
|
||||
}
|
||||
break;
|
||||
// if you use settting translation
|
||||
if (setting($type . '.quantity_name', 'quantity') == 'custom') {
|
||||
return setting($type . '.quantity_name_input');
|
||||
}
|
||||
|
||||
return $text_quantity;
|
||||
$translation = $this->getTextFromConfig($type, 'quantity');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
protected function getTextPrice($type, $text_price)
|
||||
return 'invoices.quantity';
|
||||
}
|
||||
|
||||
protected function getTextPrice($type, $textPrice)
|
||||
{
|
||||
if (!empty($text_price)) {
|
||||
return $text_price;
|
||||
if (!empty($textPrice)) {
|
||||
return $textPrice;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_price = 'bills.price';
|
||||
break;
|
||||
default:
|
||||
$text_price = setting('invoice.price_name', 'invoices.price');
|
||||
|
||||
if ($text_price == 'custom') {
|
||||
$text_price = setting('invoice.price_name_input');
|
||||
}
|
||||
break;
|
||||
// if you use settting translation
|
||||
if (setting($type . '.price_name', 'price') == 'custom') {
|
||||
return setting($type . '.price_name_input');
|
||||
}
|
||||
|
||||
return $text_price;
|
||||
$translation = $this->getTextFromConfig($type, 'price');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.price';
|
||||
}
|
||||
|
||||
protected function getTextAmount($type, $text_amount)
|
||||
@ -708,9 +738,13 @@ abstract class DocumentForm extends Component
|
||||
return $text_amount;
|
||||
}
|
||||
|
||||
$text_amount = 'general.amount';
|
||||
$translation = $this->getTextFromConfig($type, 'amount');
|
||||
|
||||
return $text_amount;
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.amount';
|
||||
}
|
||||
|
||||
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Abstracts\View\Components\Document as Base;
|
||||
use App\Events\Common\BulkActionsAdding;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class DocumentIndex extends Component
|
||||
abstract class DocumentIndex extends Base
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
@ -292,7 +292,7 @@ abstract class DocumentIndex extends Component
|
||||
return $page;
|
||||
}
|
||||
|
||||
return config("type.{$type}.route_name");
|
||||
return config("type.{$type}.route.prefix");
|
||||
}
|
||||
|
||||
protected function getDocsPath($type, $docsPath)
|
||||
@ -323,7 +323,7 @@ abstract class DocumentIndex extends Component
|
||||
return $createRoute;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.create';
|
||||
|
||||
@ -355,7 +355,8 @@ abstract class DocumentIndex extends Component
|
||||
|
||||
$importRouteParameters = [
|
||||
'group' => config("type.{$type}.group"),
|
||||
'type' => config("type.{$type}.route_name")
|
||||
'type' => config("type.{$type}.route.prefix"),
|
||||
'route' => 'invoices.import',
|
||||
];
|
||||
|
||||
return $importRouteParameters;
|
||||
@ -367,7 +368,7 @@ abstract class DocumentIndex extends Component
|
||||
return $exportRoute;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.export';
|
||||
|
||||
@ -386,7 +387,7 @@ abstract class DocumentIndex extends Component
|
||||
return $formCardHeaderRoute;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.index';
|
||||
|
||||
@ -427,9 +428,13 @@ abstract class DocumentIndex extends Component
|
||||
return $textBulkAction;
|
||||
}
|
||||
|
||||
$textBulkAction = 'general.' . config("type.{$type}.translation_key");
|
||||
$translation = $this->getTextFromConfig($type, 'bulk_action', Str::plural($type, 2));
|
||||
|
||||
return $textBulkAction;
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.invoices';
|
||||
}
|
||||
|
||||
protected function getBulkActions($type, $bulkActions, $bulkActionClass)
|
||||
@ -475,7 +480,7 @@ abstract class DocumentIndex extends Component
|
||||
|
||||
$bulkActionRouteParameters = [
|
||||
'group' => config("type.{$type}.group"),
|
||||
'type' => config("type.{$type}.route_name")
|
||||
'type' => config("type.{$type}.route.prefix")
|
||||
];
|
||||
|
||||
return $bulkActionRouteParameters;
|
||||
@ -496,6 +501,12 @@ abstract class DocumentIndex extends Component
|
||||
return $textDocumentNumber;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'document_number', 'numbers');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.numbers';
|
||||
}
|
||||
|
||||
@ -518,18 +529,15 @@ abstract class DocumentIndex extends Component
|
||||
return $textContactName;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textContactName = 'general.vendors';
|
||||
break;
|
||||
default:
|
||||
$textContactName = 'general.customers';
|
||||
break;
|
||||
$contact_type = Str::plural(config('type.' . $type . '.contact_type'), 2);
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'contact_name', $contact_type, 'trans_choice');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textContactName;
|
||||
return 'general.customers';
|
||||
}
|
||||
|
||||
protected function getClassContactName($type, $classContactName)
|
||||
@ -564,18 +572,13 @@ abstract class DocumentIndex extends Component
|
||||
return $textIssuedAt;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textIssuedAt = 'bills.bill_date';
|
||||
break;
|
||||
default:
|
||||
$textIssuedAt = 'invoices.invoice_date';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'issued_at');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textIssuedAt;
|
||||
return 'invoices.invoice_date';
|
||||
}
|
||||
|
||||
protected function getclassIssuedAt($type, $classIssuedAt)
|
||||
@ -597,18 +600,13 @@ abstract class DocumentIndex extends Component
|
||||
return $textDueAt;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textDueAt = 'bills.due_date';
|
||||
break;
|
||||
default:
|
||||
$textDueAt = 'invoices.due_date';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'due_at');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textDueAt;
|
||||
return 'invoices.due_date';
|
||||
}
|
||||
|
||||
protected function getClassDueAt($type, $classDueAt)
|
||||
@ -630,18 +628,15 @@ abstract class DocumentIndex extends Component
|
||||
return $textDocumentStatus;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textDocumentStatus = 'bills.statuses.';
|
||||
break;
|
||||
default:
|
||||
$textDocumentStatus = 'invoices.statuses.';
|
||||
break;
|
||||
$default_key = config("type.' . $type . '.translation.prefix") . '.statuses.';
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'document_status', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textDocumentStatus;
|
||||
return 'invoices.statuses.';
|
||||
}
|
||||
|
||||
protected function getClassStatus($type, $classStatus)
|
||||
@ -676,7 +671,7 @@ abstract class DocumentIndex extends Component
|
||||
return $routeButtonShow;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.show';
|
||||
|
||||
@ -698,7 +693,7 @@ abstract class DocumentIndex extends Component
|
||||
return $routeButtonEdit;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.edit';
|
||||
|
||||
@ -720,7 +715,7 @@ abstract class DocumentIndex extends Component
|
||||
return $routeButtonDuplicate;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.duplicate';
|
||||
|
||||
@ -742,7 +737,7 @@ abstract class DocumentIndex extends Component
|
||||
return $routeButtonCancelled;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.cancelled';
|
||||
|
||||
@ -764,7 +759,7 @@ abstract class DocumentIndex extends Component
|
||||
return $routeButtonDelete;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.destroy';
|
||||
|
||||
|
@ -2,16 +2,16 @@
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Abstracts\View\Components\Document as Base;
|
||||
use App\Traits\DateTime;
|
||||
use App\Models\Common\Media;
|
||||
use File;
|
||||
use Image;
|
||||
use Storage;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class DocumentShow extends Component
|
||||
abstract class DocumentShow extends Base
|
||||
{
|
||||
use DateTime;
|
||||
|
||||
@ -521,18 +521,15 @@ abstract class DocumentShow extends Component
|
||||
return $textRecurringType;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textRecurringType = 'general.bills';
|
||||
break;
|
||||
default:
|
||||
$textRecurringType = 'general.invoices';
|
||||
break;
|
||||
$default_key = config("type.' . $type . '.translation.prefix");
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'recurring_tye', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textRecurringType;
|
||||
return 'general.invoices';
|
||||
}
|
||||
|
||||
protected function getTextStatusMessage($type, $textStatusMessage)
|
||||
@ -541,18 +538,15 @@ abstract class DocumentShow extends Component
|
||||
return $textStatusMessage;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textStatusMessage = 'bills.messages.draft';
|
||||
break;
|
||||
default:
|
||||
$textStatusMessage = 'invoices.messages.draft';
|
||||
break;
|
||||
$default_key = config("type.' . $type . '.translation.prefix") . '.messages.draft';
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'status_message', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textStatusMessage;
|
||||
return 'invoices.messages.draft';
|
||||
}
|
||||
|
||||
protected function getDocumentTemplate($type, $documentTemplate)
|
||||
@ -613,7 +607,7 @@ abstract class DocumentShow extends Component
|
||||
return $signedUrl;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = 'signed.' . $page . '.show';
|
||||
|
||||
@ -634,18 +628,15 @@ abstract class DocumentShow extends Component
|
||||
return $textHistories;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textHistories = 'bills.histories';
|
||||
break;
|
||||
default:
|
||||
$textHistories = 'invoices.histories';
|
||||
break;
|
||||
$default_key = config("type.' . $type . '.translation.prefix") . '.histories';
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'histories', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textHistories;
|
||||
return 'invoices.histories';
|
||||
}
|
||||
|
||||
protected function getTextHistoryStatus($type, $textHistoryStatus)
|
||||
@ -654,18 +645,15 @@ abstract class DocumentShow extends Component
|
||||
return $textHistoryStatus;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textHistoryStatus = 'bills.statuses.';
|
||||
break;
|
||||
default:
|
||||
$textHistoryStatus = 'invoices.statuses.';
|
||||
break;
|
||||
$default_key = config("type.' . $type . '.translation.prefix") . '.statuses.';
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'statuses', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textHistoryStatus;
|
||||
return 'invoices.statuses.';
|
||||
}
|
||||
|
||||
protected function getRouteButtonAddNew($type, $routeButtonAddNew)
|
||||
@ -674,7 +662,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonAddNew;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.create';
|
||||
|
||||
@ -693,7 +681,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonEdit;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.edit';
|
||||
|
||||
@ -715,7 +703,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonDuplicate;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.duplicate';
|
||||
|
||||
@ -737,7 +725,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonPrint;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.print';
|
||||
|
||||
@ -759,7 +747,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonPdf;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.pdf';
|
||||
|
||||
@ -781,7 +769,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonCancelled;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.cancelled';
|
||||
|
||||
@ -820,7 +808,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonDelete;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.destroy';
|
||||
|
||||
@ -842,7 +830,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonPaid;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.paid';
|
||||
|
||||
@ -864,7 +852,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonSent;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.sent';
|
||||
|
||||
@ -886,7 +874,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonReceived;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.received';
|
||||
|
||||
@ -908,7 +896,7 @@ abstract class DocumentShow extends Component
|
||||
return $routeButtonEmail;
|
||||
}
|
||||
|
||||
$page = config("type.{$type}.route_name");
|
||||
$page = config("type.{$type}.route.prefix");
|
||||
|
||||
$route = $page . '.email';
|
||||
|
||||
@ -1018,18 +1006,15 @@ abstract class DocumentShow extends Component
|
||||
return $textHeaderContact;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textHeaderContact = 'general.vendors';
|
||||
break;
|
||||
default:
|
||||
$textHeaderContact = 'general.customers';
|
||||
break;
|
||||
$default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'header_contact', $default_key, 'trans_choice');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textHeaderContact;
|
||||
return 'general.customers';
|
||||
}
|
||||
|
||||
protected function getTextHeaderAmount($type, $textHeaderAmount)
|
||||
@ -1038,6 +1023,12 @@ abstract class DocumentShow extends Component
|
||||
return $textHeaderAmount;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'header_amount', 'amount_due');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.amount_due';
|
||||
}
|
||||
|
||||
@ -1047,6 +1038,12 @@ abstract class DocumentShow extends Component
|
||||
return $textHeaderDueAt;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'header_due_at', 'due_on');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.due_on';
|
||||
}
|
||||
|
||||
@ -1103,7 +1100,15 @@ abstract class DocumentShow extends Component
|
||||
return $textTimelineCreateTitle;
|
||||
}
|
||||
|
||||
return config("type.{$type}.translation_key") . '.create_' . $type;
|
||||
$default_key = 'create_' . $type;
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_create_title', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.create_invoice';
|
||||
}
|
||||
|
||||
protected function getTextTimelineCreateMessage($type, $textTimelineCreateMessage)
|
||||
@ -1112,7 +1117,13 @@ abstract class DocumentShow extends Component
|
||||
return $textTimelineCreateMessage;
|
||||
}
|
||||
|
||||
return config("type.{$type}.translation_key") . '.messages.status.created';
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_create_message', 'messages.status.created');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.messages.status.created';
|
||||
}
|
||||
|
||||
protected function getTextTimelineSentTitle($type, $textTimelineSentTitle)
|
||||
@ -1125,14 +1136,20 @@ abstract class DocumentShow extends Component
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textTimelineSentTitle = 'bills.receive_bill';
|
||||
$default_key = 'receive_bill';
|
||||
break;
|
||||
default:
|
||||
$textTimelineSentTitle = 'invoices.send_invoice';
|
||||
$default_key = 'send_invoice';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textTimelineSentTitle;
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_sent_title', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.send_invoice';
|
||||
}
|
||||
|
||||
protected function getTextTimelineSentStatusDraft($type, $textTimelineSentStatusDraft)
|
||||
@ -1145,14 +1162,20 @@ abstract class DocumentShow extends Component
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textTimelineSentStatusDraft = 'bills.messages.status.receive.draft';
|
||||
$default_key = 'messages.status.receive.draft';
|
||||
break;
|
||||
default:
|
||||
$textTimelineSentStatusDraft = 'invoices.messages.status.send.draft';
|
||||
$default_key = 'messages.status.send.draft';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textTimelineSentStatusDraft;
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_sent_status_draft', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.messages.status.send.draft';
|
||||
}
|
||||
|
||||
protected function getTextTimelineSentStatusMarkSent($type, $textTimelineSentStatusMarkSent)
|
||||
@ -1165,14 +1188,20 @@ abstract class DocumentShow extends Component
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textTimelineSentStatusMarkSent = 'bills.mark_received';
|
||||
$default_key = 'mark_received';
|
||||
break;
|
||||
default:
|
||||
$textTimelineSentStatusMarkSent = 'invoices.mark_sent';
|
||||
$default_key = 'mark_sent';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textTimelineSentStatusMarkSent;
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_sent_status_mark_sent', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.mark_sent';
|
||||
}
|
||||
|
||||
protected function getTextTimelineSentStatusReceived($type, $textTimelineSentStatusReceived)
|
||||
@ -1185,14 +1214,20 @@ abstract class DocumentShow extends Component
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textTimelineSentStatusReceived = 'bills.mark_received';
|
||||
$textTimelineSentStatusReceived = 'mark_received';
|
||||
break;
|
||||
default:
|
||||
$textTimelineSentStatusReceived = 'invoices.mark_sent';
|
||||
$textTimelineSentStatusReceived = 'mark_sent';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textTimelineSentStatusReceived;
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_sent_status_received', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.mark_sent';
|
||||
}
|
||||
|
||||
protected function getTextTimelineSendStatusMail($type, $textTimelineSendStatusMail)
|
||||
@ -1201,18 +1236,13 @@ abstract class DocumentShow extends Component
|
||||
return $textTimelineSendStatusMail;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textTimelineSendStatusMail = 'bills.send_mail';
|
||||
break;
|
||||
default:
|
||||
$textTimelineSendStatusMail = 'invoices.send_mail';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_sent_status_mail', 'send_mail');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textTimelineSendStatusMail;
|
||||
return 'invoices.send_mail';
|
||||
}
|
||||
|
||||
protected function getTextTimelineGetPaidTitle($type, $textTimelineGetPaidTitle)
|
||||
@ -1225,14 +1255,20 @@ abstract class DocumentShow extends Component
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textTimelineGetPaidTitle = 'bills.make_payment';
|
||||
$default_key = 'make_payment';
|
||||
break;
|
||||
default:
|
||||
$textTimelineGetPaidTitle = 'invoices.get_paid';
|
||||
$default_key = 'get_paid';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textTimelineGetPaidTitle;
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_get_paid_title', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.get_paid';
|
||||
}
|
||||
|
||||
protected function getTextTimelineGetPaidStatusAwait($type, $textTimelineGetPaidStatusAwait)
|
||||
@ -1241,18 +1277,13 @@ abstract class DocumentShow extends Component
|
||||
return $textTimelineGetPaidStatusAwait;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textTimelineGetPaidStatusAwait = 'bills.messages.status.paid.await';
|
||||
break;
|
||||
default:
|
||||
$textTimelineGetPaidStatusAwait = 'invoices.messages.status.paid.await';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_get_paid_status_await', 'messages.status.paid.await');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textTimelineGetPaidStatusAwait;
|
||||
return 'invoices.messages.status.paid.await';
|
||||
}
|
||||
|
||||
protected function getTextTimelineGetPaidStatusPartiallyPaid($type, $textTimelineGetPaidStatusPartiallyPaid)
|
||||
@ -1261,9 +1292,13 @@ abstract class DocumentShow extends Component
|
||||
return $textTimelineGetPaidStatusPartiallyPaid;
|
||||
}
|
||||
|
||||
$textTimelineGetPaidStatusPartiallyPaid = 'general.partially_paid';
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_get_paid_status_partially_paid', 'partially_paid');
|
||||
|
||||
return $textTimelineGetPaidStatusPartiallyPaid;
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.partially_paid';
|
||||
}
|
||||
|
||||
protected function getTextTimelineGetPaidMarkPaid($type, $textTimelineGetPaidMarkPaid)
|
||||
@ -1272,18 +1307,13 @@ abstract class DocumentShow extends Component
|
||||
return $textTimelineGetPaidMarkPaid;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textTimelineGetPaidMarkPaid = 'bills.mark_paid';
|
||||
break;
|
||||
default:
|
||||
$textTimelineGetPaidMarkPaid = 'invoices.mark_paid';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_get_paid_mark_paid', 'mark_paid');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textTimelineGetPaidMarkPaid;
|
||||
return 'invoices.mark_paid';
|
||||
}
|
||||
|
||||
protected function getTextTimelineGetPaidAddPayment($type, $textTimelineGetPaidAddPayment)
|
||||
@ -1292,18 +1322,13 @@ abstract class DocumentShow extends Component
|
||||
return $textTimelineGetPaidAddPayment;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textTimelineGetPaidAddPayment = 'bills.add_payment';
|
||||
break;
|
||||
default:
|
||||
$textTimelineGetPaidAddPayment = 'invoices.add_payment';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'timeline_get_paid_add_payment', 'add_payment');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textTimelineGetPaidAddPayment;
|
||||
return 'invoices.add_payment';
|
||||
}
|
||||
|
||||
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Abstracts\View\Components\Document as Base;
|
||||
use App\Traits\DateTime;
|
||||
use App\Models\Common\Media;
|
||||
use File;
|
||||
use Image;
|
||||
use Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class DocumentTemplate extends Component
|
||||
abstract class DocumentTemplate extends Base
|
||||
{
|
||||
use DateTime;
|
||||
|
||||
@ -251,18 +251,13 @@ abstract class DocumentTemplate extends Component
|
||||
return $textDocumentNumber;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textDocumentNumber = 'bills.bill_number';
|
||||
break;
|
||||
default:
|
||||
$textDocumentNumber = 'invoices.invoice_number';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'document_number', 'numbers');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textDocumentNumber;
|
||||
return 'general.numbers';
|
||||
}
|
||||
|
||||
protected function getTextOrderNumber($type, $textOrderNumber)
|
||||
@ -271,18 +266,13 @@ abstract class DocumentTemplate extends Component
|
||||
return $textOrderNumber;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textOrderNumber = 'bills.order_number';
|
||||
break;
|
||||
default:
|
||||
$textOrderNumber = 'invoices.order_number';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'order_number');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textOrderNumber;
|
||||
return 'invoices.order_number';
|
||||
}
|
||||
|
||||
protected function getTextContactInfo($type, $textContactInfo)
|
||||
@ -295,14 +285,20 @@ abstract class DocumentTemplate extends Component
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textContactInfo = 'bills.bill_from';
|
||||
$default_key = 'bill_from';
|
||||
break;
|
||||
default:
|
||||
$textContactInfo = 'invoices.bill_to';
|
||||
$default_key = 'bill_to';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textContactInfo;
|
||||
$translation = $this->getTextFromConfig($type, 'contact_info', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.bill_to';
|
||||
}
|
||||
|
||||
protected function getTextIssuedAt($type, $textIssuedAt)
|
||||
@ -315,14 +311,20 @@ abstract class DocumentTemplate extends Component
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textIssuedAt = 'bills.bill_date';
|
||||
$default_key = 'bill_date';
|
||||
break;
|
||||
default:
|
||||
$textIssuedAt = 'invoices.invoice_date';
|
||||
$default_key = 'invoice_date';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textIssuedAt;
|
||||
$translation = $this->getTextFromConfig($type, 'issued_at', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.invoice_date';
|
||||
}
|
||||
|
||||
protected function getTextDueAt($type, $textDueAt)
|
||||
@ -331,18 +333,13 @@ abstract class DocumentTemplate extends Component
|
||||
return $textDueAt;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textDueAt = 'bills.due_date';
|
||||
break;
|
||||
default:
|
||||
$textDueAt = 'invoices.due_date';
|
||||
break;
|
||||
$translation = $this->getTextFromConfig($type, 'due_at', 'due_date');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return $textDueAt;
|
||||
return 'invoices.due_date';
|
||||
}
|
||||
|
||||
protected function getTextItems($type, $textItems)
|
||||
@ -351,22 +348,18 @@ abstract class DocumentTemplate extends Component
|
||||
return $textItems;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textItems = 'general.items';
|
||||
break;
|
||||
default:
|
||||
$textItems = setting('invoice.item_name', 'general.items');
|
||||
|
||||
if ($textItems == 'custom') {
|
||||
$textItems = setting('invoice.item_name_input');
|
||||
}
|
||||
break;
|
||||
// if you use settting translation
|
||||
if (setting($type . '.item_name', 'items') == 'custom') {
|
||||
return setting($type . '.item_name_input');
|
||||
}
|
||||
|
||||
return $textItems;
|
||||
$translation = $this->getTextFromConfig($type, 'items');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.items';
|
||||
}
|
||||
|
||||
protected function getTextQuantity($type, $textQuantity)
|
||||
@ -375,46 +368,38 @@ abstract class DocumentTemplate extends Component
|
||||
return $textQuantity;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textQuantity = 'bills.quantity';
|
||||
break;
|
||||
default:
|
||||
$textQuantity = setting('invoice.quantity_name', 'invoices.quantity');
|
||||
|
||||
if ($textQuantity == 'custom') {
|
||||
$textQuantity = setting('invoice.quantity_name_input');
|
||||
}
|
||||
break;
|
||||
// if you use settting translation
|
||||
if (setting($type . '.quantity_name', 'quantity') == 'custom') {
|
||||
return setting($type . '.quantity_name_input');
|
||||
}
|
||||
|
||||
return $textQuantity;
|
||||
$translation = $this->getTextFromConfig($type, 'quantity');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
protected function getTextPrice($type, $text_price)
|
||||
return 'invoices.quantity';
|
||||
}
|
||||
|
||||
protected function getTextPrice($type, $textPrice)
|
||||
{
|
||||
if (!empty($text_price)) {
|
||||
return $text_price;
|
||||
if (!empty($textPrice)) {
|
||||
return $textPrice;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_price = 'bills.price';
|
||||
break;
|
||||
default:
|
||||
$text_price = setting('invoice.price_name', 'invoices.price');
|
||||
|
||||
if ($text_price == 'custom') {
|
||||
$text_price = setting('invoice.price_name_input');
|
||||
}
|
||||
break;
|
||||
// if you use settting translation
|
||||
if (setting($type . '.price_name', 'price') == 'custom') {
|
||||
return setting($type . '.price_name_input');
|
||||
}
|
||||
|
||||
return $text_price;
|
||||
$translation = $this->getTextFromConfig($type, 'price');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.price';
|
||||
}
|
||||
|
||||
protected function getTextAmount($type, $textAmount)
|
||||
@ -423,9 +408,13 @@ abstract class DocumentTemplate extends Component
|
||||
return $textAmount;
|
||||
}
|
||||
|
||||
$textAmount = 'general.amount';
|
||||
$translation = $this->getTextFromConfig($type, 'amount');
|
||||
|
||||
return $textAmount;
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.amount';
|
||||
}
|
||||
|
||||
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
|
||||
|
@ -3,42 +3,82 @@
|
||||
use App\Models\Document\Document;
|
||||
|
||||
return [
|
||||
|
||||
// Documents
|
||||
Document::INVOICE_TYPE => [
|
||||
'group' => 'sales',
|
||||
'route_name' => 'invoices',
|
||||
'route_parameter' => 'invoice',
|
||||
'permission_name' => 'sales-invoices',
|
||||
'translation_key' => 'invoices',
|
||||
'contact_type' => 'customer',
|
||||
'alias' => '', // core empty but module write own alias
|
||||
'group' => 'sales', // controller folder name for permission and route
|
||||
'route' => [
|
||||
'prefix' => 'invoices', // core use with group + prefix, module ex. estimates
|
||||
'paramater' => 'invoice', // sales/invoices/{parameter}/edit
|
||||
//'create' => 'invoices.create', // if you change route, you can write full path
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'invoices', // this controller file name.
|
||||
//'create' => 'create-sales-invoices', // if you change action permission key, you can write full permission
|
||||
],
|
||||
'translation' => [
|
||||
'prefix' => 'invoices', // this translation file name.
|
||||
'add_contact' => 'general.customers', //
|
||||
'issued_at' => 'invoices.invoice_date',
|
||||
'due_at' => 'invoices.due_date',
|
||||
],
|
||||
'contact_type' => 'customer', // use contact type
|
||||
],
|
||||
|
||||
Document::BILL_TYPE => [
|
||||
'alias' => '',
|
||||
'group' => 'purchases',
|
||||
'route_name' => 'bills',
|
||||
'route_parameter' => 'bill',
|
||||
'permission_name' => 'purchases-bills',
|
||||
'translation_key' => 'bills',
|
||||
'route' => [
|
||||
'prefix' => 'bills',
|
||||
'paramater' => 'bill',
|
||||
//'create' => 'bilss.create',
|
||||
],
|
||||
'permission' => [
|
||||
'prefix' => 'bills',
|
||||
//'create' => 'create-purchases-bills',
|
||||
],
|
||||
'translation' => [
|
||||
'prefix' => 'bills',
|
||||
'issued_at' => 'bills.bill_date',
|
||||
'due_at' => 'bills.due_date',
|
||||
],
|
||||
'contact_type' => 'vendor',
|
||||
],
|
||||
|
||||
// Contacts
|
||||
'customer' => [
|
||||
'permission_name' => 'sales-customers',
|
||||
'group' => 'sales',
|
||||
'permission' => [
|
||||
'prefix' => 'customers',
|
||||
//'create' => 'create-sales-customers',
|
||||
],
|
||||
],
|
||||
|
||||
'vendor' => [
|
||||
'permission_name' => 'purchases-vendors',
|
||||
'group' => 'purchases',
|
||||
'permission' => [
|
||||
'prefix' => 'vendors',
|
||||
//'create' => 'create-purchases-vendors',
|
||||
],
|
||||
],
|
||||
|
||||
// Transactions
|
||||
'income' => [
|
||||
'permission_name' => 'sales-revenues',
|
||||
'group' => 'sales',
|
||||
'permission' => [
|
||||
'prefix' => 'revenues',
|
||||
//'create' => 'create-sales-revenues',
|
||||
],
|
||||
'contact_type' => 'customer',
|
||||
],
|
||||
|
||||
'expense' => [
|
||||
'permission_name' => 'purchases-payments',
|
||||
'group' => 'purchases',
|
||||
'permission' => [
|
||||
'prefix' => 'payments',
|
||||
//'create' => 'create-purchases-payments',
|
||||
],
|
||||
'contact_type' => 'vendor',
|
||||
],
|
||||
];
|
||||
|
@ -1,6 +1,6 @@
|
||||
@if (empty($document))
|
||||
{!! Form::open([
|
||||
'route' => $formRoute,
|
||||
'route' => $routeStore,
|
||||
'id' => $formId,
|
||||
'@submit.prevent' => $formSubmit,
|
||||
'@keydown' => 'form.errors.clear($event.target.name)',
|
||||
@ -11,7 +11,7 @@
|
||||
]) !!}
|
||||
@else
|
||||
{!! Form::model($document, [
|
||||
'route' => [$formRoute, $document->id],
|
||||
'route' => [$routeUpdate, $document->id],
|
||||
'id' => $formId,
|
||||
'method' => 'PATCH',
|
||||
'@submit.prevent' => $formSubmit,
|
||||
|
Loading…
x
Reference in New Issue
Block a user