@extends('layouts.app') @section('title', 'Compare Plan Versions') @push('stylesheets') @endpush @section('contents')
{{-- Header --}}

Compare Plan Versions

Comparing differences for Plan #{{ $plan->id }}

Back to Plans
{{-- Toolbar --}}
Apply Comparison
{{-- Schemes & Visits --}}

Schemes & visits

@php $schemesAById = collect($payload['schemes_a'])->keyBy('scheme_id'); $schemesBById = collect($payload['schemes_b'])->keyBy('scheme_id'); $allSchemeIds = $schemesAById->keys()->merge($schemesBById->keys())->unique()->sort()->values(); $changeFlags = $payload['scheme_change_flags'] ?? []; $changes = collect($payload['changes'] ?? [])->keyBy('scheme_id'); @endphp @foreach($allSchemeIds as $sid) @php $rowA = $schemesAById->get($sid); $rowB = $schemesBById->get($sid); $changeType = $changeFlags[$sid] ?? null; $changeEntry = $changes->get($sid); $badgeLabel = $changeType === 'added' ? 'ADDED IN ' . $versionALabel : ($changeType === 'removed' ? 'ADDED IN ' . $versionBLabel : 'UPDATED'); $schemeCode = $rowA['scheme_code'] ?? $rowB['scheme_code'] ?? ('#' . $sid); $schemeName = $rowA['scheme_name'] ?? $rowB['scheme_name'] ?? '—'; $delta = $changeEntry['delta'] ?? []; @endphp
{{ $schemeCode }} @if($changeType) {{ $badgeLabel }} @endif
@if($changeType === 'added')

This scheme was not present in {{ $versionBLabel }}.

@elseif($changeType === 'removed')

This scheme was not present in {{ $versionALabel }}.

@else
{{ $versionALabel }}
Visit location
{{ $rowA['visit_location'] ?? '—' }}
Visit date
{{ $rowA['visit_date'] ?? '—' }}
Remarks
@if(filled($rowA['remarks'] ?? null)){!! nl2br(e((string) $rowA['remarks'])) !!}@else—@endif
Physical progress
{{ $rowA['physical_progress'] !== null ? $rowA['physical_progress'] . '%' : '—' }}
Financial progress
{{ $rowA['financial_progress'] !== null ? $rowA['financial_progress'] . '%' : '—' }}
Visiting team
{{ $rowA['visiting_team_names'] ?? '—' }}
{{ $versionBLabel }}
Visit location
{{ $rowB['visit_location'] ?? '—' }}
Visit date
{{ $rowB['visit_date'] ?? '—' }}
Remarks
@if(filled($rowB['remarks'] ?? null)){!! nl2br(e((string) $rowB['remarks'])) !!}@else—@endif
Physical progress
{{ $rowB['physical_progress'] !== null ? $rowB['physical_progress'] . '%' : '—' }}
Financial progress
{{ $rowB['financial_progress'] !== null ? $rowB['financial_progress'] . '%' : '—' }}
Visiting team
{{ $rowB['visiting_team_names'] ?? '—' }}
@endif
@endforeach @if($allSchemeIds->isEmpty())

No schemes in either version.

@endif
{{-- Footer: Proceed buttons (visibility and action set from permissions / controller) --}} @if($showApproveA || $showApproveB) @endif
@endsection @push('scripts') @endpush