diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.php index 31d9b74bbf..a14910208e 100755 --- a/app/Models/Actionlog.php +++ b/app/Models/Actionlog.php @@ -293,16 +293,22 @@ class Actionlog extends SnipeModel public function daysUntilNextAudit($monthInterval = 12, $asset = null) { $now = Carbon::now(); - $last_audit_date = $this->created_at; - $next_audit = $last_audit_date->addMonth($monthInterval); - $next_audit_days = $now->diffInDays($next_audit); + $last_audit_date = $this->created_at; // this is the action log's created at, not the asset itself + $next_audit = $last_audit_date->addMonth($monthInterval); // this actually *modifies* the $last_audit_date + $next_audit_days = round($now->diffInDays($next_audit, true)); + $override_default_next = $next_audit; // Override the default setting for interval if the asset has its own next audit date if (($asset) && ($asset->next_audit_date)) { - $override_default_next = \Carbon::parse($asset->next_audit_date); - $next_audit_days = $override_default_next->diffInDays($now); + $override_default_next = Carbon::parse($asset->next_audit_date); + $next_audit_days = round($override_default_next->diffInDays($now, true)); } + // Show as negative number if the next audit date is before the audit date we're looking at + if ($this->created_at > $override_default_next) { + $next_audit_days = '-'.$next_audit_days; + } + return $next_audit_days; } diff --git a/resources/views/reports/audit.blade.php b/resources/views/reports/audit.blade.php index 729fe4e015..3dc16137f1 100644 --- a/resources/views/reports/audit.blade.php +++ b/resources/views/reports/audit.blade.php @@ -35,13 +35,12 @@ {{ trans('admin/hardware/table.image') }} - {{ trans('general.audit') }} - {{ trans('general.admin') }} + {{ trans('general.created_by') }} {{ trans('general.item') }} {{ trans('general.location') }} + {{ trans('general.last_audit') }} {{ trans('general.next_audit_date') }} {{ trans('general.days_to_next_audit') }} - {{ trans('general.notes') }}