@extends('layouts.app') @section('title', 'Scheme plan changes') @push('stylesheets') @include('partials.filter-card-styles') @include('partials.collapsible-filter-styles') @include('partials.index-datatable-styles') @endpush @section('contents')
@php $spcFiltersOpen = trim((string) ($search ?? '')) !== '' || ($planTypeFilter ?? '') !== '' || ($requestTypeFilter ?? '') !== '' || (($statusFilter ?? 'all') !== 'all' && ($statusFilter ?? '') !== '') || (int) ($initiatedByFilter ?? 0) > 0; @endphp
@if ($showInitiatedByFilter ?? false)
@endif
@forelse ($requests as $r) @php $statusLabel = match ($r->status) { 'meo_review' => 'Pending MEO review', 'rd_review' => 'Forwarded to RD', 'sdm_review' => 'Forwarded to SDM', 'dg_review' => 'Forwarded to DG', 'returned' => 'Returned for revision', 'approved' => 'Approved', 'rejected' => 'Rejected', default => $r->status, }; $typeLabel = $r->request_type === 'replacement' ? 'Replacement' : 'Cancellation'; $hidePlanDetails = (bool) ($r->initiated_via_mec_sims_modification ?? false); $canOpenDetail = can('scheme_plan_changes', 'view') || can('scheme_plan_changes', 'list') || user_can_review_mec_sims_modification_requests() || ((int) $r->initiated_by === (int) login_user_id() && $hidePlanDetails && user_can_request_mec_sims_modification_cancellation()); $detailUrl = route('scheme-plan-changes.show', $r); $needsReview = ! empty($reviewQueueIds[(int) $r->id]); @endphp @if ($hidePlanDetails && $canOpenDetail)
#{{ $r->id }}
@else {{ $r->id }} @endif @if ($hidePlanDetails)
@elseif ($canOpenDetail)
{{$r->plan->plan_type . '-' . \Carbon\Carbon::create()->month((int) $r->plan->month)->format('F') . '-' . $r->plan->year . ' ' }}
@else
#{{ $r->plan_id }} {{ $r->plan?->draft_name ?: 'Visit plan' }} @if ($r->plan) · {{ strtoupper((string) $r->plan->plan_type) }} · {{ $r->plan->month }}/{{ $r->plan->year }} @endif
@endif {{ $typeLabel }} {{ (int) ($r->lines_count ?? 0) > 0 ? (int) $r->lines_count : '—' }} @if ($needsReview) {{ __('Action required') }} @endif {{ $statusLabel }} {{ $r->initiator?->name ?? '—' }} {{ $r->created_at?->format('d M Y H:i') }} @empty No requests found. @endforelse
@endsection @push('scripts') @include('partials.index-datatable-scripts') @include('partials.collapsible-filter-scripts') @endpush