From 9ca163e8cf701b700c71f7f49d6848a13a145909 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 2 Aug 2023 19:22:35 -0600 Subject: [PATCH 1/5] Stop asset acceptances from shown to user if full company support is enabled and companies not match --- app/Http/Controllers/Account/AcceptanceController.php | 2 +- resources/lang/en/general.php | 1 + resources/views/account/accept/index.blade.php | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php index 645e2624b2..99e4562888 100644 --- a/app/Http/Controllers/Account/AcceptanceController.php +++ b/app/Http/Controllers/Account/AcceptanceController.php @@ -69,7 +69,7 @@ class AcceptanceController extends Controller } if (! Company::isCurrentUserHasAccess($acceptance->checkoutable)) { - return redirect()->route('account.accept')->with('error', trans('general.insufficient_permissions')); + return redirect()->route('account.accept')->with('error', trans('general.error_user_company')); } return view('account/accept.create', compact('acceptance')); diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 4831845721..3b1d0787d5 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -452,6 +452,7 @@ return [ 'serial_number' => 'Serial Number', 'item_notes' => ':item Notes', 'item_name_var' => ':item Name', + 'error_user_company' => 'User and Asset companies missmatch', 'importer' => [ 'checked_out_to_fullname' => 'Checked Out to: Full Name', 'checked_out_to_first_name' => 'Checked Out to: First Name', diff --git a/resources/views/account/accept/index.blade.php b/resources/views/account/accept/index.blade.php index f2a9bc56f2..58ed542dc6 100755 --- a/resources/views/account/accept/index.blade.php +++ b/resources/views/account/accept/index.blade.php @@ -41,9 +41,11 @@ @foreach ($acceptances as $acceptance) + @if ($acceptance->checkoutable) {{ ($acceptance->checkoutable) ? $acceptance->checkoutable->present()->name : '' }} {{ trans('general.accept_decline') }} + @endif @endforeach From 053d3fc9ed55f8e687dc252f624128c7b3484b6e Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 2 Aug 2023 19:23:28 -0600 Subject: [PATCH 2/5] Prevent asset to be checked out if full company support is enabled and companies not match --- app/Http/Controllers/Assets/AssetCheckoutController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php index e6326da6b1..bc5465e4be 100644 --- a/app/Http/Controllers/Assets/AssetCheckoutController.php +++ b/app/Http/Controllers/Assets/AssetCheckoutController.php @@ -89,6 +89,14 @@ class AssetCheckoutController extends Controller } } + $settings = \App\Models\Setting::getSettings(); + + if ($settings->full_multiple_companies_support){ + if ($target->company_id != $asset->company_id){ + return redirect()->to("hardware/$assetId/checkout")->with('error', trans('general.error_user_company')); + } + } + if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $request->get('name'))) { return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success')); } From d365565b6d0ff95b5ba843532c2d64fa95f00e0a Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Mon, 14 Aug 2023 20:51:04 -0600 Subject: [PATCH 3/5] Add message in the acceptance assets view to indicate when the user can\'t accept nor deny the asset --- resources/lang/en/general.php | 1 + resources/views/account/accept/index.blade.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 3b1d0787d5..2268008bf7 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -453,6 +453,7 @@ return [ 'item_notes' => ':item Notes', 'item_name_var' => ':item Name', 'error_user_company' => 'User and Asset companies missmatch', + 'error_user_company_accpept_view' => 'User and Asset companies doesn\'t match so you can\'t accept nor deny it, please check with your manager', 'importer' => [ 'checked_out_to_fullname' => 'Checked Out to: Full Name', 'checked_out_to_first_name' => 'Checked Out to: First Name', diff --git a/resources/views/account/accept/index.blade.php b/resources/views/account/accept/index.blade.php index 58ed542dc6..71949f6383 100755 --- a/resources/views/account/accept/index.blade.php +++ b/resources/views/account/accept/index.blade.php @@ -44,8 +44,11 @@ @if ($acceptance->checkoutable) {{ ($acceptance->checkoutable) ? $acceptance->checkoutable->present()->name : '' }} {{ trans('general.accept_decline') }} + @else + ----- + {{ trans('general.error_user_company_accpept_view') }} + @endif - @endif @endforeach From 71cb16118d6afb16deae916671f92e9b59d287df Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Mon, 14 Aug 2023 20:52:00 -0600 Subject: [PATCH 4/5] Change error string for a better (?) one --- resources/lang/en/general.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 2268008bf7..acbf23c2c2 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -453,7 +453,7 @@ return [ 'item_notes' => ':item Notes', 'item_name_var' => ':item Name', 'error_user_company' => 'User and Asset companies missmatch', - 'error_user_company_accpept_view' => 'User and Asset companies doesn\'t match so you can\'t accept nor deny it, please check with your manager', + 'error_user_company_accpept_view' => 'An Asset assigned to you belongs to a different company so you can\'t accept nor deny it, please check with your manager', 'importer' => [ 'checked_out_to_fullname' => 'Checked Out to: Full Name', 'checked_out_to_first_name' => 'Checked Out to: First Name', From 25c58a84864a4a2339f3c841a1a43b3a2f058c9b Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 15 Aug 2023 14:17:39 -0600 Subject: [PATCH 5/5] Fix typo in language variable name --- resources/lang/en/general.php | 2 +- resources/views/account/accept/index.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index acbf23c2c2..e4596d0cd0 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -453,7 +453,7 @@ return [ 'item_notes' => ':item Notes', 'item_name_var' => ':item Name', 'error_user_company' => 'User and Asset companies missmatch', - 'error_user_company_accpept_view' => 'An Asset assigned to you belongs to a different company so you can\'t accept nor deny it, please check with your manager', + 'error_user_company_accept_view' => 'An Asset assigned to you belongs to a different company so you can\'t accept nor deny it, please check with your manager', 'importer' => [ 'checked_out_to_fullname' => 'Checked Out to: Full Name', 'checked_out_to_first_name' => 'Checked Out to: First Name', diff --git a/resources/views/account/accept/index.blade.php b/resources/views/account/accept/index.blade.php index 71949f6383..b627135a4d 100755 --- a/resources/views/account/accept/index.blade.php +++ b/resources/views/account/accept/index.blade.php @@ -46,7 +46,7 @@ {{ trans('general.accept_decline') }} @else ----- - {{ trans('general.error_user_company_accpept_view') }} + {{ trans('general.error_user_company_accept_view') }} @endif @endforeach