@extends('employee.layouts.app') @section('title', get_setting('site_name').' | '.__('Appraisal #').$instance->id) @section('content') @php $settings = \App\Models\PerformanceAppraisalSetting::settings(); $paperWorkflow = $settings->paperFormWorkflow(); $isAppraisee = (int) $instance->staff_id === (int) $staff->id; $stages = \App\Support\PerformanceAppraisal\AppraisalStages::ordered(); $currentStageIdx = \App\Support\PerformanceAppraisal\AppraisalStages::index($instance->current_stage); if ($currentStageIdx === false) { $currentStageIdx = 0; } $workflowStopped = ! $instance->isActive(); $workflowComplete = in_array($instance->status, [ \App\Models\AppraisalInstance::STATUS_FINALIZED, \App\Models\AppraisalInstance::STATUS_CLOSED, ], true); $scoringSubmission = $instance->submissions->firstWhere('stage', \App\Support\PerformanceAppraisal\AppraisalStages::scoringStage($paperWorkflow)); $scoringResponses = is_array($scoringSubmission?->responses) ? $scoringSubmission->responses : []; $showKpiReference = $instance->evaluationForm && ! $canSubmitThisStage; @endphp
@if (session()->has('message'))
{{ session('message') }}
@endif {{-- Hero --}}

{{ __('Performance appraisal') }} #{{ $instance->id }}

@include('partials.appraisal_status_badge', [ 'label' => $instance->listDisplayStatus($paperWorkflow), 'variant' => $instance->listDisplayStatusVariant(), 'class' => 'lg', ])
@if($isAppraisee)

{{ __('Your review') }} · {{ $instance->cycle?->name ?? '—' }}

@else

{{ __('Evaluating') }}: {{ staff_evaluator_label($instance->staff) }} · {{ $instance->cycle?->name ?? '—' }}

@endif @include('partials.appraisal_eval_form_banner', ['title' => $instance->evaluationForm?->title])
@if($instance->final_total_score !== null)
{{ __('Final score') }}
{{ number_format((float) $instance->final_total_score, 2) }}%
@endif {{ __('Back') }}
@if(! $isAppraisee)
{{ __('Employee') }}

{{ staff_evaluator_label($instance->staff) }}

@endif
{{ __('Status') }}

{{ $instance->listDisplayStatus($paperWorkflow) }}

{{ __('Due date') }}

{{ $instance->due_at?->format('d/m/Y') ?? '—' }}

@if($instance->evaluation_period_from || $instance->evaluation_period_to)
{{ __('Evaluation period') }}

{{ $instance->evaluation_period_from?->format('d/m/Y') ?? '—' }} – {{ $instance->evaluation_period_to?->format('d/m/Y') ?? '—' }}

@endif
{{-- Stage stepper --}}
@foreach($stages as $idx => $stageKey) @php $sub = $instance->submissions->firstWhere('stage', $stageKey); $isActive = ! $workflowStopped && ! $workflowComplete && $instance->current_stage === $stageKey; $isDone = $sub?->submitted_at || ($workflowComplete && $idx <= $currentStageIdx) || ($workflowStopped && $idx < $currentStageIdx); $stepClass = $isActive ? 'active' : ($isDone ? 'done' : ''); @endphp
@if($isDone && ! $isActive) @else {{ $idx + 1 }} @endif
{{ \App\Support\PerformanceAppraisal\AppraisalStages::label($stageKey, $paperWorkflow) }}
@endforeach
{{-- Workflow table --}}
{{ __('Workflow progress') }}
@foreach($instance->submissions->sortBy(fn ($s) => \App\Support\PerformanceAppraisal\AppraisalStages::index($s->stage)) as $sub) @endforeach
{{ __('Stage') }} {{ __('Evaluator') }} {{ __('Score') }} {{ __('Submitted') }}
{{ \App\Support\PerformanceAppraisal\AppraisalStages::label($sub->stage, $paperWorkflow) }} @if($instance->current_stage === $sub->stage && ! $workflowComplete && ! $workflowStopped) {{ __('Current') }} @endif {{ staff_evaluator_label($sub->evaluator) }} {{ $sub->total_score !== null ? number_format((float) $sub->total_score, 2).'%' : '—' }} @if($sub->submitted_at) {{ $sub->submitted_at->format('d/m/Y H:i') }} @else {{ __('Pending') }} @endif
@if($instance->probation_recommendation)
{{ __('Final decision') }}: {{ \App\Support\PerformanceAppraisal\AppraisalDecisionOptions::labelForCode($instance->probation_recommendation) }}
@endif @if($instance->strength_1 || $instance->weakness_1)
{{ __('Saved feedback on record') }}

{{ __('Strengths') }}

  1. {{ $instance->strength_1 ?: '—' }}
  2. {{ $instance->strength_2 ?: '—' }}
  3. {{ $instance->strength_3 ?: '—' }}

{{ __('Weaknesses') }}

  1. {{ $instance->weakness_1 ?: '—' }}
  2. {{ $instance->weakness_2 ?: '—' }}
  3. {{ $instance->weakness_3 ?: '—' }}
@endif {{-- KPI reference / submitted scores (when not actively submitting) --}} @if($showKpiReference && $instance->evaluationForm->formKpis->isNotEmpty())
{{ __('KPI indicators') }} @if($scoringSubmission?->submitted_at && $scoringSubmission->total_score !== null) {{ __('Score') }}: {{ number_format((float) $scoringSubmission->total_score, 2) }}% @endif
@if($scoringSubmission?->submitted_at)
@foreach($instance->evaluationForm->formKpis as $fk) @php $k = $fk->kpiIndicator; @endphp @if($k) @endif @endforeach
{{ __('KPI') }} {{ __('Description') }} {{ __('Score') }}
@if($k->title_bn){{ $k->title_bn }}@endif {{ $k->title }} ({{ $fk->weightage }}%) @include('partials.kpi_description_hint', ['indicator' => $k]) {{ $scoringResponses[$k->id] ?? '—' }}
@else @foreach($instance->evaluationForm->formKpis as $fk) @php $k = $fk->kpiIndicator; @endphp @if($k)
@if($k->title_bn){{ $k->title_bn }}@endif {{ $k->title }} · {{ __('weight') }} {{ $fk->weightage }}% @include('partials.kpi_description_hint', ['indicator' => $k])
@endif @endforeach @endif
@endif @if($canSubmitThisStage && $activeSubmission && $instance->evaluationForm)
{{ __('Your action') }}: {{ \App\Support\PerformanceAppraisal\AppraisalStages::label($activeSubmission->stage, $paperWorkflow) }}
@php $actionHint = match (true) { $paperWorkflow && $activeSubmission->stage === \App\Support\PerformanceAppraisal\AppraisalStages::SELF_ASSESSMENT => __('Fill the evaluation form (all KPI scores), then submit.'), $paperWorkflow && $activeSubmission->stage === \App\Support\PerformanceAppraisal\AppraisalStages::PRIMARY_EVALUATION => __('Enter three strengths, three weaknesses, and comments, then submit.'), $paperWorkflow && $activeSubmission->stage === \App\Support\PerformanceAppraisal\AppraisalStages::EXECUTIVE_APPROVAL => __('Review all previous comments, select one final decision, add your remarks, then submit.'), default => __('Complete the form below and submit this stage.'), }; @endphp {{ $actionHint }}
@csrf @include('partials.appraisal_submission_form', [ 'instance' => $instance, 'activeSubmission' => $activeSubmission, ])
@elseif($activeSubmission && ! $activeSubmission->submitted_at)
{{ __('Waiting for :name on this stage.', ['name' => $activeSubmission->evaluator ? staff_evaluator_label($activeSubmission->evaluator) : __('assigned evaluator')]) }}
@elseif(! $instance->evaluationForm)
{{ __('No evaluation form is linked to this instance. Contact HR.') }}
@elseif($activeSubmission?->submitted_at && ! $showKpiReference)
{{ __('You have already submitted this stage.') }}
@endif
@endsection