mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
adds migration for column unavailable, changes logic to utlize value
This commit is contained in:
parent
9da15a8e58
commit
7a23372489
|
@ -1535,8 +1535,8 @@ class Helper
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!$license->reassignable) {
|
if (!$license->reassignable) {
|
||||||
$count = Actionlog::where('action_type', '=', 'checkin from')
|
$count = LicenseSeat::where('unavailable', '=', true)
|
||||||
->where('item_id', '=', $license->id)
|
->where('license_id', '=', $license->id)
|
||||||
->count();
|
->count();
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ class LicenseCheckinController extends Controller
|
||||||
$licenseSeat->asset_id = null;
|
$licenseSeat->asset_id = null;
|
||||||
$licenseSeat->notes = $request->input('notes');
|
$licenseSeat->notes = $request->input('notes');
|
||||||
if (! $license->reassignable) {
|
if (! $license->reassignable) {
|
||||||
|
$licenseSeat->unavailable = 1;
|
||||||
$licenseSeat->notes .= "\n" . trans('admin/licenses/message.checkin.not_reassignable') . '.';
|
$licenseSeat->notes .= "\n" . trans('admin/licenses/message.checkin.not_reassignable') . '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ class LicenseSeatsTransformer
|
||||||
'reassignable' => (bool) $seat->license->reassignable,
|
'reassignable' => (bool) $seat->license->reassignable,
|
||||||
'notes' => e($seat->notes),
|
'notes' => e($seat->notes),
|
||||||
'user_can_checkout' => (($seat->assigned_to == '') && ($seat->asset_id == '')),
|
'user_can_checkout' => (($seat->assigned_to == '') && ($seat->asset_id == '')),
|
||||||
'disabled' => $this->unReassignable($seat),
|
'disabled' => $seat->unavailable,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($seat_count != 0) {
|
if ($seat_count != 0) {
|
||||||
|
@ -68,17 +68,17 @@ class LicenseSeatsTransformer
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
private function unReassignable($seat)
|
// private function unReassignable($seat)
|
||||||
{
|
// {
|
||||||
if (!$seat->license->reassignable) {
|
// if (!$seat->license->reassignable) {
|
||||||
$exists = Actionlog::where('action_type', '=', 'checkin from')
|
// $exists = Actionlog::where('action_type', '=', 'checkin from')
|
||||||
->where('item_id', '=', $seat->license->id)
|
// ->where('item_id', '=', $seat->license->id)
|
||||||
->where('updated_at', '=', $seat->updated_at)
|
// ->where('updated_at', '=', $seat->updated_at)
|
||||||
->exists();
|
// ->exists();
|
||||||
if($exists) {
|
// if($exists) {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -653,6 +653,7 @@ class License extends Depreciable
|
||||||
{
|
{
|
||||||
return $this->licenseseats()
|
return $this->licenseseats()
|
||||||
->whereNull('deleted_at')
|
->whereNull('deleted_at')
|
||||||
|
->where('unavailable', '=', 0)
|
||||||
->where(function ($query) {
|
->where(function ($query) {
|
||||||
$query->whereNull('assigned_to')
|
$query->whereNull('assigned_to')
|
||||||
->whereNull('asset_id');
|
->whereNull('asset_id');
|
||||||
|
|
|
@ -284,15 +284,6 @@ class LicensePresenter extends Presenter
|
||||||
'title' => trans('general.notes'),
|
'title' => trans('general.notes'),
|
||||||
'formatter' => 'notesFormatter'
|
'formatter' => 'notesFormatter'
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'field' => 'reassignable',
|
|
||||||
'searchable' => false,
|
|
||||||
'sortable' => false,
|
|
||||||
'visible' => true,
|
|
||||||
'title' => trans('admin/licenses/form.reassignable'),
|
|
||||||
'formatter' => 'trueFalseFormatter',
|
|
||||||
'class' => 'text-center',
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'field' => 'checkincheckout',
|
'field' => 'checkincheckout',
|
||||||
'searchable' => false,
|
'searchable' => false,
|
||||||
|
|
|
@ -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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue