Skip to content

A free open source IT asset/license management system

fixes status check for bulk checkout

Godfrey M3b832f507fa4
diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php
index 691dab8d04..cec6f302b1 100644
--- a/app/Http/Controllers/Assets/BulkAssetsController.php
+++ b/app/Http/Controllers/Assets/BulkAssetsController.php
@@ -53,7 +53,10 @@ class BulkAssetsController extends Controller
$asset_ids = $request->input('ids');
if ($request->input('bulk_actions') === 'checkout') {
- $this->isDeployable($asset_ids);
+
+ if($this->hasUndeployableStatus($asset_ids)){
+ return redirect()->back()->with('error', trans('admin/hardware/message.undeployable'));
+ }
$request->session()->flashInput(['selected_assets' => $asset_ids]);
return redirect()->route('hardware.bulkcheckout.show');
@@ -662,18 +665,15 @@ class BulkAssetsController extends Controller
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.restore.success'));
}
}
- public function isDeployable ($asset_ids) : bool {
+ public function hasUndeployableStatus (array $asset_ids) : bool
+ {
$undeployable = Asset::whereIn('id', $asset_ids)
- ->whereHas('assetstatus', function ($query) {
- $query->where('deployable', 0)
- ->where('pending', 0)
- ->where('archived', 0)
- ->exists();
- });
+ ->undeployable()
+ ->first();
- if( !$undeployable ) {
+ if($undeployable) {
return true;
}
- return redirect()->back()->with('error', trans('admin/hardware/message.upload.nofiles'));
+ return false;
}
}
diff --git a/resources/lang/en-US/admin/hardware/message.php b/resources/lang/en-US/admin/hardware/message.php
index c19bc63647..893f992708 100644
--- a/resources/lang/en-US/admin/hardware/message.php
+++ b/resources/lang/en-US/admin/hardware/message.php
@@ -2,7 +2,7 @@
return [
- 'undeployable' => '<strong>Warning: </strong> This asset has been marked as currently undeployable. If this status has changed, please update the asset status.',
+ 'undeployable' => 'An asset in your selection for checkout has been marked as currently undeployable. If this status has changed, please update the asset status before checking it out.',
'does_not_exist' => 'Asset does not exist.',
'does_not_exist_var' => 'Asset with tag :asset_tag not found.',
'no_tag' => 'No asset tag provided.',
diff --git a/routes/web.php b/routes/web.php
index add1e62354..68896bbcde 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -25,6 +25,7 @@ use App\Http\Controllers\StatuslabelsController;
use App\Http\Controllers\SuppliersController;
use App\Http\Controllers\ViewAssetsController;
use App\Livewire\Importer;
+use App\Models\Asset;
use App\Models\ReportTemplate;
use Illuminate\Support\Facades\Route;
use Tabuna\Breadcrumbs\Trail;
@@ -698,3 +699,11 @@ Route::middleware(['auth'])->get(
->breadcrumbs(fn (Trail $trail) =>
$trail->push('Home', route('home'))
);
+
+Route::get( 'blah',
+ function(){
+ Asset::whereIn('id', [1886])
+ ->undeployable()
+ ->get();
+ }
+);