Using datatables to render home dashboard
This commit is contained in:
@@ -13,14 +13,13 @@
|
||||
|
||||
@section('main-content')
|
||||
<div class="content">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="info-box">
|
||||
<span class="info-box-icon bg-red"><i class="fa fa-dollar"></i></span>
|
||||
<div class="info-box-content">
|
||||
<span class="info-box-text">Account Balance</span>
|
||||
<span class="info-box-number"><small>$</small>TBA {{ number_format($user->invoices_due->sum('due'),2) }}</span>
|
||||
<span class="info-box-number"><small>$</small>{{ number_format($user->invoices_due->sum('due'),2) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -11,34 +11,67 @@
|
||||
|
||||
<div class="box-body">
|
||||
@if ($user->invoices_due->count())
|
||||
<table class="table table-bordered table-striped table-hover" id="table">
|
||||
<tr>
|
||||
<th>Invoice</th>
|
||||
<th>Total</th>
|
||||
<th>Due</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
@foreach ($user->invoices_due as $o)
|
||||
@php
|
||||
$co = $o->currency();
|
||||
@endphp
|
||||
<tr>
|
||||
<td>{{ $o->invoice_number }}</td>
|
||||
<td class="right">{{ number_format($o->total,$co->rounding) }}</td>
|
||||
<td class="right">{{ number_format($o->due,$co->rounding) }}</td>
|
||||
<td>{{ $o->date_due }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<th>Count {{ $user->invoices_due->count() }}</th>
|
||||
{{-- @todo Number format should configured by currency --}}
|
||||
<th class="right">{{ number_format($user->invoices_due->sum('total'),2) }}</th>
|
||||
<th class="right">{{ number_format($user->invoices_due->sum('due'),2) }}</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
<table class="table table-bordered table-striped table-hover" id="invoices" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Invoice</th>
|
||||
<th>Total</th>
|
||||
<th>Due</th>
|
||||
<th>Date Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>Count {{ $user->invoices_due->count() }}</th>
|
||||
{{-- @todo Number format should configured by currency --}}
|
||||
<th class="right">{{ number_format($user->invoices_due->sum('total'),2) }}</th>
|
||||
<th class="right">{{ number_format($user->invoices_due->sum('due'),2) }}</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@else
|
||||
<p>No invoices due</p>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('page-scripts')
|
||||
@css('https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css')
|
||||
@css('https://cdn.datatables.net/rowgroup/1.0.2/css/rowGroup.dataTables.min.css')
|
||||
@js('https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js')
|
||||
@js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js')
|
||||
|
||||
<style>
|
||||
table.dataTable {
|
||||
width: 100%;
|
||||
}
|
||||
table.dataTable td {
|
||||
outline: none;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#invoices').DataTable( {
|
||||
responsive: true,
|
||||
ajax: {
|
||||
url: "/api/u/invoices"
|
||||
},
|
||||
columns: [
|
||||
{ data: "invoice_id_url" },
|
||||
{ data: "total" },
|
||||
{ data: "due" },
|
||||
{ data: "date_due" }
|
||||
],
|
||||
language: {
|
||||
emptyTable: "No Invoices Due"
|
||||
},
|
||||
order: [3, 'asc']
|
||||
});
|
||||
|
||||
$('#invoices tbody').on('click','tr', function () {
|
||||
$(this).toggleClass('selected');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@append
|
@@ -11,27 +11,54 @@
|
||||
|
||||
<div class="box-body">
|
||||
@if ($user->payment_history->count())
|
||||
<table class="table table-bordered table-striped table-hover" id="table">
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Amount</th>
|
||||
</tr>
|
||||
@php
|
||||
$c=0;
|
||||
@endphp
|
||||
@foreach ($user->payment_history as $o)
|
||||
@if(! isset($limit) OR $c++ > $limit)
|
||||
@break;
|
||||
@endif
|
||||
<tr>
|
||||
<td>{{ $o->payment_date }}</td>
|
||||
{{-- @todo Number format should configured by currency --}}
|
||||
<td class="right">{{ number_format($o->total_amt,2) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<table class="table table-bordered table-striped table-hover" id="payments" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
@else
|
||||
<p>No payments recorded</p>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('page-scripts')
|
||||
@css('https://cdn.datatables.net/responsive/2.2.1/css/responsive.dataTables.min.css')
|
||||
@css('https://cdn.datatables.net/rowgroup/1.0.2/css/rowGroup.dataTables.min.css')
|
||||
@js('https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js')
|
||||
@js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js')
|
||||
|
||||
<style>
|
||||
table.dataTable {
|
||||
width: 100%;
|
||||
}
|
||||
table.dataTable td {
|
||||
outline: none;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#payments').DataTable( {
|
||||
responsive: true,
|
||||
ajax: {
|
||||
url: "/api/u/payments"
|
||||
},
|
||||
columns: [
|
||||
{ data: "date_paid" },
|
||||
{ data: "total" },
|
||||
],
|
||||
language: {
|
||||
emptyTable: "No Payments On File"
|
||||
},
|
||||
order: [0, 'desc']
|
||||
});
|
||||
|
||||
$('#payments tbody').on('click','tr', function () {
|
||||
$(this).toggleClass('selected');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@append
|
@@ -14,9 +14,10 @@
|
||||
<table class="table table-bordered table-striped table-hover" id="services" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Category</th>
|
||||
<th>Service</th>
|
||||
<th>Name</th>
|
||||
<th>Product</th>
|
||||
<th>Status</th>
|
||||
<th>Next Invoice</th>
|
||||
</tr>
|
||||
@@ -24,7 +25,7 @@
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>Count {{ $user->services_active->count() }}</th>
|
||||
<th colspan="4"> </th>
|
||||
<th colspan="5"> </th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -40,32 +41,44 @@
|
||||
@js('https://cdn.datatables.net/responsive/2.2.1/js/dataTables.responsive.min.js')
|
||||
@js('https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js')
|
||||
|
||||
<style>
|
||||
table.dataTable td {
|
||||
outline: none;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var table = $('#services').DataTable( {
|
||||
$('#services').DataTable( {
|
||||
rowGroup: {
|
||||
dataSrc: 'product_id',
|
||||
dataSrc: 'product_name',
|
||||
startRender: null,
|
||||
endRender: function ( rows, group ) {
|
||||
return group +' ('+rows.count()+')';
|
||||
return rows.count()+' x ' + group;
|
||||
},
|
||||
},
|
||||
orderFixed: [2, 'asc'],
|
||||
orderFixed: [3, 'asc'],
|
||||
responsive: true,
|
||||
ajax: "/api/u/services",
|
||||
ajax: {
|
||||
url: "/api/u/services"
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
defaultContent: ' '
|
||||
},
|
||||
{ data: "id" },
|
||||
{ data: "product_id" },
|
||||
{ data: "active" },
|
||||
{ data: "date_next_invoice" }
|
||||
{ data: "service_id_url" },
|
||||
{ data: "category" },
|
||||
{ data: "service_name" },
|
||||
{ data: "product_name" },
|
||||
{ data: "status" },
|
||||
{ data: "next_invoice" }
|
||||
],
|
||||
language: {
|
||||
emptyTable: "No Active Services"
|
||||
},
|
||||
order: [4, 'asc']
|
||||
order: [5, 'asc']
|
||||
});
|
||||
|
||||
$('#services tbody').on('click','tr', function () {
|
||||
$(this).toggleClass('selected');
|
||||
//var data = table.row(this).data();
|
||||
//window.location.href = '/u/service/view/'+data.id;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user