From 54671af7f04fce05c8b31a4fe52b8611f1ede1e0 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 3 Oct 2017 11:49:41 -0700 Subject: [PATCH 1/7] Small export assets fix --- app/Http/Controllers/ReportsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index fb2df21840..589307d2b3 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -126,7 +126,7 @@ class ReportsController extends Controller trans('admin/hardware/table.purchase_date'), trans('admin/hardware/table.purchase_cost'), trans('admin/hardware/form.order'), - trans('admin/hardware/form.supplier'), + trans('general.supplier'), trans('admin/hardware/table.checkoutto'), trans('admin/hardware/table.checkout_date'), trans('admin/hardware/table.location'), @@ -154,7 +154,7 @@ class ReportsController extends Controller ($asset->supplier) ? e($asset->supplier->name) : '', ($asset->assignedTo) ? e($asset->assignedTo->present()->name()) : '', ($asset->last_checkout!='') ? e($asset->last_checkout) : '', - e($asset->assetLoc->present()->name()), + ($asset->assetLoc) ? e($asset->assetLoc->present()->name()) : '', ($asset->notes) ? e($asset->notes) : '', ]; foreach ($customfields as $field) { From fcb1283a14f66aefb120e17f206ce784d35072fd Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 3 Oct 2017 12:49:53 -0700 Subject: [PATCH 2/7] Added missing deployed page title --- resources/views/hardware/index.blade.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index 24aa20aa1a..18de1d12d1 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -13,6 +13,8 @@ {{ trans('general.pending') }} @elseif (Input::get('status')=='RTD') {{ trans('general.ready_to_deploy') }} + @elseif (Input::get('status')=='Deployed') + {{ trans('general.deployed') }} @elseif (Input::get('status')=='Undeployable') {{ trans('general.undeployable') }} @elseif (Input::get('status')=='Deployable') @@ -40,7 +42,7 @@ @stop @section('header_right') - + {{ trans('admin/hardware/table.dl_csv') }} {{ trans('general.create') }} @stop From 58a9b0d3e8b5ff8ab2a27c707ab197126266a7ef Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 3 Oct 2017 12:50:01 -0700 Subject: [PATCH 3/7] Normalized route name --- routes/web.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index 68280ae3a0..31bda2239b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -306,10 +306,10 @@ Route::group(['middleware' => ['auth']], function () { 'reports/export/licenses', [ 'as' => 'reports/export/licenses', 'uses' => 'ReportsController@exportLicenseReport' ] ); - Route::get('reports/assets', [ 'as' => 'reports/assets', 'uses' => 'ReportsController@getAssetsReport' ]); + Route::get('reports/assets', [ 'as' => 'reports/assets', 'uses' => 'ReportsController@getAssetsReport' ]); Route::get( 'reports/export/assets', - [ 'as' => 'reports/export/assets', 'uses' => 'ReportsController@exportAssetReport' ] + [ 'as' => 'reports.export.assets', 'uses' => 'ReportsController@exportAssetReport' ] ); Route::get('reports/accessories', [ 'as' => 'reports/accessories', 'uses' => 'ReportsController@getAccessoryReport' ]); Route::get( From 512632ce608111e53296046ea67ed9f4efc4c088 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 3 Oct 2017 12:50:18 -0700 Subject: [PATCH 4/7] Make the export button contextual for requested status --- app/Http/Controllers/ReportsController.php | 37 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 589307d2b3..c3740c8c43 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -15,6 +15,7 @@ use Illuminate\Support\Facades\View; use Input; use League\Csv\Reader; use Symfony\Component\HttpFoundation\StreamedResponse; +use Illuminate\Http\Request; /** * This controller handles all actions related to Reports for @@ -102,18 +103,45 @@ class ReportsController extends Controller * @since [v1.0] * @return \Illuminate\Http\Response */ - public function exportAssetReport() + public function exportAssetReport(Request $request) { \Debugbar::disable(); $customfields = CustomField::get(); - $response = new StreamedResponse(function () use ($customfields) { + $response = new StreamedResponse(function () use ($customfields, $request) { // Open output stream $handle = fopen('php://output', 'w'); - Asset::with('assignedTo', 'assetLoc','defaultLoc','assignedTo','model','supplier','assetstatus','model.manufacturer')->orderBy('created_at', 'DESC')->chunk(500, function($assets) use($handle, $customfields) { + $assets = Asset::with('assignedTo', 'assetLoc','defaultLoc','assignedTo','model','supplier','assetstatus','model.manufacturer'); + + // This is used by the sidenav, mostly + switch ($request->input('status')) { + case 'Deleted': + $assets->withTrashed()->Deleted(); + break; + case 'Pending': + $assets->Pending(); + break; + case 'RTD': + $assets->RTD(); + break; + case 'Undeployable': + $assets->Undeployable(); + break; + case 'Archived': + $assets->Archived(); + break; + case 'Requestable': + $assets->RequestableAssets(); + break; + case 'Deployed': + $assets->Deployed(); + break; + } + + $assets->orderBy('created_at', 'DESC')->chunk(500, function($assets) use($handle, $customfields) { $headers=[ trans('general.company'), trans('admin/hardware/table.asset_tag'), @@ -168,7 +196,8 @@ class ReportsController extends Controller fclose($handle); }, 200, [ 'Content-Type' => 'text/csv', - 'Content-Disposition' => 'attachment; filename="assets-'.date('Y-m-d-his').'.csv"', + 'Content-Disposition' + => 'attachment; filename="'.(($request->has('status')) ? trim($request->input('status')) : 'all').'-assets-'.date('Y-m-d-his').'.csv"', ]); return $response; From b4fec068d078207647f8f73be8b100a00afe1a4e Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 3 Oct 2017 13:44:50 -0700 Subject: [PATCH 5/7] Use asset url for favicon on login blade --- resources/views/layouts/basic.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/layouts/basic.blade.php b/resources/views/layouts/basic.blade.php index b803c68f8c..4df8f8c342 100644 --- a/resources/views/layouts/basic.blade.php +++ b/resources/views/layouts/basic.blade.php @@ -13,7 +13,7 @@ - + @if (($snipeSettings) && ($snipeSettings->header_color)) From 3f44987799ff85ebac60f34908fbef0f912e1c5f Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 3 Oct 2017 14:15:03 -0700 Subject: [PATCH 6/7] Small logo size tweaks --- app/Http/Controllers/SettingsController.php | 2 +- resources/views/layouts/basic.blade.php | 2 +- resources/views/layouts/default.blade.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index c406f83716..3b2441dcc9 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -414,7 +414,7 @@ class SettingsController extends Controller $file_name = "logo.".$image->getClientOriginalExtension(); $path = public_path('uploads'); if ($image->getClientOriginalExtension()!='svg') { - Image::make($image->getRealPath())->resize(null, 40, function ($constraint) { + Image::make($image->getRealPath())->resize(null, 150, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->save($path.'/'.$file_name); diff --git a/resources/views/layouts/basic.blade.php b/resources/views/layouts/basic.blade.php index 4df8f8c342..a8d3ec66f7 100644 --- a/resources/views/layouts/basic.blade.php +++ b/resources/views/layouts/basic.blade.php @@ -42,7 +42,7 @@ @if (($snipeSettings) && ($snipeSettings->logo!=''))
- +
@endif diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index ab87ce569d..5f9b415a7b 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -108,7 +108,7 @@ @if ($snipeSettings->brand == '3') From 6dd4282f1f461cccb7d1d514297f7d5f35ec9757 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 3 Oct 2017 17:53:08 -0700 Subject: [PATCH 7/7] Fixes #4130 - show deleted asset models --- app/Http/Controllers/Api/AssetModelsController.php | 6 +++++- app/Http/Transformers/AssetModelsTransformer.php | 8 +++++--- resources/views/models/index.blade.php | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Api/AssetModelsController.php b/app/Http/Controllers/Api/AssetModelsController.php index 7ef076710c..d4b66041a3 100644 --- a/app/Http/Controllers/Api/AssetModelsController.php +++ b/app/Http/Controllers/Api/AssetModelsController.php @@ -31,7 +31,7 @@ class AssetModelsController extends Controller $this->authorize('view', AssetModel::class); $allowed_columns = ['id','image','name','model_number','eol','notes','created_at','manufacturer']; - $assetmodels = AssetModel::select(['models.id','models.image','models.name','model_number','eol','models.notes','models.created_at','category_id','manufacturer_id','depreciation_id','fieldset_id']) + $assetmodels = AssetModel::select(['models.id','models.image','models.name','model_number','eol','models.notes','models.created_at','category_id','manufacturer_id','depreciation_id','fieldset_id', 'models.deleted_at']) ->with('category','depreciation', 'manufacturer','fieldset') ->withCount('assets'); @@ -39,6 +39,10 @@ class AssetModelsController extends Controller $assetmodels->TextSearch($request->input('search')); } + if ($request->has('status')) { + $assetmodels->onlyTrashed(); + } + $offset = $request->input('offset', 0); $limit = $request->input('limit', 50); diff --git a/app/Http/Transformers/AssetModelsTransformer.php b/app/Http/Transformers/AssetModelsTransformer.php index 2b06e6c0be..53f5997ed6 100644 --- a/app/Http/Transformers/AssetModelsTransformer.php +++ b/app/Http/Transformers/AssetModelsTransformer.php @@ -47,13 +47,15 @@ class AssetModelsTransformer 'notes' => e($assetmodel->notes), 'created_at' => Helper::getFormattedDateObject($assetmodel->created_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($assetmodel->updated_at, 'datetime'), + 'deleted_at' => Helper::getFormattedDateObject($assetmodel->deleted_at, 'datetime'), ]; $permissions_array['available_actions'] = [ - 'update' => Gate::allows('update', AssetModel::class) ? true : false, - 'delete' => Gate::allows('delete', AssetModel::class) ? true : false, - 'clone' => Gate::allows('create', AssetModel::class) ? true : false, + 'update' => (Gate::allows('update', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false, + 'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false, + 'clone' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at=='')) , + 'restore' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at!='')) ? true : false, ]; $array += $permissions_array; diff --git a/resources/views/models/index.blade.php b/resources/views/models/index.blade.php index b9b65629c8..4cd54d9275 100755 --- a/resources/views/models/index.blade.php +++ b/resources/views/models/index.blade.php @@ -9,7 +9,7 @@ {{-- Page title --}} @section('header_right') {{ trans('general.create') }} - {{ trans('admin/models/general.view_deleted') }} + {{ trans('admin/models/general.view_deleted') }} @stop @@ -41,7 +41,7 @@ name="models" class="table table-striped snipe-table" id="table" - data-url="{{ route('api.models.index') }}" + data-url="{{ route('api.models.index', ['status'=> e(Input::get('status'))]) }}" data-cookie="true" data-click-to-select="true" data-cookie-id-table="modelsTable-{{ config('version.hash_version') }}">