From fd93ddef323bfdbc8a22676b7c32a2b42b1d6e1c Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Tue, 12 May 2026 14:11:40 +0530 Subject: [PATCH 1/5] saml issue solved --- app/Controllers/SamlController.php | 35 +++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/app/Controllers/SamlController.php b/app/Controllers/SamlController.php index 8e53870..04e1667 100644 --- a/app/Controllers/SamlController.php +++ b/app/Controllers/SamlController.php @@ -53,30 +53,55 @@ class SamlController extends BaseController $email = $this->request->getGet('email'); if (! $email) { - return $this->response->setStatusCode(400)->setBody('Email required'); + return $this->redirectToFrontendSso([ + 'status' => 'failed', + 'code' => 400, + 'data' => '', + 'message' => 'Email required', + ]); } + $email = trim((string) $email); $at = strrchr($email, '@'); if ($at === false) { - return $this->response->setStatusCode(400)->setBody('Invalid email'); + return $this->redirectToFrontendSso([ + 'status' => 'failed', + 'code' => 400, + 'data' => '', + 'message' => 'Invalid email', + ]); } + + $domain = strtolower(substr($at, 1)); + $model = new SamlClientModel(); $samlClient = $model->getByDomain($domain); + if (! $samlClient) { - return $this->response->setStatusCode(404)->setBody('SAML not configured for this domain'); + return $this->redirectToFrontendSso([ + 'status' => 'failed', + 'code' => 404, + 'data' => '', + 'message' => 'SAML not configured for this domain', + ]); } - // dd($samlClient); + $auth = $this->getSamlAuth($samlClient['id']); } catch (\Throwable $e) { - return redirect()->to(site_url('login'))->with('error', $e->getMessage()); + return $this->redirectToFrontendSso([ + 'status' => 'failed', + 'code' => 500, + 'data' => '', + 'message' => $e->getMessage(), + ]); } $url = $auth->login(null, [], false, false, true); From d0da0d7f960e07ae4fb242adbfe2886f002140d3 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Tue, 12 May 2026 14:22:27 +0530 Subject: [PATCH 2/5] saml issue solved --- app/Controllers/SamlController.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Controllers/SamlController.php b/app/Controllers/SamlController.php index 04e1667..fc3530c 100644 --- a/app/Controllers/SamlController.php +++ b/app/Controllers/SamlController.php @@ -53,7 +53,7 @@ class SamlController extends BaseController $email = $this->request->getGet('email'); if (! $email) { - return $this->redirectToFrontendSso([ + return $this->response->setStatusCode(400)->setJSON([ 'status' => 'failed', 'code' => 400, 'data' => '', @@ -65,7 +65,7 @@ class SamlController extends BaseController $email = trim((string) $email); $at = strrchr($email, '@'); if ($at === false) { - return $this->redirectToFrontendSso([ + return $this->response->setStatusCode(400)->setJSON([ 'status' => 'failed', 'code' => 400, 'data' => '', @@ -77,13 +77,16 @@ class SamlController extends BaseController $domain = strtolower(substr($at, 1)); + // dd($domain); $model = new SamlClientModel(); $samlClient = $model->getByDomain($domain); + // dd($samlClient); + if (! $samlClient) { - return $this->redirectToFrontendSso([ + return $this->response->setStatusCode(404)->setJSON([ 'status' => 'failed', 'code' => 404, 'data' => '', @@ -96,7 +99,7 @@ class SamlController extends BaseController $auth = $this->getSamlAuth($samlClient['id']); } catch (\Throwable $e) { - return $this->redirectToFrontendSso([ + return $this->response->setStatusCode(500)->setJSON([ 'status' => 'failed', 'code' => 500, 'data' => '', From 9fcb222db3efd4ae39b8c489b4d930a2f601a6d6 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Fri, 15 May 2026 11:27:45 +0530 Subject: [PATCH 3/5] GWM : samul token issue --- app/Controllers/SamlController.php | 36 +++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/app/Controllers/SamlController.php b/app/Controllers/SamlController.php index fc3530c..79284c5 100644 --- a/app/Controllers/SamlController.php +++ b/app/Controllers/SamlController.php @@ -5,6 +5,7 @@ namespace App\Controllers; use App\Models\SamlClientModel; use App\Helpers\JWTToken; use App\Helpers\RestAuthHelper; +use App\Controllers\RestAuthenticationController; use OneLogin\Saml2\Auth as SamlAuth; use OneLogin\Saml2\Error as SamlError; use OneLogin\Saml2\Settings as SamlSettings; @@ -189,14 +190,33 @@ class SamlController extends BaseController $postEnrollment = ['status' => 'failed', 'code' => 404, 'data' => '']; if (! empty($empdata['post'])) { - $postData = $empdata['post']; - unset($postData['employee_id']); - $postData['token_type'] = 'post'; - $postEnrollment = [ - 'status' => 'success', - 'code' => 200, - 'data' => JWTToken::encode($postData), - ]; + $postId = $empdata['post']['id'] ?? $empdata['post']['employee_id'] ?? null; + if ($postId !== null && $postId !== '') { + $restAuth = new RestAuthenticationController(); + $endpoint = env('POST_ENROLLMENT_BASEURL', 'getTokenforSamulssOAuthLogin'); + $rawBody = $restAuth->callThirdPartyGETAPI( + ['id' => $postId], + $endpoint + ); + $api = is_string($rawBody) ? json_decode($rawBody, true) : null; + if (is_array($api) + && (($api['status'] ?? '') === 'success' || (int) ($api['code'] ?? 0) === 200) + && isset($api['data']) + && $api['data'] !== '' + ) { + $postEnrollment = [ + 'status' => 'success', + 'code' => 200, + 'data' => is_string($api['data']) ? $api['data'] : (string) $api['data'], + ]; + } else { + $postEnrollment = [ + 'status' => 'failed', + 'code' => (int) ($api['code'] ?? 404), + 'data' => '', + ]; + } + } } if (empty($empdata)) { From 6a9eee81d3827bfb879dd5a3d50ecbb94a072923 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Fri, 15 May 2026 11:48:08 +0530 Subject: [PATCH 4/5] GWM : samul token issue --- app/Controllers/SamlController.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/Controllers/SamlController.php b/app/Controllers/SamlController.php index 79284c5..3dc663d 100644 --- a/app/Controllers/SamlController.php +++ b/app/Controllers/SamlController.php @@ -193,11 +193,9 @@ class SamlController extends BaseController $postId = $empdata['post']['id'] ?? $empdata['post']['employee_id'] ?? null; if ($postId !== null && $postId !== '') { $restAuth = new RestAuthenticationController(); - $endpoint = env('POST_ENROLLMENT_BASEURL', 'getTokenforSamulssOAuthLogin'); - $rawBody = $restAuth->callThirdPartyGETAPI( - ['id' => $postId], - $endpoint - ); + + $rawBody = $restAuth->callThirdPartyGETAPI(['id' => $postId],'getTokenforSamulssOAuthLogin'); + $api = is_string($rawBody) ? json_decode($rawBody, true) : null; if (is_array($api) && (($api['status'] ?? '') === 'success' || (int) ($api['code'] ?? 0) === 200) From 6d9cd145cf4927f954c550640d1b6feaf69f1760 Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Sat, 16 May 2026 09:09:28 +0530 Subject: [PATCH 5/5] CHANGE_SHOW_THE_CREATED_DATE_AND_TIME_IN_THE_EMP_HISTORY --- app/Models/EmployeePolicyModel.php | 35 ++++++++++++++++++++++++++++++ app/Views/employee_data_list.php | 30 ++++++++++++++++++++----- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 9ee48ef..1753172 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -131,14 +131,17 @@ class EmployeePolicyModel extends Model // Name audit trail '(SELECT old_value FROM auditing_history WHERE pk = emp.id AND field_name = "name" AND table_name = "employees" ORDER BY id ASC LIMIT 1) AS name_first_old', '(SELECT new_value FROM auditing_history WHERE pk = emp.id AND field_name = "name" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS name_last_new', + '(SELECT DATE_FORMAT(COALESCE(created_at, emp.updated_at), "%d/%m/%Y %h:%i %p") FROM auditing_history WHERE pk = emp.id AND field_name = "name" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS name_created_at', // DOB audit trail '(SELECT old_value FROM auditing_history WHERE pk = emp.id AND field_name = "dob" AND table_name = "employees" ORDER BY id ASC LIMIT 1) AS dob_first_old', '(SELECT new_value FROM auditing_history WHERE pk = emp.id AND field_name = "dob" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS dob_last_new', + '(SELECT DATE_FORMAT(COALESCE(created_at, emp.updated_at), "%d/%m/%Y %h:%i %p") FROM auditing_history WHERE pk = emp.id AND field_name = "dob" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS dob_created_at', // Gender audit trail '(SELECT old_value FROM auditing_history WHERE pk = emp.id AND field_name = "gender" AND table_name = "employees" ORDER BY id ASC LIMIT 1) AS gender_first_old', '(SELECT new_value FROM auditing_history WHERE pk = emp.id AND field_name = "gender" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS gender_last_new', + '(SELECT DATE_FORMAT(COALESCE(created_at, emp.updated_at), "%d/%m/%Y %h:%i %p") FROM auditing_history WHERE pk = emp.id AND field_name = "gender" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS gender_created_at', "(CASE WHEN emp.relationship = 'Self' @@ -160,6 +163,19 @@ class EmployeePolicyModel extends Model ELSE NULL END) AS removed_summary", + "(CASE + WHEN emp.relationship = 'Self' + THEN ( + SELECT DATE_FORMAT(MAX(e.updated_at), '%d/%m/%Y %h:%i %p') + FROM employees e + JOIN employee_polices ep ON e.id = ep.employee_id + WHERE e.emp_code = emp.emp_code + AND (e.is_dependent_modified = 0 OR (e.is_active = 0 AND e.emp_status != 'truncated')) + AND ep.client_policy_id = employee_polices.client_policy_id + ) + ELSE NULL + END) AS removed_summary_updated_at", + "(IF(COALESCE(emp.is_dependent_modified, 0) = 1, 'Newly Added, ', CASE WHEN emp.relationship != 'Self' @@ -180,6 +196,25 @@ class EmployeePolicyModel extends Model END )) AS newly_added", + "(IF(COALESCE(emp.is_dependent_modified, 0) = 1, DATE_FORMAT(emp.updated_at, '%d/%m/%Y %h:%i %p'), + CASE + WHEN emp.relationship != 'Self' + AND emp.file_id IS NULL + AND emp.created_by = ( + SELECT e_sub.id + FROM employees e_sub + JOIN employee_polices ep_sub ON e_sub.id = ep_sub.employee_id + WHERE e_sub.emp_code = emp.emp_code + AND e_sub.relationship = 'Self' + AND e_sub.is_active = 1 + AND ep_sub.client_policy_id = employee_polices.client_policy_id + LIMIT 1 + ) + THEN DATE_FORMAT(emp.updated_at, '%d/%m/%Y %h:%i %p') + ELSE NULL + END + )) AS newly_added_updated_at", + $status_query ], false) ->join('employees emp', 'employee_polices.employee_id = emp.id') diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index 7659250..2041652 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -201,22 +201,42 @@ " . $employee['newly_added'] . "

"; + echo "

" . $employee['newly_added']; + if (!empty($employee['newly_added_updated_at'])) { + echo ' (' . $employee['newly_added_updated_at'] . ')'; + } + echo "

"; } if(!empty($employee['name_first_old']) ){ - echo "

Name : " . $employee['name_first_old'] . ' => ' . $employee['name_last_new'] . "

"; + echo "

Name : " . $employee['name_first_old'] . ' => ' . $employee['name_last_new']; + if (!empty($employee['name_created_at'])) { + echo ' (' . $employee['name_created_at'] . ')'; + } + echo "

"; } if(!empty($employee['dob_first_old'])){ - echo "

DOB : " . change_date_format($employee['dob_first_old'], null, 'd/m/Y') . ' => ' . change_date_format($employee['dob_last_new'], null, 'd/m/Y') . "

"; + echo "

DOB : " . change_date_format($employee['dob_first_old'], null, 'd/m/Y') . ' => ' . change_date_format($employee['dob_last_new'], null, 'd/m/Y'); + if (!empty($employee['dob_created_at'])) { + echo ' (' . $employee['dob_created_at'] . ')'; + } + echo "

"; } if(!empty($employee['gender_first_old'])){ - echo "

Gender : " . $employee['gender_first_old'] . ' => ' . $employee['gender_last_new'] . "

"; + echo "

Gender : " . $employee['gender_first_old'] . ' => ' . $employee['gender_last_new']; + if (!empty($employee['gender_created_at'])) { + echo ' (' . $employee['gender_created_at'] . ')'; + } + echo "

"; } // if(!empty($employee['removed_count'])){ // echo "

" . $employee['removed_count'] . " People removed

"; // } if(!empty($employee['removed_summary'])){ - echo "

" . $employee['removed_summary'] . "

"; + echo "

" . $employee['removed_summary']; + if (!empty($employee['removed_summary_updated_at'])) { + echo ' (' . $employee['removed_summary_updated_at'] . ')'; + } + echo "

"; } if(empty($employee['name_first_old']) && empty($employee['dob_first_old']) && empty($employee['gender_first_old']) && empty($employee['removed_summary'] ) && empty($employee['newly_added'] )){ echo " - ";