Fixed #4774 - show assets assigned to assets in asset view

Todo: Fix text search on the asset to asset tab. It’s currently broken so I’ve disabled it.
This commit is contained in:
snipe 2018-01-10 05:44:11 -08:00
parent eeb3d1eb42
commit e6259eb6e1
2 changed files with 50 additions and 3 deletions

View file

@ -122,6 +122,11 @@ class AssetsController extends Controller
$assets->where('assets.supplier_id', '=', $request->input('supplier_id'));
}
if (($request->has('assigned_to')) && ($request->has('assigned_type'))) {
$assets->where('assets.assigned_to', '=', $request->input('assigned_to'))
->where('assets.assigned_type', '=', $request->input('assigned_type'));
}
if ($request->has('company_id')) {
$assets->where('assets.company_id', '=', $request->input('company_id'));
}
@ -243,7 +248,8 @@ class AssetsController extends Controller
$assets->orderBy($column_sort, $order);
break;
}
$total = $assets->count();
$assets = $assets->skip($offset)->take($limit)->get();
return (new AssetsTransformer)->transformAssets($assets, $total);

View file

@ -534,6 +534,47 @@
</div>
</div> <!-- /.tab-pane components -->
<div class="tab-pane fade" id="assets">
<div class="row">
<div class="col-md-12">
{{ Form::open([
'method' => 'POST',
'route' => ['hardware/bulkedit'],
'class' => 'form-inline',
'id' => 'bulkForm']) }}
<div id="toolbar">
<select name="bulk_actions" class="form-control select2" style="300px;">
<option value="edit">Edit</option>
<option value="delete">Delete</option>
<option value="labels">Generate Labels</option>
</select>
<button class="btn btn-primary" id="bulkEdit" disabled>Go</button>
</div>
<!-- checked out assets table -->
<div class="table-responsive">
<table
name="assetAssets"
data-toolbar="#toolbar"
class="table table-striped snipe-table"
id="assetAssets"
data-search="false"
data-url="{{route('api.assets.index',['assigned_to' => $asset->id, 'assigned_type' => 'App\Models\Asset']) }}"
data-export-options='{"fileName": "asset-assets"}'
data-cookie="true"
data-show-footer="true"
data-cookie-id-table="assetAssetsTable"
data-columns="{{ \App\Presenters\AssetPresenter::dataTableLayout() }}">
</table>
{{ Form::close() }}
</div>
</div><!-- /col -->
</div> <!-- row -->
</div> <!-- /.tab-pane software -->
<div class="tab-pane fade" id="maintenances">
<div class="row">
<div class="col-md-12">
@ -619,7 +660,7 @@
<div class="row">
<div class="col-md-12">
<table
name="asset-histor"
name="asset-history"
id="asset-history"
class="table table-striped snipe-table"
data-cookie="true"
@ -740,7 +781,7 @@
@stop
@section('moar_scripts')
@include ('partials.bootstrap-table', ['simple_view' => true])
@include ('partials.bootstrap-table')
<script nonce="{{ csrf_token() }}">
$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {