diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index c1501e216a..8d1fe7b335 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -86,16 +86,16 @@ class AssetsController extends Controller $assets = Company::scopeCompanyables(Asset::select('assets.*'))->with( 'assetloc', 'assetstatus', 'defaultLoc', 'assetlog', 'company', 'model.category', 'model.manufacturer', 'model.fieldset','supplier'); - // If we should search on everything - if (($request->has('search')) && (count($filter) == 0)) { + + + if (count($filter) > 0) { + $assets->ByFilter($filter); + } elseif ($request->has('search')) { $assets->TextSearch($request->input('search')); - // otherwise loop through the filters and search strictly on them - } else { - if (count($filter) > 0) { - $assets->ByFilter($filter); - } } + + // These are used by the API to query against specific ID numbers if ($request->has('status_id')) { $assets->where('status_id', '=', $request->input('status_id')); diff --git a/app/Http/Controllers/ConsumablesController.php b/app/Http/Controllers/ConsumablesController.php index c7c920897b..ccc8a2e979 100644 --- a/app/Http/Controllers/ConsumablesController.php +++ b/app/Http/Controllers/ConsumablesController.php @@ -194,7 +194,7 @@ class ConsumablesController extends Controller if (isset($consumable->id)) { return view('consumables/view', compact('consumable')); } - return redirect()->route('consumables')->with('error', trans('admin/consumables/message.does_not_exist', compact('id'))); + return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.does_not_exist', compact('id'))); } /** diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index 1b53d61aa8..92ba702a15 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -54,9 +54,9 @@ class AssetsTransformer 'id' => (int) $asset->company->id, 'name'=> e($asset->company->name) ] : null, - 'location' => ($asset->assetloc) ? [ - 'id' => (int) $asset->assetloc->id, - 'name'=> e($asset->assetloc->name) + 'location' => ($asset->assetLoc) ? [ + 'id' => (int) $asset->assetLoc->id, + 'name'=> e($asset->assetLoc->name) ] : null, 'rtd_location' => ($asset->defaultLoc) ? [ 'id' => (int) $asset->defaultLoc->id, diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 889396928a..1ab2f41a76 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -812,48 +812,50 @@ class Asset extends Depreciable { return $query->where(function ($query) use ($filter) { foreach ($filter as $key => $search_val) { - - if ($key =='asset_tag') { + + $fieldname = str_replace('custom_fields.','', $key) ; + + if ($fieldname =='asset_tag') { $query->where('assets.asset_tag', 'LIKE', '%'.$search_val.'%'); } - if ($key =='name') { + if ($fieldname =='name') { $query->where('assets.name', 'LIKE', '%'.$search_val.'%'); } - if ($key =='product_key') { + if ($fieldname =='product_key') { $query->where('assets.serial', 'LIKE', '%'.$search_val.'%'); } - if ($key =='purchase_date') { + if ($fieldname =='purchase_date') { $query->where('assets.purchase_date', 'LIKE', '%'.$search_val.'%'); } - if ($key =='purchase_cost') { + if ($fieldname =='purchase_cost') { $query->where('assets.purchase_cost', 'LIKE', '%'.$search_val.'%'); } - if ($key =='notes') { + if ($fieldname =='notes') { $query->where('assets.notes', 'LIKE', '%'.$search_val.'%'); } - if ($key =='order_number') { + if ($fieldname =='order_number') { $query->where('assets.order_number', 'LIKE', '%'.$search_val.'%'); } - if ($key =='status_label') { + if ($fieldname =='status_label') { $query->whereHas('assetstatus', function ($query) use ($search_val) { $query->where('status_labels.name', 'LIKE', '%' . $search_val . '%'); }); } - if ($key =='location') { + if ($fieldname =='location') { $query->whereHas('defaultLoc', function ($query) use ($search_val) { $query->where('locations.name', 'LIKE', '%' . $search_val . '%'); }); } - if ($key =='checkedout_to') { + if ($fieldname =='checkedout_to') { $query->whereHas('assigneduser', function ($query) use ($search_val) { $query->where(function ($query) use ($search_val) { $query->where('users.first_name', 'LIKE', '%' . $search_val . '%') @@ -863,7 +865,7 @@ class Asset extends Depreciable } - if ($key =='manufacturer') { + if ($fieldname =='manufacturer') { $query->whereHas('model', function ($query) use ($search_val) { $query->whereHas('manufacturer', function ($query) use ($search_val) { $query->where(function ($query) use ($search_val) { @@ -873,7 +875,7 @@ class Asset extends Depreciable }); } - if ($key =='category') { + if ($fieldname =='category') { $query->whereHas('model', function ($query) use ($search_val) { $query->whereHas('category', function ($query) use ($search_val) { $query->where(function ($query) use ($search_val) { @@ -885,7 +887,7 @@ class Asset extends Depreciable }); } - if ($key =='model') { + if ($fieldname =='model') { $query->where(function ($query) use ($search_val) { $query->whereHas('model', function ($query) use ($search_val) { $query->where('models.name', 'LIKE', '%' . $search_val . '%'); @@ -893,7 +895,7 @@ class Asset extends Depreciable }); } - if ($key =='model_number') { + if ($fieldname =='model_number') { $query->where(function ($query) use ($search_val) { $query->whereHas('model', function ($query) use ($search_val) { $query->where('models.model_number', 'LIKE', '%' . $search_val . '%'); @@ -902,7 +904,7 @@ class Asset extends Depreciable } - if ($key =='company') { + if ($fieldname =='company') { $query->where(function ($query) use ($search_val) { $query->whereHas('company', function ($query) use ($search_val) { $query->where('companies.name', 'LIKE', '%' . $search_val . '%'); @@ -911,11 +913,9 @@ class Asset extends Depreciable } } - foreach (CustomField::all() as $field) { - if (array_key_exists('custom_fields.'.$field->db_column_name(), $filter)) { - $query->orWhere($field->db_column_name(), 'LIKE', '%' . $search_val . '%'); - } - } + + $query->orWhere($fieldname, 'LIKE', '%' . $search_val . '%'); + }); diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index ba030b05cd..42d4e92b1d 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -112,7 +112,7 @@ class AssetPresenter extends Presenter "sortable" => true, "title" => trans('admin/hardware/table.location'), "visible" => true, - "formatter" => "locationsLinkObjFormatter" + "formatter" => "deployedLocationFormatter" ], [ "field" => "manufacturer", "searchable" => true, diff --git a/resources/macros/macros.php b/resources/macros/macros.php index e7a15d377a..90c6b0805e 100644 --- a/resources/macros/macros.php +++ b/resources/macros/macros.php @@ -362,6 +362,7 @@ Form::macro('date_display_format', function ($name = "date_display_format", $sel 'm/d/Y', 'n/d/y', 'm/j/Y', + 'd.m.Y', ]; foreach ($formats as $format) { diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 5fc9350564..e6d4316f4f 100755 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -4,9 +4,13 @@ {{-- Page content --}} @section('content') -