@extends('layout.master') @section('content')

Lifting Equipment Availability (LEA)

Filters
@php $months = ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D']; @endphp @foreach($months as $month) @endforeach @foreach($cranes as $crane) @php $yearlyTotal = 0; $yearlyCount = 0; $craneStatus = $crane->status_crane ?? 'Inactive'; // SAFE ACCESS: Check if data exists for this crane $craneYearlyData = $yearlyData[$crane->id] ?? []; @endphp @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 @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 @endforeach
Crane Information {{ $month }} Avg
{{ $crane->tag_no ?? 'N/A' }}
{{ $crane->platform ?? 'N/A' }} @if($craneStatus === 'Active') A @else I @endif
{{ $availabilityPercentage > 0 ? $availabilityPercentage . '%' : '-' }} {{ $yearlyAverage > 0 ? $yearlyAverage . '%' : '-' }}
Showing all {{ count($cranes) }} results
Hover for details
@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 @endfor @foreach($cranes as $crane) @php // Get maintenance data safely $craneMaintenance = isset($maintenanceData[$crane->id]) ? $maintenanceData[$crane->id] : []; $operationalDays = 0; $craneStatus = $crane->status_crane ?? 'Inactive'; @endphp @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 @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 @endforeach
Crane Info
{{ $day }}
{{ $dayNames[$dayOfWeek] }}
%
{{ $crane->tag_no ?? 'N/A' }}
{{ $crane->platform ?? 'N/A' }} @if($craneStatus === 'Active') A @else I @endif
{{ $statusText }} {{ $availabilityPercentage }}%
Showing all {{ count($cranes) }} results
Hover for details • O=Operational, M=Maintenance, X=Other, •=No Data
Legend
Operational (O)
Maintenance (M)
Other (X)
No Data (•)
@endsection