diff --git a/app/controllers/admin/CategoriesController.php b/app/controllers/admin/CategoriesController.php index d46c18365c..28e19e2687 100755 --- a/app/controllers/admin/CategoriesController.php +++ b/app/controllers/admin/CategoriesController.php @@ -22,11 +22,8 @@ class CategoriesController extends AdminController public function getIndex() { - // Grab all the categories - $categories = Category::orderBy('created_at', 'DESC')->get(); - // Show the page - return View::make('backend/categories/index', compact('categories')); + return View::make('backend/categories/index'); } @@ -215,7 +212,34 @@ class CategoriesController extends AdminController } + public function getDatatable() + { + // Grab all the categories + $categories = Category::orderBy('created_at', 'DESC')->get(); + $actions = new \Chumper\Datatable\Columns\FunctionColumn('actions', function($categories) { + return ''; + }); + + return Datatable::collection($categories) + ->showColumns('name') + ->addColumn('category_type', function($categories) { + return ucwords($categories->category_type); + }) + ->addColumn('count', function($categories) { + return ($categories->category_type=='asset') ? link_to('/admin/settings/categories/'.$categories->id.'/view', $categories->assetscount()) : $categories->accessoriescount(); + }) + ->addColumn('acceptance', function($categories) { + return ($categories->require_acceptance=='1') ? '' : ''; + }) + ->addColumn('eula', function($categories) { + return ($categories->getEula()) ? '' : ''; + }) + ->addColumn($actions) + ->searchColumns('name','category_type','count','acceptance','eula','actions') + ->orderColumns('name','category_type','count','acceptance','eula','actions') + ->make(); + } } diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 1e548e3ce0..c95f923157 100755 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -24,16 +24,8 @@ class ModelsController extends AdminController */ public function getIndex() { - // Grab all the models - $models = Model::orderBy('created_at', 'DESC'); - if (Input::get('Deleted')) { - $models->withTrashed()->Deleted(); - } - - $models = $models->with('category','assets','depreciation')->get(); - // Show the page - return View::make('backend/models/index', compact('models')); + return View::make('backend/models/index'); } /** @@ -315,6 +307,42 @@ class ModelsController extends AdminController return $view; } + + public function getDatatable($status = null) + { + $models = Model::orderBy('created_at', 'DESC')->with('category','assets','depreciation'); + ($status != 'Deleted') ?: $models->withTrashed()->Deleted();; + $models = $models->get(); + $actions = new \Chumper\Datatable\Columns\FunctionColumn('actions', function($models) { + if($models->deleted_at=='') { + return ''; + } else { + return ''; + } + }); + + return Datatable::collection($models) + ->addColumn('name', function ($models) { + return link_to('/hardware/models/'.$models->id.'/view', $models->name); + }) + ->showColumns('modelno') + ->addColumn('asset_count', function($models) { + return $models->assets->count(); + }) + ->addColumn('depreciation', function($models) { + return (($models->depreciation)&&($models->depreciation->id > 0)) ? $models->depreciation->name.' ('.$models->depreciation->months.')' : Lang::get('general.no_depreciation'); + }) + ->addColumn('category', function($models) { + return ($models->category) ? $models->category->name : ''; + }) + ->addColumn('eol', function($models) { + return ($models->eol) ? $models->eol.' '.Lang::get('general.months') : ''; + }) + ->addColumn($actions) + ->searchColumns('name','modelno','asset_count','depreciation','category','eol','actions') + ->orderColumns('name','modelno','asset_count','depreciation','category','eol','actions') + ->make(); + } } diff --git a/app/routes.php b/app/routes.php index 691faf1924..613c2ea507 100755 --- a/app/routes.php +++ b/app/routes.php @@ -25,6 +25,16 @@ Route::group(array('prefix' => 'api', 'namespace' => 'Controllers\Admin', 'befor Route::resource('/', 'LicensesController'); Route::get('list', array('as'=>'api.licenses.list', 'uses'=>'LicensesController@getDatatable')); }); + /*---Models API---*/ + Route::group(array('prefix'=>'models'), function() { + Route::resource('/', 'ModelsController'); + Route::get('list/{status?}', array('as'=>'api.models.list', 'uses'=>'ModelsController@getDatatable')); + }); + /*--- Categories API---*/ + Route::group(array('prefix'=>'categories'), function() { + Route::resource('/', 'CategoriesController'); + Route::get('list', array('as'=>'api.categories.list', 'uses'=>'CategoriesController@getDatatable')); + }); }); /* diff --git a/app/views/backend/categories/index.blade.php b/app/views/backend/categories/index.blade.php index f14f64dfa8..367be2d92c 100755 --- a/app/views/backend/categories/index.blade.php +++ b/app/views/backend/categories/index.blade.php @@ -17,59 +17,58 @@
@stop diff --git a/app/views/backend/models/index.blade.php b/app/views/backend/models/index.blade.php index d7f78631da..d73c603686 100755 --- a/app/views/backend/models/index.blade.php +++ b/app/views/backend/models/index.blade.php @@ -12,73 +12,56 @@| @lang('admin/models/table.title') | -@lang('admin/models/table.modelnumber') | -@lang('admin/models/table.numassets') | -@lang('general.depreciation') | -@lang('general.category') | -@lang('general.eol') | -@lang('table.actions') | -
|---|---|---|---|---|---|---|
| {{{ $model->name }}} | -{{{ $model->modelno }}} | -{{ ($model->assets->count()) }} | -- - @if (($model->depreciation) && ($model->depreciation->id > 0)) {{{ $model->depreciation->name }}} - ({{{ $model->depreciation->months }}} - @lang('general.months') - ) - @else - @lang('general.no_depreciation') - @endif - - | -- @if ($model->category) {{{ $model->category->name }}} - @endif - | - -- - @if ($model->eol) {{{ $model->eol }}} - @lang('general.months') - @else - -- - @endif - - | - -- @if($model->deleted_at=="") - - - @else - - @endif - | -