mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
updated column name, updated Api license checkin and out
This commit is contained in:
parent
344b4e7d60
commit
f47a2b10c0
|
@ -1535,7 +1535,7 @@ class Helper
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!$license->reassignable) {
|
if (!$license->reassignable) {
|
||||||
$count = LicenseSeat::where('unavailable', '=', true)
|
$count = LicenseSeat::where('dead', '=', true)
|
||||||
->where('license_id', '=', $license->id)
|
->where('license_id', '=', $license->id)
|
||||||
->count();
|
->count();
|
||||||
return $count;
|
return $count;
|
||||||
|
|
|
@ -119,7 +119,9 @@ class LicenseSeatsController extends Controller
|
||||||
// nothing to update
|
// nothing to update
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));
|
||||||
}
|
}
|
||||||
|
if( $touched && $licenseSeat->dead) {
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', $licenseSeat, trans('admin/licenses/message.checkout.unavailable')));
|
||||||
|
}
|
||||||
// the logging functions expect only one "target". if both asset and user are present in the request,
|
// the logging functions expect only one "target". if both asset and user are present in the request,
|
||||||
// we simply let assets take precedence over users...
|
// we simply let assets take precedence over users...
|
||||||
if ($licenseSeat->isDirty('assigned_to')) {
|
if ($licenseSeat->isDirty('assigned_to')) {
|
||||||
|
@ -137,6 +139,10 @@ class LicenseSeatsController extends Controller
|
||||||
|
|
||||||
if ($is_checkin) {
|
if ($is_checkin) {
|
||||||
$licenseSeat->logCheckin($target, $request->input('note'));
|
$licenseSeat->logCheckin($target, $request->input('note'));
|
||||||
|
if(!$licenseSeat->license->ressignable){
|
||||||
|
$licenseSeat->dead = 1;
|
||||||
|
$licenseSeat->save();
|
||||||
|
}
|
||||||
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));
|
return response()->json(Helper::formatStandardApiResponse('success', $licenseSeat, trans('admin/licenses/message.update.success')));
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +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 (! $licenseSeat->license->reassignable) {
|
if (! $licenseSeat->license->reassignable) {
|
||||||
$licenseSeat->unavailable = 1;
|
$licenseSeat->dead = 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' => $seat->unavailable,
|
'disabled' => $seat->dead,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($seat_count != 0) {
|
if ($seat_count != 0) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ class LicenseSeatFactory extends Factory
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'license_id' => License::factory(),
|
'license_id' => License::factory(),
|
||||||
'unavailable' => 0,
|
'dead' => 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ return new class extends Migration
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::table('license_seats', function (Blueprint $table) {
|
Schema::table('license_seats', function (Blueprint $table) {
|
||||||
$table->addColumn('boolean', 'unavailable')->default(false)->after('assigned_to');
|
$table->addColumn('boolean', 'dead')->default(false)->after('assigned_to');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -22,8 +22,8 @@ return new class extends Migration
|
||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::table('license_seats_tables', function (Blueprint $table) {
|
Schema::table('license_seats', function (Blueprint $table) {
|
||||||
$table->dropColumn('unavailable');
|
$table->dropColumn('dead');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,7 @@ class LicenseCheckinTest extends TestCase
|
||||||
|
|
||||||
$licenseSeat->refresh();
|
$licenseSeat->refresh();
|
||||||
|
|
||||||
$this->assertEquals(1, $licenseSeat->unavailable);
|
$this->assertEquals(1, $licenseSeat->dead);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCannotCheckinLicenseThatIsNotAssigned()
|
public function testCannotCheckinLicenseThatIsNotAssigned()
|
||||||
|
|
Loading…
Reference in a new issue