Added pagination, nicer formatting for requested assets

This commit is contained in:
snipe 2017-11-02 04:17:14 -07:00
parent ba9bb470eb
commit a844d5b018
6 changed files with 200 additions and 101 deletions

View file

@ -74,11 +74,6 @@ class ViewAssetsController extends Controller
return view('account/requestable-assets', compact('user', 'assets', 'models'));
}
public function getRequestedIndex()
{
$requestedItems = CheckoutRequest::with('user', 'requestedItem')->get();
return view('admin/requested-assets', compact('requestedItems'));
}
public function getRequestItem($itemType, $itemId = null)

View file

@ -33,18 +33,27 @@
@if ($assets->count() > 0)
<div class="table-responsive">
<table class="table table-striped">
<table
name="requested-assets"
data-toolbar="#toolbar"
class="table table-striped snipe-table"
id="table"
data-advanced-search="true"
data-id-table="advancedTable"
data-cookie-id-table="requestableAssets">
<thead>
<tr role="row">
<th class="col-md-3" bSortable="true">{{ trans('admin/hardware/table.asset_model') }}</th>
<th class="col-md-1" data-sortable="true">{{ trans('general.image') }}</th>
<th class="col-md-2" data-sortable="true">{{ trans('admin/hardware/table.asset_model') }}</th>
<th class="col-md-2" data-sortable="true">{{ trans('admin/models/table.modelnumber') }}</th>
@if ($snipeSettings->display_asset_name)
<th class="col-md-3" bSortable="true">{{ trans('admin/hardware/form.name') }}</th>
<th class="col-md-2" data-sortable="true">{{ trans('admin/hardware/form.name') }}</th>
@endif
<th class="col-md-3" bSortable="true">{{ trans('admin/hardware/table.serial') }}</th>
<th class="col-md-2" bSortable="true">{{ trans('admin/hardware/table.location') }}</th>
<th class="col-md-2" bSortable="true">{{ trans('admin/hardware/table.status') }}</th>
<th class="col-md-2" bSortable="true">{{ trans('admin/hardware/form.expected_checkin') }}</th>
<th class="col-md-1 actions" bSortable="false">{{ trans('table.actions') }}</th>
<th class="col-md-3" data-sortable="true">{{ trans('admin/hardware/table.serial') }}</th>
<th class="col-md-2" data-sortable="true">{{ trans('admin/hardware/table.location') }}</th>
<th class="col-md-2" data-sortable="true">{{ trans('admin/hardware/table.status') }}</th>
<th class="col-md-2" data-sortable="true">{{ trans('admin/hardware/form.expected_checkin') }}</th>
<th class="col-md-1 actions" data-sortable="false">{{ trans('table.actions') }}</th>
</tr>
</thead>
<tbody>
@ -53,17 +62,30 @@
<tr>
<form action="{{route('account/request-item', ['itemType' => 'asset', 'itemId' => $asset->id])}}" method="POST" accept-charset="utf-8">
{{ csrf_field() }}
<td>{!! $asset->model->present()->nameUrl() !!}</td>
<td>
@if ($asset->getImageUrl())
<a href="{{ $asset->getImageUrl() }}" data-toggle="lightbox" data-type="image">
<img src="{{ $asset->getImageUrl() }}" style="max-height: {{ $snipeSettings->thumbnail_max_h }}px; width: auto;" class="img-responsive">
</a>
@endif
</td>
<td>{{ $asset->model->name }}
</td>
<td>
{{ $asset->model->model_number }}
</td>
@if ($snipeSettings->display_asset_name)
<td>{{ $asset->name }}</td>
@endif
<td><a href="{{ $asset->present()->viewUrl() }}">{{ $asset->serial }}</a></td>
<td>{{ $asset->serial }}</td>
<td>
@if ($asset->location)
{!! $asset->location->present()->nameUrl() !!}
{{ $asset->location->name }}
@endif
</td>
@if ($asset->assigned_to != '' && $asset->assigned_to > 0)
@ -106,13 +128,21 @@
@if ($models->count() > 0)
<h4>Requestable Models</h4>
<table class="table table-striped">
<table
name="requested-assets"
data-toolbar="#toolbar"
class="table table-striped snipe-table"
id="table"
data-advanced-search="true"
data-id-table="advancedTable"
data-cookie-id-table="requestableAssets">
<thead>
<tr role="row">
<th class="col-md-6" bSortable="true">{{ trans('admin/hardware/table.asset_model') }}</th>
<th class="col-md-3" bSortable="true">{{ trans('admin/accessories/general.remaining') }}</th>
<th class="col-md-2" bSortable="true">{{ trans('general.quantity') }}</th>
<th class="col-md-1 actions" bSortable="false">{{ trans('table.actions') }}</th>
<th class="col-md-1" data-sortable="true">{{ trans('general.image') }}</th>
<th class="col-md-6" data-sortable="true">{{ trans('admin/hardware/table.asset_model') }}</th>
<th class="col-md-3" data-sortable="true">{{ trans('admin/accessories/general.remaining') }}</th>
<th class="col-md-2" data-sortable="true">{{ trans('general.quantity') }}</th>
<th class="col-md-1 actions" data-sortable="false">{{ trans('table.actions') }}</th>
</tr>
</thead>
@ -121,9 +151,18 @@
<tr>
<form action="{{route('account/request-item', ['itemType' => 'asset_model', 'itemId' => $requestableModel->id])}}"
method="POST"
accept-charset="utf-8"
>
accept-charset="utf-8">
{{ csrf_field() }}
<td>
@if ($requestableModel->image)
<a href="{{ url('/') }}/uploads/models/{{ $requestableModel->image }}" data-toggle="lightbox" data-type="image">
<img src="{{ url('/') }}/uploads/models/{{ $requestableModel->image }}" style="max-height: {{ $snipeSettings->thumbnail_max_h }}px; width: auto;" class="img-responsive">
</a>
@endif
</td>
<td>{{$requestableModel->name}}</td>
<td>{{$requestableModel->assets->where('requestable', '1')->count()}}</td>
<td><input type="text" name="request-quantity" value=""></td>
@ -158,7 +197,14 @@
@section('moar_scripts')
<script nonce="{{ csrf_token() }}">
@include ('partials.bootstrap-table', [
'exportFile' => 'requested-export',
'search' => true,
'clientSearch' => true,
])
<script nonce="{{ csrf_token() }}">
$( "a[name='Request']").click(function(event) {
// event.preventDefault();
@ -169,3 +215,5 @@
});
</script>
@stop

View file

@ -1,74 +0,0 @@
@extends('layouts/default')
@section('title0')
{{ trans('admin/hardware/general.requested') }}
{{ trans('general.assets') }}
@stop
{{-- Page title --}}
@section('title')
@yield('title0') @parent
@stop
{{-- Page content --}}
@section('content')
<div class="row">
<div class="col-md-12">
@if ($requestedItems->count() > 0)
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr role="row">
<th class="col-md-1">Item Type</th>
<th class="col-md-1">Item Name</th>
<th class="col-md-1" bSortable="true">{{ trans('admin/hardware/table.location') }}</th>
<th class="col-md-1" bSortable="true">{{ trans('admin/hardware/form.expected_checkin') }}</th>
<th class="col-md-1" bSortable="true">Requesting User</th>
<th class="col-md-1">Requested Date</th>
<th class="col-md-1 actions" bSortable="false">{{ trans('table.actions') }}</th>
</tr>
</thead>
<tbody>
@foreach ($requestedItems as $request)
<tr>
<form action="#" method="POST" accept-charset="utf-8">
{{ csrf_field() }}
<td>{{ $request->itemType() }}</td>
<td>{{ $request->name() }}</td>
@if ($request->location())
<td>{{ $request->location()->name }}</td>
@else
<td></td>
@endif
<td>
@if ($request->itemType() == "asset")
{{ $request->itemRequested()->expected_checkin }}
@else
"N/A"
@endif
</td>
<td>{{ $request->requestingUser()->present()->fullName() }}</td>
<td>{{$request->created_at}}</td>
<td>
</td>
</form>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<div class="col-md-12">
<div class="alert alert-info alert-block">
<i class="fa fa-info-circle"></i>
{{ trans('general.no_results') }}
</div>
</div>
@endif
</div> <!-- .col-md-12> -->
</div> <!-- .row -->
@stop

View file

@ -0,0 +1,132 @@
@extends('layouts/default')
@section('title0')
{{ trans('admin/hardware/general.requested') }}
{{ trans('general.assets') }}
@stop
{{-- Page title --}}
@section('title')
@yield('title0') @parent
@stop
{{-- Page content --}}
@section('content')
<div class="row">
<div class="col-md-12">
<div class="box">
<div class="box-body">
{{ Form::open([
'method' => 'POST',
'route' => ['hardware/bulkedit'],
'class' => 'form-inline',
'id' => 'bulkForm']) }}
<div class="row">
<div class="col-md-12">
@if ($requestedItems->count() > 0)
<div class="table-responsive">
<table
name="requested-assets"
data-toolbar="#toolbar"
class="table table-striped snipe-table"
id="table"
data-advanced-search="true"
data-id-table="advancedTable"
data-cookie-id-table="requestedAssets">
<thead>
<tr role="row">
<th class="col-md-1">Image</th>
<th class="col-md-2">Item Name</th>
<th class="col-md-2" data-sortable="true">{{ trans('admin/hardware/table.location') }}</th>
<th class="col-md-2" data-sortable="true">{{ trans('admin/hardware/form.expected_checkin') }}</th>
<th class="col-md-3" data-sortable="true">Requesting User</th>
<th class="col-md-2">Requested Date</th>
<th class="col-md-1"></th>
</tr>
</thead>
<tbody>
@foreach ($requestedItems as $request)
<tr>
{{ csrf_field() }}
<td>
@if ($request->itemType() == "asset")
<a href="{{ $request->requestable->getImageUrl() }}" data-toggle="lightbox" data-type="image"><img src="{{ $request->requestable->getImageUrl() }}" style="max-height: {{ $snipeSettings->thumbnail_max_h }}px; width: auto;" class="img-responsive"></a>
@endif
</td>
<td>
@if ($request->itemType() == "asset")
<a href="{{ url('/') }}/hardware/{{ $request->requestable->id }}">
{{ $request->name() }}
</a>
@elseif ($request->itemType() == "asset_model")
<a href="{{ url('/') }}/models/{{ $request->requestable->id }}">
{{ $request->name() }}
</a>
@endif
</td>
@if ($request->location())
<td>{{ $request->location()->name }}</td>
@else
<td></td>
@endif
<td>
@if ($request->itemType() == "asset")
{{ App\Helpers\Helper::getFormattedDateObject($request->requestable->expected_checkin, 'datetime', false) }}
@endif
</td>
<td>
<a href="{{ url('/') }}/users/{{ $request->requestingUser()->id }}">
{{ $request->requestingUser()->present()->fullName() }}
</a>
</td>
<td>{{ App\Helpers\Helper::getFormattedDateObject($request->created_at, 'datetime', false) }}</td>
<td>
@if ($request->itemType() == "asset")
@if ($request->requestable->assigned_to=='')
<a href="{{ url('/') }}/hardware/{{ $request->requestable->id }}/checkout" class="btn btn-sm bg-maroon" data-tooltip="true" title="Check this item out to a user">{{ trans('general.checkout') }}</a>
@else
<a href="{{ url('/') }}/hardware/{{ $request->requestable->id }}/checkin" class="btn btn-sm bg-purple" data-tooltip="true" title="Check this itemi">{{ trans('general.checkin') }}</a>
@endif
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<div class="col-md-12">
<div class="alert alert-info alert-block">
<i class="fa fa-info-circle"></i>
{{ trans('general.no_results') }}
</div>
</div>
@endif
</div>
</div>
</div>
</div>
</div>
</div> <!-- .col-md-12> -->
</div> <!-- .row -->
@stop
@section('moar_scripts')
@include ('partials.bootstrap-table', [
'exportFile' => 'requested-export',
'search' => true,
'clientSearch' => true,
])
@stop

View file

@ -43,7 +43,7 @@ $('.snipe-table').bootstrapTable('destroy').bootstrapTable({
paginationVAlign: 'both',
sidePagination: 'server',
sidePagination: '{{ (isset($clientSearch)) ? 'client' : 'server' }}',
sortable: true,

View file

@ -187,8 +187,6 @@ Route::group([ 'prefix' => 'admin','middleware' => ['authorize:superuser']], fun
});
Route::get('requests', [ 'as' => 'requests', 'middleware' => 'authorize:admin', 'uses' => 'ViewAssetsController@getRequestedIndex']);
Route::resource('groups', 'GroupsController', [
'middleware' => ['auth'],