@extends('layouts.app') @section('title', 'Schemes') @push('stylesheets') @include('partials.index-datatable-styles') @include('partials.filter-card-styles') @include('schemes.partials.project-details-modal-styles') @include('partials.pc-type-selection-modal-styles') @include('schemes.partials.plan-scheme-selection-surface-styles') @endpush @section('contents')
@if (!($selectable ?? false)) @php $ss = $schemeStats ?? [ 'totalSchemes' => 0, 'completedSchemes' => 0, 'totalPc1Created' => 0, 'pc1PendingApprovals' => 0, 'pc1Approved' => 0, ]; $pmsPc1StatFilter = request('pc1_stat'); $pmsPc1StatFilter = in_array((string) $pmsPc1StatFilter, ['created', 'pending', 'approved'], true) ? (string) $pmsPc1StatFilter : null; @endphp
@php $pmsTotalSchemesAll = (int) ($ss['totalSchemes'] ?? 0); $pmsCompletedSchemes = (int) ($ss['completedSchemes'] ?? 0); // Card figure only: exclude completed. Table list still includes all in-scope schemes. $pmsTotalSchemesCard = max(0, $pmsTotalSchemesAll - $pmsCompletedSchemes); @endphp {{ number_format($pmsTotalSchemesCard) }} Total schemes In your scope · excluding completed {{ number_format($pmsCompletedSchemes) }} completed
{{ number_format((int) $ss['totalPc1Created']) }} Schemes with PC forms Distinct schemes · latest active form
{{ number_format((int) $ss['pc1PendingApprovals']) }} Schemes pending PC approval Latest active form in review
{{ number_format((int) $ss['pc1Approved']) }} Schemes with approved PC Latest active form approved
@endif @if($planSetupComplete ?? true) @endif @if($planSetupComplete ?? true)
@php // When selectable, first column is the checkbox (x-slot:firstHeader replaces headers[0]); // prepend a placeholder so thead column count matches tbody (checkbox + ADP + …). // Optional ColVis columns (hidden by default) are appended; see window.pmsSchemesDataTableColumnDefs. $pmsSchemeOptionalHeadersPlan = [ 'Completion date', 'LTBC', 'Status', 'Executing agency', 'MEC sector', 'Last visit date', 'Published date', 'Visit frequency', 'MEC region', ]; $pmsSchemeOptionalHeadersStandalone = [ 'LTBC', 'Status', 'Executing agency', 'MEC sector', 'Last visit date', 'Published date', 'Visit frequency', 'MEC region', ]; $headers = $selectable ? array_merge(['', 'ADP #', 'UID', 'Scheme name', 'Type', 'Location', 'Department', 'Cost', 'Sub-sector', 'Category', 'PP%', 'FP%', 'MEC status'], $pmsSchemeOptionalHeadersPlan) : array_merge(['ADP #', 'UID', 'Scheme name', 'Type', 'Start year', 'Completion date', 'PC-I', 'PC-II', 'PC-III A', 'PC-III B', 'PC-IV', 'PC-V'], $pmsSchemeOptionalHeadersStandalone); $sortColumns = $selectable ? array_merge([null, 'projects.adp_number', 'projects.code', 'projects.name', 'projects.project_type', null, 'projects.department_id', 'projects.approved_amount', 'projects.work_type_id', null, null, null, null], array_fill(0, count($pmsSchemeOptionalHeadersPlan), null)) : array_merge(['projects.adp_number', 'projects.code', 'projects.name', 'projects.project_type', 'projects.start_year', 'projects.target_completion_date', null, null, null, null, null, null], array_fill(0, count($pmsSchemeOptionalHeadersStandalone), null)); @endphp @if (!empty($planSelectionMeta))
{{ request()->filled('return_plan_id') ? 'Edit visit plan' : 'New visit plan' }} — {{ $planSelectionMeta['plan_type'] }} · {{ \Carbon\Carbon::createFromDate((int) $planSelectionMeta['year'], (int) $planSelectionMeta['month'], 1)->format('F Y') }} @php $changeVisitPlanPeriodQuery = []; if (request()->filled('return_plan_id')) { $changeVisitPlanPeriodQuery['return_plan_id'] = (int) request('return_plan_id'); } foreach (['locked_scheme_ids', 'scheme_ids'] as $_pq) { $v = request($_pq); if (is_array($v) && count($v) > 0) { $changeVisitPlanPeriodQuery[$_pq] = array_values(array_map('intval', $v)); } } @endphp
@endif @if ($selectable)
@csrf @if(request()->filled('return_plan_id')) @endif @foreach($lockedSchemeIds ?? [] as $lid) @endforeach @if (!empty($planSelectionMeta)) @endif @endif {!! $schemes->appends($schemesIndexQueryForLinks ?? [])->links('schemes.partials.index-pagination') !!} @if($selectable) @endif @if($selectable) @endif @foreach ($schemes as $scheme) @php $isLockedOnPlan = $selectable && in_array((int) $scheme->project_id, $lockedSchemeIds ?? [], true); $isStickySelected = $selectable && !$isLockedOnPlan && in_array((int) $scheme->project_id, $prefillSchemeIds ?? [], true); @endphp @if ($selectable) @if($isLockedOnPlan) @else @endif @endif @php $_adpRaw = trim((string) ($scheme->adp_number ?? '')); $_adpNorm = strtolower(preg_replace('/\s+/u', '', $_adpRaw) ?? ''); $_adpInvalid = $_adpRaw === '' || in_array($_adpNorm, ['nan', 'n/a', 'na', '—', '-'], true) || !preg_match('/^[0-9]+(\\.[0-9]*)?$/', $_adpRaw); $_adpOrderStr = $_adpInvalid ? '999999999999999' : (string) (0 + $_adpRaw); $schemeFullName = trim((string) ($scheme->name ?? '')) !== '' ? (string) $scheme->name : '—'; $schemeTruncated = $schemeFullName === '—' ? '—' : Str::limit($schemeFullName, (int) ($schemeNameTableLimit ?? 72)); $schemeTypeLabel = trim((string) ($scheme->project_type ?? '')); $schemeTypeLabel = $schemeTypeLabel !== '' ? $schemeTypeLabel : '—'; @endphp @php $_adpDisplay = ($selectable && filled($scheme->scheme_list_adp_display ?? null)) ? $scheme->scheme_list_adp_display : ($scheme->adp_number ?? '—'); $_adpStacked = $selectable && filled($scheme->scheme_list_adp_display ?? null); @endphp $_adpStacked])>{{ $_adpDisplay }} @if ($selectable) @php $pmsSchemeNameColorClass = \App\Support\SchemeNameListingTones::schemeNameColorClass( (bool) ($scheme->scheme_list_in_approved_plan ?? false), $scheme->scheme_list_report_assessment_tone ?? null ); @endphp {{ $scheme->code ?? '—' }} {{ display_text($schemeTruncated) }} {{ $schemeTypeLabel }} @php $locParts = ($scheme->relationLoaded('locations') ? $scheme->locations : collect())->map(function ($loc) { $n = trim((string) ($loc->name ?? '')); if ($n === '') { return ''; } $d = ($loc->relationLoaded('district') && $loc->district) ? trim((string) ($loc->district->name ?? '')) : ''; return $d !== '' ? $n . ' (' . $d . ')' : $n; })->filter()->unique()->values(); $locationLabel = $locParts->isEmpty() ? '—' : $locParts->implode(', '); $ap = $scheme->approved_amount; $est = $scheme->estimated_amount; $costNum = null; if ($ap !== null && $ap !== '' && is_numeric($ap) && (float) $ap > 0) { $costNum = (float) $ap; } elseif ($est !== null && $est !== '' && is_numeric($est)) { $costNum = (float) $est; } $costLabel = $costNum !== null ? number_format($costNum, 2) . ' M' : '—'; @endphp {{ $locationLabel }} {{ $scheme->department?->name ?? '—' }} {{ $costLabel }} @php $workTypeLabel = trim((string) ($scheme->workType?->name ?? '')); $workTypeLabel = $workTypeLabel !== '' ? $workTypeLabel : '—'; @endphp {{ $workTypeLabel }} {{ $scheme->scheme_list_mec_category_label ?? '—' }} — {{ $scheme->scheme_list_fp_percent_display ?? '—' }} {{ $scheme->scheme_list_mec_status_label ?? __('Not Visited') }} @else {{ $scheme->code ?? '—' }} {{ display_text($schemeTruncated) }} {{ $schemeTypeLabel }} {{ $scheme->start_year ?? '—' }} @if (!empty($scheme->target_completion_date)) {{ \Illuminate\Support\Carbon::parse($scheme->target_completion_date)->format('d M Y') }} @else — @endif @endif @if (!$selectable) @include('schemes.partials.pc-status-cell', ['state' => $scheme->pc_i_state ?? null, 'label' => $scheme->pc_i_state_label ?? null, 'chairmanAdviceForwarded' => $scheme->pc_i_chairman_advice_forwarded ?? false]) @include('schemes.partials.pc-status-cell', ['state' => $scheme->pc_ii_state ?? null, 'label' => $scheme->pc_ii_state_label ?? null, 'chairmanAdviceForwarded' => $scheme->pc_ii_chairman_advice_forwarded ?? false]) @include('schemes.partials.pc-status-cell', ['state' => $scheme->pc_iii_a_state ?? null, 'label' => $scheme->pc_iii_a_state_label ?? null, 'chairmanAdviceForwarded' => $scheme->pc_iii_a_chairman_advice_forwarded ?? false]) @include('schemes.partials.pc-status-cell', ['state' => $scheme->pc_iii_b_state ?? null, 'label' => $scheme->pc_iii_b_state_label ?? null, 'chairmanAdviceForwarded' => $scheme->pc_iii_b_chairman_advice_forwarded ?? false]) @include('schemes.partials.pc-status-cell', ['state' => $scheme->pc_iv_state ?? null, 'label' => $scheme->pc_iv_state_label ?? null, 'chairmanAdviceForwarded' => $scheme->pc_iv_chairman_advice_forwarded ?? false]) @include('schemes.partials.pc-status-cell', ['state' => $scheme->pc_v_state ?? null, 'label' => $scheme->pc_v_state_label ?? null, 'chairmanAdviceForwarded' => $scheme->pc_v_chairman_advice_forwarded ?? false]) @php $pcCreatedAt = $scheme->scheme_list_pc_created_at ?? null; $pcSource = trim((string) ($scheme->scheme_list_pc_source ?? '')); $pcCreatedOrder = '0000-00-00'; $pcCreatedLabel = '—'; if ($pcCreatedAt) { try { $pcCreatedCarbon = $pcCreatedAt instanceof \Illuminate\Support\Carbon ? $pcCreatedAt : \Illuminate\Support\Carbon::parse($pcCreatedAt); $pcCreatedLabel = $pcCreatedCarbon->format('d M Y'); $pcCreatedOrder = $pcCreatedCarbon->format('Y-m-d'); } catch (\Throwable $e) { $pcCreatedLabel = (string) $pcCreatedAt; } } @endphp @if ($pcCreatedLabel !== '—')
{{ $pcCreatedLabel }}
@if ($pcSource !== '') {{ $pcSource }} @endif @else — @endif @endif @php $optLtbc = ($scheme->scheme_list_ltbc ?? false) ? 'Yes' : 'No'; $optLtbcOrder = ($scheme->scheme_list_ltbc ?? false) ? 1 : 0; $optStatus = trim((string) ($scheme->scheme_list_scheme_lifecycle ?? '')); $optStatus = $optStatus !== '' ? $optStatus : '—'; $optExec = trim((string) ($scheme->scheme_list_executing_agency_pc ?? '')); if ($optExec === '') { $optExec = trim((string) ($scheme->blk?->name ?? '')); } $optExec = $optExec !== '' ? $optExec : '—'; $optMecSector = trim((string) ($scheme->mec_sector ?? '')); $optMecSector = $optMecSector !== '' ? $optMecSector : '—'; $optVisit = '—'; $optVisitOrder = '0000-00-00'; if (filled($scheme->scheme_list_last_visit_date ?? null)) { try { $optVisit = \Carbon\Carbon::parse($scheme->scheme_list_last_visit_date)->format('d M Y'); $optVisitOrder = \Carbon\Carbon::parse($scheme->scheme_list_last_visit_date)->format('Y-m-d'); } catch (\Throwable $e) { $optVisit = (string) $scheme->scheme_list_last_visit_date; } } $optPubVisit = '—'; $optPubVisitOrder = '0000-00-00'; if (filled($scheme->scheme_list_last_published_plan_at ?? null)) { try { $optPubVisit = \Carbon\Carbon::parse($scheme->scheme_list_last_published_plan_at)->format('d M Y'); $optPubVisitOrder = \Carbon\Carbon::parse($scheme->scheme_list_last_published_plan_at)->format('Y-m-d'); } catch (\Throwable $e) { $optPubVisit = (string) $scheme->scheme_list_last_published_plan_at; } } $optFreq = trim((string) ($scheme->scheme_list_visit_frequency_label ?? '')); $optFreq = $optFreq !== '' ? $optFreq : '—'; $optRegion = trim((string) ($scheme->scheme_list_region_label ?? '')); $optRegion = $optRegion !== '' ? $optRegion : '—'; $optCompletionDisp = '—'; $optCompletionOrder = '9999-12-31'; if (! empty($scheme->target_completion_date)) { try { $optCompletionDisp = \Carbon\Carbon::parse($scheme->target_completion_date)->format('d M Y'); $optCompletionOrder = \Carbon\Carbon::parse($scheme->target_completion_date)->format('Y-m-d'); } catch (\Throwable $e) { $optCompletionDisp = (string) $scheme->target_completion_date; $optCompletionOrder = ''; } } @endphp @if ($selectable) {{ $optCompletionDisp }} @endif {{ $optLtbc }} {{ $optStatus }} {{ $optExec }} {{ $optMecSector }} {{ $optVisit }} {{ $optPubVisit }} {{ $optFreq }} {{ $optRegion }} @endforeach
@if ($selectable)
@endif
@endif
@if(can_any_visit_plan('add'))
@csrf
@endif @if(can('pc-forms', 'add')) @endif @if(can('meeting_workspace', 'add')) @endif
@include('partials.pc-type-selection-modal') @include('partials.pc-iii-sub-selection-modal') @endsection @push('scripts') @php $schemeFilterDetailsForJs = $projectDetails ?? []; $pmsSchemesDataTableOrder = [[$selectable ? 1 : 0, 'asc']]; $pmsSchemesOptionalColTargetsSelectable = array_values(range(13, 21)); $pmsSchemesOptionalColTargetsStandalone = array_values(range(13, 20)); $pmsSchemesDataTableColumnDefs = $selectable ? [ ['orderable' => false, 'targets' => [0, 3, 5, 6, 10, 13, 14, 15, 16, 17, 18, 19, 20, 21]], ['visible' => false, 'targets' => $pmsSchemesOptionalColTargetsSelectable], ] : [ ['orderable' => false, 'targets' => [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]], ['visible' => false, 'targets' => $pmsSchemesOptionalColTargetsStandalone], ]; @endphp @include('partials.index-datatable-scripts') @include('meeting-workspace.partials.mws-schedule-meeting-type-picker-script') @endpush