diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index dd4a261c..dfcf11a6 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -483,6 +483,33 @@ class EmployeeRestController extends AdminController } } + private function getClaimStatusReason(string $claimStatus, array $claimsData): string + { + $statusReasonConfig = [ + 'REJECTED' => ['denial_reason', 'head_rejection_reason'], + 'CANCELLED' => ['cancel_remark'], + 'CANCELED' => ['cancel_remark'], + 'RETURNED' => ['return_remark'], + ]; + + $claimStatusKey = strtoupper($claimStatus); + + if (! isset($statusReasonConfig[$claimStatusKey])) { + return ''; + } + + foreach ($statusReasonConfig[$claimStatusKey] as $field) { + if (! empty($claimsData[$field])) { + $reason = trim((string) $claimsData[$field]); + if ($reason !== '') { + return $reason; + } + } + } + + return ''; + } + public function deleteDependence() { try { @@ -2779,10 +2806,19 @@ class EmployeeRestController extends AdminController $unique_key = $display_name; } - $filtered_history[$unique_key] = [ + $modifiedAt = date('d-m-Y h:i A', strtotime($value['created_at'])); + $reason = $this->getClaimStatusReason($status, $data['claims_data']); + + $statusEntry = [ 'modified_by' => "", - 'modified_at' => date('d-m-Y h:i A', strtotime($value['created_at'])), + 'modified_at' => $modifiedAt, ]; + + if ($reason !== '') { + $statusEntry['reason'] = ' Reason : ' . $reason; + } + + $filtered_history[$unique_key] = $statusEntry; } } } diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 25c51f36..2eed7f7f 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -2150,7 +2150,7 @@ body[data-sidebar-size="condensed"] .footer { - +