document typo..

This commit is contained in:
Cüneyt Şentürk 2021-01-09 22:31:26 +03:00
parent 7f318911fd
commit 12e063eaff
5 changed files with 163 additions and 83 deletions

View File

@ -123,4 +123,11 @@ abstract class Document extends Component
return $hide; return $hide;
} }
public function getClassFromConfig($type, $config_key)
{
$class_key = 'type.' . $type . '.class.' . $config_key;
return config($class_key, '');
}
} }

View File

@ -360,14 +360,14 @@ abstract class DocumentForm extends Base
return $contact_type; return $contact_type;
} }
if ($contact_type = config("type.{$type}.contact_type")) { if ($contact_type = config('type.' . $type . '.contact_type')) {
return $contact_type; return $contact_type;
} }
// set default type // set default type
$type = Document::INVOICE_TYPE; $type = Document::INVOICE_TYPE;
return config("type.{$type}.contact_type"); return config('type.' . $type . '.contact_type');
} }
protected function getTextAddContact($type, $textAddContact) protected function getTextAddContact($type, $textAddContact)
@ -480,28 +480,25 @@ abstract class DocumentForm extends Base
]; ];
} }
protected function getIssuedAt($type, $document, $issued_at) protected function getIssuedAt($type, $document, $issuedAt)
{ {
if (!empty($issued_at)) { if (!empty($issuedAt)) {
return $issued_at; return $issuedAt;
} }
if ($document) { if ($document) {
return $document->issued_at; return $document->issued_at;
} }
switch ($type) { $issued_at = $type . '_at';
case 'bill':
case 'expense': if (request()->has($issued_at)) {
case 'purchase': $issuedAt = request()->get($issued_at);
$issued_at = request()->get('billed_at', Date::now()->toDateString()); } else {
break; request()->get('invoiced_at', Date::now()->toDateString());
default:
$issued_at = request()->get('invoiced_at', Date::now()->toDateString());
break;
} }
return $issued_at; return $issuedAt;
} }
protected function getDocumentNumber($type, $document, $document_number) protected function getDocumentNumber($type, $document, $document_number)
@ -514,15 +511,10 @@ abstract class DocumentForm extends Base
return $document->document_number; return $document->document_number;
} }
switch ($type) { $document_number = $this->getNextDocumentNumber($type);
case 'bill':
case 'expense': if (empty($document_number)) {
case 'purchase': $document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE);
$document_number = $this->getNextDocumentNumber(Document::BILL_TYPE);
break;
default:
$document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE);
break;
} }
return $document_number; return $document_number;
@ -538,6 +530,8 @@ abstract class DocumentForm extends Base
return $document->due_at; return $document->due_at;
} }
$addDays = (setting($type . '.payment_terms', 0)) ? setting($type . '.payment_terms', 0) : setting('invoice.payment_terms', 0);
switch ($type) { switch ($type) {
case 'bill': case 'bill':
case 'expense': case 'expense':
@ -545,7 +539,7 @@ abstract class DocumentForm extends Base
$due_at = request()->get('billed_at', Date::now()->toDateString()); $due_at = request()->get('billed_at', Date::now()->toDateString());
break; break;
default: default:
$due_at = Date::parse(request()->get('invoiced_at', Date::now()->toDateString()))->addDays(setting('invoice.payment_terms', 0))->toDateString(); $due_at = Date::parse(request()->get('invoiced_at', Date::now()->toDateString()))->addDays($addDays)->toDateString();
break; break;
} }

View File

@ -292,13 +292,7 @@ abstract class DocumentIndex extends Base
return $page; return $page;
} }
$route = $this->getRouteFromConfig($type, 'update'); return config('type.' . $type . '.route.prefix', 'invoices');
if (!empty($route)) {
return $route;
}
return config("type.{$type}.route.prefix");
} }
protected function getDocsPath($type, $docsPath) protected function getDocsPath($type, $docsPath)
@ -307,6 +301,12 @@ abstract class DocumentIndex extends Base
return $docsPath; return $docsPath;
} }
$docs_path = config('type.' . $type . '.docs_path');
if (!empty($docs_path)) {
return $docs_path;
}
switch ($type) { switch ($type) {
case 'sale': case 'sale':
case 'income': case 'income':
@ -402,17 +402,22 @@ abstract class DocumentIndex extends Base
return $searchStringModel; return $searchStringModel;
} }
switch ($type) { $search_string_model = config('type.' . $type . '.search_string_model');
case 'sale':
case 'income': if (!empty($search_string_model)) {
case 'invoice': return $search_string_model;
$searchStringModel = 'App\Models\Sale\Invoice'; }
break;
case 'bill': if ($group = config('type.' . $type . '.group')) {
case 'expense': $group = Str::studly(Str::plural($group, 1)) . '\\';
case 'purchase': }
$searchStringModel = 'App\Models\Purchase\Bill';
break; $prefix = Str::studly(Str::plural(config('type.' . $type . '.route.prefix'), 1))
if ($alias = config('type.' . $type . '.alias')) {
$searchStringModel = 'Modules\\' . Str::studly($alias) .'\Models\\' . $group . $prefix;
} else {
$searchStringModel = 'App\Models\\' . $group . $prefix;
} }
return $searchStringModel; return $searchStringModel;
@ -441,17 +446,32 @@ abstract class DocumentIndex extends Base
return $bulkActions; return $bulkActions;
} }
switch ($type) { $bulk_actions = config('type.' . $type . '.bulk_actions');
case 'sale':
case 'income': if (!empty($bulk_actions)) {
case 'invoice': return $bulk_actions;
$bulkActionClass = 'App\BulkActions\Sales\Invoices'; }
break;
case 'bill': $file_name = '';
case 'expense':
case 'purchase': if ($group = config('type.' . $type . '.group')) {
$bulkActionClass = 'App\BulkActions\Purchases\Bills'; $file_name .= Str::studly($group) . '\\';
break; }
if ($prefix = config('type.' . $type . '.route.prefix')) {
$file_name .= Str::studly($prefix);
}
if ($alias = config('type.' . $type . '.alias')) {
$module = module($alias);
if (!$module instanceof Module) {
return;
}
$bulkActionClass = 'Modules\\' . $module->getStudlyName() . '\BulkActions\\' . $file_name;
} else {
$bulkActionClass = 'App\BulkActions\\' . $file_name;
} }
if (class_exists($bulkActionClass)) { if (class_exists($bulkActionClass)) {
@ -496,6 +516,12 @@ abstract class DocumentIndex extends Base
return $classBulkAction; return $classBulkAction;
} }
$class = $this->getTextFromConfig($type, 'bulk_action');
if (!empty($class)) {
return $class;
}
return 'col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block'; return 'col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block';
} }
@ -524,6 +550,12 @@ abstract class DocumentIndex extends Base
return $classDocumentNumber; return $classDocumentNumber;
} }
$class = $this->getTextFromConfig($type, 'document_number');
if (!empty($class)) {
return $class;
}
return 'col-md-2 col-lg-1 col-xl-1 d-none d-md-block'; return 'col-md-2 col-lg-1 col-xl-1 d-none d-md-block';
} }
@ -554,6 +586,12 @@ abstract class DocumentIndex extends Base
return $classContactName; return $classContactName;
} }
$class = $this->getTextFromConfig($type, 'contact_name');
if (!empty($class)) {
return $class;
}
return 'col-xs-4 col-sm-4 col-md-4 col-lg-2 col-xl-2 text-left'; return 'col-xs-4 col-sm-4 col-md-4 col-lg-2 col-xl-2 text-left';
} }
@ -567,6 +605,12 @@ abstract class DocumentIndex extends Base
return $classAmount; return $classAmount;
} }
$class = $this->getTextFromConfig($type, 'amount');
if (!empty($class)) {
return $class;
}
return 'col-xs-4 col-sm-4 col-md-3 col-lg-2 col-xl-2 text-right'; return 'col-xs-4 col-sm-4 col-md-3 col-lg-2 col-xl-2 text-right';
} }
@ -606,6 +650,12 @@ abstract class DocumentIndex extends Base
return $classIssuedAt; return $classIssuedAt;
} }
$class = $this->getTextFromConfig($type, 'issued_at');
if (!empty($class)) {
return $class;
}
return 'col-lg-2 col-xl-2 d-none d-lg-block text-left'; return 'col-lg-2 col-xl-2 d-none d-lg-block text-left';
} }
@ -630,6 +680,12 @@ abstract class DocumentIndex extends Base
return $classDueAt; return $classDueAt;
} }
$class = $this->getTextFromConfig($type, 'due_at');
if (!empty($class)) {
return $class;
}
if ($classDueAt = $this->getClass('classDueAt')) { if ($classDueAt = $this->getClass('classDueAt')) {
return $classDueAt; return $classDueAt;
} }
@ -664,6 +720,12 @@ abstract class DocumentIndex extends Base
return $classStatus; return $classStatus;
} }
$class = $this->getTextFromConfig($type, 'status');
if (!empty($class)) {
return $class;
}
return 'col-lg-1 col-xl-1 d-none d-lg-block text-center'; return 'col-lg-1 col-xl-1 d-none d-lg-block text-center';
} }
@ -677,6 +739,12 @@ abstract class DocumentIndex extends Base
return $classActions; return $classActions;
} }
$class = $this->getTextFromConfig($type, 'actions');
if (!empty($class)) {
return $class;
}
return 'col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center'; return 'col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center';
} }

View File

@ -553,16 +553,12 @@ abstract class DocumentShow extends Base
return $documentTemplate; return $documentTemplate;
} }
$documentTemplate = 'default'; if ($template = config('type.' . $type . 'template', false)) {
return $template;
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$documentTemplate = setting('invoice.template', 'default');
break;
} }
$documentTemplate = setting($type . '.template', 'default');
return $documentTemplate; return $documentTemplate;
} }
@ -963,6 +959,12 @@ abstract class DocumentShow extends Base
return $classHeaderStatus; return $classHeaderStatus;
} }
$class = $this->getTextFromConfig($type, 'header_status');
if (!empty($class)) {
return $class;
}
return 'col-md-2'; return 'col-md-2';
} }
@ -972,6 +974,12 @@ abstract class DocumentShow extends Base
return $classHeaderContact; return $classHeaderContact;
} }
$class = $this->getTextFromConfig($type, 'header_contact');
if (!empty($class)) {
return $class;
}
return 'col-md-6'; return 'col-md-6';
} }
@ -981,6 +989,12 @@ abstract class DocumentShow extends Base
return $classHeaderAmount; return $classHeaderAmount;
} }
$class = $this->getTextFromConfig($type, 'header_amount');
if (!empty($class)) {
return $class;
}
return 'col-md-2'; return 'col-md-2';
} }
@ -990,6 +1004,12 @@ abstract class DocumentShow extends Base
return $classHeaderDueAt; return $classHeaderDueAt;
} }
$class = $this->getTextFromConfig($type, 'header_due_at');
if (!empty($class)) {
return $class;
}
return 'col-md-2'; return 'col-md-2';
} }
@ -1001,6 +1021,10 @@ abstract class DocumentShow extends Base
$hideTimelineStatuses = ['paid', 'cancelled']; $hideTimelineStatuses = ['paid', 'cancelled'];
if ($timelime_statuses = config('type.' . $type . 'timeline_statuses')) {
$hideTimelineStatuses = $timelime_statuses;
}
return $hideTimelineStatuses; return $hideTimelineStatuses;
} }

View File

@ -175,18 +175,12 @@ abstract class DocumentTemplate extends Base
return $documentTemplate; return $documentTemplate;
} }
// $documentTemplate = 'components.documents.template.default'; if ($template = config('type.' . $type . 'template', false)) {
$documentTemplate = 'default'; return $template;
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
// $documentTemplate = 'components.documents.template.' . setting('invoice.template', 'default');
$documentTemplate = setting('invoice.template', 'default');
break;
} }
$documentTemplate = setting($type . '.template', 'default');
return $documentTemplate; return $documentTemplate;
} }
@ -229,19 +223,12 @@ abstract class DocumentTemplate extends Base
return $backgroundColor; return $backgroundColor;
} }
$backgroundColor = '#55588b'; if ($background_color = config('type.' . $type . 'color', false)) {
return $background_color;
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$backgroundColor = setting('bill.color');
break;
default:
$backgroundColor = setting('invoice.color');
break;
} }
$backgroundColor = setting($type . '.color', '#55588b');
return $backgroundColor; return $backgroundColor;
} }