@extends('layouts.master') @section('title', 'Project Work Flow') @section('style') @endsection @section('script') @endsection @section('content') @include('layouts.header') @include('layouts.header-sub') @php // The controller/service supplies the complete, server-validated preview. $preview = $flowPreview ?? []; // Display every required structural step, including missing and multiple matches. // Excluded project members and merged earlier roles remain visible in the comparison only. $structure = $preview['structure'] ?? []; $actual = array_values(array_filter($structure, function($step){ return !in_array($step['status'] ?? '', ['excluded', 'merged', 'skipped'], true); })); $hasRouteDifferences = count($actual) !== count($structure); $issues = $preview['issues'] ?? []; $ready = ($preview['ready'] ?? false) === true; $submitted = ($preview['submitted'] ?? false) === true; $reference = $preview['reference'] ?? null; $canSubmit = $ready && !$submitted && !empty($flowSubmitUrl); $personName = function($person){ if(is_array($person)) return $person['name'] ?? ('User ID: '.($person['id'] ?? '-')); return is_object($person) ? ($person->name ?? ('User ID: '.($person->id ?? '-'))) : (string)$person; }; @endphp
FORM {{ $project->project_form }}
Approval route verification

Project Work Flow

{{ $project->project_name_en }}

@if(isset($trackingFlows) && $trackingFlows->isNotEmpty()) @php $totalApprovals = $trackingFlows->count(); $completedApprovals = $trackingFlows->filter(function($flow){ return !empty($flow->flow_result); })->count(); $remainingApprovals = $totalApprovals - $completedApprovals; $progressPercent = $totalApprovals > 0 ? round(($completedApprovals / $totalApprovals) * 100) : 0; $isStopped = in_array($project->project_status, ['Not Recommended', 'Disapproved'], true); @endphp
{{ $totalApprovals }}
Total Steps
{{ $completedApprovals }}
Completed
{{ $remainingApprovals }}
Remaining

Approval tracking · {{ $trackingSteps->count() }} displayed roles, {{ $totalApprovals }} actual approval actions. Merged roles inherit the decision of their final approving role.

@foreach($trackingSteps as $index => $step) @php $source = $step['source_flow']; $hasDecision = !empty($source->flow_result); $state = $hasDecision ? 'completed' : ($source->flow_status === 'Pending' ? 'pending' : ($isStopped ? 'stopped' : 'upcoming')); $decisionDate = $source->flow_updated ?: ($hasDecision ? $source->flow_created : null); @endphp
{{ $index + 1 }}
{{ $step['role'] }}
{{ $step['name'] }}
@if(!empty($step['activity'])) {{ $step['activity'] }} @endif @if($step['is_merged'])
Merged into {{ $step['merged_from'] }}
@endif @if($hasDecision)
{{ $source->flow_result }}@if($decisionDate) · {{ \Carbon\Carbon::parse($decisionDate)->format('d M Y, H:i') }}@endif
@if($source->flow_comment !== null && $source->flow_comment !== '')
Comment: {{ $source->flow_comment }}
@endif @endif
{{ ucfirst($state) }}
@endforeach
@else
@if($reference)
{{ $reference['name'] ?? '-' }} Reference Researcher · {{ $reference['role'] ?? '-' }} · Faculty Member
@else
Reference Researcher not foundNo eligible Faculty Member identified
@endif
{{ count($actual) }} Required steps @if($submitted) Submitted @elseif($ready) Ready to submit @else {{ count($issues) }} issue(s) @endif
@if(count($issues))
{{ count($issues) }} item(s) need attention
@foreach($issues as $issue)
{{ is_array($issue) ? ($issue['message'] ?? '-') : $issue }}
@endforeach
@endif @if($hasRouteDifferences)
@endif

Required approval steps, including any missing or ambiguous recipients. Excluded project members and merged roles are not sent.

@forelse($actual as $index => $step)
{{ $index + 1 }}
{{ $step['role'] ?? '-' }}
{{ $step['name'] ?? 'Not identified' }}
@if(!empty($step['activity'])) {{ $step['activity'] }} @endif @if(!empty($step['note']))
{{ $step['note'] }}
@endif @if(!empty($step['candidates']))
@foreach($step['candidates'] as $candidate){{ $personName($candidate) }}@endforeach
@endif
@php $state = $step['status'] ?? 'missing'; @endphp {{ $state === 'ready' ? 'Identified' : ($state === 'multiple' ? 'Multiple matches' : 'Missing') }}
@empty
No actual workflow steps are available.
@endforelse
@if($hasRouteDifferences) @endif @endif
@include('layouts.footer') @endsection