diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index c471270852..8199715b93 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -911,14 +911,21 @@ class ReportsController extends Controller * @author Vincent Sposato * @version v1.0 */ - public function getAssetAcceptanceReport() + public function getAssetAcceptanceReport($deleted = false) { $this->authorize('reports.view'); + $showDeleted = $deleted == 'deleted'; /** * Get all assets with pending checkout acceptances */ - $acceptances = CheckoutAcceptance::pending()->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model'])->get(); + if($showDeleted) { + $acceptances = CheckoutAcceptance::pending()->withTrashed()->with(['assignedTo' , 'checkoutable.assignedTo', 'checkoutable.model'])->get(); + } else { + $acceptances = CheckoutAcceptance::pending()->with(['assignedTo' => function ($query) { + $query->withTrashed(); + }, 'checkoutable.assignedTo', 'checkoutable.model'])->get(); + } $assetsForReport = $acceptances ->filter(function ($acceptance) { @@ -928,7 +935,7 @@ class ReportsController extends Controller return ['assetItem' => $acceptance->checkoutable, 'acceptance' => $acceptance]; }); - return view('reports/unaccepted_assets', compact('assetsForReport')); + return view('reports/unaccepted_assets', compact('assetsForReport','showDeleted' )); } /** @@ -997,14 +1004,19 @@ class ReportsController extends Controller * @author Vincent Sposato * @version v1.0 */ - public function postAssetAcceptanceReport() + public function postAssetAcceptanceReport($deleted = false) { $this->authorize('reports.view'); + $showDeleted = $deleted == 'deleted'; /** * Get all assets with pending checkout acceptances */ - $acceptances = CheckoutAcceptance::pending()->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model'])->get(); + if($showDeleted) { + $acceptances = CheckoutAcceptance::pending()->withTrashed()->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model'])->get(); + } else { + $acceptances = CheckoutAcceptance::pending()->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model'])->get(); + } $assetsForReport = $acceptances ->filter(function($acceptance) { diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index aeb8dd9565..6a0971cb05 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -248,4 +248,5 @@ 'show_help' => 'Show help', 'hide_help' => 'Hide help', 'view_all' => 'view all', + 'hide_deleted' => 'Hide Deleted', ]; diff --git a/resources/views/reports/unaccepted_assets.blade.php b/resources/views/reports/unaccepted_assets.blade.php index af01239097..275a1c8425 100644 --- a/resources/views/reports/unaccepted_assets.blade.php +++ b/resources/views/reports/unaccepted_assets.blade.php @@ -9,10 +9,22 @@ @stop @section('header_right') - {{ Form::open(['method' => 'post', 'class' => 'form-horizontal']) }} - {{csrf_field()}} - - {{ Form::close() }} + + @stop {{-- Page content --}} @@ -34,6 +46,7 @@ data-show-export="true" data-show-refresh="true" data-sort-order="asc" + data-sort-name="created_at" id="unacceptedAssetsReport" class="table table-striped snipe-table" data-export-options='{ @@ -42,12 +55,13 @@ }'> - {{ trans('admin/companies/table.title') }} - {{ trans('general.category') }} - {{ trans('admin/hardware/form.model') }} - {{ trans('admin/hardware/form.name') }} - {{ trans('admin/hardware/table.asset_tag') }} - {{ trans('admin/hardware/table.checkoutto') }} + {{ trans('general.date') }} + {{ trans('admin/companies/table.title') }} + {{ trans('general.category') }} + {{ trans('admin/hardware/form.model') }} + {{ trans('admin/hardware/form.name') }} + {{ trans('admin/hardware/table.asset_tag') }} + {{ trans('admin/hardware/table.checkoutto') }} {{ trans('table.actions') }} @@ -55,16 +69,19 @@ @if ($assetsForReport) @foreach ($assetsForReport as $item) @if ($item['assetItem']) - + trashed()) style="text-decoration: line-through" @endif> + {{ $item['acceptance']->created_at }} {{ ($item['assetItem']->company) ? $assetItem->company->name : '' }} {!! $item['assetItem']->model->category->present()->nameUrl() !!} {!! $item['assetItem']->present()->modelUrl() !!} {!! $item['assetItem']->present()->nameUrl() !!} {{ $item['assetItem']->asset_tag }} - {!! ($item['acceptance']->assignedTo) ? $item['acceptance']->assignedTo->present()->nameUrl() : trans('admin/reports/general.deleted_user') !!} + assignedTo === null || $item['acceptance']->assignedTo->trashed()) style="text-decoration: line-through" @endif>{!! ($item['acceptance']->assignedTo) ? $item['acceptance']->assignedTo->present()->nameUrl() : trans('admin/reports/general.deleted_user') !!} - @if ($item['acceptance']->assignedTo){{ trans('admin/reports/general.send_reminder') }}@endif - + @if(!$item['acceptance']->trashed()) + @if ($item['acceptance']->assignedTo){{ trans('admin/reports/general.send_reminder') }}@endif + + @endif @endif diff --git a/routes/web.php b/routes/web.php index af9be8ecbd..1623277518 100644 --- a/routes/web.php +++ b/routes/web.php @@ -319,7 +319,7 @@ Route::group(['middleware' => ['auth']], function () { Route::post('reports/activity', [ReportsController::class, 'postActivityReport']); Route::get( - 'reports/unaccepted_assets', + 'reports/unaccepted_assets/{deleted?}', [ReportsController::class, 'getAssetAcceptanceReport'] )->name('reports/unaccepted_assets'); Route::get( @@ -331,7 +331,7 @@ Route::group(['middleware' => ['auth']], function () { [ReportsController::class, 'deleteAssetAcceptance'] )->name('reports/unaccepted_assets_delete'); Route::post( - 'reports/unaccepted_assets', + 'reports/unaccepted_assets/{deleted?}', [ReportsController::class, 'exportAssetAcceptanceReport'] )->name('reports/export/unaccepted_assets'); });