@extends('layout.index') @section('title', 'Farmer Anomaly Data') @section('content')
@if ($message = Session::get('success'))
@elseif ($message = Session::get('error'))
@endif
@csrf
Programmes
Brands
Seasons *
Countries *
States
Districts
PG
Blocks
Farmer Type
Field Executive
@if(!empty($stateId) || !empty($districtId) || !empty($brandId) || !empty($programId)) Clear @endif
{{--
10
--}} {{--
10
--}}
@if (!empty($feFarmer) && count($feFarmer) > 0) @php // Normalize to lowercase for safe comparison $type = strtolower(trim($anomalyType)); // All datasets mapped by lowercase keys $dataMap = [ 'input cost' => $inputCostData ?? [], 'water use' => $waterUseData ?? [], 'profit' => $profitData ?? [], 'cotton picking vs estimated quantity' =>$cottonPickingVsEstimatedData ??[], ]; @endphp @if (!in_array($type, ['input cost', 'water use', 'profit','cotton picking vs estimated quantity'])) @else @php $sampleData = current($dataMap[$type] ?? []); $firstFarmer = !empty($sampleData) ? current($sampleData) : []; @endphp @if (!empty($firstFarmer) && isset($firstFarmer)) @foreach (array_keys($firstFarmer) as $col) @endforeach @endif @endif @foreach ($feFarmer as $row) @php // Map again in lowercase for per-row lookup $dataMap = [ 'fertilizer' => $fertilizerData ?? [], 'pesticide' => $pesticideData ?? [], 'pest management' => $PesticideManagementData ?? [], 'input cost' => $inputCostData ?? [], 'water use' => $waterUseData ?? [], 'profit' => $profitData ?? [], 'cotton picking vs estimated quantity' =>$cottonPickingVsEstimatedData ??[], ]; $rowType = strtolower(trim($row->anomalyType ?? '')); @endphp @if (!empty($row->anomaly_data) && array_key_exists($rowType, $dataMap)) @php $aData = $dataMap[$rowType]; @endphp @if (array_key_exists($row->code, $aData)) @if (in_array($rowType, ['input cost', 'water use', 'profit','cotton picking vs estimated quantity'])) @foreach ($aData[$row->code][0] as $v) @endforeach @else {{-- ✅ Show nested table for other anomalies --}} @endif @endif @else {{-- If no anomaly data --}} @if (!in_array($type, ['input cost', 'water use', 'profit'])) @endif @endif @endforeach
Sr.No. Farmer Code Farmer Name Farmer Type Producer Group Cotton Land Country State District Block Village Field Executive{{ ucfirst($anomalyType) }} Anomaly{{ $col }}
{{ $count }} {{ $row->code ?? '-' }} {{ $row->name ?? '-' }} {{ $row->farmer_type ?? '-' }} {{ $row->pgName ?? '-' }} {{ $row->pgCode ? ($row->pgCode) : '-' }} {{ $row->cottonArea ?? '-' }} {{ $row->country ?? '-' }} {{ $row->state ?? '-' }} {{ $row->district ?? '-' }} {{ $row->block ?? '-' }} {{ $row->village ?? '-' }} {{ (!empty($aFE[$row->fe_sync])) ? $aFE[$row->fe_sync] : '-' }}{{ $v}}
@foreach (array_keys($aData[$row->code][0]) as $col) @endforeach @foreach ($aData[$row->code] as $val) @foreach ($val as $v) @endforeach @endforeach
{{ $col }}
{{ $v ?? '-' }}
-
@else

No data available

@endif
{{ $Paginator }}