Merge pull request #2146 from cuneytsenturk/master
Added Revenue/Payment show page [#mdbaet]
This commit is contained in:
175
app/Abstracts/View/Components/Transaction.php
Normal file
175
app/Abstracts/View/Components/Transaction.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
1243
app/Abstracts/View/Components/TransactionShow.php
Normal file
1243
app/Abstracts/View/Components/TransactionShow.php
Normal file
File diff suppressed because it is too large
Load Diff
606
app/Abstracts/View/Components/TransactionTemplate.php
Normal file
606
app/Abstracts/View/Components/TransactionTemplate.php
Normal file
@ -0,0 +1,606 @@
|
||||
<?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 Image;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class TransactionTemplate extends Base
|
||||
{
|
||||
use DateTime;
|
||||
use Transactions;
|
||||
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
public $transaction;
|
||||
|
||||
public $logo;
|
||||
|
||||
/** @var array */
|
||||
public $payment_methods;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompany;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompanyLogo;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompanyDetails;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompanyName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompanyAddress;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompanyTaxNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompanyPhone;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompanyEmail;
|
||||
|
||||
/** @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 */
|
||||
public $hideContactInfo;
|
||||
|
||||
/** @var bool */
|
||||
public $hideContactName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideContactAddress;
|
||||
|
||||
/** @var bool */
|
||||
public $hideContactTaxNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideContactPhone;
|
||||
|
||||
/** @var bool */
|
||||
public $hideContactEmail;
|
||||
|
||||
/** @var bool */
|
||||
public $hideReletad;
|
||||
|
||||
/** @var bool */
|
||||
public $hideReletadDocumentNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideReletadContact;
|
||||
|
||||
/** @var bool */
|
||||
public $hideReletadDocumentDate;
|
||||
|
||||
/** @var bool */
|
||||
public $hideReletadDocumentAmount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideReletadAmount;
|
||||
|
||||
/** @var string */
|
||||
public $textReleatedTransansaction;
|
||||
|
||||
/** @var string */
|
||||
public $textReleatedDocumentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textReleatedContact;
|
||||
|
||||
/** @var string */
|
||||
public $textReleatedDocumentDate;
|
||||
|
||||
/** @var string */
|
||||
public $textReleatedDocumentAmount;
|
||||
|
||||
/** @var string */
|
||||
public $textReleatedAmount;
|
||||
|
||||
/** @var string */
|
||||
public $routeDocumentShow;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$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 = '',
|
||||
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 = ''
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->transaction = $transaction;
|
||||
|
||||
$this->logo = $this->getLogo($logo);
|
||||
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
|
||||
|
||||
// Company Information Hide checker
|
||||
$this->hideCompany = $hideCompany;
|
||||
$this->hideCompanyLogo = $hideCompanyLogo;
|
||||
$this->hideCompanyDetails = $hideCompanyDetails;
|
||||
$this->hideCompanyName = $hideCompanyName;
|
||||
$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;
|
||||
$this->hideContactAddress = $hideContactAddress;
|
||||
$this->hideContactTaxNumber = $hideContactTaxNumber;
|
||||
$this->hideContactPhone = $hideContactPhone;
|
||||
$this->hideContactEmail = $hideContactEmail;
|
||||
|
||||
// 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);
|
||||
$this->textReleatedContact = $this->getTextReleatedContact($type, $textReleatedContact);
|
||||
$this->textReleatedDocumentDate = $this->getTextReleatedDocumentDate($type, $textReleatedDocumentDate);
|
||||
$this->textReleatedDocumentAmount = $this->getTextReleatedDocumentAmount($type, $textReleatedDocumentAmount);
|
||||
$this->textReleatedAmount = $this->getTextReleatedAmount($type, $textReleatedAmount);
|
||||
|
||||
$this->routeDocumentShow = $this->routeDocumentShow($type, $routeDocumentShow);
|
||||
}
|
||||
|
||||
protected function getLogo($logo)
|
||||
{
|
||||
if (!empty($logo)) {
|
||||
return $logo;
|
||||
}
|
||||
|
||||
$media = Media::find(setting('company.logo'));
|
||||
|
||||
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) {
|
||||
Log::info('Company ID: ' . company_id() . ' components/transactionshow.php exception.');
|
||||
Log::info($e->getMessage());
|
||||
|
||||
$path = base_path('public/img/company.png');
|
||||
|
||||
$image = Image::cache(function($image) use ($path) {
|
||||
$width = setting('invoice.logo_size_width');
|
||||
$height = setting('invoice.logo_size_height');
|
||||
|
||||
$image->make($path)->resize($width, $height)->encode();
|
||||
});
|
||||
}
|
||||
|
||||
if (empty($image)) {
|
||||
return $logo;
|
||||
}
|
||||
|
||||
$extension = File::extension($path);
|
||||
|
||||
return 'data:image/' . $extension . ';base64,' . base64_encode($image);
|
||||
}
|
||||
|
||||
protected function getTextContentTitle($type, $textContentTitle)
|
||||
{
|
||||
if (!empty($textContentTitle)) {
|
||||
return $textContentTitle;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$default_key = 'payment_made';
|
||||
break;
|
||||
default:
|
||||
$default_key = 'revenue_received';
|
||||
break;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, $type . '_made', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'revenues.revenue_received';
|
||||
}
|
||||
|
||||
protected function getTextPaidAt($type, $textPaidAt)
|
||||
{
|
||||
if (!empty($textPaidAt)) {
|
||||
return $textPaidAt;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'paid_at', 'date');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.date';
|
||||
}
|
||||
|
||||
protected function getTextAccount($type, $textAccount)
|
||||
{
|
||||
if (!empty($textAccount)) {
|
||||
return $textAccount;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'accounts', 'accounts', 'trans_choice');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'revenus.paid_by';
|
||||
}
|
||||
|
||||
protected function getTextReleatedTransansaction($type, $textReleatedTransansaction)
|
||||
{
|
||||
if (!empty($textReleatedTransansaction)) {
|
||||
return $textReleatedTransansaction;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'revenues.related_invoice';
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
protected function getTextReleatedContact($type, $textReleatedContact)
|
||||
{
|
||||
if (!empty($textReleatedContact)) {
|
||||
return $textReleatedContact;
|
||||
}
|
||||
|
||||
$default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'related_contact', $default_key, 'trans_choice');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.customers';
|
||||
}
|
||||
|
||||
protected function getTextReleatedDocumentDate($type, $textReleatedDocumentDate)
|
||||
{
|
||||
if (!empty($textReleatedDocumentDate)) {
|
||||
return $textReleatedDocumentDate;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.invoice_date';
|
||||
}
|
||||
|
||||
protected function getTextReleatedDocumentAmount($type, $textReleatedDocumentAmount)
|
||||
{
|
||||
if (!empty($textReleatedDocumentAmount)) {
|
||||
return $textReleatedDocumentAmount;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.amount';
|
||||
}
|
||||
|
||||
protected function getTextReleatedAmount($type, $textReleatedAmount)
|
||||
{
|
||||
if (!empty($textReleatedAmount)) {
|
||||
return $textReleatedAmount;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'related_amount', 'amount');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.amount';
|
||||
}
|
||||
|
||||
protected function routeDocumentShow($type, $routeDocumentShow)
|
||||
{
|
||||
if (!empty($routeDocumentShow)) {
|
||||
return $routeDocumentShow;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return 'invoices.show';
|
||||
}
|
||||
}
|
22
app/Events/Transaction/TransactionPrinting.php
Normal file
22
app/Events/Transaction/TransactionPrinting.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Transaction;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class TransactionPrinting
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public $transaction;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $transaction
|
||||
*/
|
||||
public function __construct($transaction)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
}
|
20
app/Events/Transaction/TransactionSent.php
Normal file
20
app/Events/Transaction/TransactionSent.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Transaction;
|
||||
|
||||
use App\Abstracts\Event;
|
||||
|
||||
class TransactionSent extends Event
|
||||
{
|
||||
public $transaction;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $transaction
|
||||
*/
|
||||
public function __construct($transaction)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
}
|
@ -7,9 +7,13 @@ use App\Models\Banking\Transaction;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Http\Requests\Portal\PaymentShow as Request;
|
||||
use App\Utilities\Modules;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class Payments extends Controller
|
||||
{
|
||||
use Transactions;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
@ -51,4 +55,62 @@ class Payments extends Controller
|
||||
|
||||
return $this->response('portal.currencies.index', compact('currencies'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for viewing the specified resource.
|
||||
*
|
||||
* @param Transaction $payment
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function printPayment(Transaction $payment, Request $request)
|
||||
{
|
||||
event(new \App\Events\Transaction\TransactionPrinting($payment));
|
||||
|
||||
$revenue = $payment;
|
||||
$view = view($payment->template_path, compact('revenue'));
|
||||
|
||||
return mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for viewing the specified resource.
|
||||
*
|
||||
* @param Transaction $payment
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function pdfPayment(Transaction $payment, Request $request)
|
||||
{
|
||||
event(new \App\Events\Transaction\TransactionPrinting($payment));
|
||||
|
||||
$currency_style = true;
|
||||
|
||||
$revenue = $payment;
|
||||
$view = view($payment->template_path, compact('revenue', 'currency_style'))->render();
|
||||
$html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
$pdf = app('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
|
||||
//$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
$file_name = $this->getTransactionFileName($payment);
|
||||
|
||||
return $pdf->download($file_name);
|
||||
}
|
||||
|
||||
public function signed(Transaction $payment)
|
||||
{
|
||||
if (empty($payment)) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
$payment_methods = Modules::getPaymentMethods();
|
||||
|
||||
$print_action = URL::signedRoute('signed.payments.print', [$payment->id]);
|
||||
$pdf_action = URL::signedRoute('signed.payments.pdf', [$payment->id]);
|
||||
|
||||
return view('portal.payments.signed', compact('payment', 'payment_methods', 'print_action', 'pdf_action'));
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,12 @@ use App\Models\Setting\Category;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Transactions;
|
||||
use App\Utilities\Modules;
|
||||
|
||||
class Payments extends Controller
|
||||
{
|
||||
use Currencies, DateTime;
|
||||
use Currencies, DateTime, Transactions;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
@ -40,9 +41,9 @@ class Payments extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show()
|
||||
public function show(Transaction $payment)
|
||||
{
|
||||
return redirect()->route('payments.index');
|
||||
return view('purchases.payments.show', compact('payment'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,7 +92,7 @@ class Payments extends Controller
|
||||
$response = $this->ajaxDispatch(new CreateTransaction($request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('payments.index');
|
||||
$response['redirect'] = route('payments.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]);
|
||||
|
||||
@ -206,7 +207,7 @@ class Payments extends Controller
|
||||
$response = $this->ajaxDispatch(new UpdateTransaction($payment, $request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('payments.index');
|
||||
$response['redirect'] = route('payments.show', $payment->id);
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.payments', 1)]);
|
||||
|
||||
@ -257,4 +258,69 @@ class Payments extends Controller
|
||||
{
|
||||
return $this->exportExcel(new Export, trans_choice('general.payments', 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the PDF file of payment.
|
||||
*
|
||||
* @param Transaction $payment
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function emailPayment(Transaction $payment)
|
||||
{
|
||||
if (empty($payment->contact->email)) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
// Notify the customer
|
||||
$payment->contact->notify(new Notification($payment, 'payment_new_customer', true));
|
||||
|
||||
event(new \App\Events\Transaction\TransactionSent($payment));
|
||||
|
||||
flash(trans('documents.messages.email_sent', ['type' => trans_choice('general.payments', 1)]))->success();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the payment.
|
||||
*
|
||||
* @param Transaction $payment
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function printPayment(Transaction $payment)
|
||||
{
|
||||
event(new \App\Events\Transaction\TransactionPrinting($payment));
|
||||
|
||||
$view = view($payment->template_path, compact('payment'));
|
||||
|
||||
return mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the PDF file of payment.
|
||||
*
|
||||
* @param Transaction $payment
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function pdfPayment(Transaction $payment)
|
||||
{
|
||||
event(new \App\Events\Transaction\TransactionPrinting($payment));
|
||||
|
||||
$currency_style = true;
|
||||
|
||||
$view = view($payment->template_path, compact('payment', 'currency_style'))->render();
|
||||
$html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
$pdf = app('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
|
||||
//$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
$file_name = $this->getTransactionFileName($payment);
|
||||
|
||||
return $pdf->download($file_name);
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,15 @@ use App\Models\Banking\Transaction;
|
||||
use App\Models\Common\Contact;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Notifications\Sale\Revenue as Notification;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Transactions;
|
||||
use App\Utilities\Modules;
|
||||
|
||||
class Revenues extends Controller
|
||||
{
|
||||
use Currencies, DateTime;
|
||||
use Currencies, DateTime, Transactions;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
@ -40,9 +42,9 @@ class Revenues extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show()
|
||||
public function show(Transaction $revenue)
|
||||
{
|
||||
return redirect()->route('revenues.index');
|
||||
return view('sales.revenues.show', compact('revenue'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,7 +93,7 @@ class Revenues extends Controller
|
||||
$response = $this->ajaxDispatch(new CreateTransaction($request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('revenues.index');
|
||||
$response['redirect'] = route('revenues.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.revenues', 1)]);
|
||||
|
||||
@ -206,7 +208,7 @@ class Revenues extends Controller
|
||||
$response = $this->ajaxDispatch(new UpdateTransaction($revenue, $request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('revenues.index');
|
||||
$response['redirect'] = route('revenues.show', $revenue->id);
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.revenues', 1)]);
|
||||
|
||||
@ -257,4 +259,69 @@ class Revenues extends Controller
|
||||
{
|
||||
return $this->exportExcel(new Export, trans_choice('general.revenues', 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the PDF file of revenue.
|
||||
*
|
||||
* @param Transaction $revenue
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function emailRevenue(Transaction $revenue)
|
||||
{
|
||||
if (empty($revenue->contact->email)) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
// Notify the customer
|
||||
$revenue->contact->notify(new Notification($revenue, 'revenue_new_customer', true));
|
||||
|
||||
event(new \App\Events\Transaction\TransactionSent($revenue));
|
||||
|
||||
flash(trans('documents.messages.email_sent', ['type' => trans_choice('general.revenues', 1)]))->success();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the revenue.
|
||||
*
|
||||
* @param Transaction $revenue
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function printRevenue(Transaction $revenue)
|
||||
{
|
||||
event(new \App\Events\Transaction\TransactionPrinting($revenue));
|
||||
|
||||
$view = view($revenue->template_path, compact('revenue'));
|
||||
|
||||
return mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the PDF file of revenue.
|
||||
*
|
||||
* @param Transaction $revenue
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function pdfRevenue(Transaction $revenue)
|
||||
{
|
||||
event(new \App\Events\Transaction\TransactionPrinting($revenue));
|
||||
|
||||
$currency_style = true;
|
||||
|
||||
$view = view($revenue->template_path, compact('revenue', 'currency_style'))->render();
|
||||
$html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
$pdf = app('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
|
||||
//$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
$file_name = $this->getTransactionFileName($revenue);
|
||||
|
||||
return $pdf->download($file_name);
|
||||
}
|
||||
}
|
||||
|
56
app/Listeners/Update/V21/Version2118.php
Normal file
56
app/Listeners/Update/V21/Version2118.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\Update\V21;
|
||||
|
||||
use App\Abstracts\Listeners\Update as Listener;
|
||||
use App\Events\Install\UpdateFinished as Event;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Common\EmailTemplate;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class Version2118 extends Listener
|
||||
{
|
||||
const ALIAS = 'core';
|
||||
|
||||
const VERSION = '2.1.18';
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Event $event)
|
||||
{
|
||||
if ($this->skipThisUpdate($event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->updateEmailTemplate();
|
||||
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
}
|
||||
|
||||
protected function updateCompanies()
|
||||
{
|
||||
$company_id = company_id();
|
||||
|
||||
$companies = Company::cursor();
|
||||
|
||||
foreach ($companies as $company) {
|
||||
$company->makeCurrent();
|
||||
|
||||
EmailTemplate::create([
|
||||
'company_id' => $company->id,
|
||||
'alias' => 'revenue_new_customer',
|
||||
'class' => 'App\Notifications\Sale\Revenue',
|
||||
'name' => 'settings.email.templates.revenue_new_customer',
|
||||
'subject' => trans('email_templates.revenue_new_customer.subject'),
|
||||
'body' => trans('email_templates.revenue_new_customer.body'),
|
||||
]);
|
||||
}
|
||||
|
||||
company($company_id)->makeCurrent();
|
||||
}
|
||||
}
|
@ -371,11 +371,11 @@ class Transaction extends Model
|
||||
}
|
||||
|
||||
if ($this->isIncome()) {
|
||||
return !empty($this->document_id) ? 'invoices.show' : 'revenues.edit';
|
||||
return !empty($this->document_id) ? 'invoices.show' : 'revenues.show';
|
||||
}
|
||||
|
||||
if ($this->isExpense()) {
|
||||
return !empty($this->document_id) ? 'bills.show' : 'payments.edit';
|
||||
return !empty($this->document_id) ? 'bills.show' : 'payments.show';
|
||||
}
|
||||
|
||||
return 'transactions.index';
|
||||
@ -391,6 +391,11 @@ class Transaction extends Model
|
||||
return !empty($value) ? $value : (!empty($this->document_id) ? $this->document_id : $this->id);
|
||||
}
|
||||
|
||||
public function getTemplatePathAttribute($value = null)
|
||||
{
|
||||
return $value ?: 'sales.revenues.print_default';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
|
121
app/Notifications/Sale/Revenue.php
Normal file
121
app/Notifications/Sale/Revenue.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Sale;
|
||||
|
||||
use App\Abstracts\Notification;
|
||||
use App\Models\Common\EmailTemplate;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class Revenue extends Notification
|
||||
{
|
||||
use Transactions;
|
||||
|
||||
/**
|
||||
* The revenue model.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $revenue;
|
||||
|
||||
/**
|
||||
* The email template.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $template;
|
||||
|
||||
/**
|
||||
* Should attach pdf or not.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $attach_pdf;
|
||||
|
||||
/**
|
||||
* Create a notification instance.
|
||||
*
|
||||
* @param object $revenue
|
||||
* @param object $template_alias
|
||||
* @param object $attach_pdf
|
||||
*/
|
||||
public function __construct($revenue = null, $template_alias = null, $attach_pdf = false)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->revenue = $revenue;
|
||||
$this->template = EmailTemplate::alias($template_alias)->first();
|
||||
$this->attach_pdf = $attach_pdf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$message = $this->initMessage();
|
||||
|
||||
// Attach the PDF file
|
||||
if ($this->attach_pdf) {
|
||||
$message->attach($this->storeDocumentPdfAndGetPath($this->revenue), [
|
||||
'mime' => 'application/pdf',
|
||||
]);
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
'template_alias' => $this->template->alias,
|
||||
'revenue_id' => $this->revenue->id,
|
||||
'customer_name' => $this->revenue->contact->name,
|
||||
'amount' => $this->revenue->amount,
|
||||
'revenue_date' => company_date($this->revenue->paid_at),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTags()
|
||||
{
|
||||
return [
|
||||
'{revenue_amount}',
|
||||
'{revenue_date}',
|
||||
'{revenue_guest_link}',
|
||||
'{revenue_admin_link}',
|
||||
'{revenue_portal_link}',
|
||||
'{customer_name}',
|
||||
'{company_name}',
|
||||
'{company_email}',
|
||||
'{company_tax_number}',
|
||||
'{company_phone}',
|
||||
'{company_address}',
|
||||
];
|
||||
}
|
||||
|
||||
public function getTagsReplacement()
|
||||
{
|
||||
return [
|
||||
money($this->revenue->amount, $this->revenue->currency_code, true),
|
||||
company_date($this->revenue->paid_at),
|
||||
URL::signedRoute('signed.payments.show', [$this->revenue->id]),
|
||||
route('revenues.show', $this->revenue->id),
|
||||
route('portal.payments.show', $this->revenue->id),
|
||||
$this->revenue->contact->name,
|
||||
$this->revenue->company->name,
|
||||
$this->revenue->company->email,
|
||||
$this->revenue->company->tax_number,
|
||||
$this->revenue->company->phone,
|
||||
nl2br(trim($this->revenue->company->address)),
|
||||
];
|
||||
}
|
||||
}
|
@ -34,6 +34,7 @@ class Event extends Provider
|
||||
'App\Listeners\Update\V21\Version2114',
|
||||
'App\Listeners\Update\V21\Version2116',
|
||||
'App\Listeners\Update\V21\Version2117',
|
||||
'App\Listeners\Update\V21\Version2118',
|
||||
],
|
||||
'Illuminate\Auth\Events\Login' => [
|
||||
'App\Listeners\Auth\Login',
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Models\Banking\Transaction;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait Transactions
|
||||
{
|
||||
public function isIncome()
|
||||
@ -59,4 +62,30 @@ trait Transactions
|
||||
'transaction.type.' . $index => implode(',', $types),
|
||||
])->save();
|
||||
}
|
||||
|
||||
public function getTransactionFileName(Transaction $transaction, string $separator = '-', string $extension = 'pdf'): string
|
||||
{
|
||||
return $this->getSafeTransactionNumber($transaction, $separator) . $separator . time() . '.' . $extension;
|
||||
}
|
||||
|
||||
public function getSafeTransactionNumber(Transaction $transaction, string $separator = '-'): string
|
||||
{
|
||||
return Str::slug($transaction->id, $separator, language()->getShortCode());
|
||||
}
|
||||
|
||||
protected function getSettingKey($type, $setting_key)
|
||||
{
|
||||
$key = '';
|
||||
$alias = config('type.' . $type . '.alias');
|
||||
|
||||
if (!empty($alias)) {
|
||||
$key .= $alias . '.';
|
||||
}
|
||||
|
||||
$prefix = config('type.' . $type . '.setting.prefix');
|
||||
|
||||
$key .= $prefix . '.' . $setting_key;
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
55
app/View/Components/Transactions/Script.php
Normal file
55
app/View/Components/Transactions/Script.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transactions;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Script extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var string */
|
||||
public $scriptFile;
|
||||
|
||||
/** @var string */
|
||||
public $version;
|
||||
|
||||
public $transaction;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $type = '', string $scriptFile = '', string $version = '', $transaction = false)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->scriptFile = ($scriptFile) ? $scriptFile : 'public/js/common/documents.js';
|
||||
$this->version = $this->getVersion($version);
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transactions.script');
|
||||
}
|
||||
|
||||
protected function getVersion($version)
|
||||
{
|
||||
if (!empty($version)) {
|
||||
return $version;
|
||||
}
|
||||
|
||||
if ($alias = config('type.' . $this->type . '.alias')) {
|
||||
return module_version($alias);
|
||||
}
|
||||
|
||||
return version('short');
|
||||
}
|
||||
}
|
18
app/View/Components/Transactions/Show/Attachment.php
Normal file
18
app/View/Components/Transactions/Show/Attachment.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transactions\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransactionShow as Component;
|
||||
|
||||
class Attachment extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transactions.show.attachment');
|
||||
}
|
||||
}
|
18
app/View/Components/Transactions/Show/Content.php
Normal file
18
app/View/Components/Transactions/Show/Content.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transactions\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransactionShow as Component;
|
||||
|
||||
class Content extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transactions.show.content');
|
||||
}
|
||||
}
|
18
app/View/Components/Transactions/Show/Footer.php
Normal file
18
app/View/Components/Transactions/Show/Footer.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transactions\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransactionShow as Component;
|
||||
|
||||
class Footer extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transactions.show.footer');
|
||||
}
|
||||
}
|
18
app/View/Components/Transactions/Show/Header.php
Normal file
18
app/View/Components/Transactions/Show/Header.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transactions\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransactionShow as Component;
|
||||
|
||||
class Header extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transactions.show.header');
|
||||
}
|
||||
}
|
18
app/View/Components/Transactions/Show/Histories.php
Normal file
18
app/View/Components/Transactions/Show/Histories.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transactions\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransactionShow as Component;
|
||||
|
||||
class Histories extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transactions.show.histories');
|
||||
}
|
||||
}
|
18
app/View/Components/Transactions/Show/TopButtons.php
Normal file
18
app/View/Components/Transactions/Show/TopButtons.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transactions\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransactionShow as Component;
|
||||
|
||||
class TopButtons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transactions.show.top-buttons');
|
||||
}
|
||||
}
|
18
app/View/Components/Transactions/Show/Transaction.php
Normal file
18
app/View/Components/Transactions/Show/Transaction.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transactions\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransactionShow as Component;
|
||||
|
||||
class Transaction extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transactions.show.transaction');
|
||||
}
|
||||
}
|
18
app/View/Components/Transactions/Template/Ddefault.php
Normal file
18
app/View/Components/Transactions/Template/Ddefault.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transactions\Template;
|
||||
|
||||
use App\Abstracts\View\Components\TransactionTemplate as Component;
|
||||
|
||||
class Ddefault extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transactions.template.default');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user