akaunting/app/Abstracts/View/Components/TransactionShow.php

1301 lines
36 KiB
PHP
Raw Normal View History

2021-06-24 13:52:49 +03:00
<?php
namespace App\Abstracts\View\Components;
use App\Abstracts\View\Components\Transaction 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 Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
use Image;
use Intervention\Image\Exception\NotReadableException;
use Illuminate\Support\Facades\Storage;
abstract class TransactionShow extends Base
{
use DateTime, Transactions;
public $type;
public $transaction;
/** @var string */
public $transactionTemplate;
/** @var string */
public $logo;
2021-06-25 09:44:30 +03:00
/** @var array */
public $payment_methods;
2021-06-24 13:52:49 +03:00
public $date_format;
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideButtonAddNew;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideButtonMoreActions;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideButtonEdit;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideButtonDuplicate;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideButtonPrint;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideButtonShare;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideButtonEmail;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideButtonPdf;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideButtonDelete;
2021-06-24 13:52:49 +03:00
/** @var string */
2021-06-25 09:44:30 +03:00
public $checkButtonReconciled;
/** @var bool */
public $hideButtonGroupDivider1;
/** @var bool */
public $hideButtonGroupDivider2;
/** @var bool */
public $hideButtonGroupDivider3;
2021-06-24 13:52:49 +03:00
/** @var string */
public $permissionCreate;
/** @var string */
public $permissionUpdate;
/** @var string */
public $permissionDelete;
2021-06-25 09:44:30 +03:00
/** @var string */
public $routeButtonAddNew;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var string */
public $routeButtonEdit;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var string */
public $routeButtonDuplicate;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var string */
public $routeButtonPrint;
2021-06-24 13:52:49 +03:00
/** @var string */
public $routeContactShow;
2021-06-25 09:44:30 +03:00
/** @var string */
public $signedUrl;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var string */
public $routeButtonEmail;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var string */
public $routeButtonPdf;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var string */
public $routeButtonDelete;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var string */
public $textDeleteModal;
2021-06-24 13:52:49 +03:00
/** @var bool */
2021-06-25 09:44:30 +03:00
public $hideHeader;
2021-06-24 13:52:49 +03:00
/** @var bool */
2021-06-25 09:44:30 +03:00
public $hideHeaderAccount;
2021-06-24 13:52:49 +03:00
/** @var bool */
2021-06-25 09:44:30 +03:00
public $hideHeaderCategory;
2021-06-24 13:52:49 +03:00
/** @var bool */
2021-06-25 09:44:30 +03:00
public $hideHeaderContact;
2021-06-24 13:52:49 +03:00
/** @var bool */
2021-06-25 09:44:30 +03:00
public $hideHeaderAmount;
2021-06-24 13:52:49 +03:00
/** @var bool */
2021-06-25 09:44:30 +03:00
public $hideHeaderPaidAt;
2021-06-24 13:52:49 +03:00
/** @var string */
public $textHeaderAccount;
/** @var string */
public $textHeaderCategory;
/** @var string */
public $textHeaderContact;
/** @var string */
public $textHeaderAmount;
/** @var string */
public $textHeaderPaidAt;
2021-06-25 09:44:30 +03:00
/** @var string */
public $classHeaderAccount;
2021-06-24 13:52:49 +03:00
/** @var string */
public $classHeaderCategory;
/** @var string */
public $classHeaderContact;
/** @var string */
public $classHeaderAmount;
/** @var string */
public $classHeaderPaidAt;
/** @var bool */
2021-06-25 09:44:30 +03:00
public $hideCompany;
2021-06-24 13:52:49 +03:00
/** @var bool */
public $hideCompanyLogo;
2021-06-25 09:44:30 +03:00
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideCompanyDetails;
/** @var bool */
public $hideCompanyName;
2021-06-25 09:44:30 +03:00
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideCompanyAddress;
2021-06-25 09:44:30 +03:00
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideCompanyTaxNumber;
2021-06-25 09:44:30 +03:00
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideCompanyPhone;
2021-06-25 09:44:30 +03:00
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideCompanyEmail;
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideContentTitle;
/** @var bool */
public $hidePaidAt;
/** @var bool */
public $hideAccount;
/** @var bool */
public $hideCategory;
/** @var bool */
public $hidePaymentMethods;
/** @var bool */
public $hideReference;
/** @var bool */
public $hideDescription;
/** @var bool */
public $hideAmount;
/** @var string */
public $textContentTitle;
/** @var string */
public $textPaidAt;
/** @var string */
public $textAccount;
/** @var string */
public $textCategory;
/** @var string */
public $textPaymentMethods;
/** @var string */
public $textReference;
/** @var string */
public $textDescription;
/** @var string */
public $textAmount;
/** @var string */
public $textPaidBy;
/** @var bool */
public $hideContact;
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideContactInfo;
2021-06-25 09:44:30 +03:00
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideContactName;
2021-06-25 09:44:30 +03:00
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideContactAddress;
2021-06-25 09:44:30 +03:00
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideContactTaxNumber;
2021-06-25 09:44:30 +03:00
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideContactPhone;
2021-06-25 09:44:30 +03:00
/** @var bool */
2021-06-24 13:52:49 +03:00
public $hideContactEmail;
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideReletad;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideReletadDocumentNumber;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideReletadContact;
/** @var bool */
public $hideReletadDocumentDate;
/** @var bool */
public $hideReletadDocumentAmount;
/** @var bool */
public $hideReletadAmount;
2021-06-24 13:52:49 +03:00
/** @var string */
2021-06-25 09:44:30 +03:00
public $textReleatedTransansaction;
2021-06-24 13:52:49 +03:00
/** @var string */
2021-06-25 09:44:30 +03:00
public $textReleatedDocumentNumber;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var string */
public $textReleatedContact;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var string */
public $textReleatedDocumentDate;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
/** @var string */
public $textReleatedDocumentAmount;
2021-06-24 13:52:49 +03:00
/** @var string */
2021-06-25 09:44:30 +03:00
public $textReleatedAmount;
/** @var string */
public $routeDocumentShow;
2021-06-24 13:52:49 +03:00
/** @var bool */
public $hideAttachment;
public $attachment;
2021-06-25 09:44:30 +03:00
/** @var bool */
public $hideFooter;
/** @var bool */
public $hideFooterHistories;
public $histories;
2021-06-24 13:52:49 +03:00
/** @var string */
2021-06-25 09:44:30 +03:00
public $textHistories;
/** @var string */
public $classFooterHistories;
2021-06-24 13:52:49 +03:00
/** @var string */
public $textRecurringType;
/** @var bool */
public $hideRecurringMessage;
2021-06-24 13:52:49 +03:00
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
2021-06-25 09:44:30 +03:00
$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,
2021-06-24 13:52:49 +03:00
bool $hideButtonGroupDivider1 = false, bool $hideButtonGroupDivider2 = false, bool $hideButtonGroupDivider3 = false,
2021-06-25 09:44:30 +03:00
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
string $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $signedUrl = '',
string $routeButtonEmail = '', string $routeButtonPdf = '', string $routeButtonDelete = '', string $routeContactShow = '',
2021-06-25 09:44:30 +03:00
string $textDeleteModal = '',
bool $hideHeader = false, bool $hideHeaderAccount = false, bool $hideHeaderCategory = false, bool $hideHeaderContact = false, bool $hideHeaderAmount = false, bool $hideHeaderPaidAt = false,
2021-06-24 13:52:49 +03:00
string $textHeaderAccount = '', string $textHeaderCategory = '', string $textHeaderContact = '', string $textHeaderAmount = '', string $textHeaderPaidAt = '',
2021-06-25 09:44:30 +03:00
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,
2021-06-25 09:44:30 +03:00
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 = '',
bool $hideContact = false, bool $hideContactInfo = false, bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false,
bool $hideContactPhone = false, bool $hideContactEmail = false,
bool $hideReletad = false, bool $hideReletadDocumentNumber = false, bool $hideReletadContact = false, bool $hideReletadDocumentDate = false, bool $hideReletadDocumentAmount = false, bool $hideReletadAmount = false,
string $textReleatedTransansaction = '', string $textReleatedDocumentNumber = '', string $textReleatedContact = '', string $textReleatedDocumentDate = '', string $textReleatedDocumentAmount = '', string $textReleatedAmount = '',
string $routeDocumentShow = '',
bool $hideAttachment = false, $attachment = [],
bool $hideFooter = false, bool $hideFooterHistories = false, $histories = [],
string $textHistories = '', string $classFooterHistories = '', string $textRecurringType = '', bool $hideRecurringMessage = false
2021-06-24 13:52:49 +03:00
) {
$this->type = $type;
$this->transaction = $transaction;
$this->transactionTemplate = $this->getTransactionTemplate($type, $transactionTemplate);
$this->logo = $this->getLogo($logo);
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
2021-06-24 13:52:49 +03:00
$this->date_format = $this->getCompanyDateFormat();
$this->textRecurringType = $this->getTextRecurringType($type, $textRecurringType);
$this->hideRecurringMessage = $hideRecurringMessage;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
// 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->hideButtonDelete = $hideButtonDelete;
2021-06-24 13:52:49 +03:00
$this->checkButtonReconciled = $checkButtonReconciled;
2021-06-25 09:44:30 +03:00
$this->hideButtonGroupDivider1 = $hideButtonGroupDivider1;
$this->hideButtonGroupDivider2 = $hideButtonGroupDivider2;
$this->hideButtonGroupDivider3 = $hideButtonGroupDivider3;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
// Navbar Permission
$this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
$this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate);
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
// Navbar route
2021-06-24 13:52:49 +03:00
$this->routeButtonAddNew = $this->getRouteButtonAddNew($type, $routeButtonAddNew);
$this->routeButtonEdit = $this->getRouteButtonEdit($type, $routeButtonEdit);
$this->routeButtonDuplicate = $this->getRouteButtonDuplicate($type, $routeButtonDuplicate);
$this->routeButtonPrint = $this->getRouteButtonPrint($type, $routeButtonPrint);
2021-06-25 09:44:30 +03:00
$this->signedUrl = $this->getSignedUrl($type, $signedUrl);
$this->routeButtonEmail = $this->getRouteButtonEmail($type, $routeButtonEmail);
2021-06-24 13:52:49 +03:00
$this->routeButtonPdf = $this->getRouteButtonPdf($type, $routeButtonPdf);
$this->routeButtonDelete = $this->getRouteButtonDelete($type, $routeButtonDelete);
$this->routeContactShow = $this->getRouteContactShow($type, $routeContactShow);
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
// Navbar Text
$this->textDeleteModal = $textDeleteModal;
2021-06-24 13:52:49 +03:00
// Header Hide
2021-06-24 13:52:49 +03:00
$this->hideHeader = $hideHeader;
$this->hideHeaderAccount = $hideHeaderAccount;
$this->hideHeaderCategory = $hideHeaderCategory;
$this->hideHeaderContact = $hideHeaderContact;
$this->hideHeaderCategory = $hideHeaderCategory;
$this->hideHeaderAmount = $hideHeaderAmount;
$this->hideHeaderPaidAt = $hideHeaderPaidAt;
2021-06-25 09:44:30 +03:00
// Header Text
2021-06-24 13:52:49 +03:00
$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);
2021-06-25 09:44:30 +03:00
// Header Class
2021-09-09 16:09:11 +03:00
$this->classHeaderAccount = $this->getClassHeaderAccount($type, $classHeaderAccount);
2021-06-25 09:44:30 +03:00
$this->classHeaderContact = $this->getClassHeaderContact($type, $classHeaderContact);
$this->classHeaderCategory = $this->getClassHeaderCategory($type, $classHeaderCategory);
$this->classHeaderAmount = $this->getClassHeaderAmount($type, $classHeaderAmount);
2021-09-09 16:09:11 +03:00
$this->classHeaderPaidAt = $this->getClassHeaderPaidAt($type, $classHeaderPaidAt);
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
// Hide Attachment
$this->hideAttachment = $hideAttachment;
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
// Company Information Hide checker
$this->hideCompany = $hideCompany;
2021-06-24 13:52:49 +03:00
$this->hideCompanyLogo = $hideCompanyLogo;
2021-06-25 09:44:30 +03:00
$this->hideCompanyDetails = $hideCompanyDetails;
2021-06-24 13:52:49 +03:00
$this->hideCompanyName = $hideCompanyName;
2021-06-25 09:44:30 +03:00
$this->hideCompanyAddress = $hideCompanyAddress;
$this->hideCompanyTaxNumber = $hideCompanyTaxNumber;
$this->hideCompanyPhone = $hideCompanyPhone;
$this->hideCompanyEmail = $hideCompanyEmail;
// Transaction Information Hide checker
$this->hideContentTitle = $hideContentTitle;
$this->hidePaidAt = $hidePaidAt;
$this->hideAccount = $hideAccount;
$this->hideCategory = $hideCategory;
$this->hidePaymentMethods = $hidePaymentMethods;
$this->hideReference = $hideReference;
$this->hideDescription = $hideDescription;
$this->hideAmount = $hideAmount;
// Transaction Information Text
$this->textContentTitle = $this->getTextContentTitle($type, $textContentTitle);
$this->textPaidAt = $this->getTextPaidAt($type, $textPaidAt);
$this->textAccount = $this->getTextAccount($type, $textAccount);
$this->textCategory = $this->getTextCategory($type, $textCategory);
$this->textPaymentMethods = $this->getTextPaymentMethods($type, $textPaymentMethods);
$this->textReference = $this->getTextReference($type, $textReference);
$this->textDescription = $this->getTextDescription($type, $textDescription);
$this->textAmount = $this->getTextAmount($type, $textAmount);
$this->textPaidBy = $this->getTextPaidBy($type, $textPaidBy);
// Contact Information Hide checker
$this->hideContact = $hideContact;
$this->hideContactInfo = $hideContactInfo;
$this->hideContactName = $hideContactName;
2021-06-24 13:52:49 +03:00
$this->hideContactAddress = $hideContactAddress;
$this->hideContactTaxNumber = $hideContactTaxNumber;
$this->hideContactPhone = $hideContactPhone;
$this->hideContactEmail = $hideContactEmail;
2021-06-25 09:44:30 +03:00
// Releated Information Hide checker
$this->hideReletad = $hideReletad;
$this->hideReletadDocumentNumber = $hideReletadDocumentNumber;
$this->hideReletadContact = $hideReletadContact;
$this->hideReletadDocumentDate = $hideReletadDocumentDate;
$this->hideReletadDocumentAmount = $hideReletadDocumentAmount;
$this->hideReletadAmount = $hideReletadAmount;
// Releated Information Text
$this->textReleatedTransansaction = $this->getTextReleatedTransansaction($type, $textReleatedTransansaction);
$this->textReleatedDocumentNumber = $this->getTextReleatedDocumentNumber($type, $textReleatedDocumentNumber);
2021-06-27 10:15:39 +03:00
$this->textReleatedContact = $this->getTextReleatedContact($type, $textReleatedContact);
2021-06-25 09:44:30 +03:00
$this->textReleatedDocumentDate = $this->getTextReleatedDocumentDate($type, $textReleatedDocumentDate);
$this->textReleatedDocumentAmount = $this->getTextReleatedDocumentAmount($type, $textReleatedDocumentAmount);
$this->textReleatedAmount = $this->getTextReleatedAmount($type, $textReleatedAmount);
$this->routeDocumentShow = $this->routeDocumentShow($type, $routeDocumentShow);
// Attachment data..
2021-06-24 13:52:49 +03:00
$this->attachment = '';
if (!empty($attachment)) {
$this->attachment = $attachment;
} else if (!empty($transaction)) {
$this->attachment = $transaction->attachment;
}
2021-06-25 09:44:30 +03:00
// Histories Hide
$this->hideFooter = $hideFooter;
$this->hideFooterHistories = $hideFooterHistories;
2021-06-24 13:52:49 +03:00
// Histories
2021-06-25 09:44:30 +03:00
$this->histories = $this->getHistories($histories);
$this->textHistories = $this->getTextHistories($type, $textHistories);
$this->classFooterHistories = $this->getClassFooterHistories($type, $classFooterHistories);
2021-06-24 13:52:49 +03:00
}
protected function getTransactionTemplate($type, $transactionTemplate)
{
if (!empty($transactionTemplate)) {
return $transactionTemplate;
}
if ($template = config('type.' . $type . 'template', false)) {
return $template;
}
$transactionTemplate = setting($this->getSettingKey($type, 'template')) ?: 'default';
return $transactionTemplate;
}
protected function getLogo($logo)
{
if (!empty($logo)) {
return $logo;
}
$media_id = (!empty($this->transaction->contact->logo) && !empty($this->transaction->contact->logo->id)) ? $this->transaction->contact->logo->id : setting('company.logo');
$media = Media::find($media_id);
2021-06-24 13:52:49 +03:00
if (!empty($media)) {
$path = $media->getDiskPath();
if (Storage::missing($path)) {
return $logo;
}
} else {
$path = base_path('public/img/company.png');
}
try {
$image = Image::cache(function($image) use ($media, $path) {
$width = setting('invoice.logo_size_width');
$height = setting('invoice.logo_size_height');
if ($media) {
$image->make(Storage::get($path))->resize($width, $height)->encode();
} else {
$image->make($path)->resize($width, $height)->encode();
}
});
} catch (NotReadableException | \Exception $e) {
2021-06-25 09:44:30 +03:00
Log::info('Company ID: ' . company_id() . ' components/transactionshow.php exception.');
Log::info($e->getMessage());
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
$path = base_path('public/img/company.png');
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
$image = Image::cache(function($image) use ($path) {
$width = setting('invoice.logo_size_width');
$height = setting('invoice.logo_size_height');
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
$image->make($path)->resize($width, $height)->encode();
});
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
if (empty($image)) {
return $logo;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
$extension = File::extension($path);
return 'data:image/' . $extension . ';base64,' . base64_encode($image);
2021-06-24 13:52:49 +03:00
}
protected function getRouteButtonAddNew($type, $routeButtonAddNew)
{
if (!empty($routeButtonAddNew)) {
return $routeButtonAddNew;
}
$route = $this->getRouteFromConfig($type, 'create');
if (!empty($route)) {
return $route;
}
return 'revenues.create';
}
protected function getRouteButtonEdit($type, $routeButtonEdit)
{
if (!empty($routeButtonEdit)) {
return $routeButtonEdit;
}
//example route parameter.
$parameter = 1;
$route = $this->getRouteFromConfig($type, 'edit', $parameter);
if (!empty($route)) {
return $route;
}
return 'revenues.edit';
}
protected function getRouteButtonDuplicate($type, $routeButtonDuplicate)
{
if (!empty($routeButtonDuplicate)) {
return $routeButtonDuplicate;
}
//example route parameter.
$parameter = 1;
$route = $this->getRouteFromConfig($type, 'duplicate', $parameter);
if (!empty($route)) {
return $route;
}
return 'revenues.duplicate';
}
protected function getRouteButtonPrint($type, $routeButtonPrint)
{
if (!empty($routeButtonPrint)) {
return $routeButtonPrint;
}
//example route parameter.
$parameter = 1;
$route = $this->getRouteFromConfig($type, 'print', $parameter);
if (!empty($route)) {
return $route;
}
return 'revenues.print';
}
2021-06-25 09:44:30 +03:00
protected function getSignedUrl($type, $signedUrl)
2021-06-24 13:52:49 +03:00
{
2021-06-25 09:44:30 +03:00
if (!empty($signedUrl)) {
return $signedUrl;
}
$page = config('type.' . $type . '.route.prefix');
$alias = config('type.' . $type . '.alias');
$route = '';
if (!empty($alias)) {
$route .= $alias . '.';
}
$route .= 'signed.' . $page . '.show';
try {
route($route, [$this->transaction->id, 'company_id' => company_id()]);
$signedUrl = URL::signedRoute($route, [$this->transaction->id]);
} catch (\Exception $e) {
$signedUrl = URL::signedRoute('signed.payments.show', [$this->transaction->id]);
}
return $signedUrl;
}
protected function getRouteButtonEmail($type, $routeButtonEmail)
{
if (!empty($routeButtonEmail)) {
return $routeButtonEmail;
2021-06-24 13:52:49 +03:00
}
//example route parameter.
$parameter = 1;
2021-06-25 09:44:30 +03:00
$route = $this->getRouteFromConfig($type, 'email', $parameter);
2021-06-24 13:52:49 +03:00
if (!empty($route)) {
return $route;
}
2021-06-25 09:44:30 +03:00
return 'revenues.email';
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function getRouteButtonPdf($type, $routeButtonPdf)
2021-06-24 13:52:49 +03:00
{
2021-06-25 09:44:30 +03:00
if (!empty($routeButtonPdf)) {
return $routeButtonPdf;
2021-06-24 13:52:49 +03:00
}
//example route parameter.
$parameter = 1;
2021-06-25 09:44:30 +03:00
$route = $this->getRouteFromConfig($type, 'pdf', $parameter);
2021-06-24 13:52:49 +03:00
if (!empty($route)) {
return $route;
}
2021-06-25 09:44:30 +03:00
return 'revenues.pdf';
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function getRouteButtonDelete($type, $routeButtonDelete)
2021-06-24 13:52:49 +03:00
{
2021-06-25 09:44:30 +03:00
if (!empty($routeButtonDelete)) {
return $routeButtonDelete;
2021-06-24 13:52:49 +03:00
}
//example route parameter.
$parameter = 1;
2021-06-25 09:44:30 +03:00
$route = $this->getRouteFromConfig($type, 'destroy', $parameter);
2021-06-24 13:52:49 +03:00
if (!empty($route)) {
return $route;
}
2021-06-25 09:44:30 +03:00
return 'revenues.destroy';
2021-06-24 13:52:49 +03:00
}
protected function getRouteContactShow($type, $routeContactShow)
{
if (!empty($routeContactShow)) {
return $routeContactShow;
}
//example route parameter.
$parameter = 1;
$route = Str::plural(config('type.' . $type . '.contact_type'), 2) . '.show';
try {
2021-06-30 18:41:43 +03:00
route($route, $parameter);
} catch (\Exception $e) {
try {
$route = Str::plural($type, 2) . '.' . $config_key;
2021-06-30 18:41:43 +03:00
route($route, $parameter);
} catch (\Exception $e) {
$route = '';
}
}
if (!empty($route)) {
return $route;
}
return 'customers.show';
}
2021-06-24 13:52:49 +03:00
protected function getPermissionCreate($type, $permissionCreate)
{
if (!empty($permissionCreate)) {
return $permissionCreate;
}
$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;
}
2021-06-27 10:15:39 +03:00
$translation = $this->getTextFromConfig($type, 'header_account', 'accounts', 'trans_choice');
2021-06-24 13:52:49 +03:00
if (!empty($translation)) {
return $translation;
}
2021-06-27 10:15:39 +03:00
return 'general.accounts';
2021-06-24 13:52:49 +03:00
}
protected function getTextHeaderCategory($type, $textHeaderCategory)
{
if (!empty($textHeaderCategory)) {
return $textHeaderCategory;
}
2021-06-27 10:15:39 +03:00
$translation = $this->getTextFromConfig($type, 'header_category', 'categories', 'trans_choice');
2021-06-24 13:52:49 +03:00
if (!empty($translation)) {
return $translation;
}
2021-06-27 10:15:39 +03:00
return 'general.categories';
2021-06-24 13:52:49 +03:00
}
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;
}
2021-06-27 10:15:39 +03:00
$translation = $this->getTextFromConfig($type, 'header_amount', 'amount');
2021-06-24 13:52:49 +03:00
if (!empty($translation)) {
return $translation;
}
2021-06-27 10:15:39 +03:00
return 'general.amount';
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function getTextHeaderPaidAt($type, $textHeaderPaidAt)
2021-06-24 13:52:49 +03:00
{
if (!empty($textHeaderPaidAt)) {
return $textHeaderPaidAt;
}
2021-06-27 10:15:39 +03:00
$translation = $this->getTextFromConfig($type, 'header_paid_at', 'date');
2021-06-24 13:52:49 +03:00
if (!empty($translation)) {
return $translation;
}
2021-06-27 10:15:39 +03:00
return 'general.date';
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function getClassHeaderAccount($type, $classHeaderAccount)
2021-06-24 13:52:49 +03:00
{
if (!empty($classHeaderAccount)) {
return $classHeaderAccount;
}
2021-06-27 10:15:39 +03:00
$class = $this->getClassFromConfig($type, 'header_account');
2021-06-24 13:52:49 +03:00
if (!empty($class)) {
return $class;
}
2021-06-25 18:10:58 +03:00
return 'col-4 col-lg-3';
2021-06-24 13:52:49 +03:00
}
protected function getClassHeaderContact($type, $classHeaderContact)
{
if (!empty($classHeaderContact)) {
return $classHeaderContact;
}
$class = $this->getClassFromConfig($type, 'header_contact');
if (!empty($class)) {
return $class;
}
2021-06-25 18:10:58 +03:00
return 'col-4 col-lg-2';
2021-06-24 13:52:49 +03:00
}
protected function getClassHeaderCategory($type, $classHeaderCategory)
{
if (!empty($classHeaderCategory)) {
return $classHeaderCategory;
}
2021-06-27 10:15:39 +03:00
$class = $this->getClassFromConfig($type, 'header_category');
2021-06-24 13:52:49 +03:00
if (!empty($class)) {
return $class;
}
2021-06-25 18:10:58 +03:00
return 'col-4 col-lg-3';
2021-06-24 13:52:49 +03:00
}
protected function getClassHeaderAmount($type, $classHeaderAmount)
{
if (!empty($classHeaderAmount)) {
return $classHeaderAmount;
}
$class = $this->getClassFromConfig($type, 'header_amount');
if (!empty($class)) {
return $class;
}
2021-06-25 18:10:58 +03:00
return 'col-4 col-lg-2';
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function getClassHeaderPaidAt($type, $classHeaderPaidAt)
2021-06-24 13:52:49 +03:00
{
if (!empty($classHeaderPaidAt)) {
return $classHeaderPaidAt;
}
2021-06-27 10:15:39 +03:00
$class = $this->getClassFromConfig($type, 'header_paid_at');
2021-06-24 13:52:49 +03:00
if (!empty($class)) {
return $class;
}
2021-06-25 18:10:58 +03:00
return 'col-4 col-lg-2';
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function getTextContentTitle($type, $textContentTitle)
2021-06-24 13:52:49 +03:00
{
2021-06-25 09:44:30 +03:00
if (!empty($textContentTitle)) {
return $textContentTitle;
2021-06-24 13:52:49 +03:00
}
2021-06-27 10:15:39 +03:00
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$default_key = 'payment_made';
break;
default:
$default_key = 'revenue_received';
2021-06-27 10:15:39 +03:00
break;
}
$translation = $this->getTextFromConfig($type, $type . '_made', $default_key);
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
if (!empty($translation)) {
return $translation;
2021-06-24 13:52:49 +03:00
}
return 'revenues.revenue_received';
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function getTextPaidAt($type, $textPaidAt)
2021-06-24 13:52:49 +03:00
{
2021-06-25 09:44:30 +03:00
if (!empty($textPaidAt)) {
return $textPaidAt;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
$translation = $this->getTextFromConfig($type, 'paid_at', 'date');
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
if (!empty($translation)) {
return $translation;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
return 'general.date';
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function getTextAccount($type, $textAccount)
2021-06-24 13:52:49 +03:00
{
2021-06-25 09:44:30 +03:00
if (!empty($textAccount)) {
return $textAccount;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
$translation = $this->getTextFromConfig($type, 'accounts', 'accounts', 'trans_choice');
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
if (!empty($translation)) {
return $translation;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
return 'general.accounts';
}
protected function getTextCategory($type, $textCategory)
{
if (!empty($textCategory)) {
return $textCategory;
}
$translation = $this->getTextFromConfig($type, 'categories', 'categories', 'trans_choice');
if (!empty($translation)) {
return $translation;
}
return 'general.categories';
}
protected function getTextPaymentMethods($type, $textPaymentMethods)
{
if (!empty($textPaymentMethods)) {
return $textPaymentMethods;
}
$translation = $this->getTextFromConfig($type, 'payment_methods', 'payment_methods', 'trans_choice');
if (!empty($translation)) {
return $translation;
}
return 'general.payment_methods';
}
protected function getTextReference($type, $textReference)
{
if (!empty($textReference)) {
return $textReference;
}
$translation = $this->getTextFromConfig($type, 'reference', 'reference');
if (!empty($translation)) {
return $translation;
}
return 'general.reference';
}
protected function getTextDescription($type, $textDescription)
{
if (!empty($textDescription)) {
return $textDescription;
}
$translation = $this->getTextFromConfig($type, 'description', 'description');
if (!empty($translation)) {
return $translation;
}
return 'general.description';
}
protected function getTextAmount($type, $textAmount)
{
if (!empty($textAmount)) {
return $textAmount;
}
$translation = $this->getTextFromConfig($type, 'amount', 'amount');
if (!empty($translation)) {
return $translation;
}
return 'general.amount';
}
protected function getTextPaidBy($type, $textPaidBy)
{
if (!empty($textPaidBy)) {
return $textPaidBy;
}
2021-06-27 10:15:39 +03:00
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$default_key = 'paid_to';
break;
default:
$default_key = 'paid_by';
break;
}
$translation = $this->getTextFromConfig($type, 'paid_to_by', $default_key);
2021-06-25 09:44:30 +03:00
if (!empty($translation)) {
return $translation;
}
2021-06-28 00:00:53 +03:00
return 'revenues.paid_by';
2021-06-25 09:44:30 +03:00
}
protected function getTextReleatedTransansaction($type, $textReleatedTransansaction)
{
if (!empty($textReleatedTransansaction)) {
return $textReleatedTransansaction;
}
2021-06-27 10:15:39 +03:00
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$default_key = 'related_bill';
break;
default:
$default_key = 'related_invoice';
break;
}
$translation = $this->getTextFromConfig($type, 'related_type', $default_key);
2021-06-25 09:44:30 +03:00
if (!empty($translation)) {
return $translation;
}
2021-06-27 10:15:39 +03:00
return 'revenues.related_invoice';
2021-06-25 09:44:30 +03:00
}
protected function getTextReleatedDocumentNumber($type, $textReleatedDocumentNumber)
{
if (!empty($textReleatedDocumentNumber)) {
return $textReleatedDocumentNumber;
}
$translation = $this->getTextFromConfig($type, 'related_document_number', 'numbers');
if (!empty($translation)) {
return $translation;
}
return 'general.numbers';
}
2021-06-27 10:15:39 +03:00
protected function getTextReleatedContact($type, $textReleatedContact)
2021-06-25 09:44:30 +03:00
{
if (!empty($textReleatedContact)) {
return $textReleatedContact;
}
2021-06-27 10:15:39 +03:00
$default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
$translation = $this->getTextFromConfig($type, 'related_contact', $default_key, 'trans_choice');
2021-06-25 09:44:30 +03:00
if (!empty($translation)) {
return $translation;
}
return 'general.customers';
}
protected function getTextReleatedDocumentDate($type, $textReleatedDocumentDate)
{
if (!empty($textReleatedDocumentDate)) {
return $textReleatedDocumentDate;
}
2021-06-27 10:15:39 +03:00
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$default_key = 'bill_date';
break;
default:
$default_key = 'invoice_date';
break;
}
$translation = $this->getTextFromConfig($type, 'related_document_date', $default_key);
2021-06-25 09:44:30 +03:00
if (!empty($translation)) {
return $translation;
}
return 'invoices.invoice_date';
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function getTextReleatedDocumentAmount($type, $textReleatedDocumentAmount)
2021-06-24 13:52:49 +03:00
{
2021-06-25 09:44:30 +03:00
if (!empty($textReleatedDocumentAmount)) {
return $textReleatedDocumentAmount;
}
2021-06-27 10:15:39 +03:00
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$default_key = 'bill_amount';
break;
default:
$default_key = 'invoice_amount';
break;
}
$translation = $this->getTextFromConfig($type, 'related_document_amount', $default_key);
2021-06-25 09:44:30 +03:00
if (!empty($translation)) {
return $translation;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
return 'general.amount';
}
protected function getTextReleatedAmount($type, $textReleatedAmount)
{
if (!empty($textReleatedAmount)) {
return $textReleatedAmount;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
$translation = $this->getTextFromConfig($type, 'related_amount', 'amount');
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
if (!empty($translation)) {
return $translation;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
return 'general.amount';
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function routeDocumentShow($type, $routeDocumentShow)
2021-06-24 13:52:49 +03:00
{
2021-06-25 09:44:30 +03:00
if (!empty($routeDocumentShow)) {
return $routeDocumentShow;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
if (!$this->transaction->document) {
return $routeDocumentShow;
}
//example route parameter.
$parameter = 1;
$route = $this->getRouteFromConfig($this->transaction->document->type, 'show', $parameter);
if (!empty($route)) {
return $route;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
return 'invoices.show';
}
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
protected function getHistories($histories)
{
if (!empty($histories)) {
return $histories;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
$histories[] = $this->transaction;
return $histories;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
protected function getTextHistories($type, $textHistories)
2021-06-24 13:52:49 +03:00
{
2021-06-25 09:44:30 +03:00
if (!empty($textHistories)) {
return $textHistories;
}
$translation = $this->getTextFromConfig($type, 'histories', 'histories');
if (!empty($translation)) {
return $translation;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
return 'invoices.histories';
}
protected function getClassFooterHistories($type, $classFooterHistories)
{
if (!empty($classFooterHistories)) {
return $classFooterHistories;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
$class = $this->getClassFromConfig($type, 'footer_histories');
2021-06-24 13:52:49 +03:00
2021-06-25 09:44:30 +03:00
if (!empty($class)) {
return $class;
2021-06-24 13:52:49 +03:00
}
2021-06-25 09:44:30 +03:00
return 'col-sm-6 col-md-6 col-lg-6 col-xl-6';
2021-06-24 13:52:49 +03:00
}
protected function getTextRecurringType($type, $textRecurringType)
{
if (!empty($textRecurringType)) {
return $textRecurringType;
}
$default_key = config('type.' . $type . '.translation.prefix');
$translation = $this->getTextFromConfig($type, 'recurring_tye', $default_key);
if (!empty($translation)) {
return $translation;
}
return 'general.revenues';
}
}