Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
sanjeev.p 2026-05-11 17:43:07 +05:30
commit 13ae00b1e9
9 changed files with 145 additions and 37 deletions

View File

@ -518,7 +518,7 @@ class ApiServiceController extends BaseController
$userParams['phone'] = $row['phone'];
$userParams['email'] = $row['email'];
$userParams['relationship'] = $row['relation'];
$userParams['gender'] = $row['gender'];
$userParams['gender'] = $row['gender'] == 'M' ? 'Male' : 'Female';
$userParams['dob'] = $row['dob'];
$userParams['policyNumber'] = $row['policyNumber'];
$userParams['policyStartDate'] = $row['policyStartDate'];

View File

@ -692,7 +692,8 @@ class EmployeeController extends AdminController
return $this->response->download($filePath, null, $mimeType);
} else {
// File not found, show an error message or redirect
echo view('errors/html/production');
echo view('errors/404.php', ['message' => 'Sample file not found']);
// return redirect()->back()->with('error', 'Sample file not found');
}
}
@ -3852,7 +3853,7 @@ class EmployeeController extends AdminController
foreach ($families as $empCode => $members) {
$familiesPayload[$empCode] = $this->buildFamilyPayload($empCode, $members);
}
log_message('error', "[WellnessOnboard] Page {$page} API calls done. Families processed: " . json_encode($familiesPayload));
// ----------------------------------------------------------------
// 5. SEND TO WELLNESS API
// ----------------------------------------------------------------

View File

@ -227,7 +227,7 @@ class EmployeeMultiEventServiceController extends BaseController
'format' => 'mobile',
'allowed_values' => null,
'custom' => 'check_dup_mobileno',
'params' => ['row', 'existing_mobilenos']
'params' => ['row', 'existing_mobilenos', 'excel_data', 'row_key']
],
'email' => [
'col_idx' => 13,
@ -238,7 +238,7 @@ class EmployeeMultiEventServiceController extends BaseController
'format' => null,
'allowed_values' => null,
'custom' => 'check_dup_email',
'params' => ['row', 'existing_mobilenos']
'params' => ['row', 'existing_mobilenos', 'excel_data', 'row_key']
],
'pre_existing_ailments' => [
'col_idx' => 14,

View File

@ -230,7 +230,7 @@ class EmployeeServiceController extends AdminController
'format' => 'mobile',
'allowed_values' => null,
'custom' => 'check_dup_mobileno',
'params' => ['row', 'existing_mobilenos']
'params' => ['row', 'existing_mobilenos', 'excel_data', 'row_key']
],
'email' => [
'col_idx' => 13,
@ -241,7 +241,7 @@ class EmployeeServiceController extends AdminController
'format' => null,
'allowed_values' => null,
'custom' => 'check_dup_email',
'params' => ['row', 'existing_mobilenos']
'params' => ['row', 'existing_mobilenos', 'excel_data', 'row_key']
],
'pre_existing_ailments' => [
'col_idx' => 14,

View File

@ -1162,28 +1162,28 @@ class TicketController extends BaseController
// --- EMPLOYEE DETAILS ---
'emp_code' => [
'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9\s\/_-]+$/]',
'errors' => [
'required' => 'Employee ID is required.',
'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).'
'regex_match' => 'Employee ID can only contain letters, numbers, spaces, slashes (/), hyphens (-) and underscores (_).'
]
],
'emp_name' => [
'label' => 'Employee Name',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s_-]+$/]',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\/_-]+$/]',
'errors' => [
'required' => 'Employee Name is required',
'min_length' => 'Employee Name must be at least 3 characters long',
'regex_match' => 'Employee Name can only contain letters, numbers, spaces, hyphens, and underscores.'
'regex_match' => 'Employee Name can only contain letters, numbers, spaces, slashes (/), hyphens (-), and underscores (_).'
]
],
'insured_name' => [
'label' => 'Insured Name',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s_-]+$/]',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\/_-]+$/]',
'errors' => [
'required' => 'Insured Name is required',
'min_length' => 'Insured Name must be at least 3 characters long',
'regex_match' => 'Insured Name can only contain letters, numbers, spaces, hyphens, and underscores.'
'regex_match' => 'Insured Name can only contain letters, numbers, spaces, slashes (/), hyphens (-), and underscores (_).'
]
],
'relationship' => ['label' => 'Relationship','rules' => 'required',
@ -1393,19 +1393,19 @@ class TicketController extends BaseController
// --- EMPLOYEE DETAILS ---
'emp_code' => [
'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9\s\/_-]+$/]',
'errors' => [
'required' => 'Employee ID is required.',
'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
'regex_match' => 'Employee ID can only contain letters, numbers, spaces, slashes (/), hyphens (-) and underscores (_).',
]
],
'emp_name' => [
'label' => 'Employee Name',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s_-]+$/]',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\/_-]+$/]',
'errors' => [
'required' => 'Employee Name is required',
'min_length' => 'Employee Name must be at least 3 characters long',
'regex_match' => 'Employee Name can only contain letters, numbers, spaces, hyphens, and underscores.'
'regex_match' => 'Employee Name can only contain letters, numbers, spaces, slashes (/), hyphens (-), and underscores (_).'
]
],
'emp_mobile' => ['label' => 'Employee Mobile No','rules' => 'required|numeric|exact_length[10]',
@ -1650,28 +1650,28 @@ class TicketController extends BaseController
// --- EMPLOYEE DETAILS ---
'emp_code' => [
'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9\s\/_-]+$/]',
'errors' => [
'required' => 'Employee ID is required.',
'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
'regex_match' => 'Employee ID can only contain letters, numbers, spaces, slashes (/), hyphens (-) and underscores (_).',
]
],
'emp_name' => [
'label' => 'Employee Name',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s_-]+$/]',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\/_-]+$/]',
'errors' => [
'required' => 'Employee Name is required',
'min_length' => 'Employee Name must be at least 3 characters long',
'regex_match' => 'Employee Name can only contain letters, numbers, spaces, hyphens, and underscores.'
'regex_match' => 'Employee Name can only contain letters, numbers, spaces, slashes (/), hyphens (-), and underscores (_).'
]
],
'insured_name' => [
'label' => 'Insured Name',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s_-]+$/]',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\/_-]+$/]',
'errors' => [
'required' => 'Insured Name is required',
'min_length' => 'Insured Name must be at least 3 characters long',
'regex_match' => 'Insured Name can only contain letters, numbers, spaces, hyphens, and underscores.'
'regex_match' => 'Insured Name can only contain letters, numbers, spaces, slashes (/), hyphens (-), and underscores (_).'
]
],
'relationship' => ['label' => 'Relationship','rules' => 'required',
@ -1882,19 +1882,19 @@ class TicketController extends BaseController
// --- EMPLOYEE DETAILS ---
'emp_code' => [
'label' => 'Employee ID',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]',
'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9\s\/_-]+$/]',
'errors' => [
'required' => 'Employee ID is required.',
'regex_match' => 'Employee ID cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).',
'regex_match' => 'Employee ID can only contain letters, numbers, spaces, slashes (/), hyphens (-) and underscores (_).',
]
],
'emp_name' => [
'label' => 'Employee Name',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s_-]+$/]',
'rules' => 'required|min_length[3]|regex_match[/^[a-zA-Z0-9\s\/_-]+$/]',
'errors' => [
'required' => 'Employee Name is required',
'min_length' => 'Employee Name must be at least 3 characters long',
'regex_match' => 'Employee Name can only contain letters, numbers, spaces, hyphens, and underscores.'
'regex_match' => 'Employee Name can only contain letters, numbers, spaces, slashes (/), hyphens (-), and underscores (_).'
]
],
'emp_mobile' => ['label' => 'Employee Mobile No','rules' => 'required|numeric|exact_length[10]',

View File

@ -2107,8 +2107,8 @@ if (!function_exists('remap_default_age_ratio_into_relationship')) {
}
}
if (!function_exists('check_dup_mobileno')) {
function check_dup_mobileno(array $row, array $existing_mobilenos)
if (!function_exists('check_dup_mobileno_old')) {
function check_dup_mobileno_old(array $row, array $existing_mobilenos)
{
if(!empty($row['12'])){
foreach ($existing_mobilenos as $k => $value) {
@ -2122,6 +2122,41 @@ if (!function_exists('check_dup_mobileno')) {
}
}
if (!function_exists('check_dup_mobileno')) {
function check_dup_mobileno(array $row, array $existing_mobilenos, $excel_data = [], $row_key = null)
{
if(!empty($row['12'])){
$current_relation = strtolower(trim($row['5'] ?? ''));
$current_mobile = trim((string) $row['12']);
foreach ($existing_mobilenos as $k => $value) {
if ($current_relation == 'self' && $current_mobile == trim((string) ($value['mobile'] ?? ''))) {
return array('status' => false, 'error' => "Duplicate Mobile No");
// break;
}
}
foreach ($excel_data as $ed_row => $value) {
if ($row_key !== null && (string) $ed_row === (string) $row_key) {
continue;
}
$excel_relation = strtolower(trim($value['5'] ?? ''));
$excel_mobile = trim((string) ($value['12'] ?? ''));
if ($current_relation == 'self' && $excel_relation == 'self' && $excel_mobile !== '' && $current_mobile == $excel_mobile) {
$duplicate_row_no = is_numeric($ed_row) ? $ed_row + 1 : $ed_row;
$current_row_no = is_numeric($row_key) ? $row_key + 1 : $row_key;
return array('status' => false, 'error' => "This mobile number has already been used for another self in Excel at row no. " . ($duplicate_row_no) . " and " . ($current_row_no));
// break;
}
}
}
return array('status' => true);
}
}
// if (!function_exists('check_dup_email')) {
// function check_dup_email(array $row, array $existing_mobilenos)
// {
@ -2138,8 +2173,8 @@ if (!function_exists('check_dup_mobileno')) {
// }
// }
if (!function_exists('check_dup_email')) {
function check_dup_email(array $row, array $existing_mobilenos)
if (!function_exists('check_dup_email_old')) {
function check_dup_email_old(array $row, array $existing_mobilenos)
{
$errorMessages = [];
@ -2168,6 +2203,54 @@ if (!function_exists('check_dup_email')) {
}
}
if (!function_exists('check_dup_email')) {
function check_dup_email(array $row, array $existing_mobilenos, $excel_data = [], $row_key = null)
{
$errorMessages = [];
$current_relation = strtolower(trim($row['5'] ?? ''));
$current_email = trim((string) ($row['13'] ?? ''));
// Validate email
$emailCheck = is_valid_or_empty_email($current_email);
if (!$emailCheck) {
$errorMessages[] = 'Invalid email format';
}
// Check duplicate only if email is not empty
if (!empty($current_email)) {
foreach ($existing_mobilenos as $value) {
if ($current_relation === 'self' && strcasecmp($current_email, trim((string) ($value['email_corporate'] ?? ''))) === 0) {
$errorMessages[] = 'Duplicate Email';
break;
}
}
foreach ($excel_data as $ed_row => $value) {
if ($row_key !== null && (string) $ed_row === (string) $row_key) {
continue;
}
$excel_relation = strtolower(trim($value['5'] ?? ''));
$excel_email = trim((string) ($value['13'] ?? ''));
if ($current_relation === 'self' && $excel_relation === 'self' && $excel_email !== '' && strcasecmp($current_email, $excel_email) === 0) {
$duplicate_row_no = is_numeric($ed_row) ? $ed_row + 1 : $ed_row;
$current_row_no = is_numeric($row_key) ? $row_key + 1 : $row_key;
$errorMessages[] = "This email has already been used for another self in Excel at row no. " . ($duplicate_row_no) . " and " . ($current_row_no);
break;
}
}
}
// Prepare final return
if (!empty($errorMessages)) {
return ['status' => false, 'error' => implode(' & ', $errorMessages)];
}
return ['status' => true, 'error' => ''];
}
}
if (!function_exists('generate_family_relationship_array')) {
function generate_family_relationship_array($family_structure_from_policy_terms)

View File

@ -298,6 +298,7 @@ $fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len
</div>
<div class="modal-body">
<form class="parsley-examples" id="uploadForm" action="<?php echo base_url() . 'employee/upload' ?>"
method="post"
enctype="multipart/form-data">
<input type="hidden" id="file_client_id" name="client_id">
<input type="hidden" id="file_policy_id" name="policy_id">
@ -439,6 +440,9 @@ $fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len
title: "Deleted!",
icon: "success"
});
window.location.reload(true);
} else if (response.code === 404 && response.dataStatus === false) {
console.error('No data found', response);
handleNoDataFound(response, fileId);
@ -455,10 +459,8 @@ $fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data from API:', error);
toastr.error('Something went wrong! Try later', 'Error');
@ -501,6 +503,9 @@ $fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len
title: "Deleted!",
icon: "success"
});
window.location.reload(true);
} else if (response.code === 404 && response.dataStatus === false) {
console.error('No data found', response);
Swal.fire({
@ -537,12 +542,14 @@ $fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len
}
}
$('#uploadForm').submit(function() {
$('#uploadForm').submit(function(event) {
event.preventDefault();
var isValid = $('#uploadForm').parsley().validate();
if (!isValid) {
console.log('Form is Empty', 'Warning');
return;
return false;
}
// Create FormData object
@ -595,6 +602,8 @@ $fl_col_width_px = nhance_dt_column_widths_px($fl_header_labels, $fl_col_max_len
window.location.reload(true);
}
});
return false;
})
$('body').on('click', '.reload', function() {

View File

@ -1358,10 +1358,17 @@
toastr.error(response.message || 'Unable to fetch data', 'Error');
}
setTimeout(function() {
window.location.reload();
}, 500);
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching TPA ID.', 'Error');
setTimeout(function() {
window.location.reload();
}, 500);
});
@ -1421,10 +1428,18 @@
toastr.error(response.message || 'Unable to fetch data', 'Error');
}
setTimeout(function() {
window.location.reload();
}, 500);
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while pushing.', 'Error');
setTimeout(function() {
window.location.reload();
}, 500);
});