Skip to content

A free open source IT asset/license management system

Search by asset tag

snipefb35e403421b
diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php
index 0ba72db216..9d1805ac4a 100755
--- a/app/Http/Controllers/AssetsController.php
+++ b/app/Http/Controllers/AssetsController.php
@@ -59,7 +59,6 @@ class AssetsController extends Controller
parent::__construct();
}
-
/**
* Returns a view that invokes the ajax tables which actually contains
* the content for the assets listing, which is generated in getDatatable.
@@ -74,6 +73,21 @@ class AssetsController extends Controller
return View::make('hardware/index');
}
+ /**
+ * Searches the assets table by asset tag, and redirects if it finds one
+ *
+ * @author [A. Gianotto] [<[email protected]>]
+ * @since [v3.0]
+ * @return Redirect
+ */
+ public function getAssetByTag() {
+ if ($asset = Asset::where('asset_tag','=',Input::get('assetTag'))->first()) {
+ return redirect()->route('view/hardware', $asset->id);
+ }
+ return redirect()->to('hardware')->with('error',trans('admin/hardware/message.does_not_exist'));
+
+ }
+
/**
* Returns a view that presents a form to create a new asset.
*
diff --git a/app/Http/routes.php b/app/Http/routes.php
index d78adf6808..850eed2d56 100755
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -194,6 +194,10 @@ Route::group(
'as' => 'update/hardware',
'uses' => 'AssetsController@getEdit'
]);
+ Route::get('/bytag', [
+ 'as' => 'findbytag/hardware',
+ 'uses' => 'AssetsController@getAssetByTag'
+ ]);
Route::get('{assetId}/clone', [ 'as' => 'clone/hardware', 'uses' => 'AssetsController@getClone' ]);
Route::post('{assetId}/clone', 'AssetsController@postCreate');
diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php
index cc29171a7f..c8bc49015e 100644
--- a/resources/lang/en/general.php
+++ b/resources/lang/en/general.php
@@ -88,6 +88,7 @@
'location' => 'Location',
'locations' => 'Locations',
'logout' => 'Logout',
+ 'lookup_by_tag' => 'Lookup by Asset Tag',
'manufacturer' => 'Manufacturer',
'manufacturers' => 'Manufacturers',
'markdown' => 'This field allows <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>.',
diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php
index d58a434726..5e93264229 100644
--- a/resources/views/layouts/default.blade.php
+++ b/resources/views/layouts/default.blade.php
@@ -118,6 +118,14 @@
<ul class="nav navbar-nav">
@if (Auth::user()->hasAccess('admin'))
+ <form class="navbar-form navbar-left" role="search" action="{{ route('findbytag/hardware') }}" method="get">
+ <div class="form-group">
+ <input type="text" class="form-control" id="tagSearch" name="assetTag" placeholder="{{ trans('general.lookup_by_tag') }}">
+ <input type="hidden" name="topsearch" value="true">
+ </div>
+ <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
+ </form>
+
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
@lang('general.create')
@@ -540,7 +548,9 @@
@section('moar_scripts')
@show
-
+ <script>
+ // $("#tagSearch").focus();
+ </script>
</body>
</html>