akaunting 3.0 (the last dance)

This commit is contained in:
Burak Civan
2022-06-01 10:15:55 +03:00
parent cead09f6d4
commit d9c0764572
3812 changed files with 126831 additions and 102949 deletions

View File

@ -0,0 +1,503 @@
<?php
namespace App\Abstracts\View\Components\Contacts;
use App\Abstracts\View\Component;
use App\Traits\ViewComponents;
abstract class Form extends Component
{
use ViewComponents;
public const OBJECT_TYPE = 'contact';
public const DEFAULT_TYPE = 'customer';
public const DEFAULT_PLURAL_TYPE = 'customers';
/* -- Main Start -- */
public $type;
public $contact;
public $model;
/* -- Main End -- */
/* -- Content Start -- */
public $formId;
public $formRoute;
public $formMethod;
/** @var bool */
public $hideSectionGeneral;
/** @var bool */
public $hideSectionBilling;
/** @var bool */
public $hideSectionAddress;
/** @var string */
public $textSectionGeneralTitle;
/** @var string */
public $textSectionGeneralDescription;
/** @var bool */
public $hideName;
/** @var string */
public $textName;
/** @var string */
public $classNameFromGroupClass;
/** @var bool */
public $hideEmail;
/** @var string */
public $textEmail;
/** @var bool */
public $hidePhone;
/** @var string */
public $textPhone;
/** @var bool */
public $hideWebsite;
/** @var string */
public $textWebsite;
/** @var bool */
public $hideReference;
/** @var string */
public $textReference;
/** @var bool */
public $hideCanLogin;
/** @var bool */
public $hideLogo;
/** @var string */
public $textSectionBillingTitle;
/** @var string */
public $textSectionBillingDescription;
/** @var bool */
public $hideTaxNumber;
/** @var string */
public $textTaxNumber;
/** @var bool */
public $hideCurrency;
/** @var string */
public $textSectionAddressTitle;
/** @var string */
public $textSectionAddressDescription;
/** @var bool */
public $hideAddress;
/** @var string */
public $textAddress;
/** @var bool */
public $hideCity;
/** @var string */
public $textCity;
/** @var bool */
public $hideZipCode;
/** @var string */
public $textZipCode;
/** @var bool */
public $hideState;
/** @var string */
public $textState;
/** @var bool */
public $hideCountry;
/** @var string */
public $cancelRoute;
/* -- Content End -- */
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $type, $model = false, $contact = false,
string $formId = 'contact', $formRoute = '', $formMethod = '',
bool $hideSectionGeneral = false, bool $hideSectionBilling = false, bool $hideSectionAddress = false,
string $textSectionGeneralTitle = '', string $textSectionGeneralDescription = '',
bool $hideName = false, string $textName = '', string $classNameFromGroupClass = '',
bool $hideEmail = false, string $textEmail = '',
bool $hidePhone = false, string $textPhone = '',
bool $hideWebsite = false, string $textWebsite = '',
bool $hideReference = false, string $textReference = '',
bool $hideCanLogin = false,
bool $hideLogo = false,
string $textSectionBillingTitle = '', string $textSectionBillingDescription = '',
bool $hideTaxNumber = false, string $textTaxNumber = '',
bool $hideCurrency = false,
string $textSectionAddressTitle = '', string $textSectionAddressDescription = '',
bool $hideAddress = false, string $textAddress = '',
bool $hideCity = false, string $textCity = '',
bool $hideZipCode = false, string $textZipCode = '',
bool $hideState = false, string $textState = '',
bool $hideCountry = false,
string $cancelRoute = ''
) {
$this->type = $type;
$this->model = ! empty($model) ? $model : $contact;
$this->contact = $this->model;
/* -- Content Start -- */
$this->formId = $formId;
$this->formRoute = $this->getFormRoute($type, $formRoute, $this->model);
$this->formMethod = $this->getFormMethod($type, $formMethod, $this->model);
$this->hideSectionGeneral = $hideSectionGeneral;
$this->hideSectionBilling = $hideSectionBilling;
$this->hideSectionAddress = $hideSectionAddress;
/* -- General Start -- */
$this->textSectionGeneralTitle = $this->getTextSectionGeneralTitle($type, $textSectionGeneralTitle);
$this->textSectionGeneralDescription = $this->getTextSectionGeneralDescription($type, $textSectionGeneralDescription);
$this->hideName = $hideName;
$this->textName = $this->getTextName($type, $textName);
$this->classNameFromGroupClass = $this->getClassNameFormGroupClass($type, $classNameFromGroupClass);
$this->hideEmail = $hideEmail;
$this->textEmail = $this->getTextEmail($type, $textEmail);
$this->hidePhone = $hidePhone;
$this->textPhone = $this->getTextPhone($type, $textPhone);
$this->hideWebsite = $hideWebsite;
$this->textWebsite = $this->getTextWebsite($type, $textWebsite);
$this->hideReference = $hideReference;
$this->textReference = $this->getTextReference($type, $textReference);
$this->hideCanLogin = $hideCanLogin;
$this->hideLogo = $hideLogo;
/* -- General End -- */
/* -- Billing Start -- */
$this->textSectionBillingTitle = $this->getTextSectionBillingTitle($type, $textSectionBillingTitle);
$this->textSectionBillingDescription = $this->getTextSectionBillingDescription($type, $textSectionBillingDescription);
$this->hideTaxNumber = $hideTaxNumber;
$this->textTaxNumber = $this->getTextTaxNumber($type, $textTaxNumber);
$this->hideCurrency = $hideCurrency;
/* -- Billing End -- */
/* -- Address Start -- */
$this->textSectionAddressTitle = $this->getTextSectionAddressTitle($type, $textSectionAddressTitle);
$this->textSectionAddressDescription = $this->getTextSectionAddressDescription($type, $textSectionAddressDescription);
$this->hideAddress = $hideAddress;
$this->textAddress = $this->getTextAddress($type, $textAddress);
$this->hideCity = $hideCity;
$this->textCity = $this->getTextCity($type, $textCity);
$this->hideZipCode = $hideZipCode;
$this->textZipCode = $this->getTextZipCode($type, $textZipCode);
$this->hideState = $hideState;
$this->textState = $this->getTextState($type, $textState);
$this->hideState = $hideTaxNumber;
/* -- Address End -- */
/* -- Buttons Start -- */
$this->cancelRoute = $this->getCancelRoute($type, $cancelRoute);
/* -- Buttons End -- */
/* -- Content End -- */
// Set Parent data
$this->setParentData();
}
/* -- Content Start -- */
/* -- General Start -- */
protected function getTextSectionGeneralTitle($type, $textSectionGeneralTitle)
{
if (! empty($textSectionGeneralTitle)) {
return $textSectionGeneralTitle;
}
$translation = $this->getTextFromConfig($type, 'section_general_title', 'general');
if (! empty($translation)) {
return $translation;
}
return 'general.general';
}
protected function getTextSectionGeneralDescription($type, $textSectionGeneralDescription)
{
if (! empty($textSectionGeneralDescription)) {
return $textSectionGeneralDescription;
}
$translation = $this->getTextFromConfig($type, 'section_general_description', 'form_description.general');
if (! empty($translation)) {
return $translation;
}
return 'customers.form_description.general';
}
protected function getTextName($type, $textName)
{
if (! empty($textName)) {
return $textName;
}
$translation = $this->getTextFromConfig($type, 'name', 'name');
if (! empty($translation)) {
return $translation;
}
return 'general.name';
}
protected function getClassNameFormGroupClass($type, $classNameFromGroupClass)
{
if (! empty($classNameFromGroupClass)) {
return $classNameFromGroupClass;
}
$class = $this->getClassFromConfig($type, 'name');
if (! empty($class)) {
return $class;
}
return 'sm:col-span-6';
}
protected function getTextEmail($type, $textEmail)
{
if (! empty($textEmail)) {
return $textEmail;
}
$translation = $this->getTextFromConfig($type, 'email', 'email');
if (! empty($translation)) {
return $translation;
}
return 'general.email';
}
protected function getTextPhone($type, $textPhone)
{
if (! empty($textPhone)) {
return $textPhone;
}
$translation = $this->getTextFromConfig($type, 'phone', 'phone');
if (! empty($translation)) {
return $translation;
}
return 'general.phone';
}
protected function getTextWebsite($type, $textWebsite)
{
if (! empty($textWebsite)) {
return $textWebsite;
}
$translation = $this->getTextFromConfig($type, 'website', 'website');
if (! empty($translation)) {
return $translation;
}
return 'general.website';
}
protected function getTextReference($type, $textReference)
{
if (! empty($textReference)) {
return $textReference;
}
$translation = $this->getTextFromConfig($type, 'reference', 'reference');
if (! empty($translation)) {
return $translation;
}
return 'general.reference';
}
/* -- General End -- */
/* -- Billing Start -- */
protected function getTextSectionBillingTitle($type, $textSectionBillingTitle)
{
if (! empty($textSectionBillingTitle)) {
return $textSectionBillingTitle;
}
$translation = $this->getTextFromConfig($type, 'section_billing_title');
if (! empty($translation)) {
return $translation;
}
return 'items.billing';
}
protected function getTextSectionBillingDescription($type, $textSectionBillingDescription)
{
if (! empty($textSectionBillingDescription)) {
return $textSectionBillingDescription;
}
$translation = $this->getTextFromConfig($type, 'section_billing_description');
if (! empty($translation)) {
return $translation;
}
return 'customers.form_description.billing';
}
protected function getTextTaxNumber($type, $textTaxNumber)
{
if (! empty($textTaxNumber)) {
return $textTaxNumber;
}
$translation = $this->getTextFromConfig($type, 'tax_number', 'tax_number');
if (! empty($translation)) {
return $translation;
}
return 'general.tax_number';
}
/* -- Billing End -- */
/* -- Address Start -- */
protected function getTextSectionAddressTitle($type, $textSectionAddressTitle)
{
if (! empty($textSectionAddressTitle)) {
return $textSectionAddressTitle;
}
$translation = $this->getTextFromConfig($type, 'section_address_title', 'address');
if (! empty($translation)) {
return $translation;
}
return 'general.address';
}
protected function getTextSectionAddressDescription($type, $textSectionAddressDescription)
{
if (! empty($textSectionAddressDescription)) {
return $textSectionAddressDescription;
}
$translation = $this->getTextFromConfig($type, 'section_address_description');
if (! empty($translation)) {
return $translation;
}
return 'customers.form_description.address';
}
protected function getTextAddress($type, $textAddress)
{
if (! empty($textAddress)) {
return $textAddress;
}
$translation = $this->getTextFromConfig($type, 'address', 'address');
if (! empty($translation)) {
return $translation;
}
return 'general.address';
}
protected function getTextCity($type, $textCity)
{
if (! empty($textCity)) {
return $textCity;
}
$translation = $this->getTextFromConfig($type, 'city', 'cities');
if (! empty($translation)) {
return $translation;
}
return 'general.cities';
}
protected function getTextZipCode($type, $textZipCode)
{
if (! empty($textZipCode)) {
return $textZipCode;
}
$translation = $this->getTextFromConfig($type, 'zip_code', 'zip_code');
if (! empty($translation)) {
return $translation;
}
return 'general.zip_code';
}
protected function getTextState($type, $textState)
{
if (! empty($textState)) {
return $textState;
}
$translation = $this->getTextFromConfig($type, 'state', 'state');
if (! empty($translation)) {
return $translation;
}
return 'general.state';
}
/* -- Address End -- */
/* -- Content End -- */
}

View File

@ -0,0 +1,492 @@
<?php
namespace App\Abstracts\View\Components\Contacts;
use App\Abstracts\View\Component;
use App\Traits\Documents;
use App\Traits\ViewComponents;
abstract class Index extends Component
{
use Documents, ViewComponents;
public const OBJECT_TYPE = 'contact';
public const DEFAULT_TYPE = 'customer';
public const DEFAULT_PLURAL_TYPE = 'customers';
/* -- Main Start -- */
/** @var string */
public $type;
public $contacts;
/** @var string */
public $textPage;
/** @var string */
public $group;
/** @var string */
public $page;
public $permissionCreate;
/* -- Main End -- */
/* -- Buttons Start -- */
public $checkPermissionCreate;
/** @var bool */
public $hideCreate;
/** @var bool */
public $hideImport;
/** @var bool */
public $hideExport;
/** @var string */
public $createRoute;
/** @var string */
public $importRoute;
/** @var array */
public $importRouteParameters;
/** @var string */
public $exportRoute;
/* -- Buttons End -- */
/* -- Content Start -- */
/** @var bool */
public $hideEmptyPage;
/** @var bool */
public $hideSummary;
public $summaryItems;
/** @var bool */
public $hideSearchString;
/** @var bool */
public $hideBulkAction;
/** @var string */
public $searchStringModel;
/** @var string */
public $bulkActionClass;
/** @var array */
public $bulkActionRouteParameters;
/** @var string */
public $searchRoute;
/** @var string */
public $classBulkAction;
/** @var bool */
public $showPicture;
/** @var bool */
public $hideName;
/** @var bool */
public $hideTaxNumber;
/** @var string */
public $classNameAndTaxNumber;
/** @var string */
public $textName;
/** @var string */
public $textTaxNumber;
/** @var bool */
public $hideEmail;
/** @var bool */
public $hidePhone;
/** @var string */
public $classEmailAndPhone;
/** @var string */
public $textEmail;
/** @var string */
public $textPhone;
/** @var bool */
public $hideCountry;
/** @var bool */
public $hideCurrencyCode;
/** @var string */
public $classCountryAndCurrencyCode;
/** @var string */
public $textCountry;
/** @var string */
public $textCurrencyCode;
/** @var bool */
public $hideOpen;
/** @var bool */
public $hideOverdue;
/** @var string */
public $classOpenAndOverdue;
/** @var string */
public $textOpen;
/** @var string */
public $textOverdue;
/* -- Content End -- */
/* -- Empty Start -- */
/** @var string */
public $imageEmptyPage;
/** @var string */
public $textEmptyPage;
/** @var string */
public $urlDocsPath;
/** @var string */
public $routeButtonShow;
/* -- Empty End -- */
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $type, $contacts = [], string $textPage = '', string $group = '', string $page = '',
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
bool $checkPermissionCreate = true,
bool $hideCreate = false, bool $hideImport = false, bool $hideExport = false,
string $createRoute = '', string $importRoute = '', array $importRouteParameters = [], string $exportRoute = '',
bool $hideEmptyPage = false, bool $hideSummary = false, $summaryItems = [], bool $hideSearchString = false, bool $hideBulkAction = false,
string $searchStringModel = '', string $bulkActionClass = '', array $bulkActions = [], array $bulkActionRouteParameters = [], string $searchRoute = '',
string $classBulkAction = '',
bool $showPicture = false, bool $hideName = false, bool $hideTaxNumber = false, string $classNameAndTaxNumber = '', string $textName = '', string $textTaxNumber = '',
bool $hideEmail = false, bool $hidePhone = false, string $classEmailAndPhone = '', string $textEmail = '', string $textPhone = '',
bool $hideCountry = false, bool $hideCurrencyCode = false, string $classCountryAndCurrencyCode = '', string $textCountry = '', string $textCurrencyCode = '',
bool $hideOpen = false, bool $hideOverdue = false, string $classOpenAndOverdue = '', string $textOpen = '', string $textOverdue = '',
string $imageEmptyPage = '', string $textEmptyPage = '', string $urlDocsPath = '', string $routeButtonShow = '',
) {
/* -- Main Start -- */
$this->type = $type;
$this->group = $this->getGroup($type, $group);
$this->page = $this->getPage($type, $page);
$this->contacts = ($contacts) ? $contacts : collect();
$this->textPage = $this->getTextPage($type, $textPage);
$this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
$this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate);
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
/* -- Main End -- */
/* -- Buttons Start -- */
$this->checkPermissionCreate = $checkPermissionCreate;
$this->hideCreate = $hideCreate;
$this->hideImport = $hideImport;
$this->hideExport = $hideExport;
$this->routeButtonShow = $this->getRouteButtonShow($type, $routeButtonShow);
$this->createRoute = $this->getCreateRoute($type, $createRoute);
$this->importRoute = $this->getImportRoute($importRoute);
$this->importRouteParameters = $this->getImportRouteParameters($type, $importRouteParameters);
$this->exportRoute = $this->getExportRoute($type, $exportRoute);
/* -- Buttons End -- */
/* -- Content Start -- */
$this->hideEmptyPage = $hideEmptyPage;
$this->hideSummary = $hideSummary;
$this->summaryItems = $this->getSummaryItems($type, $summaryItems);
$this->hideSearchString = $hideSearchString;
$this->hideBulkAction = $hideBulkAction;
$this->searchStringModel = $this->getSearchStringModel($type, $searchStringModel);
$this->bulkActionClass = $this->getBulkActionClass($type, $bulkActionClass);
$this->bulkActionRouteParameters = $this->getBulkActionRouteParameters($type, $bulkActionRouteParameters);
$this->searchRoute = $this->getIndexRoute($type, $searchRoute);
$this->classBulkAction = $this->getClassBulkAction($type, $classBulkAction);
$this->showPicture = $showPicture;
$this->hideName = $hideName;
$this->hideTaxNumber = $hideTaxNumber;
$this->classNameAndTaxNumber = $this->getClassNameAndTaxNumber($type, $classNameAndTaxNumber);
$this->textName = $this->getTextName($type, $textName);
$this->textTaxNumber = $this->getTextTaxNumber($type, $textTaxNumber);
$this->hideEmail = $hideEmail;
$this->hidePhone = $hidePhone;
$this->classEmailAndPhone = $this->getClassEmailAndPhone($type, $classEmailAndPhone);
$this->textEmail = $this->getTextEmail($type, $textEmail);
$this->textPhone = $this->getTextPhone($type, $textPhone);
$this->hideCountry = $hideCountry;
$this->hideCurrencyCode = $hideCurrencyCode;
$this->classCountryAndCurrencyCode = $this->getClassCountryAndCurrencyCode($type, $classCountryAndCurrencyCode);
$this->textCountry = $this->getTextCountry($type, $textCountry);
$this->textCurrencyCode = $this->getTextCurrencyCode($type, $textCurrencyCode);
$this->hideOpen = $hideOpen;
$this->hideOverdue = $hideOverdue;
$this->classOpenAndOverdue = $this->getClassOpenAndOverdue($type, $classOpenAndOverdue);
$this->textOpen = $this->getTextOpen($type, $textOpen);
$this->textOverdue = $this->getTextOverdue($type, $textOverdue);
/* -- Content End -- */
/* -- Empty Start -- */
$this->imageEmptyPage = $this->getImageEmptyPage($type, $imageEmptyPage);
$this->textEmptyPage = $this->getTextEmptyPage($type, $textEmptyPage);
$this->urlDocsPath = $this->getUrlDocsPath($type, $urlDocsPath);
/* -- Empty End -- */
// Set Parent data
$this->setParentData();
}
public function getSummaryItems($type, $summaryItems)
{
if (! empty($summaryItems)) {
return $summaryItems;
}
$route = $this->getIndexRoute($type, null);
$document_type = config('type.contact.' . $type . '.document_type', 'invoice');
$totals = $this->getTotalsForFutureDocuments($document_type);
$items = [];
foreach ($totals as $key => $total) {
$items[] = [
'title' => ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key),
'href' => route($route, ['search' => 'status:' . $key]),
'amount' => money($total, setting('default.currency'), true),
];
}
return $items;
}
/* -- Content Start -- */
protected function getClassNameAndTaxNumber($type, $classNameAndTaxNumber)
{
if (! empty($classNameAndTaxNumber)) {
return $classNameAndTaxNumber;
}
$class = $this->getClassFromConfig($type, 'name_and_tax_number');
if (! empty($class)) {
return $class;
}
return 'w-6/12 sm:w-3/12 truncate';
}
protected function getTextName($type, $textName)
{
if (! empty($textName)) {
return $textName;
}
$translation = $this->getTextFromConfig($type, 'name', 'name');
if (! empty($translation)) {
return $translation;
}
return 'general.name';
}
protected function getTextTaxNumber($type, $textTaxNumber)
{
if (! empty($textTaxNumber)) {
return $textTaxNumber;
}
$translation = $this->getTextFromConfig($type, 'tax_number', 'tax_number');
if (! empty($translation)) {
return $translation;
}
return 'general.tax_number';
}
protected function getClassEmailAndPhone($type, $classEmailAndPhone)
{
if (! empty($classEmailAndPhone)) {
return $classEmailAndPhone;
}
$class = $this->getClassFromConfig($type, 'email_and_phone');
if (! empty($class)) {
return $class;
}
return 'w-3/12 hidden sm:table-cell';
}
protected function getTextEmail($type, $textEmail)
{
if (! empty($textEmail)) {
return $textEmail;
}
$translation = $this->getTextFromConfig($type, 'email', 'email');
if (! empty($translation)) {
return $translation;
}
return 'general.email';
}
protected function getTextPhone($type, $textPhone)
{
if (! empty($textPhone)) {
return $textPhone;
}
$translation = $this->getTextFromConfig($type, 'phone', 'phone');
if (! empty($translation)) {
return $translation;
}
return 'general.phone';
}
protected function getClassCountryAndCurrencyCode($type, $classCountryAndCurrencyCode)
{
if (! empty($classCountryAndCurrencyCode)) {
return $classCountryAndCurrencyCode;
}
$class = $this->getClassFromConfig($type, 'country_and_currency_code');
if (! empty($class)) {
return $class;
}
return 'w-3/12 hidden sm:table-cell';
}
protected function getTextCountry($type, $textCountry)
{
if (! empty($textCountry)) {
return $textCountry;
}
$translation = $this->getTextFromConfig($type, 'country', 'countries');
if (! empty($translation)) {
return $translation;
}
return 'general.countries';
}
protected function getTextCurrencyCode($type, $textCurrencyCode)
{
if (! empty($textCurrencyCode)) {
return $textCurrencyCode;
}
$translation = $this->getTextFromConfig($type, 'currency_code', 'currencies');
if (! empty($translation)) {
return $translation;
}
return 'general.currencies';
}
protected function getClassOpenAndOverdue($type, $classOpenAndOverdue)
{
if (! empty($classOpenAndOverdue)) {
return $classOpenAndOverdue;
}
$class = $this->getClassFromConfig($type, 'open_and_overdue');
if (! empty($class)) {
return $class;
}
return 'w-6/12 sm:w-3/12';
}
protected function getTextOpen($type, $textOpen)
{
if (! empty($textOpen)) {
return $textOpen;
}
$translation = $this->getTextFromConfig($type, 'open', 'open');
if (! empty($translation)) {
return $translation;
}
return 'general.open';
}
protected function getTextOverdue($type, $textOverdue)
{
if (! empty($textOverdue)) {
return $textOverdue;
}
$translation = $this->getTextFromConfig($type, 'overdue', 'overdue');
if (! empty($translation)) {
return $translation;
}
return 'general.overdue';
}
protected function getRouteButtonShow($type, $routeButtonShow)
{
if (!empty($routeButtonShow)) {
return $routeButtonShow;
}
//example route parameter.
$parameter = 1;
$route = $this->getRouteFromConfig($type, 'show', $parameter);
if (!empty($route)) {
return $route;
}
return 'customer.show';
}
/* -- Content End -- */
}

View File

@ -0,0 +1,316 @@
<?php
namespace App\Abstracts\View\Components\Contacts;
use App\Abstracts\View\Component;
use App\Traits\ViewComponents;
abstract class Show extends Component
{
use ViewComponents;
public const OBJECT_TYPE = 'contact';
public const DEFAULT_TYPE = 'customer';
public const DEFAULT_PLURAL_TYPE = 'customers';
/* -- Main Start -- */
public $type;
public $contact;
public $model;
public $permissionCreate;
public $permissionUpdate;
public $permissionDelete;
/* -- Main End -- */
/* -- Buttons Start -- */
public $hideNewDropdown;
public $hideButtonDocument;
public $hideButtonTransaction;
public $permissionCreateDocument;
public $permissionCreateTransaction;
public $routeButtonDocument;
public $routeButtonTransaction;
public $textDocument;
public $textTransaction;
public $hideButtonEdit;
public $routeButtonEdit;
public $hideActionsDropdown;
public $hideButtonDuplicate;
public $routeButtonDuplicate;
public $hideButtonDelete;
public $routeButtonDelete;
public $textDeleteModal;
/* -- Buttons End -- */
/* -- Profile Start -- */
public $hideTopLeft;
public $hideAvatar;
public $hideEmail;
public $hidePhone;
public $hideTopRight;
public $hideOverdue;
public $hideOpen;
public $hidePaid;
public $hideBottomLeft;
public $hideAddress;
public $hideTaxNumber;
public $hideWebsite;
public $hideReference;
public $hideUser;
public $hideBottomRight;
/* -- Profile End -- */
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $type, $model = false, $contact = false,
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
bool $hideNewDropdown = false, bool $hideButtonDocument = false, $hideButtonTransaction = false,
string $permissionCreateDocument = '', string $permissionCreateTransaction = '',
$routeButtonDocument = '', $routeButtonTransaction = '',
string $textDocument = '', string $textTransaction = '',
bool $hideButtonEdit = false, $routeButtonEdit = '',
bool $hideActionsDropdown = false, bool $hideButtonDuplicate = false, $routeButtonDuplicate = '',
bool $hideButtonDelete = false, $routeButtonDelete = '', $textDeleteModal = '',
bool $hideTopLeft = false, bool $hideAvatar = false, bool $hideEmail = false, bool $hidePhone = false,
bool $hideTopRight = false, bool $hideOverdue = false, bool $hideOpen = false, bool $hidePaid = false,
bool $hideBottomLeft = false, bool $hideAddress = false, bool $hideTaxNumber = false , bool $hideWebsite = false, bool $hideReference = false, bool $hideUser = false,
bool $hideBottomRight = false
) {
/* -- Main Start -- */
$this->type = $type;
$this->model = ! empty($model) ? $model : $contact;
$this->contact = $this->model;
$this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
$this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate);
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
/* -- Main End -- */
/* -- Buttons Start -- */
$this->hideNewDropdown = $hideNewDropdown;
$this->hideButtonDocument = $hideButtonDocument;
$this->hideButtonTransaction = $hideButtonTransaction;
$this->permissionCreateDocument = $this->getPermissionCreateDocument($type, $permissionCreateDocument);
$this->permissionCreateTransaction = $this->getPermissionCreateTransaction($type, $permissionCreateTransaction);
$this->routeButtonDocument = $this->getCreateDocumentRoute($type, $routeButtonDocument);
$this->routeButtonTransaction = $this->getCreateTransactionRoute($type, $routeButtonTransaction);
$this->textDocument = $this->getTextDocument($type, $textDocument);
$this->textTransaction = $this->getTextTransaction($type, $textTransaction);
$this->hideButtonEdit = $hideButtonEdit;
$this->routeButtonEdit = $this->getEditRoute($type, $routeButtonEdit);
$this->hideActionsDropdown = $hideActionsDropdown;
$this->hideButtonDuplicate = $hideButtonDuplicate;
$this->routeButtonDuplicate = $this->getDuplicateRoute($type, $routeButtonDuplicate);
$this->hideButtonDelete = $hideButtonDelete;
$this->routeButtonDelete = $this->getDeleteRoute($type, $routeButtonDelete);
$this->textDeleteModal = $this->getTextDeleteModal($type, $textDeleteModal);
/* -- Buttons End -- */
/* -- Profile Start -- */
$this->hideProfile = $hideTopLeft;
$this->hideAvatar = $hideAvatar;
$this->hideEmail = $hideEmail;
$this->hidePhone = $hidePhone;
$this->hideDetails = $hideTopRight;
$this->hideOverdue = $hideOverdue;
$this->hideOpen = $hideOpen;
$this->hidePaid = $hidePaid;
$this->hideSummary = $hideBottomLeft;
$this->hideAddress = $hideAddress;
$this->hideTaxNumber = $hideTaxNumber;
$this->hideWebsite = $hideWebsite;
$this->hideReference = $hideReference;
$this->hideUser = $hideUser;
$this->hideContent = $hideBottomRight;
/* -- Profile End -- */
}
protected function getPermissionCreateDocument($type, $permissionCreateDocument)
{
if (! empty($permissionCreateDocument)) {
return $permissionCreateDocument;
}
$document_type = config('type.contact.' . $type . '.document_type', 'invoice');
$permission = '';
$config_key = 'create';
// if set config trasnlation config_key
if ($permission = config('type.document.' . $document_type . '.permission.' . $config_key)) {
return $permission;
}
$alias = config('type.document.' . $document_type . '.alias');
$group = config('type.document.' . $document_type . '.group');
$prefix = config('type.document.' . $document_type . '.permission.prefix');
$permission = $config_key . '-';
// if use module set module alias
if (! empty($alias)) {
$permission .= $alias . '-';
}
// if controller in folder it must
if (! empty($group)) {
$permission .= $group . '-';
}
$permission .= $prefix;
$permissionCreateDocument = $permission;
return $permissionCreateDocument;
}
protected function getPermissionCreateTransaction($type, $permissionCreateTransaction)
{
if (! empty($permissionCreateTransaction)) {
return $permissionCreateTransaction;
}
$permissionCreateTransaction = 'create-banking-transactions';
return $permissionCreateTransaction;
}
protected function getCreateDocumentRoute($type, $routeButtonDocument)
{
if (! empty($routeButtonDocument)) {
return $routeButtonDocument;
}
$prefix = config('type.contact.' . $type . '.route.prefix');
$document_type = config('type.contact.' . $type . '.document_type');
return $prefix . '.create-' . $document_type;
}
protected function getCreateTransactionRoute($type, $routeButtonDocument)
{
if (! empty($routeButtonDocument)) {
return $routeButtonDocument;
}
$prefix = config('type.contact.' . $type . '.route.prefix');
$transaction_type = config('type.contact.' . $type . '.transaction_type');
return $prefix . '.create-' . $transaction_type;
}
protected function getTextDocument($type, $textDocument)
{
if (! empty($textDocument)) {
return $textDocument;
}
$document_type = config('type.contact.' . $type . '.document_type');
switch ($document_type) {
case 'invoice':
$text = 'general.invoices';
break;
case 'bill':
$text = 'general.bills';
break;
default:
$text = config('type.contact.' . $type . '.translation.prefix') . '.' . config('type.contact.' . $type . '.route.prefix');
}
return $text;
}
protected function getTextTransaction($type, $textTransaction)
{
if (! empty($textTransaction)) {
return $textTransaction;
}
$document_type = config('type.contact.' . $type . '.document_type');
switch ($document_type) {
case 'invoice':
$text = 'general.incomes';
break;
case 'bill':
$text = 'general.expenses';
break;
default:
$text = config('type.contact.' . $type . '.translation.prefix') . '.' . config('type.contact.' . $type . '.transaction_type') . 's';
}
return $text;
}
protected function getTextDeleteModal($type, $textDeleteModal)
{
if (! empty($textDeleteModal)) {
return $textDeleteModal;
}
$document_type = config('type.contact.' . $type . '.document_type');
switch ($document_type) {
case 'invoice':
$text = 'general.incomes';
break;
case 'bill':
$text = 'general.expenses';
break;
default:
$text = config('type.contact.' . $type . '.translation.prefix') . '.' . config('type.contact.' . $type . '.transaction_type') . 's';
}
return $text;
}
}