mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-23 19:59:18 -08:00
Shored up the date math, updated the explanation
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
ea429d650e
commit
5fe999eb02
|
@ -627,26 +627,24 @@ class SettingsController extends Controller
|
|||
if ($request->input('audit_interval') != $setting->audit_interval) {
|
||||
|
||||
// Be careful - this could be a negative number
|
||||
$audit_diff_months = ($setting->audit_interval - (int)$request->input('audit_interval'));
|
||||
$audit_diff_months = ((int)$request->input('audit_interval') - (int)($setting->audit_interval));
|
||||
|
||||
\Log::error('we need to update audit dates');
|
||||
\Log::error('Audit difference: '.$audit_diff_months);
|
||||
\Log::debug('We need to update audit dates. Interval is changing from '.$setting->audit_interval.' to '.$request->input('audit_interval'));
|
||||
\Log::debug('Audit difference: '.$audit_diff_months);
|
||||
|
||||
$assets = Asset::whereNotNull('next_audit_date')->take(10)->get();
|
||||
$assets = Asset::whereNotNull('next_audit_date')->get();
|
||||
|
||||
foreach ($assets as $asset) {
|
||||
|
||||
if ($asset->next_audit_date != '') {
|
||||
|
||||
$old_next_audit = Carbon::parse($asset->next_audit_date);
|
||||
\Log::error('Old audit date: '.$old_next_audit);
|
||||
\Log::error('Adding '.$audit_diff_months.' months');
|
||||
$old_next_audit = new \DateTime($asset->next_audit_date);
|
||||
\Log::debug('Old audit date: '.$old_next_audit->format('Y-m-d'));
|
||||
\Log::debug('Adding '.$audit_diff_months.' months');
|
||||
|
||||
$new_next_audit = $old_next_audit->addMonths($audit_diff_months)->format('Y-m-d');
|
||||
$asset->next_audit_date = $old_next_audit->modify($audit_diff_months.' month')->format('Y-m-d');
|
||||
|
||||
\Log::error('New audit date: '.$new_next_audit);
|
||||
|
||||
$asset->next_audit_date = $new_next_audit;
|
||||
\Log::debug('New audit date: '.$asset->next_audit_date->format('Y-m-d'));
|
||||
$asset->forceSave();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
return [
|
||||
'ad' => 'Active Directory',
|
||||
'update_null_audits' => 'Also update audit dates on assets without a current next audit date set based on purchase date (if present)',
|
||||
'ad_domain' => 'Active Directory domain',
|
||||
'ad_domain_help' => 'This is sometimes the same as your email domain, but not always.',
|
||||
'ad_append_domain_label' => 'Append domain name',
|
||||
|
@ -21,7 +22,7 @@ return [
|
|||
'allow_user_skin_help_text' => 'Checking this box will allow a user to override the UI skin with a different one.',
|
||||
'asset_ids' => 'Asset IDs',
|
||||
'audit_interval' => 'Audit Interval',
|
||||
'audit_interval_help' => 'If you are required to regularly physically audit your assets, enter the interval in months.',
|
||||
'audit_interval_help' => 'If you are required to regularly physically audit your assets, enter the interval in months that you use. If you update this value, all of the "next audit dates" for assets with an upcoming audit date.',
|
||||
'audit_warning_days' => 'Audit Warning Threshold',
|
||||
'audit_warning_days_help' => 'How many days in advance should we warn you when assets are due for auditing?',
|
||||
'auto_increment_assets' => 'Generate auto-incrementing asset tags',
|
||||
|
|
Loading…
Reference in a new issue