Skip to content

Commit

Permalink
Portal payment added print and pdf action..
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Jun 27, 2021
1 parent 116562e commit 339e7b3
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 152 deletions.
6 changes: 3 additions & 3 deletions app/Abstracts/View/Components/TransactionShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public function __construct(
$this->transaction = $transaction;
$this->transactionTemplate = $this->getTransactionTemplate($type, $transactionTemplate);
$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();

// Navbar Hide
Expand Down Expand Up @@ -909,7 +909,7 @@ protected function getTextContentTitle($type, $textContentTitle)
$default_key = 'payment_made';
break;
default:
$default_key = 'revenue_made';
$default_key = 'revenue_received';
break;
}

Expand All @@ -919,7 +919,7 @@ protected function getTextContentTitle($type, $textContentTitle)
return $translation;
}

return 'revenues.revenue_made';
return 'revenues.revenue_received';
}

protected function getTextPaidAt($type, $textPaidAt)
Expand Down
6 changes: 3 additions & 3 deletions app/Abstracts/View/Components/TransactionTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function __construct(
$this->transaction = $transaction;

$this->logo = $this->getLogo($logo);
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods();
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');

// Company Information Hide checker
$this->hideCompany = $hideCompany;
Expand Down Expand Up @@ -313,7 +313,7 @@ protected function getTextContentTitle($type, $textContentTitle)
$default_key = 'payment_made';
break;
default:
$default_key = 'revenue_made';
$default_key = 'revenue_received';
break;
}

Expand All @@ -323,7 +323,7 @@ protected function getTextContentTitle($type, $textContentTitle)
return $translation;
}

return 'revenues.revenue_made';
return 'revenues.revenue_received';
}

protected function getTextPaidAt($type, $textPaidAt)
Expand Down
47 changes: 47 additions & 0 deletions app/Http/Controllers/Portal/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
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.
*
Expand Down Expand Up @@ -53,6 +56,50 @@ public function 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)
{
if (empty($payment)) {
Expand Down
2 changes: 0 additions & 2 deletions resources/lang/en-GB/payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
'payment_made' => 'Payment Made',
'paid_to' => 'Paid To',
'related_bill' => 'Releated Bill',

'overdue_payment' => 'Overdue Payment',

];
8 changes: 3 additions & 5 deletions resources/lang/en-GB/revenues.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

return [

'revenue_made' => 'Revenue Made',
'paid_by' => 'Paid By',
'related_invoice' => 'Releated Invoice',

'overdue_revenue' => 'Overdue Revenue',
'revenue_received' => 'Revenue Received',
'paid_by' => 'Paid By',
'related_invoice' => 'Releated Invoice',

];
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</td>

<td class="col-xs-4 col-sm-6 text-left long-texts">
{{ $history->creator->name }}
{{ $history->owner->name }}
</td>
@stack('row_footer_histories_body_td_end')
</tr>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/portal/invoices/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@section('new_button')
@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') }}
</a>
@stack('button_print_end')
Expand Down
167 changes: 31 additions & 136 deletions resources/views/portal/payments/show.blade.php
Original file line number Diff line number Diff line change
@@ -1,144 +1,39 @@
@extends('layouts.portal')

@section('title', trans_choice('general.payments', 1))
@section('title', trans_choice('general.payments', 1) . ': ' . @date($payment->paid_at))

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

@stack('button_pdf_start')
<a href="{{ route('portal.payments.pdf', $payment->id) }}" class="btn btn-white btn-sm">
{{ trans('general.download') }}
</a>
@stack('button_pdf_end')
@endsection

@section('content')
<div class="card">
<div class="card-header">
<h3 class="m-0 float-right">@date($payment->paid_at)</h3>
</div>

<div class="card-body">
<div class="row">
<div class="col-md-6">
<div class="card list-group">
<li class="list-group-item list-group-item-action active">
<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>
<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('scripts_start')
@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>
@endpush
2 changes: 1 addition & 1 deletion resources/views/sales/revenues/show.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@extends('layouts.admin')

@section('title', trans('revenues.revenue_made'))
@section('title', trans('revenues.revenue_received'))

@section('new_button')
<x-transactions.show.top-buttons type="income" :transaction="$revenue" />
Expand Down
2 changes: 2 additions & 0 deletions routes/portal.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
Route::resource('invoices', 'Portal\Invoices');

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::get('profile/read-invoices', 'Portal\Profile@readOverdueInvoices')->name('invoices.read');
Expand Down

0 comments on commit 339e7b3

Please sign in to comment.