Home page performance optimisations
This commit is contained in:
@@ -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,62 +0,0 @@
|
||||
<!-- $o = Account::class -->
|
||||
<!-- 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(($x=$o->invoices->where('created_at','>',\Carbon\Carbon::now()->subMonths(12))->where('due','<=',0))->count())
|
||||
<table class="table table-bordered w-100" id="invoices_past_{{ $o->id }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Account</th>
|
||||
<th>#</th>
|
||||
<th>Issued</th>
|
||||
<th>Paid</th>
|
||||
<th class="text-right">Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($x as $oo)
|
||||
<tr>
|
||||
<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->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(datatables,bootstrap4|rowgroup)
|
||||
@js(datatables,bootstrap4|rowgroup)
|
||||
|
||||
<script type="text/javascript">
|
||||
@if ($x->count())
|
||||
$(document).ready(function() {
|
||||
$('#invoices_past_{{ $o->id }}').DataTable({
|
||||
order: [[2,'desc'],[0,'asc']],
|
||||
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>
|
||||
|
Reference in New Issue
Block a user