MERGE_BRANCH_WITH_TEST_MEMBERS_LIST_AND_EXCEL_MERGE_HELPER

This commit is contained in:
Srinivas-Saravanan 2025-01-02 15:20:58 +05:30
commit 1b1836ce03
21 changed files with 2069 additions and 505 deletions

View File

@ -334,6 +334,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->post('map_employees', 'EmployeeController::mapEmployees');
$routes->post('get_data_for_mapping', 'EmployeeController::getDataForMapping');
$routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1');
$routes->get('transformMailContent', 'LeadsController::transformMailContent');
});
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
@ -381,6 +382,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
$routes->post("create", "LeadsController::createLead");
$routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1");
$routes->get("sendMail", "LeadsController::sendMailWithAttachement");
$routes->post("sendMail", "LeadsController::sendMailWithAttachement");
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");

View File

@ -205,9 +205,6 @@ class EmpDataServiceController extends BaseController
// Log the export file name
$this->myLogger->logme('error', 'Inception export file name : {data}', ['data' => $export_data['file_name']]);
// remove existing batch file anf batch list data every time export
$this->removeOldExportInfoFromBatchFile($export_data);
// default excel header information
$excel_header_columns = [
[
@ -258,7 +255,7 @@ class EmpDataServiceController extends BaseController
[
'column_index' => 7,
'column_name' => 'DATE OF COVERAGE',
'db_column_name' => 'date_coverage'
'db_column_name' => 'date_of_coverage'
],
[
'column_index' => 8,
@ -368,7 +365,7 @@ class EmpDataServiceController extends BaseController
[
'column_index' => 7,
'column_name' => 'DATE OF COVERAGE',
'db_column_name' => 'date_coverage'
'db_column_name' => 'date_of_coverage'
],
[
'column_index' => 8,
@ -428,14 +425,35 @@ class EmpDataServiceController extends BaseController
];
}else{
// get excel export format structure array
$template_json = $this->clientPolicyModel
->select('insurer_excel_export_template.jsoncolumns')
->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id')
->where('client_policy.id', $export_data['client_policy_id'])
->where('insurer_excel_export_template.event_name', $export_data['event_type'])
->where('insurer_excel_export_template.is_active', 1) //Live issue changes 17-10-2024
->where('insurer_excel_export_template.type_name', $export_data['actions'])
->first();
// $template_json = $this->clientPolicyModel
// ->select('insurer_excel_export_template.jsoncolumns')
// ->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id')
// ->where('client_policy.id', $export_data['client_policy_id'])
// ->where('insurer_excel_export_template.event_name', $export_data['event_type'])
// ->where('insurer_excel_export_template.is_active', 1) //Live issue changes 17-10-2024
// ->where('insurer_excel_export_template.type_name', $export_data['actions'])
// ->first();
$sql = "
SELECT `insurer_excel_export_template`.`jsoncolumns`
FROM `client_policy`
JOIN `insurer_excel_export_template`
ON `insurer_excel_export_template`.`insurer_id` = `client_policy`.`insurer_id`
AND `insurer_excel_export_template`.`policy_type_id` =
CASE
WHEN `client_policy`.`policy_type_id` IN (2, 3, 4, 5) THEN 2
ELSE `client_policy`.`policy_type_id`
END
WHERE `client_policy`.`id` = '".$export_data['client_policy_id']."'
AND `insurer_excel_export_template`.`event_name` = '".$export_data['event_type']."'
AND `insurer_excel_export_template`.`is_active` = 1
AND `insurer_excel_export_template`.`type_name` = '".$export_data['actions']."'
LIMIT 1";
$query = db_connect()->query($sql);
$template_json = $query->getRowArray();
// dd(db_connect()->getLastQuery());
if(!empty($template_json) && $template_json != null){
$excel_header_columns = json_decode($template_json['jsoncolumns'], true);
@ -444,6 +462,10 @@ class EmpDataServiceController extends BaseController
}
}
// remove existing batch file anf batch list data every time export
$this->removeOldExportInfoFromBatchFile($export_data);
//convert the excel data based on the insurer
$excel_data_info = generate_insurer_based_excel($excel_header_columns, $objects);
// Generate Excel file
@ -1332,6 +1354,7 @@ class EmpDataServiceController extends BaseController
$employee_data = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($ref_data, 1);
// dd($employee_data, $excel_data);
// ->select('
// employee_polices.id as emp_policy_id,
@ -1343,7 +1366,7 @@ class EmpDataServiceController extends BaseController
// employees.gender AS emp_gender,
// employee_polices.pre_existing_alignments,
// employee_polices.basic_cover_si,
// employee_polices.date_coverage,
// employee_polices.date_of_coverage,
// TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
// employees.relationship AS emp_relationship,
// employees.change_event AS change_event,
@ -1453,17 +1476,22 @@ class EmpDataServiceController extends BaseController
}
if ($insurer_or_tpa == 'tpa') {
if ($excel_data[$key][13] === null) {
$missing_id[$key][] = [
'row' => $key,
'column' => 15,
'column' => 13,
'db_data' => "TPA ID is Must",
'excel_data' => $excel_data[$key][13]
];
}
} else if ($insurer_or_tpa == 'insurer') {
if ($excel_data[$key][14] === null) {
$missing_id[$key][] = [
'row' => $key,
'column' => 16,
'column' => 14,
'db_data' => "UHID or Risk ID is Must",
'excel_data' => $excel_data[$key][14]
];
}
}
@ -1569,6 +1597,7 @@ class EmpDataServiceController extends BaseController
}
if ($emp_value['gst'] != $excel_data[$key][16]) {
$errors[$key][] = [
'row' => $key,
'column' => 16,
@ -1610,7 +1639,7 @@ class EmpDataServiceController extends BaseController
$missing_id_count = count($missing_id);
$json_missing_id = json_encode($missing_id);
// dd($error_count, $missing_id_count, $json_errors, $json_missing_id);
// dd($error_count, $missing_id_count, $json_errors, $json_missing_id, $employee_data, $excel_data);
if ($missing_id_count > 0) {
@ -1954,12 +1983,14 @@ class EmpDataServiceController extends BaseController
->where("employees.is_active", 1)
->where("employees.emp_status", "active")
->where("emp_endorsement.actions", "c")
->where("emp_endorsement.is_active", 1)
->where("emp_endorsement.status !=", "truncated")
->where("(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = '')")
->findAll();
// dd($endorsement_data, $excel_data);
dd($endorsement_data, $excel_data);
if ($endorsement_data == null || empty($endorsement_data)) {
@ -2253,6 +2284,8 @@ class EmpDataServiceController extends BaseController
->where('employee_polices.status', 'active')
->where('employees.is_active', 1)
->where('employees.emp_status', 'active')
->where("emp_endorsement.is_active", 1)
->where("emp_endorsement.status !=", "truncated")
->first();
if (isset($result['id']) && $result['id'] !== null) {

View File

@ -41,7 +41,7 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use Dompdf\Dompdf;
use Dompdf\Options;
use Kint;
class EmployeeController extends AdminController
{
@ -210,7 +210,9 @@ class EmployeeController extends AdminController
// $this->fileModel->where('id', '12')->set(['status' => 'failed','reason' => $failure_reason])->update();
// dd($failure_reason);
// }
// $this->truncateFileData(747, 5) ;
// print_rr($this->cloneWorksheet());
// die();
if ($this->request->getMethod() == 'post') {
//validate uploaded file
@ -1227,7 +1229,7 @@ class EmployeeController extends AdminController
public function truncateFileData($file_id, $role_id = null)
{
$file_id = $this->request->uri->getSegment(3);
// $file_id = 112;
// $file_id = 747;
$file = $this->fileModel->find($file_id);
$client_id = $file['client_id'];
$client_policy_id = $file['policy_id'];
@ -1263,16 +1265,66 @@ class EmployeeController extends AdminController
}
} else {
//update emp and emp plocies
$db = db_connect();
$query = "UPDATE employees JOIN employee_polices ON employees.id = employee_polices.employee_id and employees.file_id = $file_id SET employees.emp_status = 'truncated', employee_polices.status = 'truncated', employees.is_active = 0,employee_polices.is_active = 0 WHERE employees.file_id = $file_id";
$db->query($query);
$affectedRows = $db->affectedRows();
// print_r($db->getLastQuery()); die;
// $affectedRows = 10;
if($file['action'] != 'enrollment')
{
//update emp and emp plocies
$db = db_connect();
$query = "UPDATE employees JOIN employee_polices ON employees.id = employee_polices.employee_id and employees.file_id = $file_id SET employees.emp_status = 'truncated', employee_polices.status = 'truncated', employees.is_active = 0,employee_polices.is_active = 0 WHERE employees.file_id = $file_id";
$db->query($query);
$affectedRows = $db->affectedRows();
// print_r($db->getLastQuery()); die;
// $affectedRows = 10;
//update file status
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
//update file status
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
}
else
{
// echo 'came here...1';
//check all dependents added by self and other dependent policies
$emp_codes = $this->employeeModel->select('emp_code')
->where('file_id', $file_id)
->findAll();
$emp_codes = array_column($emp_codes,'emp_code');
// Kint::dump($emp_codes);//die;
$dependent_policies = $this->clientPolicyModel->select('id')
->where('base_policy', $client_policy_id)
->findAll();
// $dependent_policies = [ [10],[25],[35] ];
// Kint::dump($dependent_policies);
// Kint::dump(array_column($dependent_policies,'id'));
if(count($dependent_policies))
{
$dependent_policies = array_column($dependent_policies,'id');
// Kint::dump($dependent_policies);
$second_level_dependent_policies = $this->clientPolicyModel->select('id')
->whereIn('base_policy', $dependent_policies)
->findAll();
// dd($second_level_dependent_policies);
if(count($second_level_dependent_policies))
{
$second_level_dependent_policies = array_column($second_level_dependent_policies,'id');
}
$dependent_policies = array_merge($dependent_policies,$second_level_dependent_policies);
}
$dependent_policies = array_merge($dependent_policies,[$client_policy_id]);
// Kint::dump($dependent_policies);
//update emp and emp plocies
$db = db_connect();
$emp_codes = '(' . implode(',', array_map(fn($code) => "'$code'", $emp_codes)) . ')';
$dependent_policies = '(' . implode(',', $dependent_policies) . ')';
$query = "UPDATE employee_polices JOIN employees ON employees.id = employee_polices.employee_id and employees.emp_code in $emp_codes SET employee_polices.status = 'truncated', employee_polices.is_active = 0 WHERE employee_polices.client_policy_id in $dependent_policies";
$db->query($query);
$affectedRows = $db->affectedRows();
// dd($affectedRows);
$affectedRows = $affectedRows * 2;
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
}
if($cd_tranction){
@ -1312,7 +1364,7 @@ class EmployeeController extends AdminController
if ($res[0]->count == 0 || $role_id == 5 || $role_id == 1) {
//update truncated status to db
$this->empEndorsementModel->where('file_id', $file_id)
->set(['status' => 'truncated'])
->set(['status' => 'truncated','is_active' => 0])
->update();
//update file status
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
@ -1645,14 +1697,18 @@ class EmployeeController extends AdminController
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $client_id,client_branch_id: $branch_id);
//get familiy details in inception file format array from post method
$data = calculate_premium_new(family_data: $family_details,policy_terms:$policy_details,slab_details:$slab_details,fileArr: $file,existing_units: $existing_units);
// print_rr($data);die();
foreach($data as $key => $member )
{
// ~dd($member);
if(is_array($member))
if(is_array($member) && isset($member['policy_details']['date_coverage']) && isset($member['policy_details']['policy_end_date']) )
{
$data[$key]['policy_details']['no_of_days'] = $member['policy_details']['date_coverage'] ? (calculate_days_bw_dates($member['policy_details']['date_coverage'],$member['policy_details']['policy_end_date'])->days + 1) : '';
}
else
{
$data[$key]['policy_details']['no_of_days'] = '0';
}
}
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => ['new' => $data,'old' => $existing_famility_details], 200]);
@ -2127,4 +2183,60 @@ class EmployeeController extends AdminController
}
public function cloneWorksheet()
{
// Define file paths
$inputFilePath = 'C:\Users\Venba\Downloads/merge1.xlsx'; // Path to the existing file
$outputFilePath = WRITEPATH . '/tmp/cloned_file.xlsx'; // Path to save the new file
try {
// Load the existing spreadsheet
$spreadsheet = IOFactory::load($inputFilePath);
// Get the first worksheet (or specify the index of the sheet to clone)
$originalWorksheet = $spreadsheet->getSheet(0);
// Clone the worksheet
$clonedWorksheet = clone $originalWorksheet;
// Generate a unique name for the cloned worksheet
$baseName = "Cloned Sheet";
$sheetIndex = 1;
$uniqueName = $baseName;
// Check for duplicate names and generate a unique one
while ($spreadsheet->sheetNameExists($uniqueName)) {
$uniqueName = $baseName . " " . $sheetIndex;
$sheetIndex++;
}
// Set the unique name for the cloned worksheet
$clonedWorksheet->setTitle($uniqueName);
// Add the cloned worksheet to the spreadsheet
$spreadsheet->addSheet($clonedWorksheet);
// Modify the cloned sheet (optional)
$clonedWorksheet->setCellValue('A1', 'Hello, Cloned Sheet!');
// Save the modified spreadsheet to a new file
$writer = new Xlsx($spreadsheet);
$writer->save($outputFilePath);
return $this->response->setJSON([
'status' => 'success',
'message' => 'Spreadsheet with cloned sheet created successfully!',
'file_path' => $outputFilePath,
]);
} catch (\Exception $e) {
// Handle exceptions
return $this->response->setJSON([
'status' => 'error',
'message' => $e->getMessage(),
]);
}
}
}

View File

@ -132,7 +132,7 @@ class EmployeeServiceController extends AdminController
'format' => 'd-M-Y',
'allowed_values' => null,
'custom' => 'check_dob_diff',
'params' => ['row', 'relationship', 'default_age_ratio']
'params' => ['row', 'relationship', 'default_age_ratio','policy_details']
],
'gender' => [
'col_idx' => 4,
@ -767,10 +767,9 @@ class EmployeeServiceController extends AdminController
$relationship = $this->general_relationships;
//get exisiting mobilr nos
$existing_mobilenos = $this->employeePolicyModel->getExisitingMobileNos(client_policy_id: $file['policy_id']);
//get existing units in the current branch
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
// dd($existing_units);
// dd($excel_data);
foreach ($excel_data as $row_key => $row)
{
//define row wise action/event in temporary variable
@ -1234,7 +1233,6 @@ class EmployeeServiceController extends AdminController
// Kint::dump($family);die();
$data = calculate_premium_new(family_data:$family,policy_terms: $policy_terms,slab_details : $slab_details,fileArr: $file, existing_units:$existing_units);
// dd($data);
$employee_data_group_by_family[$emp_id] = $data;
$this->employeesOnboardProcess(['familiy_data' => $data,'file' => $file]);
}
@ -1461,6 +1459,8 @@ class EmployeeServiceController extends AdminController
->where('emp_code',$employee['emp_code'])
->where('name',$employee['name'])
->where('field_name',$field_name)
->where('is_active',1)
->where('status !=','truncated')
->findAll();
// dd($existing_endorsements);
//make entry in endorsement table
@ -1611,7 +1611,7 @@ class EmployeeServiceController extends AdminController
// echo '---------------------------------------';
//start implemet of si enhancement of grid type 10,11
if(count($employee) && $file['action'] == 'dependent_addition' && $temp['source'] == 'db' && in_array($value['temp']['grid_id'],[10,11]) && ( ($value['temp']['premium_type'] == 1 && (strtolower($value['relationship']) == 'self' || $temp['acting_self'])) || ($value['temp']['premium_type'] == 2 || $value['temp']['premium_type'] == null)))
if(count($employee) && $file['action'] == 'dependent_addition' && $temp['source'] == 'db' && in_array($temp['grid_id'],[10,11]) && ( ($temp['premium_type'] == 1 && (strtolower($value['relationship']) == 'self' || $temp['acting_self'])) || ($temp['premium_type'] == 2 || $temp['premium_type'] == null)))
{
$log_message = 'Employee record from DB,Checking SI for - '.$employee[0]['name'].'('.$employee[0]['emp_code'].')';
$this->myLogger->logme('error',$log_message);
@ -1620,7 +1620,6 @@ class EmployeeServiceController extends AdminController
break;//skip db employee
}
//end implemet of si enhancement of grid type
//save employee table
$value['relationship'] = ucfirst(trim($value['relationship']));
if(count($employee))
@ -1643,7 +1642,6 @@ class EmployeeServiceController extends AdminController
// $this->myLogger->logme('error',('Insert - ' . $value['emp_code'] .' - '. $value['name']));
// echo 'update emp';
}
$this->employeeModel->save($value);
if (isset($value['id'])) {
$emp_id = $value['id'];
@ -1702,7 +1700,7 @@ class EmployeeServiceController extends AdminController
$log_message = $file['action'].' - endorsement'. $value['emp_code'].' - '.$value['name'].' - with policy id'.$emp_policy_id;
$this->myLogger->logme('error',$log_message);
$actions = ($file['action'] == 'dependent_addition' ? 'da' : ($file['action'] == 'addition' ? 'a' : 'a'));
$addition_endorse_data = ['pk' => $emp_policy_id,'group_key' => rand(100000, 999999),'emp_code' => $value['emp_code'],'table_name' => 'employee_polices','actions' => $actions,'name' => $value['name'],'field_name' => 'basic_cover_si','old_value' => NULL,'new_value' => $policy_data['basic_cover_si'],'remarks' => 'addition endorsement','file_id' => $file['id'],'created_by' => $file['created_by']];
$addition_endorse_data = ['pk' => $emp_policy_id,'group_key' => rand(100000, 999999),'emp_code' => $value['emp_code'],'table_name' => 'employee_polices','actions' => $actions,'name' => $value['name'],'field_name' => 'basic_cover_si','old_value' => NULL,'new_value' => $policy_data['basic_cover_si'],'remarks' => 'addition endorsement','file_id' => $file['id'],'created_by' => $file['created_by'],'status' => 'pending'];
$this->employeeEndorsementforAddtionAndDependentAddition($addition_endorse_data);
}
@ -2012,10 +2010,10 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$value['emp_code'] = $row[1];
$value['name'] = $row[2];
$value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3],'Y-m-d'): null);
$value['doj'] = (!empty($row[3]) ? change_date_format($row[3],'d-M-Y','Y-m-d') : null );
$value['gender'] = $row[4];
$value['relationship'] = ucfirst(trim($row[5]));
$value['dob'] = convert_string_to_date($row[6],'Y-m-d');
$value['dob'] = change_date_format($row[6],'d-M-Y','Y-m-d');
$value['email_corporate'] = $row[7];
$value['mobile'] = $row[8];
$value['band'] = $row[10];
@ -2042,7 +2040,7 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
$value['family_floater_key'] = $relation;
$policy_data['basic_cover_si'] = $row[9];
$policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],null,'Y-m-d') : null;
$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']);

View File

@ -33,6 +33,9 @@ use App\Helpers\ExcelSanitizeHelper;
use Google\Service\CloudSearch\PushItem;
use Kint;
use App\Controllers\Jobs;
use App\Controllers\JobWorker;
class LeadsController extends BaseController
{
@ -99,8 +102,8 @@ class LeadsController extends BaseController
{
// $d = $this->constructExcelToSaveTemp(24, 1, $propsal_and_insurer = null);
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => ['lead_id' => 24]]);
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => ['lead_id' => 24]]);
// $d = $this->calculateMembersDemography(['lead_id' => 24]);
//$this->mergeQuoteExcelFileWithMembersListExcelFile(24, 1, $propsal_and_insurer = null);
// dd($d);
@ -192,11 +195,9 @@ class LeadsController extends BaseController
foreach($data['policy_type_id'] as $index => $value){
// Separate the insurer and insurer branch, handle missing or invalid data
if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) {
list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer'][$index]);
} else {
$insurer_branch_id = 0;
$insurer_id = 0;
}
@ -208,7 +209,6 @@ class LeadsController extends BaseController
$tpa_id = 0;
}
// Separate the insurer and insurer branch, handle missing or invalid data
if (isset($data['proposed_insurer'][$index]) && strpos($data['proposed_insurer'][$index], '-') !== false) {
list($proposed_insurer_branch_id, $proposed_insurer_id) = explode('-', $data['proposed_insurer'][$index]);
@ -237,8 +237,8 @@ class LeadsController extends BaseController
$policy_end_date = null;
}
if(!empty($data['incurred_claims_date'][$index])){
$incurred_claims_date = change_date_format($data['incurred_claims_date'][$index], 'd/m/Y', 'Y-m-d');
if(!empty($data['incurred_claim_date'][$index])){
$incurred_claims_date = change_date_format($data['incurred_claim_date'][$index], 'd/m/Y', 'Y-m-d');
}else{
$incurred_claims_date = null;
}
@ -250,6 +250,11 @@ class LeadsController extends BaseController
}
$file_name = file_Upload($files[$index], $uploadFilePath);
$last_3_years_claims = null;
if($value != 2){
$last_3_years_claims = $data['finyear'];
}
$processedData[] = [
'lead_type' => $data['lead_type'],
@ -306,6 +311,9 @@ class LeadsController extends BaseController
'annualised_claims' => $data['annualised_claims'][$index] ?? 0,
'incurred_claims_ratio' => $data['incurred_claims_ratio'][$index] ?? 0,
'earned_claims_ratio' => $data['earned_claims_ratio'][$index] ?? 0,
'total_si_at_incept' => $data['total_si_at_incept'][$index] ?? 0,
'total_si_at_renewal' => $data['total_si_at_renewal'][$index] ?? 0,
'fin_years_claims' => $last_3_years_claims,
'file_name' => $file_name,
@ -324,6 +332,12 @@ class LeadsController extends BaseController
$insert = $this->leadsModel->insert($value);
$insertCount[] = $insert;
$this->insertLeadStatus($insert, $value['status'], 3);
//for this push the job to the calculateMembersDemography() function
$job_details = new Jobs();
$r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [
'lead_id' => $insert,
]]);
}
if (count($insertCount) > 0) {
@ -363,6 +377,18 @@ class LeadsController extends BaseController
$data['policy_end_date'] = null;
}
if (!empty($data['incurred_claims_date'])) {
$data['incurred_claims_date'] = change_date_format($data['incurred_claims_date'], 'Y-m-d', 'd/m/Y');
} else {
$data['incurred_claims_date'] = null;
}
if (!empty($data['premium_date'])) {
$data['premium_date'] = change_date_format($data['premium_date'], 'Y-m-d', 'd/m/Y');
} else {
$data['premium_date'] = null;
}
if ($data) {
return $this->respond(['status' => true, 'data' => $data], 200);
} else {
@ -424,11 +450,13 @@ class LeadsController extends BaseController
}
$data['question_json'] = $lead_data['question_json'];
$data['page_name'] = isset($data['rfq_data']['type']) && $data['rfq_data']['type'] == 2 ? 'QCR' : 'RFQ';
$data['page_name'] = $type == 2 ? 'QCR' : 'RFQ';
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
$data['userList'] = $this->userModel->getUserListForRFQ();
$data['lead_data'] = $lead_data;
$data['mail_content'] = $this->transformMailContent($id);
// dd($data);
$this->loadLayout('view_rfq.php', $data);
}
@ -450,7 +478,10 @@ class LeadsController extends BaseController
$result = $this->RFQModel->insert($data);
if ($result) {
return $this->respond(['status' => true, 'id' => $result, 'message' => 'RFQ created successfully', 'data' => $data], 200);
$message = "RFQ submitted successfully";
if($data['submit_type'] == 'QCR'){ $message = "QCR submitted successfully"; }
return $this->respond(['status' => true, 'id' => $result, 'message' => $message, 'data' => $data], 200);
}
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create RFQ", 'data' => $data], 200);
@ -493,6 +524,29 @@ class LeadsController extends BaseController
public function exportExcelForQCRandRFQ($lead_id, $type)
{
$filepath = $this->constructExcelToSaveTemp($lead_id, $type);
$lead_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
// dd($filepath);
//Excel merging part
if ($lead_data['file_name'] != null && $lead_data['file_name'] != '') {
$temp_file_path = $filepath['filePath'];
$temp_file_name = $filepath['fileName'];
$lead_file_path = WRITEPATH . 'uploads/lead_files/' . $lead_data['file_name'];
// dd($lead_data, $temp_file_path, $temp_file_name, $lead_file_path);
if ($lead_file_path) {
$filePaths = [
['file_path' => $temp_file_path, 'sheets' => []],
['file_path' => $lead_file_path, 'sheets' => []]
];
// $outputPath = dirname($temp_file_path) . '/' . 'merged_' . $temp_file_name;
$result = ExcelMergeHelper::mergeExcelFiles($filePaths, $temp_file_path);
// print_rr($result);
}
}
$filepath = $filepath['filePath'];
if (file_exists($filepath)) {
@ -523,11 +577,74 @@ class LeadsController extends BaseController
// dd($rfq_data, $lead_id, $type, $propsal_and_insurer);
// print_r($propsal_and_insurer); die;
$lead_data = [
'Insured' => $rfq_data['client_name'],
'Insurer' => $rfq_data['insurer_name'] . ' - ' . $rfq_data['insurer_branch_name'],
'TPA' => $rfq_data['tpa_name'] . ' - ' . $rfq_data['tpa_branch_name'],
];
if($rfq_data['lead_type'] == 1){
if($rfq_data['policy_type_id'] == 2){
$lead_data = [
'Insured' => $rfq_data['client_name'],
'Policy Status' => $rfq_data['status'],
'No of Employees' => $rfq_data['incept_emp_count'],
'No of Dependents' => $rfq_data['incept_dept_count'],
'Total Lives' => $rfq_data['incept_no_of_lives'],
'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
'Policy Run Days' => $rfq_data['policy_run_days'],
];
}else if($rfq_data['policy_type_id'] == 1){
$lead_data = [
'Insured' => $rfq_data['client_name'],
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
'Policy Status' => $rfq_data['status'],
'Existing Insurer' => $rfq_data['insurer_name'],
'TPA ' => $rfq_data['tpa_name'],
];
}
}else{
if($rfq_data['policy_type_id'] == 2){
$lead_data = [
'Insured' => $rfq_data['client_name'],
'Policy Status' => $rfq_data['status'],
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
'No of Dependents at Inception' => $rfq_data['incept_dept_count'],
'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'],
'No of Employees at Expiry' => $rfq_data['exp_emp_count'],
'No of Dependents at Expiry' => $rfq_data['exp_dept_count'],
'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'],
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
'Period of Insurance ' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
'Policy Run Days' => $rfq_data['policy_run_days'],
'Inception Premium' => $rfq_data['premium_at_inception'],
'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'],
'Earned Premium' => $rfq_data['earned_premium'],
'Incurred Claims as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['incurred_claims_date'],
'Annualised Claims' => $rfq_data['annualised_claims'],
'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'],
'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'],
];
}else if($rfq_data['policy_type_id'] == 1){
$lead_data = [
'Insured' => $rfq_data['client_name'],
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
'Policy Period' => date('d/m/Y', strtotime($rfq_data['policy_start_date'])).' to '. date('d/m/Y', strtotime($rfq_data['policy_end_date'])),
'Policy Status' => $rfq_data['status'],
'Existing Insurer' => $rfq_data['insurer_name'],
'TPA ' => $rfq_data['tpa_name'],
];
}
}
$data = json_decode($rfq_data['json'], true);
@ -539,6 +656,7 @@ class LeadsController extends BaseController
}
}else if($type == 1){
$data = $this->convertJsonForQCR($data, $type);
// dd($data);
}
$spreadsheet = new Spreadsheet();
@ -670,20 +788,25 @@ class LeadsController extends BaseController
$rowNumber += 2;
// Add premium data
$labelArray = ["Premium", "GST (%)", "GST Amount (₹)", "Total"];
$premiumData = $data['premium_data']['data'];
$premium = ['Premium'];
$gst = ['GST'];
$total = ['Total'];
$premium = [$labelArray[0]];
$gst = [$labelArray[1]];
$gstAmt = [$labelArray[2]];
$total = [$labelArray[3]];
foreach ($premiumData as $proposal => $insurers) {
foreach ($insurers as $insurer => $values) {
$premium[] = $values['Premium'];
$gst[] = $values['GST'];
$total[] = $values['Total'];
if($proposal != 'Particulars'){
foreach ($insurers as $insurer => $values) {
$premium[] = $values[$labelArray[0]];
$gst[] = $values[$labelArray[1]];
$gstAmt[] = $values[$labelArray[2]];
$total[] = $values[$labelArray[3]];
}
}
}
foreach ([$premium, $gst, $total] as $index => $rowData) {
foreach ([$premium, $gst, $gstAmt, $total] as $index => $rowData) {
$columnLetter = 'B';
foreach ($rowData as $key => $value) {
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $value);
@ -1181,14 +1304,18 @@ class LeadsController extends BaseController
helper('excel_util_helper');
helper('MailHelper');
helper('ExcelMergeHelper');
$params = $this->request->getGet();
$params = $this->request->getPost();
// print_r($params); die;
$lead_id = $params['lead_id'];
$file_type = $params['file_type']; //rfq or qcr
$recipient_type = $params['recipient_type']; //insurer or client or internal or placement
$recipient_mail = $params['recipient_mail']; // - only primary key of contacts
$recipient_mail = json_decode($params['recipient_mail'], true); // - only primary key of contacts
$propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null;
$mail_content = $params['mail_content'];
$mail_subject = $params['subject'];
$result_data = [];
// dd($recipient_mail);
@ -1207,9 +1334,10 @@ class LeadsController extends BaseController
// print_r($lead_data ); die;
$cc_mails = [];
$bcc_mails = [];
//get CC Mails
if ($recipient_type == 'internal' || $recipient_type == 'placement') {
if ($recipient_type == 'internal' || $recipient_type == 'placement' || $recipient_type == 'insurer' || $recipient_type == 'client') {
$cc_data = isset($params['cc']) ? $params['cc'] : "";
$param_cc_mail = json_decode($cc_data, true);
@ -1239,6 +1367,37 @@ class LeadsController extends BaseController
}
}
//get BCC Mails
if ($recipient_type == 'insurer' || $recipient_type == 'client') {
$bcc_data = isset($params['bcc']) ? $params['bcc'] : "";
$param_bcc_mail = json_decode($bcc_data, true);
if (isset($param_bcc_mail) && is_array($param_bcc_mail) && count($param_bcc_mail) > 0) {
// Fetch user data where ID is in the param_cc_mail array
$userData = $this->userModel
->where('is_active', 1)
->whereIn('id', $param_bcc_mail)
->findAll();
// print_r($userData); die;
// Extract emails from the fetched user data
$bcc_mails = array_column($userData, 'email');
// print_r(json_encode($cc_mails)); die;
// If no emails were found, return an error response
// if (empty($cc_mails)) {
// return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'No valid CC mail addresses found!'], 200);
// }
} else {
// Handle case where param_cc_mail is not valid
// return $this->respond(['status' => 'failed','code' => 400,'data' => '','message' => 'CC mail not found!'], 200);
}
}
if ($recipient_type == 'client' && ($lead_data['contact_person_email'] == '' || $lead_data['contact_person_email'] == null)) {
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => '', 'messgae' => 'Recipient mail not found ! '], 200);
}
@ -1294,6 +1453,18 @@ class LeadsController extends BaseController
$subject = $file_type == 'rfq' ? 'Request for Quotation from ' . $lead_data['client_name'] . ' for ' . $lead_data['policy_type'] : 'Quotation Comparison Report for ' . $lead_data['policy_type'];
$original_message = '<div style="width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9;font-family:Arial,sans-serif;color:#333;line-height:1.6"><div style=background-color:#4a90e2;color:#fff;padding:15px;text-align:center><h1 style=margin:0;font-size:24px>Request for Quotation (RFQ)</h1></div><div style=padding:20px;background-color:#fff><h2 style=color:#4a90e2;font-size:20px;margin-top:0>Dear {{RECIPIENT_NAME}},</h2><p>We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.<h2 style=color:#4a90e2;font-size:20px;margin-top:20px>RFQ Details</h2><table style=width:100%;border-collapse:collapse;margin-top:20px><tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Client name<td style="border:1px solid #ddd;padding:10px;text-align:left">{{CLIENT_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Coverage Type<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_LONG_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Start Date<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_START_DATE}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Duration<td style="border:1px solid #ddd;padding:10px;text-align:left">{{DURATION}}</table><div style="margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic">Please note: Additional terms and details are included in the attachment for your reference.</div><p>Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.<p>Best regards,<p><strong>Nhance India Pvt Ltd</strong><br></div><div style=margin-top:20px;font-size:12px;color:#777;text-align:center><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
//for mail content
if(!empty($mail_content)){
$original_message = $mail_content;
}
//for mail subject
if(!empty($mail_subject)){
$subject = $mail_subject;
}
// print_r($subject); die;
if ($recipient_data) {
foreach ($recipient_data as $recipient) {
@ -1306,7 +1477,7 @@ class LeadsController extends BaseController
// print_rr($message);calculate_days_bw_dates
$res = MailHelper::send_email(['mail' => $recipient['email'], 'cc' => $cc_mails, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to]);
$res = MailHelper::send_email(['mail' => $recipient['email'], 'cc' => $cc_mails, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_mails]);
// !dd($res);
$result_data[] = ['mail' => $recipient['email'], 'status' => $res];
}
@ -1480,83 +1651,126 @@ class LeadsController extends BaseController
public function convertJsonForQCR($json, $type)
{
if ($json) {
// Deep copy of JSON
$first_json = json_decode(json_encode($json), true);
// dd($first_json);
// Column-wise Check: Remove headers and relevant data if qcr == 0
foreach ($json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
if($type == 2){
if ($proposalData['stc'] == 0 || $proposalData['stc'] === false) {
// Remove matching parentHeader in headers
foreach ($first_json['table_data']['headers'] as $index => $header) {
if ($header['parentHeader'] === $proposalKey) {
unset($first_json['table_data']['headers'][$index]);
}
}
// Column-wise Check: Remove headers and relevant data if qcr == 0
foreach ($json['proposal_data']['over_all_column_data'] as $proposalKey => $proposalData) {
// Remove data entries with matching parentth
foreach ($first_json['table_data']['data'] as &$item) {
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($proposalKey) {
return $entry['parentth'] !== $proposalKey;
}));
}
if (($proposalData['qcr'] == 0 || $proposalData['qcr'] === false) || ($proposalData['stc'] == 0 || $proposalData['stc'] === false)) {
// Remove proposalKey from over_all_column_data
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]);
if($type == 2){
// Remove proposalKey from premium_data
unset($first_json['premium_data']['data'][$proposalKey]);
}
}
// Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0
foreach ($proposalData['insurers'] as $insurerIndex => $insurer) {
if ($insurer['stc'] === 0 || $insurer['stc'] === false) {
foreach ($first_json['table_data']['headers'] as &$header) {
if (isset($header['subHeaders'])) {
$header['subHeaders'] = array_values(array_filter($header['subHeaders'], function ($sub) use ($insurer) {
return $sub !== $insurer['display_name'];
}));
// Remove matching parentHeader in headers
foreach ($first_json['table_data']['headers'] as $index => $header) {
if ($header['parentHeader'] === $proposalKey) {
unset($first_json['table_data']['headers'][$index]);
}
}
// Remove data entries with matching parentth
foreach ($first_json['table_data']['data'] as &$item) {
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($insurer) {
return $entry['subth'] !== $insurer['display_name'];
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($proposalKey) {
return $entry['parentth'] !== $proposalKey;
}));
}
// Remove insurer from proposal's insurers array
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]);
// Remove proposalKey from over_all_column_data
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]);
if($type == 2){
unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]);
// Remove proposalKey from premium_data
unset($first_json['premium_data']['data'][$proposalKey]);
}
}
// Insurer Check: Remove subHeaders and relevant data for insurers with qcr == 0
foreach ($proposalData['insurers'] as $insurerIndex => $insurer) {
if (($insurer['qcr'] === 0 || $insurer['qcr'] === false) || ($insurer['stc'] === 0 || $insurer['stc'] === false) ) {
foreach ($first_json['table_data']['headers'] as &$header) {
if (isset($header['subHeaders'])) {
$header['subHeaders'] = array_values(array_filter($header['subHeaders'], function ($sub) use ($insurer) {
return $sub !== $insurer['display_name'];
}));
}
}
foreach ($first_json['table_data']['data'] as &$item) {
$item['data'] = array_values(array_filter($item['data'], function ($entry) use ($insurer) {
return $entry['subth'] !== $insurer['display_name'];
}));
}
// Remove insurer from proposal's insurers array
unset($first_json['proposal_data']['over_all_column_data'][$proposalKey]['insurers'][$insurerIndex]);
if($type == 2){
unset($first_json['premium_data']['data'][$proposalKey][$insurer['display_name']]);
}
}
}
}
}
// Row-wise Check: Remove rows if qcr == 0 for actions
foreach ($first_json['table_data']['data'] as $rowKey => $rowData) {
foreach ($rowData['data'] as $data) {
if ($data['parentth'] === "Action" && isset($data['input_value']['stc']) && $data['input_value']['stc'] == 0) {
unset($first_json['table_data']['data'][$rowKey]);
break;
// Row-wise Check: Remove rows if qcr == 0 for actions
foreach ($first_json['table_data']['data'] as $rowKey => $rowData) {
foreach ($rowData['data'] as $data) {
if ($data['parentth'] === "Action" && (isset($data['input_value']['qcr']) && $data['input_value']['qcr'] == 0) || (isset($data['input_value']['stc']) && $data['input_value']['stc'] == 0)) {
unset($first_json['table_data']['data'][$rowKey]);
break;
}
}
}
}
// Reindex arrays to maintain proper structure
$first_json['table_data']['headers'] = array_values($first_json['table_data']['headers']);
$first_json['table_data']['data'] = array_values($first_json['table_data']['data']);
$first_json['proposal_data']['over_all_column_data'] = array_map(function ($proposal) {
$proposal['insurers'] = array_values($proposal['insurers']);
return $proposal;
}, $first_json['proposal_data']['over_all_column_data']);
// Reindex arrays to maintain proper structure
$first_json['table_data']['headers'] = array_values($first_json['table_data']['headers']);
$first_json['table_data']['data'] = array_values($first_json['table_data']['data']);
$first_json['proposal_data']['over_all_column_data'] = array_map(function ($proposal) {
$proposal['insurers'] = array_values($proposal['insurers']);
return $proposal;
}, $first_json['proposal_data']['over_all_column_data']);
}else{
//remove insurer as Subheaders for RFQ
foreach ($first_json['table_data']['headers'] as &$header) {
$header['subHeaders'] = array_filter($header['subHeaders'], function ($subHeader) {
return in_array($subHeader, ['Quote Asked', '-']);
});
}
//Remove insurer Row wise data for RFQ
foreach ($first_json['table_data']['data'] as &$row) {
// Filter the inner data array
$row['data'] = array_filter(
$row['data'],
function ($item) {
return in_array($item['subth'], ['Quote Asked', '-']);
}
);
$row['data'] = array_values($row['data']);
}
// Ensure to unset the reference after the loop
unset($row);
// Remove insurers from Proposal Data key for RFQ
foreach ($first_json['proposal_data']['over_all_column_data'] as $key => &$proposal) {
if (isset($proposal['insurers'])) {
// Set the insurers array to empty
$proposal['insurers'] = [];
}
}
// Ensure to reset the reference
unset($proposal);
}
return $first_json;
}
@ -1896,8 +2110,54 @@ class LeadsController extends BaseController
//------------------------------------------------------------------------------------------------
public function transformMailContent()
{
public function transformMailContent($lead_id)
{
helper('excel_util_helper');
// $params = $this->request->getGet();
// print_r($params); die;
// $lead_id = $params['lead_id'];
// $file_type = $params['file_type']; //rfq or qcr
// $recipient_type = $params['recipient_type']; //insurer or client or internal or placement
// $recipient_mail = $params['recipient_mail']; // - only primary key of contacts
// $propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null;
// if ($recipient_type == 'insurer' && empty($recipient_mail)) {
// return $this->respond(['status' => 'failed', 'code' => 400, 'data' => '', 'messgae' => 'Recipient mail not found ! '], 200);
// }
//gather lead info
$lead_data = $this->leadsModel
->select('leads.*,policy_type.long_name,policy_type.policy_type,user_profiles.email as created_person_email')
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
->join('user_profiles', 'leads.created_by = user_profiles.id', 'left')
->where('leads.id', $lead_id)
->first();
// dd($lead_data);
if($lead_data){
$recipient_data = ['name' => "Team"];
$original_message = '<div style="width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9;font-family:Arial,sans-serif;color:#333;line-height:1.6"><div style=background-color:#4a90e2;color:#fff;padding:15px;text-align:center><h1 style=margin:0;font-size:24px>Request for Quotation (RFQ)</h1></div><div style=padding:20px;background-color:#fff><h2 style=color:#4a90e2;font-size:20px;margin-top:0>Dear {{RECIPIENT_NAME}},</h2><p>We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.<h2 style=color:#4a90e2;font-size:20px;margin-top:20px>RFQ Details</h2><table style=width:100%;border-collapse:collapse;margin-top:20px><tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Client name<td style="border:1px solid #ddd;padding:10px;text-align:left">{{CLIENT_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Coverage Type<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_LONG_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Start Date<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_START_DATE}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Duration<td style="border:1px solid #ddd;padding:10px;text-align:left">{{DURATION}}</table><div style="margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic">Please note: Additional terms and details are included in the attachment for your reference.</div><p>Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.<p>Best regards,<p><strong>Nhance India Pvt Ltd</strong><br></div><div style=margin-top:20px;font-size:12px;color:#777;text-align:center><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
$message = $original_message;
$message = str_replace("{{RECIPIENT_NAME}}", $recipient_data['name'], $message);
$message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message);
$message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'], $message);
$message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'], 'Y-m-d', 'd-m-Y'), $message);
$message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'] ?? "", $lead_data['policy_start_date'] ?? "")->days, $message) ?? '--';
// return $this->respond(['status' => true, 'code' => 200, 'data' => $message], 200);
return $message;
}else{
// return $this->respond(['status' => false, 'code' => 404, 'message' => "This lead has not data"], 200);
return '';
}
}
}

View File

@ -31,6 +31,7 @@ use App\Models\InsurerStatements;
use App\Models\InvPaymentDetailsModel;
use App\Models\BatchFileModel;
use App\Models\FileModel;
use App\Models\COShareStmtDetailsModel;
use Kint;
class PolicyTransactionController extends BaseController
@ -62,6 +63,7 @@ class PolicyTransactionController extends BaseController
protected $invPaymentDetailsModel;
protected $batchFileModel;
protected $filesModel;
protected $coShareStmtDetailsModel;
public function __construct()
{
@ -91,11 +93,12 @@ class PolicyTransactionController extends BaseController
$this->invPaymentDetailsModel = new InvPaymentDetailsModel();
$this->batchFileModel = new BatchFileModel();
$this->filesModel = new FileModel();
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
$this->invoiceStatus = [
'pending' => 'Pending',
'generated' => 'Generated',
'sent' => 'Sent',
'payment_received' => 'Payment Received',
'payment_received' => 'Payment<br> Received',
];
}
@ -1631,20 +1634,17 @@ class PolicyTransactionController extends BaseController
$end_date = $this->request->getGet('end_date');
$client_id = $this->request->getGet('client_id');
$insurer_id = $this->request->getGet('insurer_id');
$policy_type_id = $this->request->getGet('policy_type_id');
$date_type = $this->request->getGet('date_type');
$issuer = $this->request->getGet('issuer');
$insurer_branch_id = $this->request->getGet('insurer_branch_id');
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : change_date_format($start_date,'d-m-Y','Y-m-01');
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : change_date_format($end_date,'d-m-Y','Y-m-31');
// dd([$start_date,$end_date]);
$start_date = (!isset($start_date) || $start_date === '' || $start_date === null) ? 0 : $start_date;
$end_date = (!isset($end_date) || $end_date === '' || $end_date === null) ? 0 : $end_date;
$client_id = (!isset($client_id) || $client_id === '' || $client_id === null) ? 0 : $client_id;
$insurer_id = (!isset($insurer_id) || $insurer_id === '' || $insurer_id === null) ? 0 : $insurer_id;
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
$insurer_branch_id = (!isset($insurer_branch_id) || $insurer_branch_id === '' || $insurer_branch_id === null) ? 0 : $insurer_branch_id;
$data['outstanting_list'] = $this->policyTransactionModel->getOutstandingReportLIst($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer);
$data['outstanting_list'] = $this->policyTransactionModel->getOutstandingReportLIst($start_date, $end_date,$insurer_id, $insurer_branch_id);
// dd($this->policyTransactionModel->getLastQuery());
// dd($data);
$this->loadLayout('outstanding_report_list', $data);
@ -1676,7 +1676,7 @@ class PolicyTransactionController extends BaseController
WHERE pt_co_share_details.is_active = 1
AND pt_co_share_details.statement_id = insurer_statements.id
) AS exp_inv_amt,
(SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds)
(SELECT SUM(inv_payment_details.inv_amt) + SUM(inv_payment_details.tds) + SUM(inv_payment_details.gst)
FROM inv_payment_details
WHERE inv_payment_details.is_active = 1
AND inv_payment_details.statement_id = insurer_statements.id
@ -1749,9 +1749,10 @@ class PolicyTransactionController extends BaseController
$month = $month.'-01';
// print_r($month);die;
$month = change_date_format($month,'Y-M-d','Y-m-d');
$stmt_sno = $this->request->getPost('statement_no');
// print_r($month);die;
$file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID]); //here field policy_id have client_policy_id and not policy id from policy master
$file_id = $this->insurerStatements->insert(['insurer_id' => $insurer_id, 'branch_id' => $branch_id, 'file_name' => $filename,'month' => $month, 'created_by' => $loggedInUserID,'stmt_sno' => $stmt_sno]); //here field policy_id have client_policy_id and not policy id from policy master
$this->myLogger->logme("error", '{file_id} statement uploaded success', ['file_id' => $file_id]);
//validate file
@ -1839,9 +1840,9 @@ class PolicyTransactionController extends BaseController
unset($excel_data[0]);
// Kint::dump($excel_data);
//get no of line items and update in DB
$line_items = count($excel_data);
$line_items = 0;
// get uploaded month transactions data
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// var_dump($source_data);die();
// Kint::dump($source_data);//die();
@ -1866,6 +1867,7 @@ class PolicyTransactionController extends BaseController
if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date,'d-m-Y','Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date,'d-m-Y','Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
{
$is_source_found = 1;
$line_items = $line_items + 1;
unset($source_data[$source_key]);
continue 2;
}
@ -1942,7 +1944,7 @@ class PolicyTransactionController extends BaseController
//get no of line items and update in DB
$line_items = count($excel_data);
// get uploaded month transactions data
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']);
// Kint::dump($source_data);die;
// Kint::dump($excel_data);
@ -2034,7 +2036,7 @@ class PolicyTransactionController extends BaseController
//find variance
$variance_amt = $source_row['exp_amt'] - $total_amt;
$data_to_update[] = ['id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
$data_to_update[] = ['co_share_id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id];
unset($source_data[$source_key]);
continue 2;
@ -2044,7 +2046,7 @@ class PolicyTransactionController extends BaseController
}
}
// dd($data_to_update);
$this->PTCOShareDetailsModel->updateBatch($data_to_update, 'id');
$this->coShareStmtDetailsModel->insertBatch($data_to_update, 'id');
// dd($data_to_update);
// if($error_data['error_code'])
// {
@ -2066,8 +2068,24 @@ class PolicyTransactionController extends BaseController
->where('is_active',1)
->get()
->getResultArray();
if(!$inv_details['invoice_value'])
{
$stmt_level_value = $this->coShareStmtDetailsModel->select('sum(actual_tep_brokerage_amt) + sum(actual_tp_brokerage_amt) + sum(actual_bp_brokerage_amt) + sum(reward) as invoice_value')
->where('statement_id',$statement_id)
->groupBy('statement_id')
->get()
->getResultArray();
// print_r($stmt_level_value);
if($stmt_level_value && count($stmt_level_value) && isset($stmt_level_value[0]))
{
$inv_details['invoice_value'] = $stmt_level_value[0]['invoice_value'];
}
}
// ~dd($inv_details);
$data = [ 'invoice_status' => $inv_details['invoice_status'],
'gst_per' => isset($inv_details['gst_per']) ? $inv_details['gst_per'] : 18 ,
'invoice_value' => $inv_details['invoice_value'],
'gst_value' => $inv_details['gst_value'],
'invoice_no' => $inv_details['invoice_no'],
'invoice_amount' => $inv_details['invoice_amount'],
'invoice_date' => isset($inv_details['invoice_date']) ? change_date_format($inv_details['invoice_date'],'Y-m-d','d/m/Y') : null ];
@ -2089,6 +2107,9 @@ class PolicyTransactionController extends BaseController
$invoiceNo = $jsonData['invoice_no'];
$invoiceDate = change_date_format($jsonData['invoice_date'],'d/m/Y','Y-m-d');
$invoice_amount = $jsonData['invoice_amount'];
$invoice_value = $jsonData['invoice_value'];
$gst_per = $jsonData['invoice_gst_per'];
$gst_value = $jsonData['invoice_gst'];
//Update statement table
$parentData = [
@ -2096,6 +2117,9 @@ class PolicyTransactionController extends BaseController
'invoice_no' => $invoiceNo,
'invoice_date' => $invoiceDate,
'invoice_amount' => $invoice_amount,
'gst_per' => $gst_per,
'gst_value' => $gst_value,
'invoice_value' => $invoice_value,
'updated_by' => get_session_userid()
];
@ -2107,6 +2131,7 @@ class PolicyTransactionController extends BaseController
$receivedAmounts = $jsonData['received_amount'];
$utrNos = $jsonData['utr_no'];
$tdsTotal = $jsonData['tds'];
$gstTotal = $jsonData['gst_amount'];
$paymentDates = $jsonData['payment_date'];
$pks = $jsonData['pk'];
@ -2114,6 +2139,7 @@ class PolicyTransactionController extends BaseController
$pk = $pks[$index]; // Get the pk for the current record
$utrNo = $utrNos[$index];
$tds = $tdsTotal[$index];
$gst = $gstTotal[$index];
$paymentDate = $paymentDates[$index];
// Prepare data for insert/update
@ -2121,6 +2147,7 @@ class PolicyTransactionController extends BaseController
'inv_amt' => $receivedAmount,
'utr_no' => $utrNo,
'tds' => $tds,
'gst' => $gst,
'received_date' => change_date_format($paymentDate,'d/m/Y','Y-m-d'),
'statement_id' => $hiddenStatementId
];
@ -2357,6 +2384,45 @@ class PolicyTransactionController extends BaseController
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found for this CD'], 200);
}
public function getInsurerStatementMonth()
{
$insurer_id = $this->request->getGet('insurer_id');
$month = $this->request->getGet('month');
// echo $month;
$insurer_branch_id = explode('-',$insurer_id)[1];
$insurer_id = explode('-',$insurer_id)[0];
$month = $month.'-01';
$month = change_date_format($month,'Y-M-d','Y-m-d');
// echo $month;
$res_data = $this->insurerStatements
->where('insurer_id',$insurer_id)
->where('branch_id',$insurer_branch_id)
->where('month', $month)
->where('is_active', 1)
->where('file_status', 'success')
->findAll();
return $this->respond(['dataStatus' => true, 'code' => 200,'data' => $res_data], 200);
}
public function deleteStatement($id)
{
// echo $id;die();
$this->coShareStmtDetailsModel->where('statement_id',$id)
->set(['is_active' => 0])
->update();
$this->invPaymentDetailsModel->where('statement_id',$id)
->set(['is_active' => 0])
->update();
$this->insurerStatements->where('id',$id)
->set(['is_active' => 0])
->update();
return $this->respond(['dataStatus' => true, 'code' => 200], 200);
}
}

View File

@ -97,7 +97,9 @@ class MailHelper
//check BCC mail
if (isset($params['bcc'])) {
$bcc = $params['bcc'];
$bcc = explode(',', $bcc);
if(!is_array($bcc)){
$bcc = explode(',', $bcc);
}
}else{
$bcc = [];
}

View File

@ -128,7 +128,7 @@ if (! function_exists('transform_objects_to_array_for_inception')) {
$obj->emp_gender, // Employee Gender
$obj->pre_existing_alignments, // Pre-existing Alignments
$obj->basic_cover_si, // Basic Cover SI
$obj->date_coverage, // Date Coverage
$obj->date_of_coverage, // Date Coverage
$obj->emp_age, // Employee Age
$obj->emp_relationship, // Employee Relationship
$obj->change_event, // Change Event
@ -260,7 +260,6 @@ if (! function_exists('transform_objects_to_array_for_deletion')) {
$obj->total,
$claim_status,
$endorsement_id
];
// Append the row data to the main data array
@ -487,7 +486,7 @@ if (!function_exists('format_Excel_BasedOn_Client'))
$rowData[] = $obj->basic_cover_si; // Employee BASIC COVER SI
break;
case 'dateofcoverage':
$rowData[] = $obj->date_coverage; // DATE OF COVERAGE
$rowData[] = $obj->date_of_coverage; // DATE OF COVERAGE
break;
case 'age':
$rowData[] = $obj->emp_age; // Employee AGE

View File

@ -345,8 +345,7 @@ if(!function_exists('check_basic_pay'))
if (!function_exists('check_dob_diff'))
{
function check_dob_diff($row,$relationships,$default_age_ratio) {
// echo 'called';
function check_dob_diff($row,$relationships,$default_age_ratio,$policy_details) {
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','MI']))// check rule only of action column data available
{
if($row[3] != null && $row[5] != null)
@ -358,13 +357,11 @@ if (!function_exists('check_dob_diff'))
}
// return array('status' => true);
$dob = $dateString;
// echo $row[3].' - '.$dob;echo '<br>';
$currentDateTime = new DateTime();//die();
// print_r($currentDateTime);
//$currentDateTime = new DateTime();//previously dob calculated from current date time
$temp_date = ($row[7] != null && $row[7] != "") ? convert_string_to_date($row[7]) : $policy_details[0]->policy_start_date; //pick date of coverage from row if not then use policy start date as from to calculate DOB
$currentDateTime = new DateTime($temp_date);//later DOB calculated from date of coverage or policy_start_date
// die();
$passedDateTime = new DateTime($dob);
// print_r($passedDateTime);
$interval = $currentDateTime->diff($passedDateTime);
//remap default age ratio data into relationship array
if(count($default_age_ratio))
@ -375,7 +372,6 @@ if (!function_exists('check_dob_diff'))
$relationship = $slug->slugify($row[5]);
$age_min = isset($relationships[$relationship]['age_min']) ? $relationships[$relationship]['age_min'] : NULL;
$age_max = isset($relationships[$relationship]['age_max']) ? $relationships[$relationship]['age_max'] : NULL;
// echo $relationship.','.$age_min.'-'.$age_max;
if($age_min !== null && $age_min > $interval->y)
{
return array('status' => false,'error' => "Age conflict : minimum $age_min yrs allowed, received $interval->y");
@ -965,7 +961,6 @@ if (!function_exists('calculate_premium_new'))
if(empty($member[18])){ $member[18] = $existing_units[0]; }
//transform as db row column
$transformed_familiy_member_data = transform_excel_data_to_db($member,$fileArr);
// kint::dump($transformed_familiy_member_data);
//generate relationship code
if($transformed_familiy_member_data['temp']['action'] != 'D' && $transformed_familiy_member_data['temp']['action'] != 'C' && $transformed_familiy_member_data['temp']['action'] != 'SI')
{
@ -979,7 +974,7 @@ if (!function_exists('calculate_premium_new'))
'isEmployeeSourceEnrollment' => $fileArr['id'] == null,
'isEmployeeSourceExcelFile' => $transformed_familiy_member_data['temp']['source'] == 'excel',
'isCurrentActionDependentAddition' => $fileArr['action'] == 'dependent_addition',
// 'isPrimaryGridPremiumTypeSingle' => $transformed_familiy_member_data['temp']['premium_type'] == 1,
'isPrimaryGridPremiumTypeSingle' => isset($transformed_familiy_member_data['temp']['premium_type']) ? $transformed_familiy_member_data['temp']['premium_type'] == 1 : 0,
'isCurrentRelationshipSelf' => (strtolower($transformed_familiy_member_data['relationship']) == 'self' || (isset($transformed_familiy_member_data['temp']['acting_self']) && $transformed_familiy_member_data['temp']['acting_self'] === true)),
'isBasicCoverCalculatedToCurrentEmployee' => ($transformed_familiy_member_data['policy_details']['basic_cover_si'] != null && $transformed_familiy_member_data['policy_details']['basic_cover_si'] != 0)
];
@ -1049,7 +1044,7 @@ if (!function_exists('transform_excel_data_to_db'))
$result['designation'] = $memArr[11];
$result['mobile'] = $memArr[12];
$result['email_corporate'] = $memArr[13];
$result['file_id'] = $actionArr['id'];
$result['file_id'] = isset($memArr['temp']['source']) && $memArr['temp']['source'] == 'db' && isset($memArr['temp']['file_id']) ? $memArr['temp']['file_id'] : $actionArr['id'];
$result['client_id'] = $actionArr['client_id'];
$result['change_event'] = $memArr[15];
$result['unit'] = $memArr[18];
@ -1078,8 +1073,6 @@ if (!function_exists('premium_calculation_manager'))
{
function premium_calculation_manager($emp_data,$policy_terms,$slab_details,$default_si = null)
{
// Kint::dump($emp_data);die();
$myLogger = \Config\Services::mylogger();
// grid type
// 1 = premium => si
@ -1229,9 +1222,12 @@ if (!function_exists('premium_calculation_manager'))
//GMC - Employees Age band
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
// dd($employee_received_si);
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{
// dd($slab_value);
@ -1250,9 +1246,12 @@ if (!function_exists('premium_calculation_manager'))
case "5":
//GMC - Employees Age + SI
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3 ) ))
{
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
@ -1270,9 +1269,11 @@ if (!function_exists('premium_calculation_manager'))
case "6":
//GMC - Employees + Dependent Age band
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{
// echo $emp_data['name'];
@ -1292,9 +1293,11 @@ if (!function_exists('premium_calculation_manager'))
case "7":
//GMC - Employees + Dependent Age + SI
$employee_received_si = $default_si == null ? $emp_data['policy_details']['basic_cover_si'] : $default_si;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
if($slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && (($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) ) || ($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) ))
{
$emp_data['policy_details']['basic_cover_si'] = $slab_value['si'];
@ -1442,7 +1445,8 @@ if (!function_exists('premium_calculation_manager'))
$employee_relationship = $slug->slugify($emp_data['relationship']);
$employee_relationship = ($employee_relationship == 'daughter' || $employee_relationship == 'son' ? $employee_relationship = 'child' : $employee_relationship);
$emp_data['policy_details']['basic_cover_si'] = null;
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
foreach ($temp_slab_rates as $skey => $slab_value)
{
if( $slab_value['si'] == $employee_received_si && $slab_value['unit'] == $emp_data['unit'] && ($slab_value['age_from'] <= $age && $slab_value['age_to'] >= $age) && ((($slab_value['premium_type'] == 2 || $slab_value['premium_type'] == null || $slab_value['premium_type'] == 3) && $slab_value['relationship'] == $employee_relationship) || ($slab_value['premium_type'] == 1 && ( strtolower($emp_data['relationship']) == 'self' || $emp_data['temp']['acting_self'] ) )) )
@ -1475,7 +1479,8 @@ if (!function_exists('premium_calculation_manager'))
}
if(!$is_match_found)
{
$age = calculate_days_bw_dates(from_date: $emp_data['dob'])->y;
$temp_date = (isset($emp_data['policy_details']['date_coverage']) ? $emp_data['policy_details']['date_coverage'] : $policy_terms['policy_start_date']);
$age = calculate_days_bw_dates(from_date: $emp_data['dob'],to_date: $temp_date)->y;
$log_message = '[ client_policy_id : ' .$emp_data['policy_details']['client_policy_id'].' - '. $emp_data['emp_code'].' - '.$emp_data['name'] .' - '. $emp_data['policy_details']['basic_cover_si'] . ', Age : '. $age.' ]';
if($temp_slab_rates[0]['premium_type'] == 1)
{
@ -1560,6 +1565,7 @@ if (!function_exists('transform_db_data_to_excel'))
$row['temp']['emp_status'] = $value['emp_status'];
$row['temp']['policy_status'] = $value['status'];
$row['temp']['rata_premimum'] = $value['rata_premimum'];
$row['temp']['file_id'] = $value['file_id'];
array_push($return_data, ($row));
}

View File

@ -21,7 +21,7 @@ class MyLogger extends Logger
$message = '{context} - {uuid} -' . $message;
// /echo $message;//die();
$context = array_merge($context,['uuid' => get_session_uuid()]);
$context = array_merge($context,['uuid' => (null !== get_session_uuid()) ? get_session_uuid() : 'CLI']);
// print_r($context);die();
// echo isset($context['context']) ? $context['context'] : $this->context;die();
$context['context'] = isset($context['context']) ? $context['context'] : get_session_context();

View File

@ -106,7 +106,7 @@ class EmployeeModel extends Model
public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = [],array $relationship = [],array $client_branch_id = [])
{
$result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon', 'employee_polices.payable_employee'])
$result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employees.file_id','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon', 'employee_polices.payable_employee'])
->join('employee_polices', 'employee_polices.employee_id = employees.id')
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id','left')

View File

@ -179,7 +179,11 @@ class EmployeePolicyModel extends Model
$result->where('employee_polices.is_active', 1)
->where('emp.is_active', 1);
return $result->findAll();
$res = $result->findAll();
// dd($this->db->getLastQuery());
return $res;
}
public function getEmployeePolicyForEcard($policy_id = 0)
@ -275,7 +279,7 @@ class EmployeePolicyModel extends Model
employee_polices.uhid,
employee_polices.pre_existing_alignments,
employee_polices.basic_cover_si,
employee_polices.date_coverage,
employee_polices.date_coverage as date_of_coverage,
employee_polices.policy_end_date,
employee_polices.days as no_of_days,
employee_polices.premium,
@ -322,6 +326,9 @@ class EmployeePolicyModel extends Model
}else{
$results = $query->getResult();
}
// dd($this->db->getLastQuery());
return $results;
}
@ -556,6 +563,175 @@ class EmployeePolicyModel extends Model
}
// DO NOT DELETE this DELETION QUERY FUNCTION
// public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
// {
// $client_id = $ref_data['client_id'];
// $client_policy_id = $ref_data['client_policy_id'];
// $client_branch_id = $ref_data['client_branch_id'];
// $insurer_or_tpa = $ref_data['insurer_or_tpa'];
// $get_insurer_id_from_client_policy = $this->db->table('client_policy')
// ->select('insurer_id')
// ->where('id', $client_policy_id)
// ->get()
// ->getRowArray();
// $add_one_day = 0;
// if (!empty($get_insurer_id_from_client_policy)) {
// $get_the_insurer_add_one_for_delete = $this->db->table('insurers')
// ->select('deletion_add_day')
// ->where('id', $get_insurer_id_from_client_policy['insurer_id'])
// ->get()
// ->getRowArray();
// if (!empty($get_the_insurer_add_one_for_delete) && $get_the_insurer_add_one_for_delete['deletion_add_day'] == 1) {
// $add_one_day = 1;
// }
// }
// $status_condition = "{$insurer_or_tpa}" === 'tpa'
// ? "employee_polices.status = 'inactive' AND employees.emp_status = 'inactive'"
// : "employee_polices.status = 'active' AND employees.emp_status = 'active'";
// $endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
// $query = $this->db->query("
// SELECT DISTINCT
// a.id as endorsement_primarykey,
// a.group_key,
// employee_polices.id as primaryKey,
// employees.name AS emp_name,
// employees.emp_code AS emp_code,
// employees.dob AS emp_dob,
// employees.gender AS emp_gender,
// employees.relationship AS emp_relationship,
// employees.relationship_code AS emp_relationship_code,
// employees.emp_type as emp_type,
// 'D' as event_type_data,
// TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
// employees.doj AS emp_doj,
// employees.mobile AS emp_mobile,
// employees.email_corporate AS emp_email_c,
// employees.email_personal AS emp_email_p,
// employees.band AS emp_grade,
// employees.designation AS emp_designation,
// employees.basic_pay AS emp_basic_pay,
// employee_polices.basic_cover_si,
// employee_polices.uhid as uhid,
// employee_polices.policy_end_date,
// employee_polices.rata_premimum as premium,
// employee_polices.claim_status,
// batch_data.emp_policy_id AS emp_policy_id,
// batch_data.bl AS batch_list_batch_code,
// batch_data.bf AS batch_files_batch_code,
// deletiondata.empstatus,
// deletiondata.changeevent,
// deletiondata.dateofexit,
// deletiondata.reasonforexit,
// deletiondata.status,
// DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2)
// ELSE
// 0
// END AS pro_rata_premium,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2)
// ELSE
// 0
// END AS gst,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) +
// (((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2)
// ELSE
// 0
// END AS total,
// CASE
// WHEN employee_polices.claim_status = 0 THEN
// 'No claim'
// ELSE
// 'Claim'
// END AS claim_status
// FROM
// emp_endorsement a
// LEFT JOIN
// employees ON a.emp_code = employees.emp_code
// LEFT JOIN
// employee_polices ON employees.id = employee_polices.employee_id
// LEFT JOIN(
// select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from
// ( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status' and a1.status != 'truncated') aa
// left join
// ( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event' and b1.status != 'truncated') bb on aa.emp_code = bb.emp_code
// left join
// ( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit' and c1.status != 'truncated') cc on aa.emp_code = cc.emp_code
// left join
// ( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit' and d1.status != 'truncated') dd on aa.emp_code = dd.emp_code
// left JOIN
// ( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status' and e1.status != 'truncated') ee on aa.emp_code = ee.emp_code
// ) as deletiondata on a.emp_code = deletiondata.emp_code and a.status != 'truncated'
// LEFT JOIN
// (
// SELECT
// batch_list.emp_policy_id,
// batch_list.batch_code AS bl,
// batch_files.batch_code AS bf
// FROM
// batch_files
// LEFT JOIN
// batch_list ON batch_files.batch_code = batch_list.batch_code
// WHERE
// batch_files.event_type = 'deletion'
// AND batch_files.actions = 'export'
// AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
// ) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
// WHERE employee_polices.client_policy_id = {$client_policy_id}
// AND employees.client_branch_id = {$client_branch_id}
// $endorsement_condition
// AND a.actions = 'd'
// AND a.status != 'truncated'
// AND employee_polices.is_active = 1
// AND employees.is_active = 1
// AND $status_condition
// group by group_key
// ");
// if($return_type == 1){
// $result = $query->getResultArray();
// }else{
// $result = $query->getResult();
// }
// // dd($this->db->getLastQuery(), $result);
// return $result;
// }
public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
{
@ -666,28 +842,31 @@ class EmployeePolicyModel extends Model
FROM
emp_endorsement a
LEFT JOIN
employees ON a.emp_code = employees.emp_code and a.pk = employees.id
employee_polices ON a.pk = employee_polices.id
LEFT JOIN
employee_polices ON employees.id = employee_polices.employee_id
LEFT JOIN(
select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from
( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status' and a1.status != 'truncated') aa
left join
( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event' and b1.status != 'truncated') bb on aa.emp_code = bb.emp_code
left join
( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit' and c1.status != 'truncated') cc on aa.emp_code = cc.emp_code
left join
( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit' and d1.status != 'truncated') dd on aa.emp_code = dd.emp_code
left JOIN
( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status' and e1.status != 'truncated') ee on aa.emp_code = ee.emp_code
) as deletiondata on a.emp_code = deletiondata.emp_code and a.status != 'truncated'
employees ON employee_polices.employee_id = employees.id
LEFT JOIN (
SELECT
emp_code,
group_key,
MAX(CASE WHEN field_name = 'emp_status' THEN new_value END) AS empstatus,
MAX(CASE WHEN field_name = 'change_event' THEN new_value END) AS changeevent,
MAX(CASE WHEN field_name = 'date_of_exit' THEN new_value END) AS dateofexit,
MAX(CASE WHEN field_name = 'reason_for_exit' THEN new_value END) AS reasonforexit,
MAX(CASE WHEN field_name = 'status' THEN new_value END) AS status
FROM
emp_endorsement
WHERE
status != 'truncated'
GROUP BY
group_key
) AS deletiondata
ON a.emp_code = deletiondata.emp_code AND a.status != 'truncated'
LEFT JOIN
(
(
SELECT
batch_list.emp_policy_id,
batch_list.batch_code AS bl,
@ -700,7 +879,7 @@ class EmployeePolicyModel extends Model
batch_files.event_type = 'deletion'
AND batch_files.actions = 'export'
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
WHERE employee_polices.client_policy_id = {$client_policy_id}
AND employees.client_branch_id = {$client_branch_id}
@ -720,6 +899,7 @@ class EmployeePolicyModel extends Model
}
// dd($this->db->getLastQuery(), $result);
// dd($result);
return $result;

View File

@ -80,6 +80,10 @@ class LeadsModel extends Model
'premium_amount',
'total_amount',
'cd_amount',
'total_si_at_incept',
'total_si_at_renewal',
'fin_years_claims',
];

View File

@ -399,6 +399,7 @@ class PolicyTransactionModel extends Model
WHERE
co_share_stmt_details.co_share_id = pt_co_share_details.id
AND co_share_stmt_details.is_active = 1
AND insurer_statements.is_active = 1
$date_condition
),
2
@ -465,7 +466,7 @@ class PolicyTransactionModel extends Model
AND co_share_stmt_details.is_active = 1
AND pt_table.is_active = 1
AND insurer_statements.is_active = 1
AND insurer_statements.invoice_no IS NOT NULL
AND insurer_statements.invoice_no IS NULL
$date_condition
)
),

View File

@ -60,15 +60,13 @@ class RFQModel extends Model
public function getRFQTableDataWithLeadIDAndType($lead_id, $type){
return $this->select('
leads.client_name,
leads.client_short_name,
leads.*,
insurers.name as insurer_name,
insurer_branch.branch_name as insurer_branch_name,
tpa.name as tpa_name,
tpa_branch.branch_name as tpa_branch_name,
policy_type.policy_type,
rfq.json,
file_name
')
->join('leads', 'rfq.lead_id = leads.id')
->join('policy_type', 'leads.policy_type_id = policy_type.id')

View File

@ -441,6 +441,7 @@ table.dataTable tbody td {
switchRequired('received_amount',false,'name');
switchRequired('tds',false,'name');
switchRequired('gst_amount',false,'name');
switchRequired('utr_no',false,'name');
switchRequired('payment_date',false,'name');
switchRequired('pk',false,'name');
@ -458,6 +459,7 @@ table.dataTable tbody td {
switchRequired('received_amount',true,'name');
switchRequired('utr_no',true,'name');
switchRequired('tds',true,'name');
switchRequired('gst_amount',true,'name');
switchRequired('payment_date',true,'name');
switchRequired('pk',true,'name');
}else if(invoiceStatus === 'pending')
@ -476,8 +478,11 @@ table.dataTable tbody td {
switchRequired('payment_date',false,'name');
switchRequired('pk',false,'name');
switchRequired('tds',false,'name');
switchRequired('gst_amount',false,'name');
}
calcGSTValue();
});
@ -704,6 +709,11 @@ function showInvoiceStatusModal(event)
document.getElementById('invoice_value_modal').value = response.data.invoice_value;
document.getElementById('gst_per_modal').value = response.data.gst_per;
document.getElementById('gst_value_modal').value = response.data.gst_value;
console.log('response.data.gst_value - ' + response.data.gst_value);
if(response.data.gst_value == 0 || response.data.gst_value == '' || response.data.gst_value == null)
{
calcGSTValue();
}
if (!$('#invoice_date_modal').val()) {
// alert('nope');
@ -1051,20 +1061,34 @@ function getStatementNo()
function calcGSTValue()
{
// alert('calcGSTValue');
var gst_per = document.getElementById('gst_per_modal').value;
var invoice_value_dom_obj = document.getElementById('invoice_value_modal');
var invoice_value = invoice_value_dom_obj.value;
var gst_value_dom_obj = document.getElementById('gst_value_modal');
var gst_value = gst_value_dom_obj.value;
var invoice_amount_dom_obj = document.getElementById('invoice_amount_no_modal');
// var invoice_amount = invoice_amount_dom_obj.value();
console.log('calcGSTValue called');
var inv_status_element = document.getElementById('invoice_status');
gst_value_dom_obj.value = (parseFloat(gst_per) / 100 ) * invoice_value;
invoice_amount_dom_obj.value = parseFloat(invoice_value_dom_obj.value) + parseFloat(gst_value_dom_obj.value);
checkInvAmont();
if(inv_status_element.value == 'generated' || inv_status_element.value == 'send' || inv_status_element.value == 'payment_received')
{
var gst_per = document.getElementById('gst_per_modal').value;
console.log('gst_per - ' + gst_per);
var invoice_value_dom_obj = document.getElementById('invoice_value_modal');
var invoice_value = invoice_value_dom_obj.value;
console.log('invoice_value - ' + invoice_value);
var gst_value_dom_obj = document.getElementById('gst_value_modal');
var gst_value = gst_value_dom_obj.value;
console.log('gst_value - ' + gst_value);
var invoice_amount_dom_obj = document.getElementById('invoice_amount_no_modal');
// var invoice_amount = invoice_amount_dom_obj.value();
gst_value_dom_obj.value = Math.round((parseFloat(gst_per) / 100 ) * invoice_value);
// gst_value_dom_obj.value = ((parseFloat(gst_per) / 100 ) * invoice_value);
invoice_amount_dom_obj.value = parseFloat(invoice_value_dom_obj.value) + parseFloat(gst_value_dom_obj.value);
if(inv_status_element.value == 'payment_received')
{
checkInvAmont();
}
}
}

View File

@ -384,7 +384,7 @@ function getLeadsDataForEdit(input) {
$('#contact_person_name').val(res.data.contact_person_name);
$('#contact_person_mobile').val(res.data.contact_person_mobile);
$('#contact_person_email').val(res.data.contact_person_email);
$('#policy_type_id_1').val(res.data.policy_type_id).change();
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000)
@ -397,7 +397,6 @@ function getLeadsDataForEdit(input) {
var proposed_insurer = res.data.proposed_insurer_branch_id + '-' + res.data.proposed_insurer_id;
var proposed_tpa = res.data.proposed_tpa_branch_id + '-' + res.data.proposed_tpa_id;
$('#policy_type_id_1').val(res.data.policy_type_id).change();
$('#insurer_1').val(insurer).select2();
$('#tpa_1').val(tpa).select2();
$('#proposed_insurer_1').val(proposed_insurer).select2();
@ -405,7 +404,6 @@ function getLeadsDataForEdit(input) {
$('#policy_start_date_1').val(res.data.policy_start_date);
$('#policy_end_date_1').val(res.data.policy_end_date);
$('#no_of_lives').val(res.data.no_of_lives);
$('#incurred_claims').val(res.data.incurred_claims);
$('#location').val(res.data.location);
let increment = 1;
@ -430,7 +428,12 @@ function getLeadsDataForEdit(input) {
$('#annualised_claims_' + increment).val(res.data.annualised_claims);
$('#incurred_claims_ratio_' + increment).val(res.data.incurred_claims_ratio);
$('#earned_claims_ratio_' + increment).val(res.data.earned_claims_ratio);
$('#incurred_claims_' + increment).val(res.data.incurred_claims);
$('#file_name_display').text('Upload File Name : ' + res.data.file_name);
// $('#file_name').val(res.data.file_name);
$('#total_si_at_incept_' + increment).val(res.data.total_si_at_incept);
$('#total_si_at_renewal_' + increment).val(res.data.total_si_at_renewal);
if (res.data.salse_person_id) {
@ -476,6 +479,33 @@ function getLeadsDataForEdit(input) {
}
}
if(res.data.policy_type_id != 2){
$('.gpa_hide_div_'+increment).hide();
$('.gpa_show_div_'+increment).show();
$('.gpa_div_elements_'+increment).show();
$('.emp_title').text('No of Employees at Inception');
let claimExperience = JSON.parse(res.data.fin_years_claims);
claimExperience[0].finyear.forEach((data, index) => {
const year = document.querySelector(`#${["first", "second", "third"][index]}_year_${increment}`);
const claimAmount = document.querySelector(`#${["first", "second", "third"][index]}_claim_amount_${increment}`);
const claimStatus = document.querySelector(`#${["first", "second", "third"][index]}_claim_status_${increment}`);
const causeOfDeath = document.querySelector(`#${["first", "second", "third"][index]}_casue_of_death_${increment}`);
const deathDate = document.querySelector(`#${["first", "second", "third"][index]}_death_date_${increment}`);
if (year) year.value = data.year;
if (claimAmount) claimAmount.value = data.claim_amount;
if (claimStatus) claimStatus.value = data.status;
if (causeOfDeath) causeOfDeath.value = data.cause_of_death;
if (deathDate) deathDate.value = data.death_date;
});
}else{
$('.gpa_hide_div_'+increment).show();
}
} else {
console.log('No data found');
@ -624,7 +654,6 @@ function getPolicyData(client_policy_id, increment_count) {
}
}
// Salse team user list data
function selecSalsePerson(salse_person_ids) {
@ -670,6 +699,22 @@ function addHTMLInput(check) {
const newRow8 = document.createElement('div');
newRow8.className = 'form-row dynamic-form-row';
const newRow6 = document.createElement('div');
newRow6.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow6.style.display = 'none';
const newRow9 = document.createElement('div');
newRow9.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow9.style.display = 'none';
const newRow10 = document.createElement('div');
newRow10.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow10.style.display = 'none';
const newRow11 = document.createElement('div');
newRow11.className = `form-row dynamic-form-row gpa_div_elements_${increment}`;
newRow11.style.display = 'none';
// Add an <hr> element
const hrElement = document.createElement('hr');
container.appendChild(hrElement);
@ -679,7 +724,7 @@ function addHTMLInput(check) {
<div class="form-group col-md-3">
<label for="policy_type_id">Policy Type <span class="text-danger">*</span></label>
<select class="form-control" id="policy_type_id_${increment}" name="policy_type_id[]" required>
<select class="form-control" id="policy_type_id_${increment}" name="policy_type_id[]" onchange="showGpaColumns(this)" required>
<option value="">Select Policy Type</option>
<?php
if (isset($policy_type) && count($policy_type)) {
@ -833,15 +878,20 @@ function addHTMLInput(check) {
<input type="text" class="form-control" id="renewal_emp_count_${increment}" name="renewal_emp_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="renewal_dept_count_${increment}"> No of Dependents at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_dept_count_${increment}" name="renewal_dept_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="renewal_no_of_lives_${increment}"> Total Lives at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_no_of_lives_${increment}" name="renewal_no_of_lives[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_show_div_${increment}" style="display:none;">
<label for="total_si_at_renewal_${increment}"> Total Sum Insured at Renewal <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="total_si_at_renewal_${increment}" name="total_si_at_renewal[]" placeholder="Enter Lives" >
</div>
`;
//inception div
@ -852,15 +902,20 @@ function addHTMLInput(check) {
<input type="text" class="form-control" id="incept_emp_count_${increment}" name="incept_emp_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="incept_dept_count_${increment}" class="depnd_title"> No of Dependents at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incept_dept_count_${increment}" name="incept_dept_count[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-3 gpa_hide_div_${increment}" style="display:none;">
<label for="incept_no_of_lives_${increment}" class="total_title"> Total Lives at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="incept_no_of_lives_${increment}" name="incept_no_of_lives[]" placeholder="Enter Lives" >
</div>
<div class="form-group col-md-3 gpa_show_div_${increment}" style="display:none;">
<label for="total_si_at_incept_${increment}" class="total_title"> Total Sum Insured at Inception <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="total_si_at_incept_${increment}" name="total_si_at_incept[]" placeholder="Enter Lives" >
</div>
`;
//expiry div
@ -887,14 +942,91 @@ function addHTMLInput(check) {
newRow7.innerHTML += `
<div class="form-group col-md-3">
<label for="file_upload">File Upload<span class="text-danger">*</span></label>
<input type="file" class="form-control" id="file_name" name="file_name[]" required>
<input type="file" class="form-control" id="file_name_${increment}" name="file_name[]" accept=".xls,.xlsx">
<span class="text-danger" id="file_name_display"></span>
</div>
`;
newRow9.innerHTML +=`<div class="form-group col-md-3"><h5>Claims Experience for last 3 Years </h5></div>`;
//Last 3 years claims expirence div
newRow6.innerHTML += `
<div class="form-group col-md-3">
<label for="first_year_${increment}">Year<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_year_${increment}" name="first_year[]">
</div>
<div class="form-group col-md-3">
<label for="first_claim_amount_${increment}">Claim Amount / Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]">
</div>
<div class="form-group col-md-3">
<label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]">
</div>
<div class="form-group col-md-3">
<label for="first_casue_of_death_${increment}">Nature / Casue Of Death <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_casue_of_death_${increment}" name="first_casue_of_death[]">
</div>
<div class="form-group col-md-3">
<label for="first_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_death_date_${increment}" name="first_death_date[]">
</div>
`;
//Last 3 years claims expirence div
newRow10.innerHTML += `
<div class="form-group col-md-3">
<label for="second_year_${increment}">Year<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_year_${increment}" name="second_year[]">
</div>
<div class="form-group col-md-3">
<label for="second_claim_amount_${increment}">Claim Amount / Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_claim_amount_${increment}" name="second_claim_amount[]">
</div>
<div class="form-group col-md-3">
<label for="second_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_claim_status_${increment}" name="second_claim_status[]">
</div>
<div class="form-group col-md-3">
<label for="second_casue_of_death_${increment}">Nature / Casue Of Death <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_casue_of_death_${increment}" name="second_casue_of_death[]">
</div>
<div class="form-group col-md-3">
<label for="second_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="second_death_date_${increment}" name="second_death_date[]">
</div>
`;
//Last 3 years claims expirence div
newRow11.innerHTML += `
<div class="form-group col-md-3">
<label for="third_year_${increment}">Year<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_year_${increment}" name="third_year[]">
</div>
<div class="form-group col-md-3">
<label for="third_claim_amount_${increment}">Claim Amount / Settled Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_claim_amount_${increment}" name="third_claim_amount[]">
</div>
<div class="form-group col-md-3">
<label for="third_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_claim_status_${increment}" name="third_claim_status[]">
</div>
<div class="form-group col-md-3">
<label for="third_casue_of_death_${increment}">Nature / Casue Of Death <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_casue_of_death_${increment}" name="third_casue_of_death[]">
</div>
<div class="form-group col-md-3">
<label for="third_death_date_${increment}">Date of Death<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="third_death_date_${increment}" name="third_death_date[]">
</div>
`;
//button div
newRow5.innerHTML += `
<div class="form-group col-md-12 btnDiv" style="position: relative;top: 28px;float: right;text-align: end;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(1)">+</a>
@ -902,25 +1034,44 @@ function addHTMLInput(check) {
`;
container.appendChild(newRow);
container.appendChild(newRow8);
const hrElement2 = document.createElement('hr');
container.appendChild(hrElement2);
//inception div
container.appendChild(newRow3);
//renewal div
container.appendChild(newRow2);
//expiry div
container.appendChild(newRow4);
const hrElement3 = document.createElement('hr');
hrElement3.className = "gpa_div_elements"; // Set class to hrElement3
container.appendChild(hrElement3); // Append hrElement3 to container
container.appendChild(newRow9);
//Last 3 years claims expirence div
container.appendChild(newRow6);
container.appendChild(newRow10);
container.appendChild(newRow11);
//file upload div
container.appendChild(newRow7);
//button div
container.appendChild(newRow5);
var lead_type = $('#lead_type').val();
if (lead_type == 2) {
// $('.proposed_div').show().find('select, input').attr('required', 'required');
$('.proposed_div').show();
$('.freashDiv').show()
@ -929,11 +1080,13 @@ function addHTMLInput(check) {
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
$('.gpa_div_elements').show();
} else {
// $('.proposed_div').hide().find('select, input').removeAttr('required');
$('.proposed_div').hide()
$('.gpa_div_elements').hide();
if(lead_type == 1){
$('.freashDiv').hide()
@ -947,6 +1100,7 @@ function addHTMLInput(check) {
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
$('.gpa_div_elements').show();
}
}
@ -982,7 +1136,7 @@ function addHTMLInput(check) {
console.log('increment', increment);
console.log('policy_start_datePicker selectedDates', selectedDates);
console.log('policy_start_datePicker incurred_claim_', $("#incurred_claim_" + increment).val());
console.log('policy_start_datePicker incurred_claim_date_', $("#incurred_claim_date_" + increment).val());
// Recalculate policy_run_days if incurred claim date is already selected
if ($("#incurred_claim_date_" + increment).val()) {
@ -1000,21 +1154,19 @@ function addHTMLInput(check) {
var incurred_claim_datepicker = flatpickr("#incurred_claim_date_" + increment, {
dateFormat: "d/m/Y",
allowInput: false,
onChange: function(selectedDates) {
onChange: function (selectedDates) {
console.log('Flatpickr instance:', this);
console.log('ID of this element:', this.input.id);
console.log('this object', this);
console.log('id of this element:', this.id);
// Extract the increment value from the element's ID
let increment = this.input.id.split('_').pop();
console.log('Extracted increment:', increment);
let increment = this.element.id.split('_').pop();
console.log(increment); // Outputs: 1
console.log('selectedDates', selectedDates);
console.log('policy_start_date_', $("#policy_start_date_" + increment).val());
console.log('Selected Dates:', selectedDates);
console.log('Policy Start Date:', $("#policy_start_date_" + increment).val());
// Recalculate policy_run_days if policy start date is already selected
if ($("#policy_start_date_" + increment).val()) {
console.log('selectedDates', selectedDates);
calculatePolicyRunDays(increment);
}
}
@ -1041,8 +1193,7 @@ function addHTMLInput(check) {
increment++; // Increment after adding the input
}
function removeHTMLInput(element)
{
function removeHTMLInput(element) {
const container = document.getElementById('dynamic-form-container');
const rows = container.querySelectorAll('.dynamic-form-row');
@ -1063,9 +1214,10 @@ function removeHTMLInput(element)
function calculatePolicyRunDays(increment) {
console.log('calculatePolicyRunDays function called');
console.log('increment', increment);
var policyStartDate = flatpickr.parseDate($("#policy_start_date_" + increment).val(), "d/m/Y");
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_" + increment).val(), "d/m/Y");
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
console.log('policyStartDate', policyStartDate)
console.log('incurredClaimDate', incurredClaimDate)
@ -1129,7 +1281,6 @@ function incurredClaimSum(input) {
$('#earned_claims_ratio_' + increment).val(earned_claims_ratio);
}
function earnedPremiumCalc(input) {
let increment = input.id.split('_').pop(); // Extract the increment part
@ -1150,7 +1301,6 @@ function earnedPremiumCalc(input) {
$('#earned_premium_' + increment).val(earned_premium.toFixed(2));
}
//---------------------------------------------------------------------------------------------------------
$("#leads_form_id").submit(function(event) {
@ -1187,6 +1337,11 @@ $("#leads_form_id").submit(function(event) {
// Append the JSON string to the FormData object
formData.append('salse_person_id', jsonString);
// Convert the claim experience array to JSON
const finyearJsonString = gatherClaimExperienceData();
console.log('finyearJsonString', finyearJsonString);
formData.append('finyear', finyearJsonString);
$.ajax({
data: formData,
url: form_action,
@ -1239,6 +1394,7 @@ $('#lead_type').change(function() {
$('#freshDiv').hide();
$('.freashDiv').show()
$('.renewalDiv').hide()
$('.gpa_div_elements').show();
$('#gst').val('');
$('#pan').val('');
@ -1280,6 +1436,8 @@ $('#lead_type').change(function() {
$('.emp_title').text('No of Employees')
$('.depnd_title').text('No of Dependents')
$('.total_title').text('Total Lives')
$('.gpa_div_elements').show();
}else{
$('.freashDiv').show()
$('.renewalDiv').hide()
@ -1287,6 +1445,7 @@ $('#lead_type').change(function() {
$('.emp_title').text('No of Employees at Inception')
$('.depnd_title').text(' No of Dependents at Inception')
$('.total_title').text('Total Lives at Inception')
$('.gpa_div_elements').show();
}
}
@ -1315,6 +1474,79 @@ function tpaChange(input, unique_id) {
function sumOfLives(input){
}
function gatherClaimExperienceData() {
// Initialize an empty array for the claim experience data
let claimExperience = [];
// Loop through the rows and extract data for each year
$('input[name="first_year[]"]').each(function(index) {
// Extract values for the first, second, and third year claims
const firstYear = $(this).val();
const firstClaimAmount = $(`input[name="first_claim_amount[]"]`).eq(index).val();
const firstClaimStatus = $(`input[name="first_claim_status[]"]`).eq(index).val();
const firstCauseOfDeath = $(`input[name="first_casue_of_death[]"]`).eq(index).val() || null;
const firstDeathDate = $(`input[name="first_death_date[]"]`).eq(index).val() || null;
const secondYear = $(`input[name="second_year[]"]`).eq(index).val();
const secondClaimAmount = $(`input[name="second_claim_amount[]"]`).eq(index).val();
const secondClaimStatus = $(`input[name="second_claim_status[]"]`).eq(index).val();
const secondCauseOfDeath = $(`input[name="second_casue_of_death[]"]`).eq(index).val() || null;
const secondDeathDate = $(`input[name="second_death_date[]"]`).eq(index).val() || null;
const thirdYear = $(`input[name="third_year[]"]`).eq(index).val();
const thirdClaimAmount = $(`input[name="third_claim_amount[]"]`).eq(index).val();
const thirdClaimStatus = $(`input[name="third_claim_status[]"]`).eq(index).val();
const thirdCauseOfDeath = $(`input[name="third_casue_of_death[]"]`).eq(index).val() || null;
const thirdDeathDate = $(`input[name="third_death_date[]"]`).eq(index).val() || null;
// Push each year's data into the array
claimExperience.push({
"finyear": [
{
"year": firstYear,
"claim_amount": firstClaimAmount,
"status": firstClaimStatus,
"cause_of_death": firstCauseOfDeath,
"death_date": firstDeathDate
},
{
"year": secondYear,
"claim_amount": secondClaimAmount,
"status": secondClaimStatus,
"cause_of_death": secondCauseOfDeath,
"death_date": secondDeathDate
},
{
"year": thirdYear,
"claim_amount": thirdClaimAmount,
"status": thirdClaimStatus,
"cause_of_death": thirdCauseOfDeath,
"death_date": thirdDeathDate
}
]
});
});
return JSON.stringify(claimExperience);
}
function showGpaColumns(input){
let policy_type_id = $(input).val()
let increment = input.id.split("_").pop();
if(policy_type_id != 2){
$('.gpa_hide_div_'+increment).hide();
$('.gpa_show_div_'+increment).show();
$('.gpa_div_elements_'+increment).show();
$('.emp_title').text('No of Employees at Inception')
$('.total_title').text('Total Sum Insured at Inception')
}else{
$('.gpa_hide_div_'+increment).show();
}
}
//-----------------------------------------------------------------------------------------------------------

View File

@ -518,7 +518,7 @@
<div class="form-group col-md-4 payby d-none">
<label class="switch" style="position: relative;top: 30px;left: 4px;">
<input id="bro_payable_by" type="checkbox" name="bro_payable_by">
<input id="bro_payable_by" type="checkbox" name="bro_payable_by" checked>
<span class="slider round" style="height: 27px;"></span>
</label>
@ -1279,10 +1279,10 @@ $(document).ready(function(){
$(document).on('change', 'input[type="checkbox"][name="co_share_type[]"]', function() {
let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1;
$('[name="base_premium[]"]').val("");
$('[name="co_premium[]"]').val("");
var unique_id = $(this).data('count')
console.log(unique_id);
let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1;
if (isAnyChecked) {
toastr.warning('Only one leader can be selected.', 'WARNING!');
@ -1290,6 +1290,10 @@ $(document).on('change', 'input[type="checkbox"][name="co_share_type[]"]', funct
}
});
function checkLeaderSelected(){
}
// $(document).on('input', '[name="cgst[]"]', function() {
// let val = $(this).val();
@ -1341,7 +1345,6 @@ $(document).on('change', 'input[type="checkbox"][name="co_share_type[]"]', funct
$(document).on('click', '[name="co_share_type[]"]', function() {
let val = $(this).val();
console.log(val);
let uniqueid = $(this).data('id');
let insurer = $('#follow_insurer_id_'+uniqueid).val()
@ -1352,7 +1355,6 @@ $(document).on('click', '[name="co_share_type[]"]', function() {
// console.log('client_id', client_id);
// console.log('insurer_id', insurer_id);
if(insurer == ""){
toastr.warning('Please select the insurer.', 'WARNING!');
$(this).prop('checked', false);
@ -1649,6 +1651,13 @@ function getPolicyTransactionDataForEdit(input) {
$('#table_tr_3').hide();
$('#table_tr_7').hide();
$('#table_tr_35').hide();
setTimeout(function(){
$('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
$(this).val(''); // Clear value
console.log('Input cleared:', $(this).attr('name'));
});
}, 4000);
}
// Handle "Same Insured Name"
@ -1806,9 +1815,9 @@ function amountCalculation(input) {
// console.log(standard_bp_per, standard_tp_per, standard_tep_per);
let co_premium_amt = ((bp + tp + tep) * co_share_per) / 100;
// let co_premium_amt = ((bp + tp + tep) * co_share_per) / 100;
$('#co_premium_' + input).val(!isNaN(co_premium_amt) && isFinite(co_premium_amt) ? co_premium_amt.toFixed(2) : '0.00');
// $('#co_premium_' + input).val(!isNaN(co_premium_amt) && isFinite(co_premium_amt) ? co_premium_amt.toFixed(2) : '0.00');
// Calculate GST percentage
@ -1820,17 +1829,35 @@ function amountCalculation(input) {
console.log(gst_per);
}
console.log('gst_per', gst_per);
console.log('igst', igst);
console.log('cgst', cgst);
console.log('sgst', sgst);
// Calculate the total premium (Base + TP + Co-Premium)
let tpTotal = bp + tp + tep + cop;
let tpTotal = cop;
if($('#bro_payable_by').is(':checked')){
tpTotal = bp + tp + tep;
}
console.log('bp', bp);
console.log('tp', tp);
console.log('tep', tep);
console.log('cop', cop);
console.log('tpTotal', tpTotal);
let gst_per_amt = (tpTotal * gst_per) / 100;
console.log('gst_per_amt', gst_per_amt);
// $('#gst_amount_' + input).val(gst_per_amt.toFixed(2));
$('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00');
let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt;
// console.log('Summed Amount:', finalTotal);
console.log('Summed Amount:', finalTotal);
// $('#total_amt_' + input).val(finalTotal.toFixed(2));
$('#total_amt_' + input).val(!isNaN(finalTotal) && isFinite(finalTotal) ? finalTotal.toFixed(2) : '0.00');
@ -2378,7 +2405,28 @@ function co_share_percentage_calculation(input, extra = null){
// console.log('Final input values:', inputValues);
// }
$(document).on('change', '[name="base_premium[]"], [name="co_share_per[]"]', function() {
console.log('Triggered change event.');
// Get the first non-empty base premium value
let basePremium = $('input[name="base_premium[]"]').toArray()
.map(input => parseFloat($(input).val()) || 0)
.find(value => value > 0) || 0;
console.log('Base Premium:', basePremium);
// Loop through all co_share_per[] fields
$('input[name="co_share_per[]"]').each(function(index) {
const coSharePer = parseFloat($(this).val()) || 0; // Get co_share_per value
const coPremium = (basePremium * coSharePer) / 100; // Calculate co_premium
console.log(`Index: ${index}, Co-Share Percentage: ${coSharePer}, Co-Premium: ${coPremium}`);
// Update corresponding co_premium field
$('input[name="co_premium[]"]').eq(index).val(coPremium.toFixed(2));
});
});
function select_leader_disable_premium_amt(input, value) {
@ -2398,6 +2446,7 @@ function select_leader_disable_premium_amt(input, value) {
$('input[name="co_premium[]"]').addClass('readonly-select');
$('#co_premium_' + value).removeClass('readonly-select');
} else {
// Enable and remove readonly-select class from all premiums except the one with the given value
$('input[name="base_premium[]"]').removeClass('readonly-select');
@ -2614,10 +2663,6 @@ function getCDAccountNumber(input)
console.log('follow_insurer_id insurer_id', insurer_id);
console.log('follow_insurer_id unique_id', unique_id);
// console.log('client_id', client_id);
// console.log('insurer_id', insurer_id);
if(client_id && insurer_id){
if(client_type == 1){
$.ajax({
@ -2657,8 +2702,15 @@ function getCDAccountNumber(input)
console.error(status, error);
}
});
}else{
console.error('Client type Not found')
console.log('client_type', client_type);
}
}
}else{
console.error('Client ID or Insurer ID Not found')
console.log('client_id', client_id);
console.log('insurer_id', insurer_id);
}
}
function appendCDAccountNumber(data, unique_id, new_cd_ac_no = null)
@ -3274,14 +3326,25 @@ $('#cop_yes').change(function() {
$('#table_tr_3').show()
$('#table_tr_7').show()
$('#table_tr_35').show()
$('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
$(this).val(''); // Clear value
console.log('Input cleared:', $(this).attr('name')); // Log cleared input
});
} else {
$('#add_more_row').addClass('d-none');
$('.payby').addClass('d-none');
$('#bro_payable_by').prop('checked', false);
// $('#bro_payable_by').prop('checked', false);
$('#table_tr_2').hide()
$('#table_tr_3').hide()
$('#table_tr_7').hide()
$('#table_tr_35').hide()
$('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
$(this).val(''); // Clear value
console.log('Input cleared:', $(this).attr('name')); // Log cleared input
});
}
});
@ -3621,6 +3684,10 @@ function addInsurerColumn() {
if(team_id.includes('4')){
console.log(
'################ TEAM ID 4 insurerTable '+ index + '########################'
)
switch(index) {
case 0: // Insurer selection
newCell = `<td>
@ -3749,6 +3816,10 @@ function addInsurerColumn() {
}else if(team_id.includes('3')){
console.log(
'################ TEAM ID 3 ########################'
)
switch(index) {
case 0: // Insurer selection
newCell = `<td>
@ -3841,6 +3912,10 @@ function addInsurerColumn() {
}else if(team_id.includes('6')){
console.log(
'################ TEAM ID 6 ########################'
)
switch(index) {
case 0: // Insurer selection
newCell = `<td>
@ -3971,7 +4046,9 @@ function addInsurerColumn() {
}
}
console.log('#################################################################');
console.log(newCell);
console.log('#################################################################');
$(this).append(newCell);
$('#follow_insurer_id_' + insurerCount).select2()
@ -4065,6 +4142,10 @@ function populateTable(dataArray) {
if(team_id.includes('4')){
console.log(
'################ TEAM ID 4 ########################'
)
switch (rowIndex) {
case 0: // Insurer selection
cell.find('select').val(insurer).change().toggleClass('readonly-select', !!disable_td);
@ -4172,6 +4253,10 @@ function populateTable(dataArray) {
}else if(team_id.includes('3')){
console.log(
'################ TEAM ID 3 ########################'
)
switch (rowIndex) {
case 0: // Insurer selection
cell.find('select').val(insurer).change().toggleClass('readonly-select', !!disable_td);
@ -4236,7 +4321,6 @@ function populateTable(dataArray) {
case 20: // Standard Ter %
cell.find('input').val(data.standerd_tep_per).toggleClass('readonly-select', !!disable_td);
break;
case 21: // Co-share ID (hidden field)
cell.find('input[type="hidden"]').val(data.id);
break;
@ -4244,6 +4328,10 @@ function populateTable(dataArray) {
}else if(team_id.includes('6')){
console.log(
'################ TEAM ID 6 ########################'
)
switch (rowIndex) {
case 0: // Insurer selection
cell.find('select').val(insurer).change().toggleClass('readonly-select', !!disable_td);

View File

@ -99,7 +99,8 @@ table.dataTable tbody td {
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'];?>&nbsp;%</td>
<td class="right-align-input" onclick="showCoShareStatementDetails(this)" data-id="<?= $row['pt_id'] ?>"><?php echo empty($row['total_irda_amt']) ? $row['exp_amt'] : $row['total_irda_amt']; ?></td>
<td class="right-align-input"><?php echo empty($row['billed_amt']) ? '0.00' : $row['billed_amt'] ?></td>
<td class="right-align-input"><?php echo empty($row['unbilled_amt']) ? '0.00' : $row['unbilled_amt']?></td>
<!-- <td class="right-align-input"><?php echo empty($row['unbilled_amt']) ? '0.00' : $row['unbilled_amt']?></td> -->
<td class="right-align-input"><?php echo number_format((float)$row['total_irda_amt'] - $row['billed_amt'],2, '.', '')?></td>
<td class="right-align-input"><?php echo $row['reward']; ?></td>
</tr>
<?php } ?>

File diff suppressed because it is too large Load Diff

Binary file not shown.