Changed home screen to use account models instead of user model. Home screen now shows multiple accounts
This commit is contained in:
parent
790ece14d1
commit
dde11f73f5
@ -31,8 +31,6 @@ class HomeController extends Controller
|
|||||||
if (! $o->exists)
|
if (! $o->exists)
|
||||||
$o = Auth::user();
|
$o = Auth::user();
|
||||||
|
|
||||||
$o->load(['services.invoice_items','services.type']);
|
|
||||||
|
|
||||||
return View('home',['o'=>$o]);
|
return View('home',['o'=>$o]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,9 +64,15 @@ class Account extends Model implements IDs
|
|||||||
return $this->hasOneThrough(Group::class,AccountGroup::class,'account_id','id','id','group_id');
|
return $this->hasOneThrough(Group::class,AccountGroup::class,'account_id','id','id','group_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
* @todo This needs to be optimised, to only return outstanding invoices and invoices for a specific age (eg: 2 years worth)
|
||||||
|
*/
|
||||||
public function invoices()
|
public function invoices()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Invoice::class);
|
return $this->hasMany(Invoice::class)
|
||||||
|
->active()
|
||||||
|
->with(['items.taxes','paymentitems.payment']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function language()
|
public function language()
|
||||||
@ -76,7 +82,9 @@ class Account extends Model implements IDs
|
|||||||
|
|
||||||
public function payments()
|
public function payments()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Payment::class);
|
return $this->hasMany(Payment::class)
|
||||||
|
->active()
|
||||||
|
->with(['items']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function providers()
|
public function providers()
|
||||||
@ -89,7 +97,8 @@ class Account extends Model implements IDs
|
|||||||
public function services($active=FALSE)
|
public function services($active=FALSE)
|
||||||
{
|
{
|
||||||
$query = $this->hasMany(Service::class,['account_id','site_id'],['id','site_id'])
|
$query = $this->hasMany(Service::class,['account_id','site_id'],['id','site_id'])
|
||||||
->withoutGlobalScope(SiteScope::class);
|
->withoutGlobalScope(SiteScope::class)
|
||||||
|
->with(['product.translate','invoice_items']);
|
||||||
|
|
||||||
return $active ? $query->active() : $query;
|
return $active ? $query->active() : $query;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ class Service extends Model implements IDs
|
|||||||
protected $with = [
|
protected $with = [
|
||||||
//'invoice_items',
|
//'invoice_items',
|
||||||
//'product.type.supplied',
|
//'product.type.supplied',
|
||||||
//'type',
|
'type',
|
||||||
];
|
];
|
||||||
|
|
||||||
public const INACTIVE_STATUS = [
|
public const INACTIVE_STATUS = [
|
||||||
|
@ -105,14 +105,14 @@ class User extends Authenticatable implements IDs
|
|||||||
{
|
{
|
||||||
return $this->hasMany(Account::class)
|
return $this->hasMany(Account::class)
|
||||||
->orWhereIn('id',$this->rtm_accounts()->pluck('id'))
|
->orWhereIn('id',$this->rtm_accounts()->pluck('id'))
|
||||||
->active()
|
->active();
|
||||||
->with(['services']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This users invoices
|
* This users invoices
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||||
|
* @deprecated Accounts have invoices, not users
|
||||||
*/
|
*/
|
||||||
public function invoices()
|
public function invoices()
|
||||||
{
|
{
|
||||||
@ -130,16 +130,6 @@ class User extends Authenticatable implements IDs
|
|||||||
return $this->belongsTo(Language::class);
|
return $this->belongsTo(Language::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The payments this user has made
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
|
||||||
*/
|
|
||||||
public function payments()
|
|
||||||
{
|
|
||||||
return $this->hasManyThrough(Payment::class,Account::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the routes to market account for this user
|
* Return the routes to market account for this user
|
||||||
*
|
*
|
||||||
@ -151,9 +141,10 @@ class User extends Authenticatable implements IDs
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* THe services this user has
|
* The services this user has
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||||
|
* @deprecated Accounts have services, not users
|
||||||
*/
|
*/
|
||||||
public function services()
|
public function services()
|
||||||
{
|
{
|
||||||
@ -162,6 +153,12 @@ class User extends Authenticatable implements IDs
|
|||||||
->active();
|
->active();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supplier configuration for this user
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||||
|
* @deprecated Move to account->suppliers()
|
||||||
|
*/
|
||||||
public function suppliers()
|
public function suppliers()
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Supplier::class)
|
return $this->belongsToMany(Supplier::class)
|
||||||
@ -178,7 +175,7 @@ class User extends Authenticatable implements IDs
|
|||||||
*/
|
*/
|
||||||
public function getNameAttribute(): string
|
public function getNameAttribute(): string
|
||||||
{
|
{
|
||||||
return $this->getFullNameAttribute();
|
return $this->full_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -192,13 +189,20 @@ class User extends Authenticatable implements IDs
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return my accounts
|
* Return my accounts, but only those accounts with the same group_id
|
||||||
*
|
*
|
||||||
|
* @note Users can only manage accounts with the same group ID, thereby ensuring they dont see different
|
||||||
|
* pricing options - since prices can be controlled by groups
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getMyAccountsAttribute(): Collection
|
public function getMyAccountsAttribute(): Collection
|
||||||
{
|
{
|
||||||
return $this->accounts->where('user_id',$this->id);
|
$result = $this->accounts->where('user_id',$this->id);
|
||||||
|
|
||||||
|
if (! $result->count())
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
return $this->isReseller() ? $result : $result->groupBy('group.id')->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,76 +20,102 @@
|
|||||||
@include('common.account.widget.summary')
|
@include('common.account.widget.summary')
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="card card-light card-tabs">
|
||||||
<div class="col-12">
|
<div class="card-header p-0 pt-1">
|
||||||
<div class="card-header bg-white">
|
<ul class="nav nav-tabs" id="accounts-tab" role="tablist">
|
||||||
<ul class="nav nav-pills">
|
<li class="pt-2 px-3"><h3 class="card-title">Accounts</h3></li>
|
||||||
<li class="nav-item"><a class="nav-link {{ (! session()->has('supplier_update')) ? 'active' : '' }}" href="#tab-services" data-toggle="tab">Services</a></li>
|
@foreach($o->my_accounts as $ao)
|
||||||
{{--
|
<li class="nav-item">
|
||||||
<!-- @todo this is not working -->
|
<a class="nav-link @if(! $loop->index)active @endif" href="#account_{{ $ao->id }}" data-toggle="tab" aria-controls="account_{{ $ao->id }}" aria-selected="true">{{ $ao->name }}</a>
|
||||||
<li class="nav-item"><a class="nav-link" href="#tab-nextinvoice" data-toggle="tab">Next Invoice</a></li>
|
</li>
|
||||||
--}}
|
@endforeach
|
||||||
<li class="nav-item"><a class="nav-link" href="#tab-futureinvoice" data-toggle="tab">Future Invoice</a></li>
|
|
||||||
|
|
||||||
@canany('reseller','wholesaler')
|
@canany('reseller','wholesaler')
|
||||||
<li class="nav-item ml-auto"><a class="nav-link {{ session()->has('supplier_update') ? 'active' : '' }}" href="#tab-supplier" data-toggle="tab">Supplier</a></li>
|
@if ($o === $user)
|
||||||
@if ($o == $user)
|
<li class="nav-item ml-auto">
|
||||||
<li class="nav-item "><a class="nav-link" href="#tab-reseller" data-toggle="tab">Reseller</a></li>
|
<a class="nav-link" href="#tab-reseller" data-toggle="tab">Reseller</a>
|
||||||
@endif
|
</li>
|
||||||
@endcanany
|
@endif
|
||||||
</ul>
|
@endcanany
|
||||||
</div>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card-body pl-0 pr-0">
|
<div class="card-body">
|
||||||
<div class="tab-content">
|
<div class="tab-content" id="accounts-tab-content">
|
||||||
<div class="tab-pane {{ (! session()->has('supplier_update')) ? 'active' : '' }}" id="tab-services">
|
@foreach($o->my_accounts as $ao)
|
||||||
<div class="row">
|
<div class="tab-pane fade @if(! $loop->index)show active @endif" id="account_{{ $ao->id }}" role="tabpanel" aria-labelledby="account_{{ $ao->id }}">
|
||||||
<div class="col-12 col-xl-7">
|
|
||||||
@include('service.widget.active')
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-12 col-xl-5">
|
|
||||||
@include('u.invoice.widgets.due')
|
|
||||||
|
|
||||||
@include('u.invoice.widgets.list')
|
|
||||||
|
|
||||||
@include('u.payment.widgets.list')
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{--
|
|
||||||
<!-- @todo this is not working -->
|
|
||||||
<div class="tab-pane" id="tab-nextinvoice">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@include('u.invoice.widgets.next',['future'=>FALSE])
|
<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>
|
||||||
|
<li class="nav-item ml-auto">
|
||||||
|
<a class="nav-link {{ session()->has('supplier_update') ? 'active' : '' }}" href="#tab-supplier" data-toggle="tab">Supplier</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body pl-0 pr-0">
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane {{ (! session()->has('supplier_update')) ? 'active' : '' }}" id="tab-services">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-xl-7">
|
||||||
|
@include('service.widget.active',['o'=>$ao])
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 col-xl-5">
|
||||||
|
@include('invoice.widget.due',['o'=>$ao])
|
||||||
|
|
||||||
|
@include('invoice.widget.list',['o'=>$ao])
|
||||||
|
|
||||||
|
@include('payment.widget.list',['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('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">
|
||||||
|
@include('invoice.widget.next',['future'=>TRUE])
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@canany('reseller','wholesaler')
|
||||||
|
<div class="tab-pane {{ session()->pull('supplier_update') ? 'active' : '' }}" id="tab-supplier" role="tabpanel">
|
||||||
|
@include('user.widget.supplier')
|
||||||
|
</div>
|
||||||
|
@endcanany
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
--}}
|
@endforeach
|
||||||
|
|
||||||
<div class="tab-pane" id="tab-futureinvoice">
|
@if ($o == $user)
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-xl-9">
|
|
||||||
@include('u.invoice.widgets.next',['future'=>TRUE])
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if ($o == $user)
|
|
||||||
@canany('reseller','wholesaler')
|
|
||||||
<div class="tab-pane" id="tab-reseller">
|
|
||||||
@include('r.home.widgets.home')
|
|
||||||
</div>
|
|
||||||
@endcanany
|
|
||||||
@endif
|
|
||||||
@canany('reseller','wholesaler')
|
@canany('reseller','wholesaler')
|
||||||
<div class="tab-pane {{ session()->pull('supplier_update') ? 'active' : '' }}" id="tab-supplier">
|
<div class="tab-pane" id="tab-reseller" role="tabpanel">
|
||||||
@include('user.widget.supplier')
|
@include('r.home.widgets.home')
|
||||||
</div>
|
</div>
|
||||||
@endcanany
|
@endcanany
|
||||||
</div>
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<!-- $o = Account::class -->
|
||||||
<!-- Show outstanding invoices -->
|
<!-- Show outstanding invoices -->
|
||||||
<div class="card card-warning">
|
<div class="card card-warning">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
@ -5,16 +6,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if(($x=$o->invoices()->with(['items.taxes','paymentitems.payment','account'])->get()->where('due','>',0))->count())
|
@if(($x=$o->invoices->where('due','>',0))->count())
|
||||||
<table class="table table-bordered w-100" id="invoices_due">
|
<table class="table table-bordered w-100" id="invoices_due_{{ $o->id }}">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Account</th>
|
<th>Account</th>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>Issued</th>
|
|
||||||
<th>Due</th>
|
<th>Due</th>
|
||||||
<th class="text-right">Total</th>
|
<th class="text-right">Total</th>
|
||||||
<th class="text-right">Payments</th>
|
|
||||||
<th class="text-right">Outstanding</th>
|
<th class="text-right">Outstanding</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -23,11 +22,9 @@
|
|||||||
@foreach ($x as $oo)
|
@foreach ($x as $oo)
|
||||||
<tr @if ($oo->due_at->isPast()) class="table-danger" @endif>
|
<tr @if ($oo->due_at->isPast()) class="table-danger" @endif>
|
||||||
<td>{{ $oo->account->name }}</td>
|
<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->due_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->total,2) }}</td>
|
||||||
<td class="text-right">${{ number_format($oo->paid,2) }}</td>
|
|
||||||
<td class="text-right">${{ number_format($oo->due,2) }}</td>
|
<td class="text-right">${{ number_format($oo->due,2) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
@ -45,23 +42,21 @@
|
|||||||
@js(datatables,bootstrap4|rowgroup)
|
@js(datatables,bootstrap4|rowgroup)
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
@if ($x->count())
|
||||||
$('#invoices_due').DataTable({
|
$(document).ready(function() {
|
||||||
order: [[0,'asc'],[3,'desc']],
|
$('#invoices_due_{{ $o->id }}').DataTable({
|
||||||
rowGroup: {
|
order: [[0,'asc'],[3,'desc']],
|
||||||
dataSrc: 0,
|
rowGroup: {
|
||||||
},
|
dataSrc: 0,
|
||||||
columnDefs: [
|
},
|
||||||
{
|
columnDefs: [
|
||||||
targets: [0],
|
{
|
||||||
visible: false,
|
targets: [0],
|
||||||
}
|
visible: false,
|
||||||
],
|
}
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@endif
|
||||||
$('#invoices_due tbody').on('click','tr', function () {
|
|
||||||
$(this).toggleClass('selected');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
@append
|
@append
|
@ -1,18 +1,18 @@
|
|||||||
|
<!-- $o = Account::class -->
|
||||||
<!-- Show past 12 months invoices -->
|
<!-- Show past 12 months invoices -->
|
||||||
<div class="card card-dark">
|
<div class="card card-success">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title">Past Invoices</h3>
|
<h3 class="card-title">Past Invoices</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if(($x=$o->invoices()->where('invoices.created_at','>',\Carbon\Carbon::now()->subMonths(12))->with(['items.taxes','paymentitems.payment','account.country.currency'])->get()->where('due','<=',0))->count())
|
@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">
|
<table class="table table-bordered w-100" id="invoices_past_{{ $o->id }}">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Account</th>
|
<th>Account</th>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>Issued</th>
|
<th>Issued</th>
|
||||||
<th>Due</th>
|
|
||||||
<th>Paid</th>
|
<th>Paid</th>
|
||||||
<th class="text-right">Total</th>
|
<th class="text-right">Total</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -24,7 +24,6 @@
|
|||||||
<td>{{ $oo->account->name }}</td>
|
<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->sid }}</a></td>
|
||||||
<td>{{ $oo->created_at->format('Y-m-d') }}</td>
|
<td>{{ $oo->created_at->format('Y-m-d') }}</td>
|
||||||
<td>{{ $oo->due_at->format('Y-m-d') }}</td>
|
|
||||||
<td>{{ $oo->paid_date ? $oo->paid_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>
|
<td class="text-right">${{ number_format($oo->total,2) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -43,23 +42,21 @@
|
|||||||
@js(datatables,bootstrap4|rowgroup)
|
@js(datatables,bootstrap4|rowgroup)
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
@if ($x->count())
|
||||||
$('#invoices_past').DataTable({
|
$(document).ready(function() {
|
||||||
order: [[3,'desc'],[0,'asc']],
|
$('#invoices_past_{{ $o->id }}').DataTable({
|
||||||
rowGroup: {
|
order: [[2,'desc'],[0,'asc']],
|
||||||
dataSrc: 0,
|
rowGroup: {
|
||||||
},
|
dataSrc: 0,
|
||||||
columnDefs: [
|
},
|
||||||
{
|
columnDefs: [
|
||||||
targets: [0],
|
{
|
||||||
visible: false,
|
targets: [0],
|
||||||
}
|
visible: false,
|
||||||
],
|
}
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@endif
|
||||||
$('#invoices_past tbody').on('click','tr', function () {
|
|
||||||
$(this).toggleClass('selected');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
@append
|
@append
|
@ -1,3 +1,4 @@
|
|||||||
|
<!-- @todo These needs to be optimised, and change for $o = Account::class -->
|
||||||
<!-- Show next items for an invoice -->
|
<!-- Show next items for an invoice -->
|
||||||
@if ($o->next_invoice_items($future)->count())
|
@if ($o->next_invoice_items($future)->count())
|
||||||
<div class="card">
|
<div class="card">
|
@ -1,11 +1,12 @@
|
|||||||
|
<!-- $o = Account::class -->
|
||||||
<!-- Show past 12 months payments -->
|
<!-- Show past 12 months payments -->
|
||||||
<div class="card card-dark">
|
<div class="card card-success">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title">Past Payments</h3>
|
<h3 class="card-title">Past Payments</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if(($x=$o->payments()->active()->where('payments.created_at','>',\Carbon\Carbon::now()->subMonths(12)->unix())->with(['items','account'])->get())->count())
|
@if(($x=$o->payments->where('created_at','>',\Carbon\Carbon::now()->subMonths(12)))->count())
|
||||||
<table class="table table-bordered w-100" id="payments_past">
|
<table class="table table-bordered w-100" id="payments_past">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -22,7 +23,7 @@
|
|||||||
@foreach ($x as $oo)
|
@foreach ($x as $oo)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $oo->account->name }}</td>
|
<td>{{ $oo->account->name }}</td>
|
||||||
<td>{{ $oo->sid }}</td>
|
<td>{{ $oo->lid }}</td>
|
||||||
<td>{{ $oo->paid_at->format('Y-m-d') }}</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->total,2) }}</td>
|
||||||
{{--<td class="text-right">${{ number_format($oo->balance,2) }}</td>--}}
|
{{--<td class="text-right">${{ number_format($oo->balance,2) }}</td>--}}
|
@ -52,11 +52,7 @@
|
|||||||
color: #4c110f;
|
color: #4c110f;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<style>
|
|
||||||
.strike {
|
|
||||||
text-decoration: line-through;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@if(count($o->services))
|
@if(count($o->services))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $o = User::class -->
|
<!-- $o = Account::class -->
|
||||||
<!-- Show active services -->
|
<!-- Show active services -->
|
||||||
<div class="card card-light">
|
<div class="card card-light">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
@ -6,8 +6,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if ($o->services->count())
|
@if (($x=$o->services->where('active',TRUE))->count())
|
||||||
<table class="table table-striped table-hover w-100" id="services_active">
|
<table class="table table-striped table-hover w-100" id="services_active_{{ $ao->id }}">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
@ -19,19 +19,19 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($o->services as $oo)
|
@foreach ($x as $so)
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ url('u/service',[$oo->id]) }}">{{ $oo->sid }}</a></td>
|
<td><a href="{{ url('u/service',[$so->id]) }}">{{ $so->sid }}</a></td>
|
||||||
<td>{{ $oo->product->category_name }}</td>
|
<td>{{ $so->product->category_name }}</td>
|
||||||
<td>{{ $oo->name_short }}</td>
|
<td>{{ $so->name_short }}</td>
|
||||||
<td>{{ $oo->product->name }}</td>
|
<td>{{ $so->product->name }}</td>
|
||||||
<td>{{ $oo->external_billing ? '-' : $oo->invoice_next->format('Y-m-d') }}</td>
|
<td>{{ $so->external_billing ? '-' : $so->invoice_next->format('Y-m-d') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Count {{ $o->services->count() }}</th>
|
<th>Count {{ $x->count() }}</th>
|
||||||
<th colspan="4"> </th>
|
<th colspan="4"> </th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
@ -47,19 +47,9 @@
|
|||||||
@css(datatables,bootstrap4|rowgroup)
|
@css(datatables,bootstrap4|rowgroup)
|
||||||
@js(datatables,bootstrap4|rowgroup)
|
@js(datatables,bootstrap4|rowgroup)
|
||||||
|
|
||||||
<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">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#services_active').DataTable({
|
$('#services_active_{{ $ao->id }}').DataTable({
|
||||||
order: [[1,'asc'],[2,'asc']],
|
order: [[1,'asc'],[2,'asc']],
|
||||||
rowGroup: {
|
rowGroup: {
|
||||||
dataSrc: 1,
|
dataSrc: 1,
|
||||||
@ -75,7 +65,7 @@
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#services_active tbody').on('click','tr', function () {
|
$('#services_active_{{ $ao->id }} tbody').on('click','tr', function () {
|
||||||
$(this).toggleClass('selected');
|
$(this).toggleClass('selected');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user