diff --git a/app/Http/Controllers/ResellerServicesController.php b/app/Http/Controllers/ResellerServicesController.php index 0c3e587..c168765 100644 --- a/app/Http/Controllers/ResellerServicesController.php +++ b/app/Http/Controllers/ResellerServicesController.php @@ -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()]; diff --git a/app/Models/Service.php b/app/Models/Service.php index 8c00112..7b526dc 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -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; diff --git a/app/User.php b/app/User.php index 1842ede..cadfa81 100644 --- a/app/User.php +++ b/app/User.php @@ -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'); diff --git a/resources/theme/backend/adminlte/r/home.blade.php b/resources/theme/backend/adminlte/r/home.blade.php index 2f4db2e..761080d 100644 --- a/resources/theme/backend/adminlte/r/home.blade.php +++ b/resources/theme/backend/adminlte/r/home.blade.php @@ -52,6 +52,9 @@
@include('r.agents')
+
+ @include('r.service_inactive') +
{{--
@include('r.clients') diff --git a/resources/theme/backend/adminlte/r/service_inactive.blade.php b/resources/theme/backend/adminlte/r/service_inactive.blade.php new file mode 100644 index 0000000..33abd62 --- /dev/null +++ b/resources/theme/backend/adminlte/r/service_inactive.blade.php @@ -0,0 +1,87 @@ +
+
+

Services Inactive

+
+ + +
+
+ +
+ @if ($user->all_client_service_inactive()->count()) + + + + + + + + + + + + + + + + +
IDAccountNameStatusProduct
Count {{ $user->all_client_service_inactive()->count() }} 
+ @else +

No Inactive Services

+ @endif +
+
+ +@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') + + + +@append \ No newline at end of file diff --git a/resources/theme/backend/adminlte/r/service_movements.blade.php b/resources/theme/backend/adminlte/r/service_movements.blade.php index c59e247..af457fb 100644 --- a/resources/theme/backend/adminlte/r/service_movements.blade.php +++ b/resources/theme/backend/adminlte/r/service_movements.blade.php @@ -66,7 +66,7 @@ { data: "product_name" } ], language: { - emptyTable: "No Active Clients" + emptyTable: "No Service Movements" }, order: [3, 'asc'], rowGroup: { diff --git a/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php b/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php index 53ea7c9..a80c69e 100644 --- a/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php +++ b/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php @@ -2,5 +2,14 @@
  • MENU
  • getName() == 'home')class="active"@endif> {{ trans('adminlte_lang::message.home') }}
  • -
  • getName() == 'order')class="active"@endif> Order
  • +
  • + + Order + + + +
  • \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index ef929e0..a8ac21e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -24,6 +24,7 @@ Route::group(['middleware'=>['auth:api','role:reseller']], function() { 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'); }); Route::group(['middleware'=>'auth:api'], function() {