diff --git a/app/Http/Transformers/ActionlogsTransformer.php b/app/Http/Transformers/ActionlogsTransformer.php index 80b133c57a..2de8b75e5b 100644 --- a/app/Http/Transformers/ActionlogsTransformer.php +++ b/app/Http/Transformers/ActionlogsTransformer.php @@ -37,7 +37,7 @@ class ActionlogsTransformer ] : null, 'created_at' => Helper::getFormattedDateObject($actionlog->created_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($actionlog->updated_at, 'datetime'), - 'next_audit_date' => ($actionlog->itemType()=='asset') ? Helper::getFormattedDateObject($actionlog->item->next_audit_date, 'date'): null, + 'next_audit_date' => ($actionlog->itemType()=='asset') ? Helper::getFormattedDateObject($actionlog->calcNextAuditDate(), 'date'): null, 'days_to_next_audit' => $actionlog->daysUntilNextAudit($settings->audit_interval, $actionlog->item), 'action_type' => $actionlog->present()->actionType(), 'admin' => ($actionlog->user) ? [ diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.php index b8bed75ceb..260257125d 100755 --- a/app/Models/Actionlog.php +++ b/app/Models/Actionlog.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Facades\Auth; use Response; +use Carbon; /** * Model for the Actionlog (the table that keeps a historical log of @@ -179,16 +180,13 @@ class Actionlog extends SnipeModel $monthInterval = 12; } - $dt = \Carbon::now()->addMonths(12)->toDateString(); $last_audit_date = Carbon::parse($this->created_at); - // If there is an asset-specific next date already given, if (($asset) && ($asset->next_audit_date)) { - return \Carbon::parse($asset->next_audit_date);; + return \Carbon::parse($asset->next_audit_date); } - $next_audit_date = \Carbon::now()->addMonths($monthInterval)->toDateString(); - $next_audit_date = $last_audit_date->diffInDays($last_audit_date->copy()->addMonth($monthInterval)); + return \Carbon::parse($last_audit_date)->addMonths($monthInterval)->toDateString(); } /**