A free open source IT asset/license management system
Audit Log Number under Days to next Audit [sc-28530]
snipe16420b1e00cf
diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.phpindex 31d9b74bbf..a14910208e 100755--- a/app/Models/Actionlog.php+++ b/app/Models/Actionlog.php@@ -293,16 +293,22 @@ class Actionlog extends SnipeModelpublic 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 dateif (($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.phpindex 729fe4e015..3dc16137f1 100644--- a/resources/views/reports/audit.blade.php+++ b/resources/views/reports/audit.blade.php@@ -35,13 +35,12 @@<thead><tr><th class="col-sm-1" data-field="file" data-visible="false" data-formatter="auditImageFormatter">{{ trans('admin/hardware/table.image') }}</th>- <th class="col-sm-2" data-field="created_at" data-formatter="dateDisplayFormatter" data-sortable="true" data-searchable="true">{{ trans('general.audit') }}</th>- <th class="col-sm-2" data-field="created_by" data-sortable="true" data-searchable="true" data-formatter="usersLinkObjFormatter">{{ trans('general.admin') }}</th>+ <th class="col-sm-2" data-field="created_by" data-sortable="true" data-searchable="true" data-formatter="usersLinkObjFormatter">{{ trans('general.created_by') }}</th><th class="col-sm-2" data-field="item" data-sortable="true" data-searchable="true" data-formatter="polymorphicItemFormatter">{{ trans('general.item') }}</th><th class="col-sm-1" data-field="location" data-sortable="true" data-searchable="true" data-formatter="locationsLinkObjFormatter">{{ trans('general.location') }}</th>+ <th class="col-sm-2" data-field="created_at" data-formatter="dateDisplayFormatter" data-sortable="true" data-searchable="true">{{ trans('general.last_audit') }}</th><th class="col-sm-2" data-field="next_audit_date" data-formatter="dateDisplayFormatter">{{ trans('general.next_audit_date') }}</th><th class="col-sm-1" data-field="days_to_next_audit">{{ trans('general.days_to_next_audit') }}</th>-<th class="col-sm-2" data-field="note" data-sortable="true" data-searchable="true">{{ trans('general.notes') }}</th></tr></thead>