Skip to content

Commit

Permalink
Fixes #1012 - more consistency in manufacturer view
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Nov 4, 2015
1 parent dc64ad5 commit bc8c8e4
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 57 deletions.
4 changes: 2 additions & 2 deletions app/config/version.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
return array (
'app_version' => 'v2.0-388',
'hash_version' => 'v2.0-388-g4b2e7b9',
'app_version' => 'v2.0-391',
'hash_version' => 'v2.0-391-g7e2b418',
);
68 changes: 68 additions & 0 deletions app/controllers/admin/ManufacturersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,72 @@ public function getDatatable()
}



public function getDataView($manufacturerID) {

$manufacturer = Manufacturer::find($manufacturerID);
$manufacturer_assets = $manufacturer->assets;

if (Input::has('search')) {
$manufacturer_assets = $manufacturer_assets->TextSearch(e(Input::get('search')));
}

if (Input::has('offset')) {
$offset = e(Input::get('offset'));
} else {
$offset = 0;
}

if (Input::has('limit')) {
$limit = e(Input::get('limit'));
} else {
$limit = 50;
}

$order = Input::get('order') === 'asc' ? 'asc' : 'desc';

$allowed_columns = ['id','name','serial','asset_tag'];
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
$count = $manufacturer_assets->count();

$rows = array();

foreach ($manufacturer_assets as $asset) {

$actions = '';
if ($asset->deleted_at=='') {
$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>';
} elseif ($asset->deleted_at!='') {
$actions = '<a href="'.route('restore/hardware', $asset->id).'" class="btn btn-warning btn-sm"><i class="fa fa-recycle icon-white"></i></a>';
}

if ($asset->assetstatus) {
if ($asset->assetstatus->deployable != 0) {
if (($asset->assigned_to !='') && ($asset->assigned_to > 0)) {
$inout = '<a href="'.route('checkin/hardware', $asset->id).'" class="btn btn-primary btn-sm">'.Lang::get('general.checkin').'</a>';
} else {
$inout = '<a href="'.route('checkout/hardware', $asset->id).'" class="btn btn-info btn-sm">'.Lang::get('general.checkout').'</a>';
}
}
}

$rows[] = array(
'id' => $asset->id,
'name' => link_to('/hardware/'.$asset->id.'/view', $asset->showAssetName()),
'model' => $asset->model->name,
'asset_tag' => $asset->asset_tag,
'serial' => $asset->serial,
'assigned_to' => ($asset->assigneduser) ? link_to('/admin/users/'.$asset->assigneduser->id.'/view', $asset->assigneduser->fullName()): '',
'change' => $inout,
'actions' => $actions,


);
}

$data = array('total' => $count, 'rows' => $rows);
return $data;
}


}
1 change: 1 addition & 0 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
/*---Manufacturers API---*/
Route::group(array('prefix'=>'manufacturers'), function () {
Route::get('list', array('as'=>'api.manufacturers.list', 'uses'=>'ManufacturersController@getDatatable'));
Route::get('{manufacturerID}/view', array('as'=>'api.manufacturers.view', 'uses'=>'ManufacturersController@getDataView'));
});

/*---Suppliers API---*/
Expand Down
119 changes: 64 additions & 55 deletions app/views/backend/manufacturers/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="{{ route('update/model', $manufacturer->id) }}">@lang('admin/categories/table.edit')</a></li>
<li><a href="{{ route('clone/model', $manufacturer->id) }}">@lang('admin/categories/table.clone')</a></li>
<li><a href="{{ route('create/hardware', $manufacturer->id) }}">@lang('admin/hardware/form.create')</a></li>
<li><a href="{{ route('update/manufacturer', $manufacturer->id) }}">@lang('admin/manufacturers/table.update')</a></li>
<li><a href="{{ route('create/manufacturer') }}">@lang('admin/manufacturers/table.create')</a></li>
</ul>
</div>
<h3>
{{{ $manufacturer->name }}}
@lang('general.manufacturer')
@lang('general.assets')

</h3>
</div>
Expand All @@ -36,57 +35,67 @@
<div class="row profile">
<div class="col-md-12 bio">


<!-- checked out categories table -->
@if (count($manufacturer->assets) > 0)
<table id="example">
<thead>
<tr role="row">
<th class="col-md-3">@lang('general.name')</th>
<th class="col-md-3">@lang('general.asset_tag')</th>
<th class="col-md-3">@lang('general.user')</th>
<th class="col-md-2">@lang('table.actions')</th>
</tr>
</thead>
<tbody>

@foreach ($manufacturer->assets as $modelassets)
<tr>
<td><a href="{{ route('view/hardware', $modelassets->id) }}">{{{ $modelassets->name }}}</a></td>
<td><a href="{{ route('view/hardware', $modelassets->id) }}">{{{ $modelassets->asset_tag }}}</a></td>
<td>
@if ($modelassets->assigneduser)
<a href="{{ route('view/user', $modelassets->assigned_to) }}">
{{{ $modelassets->assigneduser->fullName() }}}
</a>
@endif
</td>
<td>
@if ($modelassets->assigned_to != 0)
<a href="{{ route('checkin/hardware', $modelassets->id) }}" class="btn-flat info">Checkin</a>
@else
<a href="{{ route('checkout/hardware', $modelassets->id) }}" class="btn-flat success">Checkout</a>
@endif
</td>

</tr>
@endforeach


</tbody>
</table>

@else
<div class="col-md-9">
<div class="alert alert-info alert-block">
<i class="fa fa-info-circle"></i>
@lang('general.no_results')
</div>
</div>
@endif

</div>

<table
name="category_assets"
id="table"
data-url="{{ route('api.manufacturers.view', $manufacturer->id) }}"
data-cookie="true"
data-click-to-select="true"
data-cookie-id-table="maufacturerAssetsTableOIUOIUI">
<thead>
<tr>
<th data-searchable="false" data-sortable="false" data-field="id" data-visible="false">@lang('general.id')</th>
<th data-searchable="false" data-sortable="false" data-field="name">@lang('general.name')</th>
<th data-searchable="false" data-sortable="false" data-field="model">@lang('admin/hardware/form.model')</th>
<th data-searchable="false" data-sortable="false" data-field="asset_tag">@lang('general.asset_tag')</th>
<th data-searchable="false" data-sortable="false" data-field="serial">@lang('admin/hardware/form.serial')</th>
<th data-searchable="false" data-sortable="false" data-field="assigned_to">@lang('general.user')</th>
<th data-searchable="false" data-sortable="false" data-field="change" data-switchable="false">@lang('admin/hardware/table.change')</th>
<th data-searchable="false" data-sortable="false" data-field="actions" data-switchable="false">@lang('table.actions')</th>
</tr>
</thead>
</table>

@section('moar_scripts')
<script src="{{ asset('assets/js/bootstrap-table.js') }}"></script>
<script src="{{ asset('assets/js/extensions/cookie/bootstrap-table-cookie.js') }}"></script>
<script src="{{ asset('assets/js/extensions/mobile/bootstrap-table-mobile.js') }}"></script>
<script src="{{ asset('assets/js/extensions/export/bootstrap-table-export.js') }}"></script>
<script src="{{ asset('assets/js/extensions/export/tableExport.js') }}"></script>
<script src="{{ asset('assets/js/extensions/export/jquery.base64.js') }}"></script>
<script type="text/javascript">
$('#table').bootstrapTable({
classes: 'table table-responsive table-no-bordered',
undefinedText: '',
iconsPrefix: 'fa',
showRefresh: true,
//search: true,
pageSize: {{{ Setting::getSettings()->per_page }}},
pagination: true,
sidePagination: 'server',
sortable: true,
cookie: true,
mobileResponsive: true,
showExport: true,
showColumns: true,
exportDataType: 'all',
exportTypes: ['csv', 'txt','json', 'xml'],
maintainSelected: true,
paginationFirstText: "@lang('general.first')",
paginationLastText: "@lang('general.last')",
paginationPreText: "@lang('general.previous')",
paginationNextText: "@lang('general.next')",
pageList: ['10','25','50','100','150','200'],
icons: {
paginationSwitchDown: 'fa-caret-square-o-down',
paginationSwitchUp: 'fa-caret-square-o-up',
columns: 'fa-columns',
refresh: 'fa-refresh'
},
});
</script>
@stop


@stop

0 comments on commit bc8c8e4

Please sign in to comment.