@extends('layouts.vertical-individual', ['page_title' => $title ?? 'Adherence Pack Ratio Report']) @section('css') @endsection @section('content') @php $pagination = $pagination ?? (object) ['page' => 1, 'per_page' => 50, 'total' => 0, 'total_pages' => 0]; $currentPage = (int) ($pagination->page ?? 1); $totalPages = (int) ($pagination->total_pages ?? 0); $perPage = (int) ($perPage ?? $pagination->per_page ?? 50); $totalTms = (int) ($pagination->total ?? 0); $search = trim((string) ($search ?? '')); $type = $type ?? 'dpi'; $quartersOnly = !empty($quartersOnly); $quarters = $quarters ?? []; $quarter_data = $quarter_data ?? (object) []; $months = $months ?? []; $metrics = $metrics ?? []; $quartersAfterMonth = []; if (!$quartersOnly) { foreach ($quarters as $quarter) { $afterMonth = $quarter->after_month ?? null; if ($afterMonth) { $quartersAfterMonth[$afterMonth][] = $quarter; } } } $pageQuery = http_build_query(array_filter([ 'token' => $token, 'type' => $type, 'per_page' => $perPage, 'search' => $search, ])); $pageBase = $base_url . '/report?' . $pageQuery; $metaColumnCount = 1; @endphp
Loading report...
@include('adherencepackratioreport._pagination', ['paginationPosition' => 'adherence-pack-ratio-report-pagination-top'])
@if ($quartersOnly) @foreach ($quarters as $quarter) @endforeach @else @foreach ($months as $month) @foreach ($quartersAfterMonth[$month->key ?? ''] ?? [] as $quarter) @endforeach @endforeach @foreach ($months as $month) @foreach ($metrics as $metric) @endforeach @endforeach @endif @forelse ($tms as $tm) @php $tmQuarterData = is_object($quarter_data) ? ($quarter_data->{$tm->id} ?? null) : null; $parseRatio = function ($value) { // Missing/blank values count as 0 for highlight comparisons only. if ($value === null || $value === '' || $value === '-') { return 0.0; } if (is_numeric($value)) { return (float) $value; } $normalized = preg_replace('/[^0-9.\-]/', '', (string) $value); return $normalized === '' || !is_numeric($normalized) ? 0.0 : (float) $normalized; }; $prevQuarterRatio = null; $hasPrevQuarter = false; @endphp @if ($quartersOnly) @foreach ($quarters as $quarter) @php $quarterKey = $quarter->key ?? ''; $qValue = is_object($tmQuarterData) ? ($tmQuarterData->{$quarterKey} ?? null) : null; $currentRatio = $parseRatio($qValue); $ratioClass = ''; if ($hasPrevQuarter) { $ratioClass = $currentRatio >= $prevQuarterRatio ? 'ratio-up' : 'ratio-down'; } $prevQuarterRatio = $currentRatio; $hasPrevQuarter = true; @endphp @endforeach @else @foreach ($months as $month) @php $monthKey = $month->key ?? ''; $tmData = $data->{$tm->id} ?? null; $monthData = is_object($tmData) ? ($tmData->{$monthKey} ?? null) : null; @endphp @foreach ($metrics as $metric) @php $metricId = $metric->id ?? ''; $value = is_object($monthData) ? ($monthData->{$metricId} ?? null) : null; @endphp @endforeach @foreach ($quartersAfterMonth[$monthKey] ?? [] as $quarter) @php $quarterKey = $quarter->key ?? ''; $qValue = is_object($tmQuarterData) ? ($tmQuarterData->{$quarterKey} ?? null) : null; $currentRatio = $parseRatio($qValue); $ratioClass = ''; if ($hasPrevQuarter) { $ratioClass = $currentRatio >= $prevQuarterRatio ? 'ratio-up' : 'ratio-down'; } $prevQuarterRatio = $currentRatio; $hasPrevQuarter = true; @endphp @endforeach @endforeach @endif @empty @endforelse
TM NameQ{{ $quarter->q ?? preg_replace('/\D+/', '', $quarter->label ?? $quarter->key ?? '') }} %
TM Name{{ $month->label ?? $month->key }}{{ preg_match('/%\s*$/', (string) ($quarter->label ?? '')) ? ($quarter->label ?? $quarter->key) : trim(($quarter->label ?? $quarter->key) . ' %') }}
{{ $metric->label ?? $metric->id }}
{{ $tm->name ?? $tm->id }}{{ $qValue !== null && $qValue !== '' ? $qValue : '-' }}{{ $value !== null && $value !== '' ? $value : '-' }}{{ $qValue !== null && $qValue !== '' ? $qValue : '-' }}
@if ($search !== '') No TMs found matching "{{ $search }}". @else No TM data found. @endif
@include('adherencepackratioreport._pagination')
@endsection @section('script-bottom') @endsection