Moved out rejected orders

This commit is contained in:
Deon George
2018-11-21 13:46:16 +11:00
parent aeacb726dd
commit 72fcdab84e
8 changed files with 139 additions and 4 deletions

View File

@@ -21,6 +21,11 @@ class ResellerServicesController extends Controller
return ['data'=>Auth::user()->all_clients()->values()];
}
public function service_inactive()
{
return ['data'=>Auth::user()->all_client_service_inactive()->values()];
}
public function service_movements()
{
return ['data'=>Auth::user()->all_client_service_movements()->values()];

View File

@@ -49,6 +49,7 @@ class Service extends Model
private $inactive_status = [
'CANCELLED',
'ORDER-REJECTED',
];
public function account()
@@ -96,6 +97,19 @@ class Service extends Model
return $this->belongsTo(Product::class);
}
/**
* Find inactive services.
*
* @param $query
* @return mixed
*/
public function scopeInActive($query)
{
return $query->where(function () use ($query) {
return $query->where('active',FALSE)->orWhereIn('order_status',$this->inactive_status);
});
}
/**
* Only query active categories
*/
@@ -118,7 +132,8 @@ class Service extends Model
public function getCategoryAttribute()
{
return $this->product->category;
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
return is_object($this->product) ? $this->product->category : 'Unknown Product';
}
public function getNameAttribute()
@@ -136,7 +151,8 @@ class Service extends Model
public function getProductNameAttribute()
{
return $this->product->name($this->account->language);
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
return is_object($this->product) ? $this->product->name($this->account->language) : 'Unknown Product';
}
public function getServiceExpireAttribute()
@@ -197,6 +213,10 @@ class Service extends Model
*/
private function ServicePlugin()
{
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
if (! is_object($this->product))
return NULL;
switch ($this->product->prod_plugin_file)
{
case 'ADSL': return $this->service_adsl;

View File

@@ -246,6 +246,16 @@ class User extends Authenticatable
return $result->flatten();
}
public function all_client_service_inactive()
{
$s = Service::InActive();
$aa = $this->all_accounts()->pluck('id')->unique()->toArray();
return $s->get()->filter(function($item) use ($aa) {
return in_array($item->account_id,$aa);
});
}
public function all_client_service_movements()
{
$s = Service::active()->where('order_status','!=','ACTIVE');