@php
$planFiltersOpen = plan_index_has_scheme_filters()
|| trim((string) ($search ?? '')) !== ''
|| visit_plan_index_has_plan_type_filter()
|| request()->filled('month')
|| request()->filled('year')
|| visit_plan_index_has_region_filter()
|| (request()->filled('status') && ! in_array((string) request('status'), ['draft', 'in_process', 'approved'], true));
@endphp
@include('plan.partials.index-filter-form', ['schemeFilterCatalog' => $schemeFilterCatalog ?? []])
@php
$planTableHeaders = ['Region', 'Type', 'No. Schemes', 'Initiating Officer', 'Month-Year', 'Status', 'Last Action', 'Evaluator', 'Verifier', 'Approver'];
$planLastWorkflowDisplay = function ($plan) {
$at = $plan->plan_list_last_workflow_at ?? null;
if (! $at instanceof \Carbon\Carbon && ! $at instanceof \DateTimeInterface) {
return ['order' => 0, 'text' => '—'];
}
$parsed = \Carbon\Carbon::parse($at)->timezone(config('app.timezone'));
return [
'order' => $parsed->getTimestamp(),
'text' => $parsed->format('d M Y H:i'),
];
};
/** Sidebar “Review & Approval” is `/plan` without `status=approved` or `status=in_process` (see PlanService::planListQuery). */
$planListShowsRdConsolidationControls = can_any_visit_plan('can_check')
&& ! in_array((string) request('status', ''), ['draft', 'in_process', 'approved'], true);
$planMonthYear = function($plan) {
$month = (int) ($plan->month ?? 0);
$year = (string) ($plan->year ?? '');
if ($month >= 1 && $month <= 12 && $year !== '') {
return \Carbon\Carbon::create()->month($month)->format('F') . ' ' . $year;
}
return '—';
};
$planTypeBadgeVariant = function (?string $type): string {
return match (strtoupper(trim((string) $type))) {
'RVP' => 'custom-rvp',
'CVP' => 'custom-cvp',
'SVP' => 'custom-svp',
'DRP' => 'custom-drp',
'ERP' => 'custom-erp',
'PMP' => 'custom-pmp',
default => 'secondary',
};
};
$planSchemeCount = function ($plan): int {
$schemes = $plan->latestVersion?->schemes;
if ($schemes === null || $schemes->isEmpty()) {
return 0;
}
return $schemes->whereNull('rd_rejected_at')->count();
};
$planSchemeCountDisplay = function ($plan) use ($planSchemeCount): array {
if (plan_index_has_scheme_filters()) {
$match = (int) ($plan->plan_list_matching_scheme_count ?? 0);
return ['order' => $match, 'html' => '
'.$match.' '];
}
$count = $planSchemeCount($plan);
return ['order' => $count, 'html' => (string) $count];
};
@endphp
@if(can_any_visit_plan('can_check'))
@if($planListShowsRdConsolidationControls)
@if(($pendingCheckerShellExtractions ?? 0) > 0)
{{ (int) $pendingCheckerShellExtractions === 1
? __('One declined consolidated plan still has your schemes that were not returned with the submitters\' plans.')
: __(':count declined consolidated plans still have your schemes that were not returned with the submitters\' plans.', ['count' => (int) $pendingCheckerShellExtractions]) }}
@endif
@endif
@foreach ($plans as $plan)
@if($planListShowsRdConsolidationControls)
status !== 'rd_review') disabled @endif>
{{ $plan->display_region ?? '—' }}
@else
{{ $plan->display_region ?? '—' }}
@endif
@if(filled($plan->plan_type))
{{ $plan->plan_type }}
@else
—
@endif
@php $__psc = $planSchemeCountDisplay($plan); @endphp
{!! $__psc['html'] !!}
@if(($plan->plan_list_mo_column_mode ?? '') === 'consolidated')
Consolidated by
{{ $plan->display_consolidated_by ?? ($plan->creator->name ?? '—') }}
@else
{{ $plan->display_monitoring_officers ?? ($plan->creator->name ?? '—') }}
@endif
{{ $planMonthYear($plan) }}
@php $__ps = plan_list_row_status_for_badge($plan); @endphp
{{ plan_status_display_label($plan) }}
@if((int) ($plan->declined_scheme_count ?? 0) > 0)
{{ (int) $plan->declined_scheme_count }} declined
@endif
@if(count($plan->consolidatedSourcePlanIds()))
Consolidated
@endif
@if((int) ($plan->plan_list_merged_into_plan_id ?? 0) > 0)
Merged into #{{ (int) $plan->plan_list_merged_into_plan_id }}
@endif
@php $__plw = $planLastWorkflowDisplay($plan); @endphp
{{ $__plw['text'] }}
{{ $plan->checker->name ?? '—' }}
{{ $plan->verifier->name ?? '—' }}
{{ $plan->approver->name ?? '—' }}
@endforeach
@elseif(can_any_visit_plan('can_verify') || can_any_visit_plan('can_approve'))
@foreach ($plans as $plan)
{{ $plan->display_region ?? '—' }}
@if(filled($plan->plan_type))
{{ $plan->plan_type }}
@else
—
@endif
@php $__psc = $planSchemeCountDisplay($plan); @endphp
{!! $__psc['html'] !!}
@if(($plan->plan_list_mo_column_mode ?? '') === 'consolidated')
Consolidated by
{{ $plan->display_consolidated_by ?? ($plan->creator->name ?? '—') }}
@else
{{ $plan->display_monitoring_officers ?? ($plan->creator->name ?? '—') }}
@endif
{{ $planMonthYear($plan) }}
@php $__ps = plan_list_row_status_for_badge($plan); @endphp
{{ plan_status_display_label($plan) }}
@if((int) ($plan->declined_scheme_count ?? 0) > 0)
{{ (int) $plan->declined_scheme_count }} declined
@endif
@if(count($plan->consolidatedSourcePlanIds()))
Consolidated
@endif
@if((int) ($plan->plan_list_merged_into_plan_id ?? 0) > 0)
Merged into #{{ (int) $plan->plan_list_merged_into_plan_id }}
@endif
@php $__plw = $planLastWorkflowDisplay($plan); @endphp
{{ $__plw['text'] }}
{{ $plan->checker->name ?? '—' }}
{{ $plan->verifier->name ?? '—' }}
{{ $plan->approver->name ?? '—' }}
@endforeach
@else
@foreach ($plans as $plan)
{{ $plan->display_region ?? '—' }}
@if(filled($plan->plan_type))
{{ $plan->plan_type }}
@else
—
@endif
@php $__psc = $planSchemeCountDisplay($plan); @endphp
{!! $__psc['html'] !!}
@if(($plan->plan_list_mo_column_mode ?? '') === 'consolidated')
Consolidated by
{{ $plan->display_consolidated_by ?? ($plan->creator->name ?? '—') }}
@else
{{ $plan->display_monitoring_officers ?? ($plan->creator->name ?? '—') }}
@endif
{{ $planMonthYear($plan) }}
@php $__ps = plan_list_row_status_for_badge($plan); @endphp
{{ plan_status_display_label($plan) }}
@if((int) ($plan->declined_scheme_count ?? 0) > 0)
{{ (int) $plan->declined_scheme_count }} declined
@endif
@if(count($plan->consolidatedSourcePlanIds()))
Consolidated ({{ (int) ($plan->display_consolidation_source_count ?? count($plan->consolidatedSourcePlanIds())) }} sources)
@endif
@if((int) ($plan->plan_list_merged_into_plan_id ?? 0) > 0)
Merged into #{{ (int) $plan->plan_list_merged_into_plan_id }}
@endif
@php $__plw = $planLastWorkflowDisplay($plan); @endphp
{{ $__plw['text'] }}
{{ $plan->checker->name ?? '—' }}
{{ $plan->verifier->name ?? '—' }}
{{ $plan->approver->name ?? '—' }}
@endforeach
@endif
{{-- Plan details modal (body loaded via AJAX) --}}
@if($planListShowsRdConsolidationControls)
@endif