FIX_RACK_RATE_ISSUE_AND_OTHER_CHANGES : RV

This commit is contained in:
VENKATESHWARAN 2024-08-09 12:28:59 +05:30
parent a71f4c91ce
commit 7f5e92b50b
13 changed files with 1464 additions and 375 deletions

View File

@ -271,6 +271,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get("get_policy_type_for_base_policy/(:any)", "ClientController::getPolicyTypeForBasePolicy/$1");
$routes->get("get_client_details/(:any)", "ClientController::getClientDetails/$1");
$routes->get("featch_dashboard_data/(:any)", "DashboardController::featch_dashboard_data/$1");
$routes->get("remove_rack_rate/(:any)", "ClientController::removeRackRate/$1");
$routes->get("rename_rack_rate_tab/(:any)", "ClientController::renameRackRateTab/$1");
});
$routes->cli('cli/processjob', 'JobWorker::processJob');

View File

@ -252,15 +252,25 @@ class ClientController extends AdminController
public function removeClientBranch($id = null)
{
$this->myLogger->logme('error','Client Branch Remove function called');
// $id = $this->request->getPost('PrimaryKey');
// $data = $this->request->getPost();
$data['updated_by'] = get_session_userid();
$data['is_active'] = 0;
$update = $this->clientBranchModel->update($id,$data);
if($update){
return $this->respond(['status' => true,'code' => 200], 200);
$data = [
'updated_by' => get_session_userid(),
'is_active' => 0
];
$config_count = $this->clientPolicyModel->where('client_branch_id', $id)->countAllResults();
if($config_count > 0){
$update = $this->clientBranchModel->where('id', $id)->set($data)->update();
if($update){
return $this->respond(['status' => true,'code' => 200, 'message' => 'Client branch removed successfully'], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'Failed to remove client branch'], 200);
}
}else{
return $this->respond(['status' => false,'code' => 404], 200);
return $this->respond(['status' => false,'code' => 404, 'message' => 'The client branch configuration with policy cannot be deleted.'], 200);
}
}
@ -559,6 +569,8 @@ class ClientController extends AdminController
}
}
public function createClientRelation()
{
@ -647,6 +659,7 @@ class ClientController extends AdminController
}
}
public function createClientBranch()
{
@ -658,7 +671,7 @@ class ClientController extends AdminController
$data['sez'] = 1;
}
$data['created_by'] = get_session_userid();
$insert = $this->clientBranchModel->insert($data);
$insert = $this->clientBranchModel->insert($data);
if($insert){
for ($i = 0; $i < count($this->request->getPost('name')); $i++) {
@ -679,9 +692,18 @@ class ClientController extends AdminController
if($insert){
$branchData = $this->clientBranchModel->where('client_id', $this->request->getPost('client_id'))->findAll();
$branchData['role'] = get_role_id();
return $this->respond(['status' => true,'code' => 200,'data' => $branchData], 200);
return $this->respond([
'status' => true,
'code' => 200,
'data' => $branchData,
'message' => 'Client branch created successfully',
], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'Failed to create client branch ',
], 200);
}
}
@ -692,11 +714,57 @@ class ClientController extends AdminController
$id = $this->request->getPost('branch_id_primarykey');
$client_id = $this->request->getPost('client_id');
$data = $this->request->getPost();
$units = $this->request->getPost('units');
$emp_unit_count = 0;
$rr_unit_count = 0;
$rr_unit_count2 = 0;
$total_count = 0;
$list_of_branch_units = $this->clientBranchModel->find($id);
$units = json_decode($list_of_branch_units['units']);
if (!empty($units)) {
foreach ($units as $unit) {
$emp_unit_count += $this->employeeModel->where('unit', $unit)->countAllResults();
$rr_unit_count += $this->policyPremium2Model->where('unit', $unit)->countAllResults();
$rr_unit_count2 += $this->policyPremium1Model->where('unit', $unit)->countAllResults();
}
$total_count = $emp_unit_count + $rr_unit_count + $rr_unit_count2;
}
$uncommonValues = [];
if ($total_count > 0) {
$units = (string) $this->request->getPost('units'); // Assuming 'units' is an array
$list_of_branch_units = $this->clientBranchModel->find($id);
$branch_units = json_decode($list_of_branch_units['units'], true);
$units = json_decode($units);
$uncommonValues = array_diff($branch_units, $units);
if (count($uncommonValues) > 0) {
$branchData = $this->clientBranchModel->where('client_id', $client_id)->findAll();
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'Cannot delete config units',
'uncommonValues' => $uncommonValues,
'data' => $branchData,
], 200);
}
}
if (!isset($data['sez'])) {
$data['sez'] = 0;
} elseif ($data['sez']) {
$data['sez'] = 1;
}
$data['updated_by'] = get_session_userid();
$insert = $this->clientBranchModel->update($id, $data);
$this->myLogger->logme('error','Client branch EDITED by {data}', ['data' => get_session_userid()]);
@ -721,12 +789,25 @@ class ClientController extends AdminController
if($insert){
$branchData = $this->clientBranchModel->where('client_id', $client_id)->findAll();
return $this->respond(['status' => true,'code' => 200,'data' => $branchData], 200);
return $this->respond([
'status' => true,
'code' => 200,
'data' => $branchData,
'emp_unit_count' => $emp_unit_count,
'rr_unit_count' => $rr_unit_count,
'list_of_branch_units' => $list_of_branch_units,
'total_count' => $total_count,
'uncommonValues' => $uncommonValues,
'message' => 'Client branch updated successfully'
], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
return $this->respond(['status' => false,'code' => 404, 'message' => 'Failed to update client branch'], 200);
}
}
public function createClientPolicy()
{
@ -1019,19 +1100,29 @@ class ClientController extends AdminController
$client_policy_data = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$client_id = $client_policy_data['client_id'];
}
$branch_units = $this->getBranchUnitsByBranchId($record['client_branch_id']);
$branch_units = json_decode($branch_units);
$policy_grid_id = $this->request->getPost('policy_grid_id');
$rack_rate_name = $this->request->getPost('rack_rate_name');
$relation_data = [
'self' => $this->request->getPost('self'),
'spouse' => $this->request->getPost('spouse'),
'childrens' => $this->request->getPost('childrens'),
'parents' => $this->request->getPost('parents'),
'parents-in-law'=> $this->request->getPost('parents-in-law'),
'self' => $this->request->getPost('self') ?? 'NA',
'spouse' => $this->request->getPost('spouse') ?? 'NA',
'childrens' => $this->request->getPost('childrens') ?? 'NA',
'parents' => $this->request->getPost('parents') ?? 'NA',
'parents-in-law'=> $this->request->getPost('parents-in-law') ?? 'NA',
];
$relation_data_for_form_submit_check = [
$rack_rate_name => [
'self' => $this->request->getPost('self') ?? 'NA',
'spouse' => $this->request->getPost('spouse') ?? 'NA',
'childrens' => $this->request->getPost('childrens') ?? 'NA',
'parents' => $this->request->getPost('parents') ?? 'NA',
'parents-in-law'=> $this->request->getPost('parents-in-law') ?? 'NA',
]
];
if ($policy_grid_id == 1 || $policy_grid_id == 2 ) {
@ -1046,7 +1137,7 @@ class ClientController extends AdminController
// Convert to JSON
$jsonDataForRelation = json_encode($relation_data);
$json_data_relation_data_for_form_submit_check = json_encode($relation_data_for_form_submit_check);
$si_or_bp = $this->request->getPost('si_or_bp');
$basic_multiplier = str_replace(',', '', $this->request->getPost('basic_multiplier'));
@ -1077,7 +1168,7 @@ class ClientController extends AdminController
$premium = str_replace(',', '', $this->request->getPost('gpa_sum_premium[]'));
$sum_insure = str_replace(',', '', $this->request->getPost('gpa_sum_si[]'));
$multiplier = $this->request->getPost('gpa_sum_multiplier');
$unit = $this->request->getPost('gpa_unit[]');
$unit = $this->request->getPost('gpa_unit_1[]');
for ($i = 0; $i < count($premium); $i++) {
$data['si'] = $sum_insure[$i];
@ -1099,7 +1190,7 @@ class ClientController extends AdminController
$sum_insure = str_replace(',', '', $this->request->getPost('gpa_sum_si2[]'));
$multiplier = $this->request->getPost('gpa_sum_multiplier2');
$grade = $this->request->getPost('gpa_band[]');
$unit = $this->request->getPost('gpa_unit[]');
$unit = $this->request->getPost('gpa_unit_3[]');
for ($i = 0; $i < count($premium); $i++) {
@ -1156,20 +1247,27 @@ class ClientController extends AdminController
$data = $this->request->getPost();
$insert = true;
} else if ($policy_grid_id == '2') {
$data['premium'] = str_replace(',', '', $this->request->getPost('gpa_premium'));
$data['si'] = str_replace(',', '', $this->request->getPost('gpa_si'));
$unit = $this->request->getPost('gpa_unit');
if (empty($unit)) {
$data['unit'] = $branch_units[0];
} else {
$data['unit'] = $unit;
}
$policyPremium = $this->policyPremium1Model->insert($data);
} else if ($policy_grid_id == '2') {
$premium = $this->request->getPost('gpa_premium29[]');
$sum_insure = $this->request->getPost('gpa_si29[]');
$unit = $this->request->getPost('gpa_unit29[]');
for ($i = 0; $i < count($premium); $i++) {
$data['premium'] = str_replace(',', '', $premium[$i]);
$data['si'] = str_replace(',', '', $sum_insure[$i]);
if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) {
$data['unit'] = $branch_units[0];
} else {
$data['unit'] = $unit[$i];
}
$dataa = $this->policyPremium1Model->insert($data);
}
$data = $this->request->getPost();
$insert = true;
} else if ($policy_grid_id == '3') {
$premium = $this->request->getPost('3_premium[]');
@ -1215,17 +1313,19 @@ class ClientController extends AdminController
} else if ($policy_grid_id == '5') {
$premium = $this->request->getPost('5_premium[]');
$sum_insure = $this->request->getPost('5_si[]');
$age_from = $this->request->getPost('5_age_from[]');
$age_to = $this->request->getPost('5_age_to[]');
$unit = $this->request->getPost('5_unit[]');
for ($i = 0; $i < count($premium); $i++) {
$data['premium'] = str_replace(',', '', $premium[$i]);
$data['si'] = str_replace(',', '', $sum_insure[$i]);
$data['age_from'] = $age_from[$i];
$data['age_to'] = $age_to[$i];
if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) {
if (empty($unit) || !isset($unit[$i]) || empty($unit[$i] || $unit[$i] == 'undefined')) {
$data['unit'] = $branch_units[0];
} else {
$data['unit'] = $unit[$i];
@ -1233,8 +1333,10 @@ class ClientController extends AdminController
$dataa = $this->policyPremium2Model->insert($data);
}
$data = $this->request->getPost();
$insert = true;
} else if ($policy_grid_id == '6') {
$premium = $this->request->getPost('6_premium[]');
@ -1304,27 +1406,24 @@ class ClientController extends AdminController
$insert = true;
} else if ($policy_grid_id == '9') {
$data['premium'] = str_replace(',', '', $this->request->getPost('gpa_premium'));
$data['si'] = str_replace(',', '', $this->request->getPost('gpa_si'));
$unit = $this->request->getPost('gpa_unit');
if (empty($unit)) {
$data['unit'] = $branch_units[0];
} else {
$data['unit'] = $unit;
$premium = $this->request->getPost('gpa_premium29[]');
$sum_insure = $this->request->getPost('gpa_si29[]');
$unit = $this->request->getPost('gpa_unit29[]');
for ($i = 0; $i < count($premium); $i++) {
$data['premium'] = str_replace(',', '', $premium[$i]);
$data['si'] = str_replace(',', '', $sum_insure[$i]);
if (empty($unit) || !isset($unit[$i]) || empty($unit[$i])) {
$data['unit'] = $branch_units[0];
} else {
$data['unit'] = $unit[$i];
}
$dataa = $this->policyPremium2Model->insert($data);
}
$policyPremium = $this->policyPremium2Model->insert($data);
// $premium = $this->request->getPost('9_premium[]');
// $sum_insure = $this->request->getPost('9_si[]');
// $grade = $this->request->getPost('9_grade[]');
// for ($i = 0; $i < count($premium); $i++) {
// $data['premium'] = str_replace(',', '', $premium[$i]);
// $data['si'] = str_replace(',', '', $sum_insure[$i]);
// // $data['grade'] = $grade[$i];
// $dataa = $this->policyPremium2Model->insert($data);
// }
$data = $this->request->getPost();
$insert = true;
} else if ($policy_grid_id == '10') {
$premium = $this->request->getPost('10_premium[]');
$sum_insure = $this->request->getPost('10_si[]');
@ -1354,7 +1453,7 @@ class ClientController extends AdminController
$sum_insure = $this->request->getPost('11_si[]');
$grade = $this->request->getPost('11_grade[]');
$max_sum_insure = $this->request->getPost('11_max_si[]');
$unit = $this->request->getPost('11_max_si[]');
$unit = $this->request->getPost('11_unit[]');
for ($i = 0; $i < count($premium); $i++) {
$data['premium'] = str_replace(',', '', $premium[$i]);
@ -1420,7 +1519,7 @@ class ClientController extends AdminController
}
if ($insert) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $data, 'rack_rate_json'=>$jsonDataForRelation,], 200);
return $this->respond(['status' => true, 'code' => 200, 'data' => $data, 'rack_rate_json'=>$json_data_relation_data_for_form_submit_check,], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'data' => $data, 'message' => 'no data found'], 200);
}
@ -1556,6 +1655,7 @@ class ClientController extends AdminController
}
$results = $this->policyGridModel->like('policy_type', $search_term)->findAll();
$jsonArray = [];
if ($search_term === 'GPA' || $policy_type_id == 6 || $policy_type_id == 7) {
@ -1563,6 +1663,19 @@ class ClientController extends AdminController
} else if ($search_term === 'GMC') {
$premiumData = $this->policyPremium2Model->where(['client_id' => $record['client_id'], 'client_policy_id' => $client_policy_id, 'is_active' => 1])->findAll();
$rackRateJson = $this->policyPremium2Model
->where('client_policy_id', $client_policy_id)
->where('is_active', 1)
->groupBy('rack_rate_name')
->orderBy('id')
->findAll();
foreach ($rackRateJson as $value) {
$jsonArray[$value['rack_rate_name']] = json_decode($value['additional_relationship']);
}
} else {
$premiumData = "";
@ -1649,7 +1762,8 @@ class ClientController extends AdminController
'self' => $self,
'client_policy_id' => $client_policy_id,
'terms_si_amount_array' => $terms_si_amount_array,
'branch_units' => $branch_units
'branch_units' => $branch_units,
'jsonArray' => $jsonArray,
], 200);
} else if ($search_term === 'GPA' || $policy_type_id == 6 || $policy_type_id == 7) {
@ -1664,7 +1778,8 @@ class ClientController extends AdminController
'self' => $self,
'client_policy_id' => $client_policy_id,
'terms_si_amount_array' => $terms_si_amount_array,
'branch_units' => $branch_units
'branch_units' => $branch_units,
'jsonArray' => $jsonArray,
], 200);
} else {
@ -1678,7 +1793,8 @@ class ClientController extends AdminController
'self' => $self,
'client_policy_id' => $client_policy_id,
'terms_si_amount_array' => $terms_si_amount_array,
'branch_units' => $branch_units
'branch_units' => $branch_units,
'jsonArray' => $jsonArray,
], 200);
}
}
@ -2043,7 +2159,7 @@ class ClientController extends AdminController
$message = 'Enrolment Closed Successfully';
}
$data = $this->policesModel->getPolicyPremium($record['policy_id']);
$data = $this->policesModel->getPolicyPremium($client_policy_id);
$pattern = '/gmc/i';
$subject = $data[0]->policy_type;
if (preg_match($pattern, $subject)) {
@ -2075,8 +2191,8 @@ class ClientController extends AdminController
}
// Check if 'family_floater' key exists and has a value
if (isset($termsData->family_floater) && $termsData->family_floater == null) {
return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Family Floater field is empty'], 200);
if (isset($termsData->family_floater) && $termsData->family_floater === null) {
return $this->respond(['status' => false, 'code' => 200, 'message' => 'The Policy terms Family Floater field is empty', 'termsData' => $termsData , 'family_floater' => $termsData->family_floater], 200);
}
// Check if 'family_floaters' key exists and has a value
@ -2665,9 +2781,8 @@ class ClientController extends AdminController
public function getClientDetails($client_id)
{
$result = $this->clientModel->where('id', $client_id)->first();
return $this->respond(['status' => true, 'data' => $result], 200);
$result = $this->clientModel->where('id', $client_id)->first();
return $this->respond(['status' => true, 'data' => $result], 200);
}
public function getBranchUnitsByBranchId($branch_id)
@ -2827,7 +2942,6 @@ class ClientController extends AdminController
}
public function removeRackRate($rack_rate_name = null, $client_policy_id = null)
{
$this->myLogger->logme('error', 'Rack Rate Remove function called');
@ -2852,7 +2966,7 @@ class ClientController extends AdminController
if ($update) {
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Rack Rate removed successfully', 'rr_count' => $rackRateData], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove policy', 'rr_count' => $rackRateData], 200);
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove Rack Rate', 'rr_count' => $rackRateData], 200);
}
}else{
@ -2861,4 +2975,38 @@ class ClientController extends AdminController
}
public function renameRackRateTab($rack_rate_name = null, $new_rack_rate_name = null, $client_policy_id = null)
{
$this->myLogger->logme('error', 'Rack Rate renameRackRateTab function called');
$data = [
'updated_by' => get_session_userid(),
'rack_rate_name' => $new_rack_rate_name
];
$rackRateData = $this->policyPremium2Model
->where('rack_rate_name', $rack_rate_name)
->where('client_policy_id', $client_policy_id)
->where('is_active',1)
->countAllResults();
if($rackRateData > 0){
$update = $this->policyPremium2Model
->where('rack_rate_name', $rack_rate_name)
->where('client_policy_id', $client_policy_id)
->set($data)->update();
$affectedRows = $this->policyPremium2Model->affectedRows();
if ($update) {
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Rack Rate renamed successfully', 'rr_count' => $affectedRows], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to rename Rack Rate', 'rr_count' => $affectedRows], 200);
}
}else{
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Rack Rate not available', 'rr_count' => $rackRateData, 'rack_rate_name' => $rack_rate_name, 'client_policy_id' => $client_policy_id, 'new_rack_rate_name' => $new_rack_rate_name, ], 200);
}
}
}

View File

@ -103,6 +103,8 @@ class EmployeeController extends AdminController
$data['getData'] = $filterData;
}
// dd( $data['getData']);
// dd($this->request->getGet());
$this->myLogger->logme('error', 'list called');
$this->loadLayout('employee_list', $data);

View File

@ -118,6 +118,9 @@ class UserController extends AdminController
}else{
$id = $this->request->getPost('PrimaryKey');
$userData = $this->request->getPost();
unset($userData['csrf_test_name']);
unset($userData['PrimaryKey']);
// unset($userData['first_name']);
// Update data in the 'users' table based on the $id
$userData['updated_by'] = get_session_userid();
@ -147,7 +150,7 @@ class UserController extends AdminController
$db->table($tableName)->where('emp_code', $userData['emp_code'])
->where('email', $userData['email'])
->set($userData)
->set($hdz_staff)
->update();
}
}

View File

@ -105,6 +105,8 @@ class EmployeePolicyModel extends Model
'emp.basic_pay',
'emp.band as grade',
'policy_type.policy_type',
'client_branch.branch_name as client_branch_name',
'client_branch.branch_code as client_branch_code',
'cp.policy_no',
])
->join('employees emp', 'employee_polices.employee_id = emp.id')
@ -116,6 +118,7 @@ class EmployeePolicyModel extends Model
->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id', 'left') //tpab - tpa branch
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->join('client_branch', 'emp.client_branch_id = client_branch.id') //cm - client master
->orderBy('emp.emp_code', 'ASC')
->orderBy('employee_polices.employee_id', 'ASC');

View File

@ -23,11 +23,10 @@ class PolicesModel extends Model
public function getPolicyPremium($policy_id){
return $this->db->table('policies')
return $this->db->table('client_policy')
->select('policy_type.*')
->select('policies.name as policy_name')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->where('policies.id', $policy_id)
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.id', $policy_id)
->get()
->getResult();
}

View File

@ -259,9 +259,16 @@ $(document).ready(function () {
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
console.error("Error Details:");
console.error("Status Code:", xhr.status);
console.error("Status Text:", xhr.statusText);
console.error("Response Text:", xhr.responseText);
console.error("Ready State:", xhr.readyState);
console.error("Response Headers:", xhr.getAllResponseHeaders());
console.error("Error Thrown:", error);
console.error("Status:", status);
}
});
});

View File

@ -371,6 +371,8 @@ $("#branch_form").submit(function(event) {
contentType: false,
success: function(res) {
console.log('client branch submit response', res)
if (res) {
setTimeout(function() {
@ -380,11 +382,17 @@ $("#branch_form").submit(function(event) {
$('#branch_table').show();
$('.btnBack').hide();
$('#btnBranchAdd').show();
var message = (branch_PrimaryKey === '') ?
'Client Branch Created successfully' :
'Client Branch Updated successfully';
toastr.success(message, 'Success');
}, 1000);
if(res.status == false){
toastr.error(res.message, 'Error');
}else{
toastr.success(res.message, 'Success');
}
// var message = (branch_PrimaryKey === '') ?
// 'Client Branch Created successfully' :
// 'Client Branch Updated successfully';
// toastr.success(message, 'Success');
}, 800);
}
$('#branch_list tr').remove();
@ -395,7 +403,7 @@ $("#branch_form").submit(function(event) {
console.log(role)
$.each(res.data, function(index, item) {
console.log('client_branch_data', item)
// console.log('client_branch_data', item)
if(role != 3 && role != 4){
@ -433,8 +441,8 @@ $("#branch_form").submit(function(event) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Wrong!', 'warning');
}, 1000);
console.log('Something Wrong!', 'warning');
}, 300);
}
});
}
@ -696,10 +704,10 @@ function removeClientBranch(element) {
// console.log(res.status == true);
if (res) {
if (res.status == true) {
toastr.success('Client branch removed successfully', 'success');
toastr.success(res.message, 'success');
location.reload();
} else {
toastr.warning('Failed to remove client branch', 'warning');
toastr.warning(res.message, 'warning');
}
}
},

View File

@ -675,72 +675,17 @@
$(document).ready(function() {
/********* set the Policy_Type_id for Form Submit *******/
$('#policy').change(function() {
$('#policy_type').change(function() {
var id = $(this).val();
var dataId = $(this).children('option:selected').attr('data-id');
var branch_id = $('#client_branch').val();
var client_id = $('#client_id_policy').val();
var policy_type_id = $(this).val();
console.log('client_id', client_id)
console.log('branch_id', branch_id)
console.log('policy_type_id', dataId)
console.log('client_policy_id', $('#policy_PrimaryKey').val())
$('#policy_type_id').val(dataId);
var url = '<?php echo base_url('util/check_policy_type/') ?>' + dataId + '/' + branch_id + '/' + client_id;
if (dataId == 1) {
if (policy_type_id == 1 || policy_type_id == 6 || policy_type_id == 7) {
$('#tpa').prop('required', false);
$('#tpa_danger').hide()
} else {
$('#tpa').prop('required', true);
$('#tpa_danger').show()
}
var base_policy_dataId = $('#base_policy').children('option:selected').attr('data-id');
if ($('#policy_type').val() == 1) {
// //console.log('step 1')
if (dataId == 3) {
// //console.log('step 2')
var displayStatus = $('#base_policy_id').css('display');
$('#base_policy_id').show();
$('#base_danger').hide();
// $('#base_policy').prop('required', true);
if (displayStatus === 'none') {
// //console.log('step 2.1')
$('#base_policy').val('').change();
}
// $('#base_policy').find('option[data-id="3"]').hide();
} else {
// //console.log('step 3')
var displayStatus = $('#base_policy_id').css('display');
$('#base_policy_id').hide();
$('#base_danger').show();
// $('#base_policy').prop('required', false);
if (displayStatus === 'none') {
// //console.log('step 3.1')
$('#base_policy').val('').change();
}
}
}
});
});
@ -804,6 +749,7 @@
$('#close_date').val(rearrangeDateFormat(res.data.close_date));
$('#reminder_date').val(rearrangeDateFormat(res.data.reminder_date));
$('#gst_no').val(gst);
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
$('#policy_status_field').show();
@ -920,6 +866,15 @@
}
if (res.data.policy_type_id == '1' || res.data.policy_type_id == '6' || res.data.policy_type_id == '7') {
$('#tpa').prop('required', false);
$('#tpa_danger').hide()
} else {
$('#tpa').prop('required', true);
$('#tpa_danger').show()
}
setTimeout(function(){
appendCDACNO(res.cd_data, res.data.cd_ac_no) // append and select the current CD Account Number
appendBasePolicyList(res.client_policy_list, res.data.base_policy, res.data.client_branch_id); // append and select the Base palicy
@ -971,6 +926,8 @@
},
success: function(res) {
console.log('OpenEnrollment response', res);
if (res) {
if (res.open_for_enrollment) {
var json_decode = JSON.parse(res.open_for_enrollment);
@ -1171,13 +1128,23 @@
function convertCommaNumberToWords(input) {
let number;
if (input instanceof HTMLElement) {
console.log( 'input type step 1', typeof input);
if (input instanceof HTMLElement && input.value) {
// Ensure input.value is defined and not null
const inputValue = input.value;
number = parseFloat(inputValue.replace(/,/g, ''), 10);
} else {
} else if (input) {
console.log( 'input type step 2', typeof input);
// Handle the case where input is a string
number = parseFloat(input.replace(/,/g, ''), 10);
} else {
// Handle the case where input is undefined or null
number = NaN; // or handle as needed
}
const [integerPart, decimalPart] = number.toFixed(2).split('.');
const integerWord = convertNumberToWords(parseInt(integerPart, 10));
let result = `${integerWord}`;
@ -1224,7 +1191,12 @@
maximumFractionDigits: 2
});
//console.log('formetted value', value);
console.log('formatNumber function formetted value', value);
console.log('formatNumber function formetted value type',typeof value);
if(value == 'NaN' || value == 'null' || value == 'undefined'){
value = '';
}
input.value = (value);
@ -1232,6 +1204,7 @@
if (input.id == 'gpa_si') {
gpaSumInsureMultiplier();
}
convertCommaNumberToWords(input);
if (input.id == 'gpa_sum_si') {

View File

@ -50,7 +50,20 @@
<thead class="bg-light">
<tr>
<th class="font-weight-medium">SNO</th>
<!-- <th class="font-weight-medium">Employee code</th> -->
<?php if(isset($getData)) { ?>
<?php if($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
<th class="font-weight-medium">Client/Branch</th>
<?php } ?>
<?php } ?>
<?php if(isset($getData)) { ?>
<?php if($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
<th class="font-weight-medium">Branch</th>
<?php } ?>
<?php } ?>
<th class="font-weight-medium">Employee code</th>
<th class="font-weight-medium">Name/code</th>
<th class="font-weight-medium">Policy name</th>
<th class="font-weight-medium">Insurer <br> name</th>
@ -75,6 +88,19 @@
<tr>
<td><b><?php echo ($key + 1)?></b></td>
<?php if(isset($getData)) { ?>
<?php if($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
<td><?php echo $employee['client_short_name']?> - <?php echo $employee['client_branch_name']?> </td>
<?php } ?>
<?php } ?>
<?php if(isset($getData)) { ?>
<?php if($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
<td><?php echo $employee['client_branch_name']?></td>
<?php } ?>
<?php } ?>
<td><?php echo $employee['name']?>( <?php echo $employee['emp_code']?> - <?php echo $employee['relationship']?> )</td>
<!-- <td><?php echo isset($employee['policy_name']) ? $employee['policy_name'] : '' ?> - <?php echo isset($employee['policy_no']) ? $employee['policy_no'] : '' ?> - <?php echo isset($employee['policy_type']) ? $employee['policy_type'] : '' ?></td> -->
<td><?php echo isset($employee['policy_type']) ? $employee['policy_type'] : '' ?> - <?php echo isset($employee['policy_no']) ? $employee['policy_no'] : '' ?></td>

View File

@ -509,7 +509,6 @@
$('#gpa_client_policy_id').val(client_policy_id);
var gpa_policy_type_id = $(this).attr('id');
// console.log('gpa_policy_type_id', gpa_policy_type_id)
@ -589,8 +588,9 @@
});
let jsonObject = JSON.parse(res.data);
$("#numberToWordSumInsured").text(convertCommaNumberToWords(jsonObject.sumInsured2));
$("#numberToWordTotalSumInsured").text(convertCommaNumberToWords(jsonObject.totalSumInsured));
$("#numberToWordSumInsured").text(convertCommaNumberToWords(jsonObject.sumInsured2) ?? '' );
$("#numberToWordTotalSumInsured").text(convertCommaNumberToWords(jsonObject.totalSumInsured) ?? '');
if (jsonObject.compassionateVisitExpenses == '1') {
var element = $('input[name="compassionateVisitExpenses"]').parent().parent().next()[0];
$(element).css("display", "");
@ -615,6 +615,10 @@
Object.keys(jsonObject).forEach(function(key) {
console.log('jsonObject key', key)
console.log('jsonObject value', jsonObject[key])
console.log('jsonObject value type',typeof jsonObject[key])
let elements = document.getElementsByName(key);
if (elements && elements.length > 0) {
let element = elements[0];
@ -625,15 +629,14 @@
element.checked = jsonObject[key] === '1';
} else if (element.type === 'radio') {
element.checked = element.value === jsonObject[key];
}
} else {
if(jsonObject[key] == undefined){
if(jsonObject[key] == undefined || jsonObject[key] == ''){
element.value = " ";
}else{
element.value = jsonObject[key];
element.value = jsonObject[key] ?? '';
}
}
}
@ -788,9 +791,11 @@
});
function appendGPASIAddMore(data = null){
function appendGPASIAddMore(data = null)
{
console.log('function called')
console.log('appendGPASIAddMore function called')
console.log('appendGPASIAddMore function data', data)
var html = `
<div class="row" style="margin-bottom: 10px;">

File diff suppressed because it is too large Load Diff

View File

@ -140,6 +140,10 @@ function copyHeaders(unique_id) {
var client_units = localStorage.getItem('client_units');
client_units = JSON.parse(client_units);
console.log('copyHeaders function client_units', client_units);
console.log('copyHeaders function client_units.length', client_units.length)
let formatType = $('#grid').val();
var secondKey = $('#si_or_bp').val();
var obj = $('#grid');
@ -183,14 +187,21 @@ function copyHeaders(unique_id) {
}
var headerString = Object.values(excel_headers[formatType]).join("\t"); // Using specified format type for copying headers
console.log('copyHeaders function default headerString', headerString)
if (formatType == 1) {
if(client_units.length = 1){
console.log('copyHeaders function formatType 1', formatType)
if(client_units.length == 1){
console.log('copyHeaders function client_units.length', client_units.length)
delete excel_headers[formatType][secondKey].unit;
}
var headerString = Object.values(excel_headers[formatType][secondKey]).join("\t"); // Using specified format type for copying headers
}
console.log('headerString', headerString);
console.log('copyHeaders function converted headerString', headerString);
//console.log('headerString', headerString);
@ -209,7 +220,7 @@ function generateTable(unique_id) {
var data = $('#copied_excel_data').val();
let formatType = $('#grid').val();
var obj = $('#grid');
var secondKey = $('#si_or_bp').val();
var secondKey = $('#si_or_bp').val() ?? '';
if (unique_id != 'na') {
data = $('#copied_excel_data_'+unique_id).val();
@ -217,10 +228,12 @@ function generateTable(unique_id) {
obj = $('#grid_'+unique_id);
}
// console.log('generateTable obj', obj);
// console.log('generateTable formatType', formatType);
// console.log('generateTable data', data);
// console.log('generateTable secondKey', secondKey);
console.log('generateTable obj', obj);
console.log('generateTable formatType', formatType);
console.log('generateTable data');
console.log(data)
console.log('generateTable secondKey', secondKey);
console.log('generateTable client_units', client_units);
if (!formatType || formatType == "") {
$('.excel_table_class').empty();
@ -251,7 +264,6 @@ function generateTable(unique_id) {
var header = rows[0].split("\t");
console
// Determine the columns to keep (non-empty columns)
var columnsToKeep = [];
@ -276,14 +288,20 @@ function generateTable(unique_id) {
if (formatType == 1) {
//console.log('si_or_bp secondKey', secondKey)
console.log('si_or_bp secondKey', secondKey)
expectedHeader = Object.keys(excel_headers[formatType][secondKey]);
}
// console.log('expectedHeader', expectedHeader);
// console.log('HEADERS' , JSON.stringify(header))
// console.log('Excepted HEADERS' , JSON.stringify(expectedHeader))
// remove unit key from the array, if the client unit is one
if (client_units.length === 1) {
expectedHeader = expectedHeader.filter(key => key !== 'unit');
}
console.log('expectedHeader', expectedHeader);
console.log('HEADERS' , JSON.stringify(header));
console.log('Excepted HEADERS' , JSON.stringify(expectedHeader));
console.log('secondKey' , secondKey);
if (secondKey != 2 && secondKey != undefined) {
@ -291,9 +309,19 @@ function generateTable(unique_id) {
console.log(expectedHeader);
console.log(excel_headers[formatType]);
if (JSON.stringify(header) !== JSON.stringify(expectedHeader)) {
const expectedHeaders = JSON.stringify(Object.values(excel_headers[formatType][secondKey]));
var expectedHeaders;
if (formatType == 1 ) {
expectedHeaders = JSON.stringify(Object.values(excel_headers[formatType][secondKey]));
} else {
expectedHeaders = JSON.stringify(Object.values(excel_headers[formatType]));
}
const receivedHeaders = JSON.stringify(columnsToKeep.map(i => rows[0].split("\t")[i]));
console.log('receivedHeaders', receivedHeaders);
Swal.fire({
title: "Header Mismatch",
html: `
@ -459,7 +487,7 @@ function generateTable(unique_id) {
}
if(secondKey != 2){
if(secondKey != 2 && secondKey != undefined){
console.log(secondKey)
if ($('.duplicate').length > 0) {
//console.log('test');
@ -475,12 +503,15 @@ function generateTable(unique_id) {
$('.excel_table_class').empty();
$('.excel_textarea').val('');
}
submitData(unique_id);
submitData(unique_id, client_units);
$('.excel_textarea').val('');
}
function submitData(unique_id)
function submitData(unique_id, client_units)
{
console.log('submitData function unique id', unique_id);
console.log('submitData function client_units', client_units);
console.log('submitData function client_units first index', client_units[0]);
let formatType = $('#grid').val();
var table = $('#excel_table table');
@ -494,7 +525,6 @@ function submitData(unique_id)
var gpa_sum_multiplier = $('#gpa_sum_multiplier').val();
if (unique_id != 'na') {
formatType = $('#grid_'+unique_id).val();
table = $('#excel_table_'+unique_id+' table');
@ -552,12 +582,24 @@ function submitData(unique_id)
delete obj.band_or_grade;
}
if (client_units.length == 1) {
if (!('unit' in obj)) {
obj.unit = client_units[0];
}
}
if (formatType == 1) {
if (si_or_bp == 1) {
obj.si_or_bp = si_or_bp;
obj.multiplier = gpa_sum_multiplier ? gpa_sum_multiplier : 0;
if( obj.multiplier == 0){
obj.premium = 0;
}else{
obj.premium = obj.si * obj.multiplier / 1000
}
} else if (si_or_bp == 2) {
@ -571,6 +613,11 @@ function submitData(unique_id)
obj.si_or_bp = si_or_bp;
obj.multiplier = gpa_sum_multiplier2 ? gpa_sum_multiplier2 : 0;
if( obj.multiplier == 0){
obj.premium = 0;
}else{
obj.premium = obj.si * obj.multiplier / 1000
}
}
}
});
@ -580,7 +627,7 @@ function submitData(unique_id)
if (unique_id != 'na') {
$('#grid_content_input_'+unique_id).empty()
$('#grid_content_input_for_additional_'+unique_id).empty()
if ($('#copyfromexcel_'+unique_id).text() == "Manual entry") {
$('#copyfromexcel_'+unique_id).text("Copy from excel")
@ -588,7 +635,7 @@ function submitData(unique_id)
$('#copyfromexcel_'+unique_id).text("Copy from excel");
}
$('#grid_content_input_'+unique_id).toggle();
$('#grid_content_input_for_additional_'+unique_id).toggle();
$('#grid_content_from_excel_'+unique_id).toggle();
} else {
@ -610,14 +657,14 @@ function submitData(unique_id)
unique_id = null;
}
if (formatType == 1 || formatType == 2 || formatType == 4 || formatType == 6) {
if (formatType == 1 || formatType == 2 || formatType == 4 || formatType == 6 || formatType == 9) {
var FirstIndex = jsonData[0]
addGridHTML(false, FirstIndex, formatType, si_or_bp, unique_id)
addGridHTML(false, FirstIndex, formatType, si_or_bp, unique_id);
jsonData.shift();
}
$.each(jsonData, function(index, item) {
appendGridtHtml(formatType, unique_id, item)
appendGridtHtml(formatType, unique_id, item);
});
$('input[name="11_max_si[]"]').each(function() {
@ -654,6 +701,42 @@ function submitData(unique_id)
$(this).trigger('change').keyup();
});
$(`input[name="gpa_sum_si2[]"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
$(`input[name="gpa_sum_si[]"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
$(`input[name="gpa_premium"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
$(`input[name="gpa_si"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
$(`input[name="gpa_premium29[]"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
$(`input[name="gpa_si29[]"]`).each(function() {
// //console.log($(this));
$(this).trigger('keyup');
$(this).trigger('change').keyup();
});
}