Merge pull request #2185 from cuneytsenturk/show-transfer
Added transfer show page
This commit is contained in:
721
app/Abstracts/View/Components/TransferShow.php
Normal file
721
app/Abstracts/View/Components/TransferShow.php
Normal file
@ -0,0 +1,721 @@
|
||||
<?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 $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 $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);
|
||||
|
||||
// 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;
|
||||
|
||||
// Releated 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 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';
|
||||
}
|
||||
}
|
278
app/Abstracts/View/Components/TransferTemplate.php
Normal file
278
app/Abstracts/View/Components/TransferTemplate.php
Normal file
@ -0,0 +1,278 @@
|
||||
<?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;
|
||||
|
||||
// Releated 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';
|
||||
}
|
||||
}
|
22
app/Events/Banking/TransferPrinting.php
Normal file
22
app/Events/Banking/TransferPrinting.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events\Banking;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class TransferPrinting
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public $transfer;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $transfer
|
||||
*/
|
||||
public function __construct($transfer)
|
||||
{
|
||||
$this->transfer = $transfer;
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ use App\Models\Banking\Transfer;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Utilities\Modules;
|
||||
use Date;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Transfers extends Controller
|
||||
{
|
||||
@ -37,9 +38,9 @@ class Transfers extends Controller
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show()
|
||||
public function show(Transfer $transfer)
|
||||
{
|
||||
return redirect()->route('transfers.index');
|
||||
return view('banking.transfers.show', compact('transfer'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,11 +54,19 @@ class Transfers extends Controller
|
||||
|
||||
$payment_methods = Modules::getPaymentMethods();
|
||||
|
||||
$currencies = Currency::enabled()->orderBy('name')->get()->makeHidden(['id', 'company_id', 'created_at', 'updated_at', 'deleted_at']);
|
||||
|
||||
$currency = Currency::where('code', setting('default.currency'))->first();
|
||||
|
||||
return view('banking.transfers.create', compact('accounts', 'payment_methods', 'currencies', 'currency'));
|
||||
$file_type_mimes = explode(',', config('filesystems.mimes'));
|
||||
|
||||
$file_types = [];
|
||||
|
||||
foreach ($file_type_mimes as $mime) {
|
||||
$file_types[] = '.' . $mime;
|
||||
}
|
||||
|
||||
$file_types = implode(',', $file_types);
|
||||
|
||||
return view('banking.transfers.create', compact('accounts', 'payment_methods', 'currency', 'file_types'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +81,7 @@ class Transfers extends Controller
|
||||
$response = $this->ajaxDispatch(new CreateTransfer($request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('transfers.index');
|
||||
$response['redirect'] = route('transfers.show', $response['data']->id);
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.transfers', 1)]);
|
||||
|
||||
@ -88,6 +97,24 @@ class Transfers extends Controller
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param Transfer $transfer
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function duplicate(Transfer $transfer)
|
||||
{
|
||||
$clone = $transfer->duplicate();
|
||||
|
||||
$message = trans('messages.success.duplicated', ['type' => trans_choice('general.transfers', 1)]);
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect()->route('transfers.show', $clone->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Import the specified resource.
|
||||
*
|
||||
@ -139,11 +166,19 @@ class Transfers extends Controller
|
||||
|
||||
$account = $transfer->expense_transaction->account;
|
||||
|
||||
$currencies = Currency::enabled()->orderBy('name')->get()->makeHidden(['id', 'company_id', 'created_at', 'updated_at', 'deleted_at']);
|
||||
|
||||
$currency = Currency::where('code', $account->currency_code)->first();
|
||||
|
||||
return view('banking.transfers.edit', compact('transfer', 'accounts', 'payment_methods', 'currencies', 'currency'));
|
||||
$file_type_mimes = explode(',', config('filesystems.mimes'));
|
||||
|
||||
$file_types = [];
|
||||
|
||||
foreach ($file_type_mimes as $mime) {
|
||||
$file_types[] = '.' . $mime;
|
||||
}
|
||||
|
||||
$file_types = implode(',', $file_types);
|
||||
|
||||
return view('banking.transfers.edit', compact('transfer', 'accounts', 'payment_methods', 'currency', 'file_types'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,7 +194,7 @@ class Transfers extends Controller
|
||||
$response = $this->ajaxDispatch(new UpdateTransfer($transfer, $request));
|
||||
|
||||
if ($response['success']) {
|
||||
$response['redirect'] = route('transfers.index');
|
||||
$response['redirect'] = route('transfers.show', $transfer->id);
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.transfers', 1)]);
|
||||
|
||||
@ -210,4 +245,46 @@ class Transfers extends Controller
|
||||
{
|
||||
return $this->exportExcel(new Export, trans_choice('general.transfers', 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the transfer.
|
||||
*
|
||||
* @param Transfer $transfer
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function printTransfer(Transfer $transfer)
|
||||
{
|
||||
event(new \App\Events\Banking\TransferPrinting($transfer));
|
||||
|
||||
$view = view($transfer->template_path, compact('transfer'));
|
||||
|
||||
return mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the PDF file of transfer.
|
||||
*
|
||||
* @param Transfer $transfer
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function pdfTransfer(Transfer $transfer)
|
||||
{
|
||||
event(new \App\Events\Banking\TransferPrinting($transfer));
|
||||
|
||||
$currency_style = true;
|
||||
|
||||
$view = view($transfer->template_path, compact('transfer', '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 = trans_choice('general.transfers', 1) . '-' . Str::slug($transfer->id, '-', language()->getShortCode()) . '-' . time() . '.pdf';
|
||||
|
||||
return $pdf->download($file_name);
|
||||
}
|
||||
}
|
||||
|
67
app/Http/Controllers/Modals/TransferTemplates.php
Normal file
67
app/Http/Controllers/Modals/TransferTemplates.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Modals;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Setting\Setting as Request;
|
||||
|
||||
class TransferTemplates extends Controller
|
||||
{
|
||||
public $skip_keys = ['company_id', '_method', '_token', '_prefix', '_template'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-settings')->only('create', 'store');
|
||||
$this->middleware('permission:read-settings-settings')->only('index', 'edit');
|
||||
$this->middleware('permission:update-settings-settings')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-settings-settings')->only('destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$fields = $request->all();
|
||||
$prefix = $request->get('_prefix', 'transfer');
|
||||
$company_id = $request->get('company_id');
|
||||
|
||||
if (empty($company_id)) {
|
||||
$company_id = company_id();
|
||||
}
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
$real_key = $prefix . '.' . $key;
|
||||
|
||||
// Don't process unwanted keys
|
||||
if (in_array($key, $this->skip_keys)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
setting()->set($real_key, $value);
|
||||
}
|
||||
|
||||
// Save all settings
|
||||
setting()->save();
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.settings', 2)]);
|
||||
|
||||
$response = [
|
||||
'status' => null,
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'message' => $message,
|
||||
'data' => null,
|
||||
'redirect' => route('settings.invoice.edit'),
|
||||
];
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
}
|
@ -84,6 +84,15 @@ class CreateTransfer extends Job
|
||||
'expense_transaction_id' => $expense_transaction->id,
|
||||
'income_transaction_id' => $income_transaction->id,
|
||||
]);
|
||||
|
||||
// Upload attachment
|
||||
if ($this->request->file('attachment')) {
|
||||
foreach ($this->request->file('attachment') as $attachment) {
|
||||
$media = $this->getMedia($attachment, 'transfers');
|
||||
|
||||
$this->transfer->attachMedia($media, 'attachment');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return $this->transfer;
|
||||
|
@ -38,6 +38,19 @@ class UpdateTransfer extends Job
|
||||
public function handle()
|
||||
{
|
||||
\DB::transaction(function () {
|
||||
// Upload attachment
|
||||
if ($this->request->file('attachment')) {
|
||||
$this->deleteMediaModel($this->transfer, 'attachment', $this->request);
|
||||
|
||||
foreach ($this->request->file('attachment') as $attachment) {
|
||||
$media = $this->getMedia($attachment, 'transfers');
|
||||
|
||||
$this->transfer->attachMedia($media, 'attachment');
|
||||
}
|
||||
} elseif (!$this->request->file('attachment') && $this->transfer->attachment) {
|
||||
$this->deleteMediaModel($this->transfer, 'attachment', $this->request);
|
||||
}
|
||||
|
||||
$expense_currency_code = $this->getCurrencyCode('from');
|
||||
$income_currency_code = $this->getCurrencyCode('to');
|
||||
|
||||
|
@ -3,16 +3,20 @@
|
||||
namespace App\Models\Banking;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Models\Common\Media as MediaModel;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\Media;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class Transfer extends Model
|
||||
{
|
||||
use BelongsToThrough, Currencies, HasFactory;
|
||||
use BelongsToThrough, Currencies, HasFactory, Media;
|
||||
|
||||
protected $table = 'transfers';
|
||||
|
||||
protected $appends = ['attachment'];
|
||||
|
||||
/**
|
||||
* Attributes that should be mass-assignable.
|
||||
*
|
||||
@ -59,6 +63,36 @@ class Transfer extends Model
|
||||
)->withDefault(['name' => trans('general.na')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAttachmentAttribute($value = null)
|
||||
{
|
||||
if (!empty($value) && !$this->hasMedia('attachment')) {
|
||||
return $value;
|
||||
} elseif (!$this->hasMedia('attachment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMedia('attachment')->all();
|
||||
}
|
||||
|
||||
public function delete_attachment()
|
||||
{
|
||||
if ($attachments = $this->attachment) {
|
||||
foreach ($attachments as $file) {
|
||||
MediaModel::where('id', $file->id)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTemplatePathAttribute($value = null)
|
||||
{
|
||||
return $value ?: 'banking.transfers.print_' . setting('transfer.template');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
|
55
app/View/Components/Transfers/Script.php
Normal file
55
app/View/Components/Transfers/Script.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Script extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var string */
|
||||
public $scriptFile;
|
||||
|
||||
/** @var string */
|
||||
public $version;
|
||||
|
||||
public $transfer;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $type = '', string $scriptFile = '', string $version = '', $transfer = false)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->scriptFile = ($scriptFile) ? $scriptFile : 'public/js/banking/transfers.js';
|
||||
$this->version = $this->getVersion($version);
|
||||
$this->transfer = $transfer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transfers.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/Transfers/Show/Attachment.php
Normal file
18
app/View/Components/Transfers/Show/Attachment.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransferShow 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.transfers.show.attachment');
|
||||
}
|
||||
}
|
18
app/View/Components/Transfers/Show/Content.php
Normal file
18
app/View/Components/Transfers/Show/Content.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransferShow 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.transfers.show.content');
|
||||
}
|
||||
}
|
18
app/View/Components/Transfers/Show/Footer.php
Normal file
18
app/View/Components/Transfers/Show/Footer.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransferShow 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.transfers.show.footer');
|
||||
}
|
||||
}
|
18
app/View/Components/Transfers/Show/Header.php
Normal file
18
app/View/Components/Transfers/Show/Header.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransferShow 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.transfers.show.header');
|
||||
}
|
||||
}
|
18
app/View/Components/Transfers/Show/Histories.php
Normal file
18
app/View/Components/Transfers/Show/Histories.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransferShow 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.transfers.show.histories');
|
||||
}
|
||||
}
|
18
app/View/Components/Transfers/Show/TopButtons.php
Normal file
18
app/View/Components/Transfers/Show/TopButtons.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransferShow 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.transfers.show.top-buttons');
|
||||
}
|
||||
}
|
18
app/View/Components/Transfers/Show/Transfer.php
Normal file
18
app/View/Components/Transfers/Show/Transfer.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Show;
|
||||
|
||||
use App\Abstracts\View\Components\TransferShow as Component;
|
||||
|
||||
class Transfer extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transfers.show.transfer');
|
||||
}
|
||||
}
|
18
app/View/Components/Transfers/Template/Ddefault.php
Normal file
18
app/View/Components/Transfers/Template/Ddefault.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Template;
|
||||
|
||||
use App\Abstracts\View\Components\TransferTemplate 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.transfers.template.default');
|
||||
}
|
||||
}
|
18
app/View/Components/Transfers/Template/Second.php
Normal file
18
app/View/Components/Transfers/Template/Second.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Template;
|
||||
|
||||
use App\Abstracts\View\Components\TransferTemplate as Component;
|
||||
|
||||
class Second extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transfers.template.second');
|
||||
}
|
||||
}
|
18
app/View/Components/Transfers/Template/Third.php
Normal file
18
app/View/Components/Transfers/Template/Third.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Template;
|
||||
|
||||
use App\Abstracts\View\Components\TransferTemplate as Component;
|
||||
|
||||
class Third extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transfers.template.third');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user