diff --git a/app/Models/Asset.php b/app/Models/Asset.php index f21454698a..de88662836 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -333,7 +333,7 @@ class Asset extends Depreciable ); } - protected function eolDiff(): Attribute + protected function eolDiffInDays(): Attribute { return Attribute:: make( get: fn(mixed $value, array $attributes) => $this->eolDate ? round((Carbon::now()->diffInDays(Carbon::parse($this->eolDate), false, 1))) : null, diff --git a/app/Models/License.php b/app/Models/License.php index 09bc0b3038..73d7c22c3d 100755 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -165,6 +165,13 @@ class License extends Depreciable ); } + protected function terminatesDiffInDays(): Attribute + { + return Attribute:: make( + get: fn(mixed $value, array $attributes) => $attributes['termination_date'] ? Carbon::parse($attributes['termination_date'])->diffInDays() : null, + ); + } + protected function terminatesDiffForHumans(): Attribute { return Attribute:: make( @@ -172,6 +179,7 @@ class License extends Depreciable ); } + public function prepareLimitChangeRule($parameters, $field) { $actual_seat_count = $this->licenseseats()->count(); //we use the *actual* seat count here, in case your license has gone wonky diff --git a/app/Models/SnipeModel.php b/app/Models/SnipeModel.php index b9a1f1c171..37f513bf9d 100644 --- a/app/Models/SnipeModel.php +++ b/app/Models/SnipeModel.php @@ -29,13 +29,14 @@ class SnipeModel extends Model } - protected function expiresDiff(): Attribute + protected function expiresDiffInDays(): Attribute { return Attribute:: make( - get: fn(mixed $value, array $attributes) => $attributes['expiration_date'] ? round((Carbon::now()->diffInDays(Carbon::parse($attributes['expiration_date']), false, 1))) : null, + get: fn(mixed $value, array $attributes) => $attributes['expiration_date'] ? Carbon::parse($attributes['expiration_date'])->diffInDays() : null, ); } + protected function expiresDiffForHumans(): Attribute { return Attribute:: make( diff --git a/resources/views/notifications/markdown/report-expiring-assets.blade.php b/resources/views/notifications/markdown/report-expiring-assets.blade.php index be961ec620..1b35b7a309 100644 --- a/resources/views/notifications/markdown/report-expiring-assets.blade.php +++ b/resources/views/notifications/markdown/report-expiring-assets.blade.php @@ -5,7 +5,7 @@ | | | | | ------------- | ------------- | ------------- | @foreach ($assets as $asset) -| {{ ($asset->eol_diff_for_humans <= ($threshold / 2)) ? 'đ¨' : (($asset->eol_diff_for_humans <= $threshold) ? 'â ī¸' : ' ') }} **{{ trans('mail.name') }}** | {{ $asset->display_name }} | +| {{ ($asset->eol_diff_in_days <= ($threshold / 2)) ? 'đ¨' : (($asset->eol_diff_in_days <= $threshold) ? 'â ī¸' : 'âšī¸ ') }} **{{ trans('mail.name') }}** | {{ $asset->display_name }} | @if ($asset->serial) | **{{ trans('general.serial_number') }}** | {{ $asset->serial }} | @endif diff --git a/resources/views/notifications/markdown/report-expiring-licenses.blade.php b/resources/views/notifications/markdown/report-expiring-licenses.blade.php index e165e74433..e5445cd50e 100644 --- a/resources/views/notifications/markdown/report-expiring-licenses.blade.php +++ b/resources/views/notifications/markdown/report-expiring-licenses.blade.php @@ -6,7 +6,7 @@ | | {{ trans('mail.name') }} | {{ trans('mail.expires') }} | {{ trans('mail.terminates') }} | | :------------- | :------------- | :------------- | :------------- | @foreach ($licenses as $license) -| {{ ($license->expires_diff_for_humans <= ($threshold / 2)) ? 'đ¨' : (($license->expires_diff_for_humans <= $threshold) ? 'â ī¸' : ' ') }} | {{ $license->name }} | {{ $license->expires_formatted_date }} {!! $license->expires_diff_for_humans ? ' ('.$license->expires_diff_for_humans .')' : '' !!} | {{ $license->terminates_formatted_date }} {!! $license->terminates_diff_for_humans ? ' ('.$license->terminates_diff_for_humans .')' : '' !!} | +| {{ (($license->isExpired()) || ($license->isTerminated())) ? 'đ¨' : (($license->expires_diff_in_days <= $threshold) ? 'â ī¸' : 'âšī¸ ') }} | {{ $license->name }} | {{ $license->expires_formatted_date }} {!! $license->expires_diff_for_humans ? ' ('.$license->expires_diff_for_humans .')' : '' !!} | {{ $license->terminates_formatted_date }} {!! $license->terminates_diff_for_humans ? ' ('.$license->terminates_diff_for_humans .')' : '' !!} | |