Skip to content

Commit bc8c8e4

Browse files
committed
Fixes #1012 - more consistency in manufacturer view
1 parent dc64ad5 commit bc8c8e4

File tree

4 files changed

+135
-57
lines changed

4 files changed

+135
-57
lines changed

app/config/version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22
return array (
3-
'app_version' => 'v2.0-388',
4-
'hash_version' => 'v2.0-388-g4b2e7b9',
3+
'app_version' => 'v2.0-391',
4+
'hash_version' => 'v2.0-391-g7e2b418',
55
);

app/controllers/admin/ManufacturersController.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,72 @@ public function getDatatable()
239239
}
240240

241241

242+
243+
public function getDataView($manufacturerID) {
244+
245+
$manufacturer = Manufacturer::find($manufacturerID);
246+
$manufacturer_assets = $manufacturer->assets;
247+
248+
if (Input::has('search')) {
249+
$manufacturer_assets = $manufacturer_assets->TextSearch(e(Input::get('search')));
250+
}
251+
252+
if (Input::has('offset')) {
253+
$offset = e(Input::get('offset'));
254+
} else {
255+
$offset = 0;
256+
}
257+
258+
if (Input::has('limit')) {
259+
$limit = e(Input::get('limit'));
260+
} else {
261+
$limit = 50;
262+
}
263+
264+
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
265+
266+
$allowed_columns = ['id','name','serial','asset_tag'];
267+
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
268+
$count = $manufacturer_assets->count();
269+
270+
$rows = array();
271+
272+
foreach ($manufacturer_assets as $asset) {
273+
274+
$actions = '';
275+
if ($asset->deleted_at=='') {
276+
$actions = '<div style=" white-space: nowrap;"><a href="'.route('clone/hardware', $asset->id).'" class="btn btn-info btn-sm" title="Clone asset"><i class="fa fa-files-o"></i></a> <a href="'.route('update/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/hardware', $asset->id).'" data-content="'.Lang::get('admin/hardware/message.delete.confirm').'" data-title="'.Lang::get('general.delete').' '.htmlspecialchars($asset->asset_tag).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>';
277+
} elseif ($asset->deleted_at!='') {
278+
$actions = '<a href="'.route('restore/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
279+
}
280+
281+
if ($asset->assetstatus) {
282+
if ($asset->assetstatus->deployable != 0) {
283+
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
284+
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.Lang::get('general.checkin').'</a>';
285+
} else {
286+
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.Lang::get('general.checkout').'</a>';
287+
}
288+
}
289+
}
290+
291+
$rows[] = array(
292+
'id' => $asset->id,
293+
'name' => link_to('/hardware/'.$asset->id.'/view', $asset->showAssetName()),
294+
'model' => $asset->model->name,
295+
'asset_tag' => $asset->asset_tag,
296+
'serial' => $asset->serial,
297+
'assigned_to' => ($asset->assigneduser) ? link_to('/admin/users/'.$asset->assigneduser->id.'/view', $asset->assigneduser->fullName()): '',
298+
'change' => $inout,
299+
'actions' => $actions,
300+
301+
302+
);
303+
}
304+
305+
$data = array('total' => $count, 'rows' => $rows);
306+
return $data;
307+
}
308+
309+
242310
}

app/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
/*---Manufacturers API---*/
6767
Route::group(array('prefix'=>'manufacturers'), function () {
6868
Route::get('list', array('as'=>'api.manufacturers.list', 'uses'=>'ManufacturersController@getDatatable'));
69+
Route::get('{manufacturerID}/view', array('as'=>'api.manufacturers.view', 'uses'=>'ManufacturersController@getDataView'));
6970
});
7071

7172
/*---Suppliers API---*/

app/views/backend/manufacturers/view.blade.php

Lines changed: 64 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@
1919
<span class="caret"></span>
2020
</button>
2121
<ul class="dropdown-menu">
22-
<li><a href="{{ route('update/model', $manufacturer->id) }}">@lang('admin/categories/table.edit')</a></li>
23-
<li><a href="{{ route('clone/model', $manufacturer->id) }}">@lang('admin/categories/table.clone')</a></li>
24-
<li><a href="{{ route('create/hardware', $manufacturer->id) }}">@lang('admin/hardware/form.create')</a></li>
22+
<li><a href="{{ route('update/manufacturer', $manufacturer->id) }}">@lang('admin/manufacturers/table.update')</a></li>
23+
<li><a href="{{ route('create/manufacturer') }}">@lang('admin/manufacturers/table.create')</a></li>
2524
</ul>
2625
</div>
2726
<h3>
2827
{{{ $manufacturer->name }}}
29-
@lang('general.manufacturer')
28+
@lang('general.assets')
3029

3130
</h3>
3231
</div>
@@ -36,57 +35,67 @@
3635
<div class="row profile">
3736
<div class="col-md-12 bio">
3837

39-
40-
<!-- checked out categories table -->
41-
@if (count($manufacturer->assets) > 0)
42-
<table id="example">
43-
<thead>
44-
<tr role="row">
45-
<th class="col-md-3">@lang('general.name')</th>
46-
<th class="col-md-3">@lang('general.asset_tag')</th>
47-
<th class="col-md-3">@lang('general.user')</th>
48-
<th class="col-md-2">@lang('table.actions')</th>
49-
</tr>
50-
</thead>
51-
<tbody>
52-
53-
@foreach ($manufacturer->assets as $modelassets)
54-
<tr>
55-
<td><a href="{{ route('view/hardware', $modelassets->id) }}">{{{ $modelassets->name }}}</a></td>
56-
<td><a href="{{ route('view/hardware', $modelassets->id) }}">{{{ $modelassets->asset_tag }}}</a></td>
57-
<td>
58-
@if ($modelassets->assigneduser)
59-
<a href="{{ route('view/user', $modelassets->assigned_to) }}">
60-
{{{ $modelassets->assigneduser->fullName() }}}
61-
</a>
62-
@endif
63-
</td>
64-
<td>
65-
@if ($modelassets->assigned_to != 0)
66-
<a href="{{ route('checkin/hardware', $modelassets->id) }}" class="btn-flat info">Checkin</a>
67-
@else
68-
<a href="{{ route('checkout/hardware', $modelassets->id) }}" class="btn-flat success">Checkout</a>
69-
@endif
70-
</td>
71-
72-
</tr>
73-
@endforeach
74-
75-
76-
</tbody>
77-
</table>
78-
79-
@else
80-
<div class="col-md-9">
81-
<div class="alert alert-info alert-block">
82-
<i class="fa fa-info-circle"></i>
83-
@lang('general.no_results')
84-
</div>
85-
</div>
86-
@endif
87-
88-
</div>
89-
38+
<table
39+
name="category_assets"
40+
id="table"
41+
data-url="{{ route('api.manufacturers.view', $manufacturer->id) }}"
42+
data-cookie="true"
43+
data-click-to-select="true"
44+
data-cookie-id-table="maufacturerAssetsTableOIUOIUI">
45+
<thead>
46+
<tr>
47+
<th data-searchable="false" data-sortable="false" data-field="id" data-visible="false">@lang('general.id')</th>
48+
<th data-searchable="false" data-sortable="false" data-field="name">@lang('general.name')</th>
49+
<th data-searchable="false" data-sortable="false" data-field="model">@lang('admin/hardware/form.model')</th>
50+
<th data-searchable="false" data-sortable="false" data-field="asset_tag">@lang('general.asset_tag')</th>
51+
<th data-searchable="false" data-sortable="false" data-field="serial">@lang('admin/hardware/form.serial')</th>
52+
<th data-searchable="false" data-sortable="false" data-field="assigned_to">@lang('general.user')</th>
53+
<th data-searchable="false" data-sortable="false" data-field="change" data-switchable="false">@lang('admin/hardware/table.change')</th>
54+
<th data-searchable="false" data-sortable="false" data-field="actions" data-switchable="false">@lang('table.actions')</th>
55+
</tr>
56+
</thead>
57+
</table>
58+
59+
@section('moar_scripts')
60+
<script src="{{ asset('assets/js/bootstrap-table.js') }}"></script>
61+
<script src="{{ asset('assets/js/extensions/cookie/bootstrap-table-cookie.js') }}"></script>
62+
<script src="{{ asset('assets/js/extensions/mobile/bootstrap-table-mobile.js') }}"></script>
63+
<script src="{{ asset('assets/js/extensions/export/bootstrap-table-export.js') }}"></script>
64+
<script src="{{ asset('assets/js/extensions/export/tableExport.js') }}"></script>
65+
<script src="{{ asset('assets/js/extensions/export/jquery.base64.js') }}"></script>
66+
<script type="text/javascript">
67+
$('#table').bootstrapTable({
68+
classes: 'table table-responsive table-no-bordered',
69+
undefinedText: '',
70+
iconsPrefix: 'fa',
71+
showRefresh: true,
72+
//search: true,
73+
pageSize: {{{ Setting::getSettings()->per_page }}},
74+
pagination: true,
75+
sidePagination: 'server',
76+
sortable: true,
77+
cookie: true,
78+
mobileResponsive: true,
79+
showExport: true,
80+
showColumns: true,
81+
exportDataType: 'all',
82+
exportTypes: ['csv', 'txt','json', 'xml'],
83+
maintainSelected: true,
84+
paginationFirstText: "@lang('general.first')",
85+
paginationLastText: "@lang('general.last')",
86+
paginationPreText: "@lang('general.previous')",
87+
paginationNextText: "@lang('general.next')",
88+
pageList: ['10','25','50','100','150','200'],
89+
icons: {
90+
paginationSwitchDown: 'fa-caret-square-o-down',
91+
paginationSwitchUp: 'fa-caret-square-o-up',
92+
columns: 'fa-columns',
93+
refresh: 'fa-refresh'
94+
},
95+
96+
});
97+
</script>
98+
@stop
9099

91100

92101
@stop

0 commit comments

Comments
 (0)