Changed service movements rendering
This commit is contained in:
parent
4dfa8f1122
commit
3784de855a
@ -25,9 +25,4 @@ class ResellerServicesController extends Controller
|
||||
{
|
||||
return ['data'=>Auth::user()->all_client_service_inactive()->values()];
|
||||
}
|
||||
|
||||
public function service_movements()
|
||||
{
|
||||
return ['data'=>Auth::user()->all_client_service_movements()->values()];
|
||||
}
|
||||
}
|
34
app/User.php
34
app/User.php
@ -104,7 +104,7 @@ class User extends Authenticatable
|
||||
return $this->belongsTo(Models\Language::class);
|
||||
}
|
||||
|
||||
/**b
|
||||
/**
|
||||
* This users invoices
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
@ -313,7 +313,7 @@ class User extends Authenticatable
|
||||
// Build our where clause
|
||||
// First Name, Last name
|
||||
if (preg_match('/\ /',$term)) {
|
||||
list($fn,$ln) = explode(' ',$term,2);
|
||||
[$fn,$ln] = explode(' ',$term,2);
|
||||
|
||||
$query->where(function($query1) use ($fn,$ln,$term) {
|
||||
$query1->where(function($query2) use ($fn,$ln) {
|
||||
@ -417,16 +417,6 @@ class User extends Authenticatable
|
||||
});
|
||||
}
|
||||
|
||||
public function all_client_service_movements()
|
||||
{
|
||||
$s = Service::active()->where('order_status','!=','ACTIVE');
|
||||
$aa = $this->all_accounts()->pluck('id')->unique()->toArray();
|
||||
|
||||
return $s->get()->filter(function($item) use ($aa) {
|
||||
return in_array($item->account_id,$aa);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* List of all this users agents, recursively
|
||||
*
|
||||
@ -452,6 +442,23 @@ class User extends Authenticatable
|
||||
return $result->flatten();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show this user's clients with service movements
|
||||
*
|
||||
* A service movement, is an active service where the status is not ACTIVE
|
||||
*
|
||||
* @return DatabaseCollection
|
||||
*/
|
||||
public function client_service_movements(): DatabaseCollection
|
||||
{
|
||||
return Service::active()
|
||||
->select(['id','account_id','product_id','order_status'])
|
||||
->where('order_status','!=','ACTIVE')
|
||||
->whereIN('account_id',$this->all_accounts()->pluck('id')->unique()->toArray())
|
||||
->with(['account','product'])
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the logged in user is a reseller or wholesaler
|
||||
*
|
||||
@ -475,7 +482,8 @@ class User extends Authenticatable
|
||||
/**
|
||||
* Get all the items for the next invoice
|
||||
*
|
||||
* @return Collection
|
||||
* @param bool $future
|
||||
* @return DatabaseCollection
|
||||
*/
|
||||
public function next_invoice_items(bool $future=FALSE): DatabaseCollection
|
||||
{
|
||||
|
@ -1,3 +1,4 @@
|
||||
<!-- Show client movements -->
|
||||
<div class="card card-warning card-outline">
|
||||
<div class="card-header">
|
||||
<h4 class="card-title">Service Movements</h4>
|
||||
@ -9,7 +10,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if ($user->all_client_service_movements()->count())
|
||||
@if (($x=$user->client_service_movements())->count())
|
||||
<table class="table table-striped table-hover" id="service_movements" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -20,9 +21,20 @@
|
||||
<th>Product</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($x as $o)
|
||||
<tr>
|
||||
<td><a href="{{ url('u/service',$o->id) }}">{{ $o->id }}</a></td>
|
||||
<td>{{ $o->account->name }}</td>
|
||||
<td>{{ $o->name }}</td>
|
||||
<td>{{ $o->status }}</td>
|
||||
<td>{{ $o->product->name }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>Count {{ $user->all_client_service_movements()->count() }}</th>
|
||||
<th>Count {{ $x->count() }}</th>
|
||||
<th colspan="4"> </th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
@ -47,31 +59,11 @@
|
||||
$(document).ready(function() {
|
||||
$('#service_movements').DataTable( {
|
||||
responsive: true,
|
||||
ajax: {
|
||||
url: "/api/r/service_movements"
|
||||
},
|
||||
columns: [
|
||||
{ data:
|
||||
@if($user->isWholesaler())
|
||||
"admin_service_id_url"
|
||||
@else
|
||||
"service_id_url"
|
||||
@endif
|
||||
},
|
||||
{ data: "account_name" },
|
||||
{ data: "name_short" },
|
||||
{ data: "status" },
|
||||
{ data: "product_name" }
|
||||
],
|
||||
language: {
|
||||
emptyTable: "No Service Movements"
|
||||
},
|
||||
order: [3, 'asc'],
|
||||
rowGroup: {
|
||||
dataSrc: 'account_name',
|
||||
startRender: null,
|
||||
endRender: function ( rows, group ) {
|
||||
return rows.count()+' x ' + group;
|
||||
dataSrc: 1,
|
||||
startRender: function ( rows, group ) {
|
||||
return group+': '+rows.count()+' Services';
|
||||
},
|
||||
},
|
||||
orderFixed: [1, 'asc']
|
||||
|
@ -23,7 +23,6 @@ Route::group(['middleware'=>['auth:api','role:reseller']], function() {
|
||||
Route::get('/r/agents','ResellerServicesController@agents');
|
||||
Route::get('/r/accounts','ResellerServicesController@accounts');
|
||||
Route::get('/r/clients','ResellerServicesController@clients');
|
||||
Route::get('/r/service_movements','ResellerServicesController@service_movements');
|
||||
Route::get('/r/service_inactive','ResellerServicesController@service_inactive');
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user