Portal payment added print and pdf action..

This commit is contained in:
Cüneyt Şentürk 2021-06-27 12:59:56 +03:00
parent 116562ea03
commit 339e7b320a
10 changed files with 92 additions and 152 deletions

View File

@ -349,7 +349,7 @@ abstract class TransactionShow extends Base
$this->transaction = $transaction; $this->transaction = $transaction;
$this->transactionTemplate = $this->getTransactionTemplate($type, $transactionTemplate); $this->transactionTemplate = $this->getTransactionTemplate($type, $transactionTemplate);
$this->logo = $this->getLogo($logo); $this->logo = $this->getLogo($logo);
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods(); $this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
$this->date_format = $this->getCompanyDateFormat(); $this->date_format = $this->getCompanyDateFormat();
// Navbar Hide // Navbar Hide
@ -909,7 +909,7 @@ abstract class TransactionShow extends Base
$default_key = 'payment_made'; $default_key = 'payment_made';
break; break;
default: default:
$default_key = 'revenue_made'; $default_key = 'revenue_received';
break; break;
} }
@ -919,7 +919,7 @@ abstract class TransactionShow extends Base
return $translation; return $translation;
} }
return 'revenues.revenue_made'; return 'revenues.revenue_received';
} }
protected function getTextPaidAt($type, $textPaidAt) protected function getTextPaidAt($type, $textPaidAt)

View File

@ -187,7 +187,7 @@ abstract class TransactionTemplate extends Base
$this->transaction = $transaction; $this->transaction = $transaction;
$this->logo = $this->getLogo($logo); $this->logo = $this->getLogo($logo);
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods(); $this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
// Company Information Hide checker // Company Information Hide checker
$this->hideCompany = $hideCompany; $this->hideCompany = $hideCompany;
@ -313,7 +313,7 @@ abstract class TransactionTemplate extends Base
$default_key = 'payment_made'; $default_key = 'payment_made';
break; break;
default: default:
$default_key = 'revenue_made'; $default_key = 'revenue_received';
break; break;
} }
@ -323,7 +323,7 @@ abstract class TransactionTemplate extends Base
return $translation; return $translation;
} }
return 'revenues.revenue_made'; return 'revenues.revenue_received';
} }
protected function getTextPaidAt($type, $textPaidAt) protected function getTextPaidAt($type, $textPaidAt)

View File

@ -7,10 +7,13 @@ use App\Models\Banking\Transaction;
use App\Models\Setting\Currency; use App\Models\Setting\Currency;
use App\Http\Requests\Portal\PaymentShow as Request; use App\Http\Requests\Portal\PaymentShow as Request;
use App\Utilities\Modules; use App\Utilities\Modules;
use App\Traits\Transactions;
use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\URL;
class Payments extends Controller class Payments extends Controller
{ {
use Transactions;
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
@ -53,6 +56,50 @@ class Payments extends Controller
return $this->response('portal.currencies.index', compact('currencies')); 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) public function signed(Transaction $payment)
{ {
if (empty($payment)) { if (empty($payment)) {

View File

@ -5,7 +5,5 @@ return [
'payment_made' => 'Payment Made', 'payment_made' => 'Payment Made',
'paid_to' => 'Paid To', 'paid_to' => 'Paid To',
'related_bill' => 'Releated Bill', 'related_bill' => 'Releated Bill',
'overdue_payment' => 'Overdue Payment',
]; ];

View File

@ -2,10 +2,8 @@
return [ return [
'revenue_made' => 'Revenue Made', 'revenue_received' => 'Revenue Received',
'paid_by' => 'Paid By', 'paid_by' => 'Paid By',
'related_invoice' => 'Releated Invoice', 'related_invoice' => 'Releated Invoice',
'overdue_revenue' => 'Overdue Revenue',
]; ];

View File

@ -33,7 +33,7 @@
</td> </td>
<td class="col-xs-4 col-sm-6 text-left long-texts"> <td class="col-xs-4 col-sm-6 text-left long-texts">
{{ $history->creator->name }} {{ $history->owner->name }}
</td> </td>
@stack('row_footer_histories_body_td_end') @stack('row_footer_histories_body_td_end')
</tr> </tr>

View File

@ -4,7 +4,7 @@
@section('new_button') @section('new_button')
@stack('button_print_start') @stack('button_print_start')
<a href="{{ route('portal.invoices.print', $invoice->id) }}" target="_blank" class="btn btn-success btn-sm"> <a href="{{ route('portal.invoices.print', $invoice->id) }}" target="_blank" class="btn btn-white btn-sm">
{{ trans('general.print') }} {{ trans('general.print') }}
</a> </a>
@stack('button_print_end') @stack('button_print_end')

View File

@ -1,144 +1,39 @@
@extends('layouts.portal') @extends('layouts.portal')
@section('title', trans_choice('general.payments', 1)) @section('title', trans_choice('general.payments', 1) . ': ' . @date($payment->paid_at))
@section('content') @section('new_button')
<div class="card"> @stack('button_print_start')
<div class="card-header"> <a href="{{ route('portal.payments.print', $payment->id) }}" target="_blank" class="btn btn-white btn-sm">
<h3 class="m-0 float-right">@date($payment->paid_at)</h3> {{ trans('general.print') }}
</div> </a>
@stack('button_print_end')
<div class="card-body"> @stack('button_pdf_start')
<div class="row"> <a href="{{ route('portal.payments.pdf', $payment->id) }}" class="btn btn-white btn-sm">
<div class="col-md-6"> {{ trans('general.download') }}
<div class="card list-group"> </a>
<li class="list-group-item list-group-item-action active"> @stack('button_pdf_end')
<b>{{ trans('general.from') }}:</b> {{ setting('company.name') }}
</li>
<li class="list-group-item"><b>{{ trans('general.address') }}:</b> {{ setting('company.address') }}</li>
<li class="list-group-item"><b>{{ trans('general.phone') }}:</b> {{ setting('company.phone') }}</li>
<li class="list-group-item"><b>{{ trans('general.email') }}:</b> {{ setting('company.email') }}</li>
</div>
</div>
<div class="col-md-6">
<div class="card list-group">
<li class="list-group-item list-group-item-action active">
<b>{{ trans('general.to') }}:</b> {{ $payment->contact->name }}
</li>
<li class="list-group-item"><b>{{ trans('general.address') }}:</b> {{ $payment->contact->address }}</li>
<li class="list-group-item"><b>{{ trans('general.phone') }}:</b> {{ $payment->contact->phone }}</li>
<li class="list-group-item"><b>{{ trans('general.email') }}:</b> {{ $payment->contact->email }}</li>
</div>
</div>
<div class="col-md-6">
@if ($payment->description)
<p class="form-control-label">{{ trans('general.description') }}</p>
<p class="text-muted long-texts">{{ $payment->description }}</p>
@endif
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header border-bottom-0">
<div class="row align-items-center">
<div class="col-12 text-nowrap">
<h4 class="mb-0">{{ trans_choice('general.payments', 1) }}</h4>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-flush table-hover">
<thead class="thead-light">
<tr class="row table-head-line">
<th class="col-xs-4 col-sm-2 text-right">{{ trans('general.amount') }}</th>
<th class="col-xs-4 col-sm-3 text-left">{{ trans_choice('general.payment_methods', 1) }}</th>
<th class="col-xs-4 col-sm-7 text-left long-texts">{{ trans('general.description') }}</th>
</tr>
</thead>
<tbody>
<tr class="row border-top-1 tr-py">
<td class="col-xs-4 col-sm-2 text-right">@money($payment->amount, $payment->currency_code, true)</td>
<td class="col-xs-4 col-sm-3 text-left">{{ $payment_methods[$payment->payment_method] }}</td>
<td class="col-xs-4 col-sm-7 text-left long-texts">{{ $payment->description }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@if ($payment->attachment)
<div class="card-footer">
<div class="row float-right">
<div class="col-md-12">
@if (1)
<div class="card mb-0">
<div class="card-body">
<div class="row align-items-center">
<div class="col-auto">
<i class="far fa-file-pdf display-3"></i>
</div>
<div class="col-auto">
<a class="btn btn-sm btn-icon btn-white" type="button">
<span class="btn-inner--icon">
<i class="fas fa-paperclip"></i>
{{ basename($payment->attachment) }}
</span>
</a>
<a class="btn btn-sm btn-icon btn-info text-white float-right" type="button">
<span class="btn-inner--icon">
<i class="fas fa-file-download"></i>
{{ basename($payment->attachment) }}
</span>
</a>
</div>
</div>
</div>
</div>
@else
<div class="card mb-0">
<div class="card-body">
<div class="row align-items-center">
<div class="col-auto">
@if($payment->attachment)
<img src="public/img/invoice_templates/classic.png" alt="Attachment">
@else
<i class="far fa-file-image display-3"></i>
@endif
</div>
<div class="col-auto">
<a class="btn btn-sm btn-icon btn-white" type="button">
<span class="btn-inner--icon">
<i class="fas fa-camera"></i>
{{ basename($payment->attachment) }}
</span>
</a>
<a class="btn btn-sm btn-icon btn-info text-white float-right" type="button">
<span class="btn-inner--icon">
<i class="fas fa-file-download"></i>
{{ basename($payment->attachment) }}
</span>
</a>
</div>
</div>
</div>
</div>
@endif
</div>
</div>
</div>
@endif
</div>
@endsection @endsection
@push('scripts_start') @section('content')
<x-transactions.show.header
type="payment"
:transaction="$payment"
hide-header-contact
class-header-status="col-md-8"
/>
<x-transactions.show.transaction
type="payment"
:transaction="$payment"
transaction-template="{{ setting('payment.template', 'default') }}"
hide-payment-methods
/>
@endsection
@push('footer_start')
<link rel="stylesheet" href="{{ asset('public/css/print.css?v=' . version('short')) }}" type="text/css">
<script src="{{ asset('public/js/portal/payments.js?v=' . version('short')) }}"></script> <script src="{{ asset('public/js/portal/payments.js?v=' . version('short')) }}"></script>
@endpush @endpush

View File

@ -1,6 +1,6 @@
@extends('layouts.admin') @extends('layouts.admin')
@section('title', trans('revenues.revenue_made')) @section('title', trans('revenues.revenue_received'))
@section('new_button') @section('new_button')
<x-transactions.show.top-buttons type="income" :transaction="$revenue" /> <x-transactions.show.top-buttons type="income" :transaction="$revenue" />

View File

@ -17,6 +17,8 @@ Route::group(['as' => 'portal.'], function () {
Route::resource('invoices', 'Portal\Invoices'); Route::resource('invoices', 'Portal\Invoices');
Route::get('payments/currencies', 'Portal\Payments@currencies')->name('payment.currencies'); Route::get('payments/currencies', 'Portal\Payments@currencies')->name('payment.currencies');
Route::get('payments/{payment}/print', 'Portal\Payments@printPayment')->name('payments.print');
Route::get('payments/{payment}/pdf', 'Portal\Payments@pdfPayment')->name('payments.pdf');
Route::resource('payments', 'Portal\Payments'); Route::resource('payments', 'Portal\Payments');
Route::get('profile/read-invoices', 'Portal\Profile@readOverdueInvoices')->name('invoices.read'); Route::get('profile/read-invoices', 'Portal\Profile@readOverdueInvoices')->name('invoices.read');