Show warnings on the dates if expired or terminated
This commit is contained in:
@@ -40,7 +40,7 @@ class LicenseCheckoutController extends Controller
|
||||
}
|
||||
|
||||
// Make sure the license is expired or terminated
|
||||
if ($license->isInactive()){
|
||||
if ($license->isInactive()) {
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.license_is_inactive'));
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class LicenseCheckoutController extends Controller
|
||||
throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.not_enough_seats')));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (! $licenseSeat->license->is($license)) {
|
||||
throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.mismatch')));
|
||||
}
|
||||
|
||||
@@ -307,7 +307,26 @@ class License extends Depreciable
|
||||
$terminated = $this->termination_date && $this->asDateTime($this->termination_date)->startofDay()->lessThanOrEqualTo($day);
|
||||
|
||||
|
||||
return $expired || $terminated;
|
||||
return $this->isExpired() || $this->isTerminated();
|
||||
}
|
||||
|
||||
public function isExpired(): bool
|
||||
{
|
||||
$day = now()->startOfDay();
|
||||
|
||||
$expired = $this->expiration_date && $this->asDateTime($this->expiration_date)->startofDay()->lessThanOrEqualTo($day);
|
||||
|
||||
return $expired;
|
||||
}
|
||||
|
||||
public function isTerminated(): bool
|
||||
{
|
||||
$day = now()->startOfDay();
|
||||
|
||||
$terminated = $this->termination_date && $this->asDateTime($this->termination_date)->startofDay()->lessThanOrEqualTo($day);
|
||||
|
||||
|
||||
return $terminated;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -249,6 +249,11 @@
|
||||
</strong>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
@if ($license->isExpired())
|
||||
<span class="text-danger">
|
||||
<x-icon type="warning" class="text-warning" />
|
||||
</span>
|
||||
@endif
|
||||
{{ Helper::getFormattedDateObject($license->expiration_date, 'date', false) }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -262,6 +267,12 @@
|
||||
</strong>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
@if ($license->isTerminated())
|
||||
<span class="text-danger">
|
||||
<x-icon type="warning" class="text-warning" />
|
||||
</span>
|
||||
@endif
|
||||
|
||||
{{ Helper::getFormattedDateObject($license->termination_date, 'date', false) }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -545,7 +556,7 @@
|
||||
|
||||
@can('checkout', $license)
|
||||
|
||||
@if ($license->availCount()->count() > 0)
|
||||
@if (($license->availCount()->count() > 0) && (!$license->isInactive()))
|
||||
|
||||
<a href="{{ route('licenses.checkout', $license->id) }}" class="btn bg-maroon btn-sm btn-social btn-block hidden-print" style="margin-bottom: 5px;">
|
||||
<x-icon type="checkout" />
|
||||
@@ -558,17 +569,13 @@
|
||||
</a>
|
||||
|
||||
@else
|
||||
<span data-tooltip="true" title=" {{ trans('admin/licenses/general.bulk.checkout_all.disabled_tooltip') }}">
|
||||
<a href="#" class="btn bg-maroon btn-sm btn-social btn-block hidden-print disabled" style="margin-bottom: 5px;" data-tooltip="true" title="{{ trans('general.checkout') }}">
|
||||
<span data-tooltip="true" title="{{ ($license->availCount()->count() == 0) ? trans('admin/licenses/general.bulk.checkout_all.disabled_tooltip') : trans('admin/licenses/message.checkout.license_is_inactive') }}" class="btn bg-maroon btn-sm btn-social btn-block hidden-print disabled" style="margin-bottom: 5px;" data-tooltip="true" title="{{ trans('general.checkout') }}">
|
||||
<x-icon type="checkout" />
|
||||
{{ trans('general.checkout') }}
|
||||
</a>
|
||||
</span>
|
||||
<span data-tooltip="true" title=" {{ trans('admin/licenses/general.bulk.checkout_all.disabled_tooltip') }}">
|
||||
<a href="#" class="btn bg-maroon btn-sm btn-social btn-block hidden-print disabled" style="margin-bottom: 5px;" data-tooltip="true" title="{{ trans('general.checkout') }}">
|
||||
<span data-tooltip="true" title="{{ ($license->availCount()->count() == 0) ? trans('admin/licenses/general.bulk.checkout_all.disabled_tooltip') : trans('admin/licenses/message.checkout.license_is_inactive') }}" class="btn bg-maroon btn-sm btn-social btn-block hidden-print disabled" style="margin-bottom: 5px;" data-tooltip="true" title="{{ trans('general.checkout') }}">
|
||||
<x-icon type="checkout" />
|
||||
{{ trans('admin/licenses/general.bulk.checkout_all.button') }}
|
||||
</a>
|
||||
</span>
|
||||
@endif
|
||||
@endcan
|
||||
|
||||
Reference in New Issue
Block a user