From a844d5b0180a714f495ce71b82ac8886d6cee30f Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 2 Nov 2017 04:17:14 -0700 Subject: [PATCH] Added pagination, nicer formatting for requested assets --- app/Http/Controllers/ViewAssetsController.php | 5 - .../account/requestable-assets.blade.php | 86 +++++++++--- .../views/admin/requested-assets.blade.php | 74 ---------- resources/views/hardware/requested.blade.php | 132 ++++++++++++++++++ .../views/partials/bootstrap-table.blade.php | 2 +- routes/web.php | 2 - 6 files changed, 200 insertions(+), 101 deletions(-) delete mode 100644 resources/views/admin/requested-assets.blade.php create mode 100644 resources/views/hardware/requested.blade.php diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.php index d913c216c4..6c112ff657 100755 --- a/app/Http/Controllers/ViewAssetsController.php +++ b/app/Http/Controllers/ViewAssetsController.php @@ -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) diff --git a/resources/views/account/requestable-assets.blade.php b/resources/views/account/requestable-assets.blade.php index af4b71a3a6..5f9ab1be81 100644 --- a/resources/views/account/requestable-assets.blade.php +++ b/resources/views/account/requestable-assets.blade.php @@ -33,18 +33,27 @@ @if ($assets->count() > 0)
- +
- + + + @if ($snipeSettings->display_asset_name) - + @endif - - - - - + + + + + @@ -53,17 +62,30 @@ {{ csrf_field() }} - + + + @if ($snipeSettings->display_asset_name) @endif - + @if ($asset->assigned_to != '' && $asset->assigned_to > 0) @@ -106,13 +128,21 @@ @if ($models->count() > 0)

Requestable Models

-
{{ trans('admin/hardware/table.asset_model') }}{{ trans('general.image') }}{{ trans('admin/hardware/table.asset_model') }}{{ trans('admin/models/table.modelnumber') }}{{ trans('admin/hardware/form.name') }}{{ trans('admin/hardware/form.name') }}{{ trans('admin/hardware/table.serial') }}{{ trans('admin/hardware/table.location') }}{{ trans('admin/hardware/table.status') }}{{ trans('admin/hardware/form.expected_checkin') }}{{ trans('table.actions') }}{{ trans('admin/hardware/table.serial') }}{{ trans('admin/hardware/table.location') }}{{ trans('admin/hardware/table.status') }}{{ trans('admin/hardware/form.expected_checkin') }}{{ trans('table.actions') }}
{!! $asset->model->present()->nameUrl() !!} + @if ($asset->getImageUrl()) + + + + @endif + + {{ $asset->model->name }} + + + {{ $asset->model->model_number }} + {{ $asset->name }}{{ $asset->serial }}{{ $asset->serial }} @if ($asset->location) - {!! $asset->location->present()->nameUrl() !!} + {{ $asset->location->name }} @endif
+
- - - - + + + + + @@ -121,9 +151,18 @@ + accept-charset="utf-8"> {{ csrf_field() }} + + + @@ -158,7 +197,14 @@ @section('moar_scripts') - @stop + + diff --git a/resources/views/admin/requested-assets.blade.php b/resources/views/admin/requested-assets.blade.php deleted file mode 100644 index f8367e4af0..0000000000 --- a/resources/views/admin/requested-assets.blade.php +++ /dev/null @@ -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') - -
-
- - @if ($requestedItems->count() > 0) -
-
{{ trans('admin/hardware/table.asset_model') }}{{ trans('admin/accessories/general.remaining') }}{{ trans('general.quantity') }}{{ trans('table.actions') }}{{ trans('general.image') }}{{ trans('admin/hardware/table.asset_model') }}{{ trans('admin/accessories/general.remaining') }}{{ trans('general.quantity') }}{{ trans('table.actions') }}
+ @if ($requestableModel->image) + + + + @endif + + {{$requestableModel->name}} {{$requestableModel->assets->where('requestable', '1')->count()}}
- - - - - - - - - - - - - @foreach ($requestedItems as $request) - - - {{ csrf_field() }} - - - @if ($request->location()) - - @else - - @endif - - - - - - - - @endforeach - -
Item TypeItem Name{{ trans('admin/hardware/table.location') }}{{ trans('admin/hardware/form.expected_checkin') }}Requesting UserRequested Date{{ trans('table.actions') }}
{{ $request->itemType() }}{{ $request->name() }}{{ $request->location()->name }} - @if ($request->itemType() == "asset") - {{ $request->itemRequested()->expected_checkin }} - @else - "N/A" - @endif - {{ $request->requestingUser()->present()->fullName() }}{{$request->created_at}} -
-
- - @else -
-
- - {{ trans('general.no_results') }} -
-
- @endif - - -@stop diff --git a/resources/views/hardware/requested.blade.php b/resources/views/hardware/requested.blade.php new file mode 100644 index 0000000000..51f8119e2c --- /dev/null +++ b/resources/views/hardware/requested.blade.php @@ -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') + +
+
+
+
+ {{ Form::open([ + 'method' => 'POST', + 'route' => ['hardware/bulkedit'], + 'class' => 'form-inline', + 'id' => 'bulkForm']) }} +
+
+ + @if ($requestedItems->count() > 0) +
+ + + + + + + + + + + + + + @foreach ($requestedItems as $request) + + {{ csrf_field() }} + + + @if ($request->location()) + + @else + + @endif + + + + + + + + + @endforeach + +
ImageItem Name{{ trans('admin/hardware/table.location') }}{{ trans('admin/hardware/form.expected_checkin') }}Requesting UserRequested Date
+ @if ($request->itemType() == "asset") + + @endif + + + + + @if ($request->itemType() == "asset") + + {{ $request->name() }} + + @elseif ($request->itemType() == "asset_model") + + {{ $request->name() }} + + @endif + + {{ $request->location()->name }} + @if ($request->itemType() == "asset") + {{ App\Helpers\Helper::getFormattedDateObject($request->requestable->expected_checkin, 'datetime', false) }} + @endif + + + {{ $request->requestingUser()->present()->fullName() }} + + {{ App\Helpers\Helper::getFormattedDateObject($request->created_at, 'datetime', false) }} + @if ($request->itemType() == "asset") + @if ($request->requestable->assigned_to=='') + {{ trans('general.checkout') }} + @else + {{ trans('general.checkin') }} + @endif + + @endif +
+
+ + @else +
+
+ + {{ trans('general.no_results') }} +
+
+ @endif +
+
+
+
+
+
+ +@stop + +@section('moar_scripts') + @include ('partials.bootstrap-table', [ + 'exportFile' => 'requested-export', + 'search' => true, + 'clientSearch' => true, + ]) + +@stop diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 2c260f5807..748a2e2a64 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -43,7 +43,7 @@ $('.snipe-table').bootstrapTable('destroy').bootstrapTable({ paginationVAlign: 'both', - sidePagination: 'server', + sidePagination: '{{ (isset($clientSearch)) ? 'client' : 'server' }}', sortable: true, diff --git a/routes/web.php b/routes/web.php index 9eca110a92..bff52081a9 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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'],