Merge pull request #11608 from snipe/features/add_time_diff_to_eol
Added time diff to EOL in asset view
This commit is contained in:
commit
5fe8db541e
5 changed files with 33 additions and 32 deletions
|
@ -789,7 +789,7 @@ class ReportsController extends Controller
|
|||
|
||||
if ($request->filled('warranty')) {
|
||||
$row[] = ($asset->warranty_months) ? $asset->warranty_months : '';
|
||||
$row[] = $asset->present()->warrantee_expires();
|
||||
$row[] = $asset->present()->warranty_expires();
|
||||
}
|
||||
|
||||
if ($request->filled('depreciation')) {
|
||||
|
|
|
@ -498,10 +498,10 @@ class AssetPresenter extends Presenter
|
|||
}
|
||||
|
||||
/**
|
||||
* Date the warantee expires.
|
||||
* Date the warranty expires.
|
||||
* @return false|string
|
||||
*/
|
||||
public function warrantee_expires()
|
||||
public function warranty_expires()
|
||||
{
|
||||
if (($this->purchase_date) && ($this->warranty_months)) {
|
||||
$date = date_create($this->purchase_date);
|
||||
|
|
|
@ -371,7 +371,7 @@ class DepreciationReportPresenter extends Presenter
|
|||
* Date the warantee expires.
|
||||
* @return false|string
|
||||
*/
|
||||
public function warrantee_expires()
|
||||
public function warranty_expires()
|
||||
{
|
||||
if (($this->purchase_date) && ($this->warranty_months)) {
|
||||
$date = date_create($this->purchase_date);
|
||||
|
|
|
@ -574,7 +574,7 @@
|
|||
|
||||
|
||||
@if ($asset->warranty_months)
|
||||
<div class="row{!! $asset->present()->warrantee_expires() < date("Y-m-d") ? ' warning' : '' !!}">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<strong>
|
||||
{{ trans('admin/hardware/form.warranty') }}
|
||||
|
@ -584,10 +584,26 @@
|
|||
{{ $asset->warranty_months }}
|
||||
{{ trans('admin/hardware/form.months') }}
|
||||
|
||||
({{ trans('admin/hardware/form.expires') }}
|
||||
{{ $asset->present()->warrantee_expires() }})
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<strong>
|
||||
{{ trans('admin/hardware/form.warranty_expires') }}
|
||||
{!! $asset->present()->warranty_expires() < date("Y-m-d") ? '<i class="fas fa-exclamation-triangle text-orange" aria-hidden="true"></i>' : '' !!}
|
||||
</strong>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
{{ Helper::getFormattedDateObject($asset->present()->warranty_expires(), 'date', false) }}
|
||||
-
|
||||
{{ Carbon::parse($asset->present()->warranty_expires())->diffForHumans() }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
|
||||
@if (($asset->model) && ($asset->depreciation))
|
||||
|
@ -600,8 +616,7 @@
|
|||
<div class="col-md-6">
|
||||
{{ $asset->depreciation->name }}
|
||||
({{ $asset->depreciation->months }}
|
||||
{{ trans('admin/hardware/form.months') }}
|
||||
)
|
||||
{{ trans('admin/hardware/form.months') }})
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -611,13 +626,10 @@
|
|||
</strong>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
@if ($asset->time_until_depreciated()->y > 0)
|
||||
{{ $asset->time_until_depreciated()->y }}
|
||||
{{ trans('admin/hardware/form.years') }},
|
||||
@endif
|
||||
{{ $asset->time_until_depreciated()->m }}
|
||||
{{ trans('admin/hardware/form.months') }}
|
||||
({{ $asset->depreciated_date()->format('Y-m-d') }})
|
||||
{{ Helper::getFormattedDateObject($asset->depreciated_date()->format('Y-m-d'), 'date', false) }}
|
||||
-
|
||||
{{ Carbon::parse($asset->depreciated_date())->diffForHumans() }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
@ -644,20 +656,9 @@
|
|||
</div>
|
||||
<div class="col-md-6">
|
||||
{{ Helper::getFormattedDateObject($asset->present()->eol_date(), 'date', false) }}
|
||||
|
||||
|
||||
@if ($asset->present()->months_until_eol())
|
||||
-
|
||||
@if ($asset->present()->months_until_eol()->y > 0)
|
||||
{{ $asset->present()->months_until_eol()->y }}
|
||||
{{ trans('general.years') }},
|
||||
@endif
|
||||
|
||||
{{ $asset->present()->months_until_eol()->m }}
|
||||
{{ trans('general.months') }}
|
||||
|
||||
@endif
|
||||
|
||||
-
|
||||
{{ Carbon::parse($asset->present()->eol_date())->diffForHumans() }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<tr><td> </td><td>{{ trans('mail.name') }}</td><td>{{ trans('mail.Days') }}</td><td>{{ trans('mail.expires') }}</td><td>{{ trans('mail.supplier') }}</td><td>{{ trans('mail.assigned_to') }}</td></tr>
|
||||
@foreach ($assets as $asset)
|
||||
@php
|
||||
$expires = Helper::getFormattedDateObject($asset->present()->warrantee_expires, 'date');
|
||||
$diff = round(abs(strtotime($asset->present()->warrantee_expires) - strtotime(date('Y-m-d')))/86400);
|
||||
$expires = Helper::getFormattedDateObject($asset->present()->warranty_expires, 'date');
|
||||
$diff = round(abs(strtotime($asset->present()->warranty_expires) - strtotime(date('Y-m-d')))/86400);
|
||||
$icon = ($diff <= ($threshold / 2)) ? '🚨' : (($diff <= $threshold) ? '⚠️' : ' ');
|
||||
@endphp
|
||||
<tr><td>{{ $icon }} </td><td> <a href="{{ route('hardware.show', $asset->id) }}">{{ $asset->present()->name }}</a> </td><td> {{ $diff }} {{ trans('mail.Days') }} </td><td> {{ $expires['formatted'] }} </td><td> {{ ($asset->supplier ? e($asset->supplier->name) : '') }} </td><td> {{ ($asset->assignedTo ? e($asset->assignedTo->present()->name()) : '') }} </td></tr>
|
||||
|
|
Loading…
Add table
Reference in a new issue