Date: Tue, 12 Dec 2017 05:43:06 -0800
Subject: [PATCH 06/13] Fixed #4589 - Licence deployed to asset issue
---
app/Http/Controllers/LicensesController.php | 2 +-
resources/views/licenses/view.blade.php | 26 ++++++++++++++-------
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/app/Http/Controllers/LicensesController.php b/app/Http/Controllers/LicensesController.php
index 559f979fad..bfbcbb3b69 100755
--- a/app/Http/Controllers/LicensesController.php
+++ b/app/Http/Controllers/LicensesController.php
@@ -315,7 +315,7 @@ class LicensesController extends Controller
$licenseSeat->asset_id = $request->input('asset_id');
// Override asset's assigned user if available
- if ($target->assigned_to!='') {
+ if ($target->checkedOutToUser()) {
$licenseSeat->assigned_to = $target->assigned_to;
}
diff --git a/resources/views/licenses/view.blade.php b/resources/views/licenses/view.blade.php
index 6ee5ffc7c9..dc1bee4c88 100755
--- a/resources/views/licenses/view.blade.php
+++ b/resources/views/licenses/view.blade.php
@@ -56,34 +56,44 @@
Seat {{ $count }} |
@if (($licensedto->user) && ($licensedto->deleted_at == NULL))
+
@can('users.view')
+
{{ $licensedto->user->present()->fullName() }}
@else
+
{{ $licensedto->user->present()->fullName() }}
@endcan
+
@elseif (($licensedto->user) && ($licensedto->deleted_at != NULL))
+
{{ $licensedto->user->present()->fullName() }}
- @elseif ($licensedto->asset)
- @if ($licensedto->asset->assigned_to != 0)
- @can('users.view')
- {!! $licensedto->asset->assignedTo->present()->nameUrl() !!}
- @else
- {{ $licensedto->asset->assignedTo->present()->name() }}
- @endcan
- @endif
+
@endif
|
@if ($licensedto->asset)
+
@can('view', $licensedto->asset)
+
{{ $licensedto->asset->name }} {{ $licensedto->asset->asset_tag }}
@else
+
{{ $licensedto->asset->name }} {{ $licensedto->asset->asset_tag }}
@endcan
+
+ @if ($licensedto->asset->location)
+ @can('locations.view')
+ ({!! $licensedto->asset->location->present()->nameUrl() !!})
+ @else
+ ({{ $licensedto->asset->location->present()->name() }})
+ @endcan
+ @endif
+
@endif
|
From 4ce91a4f5d8976dd94bd0ebd7f0535704aa5bce2 Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 12 Dec 2017 06:26:37 -0800
Subject: [PATCH 07/13] Fixed namespace gate for components - related to #4282
---
app/Http/Controllers/Api/ComponentsController.php | 2 +-
resources/views/layouts/default.blade.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Http/Controllers/Api/ComponentsController.php b/app/Http/Controllers/Api/ComponentsController.php
index 4e7a3c4ed7..894d0daa17 100644
--- a/app/Http/Controllers/Api/ComponentsController.php
+++ b/app/Http/Controllers/Api/ComponentsController.php
@@ -149,7 +149,7 @@ class ComponentsController extends Controller
*/
public function getAssets(Request $request, $id)
{
- $this->authorize('index', Asset::class);
+ $this->authorize('view', \App\Models\Asset::class);
$component = Component::findOrFail($id);
$assets = $component->assets();
diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php
index f896bbb383..59d7e08ad7 100644
--- a/resources/views/layouts/default.blade.php
+++ b/resources/views/layouts/default.blade.php
@@ -479,7 +479,7 @@
@endcan
- @can('index', \App\Models\Consumable::class)
+ @can('view', \App\Models\Component::class)
From 9179b6d9c4ceba4ab8f2a20bb9d7d0b8c4c3694a Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 12 Dec 2017 06:49:04 -0800
Subject: [PATCH 08/13] Improved - disallow delete through the GUI if asset
model has assets associated
(We prevent this on the backend anyway, but this makes for nicer UI)
---
app/Http/Transformers/AssetModelsTransformer.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/Http/Transformers/AssetModelsTransformer.php b/app/Http/Transformers/AssetModelsTransformer.php
index 8c94f00577..f9ba38160e 100644
--- a/app/Http/Transformers/AssetModelsTransformer.php
+++ b/app/Http/Transformers/AssetModelsTransformer.php
@@ -53,7 +53,7 @@ class AssetModelsTransformer
$permissions_array['available_actions'] = [
'update' => (Gate::allows('update', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false,
- 'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false,
+ 'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->assets_count==0) && ($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,
];
From 856a760d89828fdef8fb821f9c145869d8ae6b45 Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 12 Dec 2017 06:52:50 -0800
Subject: [PATCH 09/13] Improved - disallow deleting manufactureres if there
are associated items
This is enforced on the backend - UI imorovement only
---
app/Http/Transformers/ManufacturersTransformer.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/Http/Transformers/ManufacturersTransformer.php b/app/Http/Transformers/ManufacturersTransformer.php
index 7ef0ea54a6..6972d0bbc4 100644
--- a/app/Http/Transformers/ManufacturersTransformer.php
+++ b/app/Http/Transformers/ManufacturersTransformer.php
@@ -40,7 +40,7 @@ class ManufacturersTransformer
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Manufacturer::class) ? true : false,
- 'delete' => Gate::allows('delete', Manufacturer::class) ? true : false,
+ 'delete' => (Gate::allows('delete', Manufacturer::class) && ($manufacturer->assets_count == 0) && ($manufacturer->licenses_count==0) && ($manufacturer->consumables_count==0) && ($manufacturer->accessories_count==0) && ($manufacturer->deleted_at=='')) ? true : false,
];
$array += $permissions_array;
From 528630a8d3f9ea409b2974c77bcd4886198639e5 Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 12 Dec 2017 07:03:09 -0800
Subject: [PATCH 10/13] Improvement - make asset, etc totals in company listing
sortable
---
app/Http/Transformers/CompaniesTransformer.php | 2 +-
app/Presenters/CompanyPresenter.php | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/app/Http/Transformers/CompaniesTransformer.php b/app/Http/Transformers/CompaniesTransformer.php
index d8f89ea3b0..e4e8a48711 100644
--- a/app/Http/Transformers/CompaniesTransformer.php
+++ b/app/Http/Transformers/CompaniesTransformer.php
@@ -38,7 +38,7 @@ class CompaniesTransformer
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Company::class) ? true : false,
- 'delete' => Gate::allows('delete', Company::class) ? true : false,
+ 'delete' => (Gate::allows('delete', Category::class) && ($company->assets_count == 0) && ($company->accessories_count == 0) && ($company->consumables_count == 0) && ($company->components_count == 0) && ($company->users_count == 0)) ? true : false,
];
$array += $permissions_array;
diff --git a/app/Presenters/CompanyPresenter.php b/app/Presenters/CompanyPresenter.php
index 233245ff7d..1d0ab86b4a 100644
--- a/app/Presenters/CompanyPresenter.php
+++ b/app/Presenters/CompanyPresenter.php
@@ -41,51 +41,51 @@ class CompanyPresenter extends Presenter
],[
"field" => "users_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"title" => ''.trans('general.users').'',
"visible" => true,
],[
"field" => "assets_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"title" => ''.trans('general.assets').'',
"visible" => true,
],[
"field" => "licenses_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => true,
"title" => ' '.trans('general.licenses').'',
],[
"field" => "accessories_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => true,
"title" => ' '.trans('general.accessories').'',
],[
"field" => "consumables_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => true,
"title" => ' '.trans('general.consumables').'',
],[
"field" => "components_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => true,
"title" => ' '.trans('general.components').'',
],[
"field" => "updated_at",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => false,
"title" => trans('general.updated_at'),
],[
"field" => "created_at",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => false,
"title" => trans('general.created_at'),
],[
From 1ef44721f59ab2ce5e241daea07fa276d5c6b5ba Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 12 Dec 2017 07:03:31 -0800
Subject: [PATCH 11/13] Improved - disallow delete if not elgible in UI
---
app/Http/Controllers/Api/CompaniesController.php | 15 +++++++++++++--
app/Http/Transformers/DepartmentsTranformer.php | 2 +-
app/Http/Transformers/LocationsTransformer.php | 2 +-
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/app/Http/Controllers/Api/CompaniesController.php b/app/Http/Controllers/Api/CompaniesController.php
index 4d5a1b2a4f..ebafd9a98e 100644
--- a/app/Http/Controllers/Api/CompaniesController.php
+++ b/app/Http/Controllers/Api/CompaniesController.php
@@ -22,10 +22,21 @@ class CompaniesController extends Controller
{
$this->authorize('view', Company::class);
- $allowed_columns = ['id','name'];
+ $allowed_columns = [
+ 'id',
+ 'name',
+ 'created_at',
+ 'updated_at',
+ 'users_count',
+ 'assets_count',
+ 'licenses_count',
+ 'accessories_count',
+ 'consumables_count',
+ 'components_count',
+ ];
$companies = Company::withCount('assets','licenses','accessories','consumables','components','users')
- ->withCount('users')->withCount('users')->withCount('assets')
+ ->withCount('users')->withCount('assets')
->withCount('licenses')->withCount('accessories')
->withCount('consumables')->withCount('components');
diff --git a/app/Http/Transformers/DepartmentsTranformer.php b/app/Http/Transformers/DepartmentsTranformer.php
index dd51e73aa8..f81954f947 100644
--- a/app/Http/Transformers/DepartmentsTranformer.php
+++ b/app/Http/Transformers/DepartmentsTranformer.php
@@ -47,7 +47,7 @@ class DepartmentsTransformer
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Department::class) ? true : false,
- 'delete' => Gate::allows('delete', Department::class) ? true : false,
+ 'delete' => (Gate::allows('delete', Department::class) && ($department->users_count==0) && ($department->deleted_at=='')) ? true : false,
];
$array += $permissions_array;
diff --git a/app/Http/Transformers/LocationsTransformer.php b/app/Http/Transformers/LocationsTransformer.php
index 96fd25fee6..f8aa322c30 100644
--- a/app/Http/Transformers/LocationsTransformer.php
+++ b/app/Http/Transformers/LocationsTransformer.php
@@ -57,7 +57,7 @@ class LocationsTransformer
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Location::class) ? true : false,
- 'delete' => Gate::allows('delete', Location::class) ? true : false,
+ 'delete' => (Gate::allows('delete', Department::class) && ($location->assigned_assets_count==0) && ($location->assets_count==0) && ($location->users_count==0) && ($location->deleted_at=='')) ? true : false,
];
$array += $permissions_array;
From e21fa372541638dc3e48b3d6fad19285ddfaa1da Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 12 Dec 2017 07:15:51 -0800
Subject: [PATCH 12/13] Added - bulk actions to model asset listings
---
resources/views/models/view.blade.php | 63 ++++++++++++++++++---------
1 file changed, 42 insertions(+), 21 deletions(-)
diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php
index 383e1d9cab..a107ed8c1a 100755
--- a/resources/views/models/view.blade.php
+++ b/resources/views/models/view.blade.php
@@ -42,27 +42,48 @@
@endif
-
-
-
- {{ trans('general.id') }} |
- {{ trans('admin/companies/table.title') }} |
- {{ trans('general.name') }} |
- {{ trans('general.asset_tag') }} |
- {{ trans('admin/hardware/table.serial') }} |
- {{ trans('general.user') }} |
- {{ trans('admin/hardware/table.change') }} |
- {{ trans('table.actions') }} |
-
-
-
+
+
+ {{ Form::open([
+ 'method' => 'POST',
+ 'route' => ['hardware/bulkedit'],
+ 'class' => 'form-inline',
+ 'id' => 'bulkForm']) }}
+
+
+
+
+
+
+
+
+ |
+ {{ trans('general.id') }} |
+ {{ trans('admin/companies/table.title') }} |
+ {{ trans('general.name') }} |
+ {{ trans('general.asset_tag') }} |
+ {{ trans('admin/hardware/table.serial') }} |
+ {{ trans('general.user') }} |
+ {{ trans('admin/hardware/table.change') }} |
+ {{ trans('table.actions') }} |
+
+
+
+ {{ Form::close() }}
+
+
From 1d82f80e735d57a6c3f1a8ace53c069e929c8115 Mon Sep 17 00:00:00 2001
From: snipe
Date: Tue, 12 Dec 2017 07:20:06 -0800
Subject: [PATCH 13/13] =?UTF-8?q?Improved=20-=20used=20=E2=80=9Cchecked=20?=
=?UTF-8?q?out=20to=E2=80=9D=20string=20in=20asset=20model=20listing=20to?=
=?UTF-8?q?=20reflect=20new=20polymorphic=20options?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
resources/views/models/view.blade.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php
index a107ed8c1a..3b5b8d7f9e 100755
--- a/resources/views/models/view.blade.php
+++ b/resources/views/models/view.blade.php
@@ -75,7 +75,7 @@
{{ trans('general.name') }} |
{{ trans('general.asset_tag') }} |
{{ trans('admin/hardware/table.serial') }} |
- {{ trans('general.user') }} |
+ {{ trans('admin/hardware/form.checkedout_to') }} |
{{ trans('admin/hardware/table.change') }} |
{{ trans('table.actions') }} |
|