Fixes for cart and payment/paypal processing
This commit is contained in:
140
resources/views/theme/backend/adminlte/checkout/cart.blade.php
Normal file
140
resources/views/theme/backend/adminlte/checkout/cart.blade.php
Normal file
@@ -0,0 +1,140 @@
|
||||
@use(App\Models\Checkout)
|
||||
@use(App\Models\Invoice)
|
||||
|
||||
@extends('adminlte::layouts.app')
|
||||
|
||||
@section('htmlheader_title')
|
||||
Payment Cart
|
||||
@endsection
|
||||
@section('page_title')
|
||||
Payments
|
||||
@endsection
|
||||
|
||||
@section('contentheader_title')
|
||||
Payment Cart
|
||||
@endsection
|
||||
@section('contentheader_description')
|
||||
@endsection
|
||||
|
||||
@section('main-content')
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="card card-dark">
|
||||
<div class="card-header p-2">
|
||||
<span class="card-title">Invoices to Pay</span>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ url('u/checkout/pay') }}">
|
||||
@csrf
|
||||
|
||||
<input type="hidden" name="type" value="invoice">
|
||||
|
||||
<!-- @todo This is currently forcing only paypal -->
|
||||
<x-leenooks::form.select id="checkout_id" name="checkout_id" icon="fa-credit-card" label="Payment Method" feedback="Payment Method is required" choose="true" :options="Checkout::active()->where('name','ilike','paypal')->orderBy('name')->get()->map(function ($item) { $item->value = $item->name; return $item; })"/>
|
||||
|
||||
<table id="invoices" class="table table-sm w-100">
|
||||
<tr>
|
||||
<th>Invoice</th>
|
||||
<th class="text-right">Balance Due</th>
|
||||
</tr>
|
||||
|
||||
@foreach (($invoices=Invoice::whereIn('id',session('invoice.cart',[]))->get()) as $io)
|
||||
<input type="hidden" name="invoice_id[]" value="{{ $io->id }}">
|
||||
<tr>
|
||||
<td><a class="cart_delete text-dark" data-id="{{ $io->id }}" data-value="{{ $io->due }}" href="{{ url('/u/cart/delete',$io->id) }}"><i class="fas fa-trash-alt"></i></a> {{ $io->sid }}</td>
|
||||
<td class="text-right">{{ number_format($io->due,2) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th class="text-right">Sub Total</th>
|
||||
<td class="text-right"><span id="subtotal">{{ number_format($invoices->sum('due'),2) }}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-right">Payment Fees</th>
|
||||
<td class="text-right"><span id="payfee">TBA</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-right">Payment Total</th>
|
||||
<th class="text-right"><span id="paytotal">TBA</span></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
<!-- Buttons -->
|
||||
<x-leenooks::button.cancel/>
|
||||
<x-leenooks::button.submit class="float-right" disabled>Pay</x-leenooks::button.submit>
|
||||
<a href="{{ url('/home') }}" class="mt-4 btn btn-sm btn-primary">Add Invoice</a>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<x-leenooks::errors/>
|
||||
@endsection
|
||||
|
||||
@section('page-scripts')
|
||||
<script type="text/javascript">
|
||||
var subtotal = {{ $invoices->sum('due') }};
|
||||
|
||||
function fee_total() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
data: {
|
||||
total: subtotal,
|
||||
checkout_id: $('#checkout_id').val()
|
||||
},
|
||||
dataType: 'json',
|
||||
url: '{{ url('u/checkout/fee') }}',
|
||||
timeout: 5000,
|
||||
error: function() {
|
||||
alert('Failed to submit, please try again...');
|
||||
},
|
||||
success: function(data) {
|
||||
$('span[id=payfee]').html(data.toFixed(2));
|
||||
$('span[id=paytotal]').html((subtotal+data).toFixed(2));
|
||||
$('button[type=submit]').prop('disabled',false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
if ($('#checkout_id').val())
|
||||
fee_total();
|
||||
|
||||
$('#checkout_id').on('change',fee_total);
|
||||
|
||||
$('.cart_delete').click(function(item) {
|
||||
var that = $(this);
|
||||
|
||||
// Delete
|
||||
$.ajax({
|
||||
url: '{{ url('u/checkout/cart/remove') }}',
|
||||
method: 'POST',
|
||||
data: {id: that.data('id')},
|
||||
|
||||
}).done(function(data) {
|
||||
that.closest('tr').hide();
|
||||
that.closest('tr').parent().find('input').attr('disabled',true);
|
||||
subtotal -= that.data('value');
|
||||
$('span[id=subtotal]').html(subtotal.toFixed(2));
|
||||
if ($('#checkout_id').val())
|
||||
fee_total();
|
||||
|
||||
}).fail(function(data) {
|
||||
alert('Hmm, that didnt work?');
|
||||
});
|
||||
|
||||
// Clear the data cache
|
||||
that.removeData();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@append
|
@@ -18,9 +18,7 @@
|
||||
@endsection
|
||||
|
||||
@section('main-content')
|
||||
<!-- Main content -->
|
||||
<div class="invoice p-3 mb-3">
|
||||
<!-- title row -->
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<h2>
|
||||
@@ -31,10 +29,8 @@
|
||||
<div class="col-4 text-right">
|
||||
<h1 class="text-uppercase">Tax Invoice</h1>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
|
||||
<!-- info row -->
|
||||
<div class="row invoice-info">
|
||||
<div class="col-4 invoice-col">
|
||||
<address>
|
||||
@@ -84,12 +80,10 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
<!-- Table row -->
|
||||
<div class="row">
|
||||
<div class="col-12 table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<div class="col">
|
||||
<table class="table table-responsive table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Qty</th>
|
||||
@@ -144,15 +138,11 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
<!-- padding -->
|
||||
<div class="row pb-5"></div>
|
||||
|
||||
<div class="row">
|
||||
<!-- accepted payments column -->
|
||||
<div class="col-6">
|
||||
<p class="lead">Payment Methods:</p>
|
||||
|
||||
@@ -172,7 +162,6 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- /.col -->
|
||||
<div class="ml-auto col-4">
|
||||
<table class="table">
|
||||
<tr>
|
||||
@@ -213,18 +202,14 @@
|
||||
@endif
|
||||
</table>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
<!-- this row will not appear when printing -->
|
||||
<div class="row d-print-none">
|
||||
<div class="col-12">
|
||||
<a href="javascript:window.print();" class="btn btn-default"><i class="fas fa-print"></i> Print</a>
|
||||
<button type="button" id="print" class="btn btn-default"><i class="fas fa-print"></i> Print</button>
|
||||
@if($o->id)
|
||||
<a href="{{ url('u/invoice/cart',$o->id) }}" class="btn btn-success float-right">
|
||||
<i class="fas fa-credit-card"></i> Pay
|
||||
</a>
|
||||
<a href="{{ url('u/checkout/cart',$o->id) }}" class="btn btn-success float-right"><i class="fas fa-credit-card"></i> Pay</a>
|
||||
{{--
|
||||
<a href="{{ url(sprintf('u/invoice/%s/pdf',$o->id)) }}" class="btn btn-primary float-right mr-2">
|
||||
<i class="fas fa-download"></i> Download PDF
|
||||
@@ -234,7 +219,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.content -->
|
||||
@endsection
|
||||
|
||||
<div class="clearfix"></div>
|
||||
@endsection
|
||||
@section('page-styles')
|
||||
<style media="print">
|
||||
/* Dont show URL and date in print output */
|
||||
@page {
|
||||
size: auto; /* auto is the initial value */
|
||||
margin: 0; /* this affects the margin in the printer settings */
|
||||
}
|
||||
</style>
|
||||
@append
|
||||
@section('page-scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#print').on('click',function() {
|
||||
window.print();
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@append
|
@@ -1,109 +0,0 @@
|
||||
@extends('adminlte::layouts.app')
|
||||
|
||||
@section('htmlheader_title')
|
||||
Payment Cart
|
||||
@endsection
|
||||
@section('page_title')
|
||||
Payments
|
||||
@endsection
|
||||
|
||||
@section('contentheader_title')
|
||||
Payment Cart
|
||||
@endsection
|
||||
@section('contentheader_description')
|
||||
@endsection
|
||||
|
||||
@section('main-content')
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="card card-dark">
|
||||
<div class="card-header">
|
||||
<span class="card-title">Invoices to Pay</span>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ url('u/checkout/pay') }}">
|
||||
@csrf
|
||||
|
||||
<input type="hidden" name="type" value="invoice">
|
||||
|
||||
<div class="input-group mb-5">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">Payment Method</span>
|
||||
</div>
|
||||
|
||||
<select class="form-control" id="paymethod" name="checkout_id[]" required>
|
||||
<option></option>
|
||||
@foreach (\App\Models\Checkout::active()->orderBy('name')->get() as $oo)
|
||||
<option value="{{ $oo->id }}">{{ $oo->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<table id="invoices" class="table table-sm w-100">
|
||||
<tr>
|
||||
<th>Invoice</th>
|
||||
<th class="text-right">Balance Due</th>
|
||||
</tr>
|
||||
|
||||
@foreach ($invoices as $io)
|
||||
<input type="hidden" name="invoice_id[]" value="{{ $io->id }}">
|
||||
<tr>
|
||||
<td>{{ $io->sid }}</td>
|
||||
<td class="text-right">{{ number_format($io->due,2) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th class="text-right">Sub Total</th>
|
||||
<td class="text-right">{{ number_format($invoices->sum('due'),2) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-right">Payment Fees</th>
|
||||
<td class="text-right"><span id="payfee">TBA</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-right">Payment Total</th>
|
||||
<th class="text-right"><span id="paytotal">TBA</span></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
<input type="submit" class="btn btn-dark mt-2" name="pay" value="Cancel">
|
||||
<input type="submit" class="btn btn-success mt-2 float-right" name="pay" value="Submit" disabled>
|
||||
<a href="{{ url('/home') }}" class="btn btn-danger mt-2 float-right mr-2">Add Invoice</a>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('page-scripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#paymethod').on('change',function(item) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: {total: {{ $invoices->sum('due') }},count: {{ $invoices->count() }} },
|
||||
dataType: "json",
|
||||
cache: true,
|
||||
url: '{{ url('api/u/checkout/fee') }}'+'/'+$(this).val(),
|
||||
timeout: 25000,
|
||||
error: function(x) {
|
||||
alert("Failed to submit, please try again...");
|
||||
},
|
||||
success: function(data) {
|
||||
$("span[id=payfee]").html(data.toFixed(2));
|
||||
$("span[id=paytotal]").html(({{ $invoices->sum('due') }}+data).toFixed(2));
|
||||
$("input[type=submit]").prop('disabled',false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@append
|
Reference in New Issue
Block a user