Customer invoice for unique link

This commit is contained in:
cuneytsenturk 2018-10-15 16:25:10 +03:00
parent c680ccf8f7
commit c23abe13bf
2 changed files with 26 additions and 5 deletions

View File

@ -20,6 +20,7 @@ use File;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Image; use Image;
use Storage; use Storage;
use SignedUrl;
class Invoices extends Controller class Invoices extends Controller
{ {
@ -183,6 +184,8 @@ class Invoices extends Controller
public function link(Invoice $invoice, Request $request) public function link(Invoice $invoice, Request $request)
{ {
session(['company_id' => $invoice->company_id]);
$paid = 0; $paid = 0;
foreach ($invoice->payments as $item) { foreach ($invoice->payments as $item) {
@ -211,6 +214,19 @@ class Invoices extends Controller
$payment_methods = Modules::getPaymentMethods(); $payment_methods = Modules::getPaymentMethods();
return view('customers.invoices.link', compact('invoice', 'accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods')); $payment_actions = [];
foreach ($payment_methods as $payment_method_key => $payment_method_value) {
$codes = explode('.', $payment_method_key);
if (!isset($payment_actions[$codes[0]])) {
$payment_actions[$codes[0]] = SignedUrl::sign(url('links/invoices/' . $invoice->id . '/' . $codes[0]), 1);
}
}
$print_action = SignedUrl::sign(url('links/invoices/' . $invoice->id . '/print'), 1);
$pdf_action = SignedUrl::sign(url('links/invoices/' . $invoice->id . '/pdf'), 1);
return view('customers.invoices.link', compact('invoice', 'accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods', 'payment_actions', 'print_action', 'pdf_action'));
} }
} }

View File

@ -150,10 +150,10 @@
<div class="box-footer row no-print"> <div class="box-footer row no-print">
<div class="col-md-10"> <div class="col-md-10">
<a href="{{ url('customers/invoices/' . $invoice->id . '/print') }}" target="_blank" class="btn btn-default"> <a href="{{ $print_action }}" target="_blank" class="btn btn-default">
<i class="fa fa-print"></i>&nbsp; {{ trans('general.print') }} <i class="fa fa-print"></i>&nbsp; {{ trans('general.print') }}
</a> </a>
<a href="{{ url('customers/invoices/' . $invoice->id . '/pdf') }}" class="btn btn-default" data-toggle="tooltip" title="{{ trans('invoices.download_pdf') }}"> <a href="{{ $pdf_action }}" class="btn btn-default" data-toggle="tooltip" title="{{ trans('invoices.download_pdf') }}">
<i class="fa fa-file-pdf-o"></i>&nbsp; {{ trans('general.download') }} <i class="fa fa-file-pdf-o"></i>&nbsp; {{ trans('general.download') }}
</a> </a>
</div> </div>
@ -162,6 +162,7 @@
@if($invoice->invoice_status_code != 'paid') @if($invoice->invoice_status_code != 'paid')
@if ($payment_methods) @if ($payment_methods)
{!! Form::select('payment_method', $payment_methods, null, array_merge(['id' => 'payment-method', 'class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.payment_methods', 1)])])) !!} {!! Form::select('payment_method', $payment_methods, null, array_merge(['id' => 'payment-method', 'class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.payment_methods', 1)])])) !!}
{!! Form::select('payment_method_actions', $payment_actions, null, array_merge(['id' => 'payment-method-actions', 'class' => 'form-control hidden'])) !!}
{!! Form::hidden('invoice_id', $invoice->id, []) !!} {!! Form::hidden('invoice_id', $invoice->id, []) !!}
@else @else
@ -182,9 +183,13 @@
gateway = payment_method.split('.'); gateway = payment_method.split('.');
$('#payment-method-actions').val(gateway[0]);
var url = $('#payment-method-actions').find('option:selected').text();
$.ajax({ $.ajax({
url: '{{ url("customers/invoices/" . $invoice->id) }}/' + gateway[0], url: url,
type: 'GET', type: 'POST',
dataType: 'JSON', dataType: 'JSON',
data: $('.box-footer input, .box-footer select'), data: $('.box-footer input, .box-footer select'),
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },