Home page performance optimisations
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<!-- $o = Account::class -->
|
||||
<!-- 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(($list=$o->invoiceSummaryDue()->get())->count())
|
||||
@include('theme.backend.adminlte.invoice.widget.due')
|
||||
|
||||
@else
|
||||
<p>No invoice due</p>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
@@ -6,7 +6,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if(($x=$o->invoices->where('created_at','>',\Carbon\Carbon::now()->subMonths(12))->where('due','<=',0))->count())
|
||||
@if(($list=$o->invoiceSummaryPast()->where('invoices.created_at','>=',\Carbon\Carbon::now()->subYears(2)->startOfYear())->get())->count())
|
||||
<table class="table table-bordered w-100" id="invoices_past_{{ $o->id }}">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -19,13 +19,13 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($x as $oo)
|
||||
@foreach ($list as $oo)
|
||||
<tr>
|
||||
<td>{{ $oo->account->name }}</td>
|
||||
<td><a href="{{ url('u/invoice',$oo->id) }}">{{ $oo->sid }}</a></td>
|
||||
<td><a href="{{ url('u/invoice',$oo->id) }}">{{ $oo->lid }}</a></td>
|
||||
<td>{{ $oo->created_at->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>
|
||||
<td>{{ $oo->_paid_at?->format('Y-m-d') }}</td>
|
||||
<td class="text-right">${{ number_format($oo->_total,2) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@@ -37,12 +37,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('page-scripts')
|
||||
@section('page-styles')
|
||||
@css(datatables,bootstrap4|rowgroup)
|
||||
@append
|
||||
|
||||
@section('page-scripts')
|
||||
@js(datatables,bootstrap4|rowgroup)
|
||||
|
||||
<script type="text/javascript">
|
||||
@if ($x->count())
|
||||
@if ($list->count())
|
||||
$(document).ready(function() {
|
||||
$('#invoices_past_{{ $o->id }}').DataTable({
|
||||
order: [[2,'desc'],[0,'asc']],
|
@@ -20,13 +20,13 @@
|
||||
|
||||
<tbody>
|
||||
@foreach ($x as $so)
|
||||
<tr>
|
||||
<td><a href="{{ url('u/service',[$so->id]) }}">{{ $so->sid }}</a></td>
|
||||
<td>{{ $so->product->category_name }}</td>
|
||||
<td>{{ $so->name_short }}</td>
|
||||
<td>{{ $so->product->name }}</td>
|
||||
<td>{{ $so->external_billing ? '-' : $so->invoice_next->format('Y-m-d') }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="{{ url('u/service',[$so->id]) }}">{{ $so->sid }}</a></td>
|
||||
<td>{{ $so->product->category_name }}</td>
|
||||
<td>{{ $so->name_short }}</td>
|
||||
<td>{{ $so->product->name }}</td>
|
||||
<td>{{ $so->external_billing ? '-' : $so->invoice_next->format('Y-m-d') }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
@@ -43,8 +43,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('page-scripts')
|
||||
@section('page-styles')
|
||||
@css(datatables,bootstrap4|rowgroup)
|
||||
@append
|
||||
|
||||
@section('page-scripts')
|
||||
@js(datatables,bootstrap4|rowgroup)
|
||||
|
||||
<script type="text/javascript">
|
||||
@@ -64,10 +67,6 @@
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
$('#services_active_{{ $ao->id }} tbody').on('click','tr', function () {
|
||||
$(this).toggleClass('selected');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@append
|
@@ -45,7 +45,7 @@
|
||||
|
||||
<div class="info-box-content">
|
||||
<span class="info-box-text">Account Balance</span>
|
||||
<span class="info-box-number"><small>$</small> {{ number_format(($x=$o->invoices()->with(['items.taxes','paymentitems.payment','account'])->get()->where('due','>',0))->sum('due'),2) }}</span>
|
||||
<span class="info-box-number"><small>$</small> {{ number_format(($x=$o->accounts->map(fn($item)=>$item->invoiceSummaryDue()->get()->pluck('_balance'))->flatten())->sum(),2) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -17,7 +17,7 @@
|
||||
@section('main-content')
|
||||
<!-- Our Summary Home Page Boxes -->
|
||||
<div class="row">
|
||||
@include('theme.backend.adminlte.common.account.widget.summary')
|
||||
@include('theme.backend.adminlte.account.widget.summary_boxes')
|
||||
</div>
|
||||
|
||||
<div class="card card-light card-tabs">
|
||||
@@ -49,10 +49,6 @@
|
||||
<div class="card-header bg-white">
|
||||
<ul class="nav nav-pills">
|
||||
<li class="nav-item"><a class="nav-link {{ (! session()->has('supplier_update')) ? 'active' : '' }}" href="#tab-services" data-toggle="tab">Services</a></li>
|
||||
{{--
|
||||
<!-- @todo this is not working -->
|
||||
<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>
|
||||
@canany('reseller','wholesaler')
|
||||
<li class="nav-item ml-auto">
|
||||
@@ -67,30 +63,16 @@
|
||||
<div class="tab-pane {{ (! session()->has('supplier_update')) ? 'active' : '' }}" id="tab-services">
|
||||
<div class="row">
|
||||
<div class="col-12 col-xl-7">
|
||||
@include('theme.backend.adminlte.service.widget.active',['o'=>$ao])
|
||||
@include('theme.backend.adminlte.account.widget.service_active',['o'=>$ao])
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-xl-5">
|
||||
@include('theme.backend.adminlte.invoice.widget.due',['o'=>$ao])
|
||||
|
||||
@include('theme.backend.adminlte.invoice.widget.list',['o'=>$ao])
|
||||
|
||||
@include('theme.backend.adminlte.payment.widget.list',['o'=>$ao])
|
||||
@include('theme.backend.adminlte.account.widget.invoice_due',['o'=>$ao])
|
||||
@include('theme.backend.adminlte.account.widget.invoice_past',['o'=>$ao])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{--
|
||||
<!-- @todo this is not working -->
|
||||
<div class="tab-pane" id="tab-nextinvoice">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('theme.backend.adminlte.u.invoice.widgets.next',['future'=>FALSE])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
--}}
|
||||
|
||||
<div class="tab-pane" id="tab-futureinvoice">
|
||||
<div class="row">
|
||||
<div class="col-12 col-xl-9">
|
||||
|
@@ -1,62 +1,53 @@
|
||||
<!-- $o = Account::class -->
|
||||
<!-- Show outstanding invoices -->
|
||||
<div class="card card-warning">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Invoices Due</h3>
|
||||
</div>
|
||||
<table class="table table-bordered w-100" id="invoices_due_{{ $o->id }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Account</th>
|
||||
<th>#</th>
|
||||
<th>Due</th>
|
||||
<th class="text-right">Total</th>
|
||||
<th class="text-right">Outstanding</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<div class="card-body">
|
||||
@if(($x=$o->invoices->where('due','>',0))->count())
|
||||
<table class="table table-bordered w-100" id="invoices_due_{{ $o->id }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Account</th>
|
||||
<th>#</th>
|
||||
<th>Due</th>
|
||||
<th class="text-right">Total</th>
|
||||
<th class="text-right">Outstanding</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($list as $oo)
|
||||
<tr @if ($oo->due_at->isPast()) class="table-danger" @endif>
|
||||
<td>{{ $oo->account->name }}</td>
|
||||
<td><a href="{{ url('u/invoice',$oo->id) }}">{{ $oo->lid }}</a></td>
|
||||
<td>{{ $oo->due_at->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>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<tbody>
|
||||
@foreach ($x as $oo)
|
||||
<tr @if ($oo->due_at->isPast()) class="table-danger" @endif>
|
||||
<td>{{ $oo->account->name }}</td>
|
||||
<td><a href="{{ url('u/invoice',$oo->id) }}">{{ $oo->lid }}</a></td>
|
||||
<td>{{ $oo->due_at->format('Y-m-d') }}</td>
|
||||
<td class="text-right">${{ number_format($oo->total,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-styles')
|
||||
@css(datatables,bootstrap4|rowgroup)
|
||||
@append
|
||||
|
||||
@section('page-scripts')
|
||||
@css(datatables,bootstrap4|rowgroup)
|
||||
@js(datatables,bootstrap4|rowgroup)
|
||||
|
||||
<script type="text/javascript">
|
||||
@if ($x->count())
|
||||
$(document).ready(function() {
|
||||
$('#invoices_due_{{ $o->id }}').DataTable({
|
||||
order: [[0,'asc'],[3,'desc']],
|
||||
rowGroup: {
|
||||
dataSrc: 0,
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
targets: [0],
|
||||
visible: false,
|
||||
}
|
||||
],
|
||||
});
|
||||
@if ($list->count())
|
||||
$(document).ready(function() {
|
||||
$('#invoices_due_{{ $o->id }}').DataTable({
|
||||
// If we have more than 1 account id, order by account
|
||||
order: [[0,'asc'],[2,'asc'],[1,'desc']],
|
||||
rowGroup: {
|
||||
dataSrc: 0,
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
targets: [0],
|
||||
visible: false,
|
||||
}
|
||||
],
|
||||
});
|
||||
});
|
||||
@endif
|
||||
</script>
|
||||
@append
|
@@ -1,11 +1,11 @@
|
||||
<!-- @todo These needs to be optimised, and change for $o = Account::class -->
|
||||
<!-- Show next items for an invoice -->
|
||||
@if ($o->next_invoice_items($future)->count())
|
||||
@if (($x=$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)
|
||||
@foreach ($x->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>
|
||||
|
@@ -1,71 +0,0 @@
|
||||
<!-- $o = Account::class -->
|
||||
<!-- 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(($x=$o->payments->where('created_at','>',\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 ($x as $oo)
|
||||
<tr>
|
||||
<td>{{ $oo->account->name }}</td>
|
||||
<td>{{ $oo->lid }}</td>
|
||||
<td>{{ $oo->paid_at->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(datatables,bootstrap4|rowgroup)
|
||||
@js(datatables,bootstrap4|rowgroup)
|
||||
|
||||
<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
|
@@ -6,66 +6,11 @@
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if($o->query_invoice_summary()->havingRaw('invoice_total-payments > 0')->count())
|
||||
<table class="table table-bordered w-100" id="reseller_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->query_invoice_summary()->havingRaw('invoice_total-payments > 0')->get() as $oo)
|
||||
<tr @if ($oo->due_at->isPast()) class="table-danger" @endif>
|
||||
<td>{{ $oo->account->name }}</td>
|
||||
<td><a href="{{ url('u/invoice',$oo->id) }}">{{ $oo->sid }}</a></td>
|
||||
<td>{{ $oo->created_at->format('Y-m-d') }}</td>
|
||||
<td>{{ $oo->due_at->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>
|
||||
@if(($list=\App\Models\Account::InvoicesDue())->count())
|
||||
@include('theme.backend.adminlte.invoice.widget.due')
|
||||
|
||||
@else
|
||||
<p>No invoice due</p>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('page-styles')
|
||||
@css(datatables,bootstrap4|rowgroup)
|
||||
@append
|
||||
|
||||
@section('page-scripts')
|
||||
@js(datatables,bootstrap4|rowgroup)
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#reseller_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
|
||||
</div>
|
Reference in New Issue
Block a user