mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-24 12:17:05 -08:00
Fixed some date math for auditing
This commit is contained in:
parent
42175782a5
commit
e439f15a64
|
@ -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) ? [
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue