@extends('layouts.vertical-individual', ['page_title' => $title ?? 'Titans Brand Units 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); $totalDoctors = (int) ($pagination->total ?? 0); $search = trim((string) ($search ?? '')); $pageQuery = http_build_query(array_filter([ 'per_page' => $perPage, 'search' => $search !== '' ? $search : null, 'token' => !empty($token ?? '') ? $token : null, ], fn ($value) => $value !== null && $value !== '')); $pageBase = $base_url . '/report?' . $pageQuery; $metaColumnCount = 8; $brandGroups = $brandGroups ?? []; $months = $months ?? []; $monthCount = count($months); $formatShortMonth = function ($month) { $key = is_object($month) ? ($month->key ?? '') : (string) $month; if (!preg_match('/^(\d{4})-(\d{2})$/', $key, $matches)) { return is_object($month) ? ($month->label ?? $key) : $key; } $ts = strtotime($key . '-01 UTC'); return date('M', $ts) . "'" . substr($matches[1], -2); }; $metricColumnCount = 0; foreach ($brandGroups as $group) { $metricColumnCount += count($group->brands ?? []) * $monthCount; } @endphp
Loading report...
@include('titansbrandunitsreport._pagination', ['paginationPosition' => 'titans-brand-units-report-pagination-top'])
@foreach ($brandGroups as $group) @endforeach @foreach ($brandGroups as $group) @foreach ($group->brands ?? [] as $brand) @endforeach @endforeach @foreach ($brandGroups as $group) @foreach ($group->brands ?? [] as $brand) @foreach ($months as $month) @endforeach @endforeach @endforeach @forelse ($doctors as $doctor) @foreach ($brandGroups as $group) @foreach ($group->brands ?? [] as $brand) @foreach ($months as $month) @php $monthKey = is_object($month) ? ($month->key ?? '') : (string) $month; $doctorData = $data->{$doctor->id} ?? null; $monthData = is_object($doctorData) ? ($doctorData->{$monthKey} ?? null) : null; $metricId = $brand->metric_id ?? ''; $value = is_object($monthData) ? ($monthData->{$metricId} ?? null) : null; @endphp @endforeach @endforeach @endforeach @empty @endforelse
Doctor Name MSL Code User Employee Code Zone Region Area Territory{{ $group->name }}
{{ $brand->name }}
{{ $formatShortMonth($month) }}
{{ $doctor->name }} {{ $doctor->msl_code ?? '-' }} {{ $doctor->user ?? '-' }} {{ $doctor->employee_code ?? '-' }} {{ $doctor->zone ?? '-' }} {{ $doctor->region ?? '-' }} {{ $doctor->area ?? '-' }} {{ $doctor->territory ?? '-' }}{{ $value !== null && $value !== '' ? $value : '-' }}
@if ($search !== '') No doctors found matching "{{ $search }}". @else No doctor data found. @endif
@include('titansbrandunitsreport._pagination')
@endsection @section('script-bottom') @endsection