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
|
// 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'));
|
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')));
|
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)) {
|
if (! $licenseSeat->license->is($license)) {
|
||||||
throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.mismatch')));
|
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);
|
$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>
|
</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<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) }}
|
{{ Helper::getFormattedDateObject($license->expiration_date, 'date', false) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -262,6 +267,12 @@
|
|||||||
</strong>
|
</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<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) }}
|
{{ Helper::getFormattedDateObject($license->termination_date, 'date', false) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -545,7 +556,7 @@
|
|||||||
|
|
||||||
@can('checkout', $license)
|
@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;">
|
<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" />
|
<x-icon type="checkout" />
|
||||||
@@ -558,17 +569,13 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
@else
|
@else
|
||||||
<span data-tooltip="true" title=" {{ trans('admin/licenses/general.bulk.checkout_all.disabled_tooltip') }}">
|
<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') }}">
|
||||||
<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') }}">
|
|
||||||
<x-icon type="checkout" />
|
<x-icon type="checkout" />
|
||||||
{{ trans('general.checkout') }}
|
{{ trans('general.checkout') }}
|
||||||
</a>
|
|
||||||
</span>
|
</span>
|
||||||
<span data-tooltip="true" title=" {{ trans('admin/licenses/general.bulk.checkout_all.disabled_tooltip') }}">
|
<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') }}">
|
||||||
<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') }}">
|
|
||||||
<x-icon type="checkout" />
|
<x-icon type="checkout" />
|
||||||
{{ trans('admin/licenses/general.bulk.checkout_all.button') }}
|
{{ trans('admin/licenses/general.bulk.checkout_all.button') }}
|
||||||
</a>
|
|
||||||
</span>
|
</span>
|
||||||
@endif
|
@endif
|
||||||
@endcan
|
@endcan
|
||||||
|
|||||||
Reference in New Issue
Block a user