Added visual on the hardware view screen

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-05-15 14:56:52 +01:00
parent ab8b40745e
commit 71b5bf2eef
3 changed files with 38 additions and 1 deletions

View file

@ -907,6 +907,23 @@ class Asset extends Depreciable
} }
/**
* Determine whether this asset's next audit date is before the last audit date
*
* @return bool
* @since [v6.4.1]
* @author [A. Gianotto] [<snipe@snipe.net>]
* */
public function checkInvalidNextAuditDate()
{
if (($this->last_audit_date) && ($this->next_audit_date) && ($this->last_audit_date > $this->next_audit_date)) {
return true;
}
return false;
}
/** /**
* Checks for a category-specific EULA, and if that doesn't exist, * Checks for a category-specific EULA, and if that doesn't exist,
* checks for a settings level EULA * checks for a settings level EULA

View file

@ -9,6 +9,7 @@ return [
'no_tag' => 'No asset tag provided.', 'no_tag' => 'No asset tag provided.',
'does_not_exist_or_not_requestable' => 'That asset does not exist or is not requestable.', 'does_not_exist_or_not_requestable' => 'That asset does not exist or is not requestable.',
'assoc_users' => 'This asset is currently checked out to a user and cannot be deleted. Please check the asset in first, and then try deleting again. ', 'assoc_users' => 'This asset is currently checked out to a user and cannot be deleted. Please check the asset in first, and then try deleting again. ',
'warning_audit_date_mismatch' => 'This asset\'s next audit date (:next_audit_date) is before the last audit date (:last_audit_date). Please update the next audit date.',
'create' => [ 'create' => [
'error' => 'Asset was not created, please try again. :(', 'error' => 'Asset was not created, please try again. :(',

View file

@ -19,6 +19,23 @@
</div> </div>
@endif @endif
@if ($asset->checkInvalidNextAuditDate())
<div class="col-md-12">
<div class="callout callout-warning">
<p><strong>{{ trans('general.warning',
[
'warning' => trans('admin/hardware/message.warning_audit_date_mismatch',
[
'last_audit_date' => Helper::getFormattedDateObject($asset->last_audit_date, 'date', false),
'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date, 'date', false)
]
)
]
) }}</strong></p>
</div>
</div>
@endif
@if ($asset->deleted_at!='') @if ($asset->deleted_at!='')
<div class="col-md-12"> <div class="col-md-12">
<div class="alert alert-danger"> <div class="alert alert-danger">
@ -237,7 +254,8 @@
</strong> </strong>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
{{ \App\Helpers\Helper::getFormattedDateObject($audit_log->created_at, 'date', false) }} {!! $asset->checkInvalidNextAuditDate() ? '<i class="fas fa-exclamation-triangle text-orange" aria-hidden="true"></i>' : '' !!}
{{ Helper::getFormattedDateObject($audit_log->created_at, 'date', false) }}
@if ($audit_log->user) @if ($audit_log->user)
(by {{ link_to_route('users.show', $audit_log->user->present()->fullname(), [$audit_log->user->id]) }}) (by {{ link_to_route('users.show', $audit_log->user->present()->fullname(), [$audit_log->user->id]) }})
@endif @endif
@ -254,6 +272,7 @@
</strong> </strong>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
{!! $asset->checkInvalidNextAuditDate() ? '<i class="fas fa-exclamation-triangle text-orange" aria-hidden="true"></i>' : '' !!}
{{ Helper::getFormattedDateObject($asset->next_audit_date, 'date', false) }} {{ Helper::getFormattedDateObject($asset->next_audit_date, 'date', false) }}
</div> </div>
</div> </div>