{{-- Workflow Templates Tab --}} @php // Document type names link to their tab only for users who can open it. $canOpenDocumentTypes = \App\Support\WorkflowPermission::canAccessAdminTab( (string) (auth()->user()->role ?? ''), 'document-types' ); @endphp
{{ __('Name') }} {{ __('Used By Document Types') }} {{ __('Stages') }} {{ __('Status') }} {{ __('Actions') }} @forelse(($workflowTemplates ?? collect()) as $wft)

{{ $wft->name }}

@if($wft->description) {{ $wft->description }} @endif @if($wft->documentTypes->count())
@foreach($wft->documentTypes as $documentType) @php $linkedDtNameEn = trim((string) ($documentType->name_en ?? $documentType->name ?? '')); $linkedDtNameKh = trim((string) ($documentType->name_kh ?? '')); $linkedDtName = app()->getLocale() === 'kh' && $linkedDtNameKh !== '' ? $linkedDtNameKh : $linkedDtNameEn; @endphp @if($canOpenDocumentTypes) {{-- Same markup as the workflow link in the Document Types tab: arrow sits outside the badge. --}} @else @endif @endforeach
@else {{ __('Not linked yet') }} @endif @php $steps = $wft->steps ?? []; @endphp @if(count($steps)) @php $visibleSteps = array_values($steps); @endphp
@foreach($visibleSteps as $index => $step) @php $stepType = $step['step_type'] ?? ''; $stepOrganizationName = $step['organization_name'] ?? ''; $stepTypeLabel = match($stepType) { 'start_organization' => __('Submission Stage'), 'vice_rector' => __('Vice Rector Review'), 'approval' => __('Rector Review'), default => null, }; if ($stepTypeLabel !== null) { $stageDisplay = $stepTypeLabel; } elseif ($stepOrganizationName !== '') { // Resolve localized organization name from the map $stageDisplay = $allOrganizationDisplayMap[$stepOrganizationName] ?? $stepOrganizationName; } else { $stageDisplay = __($step['label'] ?? \App\Models\WorkflowTemplate::stateLabel($step['from_state'] ?? '')); } @endphp @if(!$loop->last) @endif @endforeach
@else {{ __('No stages defined') }} @endif @empty {{ __('No workflow templates found.') }} @endforelse
{{-- Create Workflow Template Modal --}} {{-- Edit Workflow Template Modal --}} {{-- Hidden toggle form --}} {{-- Hidden delete form --}}