mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
allows checkin of unreassignable license seats
This commit is contained in:
parent
587449ef97
commit
8a0ed49623
|
@ -69,12 +69,7 @@ class LicenseCheckinController extends Controller
|
|||
|
||||
$this->authorize('checkout', $license);
|
||||
|
||||
if (! $license->reassignable) {
|
||||
// Not allowed to checkin
|
||||
Session::flash('error', trans('admin/licenses/message.checkin.not_reassignable') . '.');
|
||||
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = [
|
||||
|
@ -100,13 +95,16 @@ class LicenseCheckinController extends Controller
|
|||
$licenseSeat->assigned_to = null;
|
||||
$licenseSeat->asset_id = null;
|
||||
$licenseSeat->notes = $request->input('notes');
|
||||
if (! $license->reassignable) {
|
||||
$licenseSeat->notes .= "\n" . trans('admin/licenses/message.checkin.not_reassignable') . '.';
|
||||
}
|
||||
|
||||
session()->put(['redirect_option' => $request->get('redirect_option')]);
|
||||
|
||||
|
||||
// Was the asset updated?
|
||||
if ($licenseSeat->save()) {
|
||||
event(new CheckoutableCheckedIn($licenseSeat, $return_to, auth()->user(), $request->input('notes')));
|
||||
event(new CheckoutableCheckedIn($licenseSeat, $return_to, auth()->user(), $licenseSeat->notes));
|
||||
|
||||
|
||||
return redirect()->to(Helper::getRedirectOption($request, $license->id, 'Licenses'))->with('success', trans('admin/licenses/message.checkin.success'));
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Transformers;
|
||||
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\License;
|
||||
use App\Models\LicenseSeat;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
@ -48,6 +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),
|
||||
];
|
||||
|
||||
if ($seat_count != 0) {
|
||||
|
@ -66,4 +68,17 @@ class LicenseSeatsTransformer
|
|||
|
||||
return $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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ class CheckoutableListener
|
|||
$ccEmails = array_filter($adminCcEmailsArray);
|
||||
$mailable = $this->getCheckinMailType($event);
|
||||
$notifiable = $this->getNotifiables($event);
|
||||
if ($event->checkedOutTo->locale){
|
||||
if ($event->checkedOutTo?->locale){
|
||||
$mailable->locale($event->checkedOutTo->locale);
|
||||
}
|
||||
// Send email notifications
|
||||
|
|
|
@ -284,6 +284,15 @@ 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,
|
||||
|
|
|
@ -50,7 +50,7 @@ return array(
|
|||
|
||||
'checkin' => array(
|
||||
'error' => 'There was an issue checking in the license. Please try again.',
|
||||
'not_reassignable' => 'License not reassignable',
|
||||
'not_reassignable' => 'Seat has been used.',
|
||||
'success' => 'The license was checked in successfully'
|
||||
),
|
||||
|
||||
|
|
|
@ -431,13 +431,16 @@
|
|||
// Checkouts need the license ID, checkins need the specific seat ID
|
||||
|
||||
function licenseSeatInOutFormatter(value, row) {
|
||||
if(row.disabled) {
|
||||
return '<a href="{{ config('app.url') }}/licenses/' + row.id + '/checkin" class="btn btn-sm bg-purple disabled" data-tooltip="true" title="{{ trans('general.checkin_tooltip') }}">{{ trans('general.checkout') }}</a>';
|
||||
} else
|
||||
// The user is allowed to check the license seat out and it's available
|
||||
if ((row.available_actions.checkout === true) && (row.user_can_checkout === true) && ((!row.asset_id) && (!row.assigned_to))) {
|
||||
return '<a href="{{ config('app.url') }}/licenses/' + row.license_id + '/checkout/'+row.id+'" class="btn btn-sm bg-maroon" data-tooltip="true" title="{{ trans('general.checkout_tooltip') }}">{{ trans('general.checkout') }}</a>';
|
||||
} else {
|
||||
return '<a href="{{ config('app.url') }}/licenses/' + row.id + '/checkin" class="btn btn-sm bg-purple" data-tooltip="true" title="{{ trans('general.checkin_tooltip') }}">{{ trans('general.checkin') }}</a>';
|
||||
}
|
||||
|
||||
else {
|
||||
return '<a href="{{ config('app.url') }}/licenses/' + row.id + '/checkin" class="btn btn-sm bg-purple" data-tooltip="true" title="{{ trans('general.checkin_tooltip') }}">{{ trans('general.checkin') }}</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function genericCheckinCheckoutFormatter(destination) {
|
||||
|
|
Loading…
Reference in a new issue