A free open source IT asset/license management system
adds migration for column unavailable, changes logic to utlize value
Godfrey M7a23372489e9
diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.phpindex 7230917684..263204853c 100644--- a/app/Helpers/Helper.php+++ b/app/Helpers/Helper.php@@ -1535,8 +1535,8 @@ class Helper{if (!$license->reassignable) {- $count = Actionlog::where('action_type', '=', 'checkin from')- ->where('item_id', '=', $license->id)+ $count = LicenseSeat::where('unavailable', '=', true)+ ->where('license_id', '=', $license->id)->count();return $count;}diff --git a/app/Http/Controllers/Licenses/LicenseCheckinController.php b/app/Http/Controllers/Licenses/LicenseCheckinController.phpindex f70c01bfd3..1581fc1419 100644--- a/app/Http/Controllers/Licenses/LicenseCheckinController.php+++ b/app/Http/Controllers/Licenses/LicenseCheckinController.php@@ -96,6 +96,7 @@ class LicenseCheckinController extends Controller$licenseSeat->asset_id = null;$licenseSeat->notes = $request->input('notes');if (! $license->reassignable) {+ $licenseSeat->unavailable = 1;$licenseSeat->notes .= "\n" . trans('admin/licenses/message.checkin.not_reassignable') . '.';}diff --git a/app/Http/Transformers/LicenseSeatsTransformer.php b/app/Http/Transformers/LicenseSeatsTransformer.phpindex 742fc865e1..f04c593393 100644--- a/app/Http/Transformers/LicenseSeatsTransformer.php+++ b/app/Http/Transformers/LicenseSeatsTransformer.php@@ -49,7 +49,7 @@ class LicenseSeatsTransformer'reassignable' => (bool) $seat->license->reassignable,'notes' => e($seat->notes),'user_can_checkout' => (($seat->assigned_to == '') && ($seat->asset_id == '')),- 'disabled' => $this->unReassignable($seat),+ 'disabled' => $seat->unavailable,];if ($seat_count != 0) {@@ -68,17 +68,17 @@ class LicenseSeatsTransformerreturn $array;}- private function unReassignable($seat)- {- if (!$seat->license->reassignable) {- $exists = Actionlog::where('action_type', '=', 'checkin from')- ->where('item_id', '=', $seat->license->id)- ->where('updated_at', '=', $seat->updated_at)- ->exists();- if($exists) {- return true;- }- return false;- }- }+// private function unReassignable($seat)+// {+// if (!$seat->license->reassignable) {+// $exists = Actionlog::where('action_type', '=', 'checkin from')+// ->where('item_id', '=', $seat->license->id)+// ->where('updated_at', '=', $seat->updated_at)+// ->exists();+// if($exists) {+// return true;+// }+// return false;+// }+// }}diff --git a/app/Models/License.php b/app/Models/License.phpindex 5ca621bce7..a9966c16b0 100755--- a/app/Models/License.php+++ b/app/Models/License.php@@ -653,6 +653,7 @@ class License extends Depreciable{return $this->licenseseats()->whereNull('deleted_at')+ ->where('unavailable', '=', 0)->where(function ($query) {$query->whereNull('assigned_to')->whereNull('asset_id');diff --git a/app/Presenters/LicensePresenter.php b/app/Presenters/LicensePresenter.phpindex faac314e87..4256c2c686 100644--- a/app/Presenters/LicensePresenter.php+++ b/app/Presenters/LicensePresenter.php@@ -284,15 +284,6 @@ class LicensePresenter extends Presenter'title' => trans('general.notes'),'formatter' => 'notesFormatter'],- [- 'field' => 'reassignable',- 'searchable' => false,- 'sortable' => false,- 'visible' => true,- 'title' => trans('admin/licenses/form.reassignable'),- 'formatter' => 'trueFalseFormatter',- 'class' => 'text-center',- ],['field' => 'checkincheckout','searchable' => false,diff --git a/database/migrations/2025_01_15_190348_adds_unavailable_to_license_seats_tables.php b/database/migrations/2025_01_15_190348_adds_unavailable_to_license_seats_tables.phpnew file mode 100644index 0000000000..b0ec692ea0--- /dev/null+++ b/database/migrations/2025_01_15_190348_adds_unavailable_to_license_seats_tables.php@@ -0,0 +1,29 @@+<?php+namespace App\Models\LicenseSeat;+use App\Models\LicenseSeat;+use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\DB;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('license_seats', function (Blueprint $table) {+ $table->addColumn('boolean', 'unavailable')->default(false)->after('assigned_to');+ });+ }+ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::table('license_seats_tables', function (Blueprint $table) {+ $table->dropColumn('unavailable');+ });+ }+};