mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Added scope for both overdue and upcoming
This commit is contained in:
parent
00a8a2aff3
commit
e4a298ca2a
|
@ -58,7 +58,7 @@ class SendUpcomingAuditReport extends Command
|
|||
// Assets due for auditing
|
||||
|
||||
$assets = Asset::whereNotNull('next_audit_date')
|
||||
->dueForAudit($settings)
|
||||
->DueOrOverdueForAudit($settings)
|
||||
->orderBy('last_audit_date', 'asc')->get();
|
||||
|
||||
if ($assets->count() > 0) {
|
||||
|
|
|
@ -153,7 +153,7 @@ class AssetsController extends Controller
|
|||
|
||||
switch ($audit) {
|
||||
case 'due':
|
||||
$assets->DueForAudit($settings);
|
||||
$assets->DueOrOverdueForAudit($settings);
|
||||
break;
|
||||
case 'overdue':
|
||||
$assets->overdueForAudit($settings);
|
||||
|
|
|
@ -850,6 +850,29 @@ class Asset extends Depreciable
|
|||
->NotArchived();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope for Assets that are due for auditing OR overdue, based on the assets.next_audit_date
|
||||
* and settings.audit_warning_days.
|
||||
*
|
||||
* This is/will be used in the artisan command snipeit:upcoming-audits and also
|
||||
* for an upcoming API call for retrieving a report on assets that will need to be audited.
|
||||
*
|
||||
* @author A. Gianotto <snipe@snipe.net>
|
||||
* @since v4.5.17
|
||||
* @param Setting $settings
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
|
||||
public function scopeDueOrOverdueForAudit($query, $settings)
|
||||
{
|
||||
return $query->whereNotNull('assets.next_audit_date')
|
||||
->whereRaw("DATE_SUB(assets.next_audit_date, INTERVAL $settings->audit_warning_days DAY) <= '".Carbon::now()."'")
|
||||
->where('assets.archived', '=', 0)
|
||||
->NotArchived();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope for Archived assets
|
||||
*
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
@php
|
||||
$next_audit_date = \App\Helpers\Helper::getFormattedDateObject($asset->next_audit_date, 'date', false);
|
||||
$last_audit_date = \App\Helpers\Helper::getFormattedDateObject($asset->last_audit_date, 'date', false);
|
||||
$diff = Carbon::parse($next_audit_date)->diffInDays(Carbon::now());
|
||||
$diff = Carbon::parse(Carbon::now())->diffInDays($next_audit_date, false);
|
||||
$icon = ($diff <= 7) ? '🚨' : (($diff <= 14) ? '⚠️' : ' ');
|
||||
@endphp
|
||||
|{{ $icon }}| [{{ $asset->present()->name }}]({{ route('hardware.show', $asset->id) }}) | {{ $last_audit_date }}| {{ $next_audit_date }} | {{ $diff }} | {{ ($asset->supplier ? e($asset->supplier->name) : '') }}|{{ ($asset->assignedTo ? $asset->assignedTo->present()->name() : '') }}
|
||||
|
|
Loading…
Reference in a new issue