Changed service movements rendering
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
Reference in New Issue
Block a user