FEAT_MEMBER_DATA_COMPATIONSION_AND_M_MALE_CHANGE
This commit is contained in:
parent
c96256340e
commit
653403e9b3
@ -400,6 +400,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->match(['get', 'post', 'delete'], 'vehicleTypeMaster', 'MasterController::vehicleTypeMaster');
|
||||
$routes->match(['get', 'post', 'delete'], 'rtoMaster', 'MasterController::rtoMaster');
|
||||
$routes->get('checkDuplicateCdAccount', 'MasterController::checkDuplicateCdAccount');
|
||||
$routes->get('proceedExcelFileDataValidation', 'EmployeeController::proceedExcelFileDataValidation');
|
||||
});
|
||||
|
||||
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
|
||||
|
||||
@ -5640,11 +5640,11 @@ class ClientController extends AdminController
|
||||
|
||||
public function sendextraparam()
|
||||
{
|
||||
// $data = db_connect()->table('jobs')->where('id', 1677)->get()->getRowArray();
|
||||
// // dd($data);
|
||||
// $return = $this->updatePolicyTransactionDataWhileClinetPolicyUpdate(json_decode($data['payload'], true));
|
||||
// dd($return);
|
||||
// die;
|
||||
// $data = db_connect()->table('jobs')->where('id', 1677)->get()->getRowArray();
|
||||
// // dd($data);
|
||||
// $return = $this->updatePolicyTransactionDataWhileClinetPolicyUpdate(json_decode($data['payload'], true));
|
||||
// dd($return);
|
||||
// die;
|
||||
|
||||
// $employeeController = new EmployeeController();
|
||||
// $employeeController->truncateFileData('633');
|
||||
@ -5662,15 +5662,16 @@ class ClientController extends AdminController
|
||||
// ---------- EMP SERVICE CONTROLLER --------------------------------------------------------------------------------
|
||||
|
||||
$empServiceController = new EmployeeServiceController();
|
||||
$res = $empServiceController->excelFileFormatValidation(['file_id' => '2055']);
|
||||
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '1126']);
|
||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '865']);
|
||||
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 726]);
|
||||
// $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]);
|
||||
// $res = $empServiceController->employeesEnrollmentInsert(['file_id' => 836]);
|
||||
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']);
|
||||
// $res = $empServiceController->employeeDisembark(['file_id' => '1681']);
|
||||
// $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']);
|
||||
dd($res);
|
||||
// $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']);
|
||||
// $res = $empServiceController->compareMemberDataAndInceptionData(['file_id' => '1126']);
|
||||
// dd($res);
|
||||
|
||||
$EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController();
|
||||
// $res = $EmployeeMultiEventServiceController->constructMultiEventData(['file_id' => '1069']);
|
||||
|
||||
@ -171,7 +171,7 @@ class EmployeeController extends AdminController
|
||||
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
} else {
|
||||
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $file['reason']], 200);
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $file['reason'], 'is_comparison_skipped' => $file['is_comparison_skipped']], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3148,5 +3148,31 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
// function for skip the Inception and Member data validation
|
||||
public function proceedExcelFileDataValidation()
|
||||
{
|
||||
$file_id = $this->request->getGet('file_id');
|
||||
$not_skiped = $this->request->getGet('not_skiped') ?? null;
|
||||
|
||||
if(!empty($not_skiped)){
|
||||
$file_model = new FileModel();
|
||||
$file_model->where('id', $file_id)->set(['is_comparison_skipped' => 0])->update();
|
||||
$message = "Inception and Member data comparision continuted by the user id : " . get_session_userid();
|
||||
$this->myLogger->logme('error', $message);
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Inception and Member data comparision continued'], 200);
|
||||
}
|
||||
|
||||
if(!empty($file_id)){
|
||||
$r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]);
|
||||
$message = "Inception and Member data comparision skiped successfully by the user id : " . get_session_userid();
|
||||
$this->myLogger->logme('error', $message);
|
||||
$file_model = new FileModel();
|
||||
$file_model->where('id', $file_id)->set(['is_comparison_skipped' => 1])->update();
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Inception and Member data comparision skiped successfully!'], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 500, 'message' => 'Failed to skip the comparison!'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use Kint\Kint;
|
||||
|
||||
use App\Helpers\ExcelSanitizeHelper;
|
||||
use App\Models\LeadsModel;
|
||||
|
||||
class EmployeeMultiEventServiceController extends BaseController
|
||||
{
|
||||
@ -140,7 +141,7 @@ class EmployeeMultiEventServiceController extends BaseController
|
||||
'is_mandatory' => ['I', 'A', 'DA'],
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => ['M', 'F']
|
||||
'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female']
|
||||
],
|
||||
'relationship' => [
|
||||
'col_idx' => 5,
|
||||
@ -524,7 +525,7 @@ class EmployeeMultiEventServiceController extends BaseController
|
||||
'is_mandatory' => ['I', 'A', 'DA', 'E'],
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => ['M', 'F']
|
||||
'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female']
|
||||
],
|
||||
'relationship' => [
|
||||
'col_idx' => 5,
|
||||
@ -889,8 +890,108 @@ class EmployeeMultiEventServiceController extends BaseController
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
|
||||
protected $member_data_excel_columns = [
|
||||
'sno' => [
|
||||
'col_idx' => 0,
|
||||
'col_cell_name' => 'A',
|
||||
'col_name' => 'Sl no',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'emp_code' => [
|
||||
'col_idx' => 1,
|
||||
'col_cell_name' => 'B',
|
||||
'col_name' => 'Emp Code',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'name' => [
|
||||
'col_idx' => 2,
|
||||
'col_cell_name' => 'C',
|
||||
'col_name' => 'Name',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'relationship' => [
|
||||
'col_idx' => 3,
|
||||
'col_cell_name' => 'D',
|
||||
'col_name' => 'Relationship',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => [
|
||||
'Self', 'Spouse', 'Son', 'Daughter', 'Father', 'Mother',
|
||||
'Father-in-law', 'Mother-in-law',
|
||||
'self', 'spouse', 'son', 'daughter', 'father', 'mother',
|
||||
'father-in-law', 'mother-in-law'
|
||||
],
|
||||
'custom' => 'check_relationship_for_member_data',
|
||||
'params' => ['row', 'relationship', 'columns_to_check']
|
||||
],
|
||||
'gender' => [
|
||||
'col_idx' => 4,
|
||||
'col_cell_name' => 'E',
|
||||
'col_name' => 'Gender',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female']
|
||||
],
|
||||
'dob' => [
|
||||
'col_idx' => 5,
|
||||
'col_cell_name' => 'F',
|
||||
'col_name' => 'DOB',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => 'd-M-Y',
|
||||
'allowed_values' => null,
|
||||
'age_validation' => true,
|
||||
// 'custom' => 'check_dob_diff',
|
||||
// 'params' => ['row', 'relationship', 'default_age_ratio', 'policy_details']
|
||||
],
|
||||
'age' => [
|
||||
'col_idx' => 6,
|
||||
'col_cell_name' => 'G',
|
||||
'col_name' => 'Age',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'int',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'email' => [
|
||||
'col_idx' => 7,
|
||||
'col_cell_name' => 'H',
|
||||
'col_name' => 'Email',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'mobile' => [
|
||||
'col_idx' => 8,
|
||||
'col_cell_name' => 'I',
|
||||
'col_name' => 'Mobile',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'si' => [
|
||||
'col_idx' => 9,
|
||||
'col_cell_name' => 'J',
|
||||
'col_name' => 'SI',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => 'int',
|
||||
'format' => null,
|
||||
'allowed_values' => null,
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -991,6 +1092,9 @@ class EmployeeMultiEventServiceController extends BaseController
|
||||
$params["action"] = "inception";
|
||||
$params["file_path"] = $file_paths['inception'];
|
||||
$error[] = $this->excelFileFormatValidation($params);
|
||||
if (isset($error['error_data']) && count($error['error_data']) == 0) {
|
||||
$error[] = $this->compareMemberDataAndInceptionData($params);
|
||||
}
|
||||
}
|
||||
|
||||
//addition
|
||||
@ -2125,10 +2229,9 @@ class EmployeeMultiEventServiceController extends BaseController
|
||||
foreach ($familiy_data as $fkey => $value) {
|
||||
if (is_array($value)) {
|
||||
|
||||
|
||||
if (isset($value['gender'])) { $value['gender'] = normalizeGender($value['gender'] );}
|
||||
if ($file['id'] == null || $value['temp']['source'] == 'excel' || (($file['action'] == 'dependent_addition' && ($value['temp']['premium_type'] == 1 && strtolower($value['relationship']) == 'self') || ($value['temp']['premium_type'] == 2 || $value['temp']['premium_type'] == null)))) //insert data come from excel and from db i.e. ( $file['id'] == null for enrollment data)
|
||||
{
|
||||
|
||||
$employee = $this->employeeModel->checkExistingEmp($value, $file['client_branch_id']);
|
||||
$policy_data = $value['policy_details'];
|
||||
$temp = $value['temp'];
|
||||
@ -2881,6 +2984,135 @@ class EmployeeMultiEventServiceController extends BaseController
|
||||
return $temp;
|
||||
}
|
||||
|
||||
// --------- MEMBER DATA AND INCEPTION DATA COMPARISION ------------------------------------------------------------------------
|
||||
|
||||
public function compareMemberDataAndInceptionData($params)
|
||||
{
|
||||
$file_id = $params['file_id'] ?? null;
|
||||
if (empty($file_id)) {
|
||||
return ['status' => false, 'msg' => 'File ID is missing'];
|
||||
}
|
||||
|
||||
// ✅ Get File Data
|
||||
$file = $this->fileModel->where(['is_active' => 1, 'id' => $file_id])->first();
|
||||
if (empty($file)) {
|
||||
return ['status' => false, 'msg' => 'File not found in DB'];
|
||||
}
|
||||
|
||||
// ✅ Get Client Policy Data
|
||||
$client_policy_data = $this->clientPolicyModel->where(['is_active' => 1, 'id' => $file['policy_id']])->first();
|
||||
if (empty($client_policy_data)) {
|
||||
return ['status' => false, 'msg' => 'Client policy data not found in DB (policy_id: ' . $file['policy_id'] . ')'];
|
||||
}
|
||||
|
||||
// ✅ Get Lead Data
|
||||
$leadModel = new LeadsModel();
|
||||
$lead_data = $leadModel->where(['is_active' => 1, 'id' => $client_policy_data['is_from_lead']])->first();
|
||||
if (empty($lead_data)) {
|
||||
return ['status' => false, 'msg' => 'Lead data not found in DB (lead_id: ' . $client_policy_data['is_from_lead'] . ')'];
|
||||
}
|
||||
|
||||
// ✅ Define File Paths
|
||||
// $inception_file_path = !empty($file['file_name']) ? WRITEPATH . "uploads/excel/" . $file['file_name'] : '';
|
||||
$member_file_path = !empty($lead_data['file_name']) ? WRITEPATH . "uploads/lead_files/" . $lead_data['file_name'] : '';
|
||||
|
||||
// ✅ Check Inception File
|
||||
// if (empty($file['file_name']) || !file_exists($inception_file_path)) {
|
||||
// $message = empty($file['file_name']) ? "Inception file name is missing" : "Inception physical file not found";
|
||||
// $this->myLogger->logme('error', "$message for file id $file_id");
|
||||
// $this->fileModel->update($file_id, [
|
||||
// 'status' => 'failed',
|
||||
// 'reason' => json_encode(['error_summary' => [5], 'error_data' => $message])
|
||||
// ]);
|
||||
// return ['error_summary' => [5], 'error_data' => $message];
|
||||
// }
|
||||
|
||||
// ✅ Check Member File
|
||||
if (empty($lead_data['file_name']) || !file_exists($member_file_path)) {
|
||||
$message = empty($lead_data['file_name']) ? "Member file name is missing" : "Member data physical file not found";
|
||||
$this->myLogger->logme('error', "$message for lead id {$lead_data['id']}");
|
||||
$this->fileModel->update($file_id, [
|
||||
'status' => 'failed',
|
||||
'reason' => json_encode(['error_summary' => [5], 'error_data' => $message])
|
||||
]);
|
||||
return ['error_summary' => [5], 'error_data' => $message];
|
||||
}
|
||||
|
||||
|
||||
// ✅ Read Inception Excel
|
||||
$inception_columns = $this->inception_excel_columns;
|
||||
$inception_data = json_decode(file_get_contents($params['file_path'] ?? []), true);
|
||||
// $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inception_file_path);
|
||||
// $sheet = $spreadsheet->getActiveSheet();
|
||||
// $highestRow = $sheet->getHighestDataRow();
|
||||
// $allowedColumn = end($inception_columns)['col_cell_name'];
|
||||
// $inception_data = $sheet->rangeToArray("A1:{$allowedColumn}{$highestRow}");
|
||||
// $inception_data = ExcelSanitizeHelper::sanitizeArrayData($inception_data);
|
||||
|
||||
// ✅ Read Member Excel
|
||||
$member_columns = $this->member_data_excel_columns;
|
||||
$spreadsheet2 = \PhpOffice\PhpSpreadsheet\IOFactory::load($member_file_path);
|
||||
$sheet2 = $spreadsheet2->getSheet(0);
|
||||
$highestRow2 = $sheet2->getHighestDataRow();
|
||||
$allowedColumn2 = end($member_columns)['col_cell_name'];
|
||||
$member_data = $sheet2->rangeToArray("A1:{$allowedColumn2}{$highestRow2}");
|
||||
$member_data = ExcelSanitizeHelper::sanitizeArrayData($member_data);
|
||||
|
||||
// dd($inception_data, $member_data);
|
||||
|
||||
// ✅ Compare Inception Data with Member Data
|
||||
$result = ['error_type' => 2, 'error_summary' => [], 'error_data' => []];
|
||||
|
||||
$inception_data_count = count($inception_data);
|
||||
$member_data_count = count($member_data);
|
||||
|
||||
if ($inception_data_count !== $member_data_count) {
|
||||
$result['error_summary'][] = 15;
|
||||
$result['error_message'] = "
|
||||
<strong>Inception Data Count:</strong>
|
||||
<span class='badge badge-danger'>{$inception_data_count}</span>
|
||||
<strong>Member Data Count:</strong>
|
||||
<span class='badge badge-danger'>{$member_data_count}</span>";
|
||||
}
|
||||
|
||||
foreach ($inception_data as $inception_key => $inception_row) {
|
||||
|
||||
// 🔹 If inception row is empty → stop all further processing
|
||||
if (check_row_is_empty_or_null($inception_row)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$match_found = false;
|
||||
|
||||
foreach ($member_data as $member_row) {
|
||||
if (
|
||||
$inception_row[1] == $member_row[1] && // emp_id / emp_code
|
||||
$inception_row[2] == $member_row[2] && // name_of_emp_dep / name
|
||||
$inception_row[5] == $member_row[3] && // relationship
|
||||
normalizeGender($inception_row[4]) == normalizeGender($member_row[4]) && // gender
|
||||
$inception_row[3] == $member_row[5] && // dob
|
||||
$inception_row[13] == $member_row[7] && // email
|
||||
$inception_row[12] == $member_row[8] // phone / mobile
|
||||
) {
|
||||
$match_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$match_found) {
|
||||
array_push($result['error_summary'], 14);
|
||||
$result['error_data'][$inception_key]['sno']['error'][] = "This inception row was not found in the member data list.";
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ Handle Result
|
||||
if (!empty($result['error_summary'])) {
|
||||
$result['error_summary'] = array_count_values($result['error_summary']);
|
||||
$this->myLogger->logme('error', "File ID $file_id comparison failed");
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use Kint\Kint;
|
||||
|
||||
use App\Helpers\ExcelSanitizeHelper;
|
||||
|
||||
use App\Models\LeadsModel;
|
||||
|
||||
class EmployeeServiceController extends AdminController
|
||||
{
|
||||
@ -144,7 +144,7 @@ class EmployeeServiceController extends AdminController
|
||||
'is_mandatory' => ['I', 'A', 'DA'],
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => ['M', 'F']
|
||||
'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female']
|
||||
],
|
||||
'relationship' => [
|
||||
'col_idx' => 5,
|
||||
@ -529,7 +529,8 @@ class EmployeeServiceController extends AdminController
|
||||
'is_mandatory' => ['I', 'A', 'DA','E'],
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => ['M', 'F']
|
||||
'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female']
|
||||
|
||||
],
|
||||
'relationship' => [
|
||||
'col_idx' => 5,
|
||||
@ -643,21 +644,121 @@ class EmployeeServiceController extends AdminController
|
||||
];
|
||||
|
||||
protected $enrollment_to_inception_mapping = [
|
||||
0 => 0, // enrollment: sno (Sno) -> inception: sno (S.No)
|
||||
1 => 1, // enrollment: emp_code (Emp_Code) -> inception: emp_id (EMP ID)
|
||||
2 => 2, // enrollment: name (NAME OF EMP/DEP) -> inception: name_of_emp_dep (NAME OF EMP/DEP)
|
||||
3 => 8, // enrollment: doj (DOJ) -> inception: doj (DOJ)
|
||||
4 => 4, // enrollment: gender (Gender) -> inception: gender (Gender)
|
||||
5 => 5, // enrollment: relationship (Relation) -> inception: relationship (RELATIONSHIP)
|
||||
6 => 3, // enrollment: dob (DOB) -> inception: dob (DOB)
|
||||
7 => 13, // enrollment: email (Email) -> inception: email (Email)
|
||||
8 => 12, // enrollment: phone (Mobile) -> inception: phone (Phone)
|
||||
9 => 6, // enrollment: basic_cover_si (SI) -> inception: basic_cover_si (BASIC COVER SI)
|
||||
10 => 10, // enrollment: band_grade (Grade) -> inception: band_grade (Band/Grade)
|
||||
11 => 9 // enrollment: basic_pay (Basic Pay) -> inception: basic_pay (Basic Pay)
|
||||
];
|
||||
|
||||
|
||||
0 => 0, // enrollment: sno (Sno) -> inception: sno (S.No)
|
||||
1 => 1, // enrollment: emp_code (Emp_Code) -> inception: emp_id (EMP ID)
|
||||
2 => 2, // enrollment: name (NAME OF EMP/DEP) -> inception: name_of_emp_dep (NAME OF EMP/DEP)
|
||||
3 => 8, // enrollment: doj (DOJ) -> inception: doj (DOJ)
|
||||
4 => 4, // enrollment: gender (Gender) -> inception: gender (Gender)
|
||||
5 => 5, // enrollment: relationship (Relation) -> inception: relationship (RELATIONSHIP)
|
||||
6 => 3, // enrollment: dob (DOB) -> inception: dob (DOB)
|
||||
7 => 13, // enrollment: email (Email) -> inception: email (Email)
|
||||
8 => 12, // enrollment: phone (Mobile) -> inception: phone (Phone)
|
||||
9 => 6, // enrollment: basic_cover_si (SI) -> inception: basic_cover_si (BASIC COVER SI)
|
||||
10 => 10, // enrollment: band_grade (Grade) -> inception: band_grade (Band/Grade)
|
||||
11 => 9 // enrollment: basic_pay (Basic Pay) -> inception: basic_pay (Basic Pay)
|
||||
];
|
||||
protected $member_data_excel_columns = [
|
||||
'sno' => [
|
||||
'col_idx' => 0,
|
||||
'col_cell_name' => 'A',
|
||||
'col_name' => 'Sl no',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'emp_code' => [
|
||||
'col_idx' => 1,
|
||||
'col_cell_name' => 'B',
|
||||
'col_name' => 'Emp Code',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'name' => [
|
||||
'col_idx' => 2,
|
||||
'col_cell_name' => 'C',
|
||||
'col_name' => 'Name',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'relationship' => [
|
||||
'col_idx' => 3,
|
||||
'col_cell_name' => 'D',
|
||||
'col_name' => 'Relationship',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => [
|
||||
'Self', 'Spouse', 'Son', 'Daughter', 'Father', 'Mother',
|
||||
'Father-in-law', 'Mother-in-law',
|
||||
'self', 'spouse', 'son', 'daughter', 'father', 'mother',
|
||||
'father-in-law', 'mother-in-law'
|
||||
],
|
||||
'custom' => 'check_relationship_for_member_data',
|
||||
'params' => ['row', 'relationship', 'columns_to_check']
|
||||
],
|
||||
'gender' => [
|
||||
'col_idx' => 4,
|
||||
'col_cell_name' => 'E',
|
||||
'col_name' => 'Gender',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => ['M', 'F', 'Male', 'Female', 'male', 'female']
|
||||
],
|
||||
'dob' => [
|
||||
'col_idx' => 5,
|
||||
'col_cell_name' => 'F',
|
||||
'col_name' => 'DOB',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'str',
|
||||
'format' => 'd-M-Y',
|
||||
'allowed_values' => null,
|
||||
'age_validation' => true,
|
||||
// 'custom' => 'check_dob_diff',
|
||||
// 'params' => ['row', 'relationship', 'default_age_ratio', 'policy_details']
|
||||
],
|
||||
'age' => [
|
||||
'col_idx' => 6,
|
||||
'col_cell_name' => 'G',
|
||||
'col_name' => 'Age',
|
||||
'is_mandatory' => true,
|
||||
'data_type' => 'int',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'email' => [
|
||||
'col_idx' => 7,
|
||||
'col_cell_name' => 'H',
|
||||
'col_name' => 'Email',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'mobile' => [
|
||||
'col_idx' => 8,
|
||||
'col_cell_name' => 'I',
|
||||
'col_name' => 'Mobile',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => 'str',
|
||||
'format' => null,
|
||||
'allowed_values' => null
|
||||
],
|
||||
'si' => [
|
||||
'col_idx' => 9,
|
||||
'col_cell_name' => 'J',
|
||||
'col_name' => 'SI',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => 'int',
|
||||
'format' => null,
|
||||
'allowed_values' => null,
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -923,7 +1024,14 @@ class EmployeeServiceController extends AdminController
|
||||
|
||||
}
|
||||
else //trigger next data validation via job queue server
|
||||
{
|
||||
{
|
||||
// check the condition if the policy from the Leads and check the lead id exist in the client policy table
|
||||
if($file['action'] == 'inception' && $policy_details[0]->policy_entry_from == 3 && !empty($policy_details[0]->is_from_lead)){
|
||||
$r = Jobs::addJob(['job_name' => 'compareMemberDataAndInceptionData','payload' => ['file_id' => $file_id]]);
|
||||
$this->myLogger->logme("error",'compareMemberDataAndInceptionData job pushed');
|
||||
return $result;
|
||||
}
|
||||
|
||||
if($file['action'] == 'enrollment' && $file['uploaded_by'] != 1) // if current action is enrollment and uploaded by HR (0 or NULL) call next validation and return result
|
||||
{
|
||||
// dd();
|
||||
@ -1542,8 +1650,7 @@ class EmployeeServiceController extends AdminController
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//enhance of emp
|
||||
//enhance of emp
|
||||
public function employeesSIEnhanceProcess($params)
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
@ -1666,9 +1773,8 @@ class EmployeeServiceController extends AdminController
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// insert or update in db for inception addition depent addition
|
||||
public function employeesOnboardProcess($params)
|
||||
public function employeesOnboardProcess($params)
|
||||
{
|
||||
// dd($params);
|
||||
|
||||
@ -1683,7 +1789,7 @@ class EmployeeServiceController extends AdminController
|
||||
if(is_array($value))
|
||||
{
|
||||
|
||||
|
||||
if (isset($value['gender'])) { $value['gender'] = normalizeGender($value['gender'] );}
|
||||
if($file['id'] == null || $value['temp']['source'] == 'excel' || (($file['action'] == 'dependent_addition' && ($value['temp']['premium_type'] == 1 && strtolower($value['relationship']) == 'self') || ($value['temp']['premium_type'] == 2 || $value['temp']['premium_type'] == null)))) //insert data come from excel and from db i.e. ( $file['id'] == null for enrollment data)
|
||||
{
|
||||
|
||||
@ -1723,7 +1829,7 @@ class EmployeeServiceController extends AdminController
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
$value['id'] = $employee[0]['id'];
|
||||
$value['emp_status'] = 'active';
|
||||
$value['family_floater_key'] = generate_family_floater_key($value['relationship']);
|
||||
$value['family_floater_key'] = generate_family_floater_key($value['relationship']);
|
||||
$value['client_branch_id'] = $file['client_branch_id'];
|
||||
$value['file_id'] = isset($employee[0]['file_id']) && $employee[0]['file_id'] != '' ? $employee[0]['file_id'] : $file['id'] ;
|
||||
$log_message = 'Update Employee - '.$employee[0]['name'].'('.$employee[0]['emp_code'].') with PK '.$employee[0]['id'];
|
||||
@ -1872,127 +1978,125 @@ class EmployeeServiceController extends AdminController
|
||||
|
||||
|
||||
}
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
public function getExcelErrorData($file_id){
|
||||
public function getExcelErrorData($file_id)
|
||||
{
|
||||
|
||||
try {
|
||||
$file = $this->fileModel->find($file_id);
|
||||
$error_data = json_decode($file['reason']);
|
||||
// dd($error_data);
|
||||
// return $error_data;
|
||||
try {
|
||||
$file = $this->fileModel->find($file_id);
|
||||
$error_data = json_decode($file['reason']);
|
||||
// dd($error_data);
|
||||
// return $error_data;
|
||||
|
||||
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
|
||||
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
|
||||
|
||||
//check the file exist or not
|
||||
if(!file_exists($file_name_with_path))
|
||||
{
|
||||
$error_message = "File not found";
|
||||
$this->myLogger->logme('error',($error_message . ' for file id ' . $file_id));
|
||||
return 0;
|
||||
}
|
||||
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||
$excelErrorData['excel_header'] = $excel_data[0];
|
||||
unset($excel_data[0]);
|
||||
// echo '<pre>';
|
||||
// Kint::dump($excel_data);
|
||||
if($error_data->error_type == 1){
|
||||
|
||||
$finalArray = [];
|
||||
foreach ($error_data->error_data as $key => $value) {
|
||||
|
||||
foreach ($value as $key2 => $value2) {
|
||||
$error_data = $value2->error;
|
||||
$data = ['value' => $excel_data[$key][$value2->col_idx], 'error'=>$error_data,];
|
||||
$excel_data[$key][$value2->col_idx] = $data;
|
||||
|
||||
}
|
||||
array_push($finalArray, $excel_data[$key]);
|
||||
//check the file exist or not
|
||||
if(!file_exists($file_name_with_path))
|
||||
{
|
||||
$error_message = "File not found";
|
||||
$this->myLogger->logme('error',($error_message . ' for file id ' . $file_id));
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ($finalArray as $fkey => $value){
|
||||
foreach ($value as $vkey => $arrayData){
|
||||
if(!is_array($arrayData)){
|
||||
$data = ['value' => $arrayData];
|
||||
$finalArray[$fkey][$vkey] = $data;
|
||||
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||
$excelErrorData['excel_header'] = $excel_data[0];
|
||||
unset($excel_data[0]);
|
||||
// echo '<pre>';
|
||||
// Kint::dump($excel_data);
|
||||
if($error_data->error_type == 1){
|
||||
|
||||
$finalArray = [];
|
||||
foreach ($error_data->error_data as $key => $value) {
|
||||
|
||||
foreach ($value as $key2 => $value2) {
|
||||
$error_data = $value2->error;
|
||||
$data = ['value' => $excel_data[$key][$value2->col_idx], 'error'=>$error_data,];
|
||||
$excel_data[$key][$value2->col_idx] = $data;
|
||||
|
||||
}
|
||||
array_push($finalArray, $excel_data[$key]);
|
||||
}
|
||||
|
||||
foreach ($finalArray as $fkey => $value){
|
||||
foreach ($value as $vkey => $arrayData){
|
||||
if(!is_array($arrayData)){
|
||||
$data = ['value' => $arrayData];
|
||||
$finalArray[$fkey][$vkey] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$excelErrorData['excel_data'] = $finalArray;
|
||||
return $excelErrorData;
|
||||
|
||||
$excelErrorData['excel_data'] = $finalArray;
|
||||
return $excelErrorData;
|
||||
|
||||
}else if($error_data->error_type == 2){
|
||||
}else if($error_data->error_type == 2){
|
||||
|
||||
|
||||
$allErrors = [];
|
||||
$typeTowArray = [];
|
||||
$allErrors = [];
|
||||
$typeTowArray = [];
|
||||
|
||||
foreach ($error_data->error_data as $index => $item) {
|
||||
foreach ($error_data->error_data as $index => $item) {
|
||||
|
||||
foreach ($item as $field) {
|
||||
if (!isset($allErrors[$index])) {
|
||||
$allErrors[$index] = [];
|
||||
foreach ($item as $field) {
|
||||
if (!isset($allErrors[$index])) {
|
||||
$allErrors[$index] = [];
|
||||
}
|
||||
$allErrors[$index] = array_merge($allErrors[$index], $field->error);
|
||||
}
|
||||
$allErrors[$index] = array_merge($allErrors[$index], $field->error);
|
||||
}
|
||||
}
|
||||
|
||||
// dd(array_keys($allErrors));
|
||||
foreach ($allErrors as $key => $value){
|
||||
// echo $key;
|
||||
// print_r($value);
|
||||
foreach($excel_data as $excel_data_index => $excel_data_value)
|
||||
{
|
||||
if($excel_data_value[0] == $key)
|
||||
// dd(array_keys($allErrors));
|
||||
foreach ($allErrors as $key => $value){
|
||||
// echo $key;
|
||||
// print_r($value);
|
||||
foreach($excel_data as $excel_data_index => $excel_data_value)
|
||||
{
|
||||
$data = ['value' => $excel_data[$excel_data_index][1], 'error'=>$value,];
|
||||
$excel_data[$excel_data_index][1] = $data;
|
||||
array_push($typeTowArray, $excel_data[$excel_data_index]);
|
||||
break;
|
||||
if($excel_data_value[0] == $key)
|
||||
{
|
||||
$data = ['value' => $excel_data[$excel_data_index][1], 'error'=>$value,];
|
||||
$excel_data[$excel_data_index][1] = $data;
|
||||
array_push($typeTowArray, $excel_data[$excel_data_index]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// dd($data);
|
||||
foreach ($typeTowArray as $fkey => $value){
|
||||
foreach ($value as $vkey => $arrayData){
|
||||
if(!is_array($arrayData)){
|
||||
$data = ['value' => $arrayData];
|
||||
$typeTowArray[$fkey][$vkey] = $data;
|
||||
|
||||
}
|
||||
// dd($data);
|
||||
foreach ($typeTowArray as $fkey => $value){
|
||||
foreach ($value as $vkey => $arrayData){
|
||||
if(!is_array($arrayData)){
|
||||
$data = ['value' => $arrayData];
|
||||
$typeTowArray[$fkey][$vkey] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$excelErrorData['excel_data'] = $typeTowArray;
|
||||
return $excelErrorData;
|
||||
|
||||
}
|
||||
|
||||
$excelErrorData['excel_data'] = $typeTowArray;
|
||||
return $excelErrorData;
|
||||
}catch (\Exception $e) {
|
||||
// Handle any exceptions
|
||||
$errorMessage = $e->getMessage();//die();
|
||||
$this->myLogger->logme('error', $errorMessage);
|
||||
return false; // You can return an error response here
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
}catch (\Exception $e) {
|
||||
// Handle any exceptions
|
||||
$errorMessage = $e->getMessage();//die();
|
||||
$this->myLogger->logme('error', $errorMessage);
|
||||
return false; // You can return an error response here
|
||||
}
|
||||
public function getFileMetaDataByFileId($file_id, $status = 'success')
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
|
||||
$data = $this->fileModel
|
||||
$data = $this->fileModel
|
||||
->select('files.*, clients.client_name, clients.short_name, policy_type.policy_type as policy_name,client_branch.branch_code')
|
||||
->join('clients', 'clients.id = files.client_id')
|
||||
->join('client_policy', 'client_policy.id = files.policy_id')
|
||||
@ -2016,11 +2120,9 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
|
||||
return ['msg_txt' => $msg_txt, 'user_id' => $user_id, 'url' => $url, 'status' => $status, 'title' => $msg_title];
|
||||
}
|
||||
|
||||
|
||||
public function setPullNotification($data){
|
||||
|
||||
|
||||
|
||||
public function setPullNotification($data)
|
||||
{
|
||||
$array = ['message_text' => $data['msg_txt'], 'action_url' => $data['url'], 'msg_status' => $data['status'], 'msg_title' => $data['title']];
|
||||
$jsonEncodeData = json_encode($array);
|
||||
|
||||
@ -2031,17 +2133,14 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
'role_id' => NULL,
|
||||
'team_id' => NULL,
|
||||
'message_type' => '1to1',
|
||||
];
|
||||
];
|
||||
|
||||
|
||||
$this->messageModel->insert($msg_data);
|
||||
|
||||
|
||||
}
|
||||
$this->messageModel->insert($msg_data);
|
||||
}
|
||||
|
||||
public function employeesEnrollmentInsert($params)
|
||||
{
|
||||
// dd($this->request);
|
||||
// dd($this->request);
|
||||
helper('excel_util_helper');
|
||||
//get file name
|
||||
$file_id = $params['file_id'];
|
||||
@ -2059,10 +2158,10 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
if(!file_exists($file_name_with_path))
|
||||
{
|
||||
//file not found update status and reason
|
||||
$message = "Physical file not found";
|
||||
$message = "Physical file not found";
|
||||
// echo $message;
|
||||
$this->myLogger->logme('error',($message . ' for file id ' . $file_id));
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
|
||||
return array('error_summary' => [5], 'error_data' => $message);
|
||||
}
|
||||
|
||||
@ -2077,7 +2176,8 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
$allowedHighestColumn = end($columns_to_check);
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
|
||||
// print_r($keys);die();
|
||||
//get existing units in the current branch
|
||||
|
||||
//get existing units in the current branch
|
||||
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
|
||||
//remove header
|
||||
unset($excel_data[0]);
|
||||
@ -2109,11 +2209,11 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
{
|
||||
$temp_unit = $existing_units[0];
|
||||
}
|
||||
|
||||
|
||||
$value['emp_code'] = $row[1];
|
||||
$value['name'] = $row[2];
|
||||
$value['doj'] = (!empty($row[3]) ? change_date_format($row[3],'d-M-Y','Y-m-d') : null );
|
||||
$value['gender'] = $row[4];
|
||||
$value['gender'] = normalizeGender($row[4]);
|
||||
$value['relationship'] = ucfirst(trim($row[5]));
|
||||
$value['dob'] = change_date_format($row[6],'d-M-Y','Y-m-d');
|
||||
$value['email_corporate'] = $row[7];
|
||||
@ -2149,10 +2249,10 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
$policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],'d-M-Y','Y-m-d') : null;
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
|
||||
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
|
||||
unset($value['temp']);
|
||||
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
|
||||
unset($value['temp']);
|
||||
//save employee table
|
||||
// dd($employee['id']);
|
||||
// dd($employee['id']);
|
||||
if($employee !== null)
|
||||
{
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
@ -2170,11 +2270,11 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
|
||||
$value = ExcelSanitizeHelper::sanitizeArrayData($value);
|
||||
$this->employeeModel->save($value);
|
||||
if (isset($value['id']))
|
||||
{ $emp_id = $value['id']; }
|
||||
else { $emp_id = $this->employeeModel->getInsertID();
|
||||
if (isset($value['id']))
|
||||
{ $emp_id = $value['id']; }
|
||||
else { $emp_id = $this->employeeModel->getInsertID();
|
||||
$log_message .= $emp_id;
|
||||
}
|
||||
}
|
||||
|
||||
// $emp_id = $this->employeeModel->getInsertID();
|
||||
// if($emp_id != 0){ $log_message .= $emp_id; }
|
||||
@ -2232,8 +2332,8 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
'employee_id' => $emp_id,
|
||||
'mail_type' => 'member_welcome_mail',
|
||||
];
|
||||
//store email and mail content via helper to send notification
|
||||
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
|
||||
//store email and mail content via helper to send notification
|
||||
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
|
||||
}
|
||||
}
|
||||
}// endof if row is empty check
|
||||
@ -2241,7 +2341,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
|
||||
// dd($emp_emails);
|
||||
|
||||
// for bulk mail queue job push
|
||||
// for bulk mail queue job push
|
||||
if (!empty($emp_emails) && count($emp_emails) > 0) {
|
||||
|
||||
$emp_emails = array_chunk($emp_emails, 20);
|
||||
@ -2259,6 +2359,140 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
|
||||
|
||||
return true;
|
||||
}//end of employeesEnrollmentInsert
|
||||
} //end of employeesEnrollmentInsert
|
||||
|
||||
// --------- MEMBER DATA AND INCEPTION DATA COMPARISION ------------------------------------------------------------------------
|
||||
|
||||
public function compareMemberDataAndInceptionData($params)
|
||||
{
|
||||
$file_id = $params['file_id'] ?? null;
|
||||
if (empty($file_id)) {
|
||||
return ['status' => false, 'msg' => 'File ID is missing'];
|
||||
}
|
||||
|
||||
// ✅ Get File Data
|
||||
$file = $this->fileModel->where(['is_active' => 1, 'id' => $file_id])->first();
|
||||
if (empty($file)) {
|
||||
return ['status' => false, 'msg' => 'File not found in DB'];
|
||||
}
|
||||
|
||||
// ✅ Get Client Policy Data
|
||||
$client_policy_data = $this->clientPolicyModel->where(['is_active' => 1, 'id' => $file['policy_id']])->first();
|
||||
if (empty($client_policy_data)) {
|
||||
return ['status' => false, 'msg' => 'Client policy data not found in DB (policy_id: ' . $file['policy_id'] . ')'];
|
||||
}
|
||||
|
||||
// ✅ Get Lead Data
|
||||
$leadModel = new LeadsModel();
|
||||
$lead_data = $leadModel->where(['is_active' => 1, 'id' => $client_policy_data['is_from_lead']])->first();
|
||||
if (empty($lead_data)) {
|
||||
return ['status' => false, 'msg' => 'Lead data not found in DB (lead_id: ' . $client_policy_data['is_from_lead'] . ')'];
|
||||
}
|
||||
|
||||
// ✅ Define File Paths
|
||||
$inception_file_path = !empty($file['file_name']) ? WRITEPATH . "uploads/excel/" . $file['file_name'] : '';
|
||||
$member_file_path = !empty($lead_data['file_name']) ? WRITEPATH . "uploads/lead_files/" . $lead_data['file_name'] : '';
|
||||
|
||||
// ✅ Check Inception File
|
||||
if (empty($file['file_name']) || !file_exists($inception_file_path)) {
|
||||
$message = empty($file['file_name']) ? "Inception file name is missing" : "Inception physical file not found";
|
||||
$this->myLogger->logme('error', "$message for file id $file_id");
|
||||
$this->fileModel->update($file_id, [
|
||||
'status' => 'failed',
|
||||
'reason' => json_encode(['error_summary' => [5], 'error_data' => $message])
|
||||
]);
|
||||
return ['error_summary' => [5], 'error_data' => $message];
|
||||
}
|
||||
|
||||
// ✅ Check Member File
|
||||
if (empty($lead_data['file_name']) || !file_exists($member_file_path)) {
|
||||
$message = empty($lead_data['file_name']) ? "Member file name is missing" : "Member data physical file not found";
|
||||
$this->myLogger->logme('error', "$message for lead id {$lead_data['id']}");
|
||||
$this->fileModel->update($file_id, [
|
||||
'status' => 'failed',
|
||||
'reason' => json_encode(['error_summary' => [5], 'error_data' => $message])
|
||||
]);
|
||||
return ['error_summary' => [5], 'error_data' => $message];
|
||||
}
|
||||
|
||||
|
||||
// ✅ Read Inception Excel
|
||||
$inception_columns = $this->inception_excel_columns;
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inception_file_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$highestRow = $sheet->getHighestDataRow();
|
||||
$allowedColumn = end($inception_columns)['col_cell_name'];
|
||||
$inception_data = $sheet->rangeToArray("A1:{$allowedColumn}{$highestRow}");
|
||||
$inception_data = ExcelSanitizeHelper::sanitizeArrayData($inception_data);
|
||||
|
||||
// ✅ Read Member Excel
|
||||
$member_columns = $this->member_data_excel_columns;
|
||||
$spreadsheet2 = \PhpOffice\PhpSpreadsheet\IOFactory::load($member_file_path);
|
||||
$sheet2 = $spreadsheet2->getSheet(0);
|
||||
$highestRow2 = $sheet2->getHighestDataRow();
|
||||
$allowedColumn2 = end($member_columns)['col_cell_name'];
|
||||
$member_data = $sheet2->rangeToArray("A1:{$allowedColumn2}{$highestRow2}");
|
||||
$member_data = ExcelSanitizeHelper::sanitizeArrayData($member_data);
|
||||
|
||||
// dd($inception_data, $member_data);
|
||||
|
||||
// ✅ Compare Inception Data with Member Data
|
||||
$result = ['error_type' => 2, 'error_summary' => [], 'error_data' => []];
|
||||
|
||||
$inception_data_count = count($inception_data);
|
||||
$member_data_count = count($member_data);
|
||||
|
||||
if ($inception_data_count !== $member_data_count) {
|
||||
$result['error_summary'][] = 15;
|
||||
$result['error_message'] = "
|
||||
<strong>Inception Data Count:</strong>
|
||||
<span class='badge badge-danger'>{$inception_data_count}</span>
|
||||
<strong>Member Data Count:</strong>
|
||||
<span class='badge badge-danger'>{$member_data_count}</span>";
|
||||
}
|
||||
|
||||
foreach ($inception_data as $inception_key => $inception_row) {
|
||||
|
||||
// 🔹 If inception row is empty → stop all further processing
|
||||
if (check_row_is_empty_or_null($inception_row)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$match_found = false;
|
||||
|
||||
foreach ($member_data as $member_row) {
|
||||
if (
|
||||
$inception_row[1] == $member_row[1] && // emp_id / emp_code
|
||||
$inception_row[2] == $member_row[2] && // name_of_emp_dep / name
|
||||
$inception_row[5] == $member_row[3] && // relationship
|
||||
normalizeGender($inception_row[4]) == normalizeGender($member_row[4]) && // gender
|
||||
$inception_row[3] == $member_row[5] && // dob
|
||||
$inception_row[13] == $member_row[7] && // email
|
||||
$inception_row[12] == $member_row[8] // phone / mobile
|
||||
) {
|
||||
$match_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$match_found) {
|
||||
array_push($result['error_summary'], 14);
|
||||
$result['error_data'][$inception_key]['sno']['error'][] = "This inception row was not found in the member data list.";
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ Handle Result
|
||||
if (!empty($result['error_summary'])) {
|
||||
$result['error_summary'] = array_count_values($result['error_summary']);
|
||||
$this->fileModel->update($file_id, [
|
||||
'status' => 'failed',
|
||||
'reason' => json_encode($result)
|
||||
]);
|
||||
$this->myLogger->logme('error', "File ID $file_id comparison failed");
|
||||
} else {
|
||||
Jobs::addJob(['job_name' => 'excelFileDataValidation', 'payload' => ['file_id' => $file_id]]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -171,6 +171,10 @@ class JobWorker extends AdminController
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\LeadsController',
|
||||
],
|
||||
'compareMemberDataAndInceptionData' => [
|
||||
'type' => 'CC', // Handler Category
|
||||
'handler' => 'App\Controllers\EmployeeServiceController',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -3673,7 +3673,7 @@ class LeadsController extends BaseController
|
||||
private function prepareClientData($data)
|
||||
{
|
||||
return [
|
||||
'client_type' => $data['client_type'] ?? null,
|
||||
'client_type' => 1,
|
||||
'entity_type_id' => $data['entity_type_id'] ?? null,
|
||||
'client_code' => $data['client_code'] ?? null,
|
||||
'client_name' => $data['client_name'] ?? null,
|
||||
@ -3723,6 +3723,8 @@ class LeadsController extends BaseController
|
||||
'policy_start_date' => $data['policy_start_date'],
|
||||
'policy_end_date' => $data['policy_end_date'],
|
||||
'policy_status' => 1,
|
||||
'policy_entry_from' => 3,
|
||||
'is_from_lead' => $data['id'],
|
||||
];
|
||||
|
||||
$policy_type_id = $data['policy_type_id'];
|
||||
|
||||
@ -109,7 +109,8 @@ if (!function_exists('check_relationship')) {
|
||||
|
||||
$family_floaters = isset($policy_terms['family_floaters']);
|
||||
if ($family_floaters) {
|
||||
if (isset($relationship[$col]) && $relationship[$col]['gender'] != $row[4]) {
|
||||
$relation_gender = normalizeGender($row[4]);
|
||||
if (isset($relationship[$col]) && $relationship[$col]['gender'] != $relation_gender) {
|
||||
$error = "Gender relationship conflict: Expected " . $relationship[$col]['gender'] . ", received $row[4]";
|
||||
return array('status' => false, 'error' => $error);
|
||||
}
|
||||
@ -637,12 +638,19 @@ if (!function_exists('check_dependent_conflict')) {
|
||||
if (!function_exists('generate_relationship_code')) {
|
||||
function generate_relationship_code($arr)
|
||||
{
|
||||
$gender = ['M' => 1, 'F' => 2];
|
||||
$gender = [
|
||||
'M' => 1,
|
||||
'Male' => 1,
|
||||
'male' => 1,
|
||||
'F' => 2,
|
||||
'Female' => 2,
|
||||
'female' => 2,
|
||||
];
|
||||
$relationship = ['self' => 1, 'spouse' => 2, 'son' => 3, 'daughter' => 4, 'father' => 5, 'mother' => 6, 'father-in-law' => 7, 'mother-in-law' => 8];
|
||||
$slug = \Config\Services::slug();
|
||||
$relationship_code = $slug->slugify($arr['relationship']);
|
||||
$emp_type_code = ($relationship_code == 'self' ? 'EMP_TYP_01' : 'EMP_TYP_03');
|
||||
$relationship_code = $gender[trim($arr['gender'])] . $relationship[trim($relationship_code)];
|
||||
$relationship_code = $gender[trim($arr['gender'])] ?? "" . $relationship[trim($relationship_code)] ?? "";
|
||||
return ['relationship_code' => $relationship_code, 'emp_type_code' => $emp_type_code];
|
||||
}
|
||||
}
|
||||
@ -2041,6 +2049,22 @@ if (!function_exists('formatIndianCurrency')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('normalizeGender')) {
|
||||
function normalizeGender($gender)
|
||||
{
|
||||
$gender = strtoupper(trim($gender));
|
||||
|
||||
if (in_array($gender, ['M', 'MALE'])) {
|
||||
return 'M';
|
||||
} elseif (in_array($gender, ['F', 'FEMALE'])) {
|
||||
return 'F';
|
||||
}
|
||||
|
||||
// Optional: return null or original if not recognized
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------- FUNCTION FOR LEAD MEMBER DATA LIST VALIDATIONS --------------------------------------
|
||||
|
||||
if (!function_exists('check_columns_name_exist')) {
|
||||
@ -2291,8 +2315,8 @@ if (!function_exists('validateFamily')) {
|
||||
// Validation 3: Validate spouse gender if spouse exists
|
||||
if ($spouseMember !== null) {
|
||||
|
||||
$selfGender = strtoupper(trim($selfMember[4])); // Gender field
|
||||
$spouseGender = strtoupper(trim($spouseMember[4]));
|
||||
$selfGender = normalizeGender(trim($selfMember[4])); // Gender field
|
||||
$spouseGender = normalizeGender(trim($spouseMember[4]));
|
||||
$selfName = $selfMember[2]; // Name field
|
||||
$spouseName = $spouseMember[2];
|
||||
|
||||
|
||||
@ -56,6 +56,7 @@ class ClientPolicyModel extends Model
|
||||
"is_lgbtq",
|
||||
"placement_json",
|
||||
"policy_entry_from",
|
||||
"is_from_lead",
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
|
||||
@ -22,6 +22,7 @@ class FileModel extends Model
|
||||
"uploaded_by",
|
||||
"updated_by",
|
||||
"hr_file_id",
|
||||
"is_comparison_skipped",
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -465,15 +465,22 @@ function fetchFileError(file_id) {
|
||||
|
||||
$(this).find(".modal-body").html("");
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
|
||||
try {
|
||||
// console.log((JSON.parse(response.data)));
|
||||
var file_error_data = (JSON.parse(response.data));
|
||||
var file_error_html = "";
|
||||
let hasError14 = false;
|
||||
let hasError15 = false;
|
||||
let buttonAdded = false;
|
||||
let error_code = 0;
|
||||
let is_comparison_skipped = response.is_comparison_skipped ?? null;
|
||||
|
||||
for (var key in file_error_data['error_summary']) {
|
||||
// console.log(key);
|
||||
var err_id = parseInt(key);
|
||||
var err_count = file_error_data['error_summary'][key];
|
||||
|
||||
switch (err_id) {
|
||||
case 0:
|
||||
file_error_html +=
|
||||
@ -538,6 +545,20 @@ function fetchFileError(file_id) {
|
||||
"<strong>Rule conflict: Twofold relationship found within family</strong> <span class='badge badge-danger float-right'>" +
|
||||
err_count + "</span>";
|
||||
break;
|
||||
case 14:
|
||||
hasError14 = true;
|
||||
error_code = 14;
|
||||
file_error_html +=
|
||||
"<strong>This inception row was not found in the member data list.</strong> <span class='badge badge-danger float-right'>" +
|
||||
err_count + "</span>";
|
||||
break;
|
||||
case 15:
|
||||
hasError15 = true;
|
||||
error_code = 15;
|
||||
file_error_html +=
|
||||
"<strong>Inception–member data count mismatch.</strong> <span class='badge badge-danger float-right'>" + err_count + "</span> <br>"
|
||||
+ file_error_data['error_message'] ?? "" ;
|
||||
break;
|
||||
|
||||
default:
|
||||
file_error_html += "";
|
||||
@ -565,13 +586,37 @@ function fetchFileError(file_id) {
|
||||
// console.log('file_error_html_2', file_error_html)
|
||||
|
||||
}
|
||||
|
||||
// ✅ Decide when to add buttons
|
||||
if (!buttonAdded && is_comparison_skipped != 1 && is_comparison_skipped != 0) {
|
||||
if (hasError15 && error_code == 15) {
|
||||
// Add after 15 (preferred if both exist)
|
||||
file_error_html +=
|
||||
"<div id='confirmationdiv' class='mt-2 text-center'>" +
|
||||
"<p class='mb-2'>Do you want to skip the comparison?</p>" +
|
||||
"<button id='confirmYes' class='btn btn-success btn-sm mx-1' data-id="+file_id+">Yes</button>" +
|
||||
"<button id='confirmNo' class='btn btn-danger btn-sm mx-1' data-id="+file_id+">No</button>" +
|
||||
"</div>";
|
||||
buttonAdded = true;
|
||||
} else if (hasError14 && !hasError15 && error_code == 14) {
|
||||
// Add after 14 if 15 doesn't exist
|
||||
file_error_html +=
|
||||
"<div id='confirmationdiv' class='mt-2 text-center'>" +
|
||||
"<p class='mb-2'>Do you want to skip the comparison?</p>" +
|
||||
"<button id='confirmYes' class='btn btn-success btn-sm mx-1' data-id="+file_id+">Yes</button>" +
|
||||
"<button id='confirmNo' class='btn btn-danger btn-sm mx-1' data-id="+file_id+">No</button>" +
|
||||
"</div>";
|
||||
buttonAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (err_id != 5 && err_id != 6 && err_id != 0) {
|
||||
file_error_html += (file_error_html != "" ?
|
||||
"<a href ='<?php echo base_url()?>" +
|
||||
"employee/excel_error/" + file_id +
|
||||
"' target=_blank>click here to more details...</a>" : "");
|
||||
"' target=_blank class='text-center'>click here to more details...</a>" : "");
|
||||
}
|
||||
|
||||
|
||||
// console.log(file_error_html);
|
||||
$('#file-err-modal').find(".modal-body").html(file_error_html);
|
||||
return file_error_html;
|
||||
@ -1043,5 +1088,101 @@ function checkValues() {
|
||||
// return true;
|
||||
}
|
||||
|
||||
$(document).on('click', '#confirmYes', function() {
|
||||
let file_id = $(this).data('id');
|
||||
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
text: "If you proceed, the comparison of the Inception and Member data list will be skipped, and the Inception file data validation process will start.",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "Yes, proceed",
|
||||
cancelButtonText: "No, cancel",
|
||||
confirmButtonColor: "#28a745",
|
||||
cancelButtonColor: "#dc3545",
|
||||
reverseButtons: true
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url("util/proceedExcelFileDataValidation") ?>', // replace with actual API URL
|
||||
type: 'GET',
|
||||
data: { file_id: file_id },
|
||||
success: function(response) {
|
||||
console.log('API response:', response);
|
||||
|
||||
if (response.status === true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
} else {
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(xhr) {
|
||||
toastr.error('Failed to complete the action.');
|
||||
console.error('API error:', xhr.responseText);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '#confirmNo', function() {
|
||||
let file_id = $(this).data('id');
|
||||
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
text: "If you proceed, the comparison between the Inception and Member data list will continue without skipping, and the validation process will not start until the comparison is completed.",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "Yes, proceed",
|
||||
cancelButtonText: "No, cancel",
|
||||
confirmButtonColor: "#28a745",
|
||||
cancelButtonColor: "#dc3545",
|
||||
reverseButtons: true
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url("util/proceedExcelFileDataValidation") ?>', // replace with actual API URL
|
||||
type: 'GET',
|
||||
data: { file_id: file_id, not_skiped : true },
|
||||
success: function(response) {
|
||||
console.log('API response:', response);
|
||||
|
||||
if (response.status === true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
} else {
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(xhr) {
|
||||
toastr.error('Failed to complete the action.');
|
||||
console.error('API error:', xhr.responseText);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user