2020-12-24 01:28:38 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Abstracts\View\Components;
|
|
|
|
|
2021-01-10 15:43:51 +03:00
|
|
|
use Akaunting\Module\Module;
|
2021-01-09 17:47:52 +03:00
|
|
|
use App\Abstracts\View\Components\Document as Base;
|
2020-12-24 01:28:38 +03:00
|
|
|
use App\Events\Common\BulkActionsAdding;
|
2021-01-09 17:47:52 +03:00
|
|
|
use Illuminate\Support\Str;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 17:47:52 +03:00
|
|
|
abstract class DocumentIndex extends Base
|
2020-12-24 01:28:38 +03:00
|
|
|
{
|
|
|
|
/** @var string */
|
|
|
|
public $type;
|
|
|
|
|
|
|
|
public $documents;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $page;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $docsPath;
|
|
|
|
|
|
|
|
/** @var bool */
|
2021-01-06 16:35:28 +03:00
|
|
|
public $checkPermissionCreate;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $createRoute;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $importRoute;
|
|
|
|
|
|
|
|
/** @var array */
|
|
|
|
public $importRouteParameters;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $exportRoute;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideCreate;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideImport;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideExport;
|
|
|
|
|
|
|
|
/* -- Card Header Start -- */
|
|
|
|
/** @var string */
|
|
|
|
public $textBulkAction;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $bulkActionClass;
|
|
|
|
|
|
|
|
/** @var array */
|
|
|
|
public $bulkActions;
|
|
|
|
|
|
|
|
/** @var array */
|
|
|
|
public $bulkActionRouteParameters;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $formCardHeaderRoute;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideBulkAction;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $classBulkAction;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $searchStringModel;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideSearchString;
|
|
|
|
/* -- Card Header End -- */
|
|
|
|
|
|
|
|
/* -- Card Body Start -- */
|
|
|
|
/** @var string */
|
|
|
|
public $textDocumentNumber;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $textContactName;
|
|
|
|
|
|
|
|
/** @var string */
|
2020-12-31 13:08:50 +06:00
|
|
|
public $textIssuedAt;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $textDueAt;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $textDocumentStatus;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $checkButtonReconciled;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $checkButtonCancelled;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideDocumentNumber;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $classDocumentNumber;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideContactName;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $classContactName;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideAmount;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $classAmount;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideIssuedAt;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $classIssuedAt;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideDueAt;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $classDueAt;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideStatus;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $classStatus;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideActions;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $routeButtonShow;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $routeButtonEdit;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $routeButtonDuplicate;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $routeButtonCancelled;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $routeButtonDelete;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideButtonShow;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideButtonEdit;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideButtonDuplicate;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideButtonCancel;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
public $hideButtonDelete;
|
|
|
|
|
|
|
|
/** @var string */
|
2021-01-06 16:35:28 +03:00
|
|
|
public $permissionCreate;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-01-06 16:35:28 +03:00
|
|
|
public $permissionUpdate;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2021-01-06 16:35:28 +03:00
|
|
|
public $permissionDelete;
|
2020-12-24 01:28:38 +03:00
|
|
|
/* -- Card Body End -- */
|
|
|
|
|
|
|
|
public $limits;
|
|
|
|
|
|
|
|
public $hideEmptyPage;
|
|
|
|
|
|
|
|
public $classActions;
|
|
|
|
|
|
|
|
public $class_count;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new component instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
string $type, $documents = [], string $page = '', string $docsPath = '', $limits = [], $hideEmptyPage = false,
|
2021-01-06 16:35:28 +03:00
|
|
|
bool $checkPermissionCreate = true, string $createRoute = '', string $importRoute = '', array $importRouteParameters = [], string $exportRoute = '',
|
2020-12-24 01:28:38 +03:00
|
|
|
bool $hideCreate = false, bool $hideImport = false, bool $hideExport = false, // Advanced
|
|
|
|
string $textBulkAction = '', array $bulkActions = [], string $bulkActionClass = '', array $bulkActionRouteParameters = [], string $formCardHeaderRoute = '', string $searchStringModel = '',
|
|
|
|
bool $hideBulkAction = false, bool $hideSearchString = false,
|
|
|
|
string $classActions = '', string $classBulkAction = '', string $classDocumentNumber = '', string $classContactName = '', string $classIssuedAt = '', string $classDueAt = '', string $classStatus = '',
|
2020-12-31 13:08:50 +06:00
|
|
|
string $textDocumentNumber = '', string $textContactName = '', string $classAmount = '', string $textIssuedAt = '', string $textDueAt = '', string $textDocumentStatus = '',
|
2020-12-24 01:28:38 +03:00
|
|
|
bool $checkButtonReconciled = true, bool $checkButtonCancelled = true,
|
|
|
|
string $routeButtonShow = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonCancelled = '', string $routeButtonDelete = '',
|
|
|
|
bool $hideDocumentNumber = false, bool $hideContactName = false, bool $hideAmount = false, bool $hideIssuedAt = false, bool $hideDueAt = false, bool $hideStatus = false, bool $hideActions = false,
|
|
|
|
bool $hideButtonShow = false, bool $hideButtonEdit = false, bool $hideButtonDuplicate = false, bool $hideButtonCancel = false, bool $hideButtonDelete = false,
|
2021-01-06 16:35:28 +03:00
|
|
|
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = ''
|
2020-12-24 01:28:38 +03:00
|
|
|
) {
|
|
|
|
$this->type = $type;
|
|
|
|
$this->documents = $documents;
|
|
|
|
$this->page = $this->getPage($type, $page);
|
|
|
|
$this->docsPath = $this->getDocsPath($type, $docsPath);
|
|
|
|
$this->hideEmptyPage = $hideEmptyPage;
|
|
|
|
|
|
|
|
/* -- Top Buttons Start -- */
|
2021-01-06 16:35:28 +03:00
|
|
|
$this->checkPermissionCreate = $checkPermissionCreate;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
|
|
|
$this->createRoute = $this->getCreateRoute($type, $createRoute);
|
|
|
|
$this->importRoute = $this->getImportRoute($importRoute);
|
|
|
|
$this->importRouteParameters = $this->getImportRouteParameters($type, $importRouteParameters);
|
|
|
|
$this->exportRoute = $this->getExportRoute($type, $exportRoute);
|
|
|
|
|
|
|
|
$this->hideCreate = $hideCreate;
|
|
|
|
$this->hideImport = $hideImport;
|
|
|
|
$this->hideExport = $hideExport;
|
|
|
|
/* -- Top Buttons End -- */
|
|
|
|
|
|
|
|
/* -- Card Header Start -- */
|
|
|
|
$this->textBulkAction = $this->getTextBulkAction($type, $textBulkAction);
|
|
|
|
$this->bulkActionClass = $bulkActionClass;
|
|
|
|
$this->bulkActions = $this->getBulkActions($type, $bulkActions, $bulkActionClass);
|
|
|
|
|
|
|
|
$this->bulkActionRouteParameters = $this->getBulkActionRouteParameters($type, $bulkActionRouteParameters);
|
|
|
|
|
|
|
|
$this->formCardHeaderRoute = $this->getRoute($type, $formCardHeaderRoute);
|
|
|
|
|
|
|
|
$this->searchStringModel = $this->getSearchStringModel($type, $searchStringModel);
|
|
|
|
|
|
|
|
$this->hideBulkAction = $hideBulkAction;
|
|
|
|
$this->hideSearchString = $hideSearchString;
|
|
|
|
/* -- Card Header End -- */
|
|
|
|
|
|
|
|
/* -- Card Body Start -- */
|
2021-01-09 23:24:59 +03:00
|
|
|
$this->textDocumentNumber = $this->getTextDocumentNumber($type, $textDocumentNumber);
|
2020-12-24 01:28:38 +03:00
|
|
|
$this->textContactName = $this->getTextContactName($type, $textContactName);
|
2020-12-31 13:08:50 +06:00
|
|
|
$this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt);
|
2020-12-24 01:28:38 +03:00
|
|
|
$this->textDueAt = $this->getTextDueAt($type, $textDueAt);
|
|
|
|
$this->textDocumentStatus = $this->getTextDocumentStatus($type, $textDocumentStatus);
|
|
|
|
|
|
|
|
$this->checkButtonReconciled = $checkButtonReconciled;
|
|
|
|
$this->checkButtonCancelled = $checkButtonCancelled;
|
|
|
|
|
|
|
|
$this->routeButtonShow = $this->getRouteButtonShow($type, $routeButtonShow);
|
|
|
|
$this->routeButtonEdit = $this->getRouteButtonEdit($type, $routeButtonEdit);
|
|
|
|
$this->routeButtonDuplicate = $this->getRouteButtonDuplicate($type, $routeButtonDuplicate);
|
|
|
|
$this->routeButtonCancelled = $this->getRouteButtonCancelled($type, $routeButtonCancelled);
|
|
|
|
$this->routeButtonDelete = $this->getRouteButtonDelete($type, $routeButtonDelete);
|
|
|
|
|
|
|
|
$this->hideBulkAction = $hideBulkAction;
|
|
|
|
$this->hideDocumentNumber = $hideDocumentNumber;
|
|
|
|
$this->hideContactName = $hideContactName;
|
|
|
|
$this->hideAmount = $hideAmount;
|
|
|
|
$this->hideIssuedAt = $hideIssuedAt;
|
|
|
|
$this->hideDueAt = $hideDueAt;
|
|
|
|
$this->hideStatus = $hideStatus;
|
|
|
|
$this->hideActions = $hideActions;
|
|
|
|
|
|
|
|
$this->class_count = 12;
|
|
|
|
|
|
|
|
$this->calculateClass();
|
|
|
|
|
|
|
|
$this->classBulkAction = $this->getClassBulkAction($type, $classBulkAction);
|
|
|
|
$this->classDocumentNumber = $this->getClassDocumentNumber($type, $classDocumentNumber);
|
|
|
|
$this->classContactName = $this->getClassContactName($type, $classContactName);
|
|
|
|
$this->classAmount = $this->getClassAmount($type, $classAmount);
|
2021-01-09 20:38:45 +03:00
|
|
|
$this->classIssuedAt = $this->getClassIssuedAt($type, $classIssuedAt);
|
2020-12-24 01:28:38 +03:00
|
|
|
$this->classDueAt = $this->getClassDueAt($type, $classDueAt);
|
|
|
|
$this->classStatus = $this->getClassStatus($type, $classStatus);
|
|
|
|
$this->classActions = $this->getClassActions($type, $classActions);
|
|
|
|
|
|
|
|
$this->hideButtonShow = $hideButtonShow;
|
|
|
|
$this->hideButtonEdit = $hideButtonEdit;
|
|
|
|
$this->hideButtonDuplicate = $hideButtonDuplicate;
|
|
|
|
$this->hideButtonCancel = $hideButtonCancel;
|
|
|
|
$this->hideButtonDelete = $hideButtonDelete;
|
|
|
|
|
2021-01-06 16:35:28 +03:00
|
|
|
$this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
|
|
|
|
$this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate);
|
|
|
|
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
|
2020-12-24 01:28:38 +03:00
|
|
|
/* -- Card Body End -- */
|
|
|
|
|
|
|
|
$this->limits = ($limits) ? $limits : ['10' => '10', '25' => '25', '50' => '50', '100' => '100'];
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getPage($type, $page)
|
|
|
|
{
|
|
|
|
if (!empty($page)) {
|
|
|
|
return $page;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
return config('type.' . $type . '.route.prefix', 'invoices');
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getDocsPath($type, $docsPath)
|
|
|
|
{
|
|
|
|
if (!empty($docsPath)) {
|
|
|
|
return $docsPath;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
$docs_path = config('type.' . $type . '.docs_path');
|
|
|
|
|
|
|
|
if (!empty($docs_path)) {
|
|
|
|
return $docs_path;
|
|
|
|
}
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
switch ($type) {
|
|
|
|
case 'sale':
|
|
|
|
case 'income':
|
|
|
|
case 'invoice':
|
|
|
|
$docsPath = 'sales/invoices';
|
|
|
|
break;
|
|
|
|
case 'bill':
|
|
|
|
case 'expense':
|
|
|
|
case 'purchase':
|
|
|
|
$docsPath = 'purchases/bills';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $docsPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getCreateRoute($type, $createRoute)
|
|
|
|
{
|
|
|
|
if (!empty($createRoute)) {
|
|
|
|
return $createRoute;
|
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
$route = $this->getRouteFromConfig($type, 'create');
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
if (!empty($route)) {
|
|
|
|
return $route;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
return 'invoices.create';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getImportRoute($importRoute)
|
|
|
|
{
|
|
|
|
if (!empty($importRoute)) {
|
|
|
|
return $importRoute;
|
|
|
|
}
|
|
|
|
|
|
|
|
$route = 'import.create';
|
|
|
|
|
|
|
|
return $route;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getImportRouteParameters($type, $importRouteParameters)
|
|
|
|
{
|
|
|
|
if (!empty($importRouteParameters)) {
|
|
|
|
return $importRouteParameters;
|
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
$route = $this->getRouteFromConfig($type, 'import');
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
$importRouteParameters = [
|
2021-01-09 20:38:45 +03:00
|
|
|
'group' => config('type.' . $type . '.group'),
|
|
|
|
'type' => config('type.' . $type . '.route.prefix'),
|
|
|
|
'route' => ($route) ? $route : 'invoices.import',
|
2020-12-24 01:28:38 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
return $importRouteParameters;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getExportRoute($type, $exportRoute)
|
|
|
|
{
|
|
|
|
if (!empty($exportRoute)) {
|
|
|
|
return $exportRoute;
|
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
$route = $this->getRouteFromConfig($type, 'export');
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
if (!empty($route)) {
|
|
|
|
return $route;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
return 'invoices.export';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getRoute($type, $formCardHeaderRoute)
|
|
|
|
{
|
|
|
|
if (!empty($formCardHeaderRoute)) {
|
|
|
|
return $formCardHeaderRoute;
|
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
$route = $this->getRouteFromConfig($type, 'index');
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
if (!empty($route)) {
|
|
|
|
return $route;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
return 'invoices.index';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getSearchStringModel($type, $searchStringModel)
|
|
|
|
{
|
|
|
|
if (!empty($searchStringModel)) {
|
|
|
|
return $searchStringModel;
|
|
|
|
}
|
2021-01-09 22:31:26 +03:00
|
|
|
|
|
|
|
$search_string_model = config('type.' . $type . '.search_string_model');
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
if (!empty($search_string_model)) {
|
|
|
|
return $search_string_model;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($group = config('type.' . $type . '.group')) {
|
|
|
|
$group = Str::studly(Str::plural($group, 1)) . '\\';
|
|
|
|
}
|
|
|
|
|
2021-01-09 23:08:31 +03:00
|
|
|
$prefix = Str::studly(Str::plural(config('type.' . $type . '.route.prefix'), 1));
|
2021-01-09 22:31:26 +03:00
|
|
|
|
|
|
|
if ($alias = config('type.' . $type . '.alias')) {
|
|
|
|
$searchStringModel = 'Modules\\' . Str::studly($alias) .'\Models\\' . $group . $prefix;
|
|
|
|
} else {
|
|
|
|
$searchStringModel = 'App\Models\\' . $group . $prefix;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $searchStringModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTextBulkAction($type, $textBulkAction)
|
|
|
|
{
|
|
|
|
if (!empty($textBulkAction)) {
|
|
|
|
return $textBulkAction;
|
|
|
|
}
|
2021-01-09 18:24:16 +03:00
|
|
|
|
|
|
|
$default_key = config('type.' . $type . '.translation.prefix');
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 18:24:16 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'bulk_action', $default_key, 'trans_choice');
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 17:47:52 +03:00
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'general.invoices';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getBulkActions($type, $bulkActions, $bulkActionClass)
|
|
|
|
{
|
|
|
|
if (!empty($bulkActions)) {
|
|
|
|
return $bulkActions;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
$bulk_actions = config('type.' . $type . '.bulk_actions');
|
|
|
|
|
|
|
|
if (!empty($bulk_actions)) {
|
|
|
|
return $bulk_actions;
|
|
|
|
}
|
|
|
|
|
|
|
|
$file_name = '';
|
|
|
|
|
|
|
|
if ($group = config('type.' . $type . '.group')) {
|
|
|
|
$file_name .= Str::studly($group) . '\\';
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2021-01-10 15:43:51 +03:00
|
|
|
$b = new \stdClass();
|
|
|
|
$b->actions = [];
|
|
|
|
|
|
|
|
event(new BulkActionsAdding($b));
|
|
|
|
|
|
|
|
return $b->actions;
|
2021-01-09 22:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$bulkActionClass = 'Modules\\' . $module->getStudlyName() . '\BulkActions\\' . $file_name;
|
|
|
|
} else {
|
|
|
|
$bulkActionClass = 'App\BulkActions\\' . $file_name;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (class_exists($bulkActionClass)) {
|
|
|
|
event(new BulkActionsAdding(app($bulkActionClass)));
|
|
|
|
|
|
|
|
$bulkActions = app($bulkActionClass)->actions;
|
|
|
|
} else {
|
|
|
|
$b = new \stdClass();
|
|
|
|
$b->actions = [];
|
|
|
|
|
|
|
|
event(new BulkActionsAdding($b));
|
|
|
|
|
|
|
|
$bulkActions = $b->actions;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $bulkActions;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getBulkActionRouteParameters($type, $bulkActionRouteParameters)
|
|
|
|
{
|
|
|
|
if (!empty($bulkActionRouteParameters)) {
|
|
|
|
return $bulkActionRouteParameters;
|
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
$group = config('type.' . $type . '.group');
|
|
|
|
|
|
|
|
if (!empty(config('type.' . $type . '.alias'))) {
|
|
|
|
$group = config('type.' . $type . '.alias');
|
|
|
|
}
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
$bulkActionRouteParameters = [
|
2021-01-09 20:38:45 +03:00
|
|
|
'group' => $group,
|
|
|
|
'type' => config('type.' . $type . '.route.prefix')
|
2020-12-24 01:28:38 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
return $bulkActionRouteParameters;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getClassBulkAction($type, $classBulkAction)
|
|
|
|
{
|
|
|
|
if (!empty($classBulkAction)) {
|
|
|
|
return $classBulkAction;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
$class = $this->getTextFromConfig($type, 'bulk_action');
|
|
|
|
|
|
|
|
if (!empty($class)) {
|
|
|
|
return $class;
|
|
|
|
}
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
return 'col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block';
|
|
|
|
}
|
|
|
|
|
2021-01-09 23:24:59 +03:00
|
|
|
protected function getTextDocumentNumber($type, $textDocumentNumber)
|
2020-12-24 01:28:38 +03:00
|
|
|
{
|
|
|
|
if (!empty($textDocumentNumber)) {
|
|
|
|
return $textDocumentNumber;
|
|
|
|
}
|
|
|
|
|
2021-01-09 17:47:52 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'document_number', 'numbers');
|
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
|
|
|
}
|
|
|
|
|
2020-12-25 13:30:12 +03:00
|
|
|
return 'general.numbers';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getClassDocumentNumber($type, $classDocumentNumber)
|
|
|
|
{
|
|
|
|
if (!empty($classDocumentNumber)) {
|
|
|
|
return $classDocumentNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($classDocumentNumber = $this->getClass('classDocumentNumber')) {
|
|
|
|
return $classDocumentNumber;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
$class = $this->getTextFromConfig($type, 'document_number');
|
|
|
|
|
|
|
|
if (!empty($class)) {
|
|
|
|
return $class;
|
|
|
|
}
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
return 'col-md-2 col-lg-1 col-xl-1 d-none d-md-block';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTextContactName($type, $textContactName)
|
|
|
|
{
|
|
|
|
if (!empty($textContactName)) {
|
|
|
|
return $textContactName;
|
|
|
|
}
|
|
|
|
|
2021-01-09 18:24:16 +03:00
|
|
|
$default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
|
2021-01-09 17:47:52 +03:00
|
|
|
|
2021-01-09 18:24:16 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'contact_name', $default_key, 'trans_choice');
|
2021-01-09 17:47:52 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 17:47:52 +03:00
|
|
|
return 'general.customers';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getClassContactName($type, $classContactName)
|
|
|
|
{
|
|
|
|
if (!empty($classContactName)) {
|
|
|
|
return $classContactName;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($classContactName = $this->getClass('classContactName')) {
|
|
|
|
return $classContactName;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
$class = $this->getTextFromConfig($type, 'contact_name');
|
|
|
|
|
|
|
|
if (!empty($class)) {
|
|
|
|
return $class;
|
|
|
|
}
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
return 'col-xs-4 col-sm-4 col-md-4 col-lg-2 col-xl-2 text-left';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getClassAmount($type, $classAmount)
|
|
|
|
{
|
|
|
|
if (!empty($classAmount)) {
|
|
|
|
return $classAmount;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($classAmount = $this->getClass('classAmount')) {
|
|
|
|
return $classAmount;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
$class = $this->getTextFromConfig($type, 'amount');
|
|
|
|
|
|
|
|
if (!empty($class)) {
|
|
|
|
return $class;
|
|
|
|
}
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
return 'col-xs-4 col-sm-4 col-md-3 col-lg-2 col-xl-2 text-right';
|
|
|
|
}
|
|
|
|
|
2020-12-31 13:08:50 +06:00
|
|
|
protected function getTextIssuedAt($type, $textIssuedAt)
|
2020-12-24 01:28:38 +03:00
|
|
|
{
|
2020-12-31 13:08:50 +06:00
|
|
|
if (!empty($textIssuedAt)) {
|
|
|
|
return $textIssuedAt;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 18:24:16 +03:00
|
|
|
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);
|
2021-01-09 17:47:52 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 17:47:52 +03:00
|
|
|
return 'invoices.invoice_date';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
protected function getClassIssuedAt($type, $classIssuedAt)
|
2020-12-24 01:28:38 +03:00
|
|
|
{
|
|
|
|
if (!empty($classIssuedAt)) {
|
|
|
|
return $classIssuedAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($classIssuedAt = $this->getClass('classIssuedAt')) {
|
|
|
|
return $classIssuedAt;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
$class = $this->getTextFromConfig($type, 'issued_at');
|
|
|
|
|
|
|
|
if (!empty($class)) {
|
|
|
|
return $class;
|
|
|
|
}
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
return 'col-lg-2 col-xl-2 d-none d-lg-block text-left';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTextDueAt($type, $textDueAt)
|
|
|
|
{
|
|
|
|
if (!empty($textDueAt)) {
|
|
|
|
return $textDueAt;
|
|
|
|
}
|
|
|
|
|
2021-01-09 18:24:16 +03:00
|
|
|
$translation = $this->getTextFromConfig($type, 'due_at', 'due_date');
|
2021-01-09 17:47:52 +03:00
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 17:47:52 +03:00
|
|
|
return 'invoices.due_date';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getClassDueAt($type, $classDueAt)
|
|
|
|
{
|
|
|
|
if (!empty($classDueAt)) {
|
|
|
|
return $classDueAt;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
$class = $this->getTextFromConfig($type, 'due_at');
|
|
|
|
|
|
|
|
if (!empty($class)) {
|
|
|
|
return $class;
|
|
|
|
}
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
if ($classDueAt = $this->getClass('classDueAt')) {
|
|
|
|
return $classDueAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'col-lg-2 col-xl-2 d-none d-lg-block text-left';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTextDocumentStatus($type, $textDocumentStatus)
|
|
|
|
{
|
|
|
|
if (!empty($textDocumentStatus)) {
|
|
|
|
return $textDocumentStatus;
|
|
|
|
}
|
|
|
|
|
2021-01-09 18:24:16 +03:00
|
|
|
$default_key = config('type.' . $type . '.translation.prefix') . '.statuses.';
|
2021-01-09 17:47:52 +03:00
|
|
|
|
|
|
|
$translation = $this->getTextFromConfig($type, 'document_status', $default_key);
|
|
|
|
|
|
|
|
if (!empty($translation)) {
|
|
|
|
return $translation;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
2020-12-25 13:30:12 +03:00
|
|
|
|
2021-01-09 17:47:52 +03:00
|
|
|
return 'invoices.statuses.';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getClassStatus($type, $classStatus)
|
|
|
|
{
|
|
|
|
if (!empty($classStatus)) {
|
|
|
|
return $classStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($classStatus = $this->getClass('classStatus')) {
|
|
|
|
return $classStatus;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
$class = $this->getTextFromConfig($type, 'status');
|
|
|
|
|
|
|
|
if (!empty($class)) {
|
|
|
|
return $class;
|
|
|
|
}
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
return 'col-lg-1 col-xl-1 d-none d-lg-block text-center';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getClassActions($type, $classActions)
|
|
|
|
{
|
|
|
|
if (!empty($classActions)) {
|
|
|
|
return $classActions;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($classActions = $this->getClass('classActions')) {
|
|
|
|
return $classActions;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:31:26 +03:00
|
|
|
$class = $this->getTextFromConfig($type, 'actions');
|
|
|
|
|
|
|
|
if (!empty($class)) {
|
|
|
|
return $class;
|
|
|
|
}
|
|
|
|
|
2020-12-24 01:28:38 +03:00
|
|
|
return 'col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getRouteButtonShow($type, $routeButtonShow)
|
|
|
|
{
|
|
|
|
if (!empty($routeButtonShow)) {
|
|
|
|
return $routeButtonShow;
|
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
//example route parameter.
|
|
|
|
$parameter = 1;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
$route = $this->getRouteFromConfig($type, 'show', $parameter);
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
if (!empty($route)) {
|
|
|
|
return $route;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
return 'invoices.show';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getRouteButtonEdit($type, $routeButtonEdit)
|
|
|
|
{
|
|
|
|
if (!empty($routeButtonEdit)) {
|
|
|
|
return $routeButtonEdit;
|
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
//example route parameter.
|
|
|
|
$parameter = 1;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
$route = $this->getRouteFromConfig($type, 'edit', $parameter);
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
if (!empty($route)) {
|
|
|
|
return $route;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
return 'invoices.edit';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getRouteButtonDuplicate($type, $routeButtonDuplicate)
|
|
|
|
{
|
|
|
|
if (!empty($routeButtonDuplicate)) {
|
|
|
|
return $routeButtonDuplicate;
|
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
//example route parameter.
|
|
|
|
$parameter = 1;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
$route = $this->getRouteFromConfig($type, 'duplicate', $parameter);
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
if (!empty($route)) {
|
|
|
|
return $route;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
return 'invoices.duplicate';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getRouteButtonCancelled($type, $routeButtonCancelled)
|
|
|
|
{
|
|
|
|
if (!empty($routeButtonCancelled)) {
|
|
|
|
return $routeButtonCancelled;
|
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
//example route parameter.
|
|
|
|
$parameter = 1;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
$route = $this->getRouteFromConfig($type, 'cancelled', $parameter);
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
if (!empty($route)) {
|
|
|
|
return $route;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
return 'invoices.cancelled';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getRouteButtonDelete($type, $routeButtonDelete)
|
|
|
|
{
|
|
|
|
if (!empty($routeButtonDelete)) {
|
|
|
|
return $routeButtonDelete;
|
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
//example route parameter.
|
|
|
|
$parameter = 1;
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
$route = $this->getRouteFromConfig($type, 'destroy', $parameter);
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
if (!empty($route)) {
|
|
|
|
return $route;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 20:38:45 +03:00
|
|
|
return 'invoices.destroy';
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-06 16:35:28 +03:00
|
|
|
protected function getPermissionCreate($type, $permissionCreate)
|
2020-12-24 01:28:38 +03:00
|
|
|
{
|
2021-01-06 16:35:28 +03:00
|
|
|
if (!empty($permissionCreate)) {
|
|
|
|
return $permissionCreate;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 19:16:30 +03:00
|
|
|
$permissionCreate = $this->getPermissionFromConfig($type, 'create');
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-06 16:35:28 +03:00
|
|
|
return $permissionCreate;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-06 16:35:28 +03:00
|
|
|
protected function getPermissionUpdate($type, $permissionUpdate)
|
2020-12-24 01:28:38 +03:00
|
|
|
{
|
2021-01-06 16:35:28 +03:00
|
|
|
if (!empty($permissionUpdate)) {
|
|
|
|
return $permissionUpdate;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 19:16:30 +03:00
|
|
|
$permissionUpdate = $this->getPermissionFromConfig($type, 'update');
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-06 16:35:28 +03:00
|
|
|
return $permissionUpdate;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-06 16:35:28 +03:00
|
|
|
protected function getPermissionDelete($type, $permissionDelete)
|
2020-12-24 01:28:38 +03:00
|
|
|
{
|
2021-01-06 16:35:28 +03:00
|
|
|
if (!empty($permissionDelete)) {
|
|
|
|
return $permissionDelete;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2021-01-09 19:16:30 +03:00
|
|
|
$permissionDelete = $this->getPermissionFromConfig($type, 'delete');
|
2020-12-24 01:28:38 +03:00
|
|
|
|
2021-01-06 16:35:28 +03:00
|
|
|
return $permissionDelete;
|
2020-12-24 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function calculateClass()
|
|
|
|
{
|
|
|
|
$hides = [
|
|
|
|
'BulkAction' => '1',
|
|
|
|
'DocumentNumber' => '1',
|
|
|
|
'ContactName' => '2',
|
|
|
|
'Amount' => '2',
|
|
|
|
'IssuedAt' => '2',
|
|
|
|
'DueAt' => '2',
|
|
|
|
'Status' => '1',
|
|
|
|
'Actions' => '1',
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach ($hides as $hide => $count) {
|
|
|
|
if ($this->{'hide'. $hide}) {
|
|
|
|
$this->class_count -= $count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getClass($type)
|
|
|
|
{
|
|
|
|
$hide_count = 12 - $this->class_count;
|
|
|
|
|
|
|
|
if (empty($hide_count)) {
|
|
|
|
//return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$class = false;
|
|
|
|
|
|
|
|
switch($type) {
|
|
|
|
case 'classDocumentNumber':
|
|
|
|
switch ($hide_count) {
|
|
|
|
case 1:
|
|
|
|
$class = 'col-md-3 col-lg-2 col-xl-2 d-none d-md-block';
|
|
|
|
$this->class_count++;
|
|
|
|
break;
|
|
|
|
case 2:
|
2020-12-31 13:45:58 +06:00
|
|
|
$class = 'col-md-4 col-lg-3 col-xl-3 d-none d-md-block';
|
2020-12-24 01:28:38 +03:00
|
|
|
$this->class_count += 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-12-31 13:45:58 +06:00
|
|
|
$class = 'col-md-5 col-lg-4 col-xl-4 d-none d-md-block';
|
2020-12-24 01:28:38 +03:00
|
|
|
$this->class_count += 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $class;
|
|
|
|
}
|
|
|
|
}
|