diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 3c1d1940..8db53a2f 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -4367,10 +4367,55 @@ class EmployeeController extends AdminController $not_in_tpa = $this->employeePolicyModel->getTPADataVariationReport($client_id, $client_policy_id, $file_id, $tpa_emp_codes); if (!empty($not_in_tpa) || !empty($not_in_nhance) || !empty($emp_data_wo_tpa_id)) { + $not_in_nhance_button_enable_status = false; + if(count($not_in_tpa)) + { + foreach($not_in_nhance as $nih) + { + if($nih['ref'] === '' || empty($nih['ref'])) + { + $not_in_nhance_button_enable_status = true; + break; + } + } + } + + $not_in_nhance_inception_count = 0; + $not_in_nhance_deletion_count = 0; + foreach ($not_in_nhance as $nih) { + $hasRefKey = array_key_exists('ref', $nih); + $ref = $hasRefKey ? $nih['ref'] : null; + // Empty/null ref: no key, NULL, '', or whitespace-only string. + $refIsEmpty = !$hasRefKey + || $ref === null + || $ref === '' + || (is_string($ref) && trim($ref) === ''); + + $actionIsDeletion = strtoupper(trim((string) ($nih['action_flag_status'] ?? ''))) === 'D'; + + // Every empty/null ref row counts as inception; those that also have flag D additionally count as deletion. + if ($refIsEmpty) { + $not_in_nhance_inception_count++; + if ($actionIsDeletion) { + $not_in_nhance_deletion_count++; + } + } + } + + $not_in_nhance_proceed_button_text = sprintf( + 'Proceed - Inception(%d) + Deletion(%d)', + $not_in_nhance_inception_count, + $not_in_nhance_deletion_count + ); + $response = [ 'not_in_tpa' => $not_in_tpa, 'not_in_nhance' => $not_in_nhance, 'mismatch_data' => $emp_data_wo_tpa_id, + 'not_in_nhance_button_enable_status' => $not_in_nhance_button_enable_status, + 'not_in_nhance_inception_count' => $not_in_nhance_inception_count, + 'not_in_nhance_deletion_count' => $not_in_nhance_deletion_count, + 'not_in_nhance_proceed_button_text' => $not_in_nhance_proceed_button_text, ]; if ($type === 'view') { @@ -4447,10 +4492,10 @@ class EmployeeController extends AdminController { if($generationResult['data']['file_id']) { - sleep(1); + // sleep(1); //initiate update references b/w tpa_api_data and employess (pk update) // $this->reconTpaApiDataWithEmployeepolicies(['file_id' => $file_id]); - sleep(1); + // sleep(1); //initiate deleteion if any // $this->initializeDeletionProcessForTpaApiData(['file_id' => $file_id]); diff --git a/app/Controllers/EmployeeMultiEventServiceController.php b/app/Controllers/EmployeeMultiEventServiceController.php index 634af029..b554a969 100644 --- a/app/Controllers/EmployeeMultiEventServiceController.php +++ b/app/Controllers/EmployeeMultiEventServiceController.php @@ -223,8 +223,8 @@ class EmployeeMultiEventServiceController extends BaseController 'col_cell_name' => 'M', 'col_name' => 'Phone', 'is_mandatory' => false, - 'data_type' => 'str', - 'format' => null, + 'data_type' => 'mobile', + 'format' => 'mobile', 'allowed_values' => null, 'custom' => 'check_dup_mobileno', 'params' => ['row', 'existing_mobilenos'] @@ -1506,6 +1506,7 @@ class EmployeeMultiEventServiceController extends BaseController foreach ($row as $col_key => $col) { $is_mandatory = $columns_to_check[$keys[$col_key]]['is_mandatory']; $format = $columns_to_check[$keys[$col_key]]['format']; + $data_type = $columns_to_check[$keys[$col_key]]['data_type']; $allowed_values = $columns_to_check[$keys[$col_key]]['allowed_values']; $custom_function = isset($columns_to_check[$keys[$col_key]]['custom']) ? $columns_to_check[$keys[$col_key]]['custom'] : null; $binding_params = isset($columns_to_check[$keys[$col_key]]['params']) ? $columns_to_check[$keys[$col_key]]['params'] : null; @@ -1545,14 +1546,26 @@ class EmployeeMultiEventServiceController extends BaseController } //format check - if (isset($format)) { - $format_error = check_excel_date_format($col, $format); - if (!$format_error['status']) { + if(isset($format)) + { + + $validation = validate_excel_value($col, $data_type, $format, $allowed_values); + if (!$validation['status']) { array_push($result['error_summary'], 2); - $result['error_data'][$row_key][$keys[$col_key]]['col_name'] = $column_dispaly_name; //push column name - $result['error_data'][$row_key][$keys[$col_key]]['col_idx'] = $column_index; //push column index - $result['error_data'][$row_key][$keys[$col_key]]['error'][] = $format_error['error']; + + $result['error_data'][$row_key][$keys[$col_key]]['col_name'] = $column_dispaly_name; + $result['error_data'][$row_key][$keys[$col_key]]['col_idx'] = $column_index; + $result['error_data'][$row_key][$keys[$col_key]]['error'][] = $validation['error']; } + + // $format_error = check_excel_date_format($col,$format); + // if(!$format_error['status']) + // { + // array_push($result['error_summary'],2); + // $result['error_data'][$row_key][$keys[$col_key]]['col_name'] = $column_dispaly_name; //push column name + // $result['error_data'][$row_key][$keys[$col_key]]['col_idx'] = $column_index; //push column index + // $result['error_data'][$row_key][$keys[$col_key]]['error'][] = $format_error['error']; + // } } // Kint::dump($is_mandatory); //allowed values check diff --git a/app/Controllers/FhplApiController.php b/app/Controllers/FhplApiController.php index d941c757..542f461b 100644 --- a/app/Controllers/FhplApiController.php +++ b/app/Controllers/FhplApiController.php @@ -530,12 +530,19 @@ class FhplApiController extends BaseController $employeePolicyModel = new EmployeePolicyModel(); $employeePolicyData = $employeePolicyModel + ->select(' + employees.*, + employee_polices.id as emp_policy_id, + employee_polices.client_policy_id, + ') ->join('employees', 'employees.id = employee_polices.employee_id') ->where('employee_polices.client_policy_id', $client_policy_id) ->where('employee_polices.tpa_id IS NULL') ->findAll(); $updated = 0; + $employee_policy_ids = []; + $batch_file_success = 'success'; foreach ($employeePolicyData as $policy) { $hasMatchForThisPolicy = false; @@ -566,24 +573,22 @@ class FhplApiController extends BaseController } } } - } - // Handle NO MATCH for this policy - if (!$hasMatchForThisPolicy) { + if (!$hasMatchForThisPolicy) { + $nhanceSideData = [ + 'name' => $policy['name'] ?? null, + 'emp_code' => $policy['emp_code'] ?? null, + 'relationship' => $policy['relationship'] ?? null, + 'gender' => $policy['gender'] ?? null, + 'dob' => $policy['dob'] ?? null, + ]; + $batch_file_success = 'partially success'; - $nhanceSideData = [ - 'name' => $policy_data['name'] ?? null, - 'emp_code' => $policy_data['emp_code'] ?? null, - 'relationship' => $policy_data['relationship'] ?? null, - 'gender' => $policy_data['gender'] ?? null, - 'dob' => $policy_data['dob'] ?? null, - ]; - $batch_file_success = 'partially success'; - - log_message( - 'error', - "FHPL - TPA ID Pull No match for Nhance = " . json_encode($nhanceSideData) - ); + log_message( + 'error', + "FHPL - TPA ID Pull No match for Nhance = " . json_encode($nhanceSideData) + ); + } } // send e-card @@ -1064,6 +1069,11 @@ class FhplApiController extends BaseController 'is_active' => 1, 'created_by' => $file_info[0]['created_by'] ?? null, 'action_flag_status' => $row['IsActive'] == 1 ? 'A' : 'D' + 'si' => $row['BASE_SUMINSURED'], + 'doj' => change_date_format($row['DATE_OF_JOINING'],'Y-m-d\TH:i:s'), + 'endorsement_no' => $row['ENDORSEMENT_NO'] + // 'date_of_exit' => $row['DATE_OF_RESIGN_FROM_POLICY'] + ]; } diff --git a/app/Controllers/HealthIndiaApiController.php b/app/Controllers/HealthIndiaApiController.php index 5e9f79bc..db356888 100644 --- a/app/Controllers/HealthIndiaApiController.php +++ b/app/Controllers/HealthIndiaApiController.php @@ -1092,7 +1092,10 @@ class HealthIndiaApiController extends BaseController 'is_active' => 1, 'created_by' => $file_info[0]['created_by'] ?? null, - 'action_flag_status' => $row['insuredStatus'] == 'Active' ? 'A' : 'D' + 'action_flag_status' => $row['insuredStatus'] == 'Active' ? 'A' : 'D', + 'doj' => change_date_format($row['doj'],), + 'si' => $row['baseSumInsured'], + 'endorsement_no' => $row['endorsementNumber'] ]; } // log_message('error','HEALTH_INDIA - COUNT' . count($mappedRows)); diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index c0657c30..9498fb88 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -661,6 +661,13 @@ if (! function_exists('change_date_format')) { $date_str = trim($date_str); // Allowed date formats $allowed_formats = [ + + // ISO 8601 datetime (must come before plain Y-m-d to avoid partial match issues) + 'Y-m-d\TH:i:sP', // 2025-07-26T00:00:00+05:30 + 'Y-m-d\TH:i:s\Z', // 2025-07-26T00:00:00Z + 'Y-m-d\TH:i:s', // 2025-07-26T00:00:00 + + // Day Month Year (clear unambiguous formats) 'd M Y', // 01 Dec 2024 'd-M-Y', // 01-Dec-2024 diff --git a/app/Views/batch_list.php b/app/Views/batch_list.php index 8849f24f..a610e38a 100755 --- a/app/Views/batch_list.php +++ b/app/Views/batch_list.php @@ -522,6 +522,10 @@ for ($i = 0; $i < $batch_col_count; $i++) {