diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 4f1716bd58..707668d6d6 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -244,6 +244,8 @@ class AssetsController extends Controller break; case 'location': $assets->OrderLocation($order); + case 'rtd_location': + $assets->OrderRtdLocation($order); break; case 'status_label': $assets->OrderStatus($order); diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 834aa91db7..c8ce28f0c8 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -624,7 +624,7 @@ class ReportsController extends Controller } if ($request->has('category')) { - $row[] = ($asset->model->category) ? $asset->model->category->name : ''; + $row[] = (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : ''; } if ($request->has('manufacturer')) { diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 1c6ad8fcb8..56fd9fc605 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -1162,6 +1162,18 @@ class Asset extends Depreciable return $query->leftJoin('locations as asset_locations', 'asset_locations.id', '=', 'assets.location_id')->orderBy('asset_locations.name', $order); } + /** + * Query builder scope to order on default + * @param \Illuminate\Database\Query\Builder $query Query builder instance + * @param text $order Order + * + * @return \Illuminate\Database\Query\Builder Modified query builder + */ + public function scopeOrderRtdLocation($query, $order) + { + return $query->leftJoin('locations as rtd_asset_locations', 'rtd_asset_locations.id', '=', 'assets.rtd_location_id')->orderBy('rtd_asset_locations.name', $order); + } + /** * Query builder scope to order on supplier name diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index b8ca796d28..b011ee15f1 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -113,7 +113,14 @@ class AssetPresenter extends Presenter "title" => trans('admin/hardware/table.location'), "visible" => true, "formatter" => "deployedLocationFormatter" - ], [ + ], [ + "field" => "rtd_location", + "searchable" => true, + "sortable" => true, + "title" => trans('admin/hardware/form.default_location'), + "visible" => false, + "formatter" => "deployedLocationFormatter" + ], [ "field" => "manufacturer", "searchable" => true, "sortable" => true, diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index 4133187e51..412cd6c521 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -80,6 +80,7 @@ id="table" data-advanced-search="true" data-show-export="true" + data-cookie="true" data-id-table="advancedTable" data-url="{{ route('api.assets.index', array('status' => e(Input::get('status')),