CHANGE_EB_CHANGES : RV

This commit is contained in:
VENKATESHWARAN 2025-10-09 12:49:56 +05:30
parent 915c2861f2
commit a8660f5097
10 changed files with 2067 additions and 78 deletions

View File

@ -388,6 +388,10 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get("download_claim_dump_file/(:any)", "TicketController::downloadClaimDumpFile/$1");
$routes->post('uploadMultiFileFromRfq', 'LeadsController::uploadMultiFileFromRfq');
$routes->get('downloadMemberFile/(:any)', 'LeadsController::downloadMemberFile/$1');
$routes->get('downloadFullMemberDataExcelErrorFile/(:any)', 'LeadsController::downloadFullMemberDataExcelErrorFile/$1');
$routes->get('getMemberDataExcelFileErrors', 'LeadsController::getMemberDataExcelFileErrors');
$routes->post('savePlacementDataAndValidateMemberDataFile', 'LeadsController::savePlacementDataAndValidateMemberDataFile');
$routes->get('checkMemberDataFileValidationStatus', 'LeadsController::checkMemberDataFileValidationStatus');
});
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
@ -700,6 +704,8 @@ $routes->group('test', function($routes) {
$routes->get('viewrfq', 'TestingController::viewRFQNonEb');
$routes->get('exportexcel', 'TestingController::exportExcel');
$routes->post('saverfq', 'TestingController::saverfq');
$routes->get('membervalidation', 'TestingController::membervalidation');
$routes->get('generateExcel', 'TestingController::generateExcel');
});
$routes->cli('cli/testcli', 'TestingController::testcli');

View File

@ -167,6 +167,10 @@ class JobWorker extends AdminController
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\EmployeeMultiEventServiceController',
],
'memberDataListExcelFileFormatValidation' => [
'type' => 'CC', // Handler Category
'handler' => 'App\Controllers\LeadsController',
],
];

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,12 @@ use CodeIgniter\API\ResponseTrait;
use Dompdf\Dompdf;
use Dompdf\Options;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Style\Border;
class TestingController extends BaseController
{
use ResponseTrait;
@ -346,4 +352,185 @@ class TestingController extends BaseController
dd($policy_data);
}
public function membervalidation($lead_id = 329)
{
$lead_controll = new LeadsController();
// $lead_controll->getMemberDataExcelFileErrors();
$res = $lead_controll->memberDataListExcelFileFormatValidation(['lead_id' => $lead_id]);
dd($res);
}
private $firstNames = [
'Rajesh', 'Priya', 'Amit', 'Sneha', 'Vikram', 'Anjali', 'Rahul', 'Deepika',
'Sanjay', 'Kavita', 'Arun', 'Pooja', 'Manoj', 'Nisha', 'Suresh', 'Meera',
'Karthik', 'Divya', 'Ravi', 'Lakshmi', 'Anand', 'Swathi', 'Vijay', 'Rekha',
'Ashok', 'Sangeetha', 'Prakash', 'Uma', 'Ramesh', 'Vani', 'Kumar', 'Radha',
'Dinesh', 'Shanti', 'Ganesh', 'Parvati', 'Mohan', 'Sita', 'Arjun', 'Geetha'
];
private $lastNames = [
'Kumar', 'Sharma', 'Singh', 'Patel', 'Reddy', 'Nair', 'Iyer', 'Krishnan',
'Rao', 'Gupta', 'Verma', 'Agarwal', 'Joshi', 'Mehta', 'Desai', 'Pillai',
'Menon', 'Bhat', 'Naidu', 'Varma', 'Malhotra', 'Kapoor', 'Chopra', 'Saxena',
'Pandey', 'Mishra', 'Tiwari', 'Dubey', 'Sinha', 'Jain', 'Shah', 'Thakur'
];
private $relationships = ['Self', 'Spouse', 'Son', 'Daughter', 'Father', 'Mother'];
private $genders = ['M', 'F'];
private $domains = ['gmail.com', 'yahoo.com', 'outlook.com', 'company.com', 'example.com'];
public function generateExcel()
{
// Increase execution time and memory for large files
ini_set('max_execution_time', 600);
ini_set('memory_limit', '1024M');
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
// Define headers
$headers = [
'Sl no',
'Emp Code',
'Name',
'Relationship',
'Gender',
'DOB',
'Age',
'Email',
'Mobile',
'SI',
'SI Enhancement',
'Proposed Sum Insured 1',
'Proposed Sum Insured 2',
'Proposed Sum Insured 3',
'Proposed Sum Insured 4'
];
// Set headers in row 1
$col = 'A';
foreach ($headers as $header) {
$sheet->setCellValue($col . '1', $header);
$col++;
}
// Style the header row
$headerStyle = [
'font' => ['bold' => true, 'color' => ['rgb' => 'FFFFFF']],
'fill' => ['fillType' => Fill::FILL_SOLID, 'startColor' => ['rgb' => '4472C4']],
'alignment' => ['horizontal' => Alignment::HORIZONTAL_CENTER, 'vertical' => Alignment::VERTICAL_CENTER],
'borders' => ['allBorders' => ['borderStyle' => Border::BORDER_THIN]]
];
$sheet->getStyle('A1:O1')->applyFromArray($headerStyle);
// Generate 70,000 sample records
$totalRecords = 1000;
$batchSize = 1000;
for ($i = 1; $i <= $totalRecords; $i++) {
$row = $i + 1; // Start from row 2 (row 1 is header)
$record = $this->generateSampleRecord($i);
$sheet->setCellValue('A' . $row, $record['sl_no']);
$sheet->setCellValue('B' . $row, $record['emp_code']);
$sheet->setCellValue('C' . $row, $record['name']);
$sheet->setCellValue('D' . $row, $record['relationship']);
$sheet->setCellValue('E' . $row, $record['gender']);
$sheet->setCellValue('F' . $row, $record['dob']);
$sheet->setCellValue('G' . $row, $record['age']);
$sheet->setCellValue('H' . $row, $record['email']);
$sheet->setCellValue('I' . $row, $record['mobile']);
$sheet->setCellValue('J' . $row, $record['si']);
$sheet->setCellValue('K' . $row, $record['si_enhancement']);
$sheet->setCellValue('L' . $row, $record['proposed_si_1']);
$sheet->setCellValue('M' . $row, $record['proposed_si_2']);
$sheet->setCellValue('N' . $row, $record['proposed_si_3']);
$sheet->setCellValue('O' . $row, $record['proposed_si_4']);
// Clear memory every batch
if ($i % $batchSize == 0) {
$sheet->garbageCollect();
}
}
// Auto-size columns
foreach (range('A', 'O') as $col) {
$sheet->getColumnDimension($col)->setAutoSize(true);
}
// Generate filename
$filename = 'employee_data_70k_' . date('Y-m-d_His') . '.xlsx';
// Set headers for download
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $filename . '"');
header('Cache-Control: max-age=0');
// Write file to output
$writer = new Xlsx($spreadsheet);
$writer->save('php://output');
// Clean up
$spreadsheet->disconnectWorksheets();
unset($spreadsheet);
exit;
}
private function generateSampleRecord($index)
{
$firstName = $this->firstNames[array_rand($this->firstNames)];
$lastName = $this->lastNames[array_rand($this->lastNames)];
$name = $firstName . ' ' . $lastName;
$relationship = $this->relationships[array_rand($this->relationships)];
$gender = $this->genders[array_rand($this->genders)];
// Generate random age between 18 and 65
$age = rand(18, 65);
// Calculate DOB based on age
$year = date('Y') - $age;
$month = str_pad(rand(1, 12), 2, '0', STR_PAD_LEFT);
$day = str_pad(rand(1, 28), 2, '0', STR_PAD_LEFT);
$dob = "{$day}-{$month}-{$year}";
// Generate employee code
$empCode = 'EMP' . str_pad($index, 6, '0', STR_PAD_LEFT);
// Generate email
$email = strtolower($firstName . '.' . $lastName . $index) . '@' . $this->domains[array_rand($this->domains)];
// Generate mobile number (Indian format)
$mobile = '+91' . rand(7000000000, 9999999999);
// Generate insurance amounts
$siOptions = [100000, 200000, 300000, 500000, 1000000];
$si = $siOptions[array_rand($siOptions)];
$si_enhancement = rand(0, 1) ? rand(50000, 200000) : 0;
$proposed_si_1 = $si + rand(100000, 500000);
$proposed_si_2 = $proposed_si_1 + rand(100000, 500000);
$proposed_si_3 = $proposed_si_2 + rand(100000, 500000);
$proposed_si_4 = $proposed_si_3 + rand(100000, 500000);
return [
'sl_no' => $index,
'emp_code' => $empCode,
'name' => $name,
'relationship' => $relationship,
'gender' => $gender,
'dob' => $dob,
'age' => $age,
'email' => $email,
'mobile' => $mobile,
'si' => $si,
'si_enhancement' => $si_enhancement,
'proposed_si_1' => $proposed_si_1,
'proposed_si_2' => $proposed_si_2,
'proposed_si_3' => $proposed_si_3,
'proposed_si_4' => $proposed_si_4
];
}
}

View File

@ -1993,7 +1993,6 @@ if (!function_exists('group_slab_rates_basedon_name')) {
}
}
//this key generating mandantory for display employee info in enrolment app w/o error
if (!function_exists('generate_family_floater_key')) {
function generate_family_floater_key($relationship)
@ -2002,7 +2001,7 @@ if (!function_exists('generate_family_floater_key')) {
$relation = 'parent';
} else if (strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter') {
$relation = 'child';
} else if ((strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law') || (strtolower(trim($relationship)) === 'father-in-Law' || strtolower(trim($relationship)) === 'mother-in-Law')) {
} else if ((strtolower(trim($relationship)) === 'father in law' || strtolower(trim($relationship)) === 'mother in law') || (strtolower(trim($relationship)) === 'father-in-law' || strtolower(trim($relationship)) === 'mother-in-law')) {
$relation = 'parent_in_law';
} else if (strtolower(trim($relationship)) === 'spouse') {
$relation = 'spouse';
@ -2041,3 +2040,331 @@ if (!function_exists('formatIndianCurrency')) {
return $formatted . $decimal;
}
}
// ------------- FUNCTION FOR LEAD MEMBER DATA LIST VALIDATIONS --------------------------------------
if (!function_exists('check_columns_name_exist')) {
function check_columns_name_exist($definedColumns, $excelColumns)
{
$mismatchedColumns = [];
foreach ($definedColumns as $colKey => $definedCol) {
$definedColName = strtolower(trim($definedCol['col_name']));
// Normalize excel columns to lowercase for comparison
$excelColsLower = array_map('strtolower', array_map('trim', $excelColumns));
if (!in_array($definedColName, $excelColsLower)) {
$mismatchedColumns[] = "Missing column: <strong>" . $definedCol['col_name'] . "</strong> in Excel file.<br/>";
}
}
return $mismatchedColumns;
}
}
if (!function_exists('update_excel_column_indexes')) {
function update_excel_column_indexes($definedColumns, $excelColumns)
{
// $excelColumns is the first row of the Excel file (header row)
// Example: ['Emp Code', 'Name', 'Gender', 'DOB', 'SI']
foreach ($definedColumns as $key => &$definedCol) {
$definedColName = strtolower(trim($definedCol['col_name']));
$excelColsLower = array_map('strtolower', array_map('trim', $excelColumns));
// Find column index in Excel
$colIndex = array_search($definedColName, $excelColsLower);
if ($colIndex !== false) {
$definedCol['col_idx'] = $colIndex;
$definedCol['col_cell_name'] = chr(65 + $colIndex); // A=65, B=66...
} else {
// If column missing in Excel
$definedCol['col_idx'] = null;
$definedCol['col_cell_name'] = null;
}
}
return $definedColumns;
}
}
if (!function_exists('check_duplicate_rows_and_contacts')) {
function check_duplicate_rows_and_contacts($excel_data, $columns_to_check, $err_data)
{
$exl_col = $columns_to_check;
$keys = array_keys($columns_to_check);
unset($columns_to_check['sno'], $columns_to_check['si'], $columns_to_check['email'], $columns_to_check['mobile'], $columns_to_check['age']);
$seenRows = [];
$emailSeen = [];
$mobileSeen = [];
$duplicateRows = [];
foreach ($excel_data as $rowIndex => $row) {
// Build unique key from selected columns
$values = [];
foreach ($columns_to_check as $colIdx) {
$values[] = isset($row[$colIdx['col_idx']]) ? trim($row[$colIdx['col_idx']]) : '';
}
$rowKey = json_encode($values);
// =============== STEP 1: Main duplicate check ===============
if (!isset($seenRows[$rowKey])) {
$seenRows[$rowKey] = [$rowIndex];
} else {
// First duplicate occurrence — mark all related rows
$seenRows[$rowKey][] = $rowIndex;
$indexes = $seenRows[$rowKey];
$rows_str = implode(', ', array_map(fn($i) => $i + 1, $indexes));
$error_message = "Duplicate found in selected columns: Rows {$rows_str} are identical";
foreach ($indexes as $i) {
// Avoid re-adding duplicate errors
if (!in_array($i, $duplicateRows)) {
array_push($err_data['error_summary'], 1);
$err_data['error_data'][$i][$keys[0]]['col_name'] = 'Sl no';
$err_data['error_data'][$i][$keys[0]]['col_idx'] = 0;
$err_data['error_data'][$i][$keys[0]]['error'][] = $error_message;
$duplicateRows[] = $i;
}
}
// Skip email/mobile check for this duplicate row
continue;
}
// =============== STEP 2: Email & Mobile check (only if not duplicate) ===============
$email = isset($row[$exl_col['email']['col_idx']]) ? trim($row[$exl_col['email']['col_idx']]) : '';
$mobile = isset($row[$exl_col['mobile']['col_idx']]) ? trim($row[$exl_col['mobile']['col_idx']]) : '';
// Check email duplicates
if ($email !== '') {
if (isset($emailSeen[$email])) {
$firstIndex = $emailSeen[$email] + 1;
$currentRow = $rowIndex + 1;
$error_message = "Duplicate email found: Row {$currentRow} and Row {$firstIndex} have the same email '$email'";
array_push($err_data['error_summary'], 1);
$err_data['error_data'][$rowIndex][$keys[$exl_col['email']['col_idx']]]['col_name'] = $exl_col['email']['col_name'];
$err_data['error_data'][$rowIndex][$keys[$exl_col['email']['col_idx']]]['col_idx'] = $exl_col['email']['col_idx'];
$err_data['error_data'][$rowIndex][$keys[$exl_col['email']['col_idx']]]['error'][] = $error_message;
} else {
$emailSeen[$email] = $rowIndex;
}
}
// Check mobile duplicates
if ($mobile !== '') {
if (isset($mobileSeen[$mobile])) {
$firstIndex = $mobileSeen[$mobile] + 1;
$currentRow = $rowIndex + 1;
$error_message = "Duplicate mobile number found: Row {$currentRow} and Row {$firstIndex} have the same mobile '$mobile'";
array_push($err_data['error_summary'], 1);
$err_data['error_data'][$rowIndex][$keys[$exl_col['mobile']['col_idx']]]['col_name'] = $exl_col['mobile']['col_name'];
$err_data['error_data'][$rowIndex][$keys[$exl_col['mobile']['col_idx']]]['col_idx'] = $exl_col['mobile']['col_idx'];
$err_data['error_data'][$rowIndex][$keys[$exl_col['mobile']['col_idx']]]['error'][] = $error_message;
} else {
$mobileSeen[$mobile] = $rowIndex;
}
}
}
return $err_data;
}
}
if (!function_exists('check_relationship_for_member_data')) {
function check_relationship_for_member_data($row, $relationship, $columns_to_check)
{
$relation_col_idx = $columns_to_check['relationship']['col_idx'] ?? null;
$gender_col_idx = $columns_to_check['gender']['col_idx'] ?? null;
if ($relation_col_idx !== null && $gender_col_idx !== null && !empty($row[$relation_col_idx]) && !empty($row[$gender_col_idx])) { //$row[5] = relationship $row[4] = Gender
$slug = \Config\Services::slug();
$col = $slug->slugify($row[$relation_col_idx]);
if ($col != 'self' && $col != 'spouse') {
if (!isset($relationship[$col])) {
return array('status' => false, 'error' => 'Rule Conflict: Unknown Relationship');
}
if (isset($relationship[$col]) && $relationship[$col]['gender'] != $row[$gender_col_idx]) {
$error = "Gender relationship conflict: Expected " . $relationship[$col]['gender'] . ", received $row[$gender_col_idx]";
return array('status' => false, 'error' => $error);
}
}
return array('status' => true);
} else {
return array('status' => false, 'error' => 'Rule Conflict: Both Relationship and Gender required for check relationship conflict');
}
}
}
if (!function_exists('member_data_group_by_family')) {
function member_data_group_by_family($member_data, $columns_to_check)
{
$result = [];
// Kint::dump($member_data);
foreach ($member_data as $rowIndex => $row) {
if (!check_row_is_empty_or_null($row)) {
$row['row_index'] = $rowIndex;
$relation_idx = $columns_to_check['relationship']['col_idx'];
$emp_code_idx = $columns_to_check['emp_code']['col_idx'];
if (isset($row[$relation_idx]) && strtolower($row[$relation_idx]) == 'self' && isset($result[$row[$emp_code_idx]])) {
array_unshift($result[$row[$emp_code_idx]], $row);
} else {
$result[$row[$emp_code_idx]][] = $row;
}
}
}
return $result;
}
}
if (!function_exists('validateFamily')) {
function validateFamily($familyData, $columns_to_check, $errors) {
$keys = array_keys($columns_to_check);
foreach ($familyData as $familyId => $members) {
$selfMember = null;
$spouseMember = null;
$selfCount = 0;
$row_index = null;
// Find Self and Spouse members
foreach ($members as $member) {
$relation = trim($member[3]); // Relationship field
if (strtolower($relation) == 'self') {
$selfCount++;
$selfMember = $member;
}
if (strtolower($relation) == 'spouse') {
$spouseMember = $member;
}
if($row_index == null){
if(strtolower($relation) == 'self'){
$row_index = $member['row_index'];
}else if(strtolower($relation) == 'spouse'){
$row_index = $member['row_index'];
}else{
$row_index = $member['row_index'];
}
}
}
// Validation 1: Check if Self exists
if ($selfCount === 0) {
$message = "Emp ID - {$familyId}: Missing 'Self' member";
array_push($errors['error_summary'], 4);
$errors['error_data'][$row_index][$keys[$columns_to_check['emp_code']['col_idx']]]['col_name'] = $columns_to_check['emp_code']['col_name'];
$errors['error_data'][$row_index][$keys[$columns_to_check['emp_code']['col_idx']]]['col_idx'] = $columns_to_check['emp_code']['col_idx'];
$errors['error_data'][$row_index][$keys[$columns_to_check['emp_code']['col_idx']]]['error'][] = $message;
continue;
}
// Validation 2: Check if there's exactly one Self
if ($selfCount > 1) {
$message = "Emp ID - {$familyId}: Multiple 'Self' members found. Only one 'Self' is allowed per family";
array_push($errors['error_summary'], 5);
$errors['error_data'][$row_index][$keys[$columns_to_check['emp_code']['col_idx']]]['col_name'] = $columns_to_check['emp_code']['col_name'];
$errors['error_data'][$row_index][$keys[$columns_to_check['emp_code']['col_idx']]]['col_idx'] = $columns_to_check['emp_code']['col_idx'];
$errors['error_data'][$row_index][$keys[$columns_to_check['emp_code']['col_idx']]]['error'][] = $message;
continue;
}
// Validation 3: Validate spouse gender if spouse exists
if ($spouseMember !== null) {
$selfGender = strtoupper(trim($selfMember[4])); // Gender field
$spouseGender = strtoupper(trim($spouseMember[4]));
$selfName = $selfMember[2]; // Name field
$spouseName = $spouseMember[2];
// Check gender compatibility
$message = '';
if ($selfGender === 'M' && $spouseGender !== 'F') {
$message = "Emp ID - {$familyId}: Self ('{$selfName}') is Male (M); spouse must be Female (F). Found spouse ('{$spouseName}') with gender '({$spouseGender})'.";
} elseif ($selfGender === 'F' && $spouseGender !== 'M') {
$message = "Emp ID - {$familyId}: Self ('{$selfName}') is Female (F); spouse must be Male (M). Found spouse ('{$spouseName}') with gender '({$spouseGender})'.";
} elseif (!in_array($selfGender, ['M', 'F'])) {
$message = "Emp ID - {$familyId}: Invalid gender for Self member ('{$selfName}'). Expected 'M' or 'F', found '({$selfGender})'.";
}
if(isset($message) && !empty($message)){
array_push($errors['error_summary'], 6);
$errors['error_data'][$row_index][$keys[$columns_to_check['emp_code']['col_idx']]]['col_name'] = $columns_to_check['emp_code']['col_name'];
$errors['error_data'][$row_index][$keys[$columns_to_check['emp_code']['col_idx']]]['col_idx'] = $columns_to_check['emp_code']['col_idx'];
$errors['error_data'][$row_index][$keys[$columns_to_check['emp_code']['col_idx']]]['error'][] = $message;
}
}
}
return $errors;
}
}
if (!function_exists('check_age_validation')) {
function check_age_validation($row, $family_composition)
{
if ($row[5] != null) {
$dateString = convert_string_to_date($row[5]);
if ($dateString === false) {
return array('status' => false, 'error' => 'Not a valid Date');
}
$relationships = $family_composition['age_ratio'];
$dob = $dateString;
$currentDateTime = new DateTime();
$passedDateTime = new DateTime($dob);
$interval = $currentDateTime->diff($passedDateTime);
$slug = \Config\Services::slug();
$relationship = $slug->slugify($row[3]);
if($relationship == 'son' || $relationship == 'daughter'){
$relationship = 'child';
}
if($relationship == 'father' || $relationship == 'mother' || $relationship == 'mother-in-law'|| $relationship == 'father-in-law' ){
$relationship = 'elders';
}
$age_min = isset($relationships[$relationship]['min']) ? $relationships[$relationship]['min'] : NULL;
$age_max = isset($relationships[$relationship]['max']) ? $relationships[$relationship]['max'] : NULL;
// Kint::dump($dob,$currentDateTime,$passedDateTime, $interval->y, $age_min, $age_max, $relationship, $relationships);
if ($age_min !== null && $age_min > $interval->y) {
return array('status' => false, 'error' => "Age conflict : minimum $age_min yrs allowed, received $interval->y");
}
if ($age_max !== null && $age_max < $interval->y) {
return array('status' => false, 'error' => "Age conflict : maximum $age_max yrs allowed, received $interval->y");
}
return array('status' => true);
} else {
return array('status' => false, 'error' => 'Rule Conflict: Both DOB and Relationship required for age check');
}
}
}
// ------------- END OF LEAD MEMBER DATA LIST VALIDATIONS --------------------------------------

View File

@ -17,7 +17,10 @@ class LeadFilesModel extends Model
'updated_by',
'created_at',
'updated_at',
'is_active'
'is_active',
'error_data',
'status',
'type',
];
// Callbacks

View File

@ -147,6 +147,7 @@ class LeadsModel extends Model
$data = $this->select('
leads.*,
lead_files.status as demography_file_status,
kyc_entity_type.name as entity_type,
policy_type.policy_type,
user_profiles.first_name as salse_person_name,
@ -169,6 +170,7 @@ class LeadsModel extends Model
->join('kyc_entity_type', 'leads.entity_type_id = kyc_entity_type.id', 'left')
->join('user_profiles', 'leads.salse_person_id = user_profiles.id', 'left')
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
->join('lead_files', 'leads.id = lead_files.lead_id AND lead_files.type = 2 AND lead_files.is_active = 1', 'left')
->where('leads.is_active', 1);
if (!empty($where)) {

View File

@ -110,7 +110,18 @@ table.dataTable tbody td {
<!-- Include DataTables Buttons HTML5 export extension -->
<script src="https://cdn.datatables.net/buttons/2.3.0/js/buttons.html5.min.js"></script>
<?php
if (isset($lead_id)) {
$url = base_url("util/downloadFullMemberDataExcelErrorFile/") . $lead_id;
} else {
$url = base_url("util/full-excel-error-file/") . $file_id;
}
?>
<script>
let url = "<?= $url ?>";
$(document).ready(function() {
$('#tickets-table').DataTable({
dom: 'Bfrtip',
@ -123,7 +134,7 @@ $(document).ready(function() {
{
text: 'Excel Error', // Set the text for the custom button
action: function (e, dt, node, config) {
window.location.href = '<?= base_url("util/full-excel-error-file/") . $file_id ?>';
window.location.href = url;
}
}
],

View File

@ -184,7 +184,18 @@ table.dataTable tbody td {
<?php if(isset($lead_data_list)) { ?>
<?php foreach($lead_data_list as $index => $row){ ?>
<tr>
<td class="text-center"><?php echo $index + 1; ?></td>
<td class="text-center">
<?php echo $index + 1; ?>
<?php if($row['demography_file_status'] == "failed") { ?>
<a href="<?= base_url('util/getMemberDataExcelFileErrors?lead_id=').$row['id'] ?>"
class="mdi mdi-information-outline text-danger"
style="cursor: pointer; font-size: 16px"
data-toggle="tooltip"
data-placement="top"
title="Click to view the Demography File Error data" target="_blank">
</a>
<?php } ?>
</td>
<td><?php echo $lead_type[$row['lead_type']] ?? '-'; ?></td>
<td><?php echo $issuer[$row['issuer']] ?? '-'; ?></td>
<td><?php echo $client_type[$row['client_type']] ?? '-'; ?></td>

View File

@ -1,7 +1,5 @@
<style>
.table-container {
overflow-x: auto !important;
/* margin-top: 20px; */
@ -178,18 +176,18 @@
width: 300px;
}
.dialog-header {
/* .dialog-header {
font-size: 18px;
margin-bottom: 10px;
}
} */
.dialog-content {
margin-bottom: 15px;
}
.dialog-footer {
/* .dialog-footer {
text-align: right;
}
} */
.dialog button {
padding: 5px 10px;
@ -310,16 +308,205 @@
</style>
<style>
.dialog {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: white;
border-radius: 8px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
z-index: 1000;
width: 90%;
max-width: 450px;
max-height: 90vh;
display: flex;
flex-direction: column;
}
.dialog-header {
padding: 10px 20px;
border-bottom: 1px solid #ddd;
display: flex;
justify-content: space-between;
align-items: center;
flex-shrink: 0;
background: #f8f9fa;
border-radius: 8px 8px 0 0;
position: relative;
top: -7px;
}
.dialog-content {
padding: 22px;
/* overflow-y: auto;
overflow-x: hidden; */
flex: 1;
/* max-height: calc(80vh - 120px); */
}
.dialog-content::-webkit-scrollbar {
width: 8px;
}
.dialog-content::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 4px;
}
.dialog-content::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
.dialog-content::-webkit-scrollbar-thumb:hover {
background: #555;
}
.dialog-footer {
padding: 5px 5px;
/* border-top: 1px solid #ddd; */
text-align: right;
flex-shrink: 0;
/* background: #f8f9fa; */
/* border-radius: 0 0 8px 8px; */
margin-top: -41px;
}
/* Family Row Layout */
.family-row {
display: flex;
align-items: flex-start;
gap: 15px;
margin-bottom: 15px;
min-height: 45px;
}
.family-member-col {
flex: 0 0 200px;
display: flex;
flex-direction: column;
gap: 5px;
}
.family-member-col.full-width {
flex: 1;
}
.family-member-col > label {
font-weight: 500;
margin-bottom: 5px;
display: block;
}
.family-member-col input[type="checkbox"] {
margin-right: 8px;
}
.age-inputs-col {
flex: 1;
display: flex;
gap: 15px;
align-items: flex-start;
transition: opacity 0.3s ease;
}
.age-inputs-col.hidden {
opacity: 0;
visibility: hidden;
pointer-events: none;
}
.age-input-group {
flex: 1;
display: flex;
flex-direction: column;
gap: 5px;
}
.age-label {
font-size: 12px;
font-weight: 500;
color: #666;
margin-bottom: 3px;
display: block;
}
.age-input {
width: 100%;
max-width: 120px;
padding: 6px 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
}
.age-input:focus {
outline: none;
border-color: #007bff;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}
.select-small {
width: 200px !important;
display: inline-block;
}
.form-control {
width: 100%;
padding: 6px 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
}
/* Responsive */
@media (max-width: 576px) {
.family-row {
flex-direction: column;
align-items: stretch;
}
.family-member-col {
flex: 1;
width: 100%;
}
.age-inputs-col {
width: 100%;
}
.age-input {
max-width: none;
}
}
</style>
<div class="row" id="inception_list">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="align-self: center;">
<div class="col-4" style="align-self: center;">
<h4 style="position: relative;" id="rfq_qcr_page_title"> <?= isset($page_name) ? $page_name : 'RFQ' ?></h4>
</div>
<div class="col-2" style="position: relative;right: 255px;">
<?php if($lead_data['demography_file_status'] == "failed") { ?>
<a href="<?= base_url('util/getMemberDataExcelFileErrors?lead_id=').$lead_data['id'] ?>"
class="mdi mdi-information-outline text-danger"
style="cursor: pointer; font-size: 27px"
data-toggle="tooltip"
data-placement="top"
title="Member data demography file validation failed Click to view the Error data" target="_blank">
</a>
<?php } ?>
</div>
<div class="col-2" id="status_change"
style="text-align: right; position: relative;top: 56px; left: 386px;">
<a onclick="checkTheTableDataChanged(1)" class="btn btn-primary">Back</a>
@ -426,51 +613,130 @@
</div>
<!-- familiy floater dialog -->
<div class="dialog" id="familyFloaterDialog">
<div class="dialog-header ">
<span style="color:black;" >Family Members </span>
<div class="dialog" id="familyFloaterDialog" style="display: none;">
<div class="dialog-header">
<span style="color:black;">Family Members</span>
<span>
<i class="mdi mdi-close remove-icon" id="closeDialogBtn" aria-hidden="true"
style="color: black;text-align: right;margin-left: 80px;margin-top:10px;"></i>
</span>
</div>
<div class="dialog-content">
<label>
<input type="checkbox" id="family_self" checked>
Self
</label><br>
<label>
<input type="checkbox" id="family_spouse">
Spouse
</label><br>
<label for="children">Children:</label>
<select class="form-control" id="family_children">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select><br>
<label for="otherMembers">Other Members:</label>
<select class="form-control" id="family_other_members" onchange="setEldersCount(this)">
<option value="0">Select</option>
<option data-value="1" value="oneparent">Only one parent (Either Father / Mother)</option>
<option data-value="2" value="twoparent">Only two parents (Father+Mother)</option>
<option data-value="1" value="onepil">Only one parent in law (Either MIL / FIL)</option>
<option data-value="2" value="twopil">Only two parents in law (FIL + MIL)</option>
<option data-value="2" value="either_par_pil">Parents or PIL (Any two of Father, Mother, MIl, FIL)</option>
<option data-value="2" value="any_two">Either Parents or PIL (Parents or Parents In Law)</option>
<option data-value="4" value="all">Parents + PIL (Father + Mother + MIL + FIL)</option>
</select><br>
<label for="eldersCount">Elders Count:</label>
<input class="form-control" type="text" id="family_elders_count" readonly>
<!-- Self -->
<div class="family-row">
<div class="family-member-col" style="margin-top: 15px;">
<label>
<input type="checkbox" id="family_self" checked onchange="toggleAgeFields(this, 'self')">
Self
</label>
</div>
<div class="age-inputs-col" id="self_age_fields">
<div class="age-input-group" style="margin-top: -23px;">
<label class="age-label">Min Age</label>
<input type="number" class="age-input" id="family_self_min_age"
placeholder="18" min="18" max="99">
</div>
<div class="age-input-group" style="margin-top: -23px;">
<label class="age-label">Max Age</label>
<input type="number" class="age-input" id="family_self_max_age"
placeholder="99" min="18" max="99">
</div>
</div>
</div>
<!-- Spouse -->
<div class="family-row">
<div class="family-member-col" style="margin-top: 24px;">
<label>
<input type="checkbox" id="family_spouse" onchange="toggleAgeFields(this, 'spouse')">
Spouse
</label>
</div>
<div class="age-inputs-col hidden" id="spouse_age_fields">
<div class="age-input-group" style="margin-top: -11px;">
<label class="age-label">Min Age</label>
<input type="number" class="age-input" id="family_spouse_min_age"
placeholder="18" min="18" max="99">
</div>
<div class="age-input-group" style="margin-top: -11px;">
<label class="age-label">Max Age</label>
<input type="number" class="age-input" id="family_spouse_max_age"
placeholder="99" min="18" max="99">
</div>
</div>
</div>
<!-- Children -->
<div class="family-row">
<div class="family-member-col">
<label for="children">Children:</label>
<select class="form-control select-small" id="family_children" onchange="toggleAgeFields(this, 'children')">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</div>
<div class="age-inputs-col hidden" id="children_age_fields">
<div class="age-input-group">
<label class="age-label">Min Age</label>
<input type="number" class="age-input" id="family_children_min_age"
placeholder="0" min="0" max="25">
</div>
<div class="age-input-group">
<label class="age-label">Max Age</label>
<input type="number" class="age-input" id="family_children_max_age"
placeholder="25" min="0" max="25">
</div>
</div>
</div>
<!-- Other Members -->
<div class="family-row">
<div class="family-member-col">
<label for="otherMembers">Other Members:</label>
<select class="form-control" id="family_other_members" onchange="setEldersCount(this); toggleAgeFields(this, 'others')">
<option value="0">Select</option>
<option data-value="1" value="oneparent">Only one parent (Either Father / Mother)</option>
<option data-value="2" value="twoparent">Only two parents (Father+Mother)</option>
<option data-value="1" value="onepil">Only one parent in law (Either MIL / FIL)</option>
<option data-value="2" value="twopil">Only two parents in law (FIL + MIL)</option>
<option data-value="2" value="either_par_pil">Parents or PIL (Any two of Father, Mother, MIl, FIL)</option>
<option data-value="2" value="any_two">Either Parents or PIL (Parents or Parents In Law)</option>
<option data-value="4" value="all">Parents + PIL (Father + Mother + MIL + FIL)</option>
</select>
</div>
<div class="age-inputs-col hidden" id="others_age_fields">
<div class="age-input-group">
<label class="age-label">Min Age</label>
<input type="number" class="age-input" id="family_others_min_age"
placeholder="40" min="40" max="99">
</div>
<div class="age-input-group">
<label class="age-label">Max Age</label>
<input type="number" class="age-input" id="family_others_max_age"
placeholder="99" min="40" max="99" >
</div>
</div>
</div>
<!-- Elders Count -->
<div class="family-row">
<div class="family-member-col full-width">
<label for="eldersCount">Elders Count:</label>
<input class="form-control" type="text" id="family_elders_count" readonly>
</div>
</div>
<input type="text" id="familiy_dialog_row_index" style="display: none;" readonly>
<input type="text" id="familiy_dialog_column_index" style="display: none;" readonly>
</div>
<div class="dialog-footer">
<button class="btn btn-primary btn-sm" id="savefamiliy" onclick="saveFamilyMembersDetails()">save</button>
<button class="btn btn-primary btn-sm" id="savefamiliy" onclick="saveFamilyMembersDetails()">Save</button>
</div>
</div>
<!-- familiy floater dialog end -->
<!-- Modal content for Send Insurer and Client Mail -->
@ -765,10 +1031,14 @@
</div>
</div>
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
<div class="form-group text-right m-b-0" id="send_mail_btn">
<button type="submit" class="btn btn-primary" onclick="constructURL(3)">Send Mail</button>
</div>
<div class="form-group text-right m-b-0" id="validate_file_btn" style="display: none;">
<button type="submit" class="btn btn-warning" onclick="savePlacementDataAndValidateMemberDataFile(3)">Validate File</button>
</div>
</div>
</div><!-- /.modal-content -->
</div>
@ -1081,13 +1351,16 @@ let intervalId;
$(document).ready(function () {
console.log("Document ready");
var demography_file_status_for_hide_and_show = '<?= $lead_data['demography_file_status'] ?>';
toggleButtons(demography_file_status_for_hide_and_show);
let lead_status = '<?= isset($lead_data['status']) ? $lead_data['status'] : '' ?>';
console.log('Lead status retrieved:', lead_status);
if (lead_status != "won") {
console.log("Lead status is not 'won', setting interval for submitData");
startInterval();
// startInterval();
} else {
console.log("Lead status is 'won', submitData will not be called");
}
@ -1121,10 +1394,12 @@ const closeDialogBtn = document.getElementById('closeDialogBtn');
// };
$('.remove-icon').on('click', function() {
$('#familyFloaterDialog').css('display', 'none');
resetFamiliyDialogModalValues();
});
var currentThrdottedMenu = '';
var proposal_colum_count = 1;
var demography_file_status = '<?= $lead_data['demography_file_status'] ?>';
var over_all_column_data = {
"Proposal 1": {
@ -1133,6 +1408,7 @@ var over_all_column_data = {
'insurers': []
}
};
document.addEventListener('DOMContentLoaded', function () {
const textarea = document.getElementById('placement_mail_content');
const textarea2 = document.getElementById("placement_subject");
@ -1179,7 +1455,7 @@ function showFamilyFloaterDialogBox(target) {
let hiddenInput = target.querySelector('input[type="hidden"]');
// alert(hiddenInput);
let inputValue = hiddenInput ? hiddenInput.value : null;
// console.log('hidden input value');
console.log('hidden input value');
console.log(inputValue);
if (inputValue !== null && inputValue !== '') {
//get stored familiy composition json if any in hidden input and display it
@ -1189,6 +1465,8 @@ function showFamilyFloaterDialogBox(target) {
setFamilyDialogValues(inputValue);
// return true;
}else{
resetFamiliyDialogModalValues();
}
// setCellInnerHTMLByCellIndex('rfqTable', currentTD.rowIndex, (currentTD.columnIndex), '<b>TEST</b>');
@ -1207,6 +1485,19 @@ function saveFamilyMembersDetails() {
var elders = $('#family_other_members').val();
var elders_count = $('#family_elders_count').val();
// --- Get min/max age values ---
let self_min_age = $('#family_self_min_age').val();
let self_max_age = $('#family_self_max_age').val();
let spouse_min_age = $('#family_spouse_min_age').val();
let spouse_max_age = $('#family_spouse_max_age').val();
let children_min_age = $('#family_children_min_age').val();
let children_max_age = $('#family_children_max_age').val();
let others_min_age = $('#family_others_min_age').val();
let others_max_age = $('#family_others_max_age').val();
console.log('Current Family Modal Values');
console.log('self' + '-' + self);
console.log('spouse' + '-' + spouse);
@ -1227,8 +1518,17 @@ function saveFamilyMembersDetails() {
'spouse': spouse,
'children': children,
'family_other_members': elders,
'elders_count': elders_count
'elders_count': elders_count,
'self_min_age': self_min_age,
'self_max_age': self_max_age,
'spouse_min_age': spouse_min_age,
'spouse_max_age': spouse_max_age,
'children_min_age': children_min_age,
'children_max_age': children_max_age,
'others_min_age': others_min_age,
'others_max_age': others_max_age
});
console.log('display string');
console.log(display_value);
@ -1256,16 +1556,36 @@ function saveFamilyMembersDetails() {
}
function resetFamiliyDialogModalValues() {
$('#familiy_dialog_row_index').val('');
$('#familiy_dialog_column_index').val('');
// $('#family_self').val('');
$('#family_self').prop('checked', true); // Checks the checkbox
// $('#family_spouse').val('');
$('#family_spouse').prop('checked', false); // Checks the checkbox
$('#family_children').val(0)
// Reset Self
$('#family_self').prop('checked', true);
$('#family_self_min_age').val('18');
$('#family_self_max_age').val('99');
$('#self_age_fields').removeClass('hidden');
// Reset Spouse
$('#family_spouse').prop('checked', false);
$('#family_spouse_min_age').val('0');
$('#family_spouse_max_age').val('0');
$('#spouse_age_fields').addClass('hidden');
// Reset Children
$('#family_children').val('0');
$('#family_children_min_age').val('0');
$('#family_children_max_age').val('0');
$('#children_age_fields').addClass('hidden');
// Reset Other Members
$('#family_other_members').val('0');
$('#family_elders_count').val(0);
$('#family_others_min_age').val('0');
$('#family_others_max_age').val('0');
$('#others_age_fields').addClass('hidden');
// Reset Elders Count
$('#family_elders_count').val('0');
}
function createFamilyDisplayString(familyArray) {
@ -1307,6 +1627,9 @@ function createFamilyDisplayString(familyArray) {
}
function createFamilyJSONString(familyArray) {
console.log('familyArray', familyArray);
let result = {
"self": familyArray['self'] || 0,
"spouse": familyArray['spouse'] || 0,
@ -1317,6 +1640,15 @@ function createFamilyJSONString(familyArray) {
"elders_count": familyArray['elders_count'] || "0"
};
let familyAgeLimits = {
"self": { "min": familyArray['self_min_age'], "max": familyArray['self_max_age'] },
"spouse": { "min": familyArray['spouse_min_age'], "max": familyArray['spouse_max_age'] },
"child": { "min": familyArray['children_min_age'], "max": familyArray['children_max_age'] },
"elders": { "min": familyArray['others_min_age'], "max": familyArray['others_max_age'] }
};
result['age_ratio'] = familyAgeLimits;
// Process the family_other_members values to set parents and parents-in-law
switch (familyArray['family_other_members']) {
case 'oneparent':
@ -1350,19 +1682,74 @@ function createFamilyJSONString(familyArray) {
break;
}
// Conditionally add min/max ages
if (result['self'] == 1) {
result['self_min_age'] = familyArray['self_min_age'];
result['self_max_age'] = familyArray['self_max_age'];
}
if (result['spouse'] == 1) {
result['spouse_min_age'] = familyArray['spouse_min_age'];
result['spouse_max_age'] = familyArray['spouse_max_age'];
}
if (parseInt(result['childrens']) > 0) {
result['children_min_age'] = familyArray['children_min_age'];
result['children_max_age'] = familyArray['children_max_age'];
}
if (familyArray['family_other_members'] && familyArray['family_other_members'] != "0") {
result['elders_min_age'] = familyArray['others_min_age'];
result['elders_max_age'] = familyArray['others_max_age'];
}
console.log('result', result);
// Convert the result object to a JSON string
return JSON.stringify(result);
}
function setFamilyDialogValues(familyData) {
// Set Self checkbox
$('#family_self').prop('checked', familyData.self === 1);
$('#family_self_min_age').val(familyData.self_min_age || 18);
$('#family_self_max_age').val(familyData.self_max_age || 99);
if (familyData.self === 1) {
$('#self_age_fields').removeClass('hidden');
} else {
$('#self_age_fields').addClass('hidden');
}
// Set Spouse checkbox
$('#family_spouse').prop('checked', familyData.spouse === 1);
$('#family_spouse_min_age').val(familyData.spouse_min_age || 18);
$('#family_spouse_max_age').val(familyData.spouse_max_age || 99);
if (familyData.spouse === 1) {
$('#spouse_age_fields').removeClass('hidden');
} else {
$('#spouse_age_fields').addClass('hidden');
}
// Set Children select
$('#family_children').val(familyData.childrens);
$('#family_children_min_age').val(familyData.children_min_age || 0);
$('#family_children_max_age').val(familyData.children_max_age || 25);
if (parseInt(familyData.childrens) > 0) {
$('#children_age_fields').removeClass('hidden');
} else {
$('#children_age_fields').addClass('hidden');
}
// Set Other Members
$('#family_others_min_age').val(familyData.elders_min_age || 40);
$('#family_others_max_age').val(familyData.elders_max_age || 99);
if (familyData.elders_count && familyData.elders_count != 0) {
$('#others_age_fields').removeClass('hidden');
} else {
$('#others_age_fields').addClass('hidden');
}
// Determine which value to select for family other members (parents, parents-in-law)
if (familyData.parents === 1) {
@ -4010,7 +4397,7 @@ function constructURL_ForInternalMailSend() {
}
//placement mail
function constructURL_ForPlacementMailSend() {
function constructURL_ForPlacementMailSend(return_type = false) {
var lead_id = $('#lead_id').val();
let to = $('#placement_to').val();
@ -4067,7 +4454,6 @@ function constructURL_ForPlacementMailSend() {
data.push(obj);
});
// Prepare FormData
var formData = new FormData();
formData.append('lead_id', lead_id);
@ -4096,8 +4482,40 @@ function constructURL_ForPlacementMailSend() {
formData.append('acm_email', acm_email);
formData.append('acm_pk', acm_pk);
// Prepare plain key-value object
let dataObj = {
lead_id: lead_id,
file_type: RFQ_or_QCR == 2 ? 'qcr' : 'rfq',
recipient_type: 'placement',
recipient_mail: to,
cc: cc,
subject: subject,
proposal_insurer: proposal_insurer,
insurer_and_branch: insurer_and_branch,
placement_date: placement_date,
payment_date: payment_date,
policy_end_date: policy_end_date,
policy_start_date: policy_start_date,
is_cd: is_cd,
utr_no: utr_no,
premium_amount: premium_amount,
total_amount: total_amount,
cd_amount: cd_amount,
mail_content: mail_content,
selected_attachment_files: selectedFiles,
installments: JSON.stringify(data),
no_of_installment: no_of_installment,
is_installment: is_installment,
tpa_id: tpa_id,
acm_email: acm_email,
acm_pk: acm_pk
};
ajaxRequest(formData);
if(return_type == false){
ajaxRequest(formData);
}else{
return dataObj;
}
}
@ -4441,9 +4859,13 @@ function checkTheTableDataChanged(redirect_type, url){
window.location.href = url;
}else if(redirect_type == 6){
//INTERNAL MAIL SEND
//PLACEMENT MAIL SEND
showModal(3);
// if(demography_file_status == "failed"){
// toastr.warning('Member Demography file validation failed. Please re-upload', 'WARNING');
// }else{
// showModal(3);
// }
}
}
}
@ -7053,6 +7475,7 @@ function appendMultiFileData(data) {
$('.attachmet_row').empty();
$('#multiFileAppendArea').append(res.document_data);
$('.attachmet_row').html(res.attachment_html);
window.location.reload();
}else{
toastr.warning(res.message, 'WARNING');
}
@ -7069,4 +7492,155 @@ function appendMultiFileData(data) {
});
});
function toggleAgeFields(element, type) {
const ageFieldsDiv = document.getElementById(type + '_age_fields');
const minAgeInput = document.getElementById('family_' + type + '_min_age');
const maxAgeInput = document.getElementById('family_' + type + '_max_age');
if (type === 'self' || type === 'spouse') {
// For checkboxes
if (element.checked) {
ageFieldsDiv.classList.remove('hidden');
minAgeInput.value = '18';
maxAgeInput.value = '99';
} else {
ageFieldsDiv.classList.add('hidden');
// Clear values when unchecked
minAgeInput.value = '0';
maxAgeInput.value = '0';
}
} else if (type === 'children') {
// For children dropdown
if (element.value > 0) {
ageFieldsDiv.classList.remove('hidden');
minAgeInput.value = '0';
maxAgeInput.value = '25';
} else {
ageFieldsDiv.classList.add('hidden');
minAgeInput.value = '0';
maxAgeInput.value = '0';
}
} else if (type === 'others') {
// For other members dropdown
if (element.value !== '0') {
ageFieldsDiv.classList.remove('hidden');
minAgeInput.value = '40';
maxAgeInput.value = '99';
} else {
ageFieldsDiv.classList.add('hidden');
minAgeInput.value = '0';
maxAgeInput.value = '0';
}
}
}
function savePlacementDataAndValidateMemberDataFile(){
let url = '<?= base_url('util/savePlacementDataAndValidateMemberDataFile') ?>';
console.log('url', url);
// Data to send in the AJAX request
let requestData = constructURL_ForPlacementMailSend(true);
console.log('requestData', requestData);
// Show loader
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, 'POST', requestData, function(res) {
if (res.status == true) {
toastr.success(res.message, 'SUCCESS');
checkMemberDataValidationStatus(res.lead_id)
} else {
toastr.warning(res.message, 'WARNING');
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
}, function(xhr, status, error) {
clearInterval(interval);
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while validation.', 'ERROR');
console.error("❌ Error checking validation status:", err);
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
function checkMemberDataValidationStatus(lead_id) {
if (!lead_id) {
console.error("Lead ID is required");
return;
}
let url = '<?= base_url('util/checkMemberDataFileValidationStatus') ?>';
// Data to send in the AJAX request
let requestData = {
lead_id: lead_id,
};
// Show loader
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
let interval = setInterval(() => {
// Send AJAX request
sendAjaxRequestForGlobal(url, 'GET', requestData, function(res) {
if (res.code === 200 && res.data.status != "pending") {
clearInterval(interval); // stop checking
if(res.data.status == 'success'){
toastr.success("✅ Validation Completed status : " + res.data.status, 'SUCCESS');
}else{
toastr.warning("✅ Validation Completed status : " + res.data.status, 'WARNING');
}
window.location.reload();
// if (typeof callback === "function") {
// callback(res.data); // send final result to callback
// }
} else {
console.log("⏳ Validation still in progress...");
}
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
clearInterval(interval);
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while validation.', 'ERROR');
console.error("❌ Error checking validation status:", err);
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}, 2000); // check every 2 seconds
}
function toggleButtons(status) {
if (status === "failed") {
$("#send_mail_btn").hide();
$("#validate_file_btn").show();
} else {
$("#validate_file_btn").hide();
$("#send_mail_btn").show();
}
}
</script>