@extends('layout.master') @section('content')
| Crane Information | @php $months = ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D']; @endphp @foreach($months as $month){{ $month }} | @endforeachAvg |
|---|---|---|
|
{{ $crane->tag_no ?? 'N/A' }}
{{ $crane->platform ?? 'N/A' }}
@if($craneStatus === 'Active')
A
@else
I
@endif
|
@for($month = 1; $month <= 12; $month++)
@php
// SAFE ACCESS: Check if month data exists
$availabilityPercentage = 0;
$monthTitle = 'No data';
if (isset($craneYearlyData[$month])) {
$monthData = $craneYearlyData[$month];
$availabilityPercentage = $monthData['percentage'] ?? 0;
$monthTitle = ($monthData['operational_days'] ?? 0) . ' operational days out of ' . ($monthData['total_days'] ?? 0);
}
// Determine color based on percentage
$bgColor = 'bg-secondary';
$statusClass = 'no_data';
if ($availabilityPercentage > 0) {
if ($availabilityPercentage >= 90) {
$bgColor = 'bg-success';
$statusClass = 'excellent';
} elseif ($availabilityPercentage >= 70) {
$bgColor = 'bg-warning';
$statusClass = 'good';
} else {
$bgColor = 'bg-danger';
$statusClass = 'needs_attention';
}
}
// Add to yearly total
if ($availabilityPercentage > 0) {
$yearlyTotal += $availabilityPercentage;
$yearlyCount++;
}
@endphp
{{ $availabilityPercentage > 0 ? $availabilityPercentage . '%' : '-' }} | @endfor @php // Calculate yearly average $yearlyAverage = $yearlyCount > 0 ? round($yearlyTotal / $yearlyCount, 1) : 0; // Determine color for yearly average $yearlyBgColor = 'bg-secondary'; $yearlyStatusClass = 'no_data'; if ($yearlyAverage > 0) { if ($yearlyAverage >= 90) { $yearlyBgColor = 'bg-success'; $yearlyStatusClass = 'excellent'; } elseif ($yearlyAverage >= 70) { $yearlyBgColor = 'bg-warning'; $yearlyStatusClass = 'good'; } else { $yearlyBgColor = 'bg-danger'; $yearlyStatusClass = 'needs_attention'; } } @endphp{{ $yearlyAverage > 0 ? $yearlyAverage . '%' : '-' }} |
| Crane Info | @php $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $currentMonth, $currentYear); $firstDayOfWeek = date('w', strtotime("$currentYear-$currentMonth-01")); $dayNames = ['S', 'M', 'T', 'W', 'T', 'F', 'S']; @endphp @for($day = 1; $day <= $daysInMonth; $day++) @php $dayOfWeek = ($firstDayOfWeek + $day - 1) % 7; $isWeekend = $dayOfWeek === 0 || $dayOfWeek === 6; @endphp
{{ $day }}
{{ $dayNames[$dayOfWeek] }}
|
@endfor
% |
|---|---|---|
|
{{ $crane->tag_no ?? 'N/A' }}
{{ $crane->platform ?? 'N/A' }}
@if($craneStatus === 'Active')
A
@else
I
@endif
|
@for($day = 1; $day <= $daysInMonth; $day++)
@php
$status = null;
$hasData = false;
$statusText = '•';
$title = 'No data';
$bgColor = 'bg-secondary';
$statusClass = 'no_data';
// Check if maintenance data exists for this day
if (isset($craneMaintenance[$day])) {
$dayData = $craneMaintenance[$day];
$status = $dayData->maintenance_status_id ?? null;
$hasData = true;
// Determine status display
if ($hasData && $status !== null) {
if ($status == 1) {
$bgColor = 'bg-danger';
$title = 'Maintenance Required - Day ' . $day;
$statusText = 'M';
$statusClass = 'maintenance';
} elseif ($status == 5) {
$bgColor = 'bg-success';
$title = 'Operational - Day ' . $day;
$statusText = 'O';
$statusClass = 'operational';
$operationalDays++;
} else {
$bgColor = 'bg-warning';
$title = 'Other Status (ID: ' . $status . ') - Day ' . $day;
$statusText = 'X';
$statusClass = 'other';
}
}
}
@endphp
{{ $statusText }} | @endfor @php // Calculate monthly availability percentage $availabilityPercentage = $daysInMonth > 0 ? round(($operationalDays / $daysInMonth) * 100, 1) : 0; // Determine color for percentage $percentageBgColor = 'bg-secondary'; $percentageStatusClass = 'no_data'; if ($availabilityPercentage > 0) { if ($availabilityPercentage >= 90) { $percentageBgColor = 'bg-success'; $percentageStatusClass = 'excellent'; } elseif ($availabilityPercentage >= 70) { $percentageBgColor = 'bg-warning'; $percentageStatusClass = 'good'; } else { $percentageBgColor = 'bg-danger'; $percentageStatusClass = 'needs_attention'; } } @endphp{{ $availabilityPercentage }}% |