@extends('layouts/default')
{{-- Page title --}}
@section('title')
{{ trans('admin/maintenances/general.view') }} {{ $maintenance->name }}
@parent
@stop
@section('header_right')
@endsection
{{-- Page content --}}
@section('content')
{!! $maintenance->asset?->present()->nameUrl !!}
{{ trans('admin/maintenances/form.asset_maintenance_type') }}
{{ $maintenance->asset_maintenance_type }}
{{ $maintenance->asset?->asset_tag }}
{!! $maintenance->asset?->model?->present()->nameUrl !!}
{{ $maintenance->asset?->model?->model_number }}
{{ Helper::getFormattedDateObject($maintenance->start_date, 'date', false) }}
@if ($maintenance->completion_date)
{{ Helper::getFormattedDateObject($maintenance->completion_date, 'date', false) }}
@else
{{ trans('admin/maintenances/message.asset_maintenance_incomplete') }}
@endif
@if ($maintenance->asset_maintenance_time)
{{ $maintenance->asset_maintenance_time }} {{ trans('general.days') }}
@endif
{{ $snipeSettings->default_currency .' '. Helper::formatCurrencyOutput($maintenance->cost) }}
@if ($maintenance->is_warranty=='1')
{{ trans('general.yes') }}
@else
{{ trans('general.no') }}
@endif
@php
$startCarbon = $maintenance->start_date ? Carbon::parse($maintenance->start_date) : null;
$endCarbon = $maintenance->completion_date
? Carbon::parse($maintenance->completion_date)
: null;
$maintenancePercent = 0;
if ($startCarbon) {
$progressLabel = App\Helpers\Helper::getFormattedDateObject($maintenance->start_date, 'date', false);
if ($endCarbon) {
$progressLabel .= ' - '.App\Helpers\Helper::getFormattedDateObject($maintenance->completion_date, 'date', false);;
// Completed: show how far through the total duration we are as of today
$totalDays = max(1, $startCarbon->diffInDays($endCarbon));
$elapsedDays = min($totalDays, $startCarbon->diffInDays(Carbon::now()));
$maintenancePercent = min(100, max(0, ($elapsedDays / $totalDays) * 100));
} else {
// In progress: base on days elapsed since start_date relative to 30-day window
$elapsedDays = $startCarbon->diffInDays(Carbon::now());
$maintenancePercent = min(100, max(0, ($elapsedDays / 30) * 100));
}
}
@endphp
@endsection
@section('moar_scripts')
@can('files', $maintenance)
@include ('modals.upload-file', ['item_type' => 'maintenances', 'item_id' => $maintenance->id])
@endcan
@include ('partials.bootstrap-table')
@endsection