Optimise users home page

This commit is contained in:
Deon George
2021-06-29 16:36:34 +10:00
parent 638472fb4f
commit bac4fd6227
34 changed files with 915 additions and 627 deletions

View File

@@ -20,95 +20,45 @@
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header p-2">
<ul class="nav nav-pills">
<li class="nav-item"><a class="nav-link active" href="#tab-services" data-toggle="tab">Services</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-nextinvoice" data-toggle="tab">Next Invoice</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-futureinvoice" data-toggle="tab">Future Invoice</a></li>
</ul>
</div>
<div class="col-12">
<div class="card-header bg-white">
<ul class="nav nav-pills">
<li class="nav-item"><a class="nav-link active" href="#tab-services" data-toggle="tab">Services</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-nextinvoice" data-toggle="tab">Next Invoice</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-futureinvoice" data-toggle="tab">Future Invoice</a></li>
</ul>
</div>
<div class="card-body">
<div class="tab-content">
<div class="active tab-pane" id="tab-services">
<div class="row">
<div class="col-7">
@include('common.service.widget.active')
</div>
<div class="card-body pl-0 pr-0">
<div class="tab-content">
<div class="active tab-pane" id="tab-services">
<div class="row">
<div class="col-7">
@include('u.service.widgets.active')
</div>
<div class="col-5">
<!-- Show outstanding invoices -->
<div class="card card-warning card-outline">
<div class="card-header">
<h4 class="card-title">Outstanding Invoices</h4>
<div class="col-5">
@include('u.invoice.widgets.due')
<div class="card-tools">
<button type="button" class="btn btn-tool" data-widget="collapse"><i class="fas fa-minus"></i></button>
</div>
</div>
@include('u.invoice.widgets.list')
<div class="card-body">
@include('widgets.invoice',[
'o'=>$o->query_invoice_summary()->whereIN('account_id',$o->accounts()->pluck('id')->toArray())->having('balance','>',0),
'widget_invoice_name'=>'widget-invoice'
])
</div>
</div>
<!-- Show last 10 invoices -->
<div class="card card-warning card-outline">
<div class="card-header">
<h4 class="card-title">Invoices - Last 12 Months</h4>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-widget="collapse"><i class="fas fa-minus"></i></button>
</div>
</div>
<div class="card-body">
@include('widgets.invoice',[
'o'=>$o->query_invoice_summary()->whereIN('account_id',$o->accounts()->pluck('id')->toArray())->where('due_date','>',now()->subYear()->timestamp)->having('balance','=',0),
'widget_invoice_name'=>'widget-invoice-last'
])
</div>
</div>
<!-- Show last 10 invoices -->
<div class="card card-warning card-outline">
<div class="card-header">
<h4 class="card-title">Payments - Last 12 Months</h4>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-widget="collapse"><i class="fas fa-minus"></i></button>
</div>
</div>
<div class="card-body">
@include('widgets.payment',[
'o'=>$o->query_payment_summary()->where('date_payment','>',now()->subYear()->timestamp)->with(['items']),
'widget_payment_name'=>'widget-payment-last'
])
</div>
</div>
</div>
@include('u.payment.widgets.list')
</div>
</div>
</div>
<div class="tab-pane" id="tab-nextinvoice">
<div class="row">
<div class="col-12">
@include('r.invoice.widget.next',['future'=>FALSE])
</div>
<div class="tab-pane" id="tab-nextinvoice">
<div class="row">
<div class="col-12">
@include('u.invoice.widgets.next',['future'=>FALSE])
</div>
</div>
</div>
<div class="tab-pane" id="tab-futureinvoice">
<div class="row">
<div class="col-12">
@include('r.invoice.widget.next',['future'=>TRUE])
</div>
<div class="tab-pane" id="tab-futureinvoice">
<div class="row">
<div class="col-12">
@include('u.invoice.widgets.next',['future'=>TRUE])
</div>
</div>
</div>

View File

@@ -3,6 +3,9 @@
@section('htmlheader_title')
Payment Cart
@endsection
@section('page_title')
Payments
@endsection
@section('contentheader_title')
Payment Cart

View File

@@ -1,14 +1,16 @@
@extends('adminlte::layouts.app')
@section('htmlheader_title')
Invoice #{{ $o->id }}
Invoice #{{ $o->lid }}
@endsection
@section('page_title')
{{ $o->sid }}
@endsection
@section('contentheader_title')
Invoice #{{ $o->id }}
Tax Invoice <strong>#{{ $o->lid }}</strong>
@endsection
@section('contentheader_description')
{{ $o->invoice_account_id }}
@endsection
@section('main-content')
@@ -16,11 +18,14 @@
<div class="invoice p-3 mb-3">
<!-- title row -->
<div class="row">
<div class="col-12">
<h4>
<i class="fa fa-globe"></i> {{ $so->site_name }}
<small class="float-right">Date: {{ $o->invoice_date}}</small>
</h4>
<div class="col-8">
<h2>
<img src="{{ $so->site_logo }}">
</h2>
</div>
<div class="col-4 text-right">
<h1 class="text-uppercase">Tax Invoice</h1>
</div>
<!-- /.col -->
</div>
@@ -54,17 +59,26 @@
<div class="ml-auto col-3">
<table class="table table-borderless text-right" style="font-size: 1.1rem;">
<tr >
<td class="p-0">Account:</td><td class="p-0"><strong>{{ $o->account->account_id }}</strong></td>
<td class="p-0">Issue Date:</td><td class="p-0"><strong>{{ $o->invoice_date->format('Y-m-d') }}</strong></td>
</tr>
<tr >
<td class="p-0">Invoice:</td><td class="p-0"><strong>{{ $o->invoice_id }}</strong></td>
<td class="p-0">Account:</td><td class="p-0"><strong>{{ $o->account->sid }}</strong></td>
</tr>
<tr >
<td class="p-0">Invoice:</td><td class="p-0"><strong>{{ $o->lid }}</strong></td>
</tr>
<tr>
<td class="p-0">Payment Due:</td><td class="p-0"><strong>{{ $o->due_date->format('Y-m-d') }}</strong></td>
</tr>
<tr>
<td class="p-0">Total Due:</td><td class="p-0"><strong>${{ number_format($o->total,$o->currency()->rounding) }}</strong></td>
<td class="p-0">This Invoice Due:</td><td class="p-0"><strong>${{ number_format($o->total,$o->currency()->rounding) }}</strong></td>
</tr>
{{--
<!-- @todo -->
<tr>
<td class="p-0">Total Account Due:</td><td class="p-0"><strong>${{ number_format($o->account->due,$o->currency()->rounding) }}</strong></td>
</tr>
--}}
</table>
</div>
</div>
@@ -73,7 +87,7 @@
<!-- Table row -->
<div class="row">
<div class="col-12 table-responsive">
<table id="restripe" class="table" width="100%">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Qty</th>
@@ -87,20 +101,22 @@
@foreach ($o->products() as $po)
<tr id="invoice-services">
<td>{{ $po->count }}</td>
<td>{{ $po->product_id }}</td>
<td>#{{ $po->lid }}</td>
<td colspan="2">{{ $po->name($o->account->user->language) }}</td>
<td colspan="3" class="text-right">${{ number_format($o->items->filter(function($item) use ($po) {return $item->product_id == $po->id; })->sum('total'),$o->currency()->rounding) }}</td>
</tr>
@foreach ($o->product_services($po) as $so)
<tr id="invoice-service-items" class="invoice-services d-none @if($o->products()->count() > 1) d-print-table-row @endif">
<tr id="invoice-service-items" class="invoice-services @if($o->products()->count() > 1) d-print-table-row @endif">
<td colspan="2">&nbsp;</td>
<td colspan="2">Service: <strong>{{ $so->service_id }}: {{ $so->name }}</strong></td>
<td colspan="2">Service: <strong>{{ $so->sid }}: {{ $so->name }}</strong></td>
<td>&nbsp;</td>
<td class="text-right">${{ number_format($o->product_service_items($po,$so)->sum('total'),$o->currency()->rounding) }}</td>
<td>&nbsp;</td>
</tr>
@foreach ($o->product_service_items($po,$so) as $io)
<tr class="invoice-service-items d-none d-print-table-row">
<tr class="invoice-service-items d-print-table-row">
<td colspan="2">&nbsp;</td>
<td width="5%">&nbsp;</td>
<td>{{ $io->item_type_name }}</td>
@@ -117,6 +133,9 @@
</div>
<!-- /.row -->
<!-- padding -->
<div class="row pb-5"></div>
<div class="row">
<!-- accepted payments column -->
<div class="col-6">
@@ -138,16 +157,17 @@
<table class="table">
<tr>
<th colspan="2" style="width:50%">Subtotal:</th>
<td class="text-right">${{ number_format($o->sub_total,$o->currency()->rounding) }}</td>
<td class="text-right">${{ number_format($o->total_sub,$o->currency()->rounding) }}</td>
</tr>
<tr>
<th>&nbsp;</th>
<th>Tax (GST 10%)</th>
<td class="text-right">${{ number_format($o->tax_total,$o->currency()->rounding) }}</td>
<td class="text-right">${{ number_format($o->total_tax,$o->currency()->rounding) }}</td>
</tr>
<tr>
<th>&nbsp;</th>
<th>Other Charges:</th>
<!-- @todo -->
<td class="text-right">$0.00</td>
</tr>
<tr>
@@ -158,23 +178,17 @@
<tr>
<th>&nbsp;</th>
<th>Payments To Clear:</th>
<td class="text-right">${{ number_format($o->pending_paid,$o->currency()->rounding) }}</td>
<td class="text-right">${{ number_format($o->paid_pending,$o->currency()->rounding) }}</td>
</tr>
<tr>
<th>&nbsp;</th>
<th>Payments:</th>
<td class="text-right">${{ number_format($o->paid,$o->currency()->rounding) }}</td>
</tr>
<tr>
<th colspan="2">Invoice Total Due:</th>
<tr style="font-size: 145%">
<th colspan="2">Invoice Due:</th>
<td class="text-right">${{ number_format($o->due,$o->currency()->rounding) }}</td>
</tr>
{{--
<tr>
<th colspan="2">Account Due:</th>
<td class="text-right">${{ number_format($o->account->due,$o->currency()->rounding) }}</td>
</tr>
--}}
@endif
</table>
</div>
@@ -185,13 +199,13 @@
<!-- 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="fa fa-print"></i> Print</a>
<a href="javascript:window.print();" class="btn btn-default"><i class="fas fa-print"></i> Print</a>
@if($o->id)
<a href="{{ url('u/invoice/cart',$o->id) }}" class="btn btn-success float-right">
<i class="fa fa-credit-card"></i> Pay
<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="fa fa-download"></i> Download PDF
<i class="fas fa-download"></i> Download PDF
</a>
@endif
</div>
@@ -200,33 +214,4 @@
<!-- /.content -->
<div class="clearfix"></div>
@endsection
@section('page-scripts')
<style>
.stripe-odd {
background-color: #f9f9f9;
}
.stripe-even {
background-color: #e9e9e9;
}
</style>
<script>
$(document).ready(function() {
$("table#restripe").removeClass("table-striped");
$("table#restripe tr:not(.d-print-table-row)").each(function (index) {
$(this).toggleClass("stripe-odd", (index & 1));
$(this).toggleClass("stripe-even", !!(index & 1));
});
$('tr[id="invoice-services"]').click(function() {
$(".invoice-services").toggleClass("d-none");
});
$('tr[id="invoice-service-items"]').click(function() {
$(".invoice-service-items").toggleClass("d-none");
});
})
</script>
@append
@endsection

View File

@@ -0,0 +1,70 @@
<!-- Show outstanding invoices -->
<div class="card card-warning">
<div class="card-header">
<h3 class="card-title">Invoices Due</h3>
</div>
<div class="card-body">
@if($o->invoices->where('due','>',0)->count())
<table class="table table-bordered w-100" id="invoices_due">
<thead>
<tr>
<th>Account</th>
<th>#</th>
<th>Issued</th>
<th>Due</th>
<th class="text-right">Total</th>
<th class="text-right">Payments</th>
<th class="text-right">Outstanding</th>
</tr>
</thead>
<tbody>
@foreach ($o->invoices->where('due','>',0) as $oo)
<tr @if ($oo->due_date->isPast()) class="table-danger" @endif>
<td>{{ $oo->account->name }}</td>
<td><a href="{{ url('u/invoice',$oo->id) }}">{{ $oo->sid }}</a></td>
<td>{{ $oo->date_orig->format('Y-m-d') }}</td>
<td>{{ $oo->due_date->format('Y-m-d') }}</td>
<td class="text-right">${{ number_format($oo->total,2) }}</td>
<td class="text-right">${{ number_format($oo->paid,2) }}</td>
<td class="text-right">${{ number_format($oo->due,2) }}</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p>No invoice due</p>
@endif
</div>
</div>
@section('page-scripts')
@css('//cdn.datatables.net/1.10.25/css/dataTables.bootstrap5.min.css','jq-dt-css','jquery')
@js('//cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js','jq-dt-js','jquery')
@js('//cdn.datatables.net/1.10.25/js/dataTables.bootstrap5.min.js','jq-dt-bs5-js','jq-dt-js')
@js('//cdn.datatables.net/rowgroup/1.1.3/js/dataTables.rowGroup.min.js','jq-dt-rowgroup-js','jq-dt-js')
@css('//cdn.datatables.net/rowgroup/1.1.3/css/rowGroup.bootstrap5.min.css','jq-dt-rowgroup-css','jq-dt-jss')
<script type="text/javascript">
$(document).ready(function() {
$('#invoices_due').DataTable({
order: [[0,'asc'],[3,'desc']],
rowGroup: {
dataSrc: 0,
},
columnDefs: [
{
targets: [0],
visible: false,
}
],
});
$('#invoices_due tbody').on('click','tr', function () {
$(this).toggleClass('selected');
});
});
</script>
@append

View File

@@ -0,0 +1,68 @@
<!-- Show past 12 months invoices -->
<div class="card card-success">
<div class="card-header">
<h3 class="card-title">Past Invoices</h3>
</div>
<div class="card-body">
@if($o->invoices->where('date_orig','>',($x=\Carbon\Carbon::now()->subMonths(12)))->where('due','=',0)->count())
<table class="table table-bordered w-100" id="invoices_past">
<thead>
<tr>
<th>Account</th>
<th>#</th>
<th>Issued</th>
<th>Due</th>
<th>Paid</th>
<th class="text-right">Total</th>
</tr>
</thead>
<tbody>
@foreach ($o->invoices->where('date_orig','>',$x)->where('due','=',0) as $oo)
<tr>
<td>{{ $oo->account->name }}</td>
<td><a href="{{ url('u/invoice',$oo->id) }}">{{ $oo->sid }}</a></td>
<td>{{ $oo->date_orig->format('Y-m-d') }}</td>
<td>{{ $oo->due_date->format('Y-m-d') }}</td>
<td>{{ $oo->paid_date ? $oo->paid_date->format('Y-m-d') : '' }}</td>
<td class="text-right">${{ number_format($oo->total,2) }}</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p>No invoices to list</p>
@endif
</div>
</div>
@section('page-scripts')
@css('//cdn.datatables.net/1.10.25/css/dataTables.bootstrap5.min.css','jq-dt-css','jquery')
@js('//cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js','jq-dt-js','jquery')
@js('//cdn.datatables.net/1.10.25/js/dataTables.bootstrap5.min.js','jq-dt-bs5-js','jq-dt-js')
@js('//cdn.datatables.net/rowgroup/1.1.3/js/dataTables.rowGroup.min.js','jq-dt-rowgroup-js','jq-dt-js')
@css('//cdn.datatables.net/rowgroup/1.1.3/css/rowGroup.bootstrap5.min.css','jq-dt-rowgroup-css','jq-dt-jss')
<script type="text/javascript">
$(document).ready(function() {
$('#invoices_past').DataTable({
order: [[0,'asc'],[3,'desc']],
rowGroup: {
dataSrc: 0,
},
columnDefs: [
{
targets: [0],
visible: false,
}
],
});
$('#invoices_past tbody').on('click','tr', function () {
$(this).toggleClass('selected');
});
});
</script>
@append

View File

@@ -0,0 +1,40 @@
<!-- Show next items for an invoice -->
@if ($o->next_invoice_items($future)->count())
<div class="card">
<div class="card-body">
<table class="table">
<!-- Group by Account -->
@foreach (($x=$o->next_invoice_items($future))->groupBy('product_id') as $id => $oo)
<tr>
<th colspan="4">{{ $oo->first()->product->name }}</th>
<th class="text-right">${{ number_format($oo->sum('total'),2) }}</th>
</tr>
@foreach ($oo->groupBy('service_id') as $ooo)
<tr>
<td class="pt-0 pb-1" style="width: 8em;"><a href="{{ url('u/service',$ooo->first()->service_id) }}">{{ $ooo->first()->service->sid }}</a></td>
<td class="pt-0 pb-1" colspan="3">{{ $ooo->first()->service->sname }}: {{ $ooo->first()->service->sdesc }}</td>
</tr>
@foreach ($ooo as $io)
<tr>
<td class="pt-0 pb-1">&nbsp;</td>
<td class="pt-0 pb-1">&nbsp;</td>
<td class="pt-0 pb-1">{{ $io->item_type_name }}</td>
<td class="text-right pt-0 pb-1">${{ number_format($io->total,2) }}</td>
</tr>
@endforeach
@endforeach
@endforeach
<tr>
<th class="text-right" colspan="4">TOTAL</th>
<th class="text-right">${{ number_format($x->sum('total'),2) }}</th>
</tr>
</table>
</div>
</div>
@else
<p>No items currently due to invoice.</p>
@endif

View File

@@ -0,0 +1,73 @@
<!-- Show past 12 months payments -->
<div class="card card-success">
<div class="card-header">
<h3 class="card-title">Past Payments</h3>
</div>
<div class="card-body">
@if($o->payments->where('date_orig','>',($x=\Carbon\Carbon::now()->subMonths(12)))->count())
<table class="table table-bordered w-100" id="payments_past">
<thead>
<tr>
<th>Account</th>
<th>#</th>
<th>Received</th>
<th class="text-right">Total</th>
{{--<th class="text-right">Balance</th>--}}
<th>Invoice(s)</th>
</tr>
</thead>
<tbody>
@foreach ($o->payments->where('date_orig','>',($x=\Carbon\Carbon::now()->subMonths(12))) as $oo)
<tr>
<td>{{ $oo->account->name }}</td>
<td>{{ $oo->sid }}</td>
<td>{{ $oo->date_payment->format('Y-m-d') }}</td>
<td class="text-right">${{ number_format($oo->total,2) }}</td>
{{--<td class="text-right">${{ number_format($oo->balance,2) }}</td>--}}
<td>
{!! join(', ',$oo->items
->filter(function($item) { return $item->invoice_id; })
->transform(function($item) { return sprintf('<a href="%s">%s</a>',url('u/invoice',$item->invoice_id),$item->invoice_id); })
->toArray()) !!}
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p>No payments to list</p>
@endif
</div>
</div>
@section('page-scripts')
@css('//cdn.datatables.net/1.10.25/css/dataTables.bootstrap5.min.css','jq-dt-css','jquery')
@js('//cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js','jq-dt-js','jquery')
@js('//cdn.datatables.net/1.10.25/js/dataTables.bootstrap5.min.js','jq-dt-bs5-js','jq-dt-js')
@js('//cdn.datatables.net/rowgroup/1.1.3/js/dataTables.rowGroup.min.js','jq-dt-rowgroup-js','jq-dt-js')
@css('//cdn.datatables.net/rowgroup/1.1.3/css/rowGroup.bootstrap5.min.css','jq-dt-rowgroup-css','jq-dt-jss')
<script type="text/javascript">
$(document).ready(function() {
$('#payments_past').DataTable({
order: [2,'desc'],
rowGroup: {
dataSrc: 0,
},
columnDefs: [
{
targets: [0],
visible: false,
}
],
});
$('#payments_past tbody').on('click','tr', function () {
$(this).toggleClass('selected');
});
});
</script>
@append

View File

@@ -88,7 +88,7 @@
</div>
@can('wholesaler')
<div class="tab-pane fade" id="internal" role="tabpanel">
@include('a.service.widget.internal')
@include('a.service.widgets.internal')
</div>
@endcan
</div>

View File

@@ -0,0 +1,79 @@
<!-- Show active services -->
<div class="card card-primary">
<div class="card-header">
<h3 class="card-title">Active Services</h3>
</div>
<div class="card-body">
@if ($o->services->count())
<table class="table table-striped table-hover" id="services_active">
<thead>
<tr>
<th>ID</th>
<th>Category</th>
<th>Service</th>
<th>Product</th>
<th>Next Invoice</th>
</tr>
</thead>
<tbody>
@foreach ($o->services as $oo)
<tr>
<td><a href="{{ url('u/service',[$oo->id]) }}">{{ $oo->sid }}</a></td>
<td>{{ $oo->product_category }}</td>
<td>{{ $oo->name_short }}</td>
<td>{{ $oo->product_name }}</td>
<td>{{ $oo->external_billing ? '-' : $oo->next_invoice->format('Y-m-d') }}</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th>Count {{ $o->services->count() }}</th>
<th colspan="4">&nbsp;</th>
</tr>
</tfoot>
</table>
@else
<p>No services active</p>
@endif
</div>
</div>
@section('page-scripts')
@css('//cdn.datatables.net/1.10.25/css/dataTables.bootstrap5.min.css','jq-dt-css','jquery')
@js('//cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js','jq-dt-js','jquery')
@js('//cdn.datatables.net/1.10.25/js/dataTables.bootstrap5.min.js','jq-dt-bs5-js','jq-dt-js')
@js('//cdn.datatables.net/rowgroup/1.1.3/js/dataTables.rowGroup.min.js','jq-dt-rowgroup-js','jq-dt-js')
@css('//cdn.datatables.net/rowgroup/1.1.3/css/rowGroup.bootstrap5.min.css','jq-dt-rowgroup-css','jq-dt-jss')
<style>
table.dataTable tr.dtrg-group.dtrg-end.dtrg-level-0 {
font-size: 75%;
background-color: #eeeeee !important;
}
table.dataTable tr.dtrg-group.dtrg-end.dtrg-level-0 td {
background-color: #fefefe !important;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('#services_active').DataTable( {
order: [4,'asc'],
rowGroup: {
dataSrc: 1,
endRender: function ( rows, group ) {
return rows.count()+' x ' + group;
},
},
});
$('#services_active tbody').on('click','tr', function () {
$(this).toggleClass('selected');
});
});
</script>
@append