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,13 @@
<?php
namespace App\Abstracts\View;
use Illuminate\View\Component as BaseComponent;
abstract class Component extends BaseComponent
{
public function getParentData($key, $default = null)
{
return app('view')->getConsumableComponentData($key, $default);
}
}

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;
}
}

View File

@ -1,175 +0,0 @@
<?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 translation 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, $config_parameters = [])
{
$route = '';
// if set config trasnlation config_key
if ($route = config('type.' . $type . '.route.' . $config_key)) {
return $route;
}
$alias = config('type.' . $type . '.alias');
$prefix = config('type.' . $type . '.route.prefix');
// if use module set module alias
if (!empty($alias)) {
$route .= $alias . '.';
}
if (!empty($prefix)) {
$route .= $prefix . '.';
}
$route .= $config_key;
try {
route($route, $config_parameters);
} catch (\Exception $e) {
try {
$route = Str::plural($type, 2) . '.' . $config_key;
route($route, $config_parameters);
} catch (\Exception $e) {
$route = '';
}
}
return $route;
}
public function getPermissionFromConfig($type, $config_key)
{
$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 = $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;
return $permission;
}
public function getHideFromConfig($type, $config_key)
{
$hide = false;
$hides = config('type.' . $type . '.hide');
if (!empty($hides) && (in_array($config_key, $hides))) {
$hide = true;
}
return $hide;
}
public function getClassFromConfig($type, $config_key)
{
$class_key = 'type.' . $type . '.class.' . $config_key;
return config($class_key, '');
}
public function getCategoryFromConfig($type)
{
$category_type = '';
// if set config trasnlation config_key
if ($category_type = config('type.' . $type . '.category_type')) {
return $category_type;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$category_type = 'expense';
break;
case 'item':
$category_type = 'item';
break;
case 'other':
$category_type = 'other';
break;
case 'transfer':
$category_type = 'transfer';
break;
default:
$category_type = 'income';
break;
}
return $category_type;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,642 @@
<?php
namespace App\Abstracts\View\Components\Documents;
use Akaunting\Module\Module;
use App\Abstracts\View\Component;
use App\Events\Common\BulkActionsAdding;
use App\Traits\Documents;
use App\Traits\Modules;
use App\Traits\ViewComponents;
use Illuminate\Support\Str;
use Illuminate\View\View;
abstract class Index extends Component
{
use Documents, Modules, ViewComponents;
public const OBJECT_TYPE = 'document';
public const DEFAULT_TYPE = 'invoice';
public const DEFAULT_PLURAL_TYPE = 'invoices';
/* -- Main Start -- */
/** @var string */
public $type;
/** @var string */
public $alias;
public $documents;
/** @var string */
public $group;
/** @var string */
public $page;
/** @var string */
public $textTabDocument;
/** @var string */
public $routeTabDocument;
/** @var string */
public $routeTabRecurring;
/** @var string */
public $textPage;
/** @var string */
public $permissionCreate;
/** @var string */
public $permissionUpdate;
/** @var string */
public $permissionDelete;
/* -- Main End -- */
/* -- Buttons Start -- */
/** @var bool */
public $hideAcceptPayment;
/** @var bool */
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 array */
public $emptyPageButtons;
/** @var string */
public $imageEmptyPage;
/** @var string */
public $textEmptyPage;
/** @var string */
public $urlDocsPath;
/** @var bool */
public $hideSummary;
/** @var array */
public $summaryItems;
/** @var bool */
public $withoutTabs;
/** @var string */
public $tabActive;
/** @var bool */
public $hideRecurringTemplates;
/** @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 $hideDueAt;
/** @var bool */
public $hideIssuedAt;
/** @var string */
public $classDueAtAndIssueAt;
/** @var string */
public $textDueAt;
/** @var string */
public $textIssuedAt;
/** @var bool */
public $hideStatus;
/** @var string */
public $classStatus;
/** @var bool */
public $hideContactName;
/** @var bool */
public $hideDocumentNumber;
/** @var string */
public $classContactNameAndDocumentNumber;
/** @var string */
public $textContactName;
/** @var string */
public $showContactRoute;
/** @var string */
public $textDocumentNumber;
/** @var bool */
public $hideAmount;
/** @var string */
public $classAmount;
/** @var bool */
public $hideShow;
/** @var string */
public $showRoute;
/** @var bool */
public $hideEdit;
/** @var string */
public $editRoute;
/** @var bool */
public $hideDuplicate;
/** @var string */
public $duplicateRoute;
/** @var string */
public $textDocumentStatus;
/** @var bool */
public $checkButtonReconciled;
/** @var bool */
public $checkButtonCancelled;
/* -- Content End -- */
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $type, string $alias = '', $documents = [], string $group = '', string $page = '', string $textTabDocument = '', string $textPage = '',
string $routeTabDocument = '', string $routeTabRecurring = '',
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
bool $hideAcceptPayment = false, bool $checkPermissionCreate = true,
bool $hideCreate = false, bool $hideImport = false, bool $hideExport = false,
string $createRoute = '', string $importRoute = '', array $importRouteParameters = [], string $exportRoute = '',
bool $hideEmptyPage = false, array $emptyPageButtons = [], string $imageEmptyPage = '', string $textEmptyPage = '', string $urlDocsPath = '',
bool $hideSummary = false, array $summaryItems = [],
bool $withoutTabs = false, string $tabActive = '', bool $hideRecurringTemplates = false,
bool $hideSearchString = false, bool $hideBulkAction = false,
string $searchStringModel = '', string $bulkActionClass = '', array $bulkActions = [], array $bulkActionRouteParameters = [], string $searchRoute = '', string $classBulkAction = '',
bool $hideDueAt = false, bool $hideIssuedAt = false, string $classDueAtAndIssueAt = '', string $textDueAt = '', string $textIssuedAt = '',
bool $hideStatus = false, string $classStatus = '',
bool $hideContactName = false, bool $hideDocumentNumber = false, string $classContactNameAndDocumentNumber = '', string $textContactName = '', string $showContactRoute = '', string $textDocumentNumber = '',
bool $hideAmount = false, string $classAmount = '',
bool $hideShow = false, string $showRoute = '', bool $hideEdit = false, string $editRoute = '', bool $hideDuplicate = false, string $duplicateRoute = '',
string $textDocumentStatus = '',
bool $checkButtonReconciled = true, bool $checkButtonCancelled = true
) {
/* -- Main Start -- */
$this->type = $type;
$this->alias = $this->getAlias($type, $alias);
$this->documents = ($documents) ? $documents : collect();
$this->group = $this->getGroup($type, $group);
$this->page = $this->getPage($type, $page);
$this->textTabDocument = $this->getTextTabDocument($type, $textTabDocument);
$this->textPage = $this->getTextPage($type, $textPage);
$this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
$this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate);
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
$this->routeTabDocument = $this->getRouteTabDocument($type, $routeTabDocument);
$this->routeTabRecurring = $this->getRouteTabRecurring($type, $routeTabRecurring);
/* -- Main End -- */
/* -- Buttons Start -- */
$this->hideAcceptPayment = $hideAcceptPayment;
$this->checkPermissionCreate = $checkPermissionCreate;
$this->hideCreate = $hideCreate;
$this->hideImport = $hideImport;
$this->hideExport = $hideExport;
$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 -- */
/* -- Empty Page Start -- */
$this->hideEmptyPage = $hideEmptyPage;
$this->emptyPageButtons = $this->getEmptyPageButtons($type, $emptyPageButtons);
$this->imageEmptyPage = $this->getImageEmptyPage($type, $imageEmptyPage);
$this->textEmptyPage = $this->getTextEmptyPage($type, $textEmptyPage);
$this->urlDocsPath = $this->getUrlDocsPath($type, $urlDocsPath);
/* -- Empty Page End -- */
/* -- Summary Start -- */
$this->hideSummary = $hideSummary;
$this->summaryItems = $this->getSummaryItems($type, $summaryItems);
/* -- Sumamry End -- */
/* Container Start */
$this->withoutTabs = $withoutTabs;
$this->tabActive = $this->getTabActive($type, $tabActive);
$this->hideRecurringTemplates = $hideRecurringTemplates;
$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);
/* Document Start */
$this->hideDueAt = $hideDueAt;
$this->hideIssuedAt = $hideIssuedAt;
$this->classDueAtAndIssueAt = $this->getClassDueAtAndIssueAt($type, $classDueAtAndIssueAt);
$this->textDueAt = $this->getTextDueAt($type, $textDueAt);
$this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt);
$this->hideStatus = $hideStatus;
$this->classStatus = $this->getClassStatus($type, $classStatus);
$this->hideContactName = $hideContactName;
$this->hideDocumentNumber = $hideDocumentNumber;
$this->classContactNameAndDocumentNumber = $this->getClassContactNameAndDocumentNumber($type, $classContactNameAndDocumentNumber);
$this->textContactName = $this->getTextContactName($type, $textContactName);
$this->showContactRoute = $this->getShowContactRoute($type, $showContactRoute);
$this->textDocumentNumber = $this->getTextDocumentNumber($type, $textDocumentNumber);
$this->hideAmount = $hideAmount;
$this->classAmount = $this->getClassAmount($type, $classAmount);
$this->hideShow = $hideShow;
$this->showRoute = $this->getShowRoute($type, $showRoute);
$this->hideEdit = $hideEdit;
$this->editRoute = $this->getEditRoute($type, $editRoute);
$this->hideDuplicate = $hideDuplicate;
$this->duplicateRoute = $this->getDuplicateRoute($type, $duplicateRoute);
$this->textDocumentStatus = $this->getTextDocumentStatus($type, $textDocumentStatus);
$this->checkButtonReconciled = $checkButtonReconciled;
$this->checkButtonCancelled = $checkButtonCancelled;
/* Document End */
/* Container End */
/* -- Content End -- */
// Set Parent data
$this->setParentData();
}
protected function getEmptyPageButtons($type, $emptyPageButtons)
{
if (! empty($emptyPageButtons)) {
return $emptyPageButtons;
}
$prefix = config('type.' . static::OBJECT_TYPE . '.' . $type . '.route.prefix', 'invoices');
$buttons = [];
if (! $this->hideCreate) {
$route = $this->getRouteFromConfig($type, 'create');
$buttons[] = [
'permission' => $this->permissionCreate,
'url' => route($this->createRoute),
'text' => trans('general.title.new', ['type' => trans_choice($this->textPage ?? 'general.' . $prefix, 1)]),
'description' => trans('general.empty.actions.new', ['type' => strtolower(trans_choice($this->textPage ?? 'general.' . $prefix, 1))]),
'active_badge' => true,
];
}
if (! $this->hideImport) {
$route = $this->getRouteFromConfig($type, 'import');
$buttons[] = [
'permission' => $this->permissionCreate,
'url' => route($this->importRoute, $this->importRouteParameters),
'text' => trans('import.title', ['type' => trans_choice($this->textPage ?? 'general.' . $prefix, 1)]),
'description' => trans('general.empty.actions.import', ['type' => strtolower(trans_choice($this->textPage ?? 'general.' . $prefix, 1))]),
];
}
return $buttons;
}
public function getSummaryItems($type, $summaryItems)
{
if (! empty($summaryItems)) {
return $summaryItems;
}
$route = $this->getIndexRoute($type, null);
$totals = $this->getTotalsForFutureDocuments($type);
$items = [];
foreach ($totals as $key => $total) {
$title = ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key);
$href = route($route, ['search' => 'status:' . $key]);
$amount = money($total, setting('default.currency'), true);
$items[] = [
'title' => $title,
'href' => $href,
'amount' => $amount,
];
}
return $items;
}
protected function getTextTabDocument($type, $textTabDocument)
{
if (! empty($textTabDocument)) {
return $textTabDocument;
}
$default_key = config('type.' . static::OBJECT_TYPE . '.' . $type . '.translation.prefix');
$translation = $this->getTextFromConfig($type, 'tab_document', $default_key);
if (! empty($translation)) {
return $translation;
}
return 'general.invoices';
}
public function getTabActive($type, $tabActive)
{
if (! empty($tabActive)) {
return $tabActive;
}
return $type;
}
protected function getRouteTabDocument($type, $routeTabDocument)
{
if (! empty($routeTabDocument)) {
return $routeTabDocument;
}
$route = $this->getRouteFromConfig($type, 'document', 'invoices');
if (! empty($route)) {
return $route;
}
return 'invoices.index';
}
protected function getRouteTabRecurring($type, $routeTabDocument)
{
if (! empty($routeTabDocument)) {
return $routeTabDocument;
}
$route = $this->getRouteFromConfig($type, 'recurring', 'recurring-invoices');
if (! empty($route)) {
return $route;
}
return 'recurring-invoices.index';
}
protected function getClassDueAtAndIssueAt($type, $classDueAtAndIssueAt)
{
if (! empty($classDueAtAndIssueAt)) {
return $classDueAtAndIssueAt;
}
$class = $this->getClassFromConfig($type, 'due_at_and_issue_at');
if (! empty($class)) {
return $class;
}
return 'w-4/12 table-title hidden sm:table-cell';
}
protected function getTextDueAt($type, $textDueAt)
{
if (! empty($textDueAt)) {
return $textDueAt;
}
$translation = $this->getTextFromConfig($type, 'due_at', 'due_date');
if (! empty($translation)) {
return $translation;
}
return 'invoices.due_date';
}
protected function getTextIssuedAt($type, $textIssuedAt)
{
if (! empty($textIssuedAt)) {
return $textIssuedAt;
}
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);
if (! empty($translation)) {
return $translation;
}
return 'invoices.invoice_date';
}
protected function getClassStatus($type, $classStatus)
{
if (! empty($classStatus)) {
return $classStatus;
}
$class = $this->getClassFromConfig($type, 'status');
if (! empty($class)) {
return $class;
}
return 'w-3/12 table-title hidden sm:table-cell';
}
protected function getClassContactNameAndDocumentNumber($type, $classContactNameAndDocumentNumber)
{
if (! empty($classContactNameAndDocumentNumber)) {
return $classContactNameAndDocumentNumber;
}
$class = $this->getClassFromConfig($type, 'contact_name');
if (! empty($class)) {
return $class;
}
return 'w-6/12 sm:w-3/12 table-title';
}
protected function getTextContactName($type, $textContactName)
{
if (! empty($textContactName)) {
return $textContactName;
}
$default_key = Str::plural(config('type.' . static::OBJECT_TYPE . '.' . $type . '.contact_type'), 2);
$translation = $this->getTextFromConfig($type, 'contact_name', $default_key, 'trans_choice');
if (! empty($translation)) {
return $translation;
}
return 'general.customers';
}
protected function getShowContactRoute($type, $showContactRoute)
{
if (! empty($showContactRoute)) {
return $showContactRoute;
}
if (! empty($showRoute)) {
return $showRoute;
}
$route = $this->getRouteFromConfig($type, 'contact.show', 1);
if (!empty($route)) {
return $route;
}
$default_key = Str::plural(config('type.' . static::OBJECT_TYPE . '.' . $type . '.contact_type'), 2);
return $default_key . '.show';
}
protected function getTextDocumentNumber($type, $textDocumentNumber)
{
if (! empty($textDocumentNumber)) {
return $textDocumentNumber;
}
$translation = $this->getTextFromConfig($type, 'document_number', 'numbers');
if (! empty($translation)) {
return $translation;
}
return 'general.numbers';
}
protected function getClassAmount($type, $classAmount)
{
if (! empty($classAmount)) {
return $classAmount;
}
$class = $this->getClassFromConfig($type, 'amount');
if (! empty($class)) {
return $class;
}
return 'w-6/12 sm:w-2/12';
}
protected function getTextDocumentStatus($type, $textDocumentStatus)
{
if (! empty($textDocumentStatus)) {
return $textDocumentStatus;
}
$translation = $this->getTextFromConfig($type, 'document_status', 'statuses.');
if (! empty($translation)) {
return $translation;
}
$alias = config('type.' . static::OBJECT_TYPE . '.' . $type . '.alias');
if (! empty($alias)) {
$translation = $alias . '::' . config('type.' . static::OBJECT_TYPE . '.' . $type . '.translation.prefix') . '.statuses';
if (is_array(trans($translation))) {
return $translation . '.';
}
}
return 'documents.statuses.';
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,27 @@
<?php
namespace App\Abstracts\View\Components;
namespace App\Abstracts\View\Components\Documents;
use App\Abstracts\View\Components\Document as Base;
use App\Abstracts\View\Component;
use App\Models\Common\Media;
use App\Traits\DateTime;
use App\Traits\Documents;
use File;
use App\Traits\ViewComponents;
use Illuminate\Support\Facades\Log;
use Image;
use Intervention\Image\Exception\NotReadableException;
use Storage;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\Exception\NotReadableException;
use Image;
abstract class DocumentTemplate extends Base
abstract class Template extends Component
{
use DateTime;
use Documents;
use DateTime, Documents, ViewComponents;
public const OBJECT_TYPE = 'document';
public const DEFAULT_TYPE = 'invoice';
public const DEFAULT_PLURAL_TYPE = 'invoices';
public $type;
@ -180,15 +185,18 @@ abstract class DocumentTemplate extends Base
$this->textQuantity = $this->getTextQuantity($type, $textQuantity);
$this->textPrice = $this->getTextPrice($type, $textPrice);
$this->textAmount = $this->getTextAmount($type, $textAmount);
// Set Parent data
//$this->setParentData();
}
protected function getDocumentTemplate($type, $documentTemplate)
{
if (!empty($documentTemplate)) {
if (! empty($documentTemplate)) {
return $documentTemplate;
}
if ($template = config('type.' . $type . 'template', false)) {
if ($template = config('type.document.' . $type . '.template', false)) {
return $template;
}
@ -199,15 +207,15 @@ abstract class DocumentTemplate extends Base
protected function getLogo($logo)
{
if (!empty($logo)) {
if (! empty($logo)) {
return $logo;
}
$media_id = (!empty($this->document->contact->logo) && !empty($this->document->contact->logo->id)) ? $this->document->contact->logo->id : setting('company.logo');
$media_id = (! empty($this->document->contact->logo) && ! empty($this->document->contact->logo->id)) ? $this->document->contact->logo->id : setting('company.logo');
$media = Media::find($media_id);
if (!empty($media)) {
if (! empty($media)) {
$path = $media->getDiskPath();
if (Storage::missing($path)) {
@ -253,14 +261,19 @@ abstract class DocumentTemplate extends Base
protected function getBackgroundColor($type, $backgroundColor)
{
if (!empty($backgroundColor)) {
if (! empty($backgroundColor)) {
return $backgroundColor;
}
if ($background_color = config('type.' . $type . 'color', false)) {
if ($background_color = config('type.document.' . $type . '.color', false)) {
return $background_color;
}
if (! empty($alias = config('type.document.' . $type . '.alias'))) {
$type = $alias . '.' . str_replace('-', '_', $type);
}
$backgroundColor = setting($this->getSettingKey($type, 'color'), '#55588b');
return $backgroundColor;
@ -268,19 +281,19 @@ abstract class DocumentTemplate extends Base
protected function getTextDocumentTitle($type, $textDocumentTitle)
{
if (!empty($textDocumentTitle)) {
if (! empty($textDocumentTitle)) {
return $textDocumentTitle;
}
$key = $this->getSettingKey($type, 'title');
if (!empty(setting($key))) {
if (! empty(setting($key))) {
return setting($key);
}
$translation = $this->getTextFromConfig($type, 'document_title', Str::plural($type));
if (!empty($translation)) {
if (! empty($translation)) {
return trans_choice($translation, 1);
}
@ -289,19 +302,19 @@ abstract class DocumentTemplate extends Base
protected function getTextDocumentSubheading($type, $textDocumentSubheading)
{
if (!empty($textDocumentSubheading)) {
if (! empty($textDocumentSubheading)) {
return $textDocumentSubheading;
}
$key = $this->getSettingKey($type, 'subheading');
if (!empty(setting($key))) {
if (! empty(setting($key))) {
return setting($key);
}
$translation = $this->getTextFromConfig($type, 'document_subheading', 'subheading');
if (!empty($translation)) {
if (! empty($translation)) {
return trans($translation);
}
@ -310,7 +323,7 @@ abstract class DocumentTemplate extends Base
protected function getTextDocumentNumber($type, $textDocumentNumber)
{
if (!empty($textDocumentNumber)) {
if (! empty($textDocumentNumber)) {
return $textDocumentNumber;
}
@ -327,7 +340,7 @@ abstract class DocumentTemplate extends Base
$translation = $this->getTextFromConfig($type, 'document_number', $default_key);
if (!empty($translation)) {
if (! empty($translation)) {
return $translation;
}
@ -336,13 +349,13 @@ abstract class DocumentTemplate extends Base
protected function getTextOrderNumber($type, $textOrderNumber)
{
if (!empty($textOrderNumber)) {
if (! empty($textOrderNumber)) {
return $textOrderNumber;
}
$translation = $this->getTextFromConfig($type, 'order_number');
if (!empty($translation)) {
if (! empty($translation)) {
return $translation;
}
@ -351,7 +364,7 @@ abstract class DocumentTemplate extends Base
protected function getTextContactInfo($type, $textContactInfo)
{
if (!empty($textContactInfo)) {
if (! empty($textContactInfo)) {
return $textContactInfo;
}
@ -368,7 +381,7 @@ abstract class DocumentTemplate extends Base
$translation = $this->getTextFromConfig($type, 'contact_info', $default_key);
if (!empty($translation)) {
if (! empty($translation)) {
return $translation;
}
@ -377,7 +390,7 @@ abstract class DocumentTemplate extends Base
protected function getTextIssuedAt($type, $textIssuedAt)
{
if (!empty($textIssuedAt)) {
if (! empty($textIssuedAt)) {
return $textIssuedAt;
}
@ -394,7 +407,7 @@ abstract class DocumentTemplate extends Base
$translation = $this->getTextFromConfig($type, 'issued_at', $default_key);
if (!empty($translation)) {
if (! empty($translation)) {
return $translation;
}
@ -403,13 +416,13 @@ abstract class DocumentTemplate extends Base
protected function getTextDueAt($type, $textDueAt)
{
if (!empty($textDueAt)) {
if (! empty($textDueAt)) {
return $textDueAt;
}
$translation = $this->getTextFromConfig($type, 'due_at', 'due_date');
if (!empty($translation)) {
if (! empty($translation)) {
return $translation;
}
@ -418,7 +431,7 @@ abstract class DocumentTemplate extends Base
protected function getTextItems($type, $textItems)
{
if (!empty($textItems)) {
if (! empty($textItems)) {
return $textItems;
}
@ -431,15 +444,15 @@ abstract class DocumentTemplate extends Base
return $textItems;
}
if (setting($this->getSettingKey($type, 'item_name')) !== null &&
(trans(setting($this->getSettingKey($type, 'item_name'))) != setting($this->getSettingKey($type, 'item_name')))
if (setting($this->getSettingKey($type, 'item_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'item_name'))) != setting($this->getSettingKey($type, 'item_name')))
) {
return setting($this->getSettingKey($type, 'item_name'));
}
$translation = $this->getTextFromConfig($type, 'items');
if (!empty($translation)) {
if (! empty($translation)) {
return $translation;
}
@ -448,7 +461,7 @@ abstract class DocumentTemplate extends Base
protected function getTextQuantity($type, $textQuantity)
{
if (!empty($textQuantity)) {
if (! empty($textQuantity)) {
return $textQuantity;
}
@ -461,15 +474,15 @@ abstract class DocumentTemplate extends Base
return $textQuantity;
}
if (setting($this->getSettingKey($type, 'quantity_name')) !== null &&
(trans(setting($this->getSettingKey($type, 'quantity_name'))) != setting($this->getSettingKey($type, 'quantity_name')))
if (setting($this->getSettingKey($type, 'quantity_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'quantity_name'))) != setting($this->getSettingKey($type, 'quantity_name')))
) {
return setting($this->getSettingKey($type, 'quantity_name'));
}
$translation = $this->getTextFromConfig($type, 'quantity');
if (!empty($translation)) {
if (! empty($translation)) {
return $translation;
}
@ -478,7 +491,7 @@ abstract class DocumentTemplate extends Base
protected function getTextPrice($type, $textPrice)
{
if (!empty($textPrice)) {
if (! empty($textPrice)) {
return $textPrice;
}
@ -491,15 +504,15 @@ abstract class DocumentTemplate extends Base
return $textPrice;
}
if (setting($this->getSettingKey($type, 'price_name')) !== null &&
(trans(setting($this->getSettingKey($type, 'price_name'))) != setting($this->getSettingKey($type, 'price_name')))
if (setting($this->getSettingKey($type, 'price_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'price_name'))) != setting($this->getSettingKey($type, 'price_name')))
) {
return setting($this->getSettingKey($type, 'price_name'));
}
$translation = $this->getTextFromConfig($type, 'price');
if (!empty($translation)) {
if (! empty($translation)) {
return $translation;
}
@ -508,13 +521,13 @@ abstract class DocumentTemplate extends Base
protected function getTextAmount($type, $textAmount)
{
if (!empty($textAmount)) {
if (! empty($textAmount)) {
return $textAmount;
}
$translation = $this->getTextFromConfig($type, 'amount');
if (!empty($translation)) {
if (! empty($translation)) {
return $translation;
}
@ -523,7 +536,7 @@ abstract class DocumentTemplate extends Base
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
{
if (!empty($hideItems)) {
if (! empty($hideItems)) {
return $hideItems;
}
@ -540,7 +553,7 @@ abstract class DocumentTemplate extends Base
protected function getHideName($type, $hideName)
{
if (!empty($hideName)) {
if (! empty($hideName)) {
return $hideName;
}
@ -561,7 +574,7 @@ abstract class DocumentTemplate extends Base
protected function getHideDescription($type, $hideDescription)
{
if (!empty($hideDescription)) {
if (! empty($hideDescription)) {
return $hideDescription;
}
@ -582,7 +595,7 @@ abstract class DocumentTemplate extends Base
protected function getHideQuantity($type, $hideQuantity)
{
if (!empty($hideQuantity)) {
if (! empty($hideQuantity)) {
return $hideQuantity;
}
@ -603,7 +616,7 @@ abstract class DocumentTemplate extends Base
protected function getHidePrice($type, $hidePrice)
{
if (!empty($hidePrice)) {
if (! empty($hidePrice)) {
return $hidePrice;
}
@ -624,7 +637,7 @@ abstract class DocumentTemplate extends Base
protected function getHideDiscount($type, $hideDiscount)
{
if (!empty($hideDiscount)) {
if (! empty($hideDiscount)) {
return $hideDiscount;
}
@ -645,7 +658,7 @@ abstract class DocumentTemplate extends Base
protected function getHideAmount($type, $hideAmount)
{
if (!empty($hideAmount)) {
if (! empty($hideAmount)) {
return $hideAmount;
}

View File

@ -0,0 +1,307 @@
<?php
namespace App\Abstracts\View\Components;
use App\Abstracts\View\Component;
use Illuminate\Support\Collection;
abstract class Form extends Component
{
/** @var string */
public $type;
/** @var string */
public $name;
/** @var string */
public $label;
/** @var string */
public $id;
public $value;
/** @var string */
public $valueKey;
/** @var string */
public $placeholder;
/** @var array */
public $options;
/** @var array */
public $option;
/** @var string */
public $optionKey;
/** @var string */
public $optionValue;
/** @var string */
public $checked;
/** @var string */
public $checkedKey;
/** @var string */
public $selected;
/** @var string */
public $selectedKey;
/** @var string */
public $rows;
/** @var bool */
public $remote;
/** @var bool */
public $multiple;
/** @var bool */
public $addNew;
/** @var bool */
public $group;
/** @var bool */
public $disabled;
/** @var bool */
public $readonly;
/** @var bool */
public $required;
/** @var bool */
public $notRequired;
/** @var string */
public $formGroupClass = 'sm:col-span-3';
/** @var string */
public $inputGroupClass = '';
/** @var array */
public $custom_attributes = [];
/** @var array */
public $dynamicAttributes = [];
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $name = '', string $type = 'text', string $label = '', string $id = null, $value = '', $valueKey = null, string $placeholder = '',
$options = [], $option = [], string $optionKey = 'id', string $optionValue = 'name', $checked = null, $checkedKey = null, $selected = null, $selectedKey = null, $rows = '3',
$remote = false, $multiple = false, $addNew = false, $group = false,
bool $disabled = false, bool $readonly = false, bool $required = true, bool $notRequired = false,
string $formGroupClass = '', string $inputGroupClass = '',
$dynamicAttributes = '',
) {
$this->type = $this->getType($type);
$this->name = $this->getName($name);
$this->label = $label;
$this->id = $id ?? $name;
$this->value = $this->getValue($value, $valueKey);
$this->placeholder = $this->getPlaceholder($placeholder);
$this->rows = $rows;
$this->remote = $remote;
$this->multiple = $multiple;
$this->addNew = $addNew;
$this->group = $group;
$this->disabled = $disabled;
$this->readonly = $readonly;
$this->required = $this->getRequired($required, $notRequired);
$this->options = $this->getOptions($options);
$this->option = $option;
$this->optionKey = $optionKey;
$this->optionValue = $optionValue;
$this->checked = $this->getChecked($checked, $checkedKey);
$this->selected = $this->getSelected($selected, $selectedKey);
$this->formGroupClass = $this->getFromGroupClass($formGroupClass);
$this->inputGroupClass = $this->getInputGroupClass($inputGroupClass);
$this->custom_attributes = $this->getCustomAttributes();
$this->setDynamicAttributes($dynamicAttributes);
}
protected function getType($type)
{
if (! empty($type) && (! empty($this->type) && $type != 'text')) {
return $type;
}
if (! empty($this->type)) {
return $this->type;
}
}
protected function getName($name)
{
if (! empty($name)) {
return $name;
}
return $this->name;
}
protected function getValue($value, $valueKey)
{
if ($value != '') {
return $value;
}
if (empty($valueKey)) {
$valueKey = $this->name;
}
if (empty($valueKey)) {
return '';
}
// set model value.
$model = $this->getParentData('model');
$value_keys = explode('.', $valueKey);
if (count($value_keys) > 1) {
$valueKey = $value_keys[0];
}
if (! empty($model->{$valueKey})) {
$value = $model->{$valueKey};
}
if ($model instanceof Collection) {
$value = $model->get($valueKey);
}
if (count($value_keys) > 1) {
$value = $value[0]->{$value_keys[1]};
}
if (empty($value) && request()->has($valueKey)) {
$value = request()->get($valueKey);
}
return old($valueKey, $value);
}
protected function getPlaceholder($placeholder)
{
if (! empty($placeholder)) {
return $placeholder;
}
$label = $this->label;
if (! empty($this->label) && ! empty($this->label->contents)) {
$label = $this->name;
}
return trans('general.form.enter', ['field' => $label]);
}
protected function getOptions($options)
{
if (! empty($options)) {
if (is_array($options) && ! $this->group) {
$o = collect();
foreach ($options as $key => $value) {
if (is_array($value)) {
$o->push((object) $value);
} else {
$o->push((object) [
'id' => $key,
'name' => $value,
]);
}
}
$options = $o;
}
return $options;
}
return [];
}
protected function getChecked($checked, $checkedKey)
{
return $this->getValue($checked, $checkedKey);
}
protected function getSelected($selected, $selectedKey)
{
return $this->getValue($selected, $selectedKey);
}
protected function getRequired($required, $notRequired)
{
if (! empty($notRequired)) {
return false;
}
return $required;
}
protected function getFromGroupClass($formGroupClass)
{
if (! empty($formGroupClass)) {
return $formGroupClass;
}
return $this->formGroupClass;
}
protected function getInputGroupClass($inputGroupClass)
{
if (! empty($inputGroupClass)) {
return $inputGroupClass;
}
return $this->inputGroupClass;
}
protected function getCustomAttributes()
{
$attributes = [];
if (! empty($this->required)) {
$attributes['required'] = $this->required;
}
if (! empty($this->disabled)) {
$attributes['disabled'] = $this->disabled;
}
if (! empty($this->readonly)) {
$attributes['readonly'] = $this->readonly;
}
foreach ($this->custom_attributes as $key => $value) {
$attributes[$key] = $value;
}
return $attributes;
}
protected function setDynamicAttributes($dynamicAttributes)
{
if (! empty($dynamicAttributes)) {
$this->dynamicAttributes = $dynamicAttributes;
}
}
}

View File

@ -1,175 +0,0 @@
<?php
namespace App\Abstracts\View\Components;
use Illuminate\View\Component;
use Illuminate\Support\Str;
abstract class Transaction extends Component
{
public function getTextFromConfig($type, $config_key, $default_key = '', $trans_type = 'trans')
{
$translation = '';
// if set config translation 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, $config_parameters = [])
{
$route = '';
// if set config trasnlation config_key
if ($route = config('type.' . $type . '.route.' . $config_key)) {
return $route;
}
$alias = config('type.' . $type . '.alias');
$prefix = config('type.' . $type . '.route.prefix');
// if use module set module alias
if (!empty($alias)) {
$route .= $alias . '.';
}
if (!empty($prefix)) {
$route .= $prefix . '.';
}
$route .= $config_key;
try {
route($route, $config_parameters);
} catch (\Exception $e) {
try {
$route = Str::plural($type, 2) . '.' . $config_key;
route($route, $config_parameters);
} catch (\Exception $e) {
$route = '';
}
}
return $route;
}
public function getPermissionFromConfig($type, $config_key)
{
$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 = $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;
return $permission;
}
public function getHideFromConfig($type, $config_key)
{
$hide = false;
$hides = config('type.' . $type . '.hide');
if (!empty($hides) && (in_array($config_key, $hides))) {
$hide = true;
}
return $hide;
}
public function getClassFromConfig($type, $config_key)
{
$class_key = 'type.' . $type . '.class.' . $config_key;
return config($class_key, '');
}
public function getCategoryFromConfig($type)
{
$category_type = '';
// if set config trasnlation config_key
if ($category_type = config('type.' . $type . '.category_type')) {
return $category_type;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$category_type = 'expense';
break;
case 'item':
$category_type = 'item';
break;
case 'other':
$category_type = 'other';
break;
case 'transfer':
$category_type = 'transfer';
break;
default:
$category_type = 'income';
break;
}
return $category_type;
}
}

View File

@ -1,23 +1,28 @@
<?php
namespace App\Abstracts\View\Components;
namespace App\Abstracts\View\Components\Transactions;
use App\Abstracts\View\Components\Transaction as Base;
use App\Abstracts\View\Component;
use App\Models\Common\Media;
use App\Traits\DateTime;
use App\Traits\Transactions;
use App\Utilities\Modules;
use File;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
use Image;
use Intervention\Image\Facades\Image;
use Intervention\Image\Exception\NotReadableException;
use Illuminate\Support\Facades\Storage;
use App\Traits\ViewComponents;
abstract class TransactionShow extends Base
abstract class Show extends Component
{
use DateTime, Transactions;
use DateTime, Transactions, ViewComponents;
public const OBJECT_TYPE = 'transaction';
public const DEFAULT_TYPE = 'transaction';
public const DEFAULT_PLURAL_TYPE = 'transactions';
public $type;
@ -34,9 +39,6 @@ abstract class TransactionShow extends Base
public $date_format;
/** @var string */
public $routePrefix;
/** @var bool */
public $hideButtonAddNew;
@ -49,6 +51,9 @@ abstract class TransactionShow extends Base
/** @var bool */
public $hideButtonDuplicate;
/** @var bool */
public $hideButtonConnect;
/** @var bool */
public $hideButtonPrint;
@ -61,6 +66,9 @@ abstract class TransactionShow extends Base
/** @var bool */
public $hideButtonPdf;
/** @var bool */
public $hideButtonEnd;
/** @var bool */
public $hideButtonDelete;
@ -68,13 +76,16 @@ abstract class TransactionShow extends Base
public $checkButtonReconciled;
/** @var bool */
public $hideButtonGroupDivider1;
public $hideDivider1;
/** @var bool */
public $hideButtonGroupDivider2;
public $hideDivider2;
/** @var bool */
public $hideButtonGroupDivider3;
public $hideDivider3;
/** @var bool */
public $hideDivider4;
/** @var string */
public $permissionCreate;
@ -100,6 +111,9 @@ abstract class TransactionShow extends Base
/** @var string */
public $routeContactShow;
/** @var string */
public $shareRoute;
/** @var string */
public $signedUrl;
@ -109,60 +123,15 @@ abstract class TransactionShow extends Base
/** @var string */
public $routeButtonPdf;
/** @var string */
public $routeButtonEnd;
/** @var string */
public $routeButtonDelete;
/** @var string */
public $textDeleteModal;
/** @var bool */
public $hideHeader;
/** @var bool */
public $hideHeaderAccount;
/** @var bool */
public $hideHeaderCategory;
/** @var bool */
public $hideHeaderContact;
/** @var bool */
public $hideHeaderAmount;
/** @var bool */
public $hideHeaderPaidAt;
/** @var string */
public $textHeaderAccount;
/** @var string */
public $textHeaderCategory;
/** @var string */
public $textHeaderContact;
/** @var string */
public $textHeaderAmount;
/** @var string */
public $textHeaderPaidAt;
/** @var string */
public $classHeaderAccount;
/** @var string */
public $classHeaderCategory;
/** @var string */
public $classHeaderContact;
/** @var string */
public $classHeaderAmount;
/** @var string */
public $classHeaderPaidAt;
/** @var bool */
public $hideCompany;
@ -190,6 +159,9 @@ abstract class TransactionShow extends Base
/** @var bool */
public $hideContentTitle;
/** @var bool */
public $hideNumber;
/** @var bool */
public $hidePaidAt;
@ -211,9 +183,15 @@ abstract class TransactionShow extends Base
/** @var bool */
public $hideAmount;
/** @var string */
public $textButtonAddNew;
/** @var string */
public $textContentTitle;
/** @var string */
public $textNumber;
/** @var string */
public $textPaidAt;
@ -298,24 +276,19 @@ abstract class TransactionShow extends Base
/** @var string */
public $routeDocumentShow;
/** @var bool */
public $hideSchedule;
/** @var bool */
public $hideChildren;
/** @var bool */
public $hideAttachment;
public $attachment;
/** @var bool */
public $hideFooter;
/** @var bool */
public $hideFooterHistories;
public $histories;
/** @var string */
public $textHistories;
/** @var string */
public $classFooterHistories;
/** @var array */
public $connectTranslations;
/** @var string */
public $textRecurringType;
@ -330,32 +303,28 @@ abstract class TransactionShow extends Base
*/
public function __construct(
$type, $transaction, $transactionTemplate = '', $logo = '', array $payment_methods = [],
bool $hideButtonAddNew = false, bool $hideButtonMoreActions = false, bool $hideButtonEdit = false, bool $hideButtonDuplicate = false, bool $hideButtonPrint = false, bool $hideButtonShare = false,
bool $hideButtonEmail = false, bool $hideButtonPdf = false, bool $hideButtonDelete = false, bool $checkButtonReconciled = true,
bool $hideButtonGroupDivider1 = false, bool $hideButtonGroupDivider2 = false, bool $hideButtonGroupDivider3 = false,
bool $hideButtonAddNew = false, bool $hideButtonMoreActions = false, bool $hideButtonEdit = false, bool $hideButtonDuplicate = false, bool $hideButtonConnect = false, bool $hideButtonPrint = false, bool $hideButtonShare = false,
bool $hideButtonEmail = false, bool $hideButtonPdf = false, bool $hideButtonEnd = false, bool $hideButtonDelete = false, bool $checkButtonReconciled = true,
bool $hideDivider1 = false, bool $hideDivider2 = false, bool $hideDivider3 = false, bool $hideDivider4 = false,
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
string $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $signedUrl = '',
string $routeButtonEmail = '', string $routeButtonPdf = '', string $routeButtonDelete = '', string $routeContactShow = '',
string $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $shareRoute = '', string $signedUrl = '',
string $routeButtonEmail = '', string $routeButtonPdf = '', string $routeButtonEnd = '', string $routeButtonDelete = '', string $routeContactShow = '',
string $textDeleteModal = '',
bool $hideHeader = false, bool $hideHeaderAccount = false, bool $hideHeaderCategory = false, bool $hideHeaderContact = false, bool $hideHeaderAmount = false, bool $hideHeaderPaidAt = false,
string $textHeaderAccount = '', string $textHeaderCategory = '', string $textHeaderContact = '', string $textHeaderAmount = '', string $textHeaderPaidAt = '',
string $classHeaderAccount = '', string $classHeaderCategory = '', string $classHeaderContact = '', string $classHeaderAmount = '', string $classHeaderPaidAt = '',
bool $hideCompany = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, bool $hideCompanyName = false, bool $hideCompanyAddress = false,
bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false,
bool $hideContentTitle = false,bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false, bool $hideDescription = false,
bool $hideAmount = false,
string $textContentTitle = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '', string $textDescription = '',
bool $hideContentTitle = false, bool $hideNumber = false, bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false,
bool $hideDescription = false, bool $hideAmount = false,
string $textContentTitle = '', string $textNumber = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '', string $textDescription = '',
string $textAmount = '', string $textPaidBy = '',
bool $hideContact = false, bool $hideContactInfo = false, bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false,
bool $hideContactPhone = false, bool $hideContactEmail = false,
bool $hideRelated = false, bool $hideRelatedDocumentNumber = false, bool $hideRelatedContact = false, bool $hideRelatedDocumentDate = false, bool $hideRelatedDocumentAmount = false, bool $hideRelatedAmount = false,
string $textRelatedTransansaction = '', string $textRelatedDocumentNumber = '', string $textRelatedContact = '', string $textRelatedDocumentDate = '', string $textRelatedDocumentAmount = '', string $textRelatedAmount = '',
string $routeDocumentShow = '',
string $routeDocumentShow = '', string $textButtonAddNew = '',
bool $hideAttachment = false, $attachment = [],
bool $hideFooter = false, bool $hideFooterHistories = false, $histories = [],
string $textHistories = '', string $classFooterHistories = '', string $textRecurringType = '', bool $hideRecurringMessage = false
bool $hideSchedule = false, bool $hideChildren = false, bool $hideAttachment = false, $attachment = [],
array $connectTranslations = [], string $textRecurringType = '', bool $hideRecurringMessage = false
) {
$this->type = $type;
$this->transaction = $transaction;
@ -363,24 +332,25 @@ abstract class TransactionShow extends Base
$this->logo = $this->getLogo($logo);
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
$this->date_format = $this->getCompanyDateFormat();
$this->textRecurringType = $this->getTextRecurringType($type, $textRecurringType);
$this->hideRecurringMessage = $hideRecurringMessage;
$this->routePrefix = $this->getRoutePrefix($type);
// Navbar Hide
$this->hideButtonAddNew = $hideButtonAddNew;
$this->hideButtonMoreActions = $hideButtonMoreActions;
$this->hideButtonEdit = $hideButtonEdit;
$this->hideButtonDuplicate = $hideButtonDuplicate;
$this->hideButtonPrint = $hideButtonPrint;
$this->hideButtonDuplicate = $hideButtonDuplicate;
$this->hideButtonConnect = $hideButtonConnect;
$this->hideButtonPrint = $hideButtonPrint;
$this->hideButtonShare = $hideButtonShare;
$this->hideButtonEmail = $hideButtonEmail;
$this->hideButtonPdf = $hideButtonPdf;
$this->hideButtonPdf = $hideButtonPdf;
$this->hideButtonEnd = $hideButtonEnd;
$this->hideButtonDelete = $hideButtonDelete;
$this->checkButtonReconciled = $checkButtonReconciled;
$this->hideButtonGroupDivider1 = $hideButtonGroupDivider1;
$this->hideButtonGroupDivider2 = $hideButtonGroupDivider2;
$this->hideButtonGroupDivider3 = $hideButtonGroupDivider3;
$this->hideDivider1 = $hideDivider1;
$this->hideDivider2 = $hideDivider2;
$this->hideDivider3 = $hideDivider3;
$this->hideDivider4 = $hideDivider4;
// Navbar Permission
$this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
@ -392,38 +362,23 @@ abstract class TransactionShow extends Base
$this->routeButtonEdit = $this->getRouteButtonEdit($type, $routeButtonEdit);
$this->routeButtonDuplicate = $this->getRouteButtonDuplicate($type, $routeButtonDuplicate);
$this->routeButtonPrint = $this->getRouteButtonPrint($type, $routeButtonPrint);
$this->shareRoute = $this->getShareRoute($type, $shareRoute);
$this->signedUrl = $this->getSignedUrl($type, $signedUrl);
$this->routeButtonEmail = $this->getRouteButtonEmail($type, $routeButtonEmail);
$this->routeButtonPdf = $this->getRouteButtonPdf($type, $routeButtonPdf);
$this->routeButtonEnd = $this->getRouteButtonEnd($type, $routeButtonEnd);
$this->routeButtonDelete = $this->getRouteButtonDelete($type, $routeButtonDelete);
$this->routeContactShow = $this->getRouteContactShow($type, $routeContactShow);
// Navbar Text
$this->textButtonAddNew = $this->getTextButtonAddNew($type, $textButtonAddNew);
$this->textDeleteModal = $textDeleteModal;
// Header Hide
$this->hideHeader = $hideHeader;
// Hide Schedule
$this->hideSchedule = $hideSchedule;
$this->hideHeaderAccount = $hideHeaderAccount;
$this->hideHeaderCategory = $hideHeaderCategory;
$this->hideHeaderContact = $hideHeaderContact;
$this->hideHeaderCategory = $hideHeaderCategory;
$this->hideHeaderAmount = $hideHeaderAmount;
$this->hideHeaderPaidAt = $hideHeaderPaidAt;
// Header Text
$this->textHeaderAccount = $this->getTextHeaderAccount($type, $textHeaderAccount);
$this->textHeaderCategory = $this->getTextHeaderCategory($type, $textHeaderCategory);
$this->textHeaderContact = $this->getTextHeaderContact($type, $textHeaderContact);
$this->textHeaderAmount = $this->getTextHeaderAmount($type, $textHeaderAmount);
$this->textHeaderPaidAt = $this->gettextHeaderPaidAt($type, $textHeaderPaidAt);
// Header Class
$this->classHeaderAccount = $this->getClassHeaderAccount($type, $classHeaderAccount);
$this->classHeaderContact = $this->getClassHeaderContact($type, $classHeaderContact);
$this->classHeaderCategory = $this->getClassHeaderCategory($type, $classHeaderCategory);
$this->classHeaderAmount = $this->getClassHeaderAmount($type, $classHeaderAmount);
$this->classHeaderPaidAt = $this->getClassHeaderPaidAt($type, $classHeaderPaidAt);
// Hide Children
$this->hideChildren = $hideChildren;
// Hide Attachment
$this->hideAttachment = $hideAttachment;
@ -440,6 +395,7 @@ abstract class TransactionShow extends Base
// Transaction Information Hide checker
$this->hideContentTitle = $hideContentTitle;
$this->hideNumber = $hideNumber;
$this->hidePaidAt = $hidePaidAt;
$this->hideAccount = $hideAccount;
$this->hideCategory = $hideCategory;
@ -450,6 +406,7 @@ abstract class TransactionShow extends Base
// Transaction Information Text
$this->textContentTitle = $this->getTextContentTitle($type, $textContentTitle);
$this->textNumber = $this->getTextNumber($type, $textNumber);
$this->textPaidAt = $this->getTextPaidAt($type, $textPaidAt);
$this->textAccount = $this->getTextAccount($type, $textAccount);
$this->textCategory = $this->getTextCategory($type, $textCategory);
@ -495,14 +452,11 @@ abstract class TransactionShow extends Base
$this->attachment = $transaction->attachment;
}
// Histories Hide
$this->hideFooter = $hideFooter;
$this->hideFooterHistories = $hideFooterHistories;
// Connect translations
$this->connectTranslations = $this->getTranslationsForConnect($type);
// Histories
$this->histories = $this->getHistories($histories);
$this->textHistories = $this->getTextHistories($type, $textHistories);
$this->classFooterHistories = $this->getClassFooterHistories($type, $classFooterHistories);
$this->textRecurringType = $this->getTextRecurringType($type, $textRecurringType);
$this->hideRecurringMessage = $hideRecurringMessage;
}
protected function getTransactionTemplate($type, $transactionTemplate)
@ -511,7 +465,7 @@ abstract class TransactionShow extends Base
return $transactionTemplate;
}
if ($template = config('type.' . $type . 'template', false)) {
if ($template = config('type.transaction.' . $type . '.template', false)) {
return $template;
}
@ -580,13 +534,16 @@ abstract class TransactionShow extends Base
return $routeButtonAddNew;
}
$route = $this->getRouteFromConfig($type, 'create');
//example route parameter.
$parameter = 1;
$route = $this->getRouteFromConfig($type, 'create', $parameter);
if (!empty($route)) {
return $route;
}
return 'revenues.create';
return 'transactions.create';
}
protected function getRouteButtonEdit($type, $routeButtonEdit)
@ -604,7 +561,7 @@ abstract class TransactionShow extends Base
return $route;
}
return 'revenues.edit';
return 'transactions.edit';
}
protected function getRouteButtonDuplicate($type, $routeButtonDuplicate)
@ -622,7 +579,7 @@ abstract class TransactionShow extends Base
return $route;
}
return 'revenues.duplicate';
return 'transactions.duplicate';
}
protected function getRouteButtonPrint($type, $routeButtonPrint)
@ -640,7 +597,25 @@ abstract class TransactionShow extends Base
return $route;
}
return 'revenues.print';
return 'transactions.print';
}
protected function getShareRoute($type, $shareRoute)
{
if (! empty($shareRoute)) {
return $shareRoute;
}
//example route parameter.
$parameter = 1;
$route = $this->getRouteFromConfig($type, 'share', $parameter);
if (! empty($route)) {
return $route;
}
return 'modals.transactions.share.create';
}
protected function getSignedUrl($type, $signedUrl)
@ -649,8 +624,8 @@ abstract class TransactionShow extends Base
return $signedUrl;
}
$page = config('type.' . $type . '.route.prefix');
$alias = config('type.' . $type . '.alias');
$page = config('type.transaction.' . $type . '.route.prefix');
$alias = config('type.transaction.' . $type . '.alias');
$route = '';
@ -673,20 +648,20 @@ abstract class TransactionShow extends Base
protected function getRouteButtonEmail($type, $routeButtonEmail)
{
if (!empty($routeButtonEmail)) {
if (! empty($routeButtonEmail)) {
return $routeButtonEmail;
}
//example route parameter.
$parameter = 1;
$route = $this->getRouteFromConfig($type, 'email', $parameter);
$route = $this->getRouteFromConfig($type, 'emails.create', $parameter, true);
if (!empty($route)) {
if (! empty($route)) {
return $route;
}
return 'revenues.email';
return 'modals.transactions.emails.create';
}
protected function getRouteButtonPdf($type, $routeButtonPdf)
@ -704,7 +679,25 @@ abstract class TransactionShow extends Base
return $route;
}
return 'revenues.pdf';
return 'transactions.pdf';
}
protected function getRouteButtonEnd($type, $routeButtonEnd)
{
if (!empty($routeButtonEnd)) {
return $routeButtonEnd;
}
//example route parameter.
$parameter = 1;
$route = $this->getRouteFromConfig($type, 'end', $parameter);
if (!empty($route)) {
return $route;
}
return 'recurring-transactions.end';
}
protected function getRouteButtonDelete($type, $routeButtonDelete)
@ -722,7 +715,7 @@ abstract class TransactionShow extends Base
return $route;
}
return 'revenues.destroy';
return 'transactions.destroy';
}
protected function getRouteContactShow($type, $routeContactShow)
@ -734,7 +727,7 @@ abstract class TransactionShow extends Base
//example route parameter.
$parameter = 1;
$route = Str::plural(config('type.' . $type . '.contact_type'), 2) . '.show';
$route = Str::plural(config('type.transaction.' . $type . '.contact_type'), 2) . '.show';
try {
route($route, $parameter);
@ -755,189 +748,19 @@ abstract class TransactionShow extends Base
return 'customers.show';
}
protected function getPermissionCreate($type, $permissionCreate)
protected function getTextButtonAddNew($type, $textButtonAddNew)
{
if (!empty($permissionCreate)) {
return $permissionCreate;
if (!empty($textButtonAddNew)) {
return $textButtonAddNew;
}
$permissionCreate = $this->getPermissionFromConfig($type, 'create');
return $permissionCreate;
}
protected function getPermissionUpdate($type, $permissionUpdate)
{
if (!empty($permissionUpdate)) {
return $permissionUpdate;
}
$permissionUpdate = $this->getPermissionFromConfig($type, 'update');
return $permissionUpdate;
}
protected function getPermissionDelete($type, $permissionDelete)
{
if (!empty($permissionDelete)) {
return $permissionDelete;
}
$permissionDelete = $this->getPermissionFromConfig($type, 'delete');
return $permissionDelete;
}
protected function getTextHeaderAccount($type, $textHeaderAccount)
{
if (!empty($textHeaderAccount)) {
return $textHeaderAccount;
}
$translation = $this->getTextFromConfig($type, 'header_account', 'accounts', 'trans_choice');
$translation = $this->getTextFromConfig($type, 'transactions');
if (!empty($translation)) {
return $translation;
return trans('general.title.new', ['type' => trans_choice($translation, 1)]);
}
return 'general.accounts';
}
protected function getTextHeaderCategory($type, $textHeaderCategory)
{
if (!empty($textHeaderCategory)) {
return $textHeaderCategory;
}
$translation = $this->getTextFromConfig($type, 'header_category', 'categories', 'trans_choice');
if (!empty($translation)) {
return $translation;
}
return 'general.categories';
}
protected function getTextHeaderContact($type, $textHeaderContact)
{
if (!empty($textHeaderContact)) {
return $textHeaderContact;
}
$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 'general.customers';
}
protected function getTextHeaderAmount($type, $textHeaderAmount)
{
if (!empty($textHeaderAmount)) {
return $textHeaderAmount;
}
$translation = $this->getTextFromConfig($type, 'header_amount', 'amount');
if (!empty($translation)) {
return $translation;
}
return 'general.amount';
}
protected function getTextHeaderPaidAt($type, $textHeaderPaidAt)
{
if (!empty($textHeaderPaidAt)) {
return $textHeaderPaidAt;
}
$translation = $this->getTextFromConfig($type, 'header_paid_at', 'date');
if (!empty($translation)) {
return $translation;
}
return 'general.date';
}
protected function getClassHeaderAccount($type, $classHeaderAccount)
{
if (!empty($classHeaderAccount)) {
return $classHeaderAccount;
}
$class = $this->getClassFromConfig($type, 'header_account');
if (!empty($class)) {
return $class;
}
return 'col-4 col-lg-3';
}
protected function getClassHeaderContact($type, $classHeaderContact)
{
if (!empty($classHeaderContact)) {
return $classHeaderContact;
}
$class = $this->getClassFromConfig($type, 'header_contact');
if (!empty($class)) {
return $class;
}
return 'col-4 col-lg-2';
}
protected function getClassHeaderCategory($type, $classHeaderCategory)
{
if (!empty($classHeaderCategory)) {
return $classHeaderCategory;
}
$class = $this->getClassFromConfig($type, 'header_category');
if (!empty($class)) {
return $class;
}
return 'col-4 col-lg-3';
}
protected function getClassHeaderAmount($type, $classHeaderAmount)
{
if (!empty($classHeaderAmount)) {
return $classHeaderAmount;
}
$class = $this->getClassFromConfig($type, 'header_amount');
if (!empty($class)) {
return $class;
}
return 'col-4 col-lg-2';
}
protected function getClassHeaderPaidAt($type, $classHeaderPaidAt)
{
if (!empty($classHeaderPaidAt)) {
return $classHeaderPaidAt;
}
$class = $this->getClassFromConfig($type, 'header_paid_at');
if (!empty($class)) {
return $class;
}
return 'col-4 col-lg-2';
return trans('general.title.new', ['type' => trans_choice('general.' . Str::plural($type), 1)]);
}
protected function getTextContentTitle($type, $textContentTitle)
@ -953,7 +776,7 @@ abstract class TransactionShow extends Base
$default_key = 'payment_made';
break;
default:
$default_key = 'revenue_received';
$default_key = 'receipts';
break;
}
@ -963,7 +786,16 @@ abstract class TransactionShow extends Base
return $translation;
}
return 'revenues.revenue_received';
return 'general.receipts';
}
protected function getTextNumber($type, $textNumber)
{
if (!empty($textNumber)) {
return $textNumber;
}
return 'general.numbers';
}
protected function getTextPaidAt($type, $textPaidAt)
@ -1094,7 +926,7 @@ abstract class TransactionShow extends Base
return $translation;
}
return 'revenues.paid_by';
return 'transactions.paid_by';
}
protected function getTextRelatedTransansaction($type, $textRelatedTransansaction)
@ -1120,7 +952,7 @@ abstract class TransactionShow extends Base
return $translation;
}
return 'revenues.related_invoice';
return 'transactions.related_invoice';
}
protected function getTextRelatedDocumentNumber($type, $textRelatedDocumentNumber)
@ -1144,7 +976,7 @@ abstract class TransactionShow extends Base
return $textRelatedContact;
}
$default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
$default_key = Str::plural(config('type.transaction.' . $type . '.contact_type'), 2);
$translation = $this->getTextFromConfig($type, 'related_contact', $default_key, 'trans_choice');
@ -1244,50 +1076,9 @@ abstract class TransactionShow extends Base
return 'invoices.show';
}
protected function getHistories($histories)
{
if (!empty($histories)) {
return $histories;
}
$histories[] = $this->transaction;
return $histories;
}
protected function getTextHistories($type, $textHistories)
{
if (!empty($textHistories)) {
return $textHistories;
}
$translation = $this->getTextFromConfig($type, 'histories', 'histories');
if (!empty($translation)) {
return $translation;
}
return 'invoices.histories';
}
protected function getClassFooterHistories($type, $classFooterHistories)
{
if (!empty($classFooterHistories)) {
return $classFooterHistories;
}
$class = $this->getClassFromConfig($type, 'footer_histories');
if (!empty($class)) {
return $class;
}
return 'col-sm-6 col-md-6 col-lg-6 col-xl-6';
}
protected function getTextRecurringType($type, $textRecurringType)
{
if (!empty($textRecurringType)) {
if (! empty($textRecurringType)) {
return $textRecurringType;
}
@ -1295,18 +1086,10 @@ abstract class TransactionShow extends Base
$translation = $this->getTextFromConfig($type, 'recurring_tye', $default_key);
if (!empty($translation)) {
if (! empty($translation)) {
return $translation;
}
return 'general.revenues';
}
protected function getRoutePrefix($type) {
if ($prefix = config('type.' . $type . '.route.prefix', false)){
return 'revenues';
}
return $prefix;
}
}

View File

@ -1,23 +1,27 @@
<?php
namespace App\Abstracts\View\Components;
namespace App\Abstracts\View\Components\Transactions;
use App\Abstracts\View\Components\Transaction as Base;
use App\Abstracts\View\Component;
use App\Models\Common\Media;
use App\Traits\DateTime;
use App\Traits\Transactions;
use App\Utilities\Modules;
use File;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use Image;
use Intervention\Image\Exception\NotReadableException;
use Storage;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\Facades\Image;
use Intervention\Image\Exception\NotReadableException;
use App\Traits\ViewComponents;
abstract class TransactionTemplate extends Base
abstract class Template extends Component
{
use DateTime;
use Transactions;
use DateTime, Transactions, ViewComponents;
public const OBJECT_TYPE = 'transaction';
public const DEFAULT_TYPE = 'transaction';
public const DEFAULT_PLURAL_TYPE = 'transactions';
/** @var string */
public $type;
@ -56,6 +60,9 @@ abstract class TransactionTemplate extends Base
/** @var bool */
public $hideContentTitle;
/** @var bool */
public $hideNumber;
/** @var bool */
public $hidePaidAt;
@ -80,6 +87,9 @@ abstract class TransactionTemplate extends Base
/** @var string */
public $textContentTitle;
/** @var string */
public $textNumber;
/** @var string */
public $textPaidAt;
@ -176,10 +186,10 @@ abstract class TransactionTemplate extends Base
$type, $transaction, $logo = '', array $payment_methods = [],
bool $hideCompany = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, bool $hideCompanyName = false, bool $hideCompanyAddress = false,
bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false,
bool $hideContentTitle = false,bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false, bool $hideDescription = false,
bool $hideAmount = false,
string $textContentTitle = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '', string $textDescription = '',
string $textAmount = '', string $textPaidBy = '', string $textContactInfo = '',
bool $hideContentTitle = false, bool $hideNumber = false, bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false,
bool $hideDescription = false, bool $hideAmount = false,
string $textContentTitle = '', string $textNumber = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '',
string $textDescription = '', string $textAmount = '', string $textPaidBy = '', string $textContactInfo = '',
bool $hideContact = false, bool $hideContactInfo = false, bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false,
bool $hideContactPhone = false, bool $hideContactEmail = false,
bool $hideRelated = false, bool $hideRelatedDocumentNumber = false, bool $hideRelatedContact = false, bool $hideRelatedDocumentDate = false, bool $hideRelatedDocumentAmount = false, bool $hideRelatedAmount = false,
@ -204,6 +214,7 @@ abstract class TransactionTemplate extends Base
// Transaction Information Hide checker
$this->hideContentTitle = $hideContentTitle;
$this->hideNumber = $hideNumber;
$this->hidePaidAt = $hidePaidAt;
$this->hideAccount = $hideAccount;
$this->hideCategory = $hideCategory;
@ -214,6 +225,7 @@ abstract class TransactionTemplate extends Base
// Transaction Information Text
$this->textContentTitle = $this->getTextContentTitle($type, $textContentTitle);
$this->textNumber = $this->getTextNumber($type, $textNumber);
$this->textPaidAt = $this->getTextPaidAt($type, $textPaidAt);
$this->textAccount = $this->getTextAccount($type, $textAccount);
$this->textCategory = $this->getTextCategory($type, $textCategory);
@ -252,26 +264,6 @@ abstract class TransactionTemplate extends Base
$this->routeDocumentShow = $this->routeDocumentShow($type, $routeDocumentShow);
}
protected function getTextContactInfo($type, $textContactInfo)
{
if (!empty($textContactInfo)) {
return $textContactInfo;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textContactInfo = 'bills.bill_from';
break;
default:
$textContactInfo = 'invoices.bill_to';
break;
}
return $textContactInfo;
}
protected function getLogo($logo)
{
if (!empty($logo)) {
@ -339,7 +331,7 @@ abstract class TransactionTemplate extends Base
$default_key = 'payment_made';
break;
default:
$default_key = 'revenue_received';
$default_key = 'receipts';
break;
}
@ -349,7 +341,16 @@ abstract class TransactionTemplate extends Base
return $translation;
}
return 'revenues.revenue_received';
return 'general.receipts';
}
protected function getTextNumber($type, $textNumber)
{
if (!empty($textNumber)) {
return $textNumber;
}
return 'general.numbers';
}
protected function getTextPaidAt($type, $textPaidAt)
@ -480,7 +481,27 @@ abstract class TransactionTemplate extends Base
return $translation;
}
return 'revenues.paid_by';
return 'transactions.paid_by';
}
protected function getTextContactInfo($type, $textContactInfo)
{
if (!empty($textContactInfo)) {
return $textContactInfo;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textContactInfo = 'bills.bill_from';
break;
default:
$textContactInfo = 'invoices.bill_to';
break;
}
return $textContactInfo;
}
protected function getTextRelatedTransansaction($type, $textRelatedTransansaction)
@ -506,7 +527,7 @@ abstract class TransactionTemplate extends Base
return $translation;
}
return 'revenues.related_invoice';
return 'transactions.related_invoice';
}
protected function getTextRelatedDocumentNumber($type, $textRelatedDocumentNumber)
@ -530,7 +551,7 @@ abstract class TransactionTemplate extends Base
return $textRelatedContact;
}
$default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
$default_key = Str::plural(config('type.transaction.' . $type . '.contact_type'), 2);
$translation = $this->getTextFromConfig($type, 'related_contact', $default_key, 'trans_choice');

View File

@ -1,747 +0,0 @@
<?php
namespace App\Abstracts\View\Components;
use App\Models\Common\Media;
use App\Traits\DateTime;
use App\Traits\Transactions;
use App\Utilities\Modules;
use File;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
use Image;
use Intervention\Image\Exception\NotReadableException;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\Component;
abstract class TransferShow extends Component
{
use DateTime, Transactions;
public $transfer;
/** @var string */
public $transferTemplate;
/** @var array */
public $payment_methods;
public $date_format;
/** @var bool */
public $hideButtonAddNew;
/** @var bool */
public $hideButtonMoreActions;
/** @var bool */
public $hideButtonEdit;
/** @var bool */
public $hideButtonDuplicate;
/** @var bool */
public $hideButtonPrint;
/** @var bool */
public $hideButtonShare;
/** @var bool */
public $hideButtonEmail;
/** @var bool */
public $hideButtonPdf;
/** @var bool */
public $hideButtonDelete;
/** @var bool */
public $hideButtonGroupDivider1;
/** @var bool */
public $hideButtonGroupDivider2;
/** @var bool */
public $hideButtonGroupDivider3;
/** @var string */
public $permissionCreate;
/** @var string */
public $permissionUpdate;
/** @var string */
public $permissionDelete;
/** @var string */
public $routeButtonAddNew;
/** @var string */
public $routeButtonEdit;
/** @var string */
public $routeButtonDuplicate;
/** @var string */
public $routeButtonPrint;
/** @var string */
public $signedUrl;
/** @var string */
public $routeButtonEmail;
/** @var string */
public $routeButtonPdf;
/** @var string */
public $hideButtonTemplate;
/** @var string */
public $routeButtonDelete;
/** @var string */
public $routeFromAccountShow;
/** @var string */
public $routeToAccountShow;
/** @var string */
public $textDeleteModal;
/** @var bool */
public $hideHeader;
/** @var bool */
public $hideHeaderFromAccount;
/** @var bool */
public $hideHeaderToAccount;
/** @var bool */
public $hideHeaderAmount;
/** @var bool */
public $hideHeaderPaidAt;
/** @var string */
public $textHeaderFromAccount;
/** @var string */
public $textHeaderToAccount;
/** @var string */
public $textHeaderAmount;
/** @var string */
public $textHeaderPaidAt;
/** @var string */
public $classHeaderFromAccount;
/** @var string */
public $classHeaderToAccount;
/** @var string */
public $classHeaderAmount;
/** @var string */
public $classHeaderPaidAt;
/** @var bool */
public $hideFromAccount;
/** @var bool */
public $hideFromAccountTitle;
/** @var bool */
public $hideFromAccountName;
/** @var bool */
public $hideFromAccountNumber;
/** @var bool */
public $hideFromAccountBankName;
/** @var bool */
public $hideFromAccountBankPhone;
/** @var bool */
public $hideFromAccountBankAddress;
/** @var string */
public $textFromAccountTitle;
/** @var string */
public $textFromAccountNumber;
/** @var bool */
public $hideToAccount;
/** @var bool */
public $hideToAccountTitle;
/** @var bool */
public $hideToAccountName;
/** @var bool */
public $hideToAccountNumber;
/** @var bool */
public $hideToAccountBankName;
/** @var bool */
public $hideToAccountBankPhone;
/** @var bool */
public $hideToAccountBankAddress;
/** @var string */
public $textToAccountTitle;
/** @var string */
public $textToAccountNumber;
/** @var bool */
public $hideDetails;
/** @var bool */
public $hideDetailTitle;
/** @var bool */
public $hideDetailDate;
/** @var bool */
public $hideDetailPaymentMethod;
/** @var bool */
public $hideDetailReference;
/** @var bool */
public $hideDetailDescription;
/** @var bool */
public $hideDetailAmount;
/** @var string */
public $textDetailTitle;
/** @var string */
public $textDetailDate;
/** @var string */
public $textDetailPaymentMethod;
/** @var string */
public $textDetailReference;
/** @var string */
public $textDetailDescription;
/** @var string */
public $textDetailAmount;
/** @var bool */
public $hideAttachment;
public $attachment;
/** @var bool */
public $hideFooter;
/** @var bool */
public $hideFooterHistories;
public $histories;
/** @var string */
public $textHistories;
/** @var string */
public $classFooterHistories;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
$transfer, $transferTemplate = '', array $payment_methods = [],
bool $hideButtonAddNew = false, bool $hideButtonMoreActions = false, bool $hideButtonEdit = false, bool $hideButtonDuplicate = false, bool $hideButtonPrint = false, bool $hideButtonShare = false,
bool $hideButtonEmail = false, bool $hideButtonPdf = false, bool $hideButtonTemplate = false, bool $hideButtonDelete = false,
bool $hideButtonGroupDivider1 = false, bool $hideButtonGroupDivider2 = false, bool $hideButtonGroupDivider3 = false,
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
string $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $signedUrl = '',
string $routeButtonEmail = '', string $routeButtonPdf = '', string $routeButtonDelete = '', string $routeFromAccountShow = '', string $routeToAccountShow = '',
string $textDeleteModal = '',
bool $hideHeader = false, bool $hideHeaderFromAccount = false, bool $hideHeaderToAccount = false, bool $hideHeaderAmount = false, bool $hideHeaderPaidAt = false,
string $textHeaderFromAccount = '', string $textHeaderToAccount = '', string $textHeaderAmount = '', string $textHeaderPaidAt = '',
string $classHeaderFromAccount = '', string $classHeaderToAccount = '', string $classHeaderAmount = '', string $classHeaderPaidAt = '',
bool $hideFromAccount = false, bool $hideFromAccountTitle = false, bool $hideFromAccountName = false, bool $hideFromAccountNumber = false,
bool $hideFromAccountBankName = false, bool $hideFromAccountBankPhone = false, bool $hideFromAccountBankAddress = false,
string $textFromAccountTitle = '', string $textFromAccountNumber = '',
bool $hideToAccount = false, bool $hideToAccountTitle = false, bool $hideToAccountName = false, bool $hideToAccountNumber = false,
bool $hideToAccountBankName = false, bool $hideToAccountBankPhone = false, bool $hideToAccountBankAddress = false,
string $textToAccountTitle = '', string $textToAccountNumber = '',
bool $hideDetails = false, bool $hideDetailTitle = false, bool $hideDetailDate = false, bool $hideDetailPaymentMethod = false,
bool $hideDetailReference = false, bool $hideDetailDescription = false, bool $hideDetailAmount = false,
string $textDetailTitle = '', string $textDetailDate = '', string $textDetailPaymentMethod = '', string $textDetailReference = '',
string $textDetailDescription = '', string $textDetailAmount = '',
bool $hideAttachment = false, $attachment = [],
bool $hideFooter = false, bool $hideFooterHistories = false, $histories = [],
string $textHistories = '', string $classFooterHistories = ''
) {
$this->transfer = $transfer;
$this->transferTemplate = $this->getTransferTemplate($transferTemplate);
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
$this->date_format = $this->getCompanyDateFormat();
// Navbar Hide
$this->hideButtonAddNew = $hideButtonAddNew;
$this->hideButtonMoreActions = $hideButtonMoreActions;
$this->hideButtonEdit = $hideButtonEdit;
$this->hideButtonDuplicate = $hideButtonDuplicate;
$this->hideButtonPrint = $hideButtonPrint;
$this->hideButtonShare = $hideButtonShare;
$this->hideButtonEmail = $hideButtonEmail;
$this->hideButtonPdf = $hideButtonPdf;
$this->hideButtonTemplate = $hideButtonTemplate;
$this->hideButtonDelete = $hideButtonDelete;
$this->hideButtonGroupDivider1 = $hideButtonGroupDivider1;
$this->hideButtonGroupDivider2 = $hideButtonGroupDivider2;
$this->hideButtonGroupDivider3 = $hideButtonGroupDivider3;
// Navbar Permission
$this->permissionCreate = $this->getPermissionCreate($permissionCreate);
$this->permissionUpdate = $this->getPermissionUpdate($permissionUpdate);
$this->permissionDelete = $this->getPermissionDelete($permissionDelete);
// Navbar route
$this->routeButtonAddNew = $this->getRouteButtonAddNew($routeButtonAddNew);
$this->routeButtonEdit = $this->getRouteButtonEdit($routeButtonEdit);
$this->routeButtonDuplicate = $this->getRouteButtonDuplicate($routeButtonDuplicate);
$this->routeButtonPrint = $this->getRouteButtonPrint($routeButtonPrint);
$this->signedUrl = $this->getSignedUrl($signedUrl);
$this->routeButtonEmail = $this->getRouteButtonEmail($routeButtonEmail);
$this->routeButtonPdf = $this->getRouteButtonPdf($routeButtonPdf);
$this->routeButtonDelete = $this->getRouteButtonDelete($routeButtonDelete);
$this->routeFromAccountShow = $this->getRouteFromAccountShow($routeFromAccountShow);
$this->routeToAccountShow = $this->getRouteToAccountShow($routeToAccountShow);
// Navbar Text
$this->textDeleteModal = $textDeleteModal;
// Header Hide
$this->hideHeader = $hideHeader;
$this->hideHeaderFromAccount = $hideHeaderFromAccount;
$this->hideHeaderToAccount = $hideHeaderToAccount;
$this->hideHeaderToAccount = $hideHeaderToAccount;
$this->hideHeaderAmount = $hideHeaderAmount;
$this->hideHeaderPaidAt = $hideHeaderPaidAt;
// Header Text
$this->textHeaderFromAccount = $this->getTextHeaderFromAccount($textHeaderFromAccount);
$this->textHeaderToAccount = $this->getTextHeaderToAccount($textHeaderToAccount);
$this->textHeaderAmount = $this->getTextHeaderAmount($textHeaderAmount);
$this->textHeaderPaidAt = $this->gettextHeaderPaidAt($textHeaderPaidAt);
// Header Class
$this->classHeaderFromAccount = $this->getclassHeaderFromAccount($classHeaderFromAccount);
$this->classHeaderToAccount = $this->getClassHeaderToAccount($classHeaderToAccount);
$this->classHeaderAmount = $this->getClassHeaderAmount($classHeaderAmount);
$this->classHeaderPaidAt = $this->getclassHeaderPaidAt($classHeaderPaidAt);
// From account Hide
$this->hideFromAccount = $hideFromAccount;
$this->hideFromAccountTitle = $hideFromAccountTitle;
$this->hideFromAccountName = $hideFromAccountName;
$this->hideFromAccountNumber = $hideFromAccountNumber;
$this->hideFromAccountBankName = $hideFromAccountBankName;
$this->hideFromAccountBankPhone = $hideFromAccountBankPhone;
$this->hideFromAccountBankAddress = $hideFromAccountBankAddress;
// From account text
$this->textFromAccountTitle = $this->getTextFromAccountTitle($textFromAccountTitle);
$this->textFromAccountNumber = $this->getTextFromAccountNumber($textFromAccountNumber);
// To account Hide
$this->hideToAccount = $hideToAccount;
$this->hideToAccountTitle = $hideToAccountTitle;
$this->hideToAccountName = $hideToAccountName;
$this->hideToAccountNumber = $hideToAccountNumber;
$this->hideToAccountBankName = $hideToAccountBankName;
$this->hideToAccountBankPhone = $hideToAccountBankPhone;
$this->hideToAccountBankAddress = $hideToAccountBankAddress;
// To account text
$this->textToAccountTitle = $this->getTextToAccountTitle($textToAccountTitle);
$this->textToAccountNumber = $this->getTextToAccountNumber($textToAccountNumber);
// Detail Information Hide checker
$this->hideDetails = $hideDetails;
$this->hideDetailTitle = $hideDetailTitle;
$this->hideDetailDate = $hideDetailDate;
$this->hideDetailPaymentMethod = $hideDetailPaymentMethod;
$this->hideDetailReference = $hideDetailReference;
$this->hideDetailDescription = $hideDetailDescription;
$this->hideDetailAmount = $hideDetailAmount;
// Related Information Text
$this->textDetailTitle = $this->getTextDetailTitle($textDetailTitle);
$this->textDetailDate = $this->getTextDetailDate($textDetailDate);
$this->textDetailPaymentMethod = $this->getTextDetailPaymentMethod($textDetailPaymentMethod);
$this->textDetailReference = $this->getTextDetailReference($textDetailReference);
$this->textDetailDescription = $this->getTextDetailDescription($textDetailDescription);
$this->textDetailAmount = $this->getTextDetailAmount($textDetailAmount);
// Hide Attachment
$this->hideAttachment = $hideAttachment;
// Attachment data..
$this->attachment = '';
if (!empty($attachment)) {
$this->attachment = $attachment;
} else if (!empty($transfer)) {
$this->attachment = $transfer->attachment;
}
// Histories Hide
$this->hideFooter = $hideFooter;
$this->hideFooterHistories = $hideFooterHistories;
// Histories
$this->histories = $this->getHistories($histories);
$this->textHistories = $this->getTextHistories($textHistories);
$this->classFooterHistories = $this->getClassFooterHistories($classFooterHistories);
}
protected function getTransferTemplate($transferTemplate)
{
if (!empty($transferTemplate)) {
return $transferTemplate;
}
return setting('transfer.template');
}
protected function getRouteButtonAddNew($routeButtonAddNew)
{
if (!empty($routeButtonAddNew)) {
return $routeButtonAddNew;
}
return 'transfers.create';
}
protected function getRouteButtonEdit($routeButtonEdit)
{
if (!empty($routeButtonEdit)) {
return $routeButtonEdit;
}
return 'transfers.edit';
}
protected function getRouteButtonDuplicate($routeButtonDuplicate)
{
if (!empty($routeButtonDuplicate)) {
return $routeButtonDuplicate;
}
return 'transfers.duplicate';
}
protected function getRouteButtonPrint($routeButtonPrint)
{
if (!empty($routeButtonPrint)) {
return $routeButtonPrint;
}
return 'transfers.print';
}
protected function getSignedUrl($signedUrl)
{
if (!empty($signedUrl)) {
return $signedUrl;
}
try {
$signedUrl = URL::signedRoute('signed.transfer.show', [$this->transfer->id]);
} catch (\Exception $e) {
$signedUrl = false;
}
return $signedUrl;
}
protected function getRouteButtonEmail($routeButtonEmail)
{
if (!empty($routeButtonEmail)) {
return $routeButtonEmail;
}
return 'transfers.email';
}
protected function getRouteButtonPdf($routeButtonPdf)
{
if (!empty($routeButtonPdf)) {
return $routeButtonPdf;
}
return 'transfers.pdf';
}
protected function getRouteButtonDelete($routeButtonDelete)
{
if (!empty($routeButtonDelete)) {
return $routeButtonDelete;
}
return 'transfers.destroy';
}
protected function getRouteFromAccountShow($routeFromAccountShow)
{
if (!empty($routeFromAccountShow)) {
return $routeFromAccountShow;
}
return 'accounts.show';
}
protected function getRouteToAccountShow($routeToAccountShow)
{
if (!empty($routeToAccountShow)) {
return $routeToAccountShow;
}
return 'accounts.show';
}
protected function getPermissionCreate($permissionCreate)
{
if (!empty($permissionCreate)) {
return $permissionCreate;
}
return 'create-banking-transfers';
}
protected function getPermissionUpdate($permissionUpdate)
{
if (!empty($permissionUpdate)) {
return $permissionUpdate;
}
return 'update-banking-transfers';
}
protected function getPermissionDelete($permissionDelete)
{
if (!empty($permissionDelete)) {
return $permissionDelete;
}
return 'delete-banking-transfers';
}
protected function getTextHeaderFromAccount($textHeaderFromAccount)
{
if (!empty($textHeaderFromAccount)) {
return $textHeaderFromAccount;
}
return 'transfers.from_account';
}
protected function getTextHeaderToAccount($textHeaderToAccount)
{
if (!empty($textHeaderToAccount)) {
return $textHeaderToAccount;
}
return 'transfers.to_account';
}
protected function getTextHeaderAmount($textHeaderAmount)
{
if (!empty($textHeaderAmount)) {
return $textHeaderAmount;
}
return 'general.amount';
}
protected function getTextHeaderPaidAt($textHeaderPaidAt)
{
if (!empty($textHeaderPaidAt)) {
return $textHeaderPaidAt;
}
return 'general.date';
}
protected function getClassHeaderFromAccount($classHeaderFromAccount)
{
if (!empty($classHeaderFromAccount)) {
return $classHeaderFromAccount;
}
return 'col-4 col-lg-2';
}
protected function getClassHeaderToAccount($classHeaderToAccount)
{
if (!empty($classHeaderToAccount)) {
return $classHeaderToAccount;
}
return 'col-4 col-lg-6';
}
protected function getClassHeaderAmount($classHeaderAmount)
{
if (!empty($classHeaderAmount)) {
return $classHeaderAmount;
}
return 'col-4 col-lg-2 float-right';
}
protected function getClassHeaderPaidAt($classHeaderPaidAt)
{
if (!empty($classHeaderPaidAt)) {
return $classHeaderPaidAt;
}
return 'col-4 col-lg-2';
}
protected function getTextFromAccountTitle($textToAccountTitle)
{
if (!empty($textToAccountTitle)) {
return $textToAccountTitle;
}
return 'transfers.from_account';
}
protected function getTextFromAccountNumber($textFromAccountNumber)
{
if (!empty($textFromAccountNumber)) {
return $textFromAccountNumber;
}
return 'accounts.number';
}
protected function getTextToAccountTitle($textFromAccountTitle)
{
if (!empty($textFromAccountTitle)) {
return $textFromAccountTitle;
}
return 'transfers.to_account';
}
protected function getTextToAccountNumber($textToAccountNumber)
{
if (!empty($textToAccountNumber)) {
return $textToAccountNumber;
}
return 'accounts.number';
}
protected function getTextDetailTitle($textDetailTitle)
{
if (!empty($textDetailTitle)) {
return $textDetailTitle;
}
return 'transfers.details';
}
protected function getTextDetailDate($textDetailDate)
{
if (!empty($textDetailDate)) {
return $textDetailDate;
}
return 'general.date';
}
protected function getTextDetailPaymentMethod($textDetailPaymentMethod)
{
if (!empty($textDetailPaymentMethod)) {
return $textDetailPaymentMethod;
}
return 'general.payment_methods';
}
protected function getTextDetailReference($textDetailReference)
{
if (!empty($textDetailReference)) {
return $textDetailReference;
}
return 'general.reference';
}
protected function getTextDetailDescription($textDetailDescription)
{
if (!empty($textDetailDescription)) {
return $textDetailDescription;
}
return 'general.description';
}
protected function getTextDetailAmount($textDetailAmount)
{
if (!empty($textDetailAmount)) {
return $textDetailAmount;
}
return 'general.amount';
}
protected function getHistories($histories)
{
if (!empty($histories)) {
return $histories;
}
$histories[] = $this->transfer;
return $histories;
}
protected function getTextHistories($textHistories)
{
if (!empty($textHistories)) {
return $textHistories;
}
return 'invoices.histories';
}
protected function getClassFooterHistories($classFooterHistories)
{
if (!empty($classFooterHistories)) {
return $classFooterHistories;
}
return 'col-sm-6 col-md-6 col-lg-6 col-xl-6';
}
}

View File

@ -1,278 +0,0 @@
<?php
namespace App\Abstracts\View\Components;
use App\Abstracts\View\Components\Transfer as Base;
use App\Models\Common\Media;
use App\Traits\DateTime;
use App\Traits\Transactions;
use App\Utilities\Modules;
use File;
use Illuminate\Support\Facades\Log;
use Image;
use Intervention\Image\Exception\NotReadableException;
use Storage;
use Illuminate\Support\Str;
use Illuminate\View\Component;
abstract class TransferTemplate extends Component
{
use DateTime;
use Transactions;
public $transfer;
/** @var array */
public $payment_methods;
/** @var bool */
public $hideFromAccount;
/** @var bool */
public $hideFromAccountTitle;
/** @var bool */
public $hideFromAccountName;
/** @var bool */
public $hideFromAccountNumber;
/** @var bool */
public $hideFromAccountBankName;
/** @var bool */
public $hideFromAccountBankPhone;
/** @var bool */
public $hideFromAccountBankAddress;
/** @var string */
public $textFromAccountTitle;
/** @var string */
public $textFromAccountNumber;
/** @var bool */
public $hideToAccount;
/** @var bool */
public $hideToAccountTitle;
/** @var bool */
public $hideToAccountName;
/** @var bool */
public $hideToAccountNumber;
/** @var bool */
public $hideToAccountBankName;
/** @var bool */
public $hideToAccountBankPhone;
/** @var bool */
public $hideToAccountBankAddress;
/** @var string */
public $textToAccountTitle;
/** @var string */
public $textToAccountNumber;
/** @var bool */
public $hideDetails;
/** @var bool */
public $hideDetailTitle;
/** @var bool */
public $hideDetailDate;
/** @var bool */
public $hideDetailPaymentMethod;
/** @var bool */
public $hideDetailReference;
/** @var bool */
public $hideDetailDescription;
/** @var bool */
public $hideDetailAmount;
/** @var string */
public $textDetailTitle;
/** @var string */
public $textDetailDate;
/** @var string */
public $textDetailPaymentMethod;
/** @var string */
public $textDetailReference;
/** @var string */
public $textDetailDescription;
/** @var string */
public $textDetailAmount;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
$transfer, array $payment_methods = [],
bool $hideFromAccount = false, bool $hideFromAccountTitle = false, bool $hideFromAccountName = false, bool $hideFromAccountNumber = false,
bool $hideFromAccountBankName = false, bool $hideFromAccountBankPhone = false, bool $hideFromAccountBankAddress = false,
string $textFromAccountTitle = '', string $textFromAccountNumber = '',
bool $hideToAccount = false, bool $hideToAccountTitle = false, bool $hideToAccountName = false, bool $hideToAccountNumber = false,
bool $hideToAccountBankName = false, bool $hideToAccountBankPhone = false, bool $hideToAccountBankAddress = false,
string $textToAccountTitle = '', string $textToAccountNumber = '',
bool $hideDetails = false, bool $hideDetailTitle = false, bool $hideDetailDate = false, bool $hideDetailPaymentMethod = false,
bool $hideDetailReference = false, bool $hideDetailDescription = false, bool $hideDetailAmount = false,
string $textDetailTitle = '', string $textDetailDate = '', string $textDetailPaymentMethod = '', string $textDetailReference = '',
string $textDetailDescription = '', string $textDetailAmount = ''
) {
$this->transfer = $transfer;
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
// From account Hide
$this->hideFromAccount = $hideFromAccount;
$this->hideFromAccountTitle = $hideFromAccountTitle;
$this->hideFromAccountName = $hideFromAccountName;
$this->hideFromAccountNumber = $hideFromAccountNumber;
$this->hideFromAccountBankName = $hideFromAccountBankName;
$this->hideFromAccountBankPhone = $hideFromAccountBankPhone;
$this->hideFromAccountBankAddress = $hideFromAccountBankAddress;
// From account text
$this->textFromAccountTitle = $this->getTextFromAccountTitle($textFromAccountTitle);
$this->textFromAccountNumber = $this->getTextFromAccountNumber($textFromAccountNumber);
// To account Hide
$this->hideToAccount = $hideToAccount;
$this->hideToAccountTitle = $hideToAccountTitle;
$this->hideToAccountName = $hideToAccountName;
$this->hideToAccountNumber = $hideToAccountNumber;
$this->hideToAccountBankName = $hideToAccountBankName;
$this->hideToAccountBankPhone = $hideToAccountBankPhone;
$this->hideToAccountBankAddress = $hideToAccountBankAddress;
// To account text
$this->textToAccountTitle = $this->getTextToAccountTitle($textToAccountTitle);
$this->textToAccountNumber = $this->getTextToAccountNumber($textToAccountNumber);
// Detail Information Hide checker
$this->hideDetails = $hideDetails;
$this->hideDetailTitle = $hideDetailTitle;
$this->hideDetailDate = $hideDetailDate;
$this->hideDetailPaymentMethod = $hideDetailPaymentMethod;
$this->hideDetailReference = $hideDetailReference;
$this->hideDetailDescription = $hideDetailDescription;
$this->hideDetailAmount = $hideDetailAmount;
// Related Information Text
$this->textDetailTitle = $this->getTextDetailTitle($textDetailTitle);
$this->textDetailDate = $this->getTextDetailDate($textDetailDate);
$this->textDetailPaymentMethod = $this->getTextDetailPaymentMethod($textDetailPaymentMethod);
$this->textDetailReference = $this->getTextDetailReference($textDetailReference);
$this->textDetailDescription = $this->getTextDetailDescription($textDetailDescription);
$this->textDetailAmount = $this->getTextDetailAmount($textDetailAmount);
}
protected function getTextFromAccountTitle($textToAccountTitle)
{
if (!empty($textToAccountTitle)) {
return $textToAccountTitle;
}
return 'transfers.from_account';
}
protected function getTextFromAccountNumber($textFromAccountNumber)
{
if (!empty($textFromAccountNumber)) {
return $textFromAccountNumber;
}
return 'accounts.number';
}
protected function getTextToAccountTitle($textFromAccountTitle)
{
if (!empty($textFromAccountTitle)) {
return $textFromAccountTitle;
}
return 'transfers.to_account';
}
protected function getTextToAccountNumber($textToAccountNumber)
{
if (!empty($textToAccountNumber)) {
return $textToAccountNumber;
}
return 'accounts.number';
}
protected function getTextDetailTitle($textDetailTitle)
{
if (!empty($textDetailTitle)) {
return $textDetailTitle;
}
return 'transfers.details';
}
protected function getTextDetailDate($textDetailDate)
{
if (!empty($textDetailDate)) {
return $textDetailDate;
}
return 'general.date';
}
protected function getTextDetailPaymentMethod($textDetailPaymentMethod)
{
if (!empty($textDetailPaymentMethod)) {
return $textDetailPaymentMethod;
}
return 'general.payment_methods';
}
protected function getTextDetailReference($textDetailReference)
{
if (!empty($textDetailReference)) {
return $textDetailReference;
}
return 'general.reference';
}
protected function getTextDetailDescription($textDetailDescription)
{
if (!empty($textDetailDescription)) {
return $textDetailDescription;
}
return 'general.description';
}
protected function getTextDetailAmount($textDetailAmount)
{
if (!empty($textDetailAmount)) {
return $textDetailAmount;
}
return 'general.amount';
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace App\Abstracts\View\Components\Transfers;
use App\Abstracts\View\Component;
use App\Traits\ViewComponents;
abstract class Show extends Component
{
use ViewComponents;
public $model;
public $transfer;
public $template;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
$model = false, $transfer = false, string $template = ''
) {
$this->model = $model;
$this->transfer = $this->getTransfer($model, $transfer);
$this->template = ! empty($template) ? $template : setting('transfer.template');
// Set Parent data
$this->setParentData();
}
protected function getTransfer($model, $transfer)
{
if (! empty($model)) {
return $model;
}
if (! empty($transfer)) {
return $transfer;
}
return false;
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace App\Abstracts\View\Components\Transfers;
use App\Abstracts\View\Component;
use App\Traits\ViewComponents;
abstract class Template extends Component
{
use ViewComponents;
public $model;
public $transfer;
public $template;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
$model = false, $transfer = false, string $template = ''
) {
$this->model = $model;
$this->transfer = $this->getTransfer($model, $transfer);
$this->template = ! empty($template) ? $template : setting('transfer.template');
// Set Parent data
$this->setParentData();
}
protected function getTransfer($model, $transfer)
{
if (! empty($model)) {
return $model;
}
if (! empty($transfer)) {
return $transfer;
}
return false;
}
}