mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Search by asset tag
Compatible with barcode scanners
This commit is contained in:
parent
b796e72faf
commit
fb35e40342
|
@ -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] [<snipe@snipe.net>]
|
||||
* @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.
|
||||
*
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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>.',
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue