@extends('layouts.app') @section('title', 'Take Action — Instance #' . $instance->instance_id) @php /** * Defensive date formatter. * Accepts Carbon, string, or null; returns formatted or '—'. */ $fmtDate = function ($value, string $format = 'M j, Y H:i') { if (empty($value)) return '—'; try { return \Illuminate\Support\Carbon::parse($value)->format($format); } catch (\Throwable $e) { return (string) $value; } }; @endphp @section('content')
{{-- ─── Flash / errors ──────────────────────────────────── --}} @if(session('error'))
{!! session('error') !!}
@endif @if($errors->any())
@endif
{{-- Role / Delegation badge --}}
Your Role: {{ auth()->user()->role?->display_name ?? auth()->user()->role?->name ?? 'Unknown' }} @if($delegation) Acting on delegation #{{ $delegation->delegation_id }} @endif
{{-- Progress --}}
Approval Progress
{{ $actionsTaken }}/{{ $totalSteps }} Steps Completed
Initiated: {{ $fmtDate($instance->initiated_at, 'M j, Y') }} Current Step: {{ $currentStep->step_name }} Total Steps: {{ $totalSteps }}
{{-- Main card --}}

Take Approval Action

Step {{ $currentStep->step_order }}: {{ $currentStep->step_name }}
@if(!$canApprove)
You are not authorized to approve this step.
@endif {{-- Instance summary --}}
Document Information

Document: {{ $instance->record_number ?: '#' . $instance->record_id }}

Title: {{ $instance->record_title ?: 'N/A' }}

Type: {{ $instance->record_type }}

Workflow: {{ $instance->workflow?->workflow_name ?? '—' }}

Initiator: {{ $instance->initiator?->name ?? '—' }}

Initiated: {{ $fmtDate($instance->initiated_at) }}

{{-- Previous actions ─────────────────────────── --}} @if($actions->isNotEmpty())
Previous Actions
@foreach($actions as $action)
{{ $action->approver?->name ?? 'Unknown' }} {{-- line 126 lives here — now using $fmtDate --}} {{ $fmtDate($action->action_date) }}
@if($action->step?->step_name)
Step {{ $action->step->step_order }}: {{ $action->step->step_name }}
@endif @if($action->comment)

{{ $action->comment }}

@endif @if($action->signature)
Signed: {{ $action->signature }}
@endif
@endforeach
@endif {{-- Action form ──────────────────────────────── --}} @if($canApprove)
@csrf
@if($currentStep->require_esignature)
@if($userSignature)

Your stored signature will be used:

Signature
@endif By typing your name, you are electronically signing this document.
@endif @if($currentStep->allow_attachments)
Max 10MB per file. PDF, Office docs, images, zip.
@endif
Cancel
@endif
{{-- Step requirements ────────────────────────────── --}}
Step Requirements
Required: {{ $currentStep->is_required ? 'Yes' : 'No' }}
Delegation: {{ $currentStep->allow_delegation ? 'Allowed' : 'Not Allowed' }}
Comments: {{ $currentStep->allow_comments ? 'Required' : 'Optional' }}
E-Signature: {{ $currentStep->require_esignature ? 'Required' : 'Optional' }}
@endsection @push('scripts') @endpush