Skip to content

A free open source IT asset/license management system

Licenses/Accessory/Consumables: Fixed FD-55732 - confirm FMCS on backend

snipecbc6dc94a52b
diff --git a/app/Http/Controllers/Accessories/AccessoryCheckoutController.php b/app/Http/Controllers/Accessories/AccessoryCheckoutController.php
index 184ee1711a..5ae39772a4 100644
--- a/app/Http/Controllers/Accessories/AccessoryCheckoutController.php
+++ b/app/Http/Controllers/Accessories/AccessoryCheckoutController.php
@@ -10,6 +10,7 @@ use App\Http\Traits\CheckInOutTrait;
use App\Models\Accessory;
use App\Models\AccessoryCheckout;
use App\Models\CheckoutAcceptance;
+use App\Models\Setting;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Contracts\View\View;
@@ -66,6 +67,10 @@ class AccessoryCheckoutController extends Controller
$target = $this->determineCheckoutTarget();
session()->put(['checkout_to_type' => $target]);
+ if ((Setting::getSettings()->full_multiple_companies_support == '1') && (! $target->companies()->where('companies.id', $accessory->company_id)->exists())) {
+ return redirect()->back()->with('error', trans('general.error_user_company'));
+ }
+
$accessory->checkout_qty = $request->input('checkout_qty', 1);
for ($i = 0; $i < $accessory->checkout_qty; $i++) {
diff --git a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php b/app/Http/Controllers/Consumables/ConsumableCheckoutController.php
index cc283e1d46..ea394671ac 100644
--- a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php
+++ b/app/Http/Controllers/Consumables/ConsumableCheckoutController.php
@@ -7,6 +7,7 @@ use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\Models\CheckoutAcceptance;
use App\Models\Consumable;
+use App\Models\Setting;
use App\Models\User;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\View\View;
@@ -96,6 +97,10 @@ class ConsumableCheckoutController extends Controller
return redirect()->route('consumables.checkout.show', $consumable)->with('error', trans('admin/consumables/message.checkout.user_does_not_exist'))->withInput();
}
+ if ((Setting::getSettings()->full_multiple_companies_support == '1') && (! $user->companies()->where('companies.id', $consumable->company_id)->exists())) {
+ return redirect()->back()->with('error', trans('general.error_user_company'));
+ }
+
// Update the consumable data
$consumable->assigned_to = e($request->input('assigned_to'));
diff --git a/app/Http/Controllers/Licenses/LicenseCheckoutController.php b/app/Http/Controllers/Licenses/LicenseCheckoutController.php
index eb37265512..bba007291e 100644
--- a/app/Http/Controllers/Licenses/LicenseCheckoutController.php
+++ b/app/Http/Controllers/Licenses/LicenseCheckoutController.php
@@ -96,6 +96,20 @@ class LicenseCheckoutController extends Controller
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.license_is_inactive'));
}
+ if (Setting::getSettings()->full_multiple_companies_support == '1') {
+ if ($request->filled('asset_id')) {
+ $fmcsTarget = Asset::find($request->input('asset_id'));
+ if ($fmcsTarget && $license->company_id && $license->company_id !== $fmcsTarget->company_id) {
+ return redirect()->route('licenses.index')->with('error', trans('general.error_user_company'));
+ }
+ } elseif ($request->filled('assigned_to')) {
+ $fmcsTarget = User::find($request->input('assigned_to'));
+ if ($fmcsTarget && ! $fmcsTarget->companies()->where('companies.id', $license->company_id)->exists()) {
+ return redirect()->route('licenses.index')->with('error', trans('general.error_user_company'));
+ }
+ }
+ }
+
$licenseSeat = null;
$checkoutTarget = null;