diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 3ca47517..76ec5cca 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -49,7 +49,7 @@ $routes->group("/user", ["filter" => "authMVC"], function ($routes) { $routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) { - $routes->match(['get','post'],'view','DashboardController::dashboard'); + $routes->get("view", "DashboardController::dashboard"); $routes->get('get-notification', 'DashboardController::getDashboardNotifications'); $routes->get('acknowledge-notification/(:segment)', 'DashboardController::acknowledgeMessage/$1'); $routes->get('get-pending-action', 'PendingActionsController::getPendingActions'); @@ -146,7 +146,6 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) { $routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1"); $routes->get("test-rack-rate", "EmployeeController::testRackRate"); $routes->post("test-rack-rate", "EmployeeController::testRackRate"); - $routes->post("test-dependent", "EmployeeController::testCheckDependentConflict"); }); @@ -273,15 +272,12 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $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("get_client_policy_list_for_remainder/(:any)", "EmployeeController::get_client_policy_list_for_remainder/$1"); - $routes->get("send_manual_remainder/(:any)", "DashboardController::sendManualRemainder/$1"); - $routes->get("get_insurer_by_export_templete", "MasterController::getInsurerByExportTemplete"); - $routes->get("copy_insurer_templete/(:any)", "MasterController::copyInsurerTemplete/$1"); + $routes->get("rename_rack_rate_tab/(:any)", "ClientController::renameRackRateTab/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); $routes->cli('cli/processjobs', 'JobWorker::processJobs'); -$routes->cli('cli/updatePolicyEnrollmentStatus', 'DashboardController::updatePolicyEnrollmentStatus'); +$routes->cli('cli/enrollment_status', 'JobWorker::enrollment_status'); $routes->get("processjob", "JobWorker::processJob"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index a5c6ebf0..70431bb7 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -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,22 +1100,32 @@ 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', ]; - if ($policy_grid_id == 1 || $policy_grid_id == 2 || $policy_grid_id == 6 || $policy_grid_id == 7) { + $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 ) { $relation_data = [ 'self' => 1, 'spouse' => 'NA', @@ -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,6 +1313,7 @@ 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[]'); @@ -1226,7 +1325,7 @@ class ClientController extends AdminController $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]; @@ -1234,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[]'); @@ -1305,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[]'); @@ -1355,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]); @@ -1421,13 +1519,13 @@ 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); } } catch (\Exception $e) { - echo 'Error: ' . $e->getMessage(); + echo 'Error: ' . $e->getMessage(). ' at line no ' . $e->getLine(); } } @@ -1557,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) { @@ -1564,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 = ""; @@ -1650,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) { @@ -1665,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 { @@ -1679,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); } } @@ -2044,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)) { @@ -2076,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 @@ -2666,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) @@ -2828,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'); @@ -2853,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{ @@ -2862,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); + } + } + } \ No newline at end of file diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index c59195a3..6e69647f 100644 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -331,7 +331,7 @@ class EmpDataServiceController extends BaseController [ 'column_index' => 0, 'column_name' => 'S.No', - 'header_name' => 'index' + 'db_column_name' => 'index' ], [ 'column_index' => 1, @@ -1549,7 +1549,6 @@ class EmpDataServiceController extends BaseController } } - $batch_list_id[] = $emp_value['emp_policy_id']; } @@ -1696,7 +1695,7 @@ class EmpDataServiceController extends BaseController $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name']; $excel_data = $this->readExcelFileToArray($file_name_with_path); unset($excel_data[0]); // Remove header row - array_pop($excel_data); // Remove footer row + // array_pop($excel_data); $totals = 0; $emp_policy_ids = []; @@ -1707,7 +1706,6 @@ class EmpDataServiceController extends BaseController $emp_count = count($excel_data); $db = \Config\Database::connect(); - foreach ($excel_data as $key => $value) { $name = $value[1]; @@ -1716,33 +1714,37 @@ class EmpDataServiceController extends BaseController $uhid[] = $value[16]; $amount = $value[20]; - $totals = $totals + $amount; + if(!empty($name) && !empty($emp_code)){ - $query = $db->table('employee_polices'); - $query->select('employee_polices.id'); - $query->join('employees', 'employees.id = employee_polices.employee_id'); - $query->where('employee_polices.client_policy_id', $client_policy_id); - $query->where('employees.client_id', $client_id); - $query->where('employees.client_branch_id', $client_branch_id); - $query->where('employees.name', $name); - $query->where('employees.emp_code', $emp_code); - if ($file['insurer_or_tpa'] == 'tpa') { + $totals = $totals + $amount; - $query->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")'); - } else if ($file['insurer_or_tpa'] == 'insurer') { + $query = $db->table('employee_polices'); + $query->select('employee_polices.id'); + $query->join('employees', 'employees.id = employee_polices.employee_id'); + $query->where('employee_polices.client_policy_id', $client_policy_id); + $query->where('employees.client_id', $client_id); + $query->where('employees.client_branch_id', $client_branch_id); + $query->where('employees.name', $name); + $query->where('employees.emp_code', $emp_code); + if ($file['insurer_or_tpa'] == 'tpa') { - $query->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")'); - } - $query->where('employee_polices.is_active', 1); - $query->where('employee_polices.status', 'active'); - $query->where('employees.is_active', 1); - $query->where('employees.emp_status', 'active'); - $query->limit(1); + $query->where('(employee_polices.tpa_id IS NULL OR employee_polices.tpa_id = "")'); + } else if ($file['insurer_or_tpa'] == 'insurer') { + + $query->where('(employee_polices.uhid IS NULL OR employee_polices.uhid = "")'); + } + $query->where('employee_polices.is_active', 1); + $query->where('employee_polices.status', 'active'); + $query->where('employees.is_active', 1); + $query->where('employees.emp_status', 'active'); + $query->limit(1); + + $result = $query->get()->getRowArray(); + if (isset($result['id']) && $result['id'] !== null) { + $emp_policy_ids[] = $result['id']; //for cash deposite + $emp_details[] = array('id' => $result['id'], 'tpa_id' => $value[15], 'uhid' => $value[16]); + } - $result = $query->get()->getRowArray(); - if (isset($result['id']) && $result['id'] !== null) { - $emp_policy_ids[] = $result['id']; //for cash deposite - $emp_details[] = array('id' => $result['id'], 'tpa_id' => $value[15], 'uhid' => $value[16]); } } @@ -1766,18 +1768,17 @@ class EmpDataServiceController extends BaseController $this->myLogger->logme('error', 'Inception Update TPA and UHID -- set cashDepositCalculationForInception and sendMailForDownloadingECard in JOB QUEUE'); $policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id); - $depositeData = [ - 'employeeIds' => $emp_policy_ids, - 'client_id' => $client_id, - 'client_policy_id' => $client_policy_id, - 'client_branch_id' => $client_branch_id, - 'count' => $emp_count, - 'event' => $file['event_type'], - 'policy_name' => $policy_name['policy_name'], - 'user_id' => $user_id, - ]; - + // $depositeData = [ + // 'employeeIds' => $emp_policy_ids, + // 'client_id' => $client_id, + // 'client_policy_id' => $client_policy_id, + // 'client_branch_id' => $client_branch_id, + // 'count' => $emp_count, + // 'event' => $file['event_type'], + // 'policy_name' => $policy_name['policy_name'], + // 'user_id' => $user_id, + // ]; $job_details = new Jobs(); $r = Jobs::addJob(['job_name' => 'cashDepositCalculationForInception', 'payload' => [ @@ -1813,8 +1814,6 @@ class EmpDataServiceController extends BaseController - - //Endorsement Correction public function importCorrectionValidation($params) { @@ -2229,7 +2228,6 @@ class EmpDataServiceController extends BaseController - //Endorsement SIEnhancement public function importSIEnhancementValidation($params) { @@ -2866,7 +2864,7 @@ class EmpDataServiceController extends BaseController $excel_data = $this->readExcelFileToArray($file_name_with_path); $excel_header = $excel_data[0]; unset($excel_data[0]); - array_pop($excel_data); + // array_pop($excel_data); $headers = ['S.No','EMP ID','EMP NAME','DOB','GENDER','RELATIONSHIP','SUM INSURED','Date of Leaving','Policy End Date','No Of Days','Premium','Pro Rata Premium','GST','Total','Claim Status','ENDORSEMENT_ID']; @@ -3276,24 +3274,25 @@ class EmpDataServiceController extends BaseController $totals = $totals + $value[13]; $endorsement_id = $value[15]; + if(!empty($emp_code) && !empty($emp_name)){ - $fetch_data = [ - 'client_policy_id' => $client_policy_id, - 'client_branch_id' => $client_branch_id, - 'client_id' => $client_id, - 'emp_name' => $emp_name, - 'emp_code' => $emp_code - ]; - $result = $this->employeePolicyModel->fetchEmpEndorsementData($fetch_data); + $fetch_data = [ + 'client_policy_id' => $client_policy_id, + 'client_branch_id' => $client_branch_id, + 'client_id' => $client_id, + 'emp_name' => $emp_name, + 'emp_code' => $emp_code + ]; + $result = $this->employeePolicyModel->fetchEmpEndorsementData($fetch_data); - // dd($result['emp_endorsement_primarykey']); + if (isset($result['emp_endorsement_primarykey']) && $result['emp_endorsement_primarykey'] !== null) { - if (isset($result['emp_endorsement_primarykey']) && $result['emp_endorsement_primarykey'] !== null) { + $employee_policy_table_primaryKey[] = $result['emp_policy_primarykey']; //for cash deposite + $employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => $result['date_of_exit'], 'reason_for_exit' => $result['reason_for_exit'], 'status' => $result['status']); + $employees_table_data[] = array('id' => $result['employees_id'], 'emp_status' => $result['status']); + $emp_endorsement_table_data[] = array('id' => $result['emp_endorsement_primarykey'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[15], 'status' => 'complete'); + } - $employee_policy_table_primaryKey[] = $result['emp_policy_primarykey']; //for cash deposite - $employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => $result['date_of_exit'], 'reason_for_exit' => $result['reason_for_exit'], 'status' => $result['status']); - $employees_table_data[] = array('id' => $result['employees_id'], 'emp_status' => $result['status']); - $emp_endorsement_table_data[] = array('id' => $result['emp_endorsement_primarykey'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[15], 'status' => 'complete'); } } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 10ad95c4..1cc96792 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -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); @@ -463,10 +465,10 @@ class EmployeeController extends AdminController if (!$return) { if ($insurer_or_tpa == 'tpa') { - session()->setFlashdata('error', "No data was found for this action. The TPA ID has already been updated."); + session()->setFlashdata('error', "No data was found for this action."); return redirect()->to(base_url('employee/upload')); } else if ($insurer_or_tpa == 'insurer') { - session()->setFlashdata('error', "No data was found for this action. The UHID has already been updated."); + session()->setFlashdata('error', "No data was found for this action."); return redirect()->to(base_url('employee/upload')); } } else { @@ -1511,8 +1513,11 @@ class EmployeeController extends AdminController $client_id = $json->client_id; $policy_id = $json->policy_id; $branch_id = $json->branch_id; + $unit_id = $json->unit_id; + $action = $json->action; + $family_code = $json->emp_code; $tabledata = $json->data; - + $existing_famility_details = []; if(count($tabledata)) { $family_details = []; @@ -1523,7 +1528,7 @@ class EmployeeController extends AdminController { $temp[0] = $row['column1'];//sno - $temp[1] = $row['column2'];//emp code + $temp[1] = $family_code != "" ? $family_code : $row['column2'];//emp code $temp[2] = $row['column3'];//name $temp[3] = $row['column4'];//DOB $temp[4] = strtoupper($row['column5']);//Gender @@ -1540,14 +1545,29 @@ class EmployeeController extends AdminController $temp[15] = '';//RFE $temp[16] = '';//DOE $temp[17] = '';//Unit - $temp[18] = $row['column11'];//unit + $temp[18] = $unit_id;//unit $family_details[] = $temp; } } } - // print_r($family_details); - // return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $family_details], 200); + if($action == 'dependent_addition') + { + $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: $family_code,client_id: $client_id,client_policy_id: $policy_id,emp_status: ['active'],policy_status:['active'],client_branch_id: [ $branch_id ]); + // ~dd($this->employeeModel->getLastQuery()); + + if(!count($existing_famility_details)) + { + return $this->respond(['dataStatus' => false, 'code' => 404, 'data' => [],'messgae' => "No Data found for emp code $family_code"], 200); + } + //transsform familiy details from db columns to exxcel row with column indexs for checking remaining functionalitites + $existing_famility_details = transform_db_data_to_excel($existing_famility_details,[]); + // Kint::dump($existing_famility_details); + $family_details = array_merge($family_details,$existing_famility_details); + $family_details = data_group_by_family($family_details)[ $family_code ];// reason to call this again is bring self to first index of the array + // dd($family); + } + //get policy details $policy_details = $this->clientPolicyModel->getPolicyDetails($client_id,$policy_id); $policy_details = (array)$policy_details[0]; @@ -1570,7 +1590,7 @@ class EmployeeController extends AdminController } } - return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $data], 200); + return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => ['new' => $data,'old' => $existing_famility_details], 200]); } } diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 9f928ce0..af9c2f07 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1015,6 +1015,17 @@ class EmployeeRestController extends AdminController $self['data']['basic_cover_si'] = $employee_policy->basic_cover_si; $array->mapped_family_floaters = $self; + + + + $res = []; + array_push($res,$array); + $EDLIPolicy = $this->getAdditionalGPAPolicy($employeeData,6,$emp_code,$client_id,$client_branch_id); + if($EDLIPolicy){ array_push($res,$EDLIPolicy); } + $GTLIPolicy = $this->getAdditionalGPAPolicy($employeeData,7,$emp_code,$client_id,$client_branch_id); + if($GTLIPolicy){ array_push($res,$GTLIPolicy); } + return $this->respond(['status' => 'success','code' => 200,'data' => $res ], 200); + // Return result if($this->request->getGet('policy') == 'GPA') @@ -1133,8 +1144,8 @@ class EmployeeRestController extends AdminController $array->mapped_family_floaters = $data; $array->type = "Group Medical Coverage"; - $checkGmcParentsPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, policies.id as PolicyId , client_policy.policy_type_id as policy_type_id, policies.name as Policy_Name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms') - ->join('policies', 'client_policy.policy_id = policies.id', 'left') + $checkGmcParentsPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, client_policy.policy_type_id as policy_type_id, policy_type.long_name as Policy_Name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms') + ->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left') ->where('client_policy.policy_type_id', 3 ) ->where('client_policy.is_addon', 1 ) ->where('client_policy.client_id', $this->request->getGet('client_id') ) @@ -1328,6 +1339,70 @@ class EmployeeRestController extends AdminController } + + public function getAdditionalGPAPolicy($empData,$policy_type,$emp_code,$client_id,$client_branch_id) + { + $checkPolicyExist = $this->clientPolicyModel->select('client_policy.id as ClientPolicyId , client_policy.client_id as ClientId, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type , client_policy.policy_terms as Policy_Terms , client_policy.enrolment_visibility') + ->where('client_policy.policy_type_id', $policy_type ) + ->where('client_policy.is_addon', 1 ) + ->where('client_policy.client_id', $client_id ) + ->where('client_policy.client_branch_id', $client_branch_id ) + ->where('client_policy.is_active', 1 ) + ->get() + ->getResult(); + + if($checkPolicyExist){ + + foreach ($checkPolicyExist as $key => $array) { + + $decodedArray = json_decode($array->Policy_Terms); + $array->Policy_Terms = $decodedArray; + + + // Filter employee data where the family_floater_key is 'self' + $selfData = array_filter($empData, fn($arr) => trim(strtolower($arr['family_floater_key'])) === 'self'); + $employee_policy = $this->employeePolicyModel->where('employee_id',$selfData[0]['id'])->where('client_policy_id',$array->ClientPolicyId)->where('is_active', 1 )->get()->getRow(); + $policyTypeData = $this->policyTypeModel->where('id',$policy_type)->get()->getRow(); + $array->type = $policyTypeData->policy_type; + $array->Policy_Name = $policyTypeData->long_name; + if($employee_policy){ + + if($employee_policy->tpa_id != null){ + $array->eCardDownload = base_url('download-e-card/') . $employee_policy->rand_string; + }else{ $array->eCardDownload = null; } + + $self['is_value_exist'] = true; + $self['data']['family_floater_key'] = 'self'; + $self['data']['employee_id'] = $selfData[0]['id']; + $self['data']['relationship'] = 'Self'; + $self['data']['name'] = $selfData[0]['name']; + $self['data']['dob'] = $this->convertDateFormatDMY($selfData[0]['dob']); + $self['data']['mobile'] = $selfData[0]['mobile']; + $self['data']['client_policy_id'] = $array->ClientPolicyId; + $self['data']['basic_cover_si'] = $employee_policy->basic_cover_si; + $array->mapped_family_floaters = $self; + + if($array->enrolment_visibility == 1) + return $array; + else + return false; + + }else{ + return false; + } + + + + } + + } + } + + public function getGTLIPolicy($empData,$emp_code,$client_id,$client_branch_id) + { + + } + public function FloterConvertion($array){ $result = []; @@ -1473,8 +1548,9 @@ class EmployeeRestController extends AdminController } - - $responce['policy_name'] = $this->policesModel->where('id',$array['policy_id'])->get()->getRow()->name; + $policyTypeData = $this->policyTypeModel->where('id',$array['policy_type_id'])->get()->getRow(); + $responce['policy_name'] = $policyTypeData->long_name; + $responce['type'] = $policyTypeData->policy_type; $responce['SlabRates'] = $uniqueData; $responce['GridMaster'] = $getSlabAndGridData['grid_master']; $responce['client_id'] = $array['client_id']; @@ -1934,8 +2010,8 @@ class EmployeeRestController extends AdminController $data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0; $data['policyDetails'] = []; - $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id , client_policy.policy_type_id as policy_type_id, policies.name as policy_name , client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ') - ->join('policies', 'client_policy.policy_id = policies.id', 'left') + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ') + ->where('client_policy.insurer_id', $value['insurerId'] ) ->where('client_policy.client_id', $this->request->getGet('client_id') ) ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) @@ -1945,8 +2021,9 @@ class EmployeeRestController extends AdminController // dd( $ClientPolicyData); foreach ($ClientPolicyData as $key => $value) { - - $value['type'] = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow()->policy_type; + $policyTypeData = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow(); + $value['type'] = $policyTypeData->policy_type; + $value['policy_name'] = $policyTypeData->long_name; $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0,branch_id:$this->request->getGet('client_branch_id')); $enrolledCount = 0; $draftCount = 0; diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index f31460b2..826c7e29 100644 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -18,6 +18,7 @@ use App\Models\EmpEndorsementModel; use App\Models\MessageModel; use App\Models\ClientBranchModel; use App\Models\NotificationModel; +use App\Models\InsurerModel; use App\Helpers\sendMailNotification; @@ -41,6 +42,7 @@ class EmployeeServiceController extends AdminController protected $messageModel; protected $clientBranchModel; protected $notificationModel; + protected $insurerModel; protected $general_relationships = [ 'self' => [ @@ -649,6 +651,7 @@ class EmployeeServiceController extends AdminController $this->messageModel = new MessageModel(); $this->clientBranchModel = new ClientBranchModel(); $this->notificationModel = new NotificationModel(); + $this->insurerModel = new InsurerModel(); } public function excelFileFormatValidation($params) @@ -1295,21 +1298,31 @@ class EmployeeServiceController extends AdminController // $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); unset($excel_data[0]); - // dd($excel_data); + // kint::dump($excel_data); $endorsement_data = []; - - + $policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']); + $insurer = new InsurerModel(); + $insurer = ($insurer->find($policy_terms[0]->insurer_id)); + // kint::dump($insurer); //make closure funciton which is going to use only by this method - $endorsement = function($data,$file,$row){ + $endorsement = function($data,$file,$row) use ($insurer){ $group_key = rand(100000, 999999); + $row[4] = change_date_format($row[4],'d-M-Y','Y-m-d');// date of exit from excel + // Kint::dump($row[4]); + // check if insurer configured with add one day for deletion + if($insurer['deletion_add_day'] == true) + { + $row[4] = (new \DateTime($row[4]))->modify('+1 day')->format('Y-m-d'); + } + // dd($row[4]); //for emp table $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'emp_status','old_value' => $data['emp_status'],'new_value' => 'deactivate','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); // dd( $this->empEndorsementModel->getLastQuery()); // $this->empEndorsementModel->save(['pk' => (int)$data['emp_id'],'emp_code' => $data['emp_code'],'table_name' => 'employees','actions' => 'd','name' => $data['name'],'field_name' => 'change_event','old_value' => $data['change_event'],'new_value' => 'deletion','created_by' => $file['created_by'],'remarks' => 'general deletion']); // for employee policy table - $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'date_of_exit','old_value' => $data['date_of_exit'],'new_value' => change_date_format($row[4],'d-M-Y','Y-m-d'),'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); + $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'date_of_exit','old_value' => $data['date_of_exit'],'new_value' => $row[4],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'reason_for_exit','old_value' => $data['reason_for_exit'],'new_value' => $row[5],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'status','old_value' => $data['status'],'new_value' => 'inactive','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); }; @@ -1326,6 +1339,7 @@ class EmployeeServiceController extends AdminController // dd($employee); if(is_array($employee) && count($employee)) { + // dd($employee); $existing_endorsements = $this->empEndorsementModel->where('actions','d') ->where('table_name','employees') ->where('endorsement_id is null') @@ -1334,9 +1348,10 @@ class EmployeeServiceController extends AdminController ->where('field_name','emp_status') ->findAll(); - + // dd($existing_endorsements); if(!count($existing_endorsements)) { + // dd($employee); if(strtolower($employee['relationship']) != 'self') { @@ -1654,6 +1669,10 @@ class EmployeeServiceController extends AdminController }// if end }// is array check end + else + { + $this->myLogger->logme('error','######Incoming value is not an array'); + } }// for end }//function end diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 969f01c6..0fa4f33b 100644 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -152,8 +152,17 @@ class MasterController extends AdminController $editData['insurer'] = $this->insurerModel->where(['id' => $id, 'is_active' => 1])->first(); - $editData['insuer_branch'] = $this->insurerBranchModel->where(['insurer_id' => $id, 'is_active' => 1])->findAll(); + $editData['insuer_branch'] = $this->insurerBranchModel->where(['insurer_id' => $id, 'is_active' => 1])->findAll(); $editData['insurer_templete_count'] = $this->insurerTemplateModel->where(['insurer_id' => $id, 'is_active' => 1])->countAllResults(); + $editData['insurer_templete_list'] = $this->insurerModel->getInsurerTemplateByInsurerID($id); + + + $editData['policy_type'] = $this->policyTypeModel->whereIn('id', [1,2,6,7])->findAll(); + $editData['events'] = ['inception' => 'Inception', 'addition' => 'Addition', 'dependent_addition' => 'Dependent Addition', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement', 'all' => 'All']; + $editData['action'] = ['import' => 'Import', 'export' => 'Export']; + $editData['db_column_name'] = ['Employee Name' => 'emp_name', 'Employee ID' => 'emp_code']; + + // echo "
";
@@ -377,8 +386,6 @@ class MasterController extends AdminController
}else{
return $this->respond(['status' => true, 'message' => 'Failed to add template', $insurer_templete_data]);
}
-
-
}
// Insurer Ends
@@ -386,7 +393,6 @@ class MasterController extends AdminController
// TPA Start
-
public function tpaList()
{
$this->myLogger->logme('error','TPA list function called');
@@ -709,10 +715,11 @@ class MasterController extends AdminController
echo json_encode($editData);
exit();
}
-
//Ends TPA Models
+
+
//Start KYC
public function kycList()
@@ -901,8 +908,9 @@ class MasterController extends AdminController
- //Start Policy
+
+ //Start Policy
public function policyTypeList()
{
$this->myLogger->logme('error','Policy Type list function called');
@@ -1098,10 +1106,11 @@ class MasterController extends AdminController
echo json_encode(array("status" => false));
}
}
-
//end policies
+
+
//start CD Master list
public function CDMasterList()
{
@@ -1254,4 +1263,25 @@ class MasterController extends AdminController
}
}
+
+
+ public function createExcelTemplate()
+ {
+ $data = [
+ 'insurer_id' => $this->request->getPost('insurer_id'),
+ 'policy_type_id' => $this->request->getPost('policy_type'),
+ 'event_name' => $this->request->getPost('event'),
+ 'type_name' => $this->request->getPost('import_or_export'),
+ 'jsoncolumns' => $this->request->getPost('json_data'),
+ ];
+
+ $insert = $this->insurerTemplateModel->insert($data);
+
+ if($insert){
+ return $this->respond(['status' => true, 'message' => 'Template created successfully', $data]);
+ }else{
+ return $this->respond(['status' => true, 'message' => 'Failed to create template', $data]);
+ }
+
+ }
}
\ No newline at end of file
diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php
index f654dc40..d3bd04aa 100644
--- a/app/Controllers/UserController.php
+++ b/app/Controllers/UserController.php
@@ -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();
}
}
diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php
index 0f3fd7d0..3f07ed82 100644
--- a/app/Helpers/excel_util_helper.php
+++ b/app/Helpers/excel_util_helper.php
@@ -241,6 +241,13 @@ if(!function_exists('check_si'))
$return_array = array('status' => true,'error' => '');
}
+ if($policy_details['policy_type_id'] == 3 && strtolower($row['5']) == 'self') // if GMC parent and current relation is self then skip this . so set all true;
+ {
+ $is_si_found = true;
+ $is_age_slab_found = true;
+ $return_array = array('status' => true,'error' => '');
+ }
+
if($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I','A','DA','SI','MI']))// check rule only of action column data available
{
$received_si = $row['current_action'] == 'SI' ? $row[3] : $row[6];
diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php
index b6101356..718e67a8 100644
--- a/app/Models/ClientModel.php
+++ b/app/Models/ClientModel.php
@@ -45,14 +45,14 @@ class ClientModel extends Model
->where('is_active',1)
->findAll();
- // if($role_id == 2 || $role_id == 3){
+ if($role_id == 2 || $role_id == 3){
- // $clients = $this->select($columns)
- // ->join('client_rm', 'client_rm.client_id = clients.id')
- // ->where('client_rm.user_id', $user_id)
- // ->where('clients.is_active',1)
- // ->findAll();
- // }
+ $clients = $this->select($columns)
+ ->join('client_rm', 'client_rm.client_id = clients.id')
+ ->where('client_rm.user_id', $user_id)
+ ->where('clients.is_active',1)
+ ->findAll();
+ }
@@ -84,6 +84,7 @@ class ClientModel extends Model
$clientBranchModel = new ClientBranchModel();
$clientBranchs = $clientBranchModel->select(['client_branch.id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id','client_branch.units'])
->where('client_branch.client_id',$client['id'])
+ ->where('client_branch.is_active',1)
->findAll();
$client['branchs'] = $clientBranchs;
diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php
index e0e29c14..e64a4d63 100644
--- a/app/Models/EmployeeModel.php
+++ b/app/Models/EmployeeModel.php
@@ -149,9 +149,9 @@ class EmployeeModel extends Model
{
return $this->db->table('employee_polices')
- ->select(' policies.name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
+ ->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
- ->join('policies', 'policies.id = client_policy.policy_id')
+ ->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.policy_status', 1)
->where('employee_polices.employee_id', $id)
->get()
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index 6a668532..759835c7 100644
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -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');
diff --git a/app/Models/InsurerModel.php b/app/Models/InsurerModel.php
index a731c858..8d72bca7 100644
--- a/app/Models/InsurerModel.php
+++ b/app/Models/InsurerModel.php
@@ -20,6 +20,7 @@ class InsurerModel extends Model
"is_active",
"addition_add_day",
"is_multi_event",
+ "deletion_add_day",
];
@@ -35,6 +36,7 @@ class InsurerModel extends Model
->get()
->getResult();
}
+
public function getInsurerName($insurerId)
{
// Fetch the insurer name based on the insurer ID
@@ -50,6 +52,21 @@ class InsurerModel extends Model
return null; // or handle accordingly if the insurer is not found
}
+
+ public function getInsurerTemplateByInsurerID($insurer_id)
+ {
+ $insurer_data = $this->db->table('insurer_excel_export_template')
+ ->select('insurers.name as insurer_name, insurers.id, insurers.is_multi_event')
+ ->select('CASE WHEN insurers.is_multi_event = 1 THEN "multiple" ELSE insurer_excel_export_template.event_name END as event_name', false)
+ ->select('insurer_excel_export_template.type_name, insurer_excel_export_template.jsoncolumns, policy_type.policy_type')
+ ->join('insurers', 'insurers.id = insurer_excel_export_template.insurer_id')
+ ->join('policy_type', 'policy_type.id = insurer_excel_export_template.policy_type_id')
+ ->where('insurers.id', $insurer_id)
+ ->get()
+ ->getResultArray();
+
+ return $insurer_data;
+ }
}
\ No newline at end of file
diff --git a/app/Models/PolicesModel.php b/app/Models/PolicesModel.php
index ec010b82..bd8fe9d4 100644
--- a/app/Models/PolicesModel.php
+++ b/app/Models/PolicesModel.php
@@ -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();
}
diff --git a/app/Views/UserList.php b/app/Views/UserList.php
index e53e341d..37ce4dd5 100644
--- a/app/Views/UserList.php
+++ b/app/Views/UserList.php
@@ -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);
+ }
+
});
});
diff --git a/app/Views/cd_master_list.php b/app/Views/cd_master_list.php
index 04a52784..cf0f19e8 100644
--- a/app/Views/cd_master_list.php
+++ b/app/Views/cd_master_list.php
@@ -241,6 +241,10 @@ table.dataTable thead th {
$('#opening_bal').val('');
$('#CDMasterForm')[0].reset();
$('#CDMasterForm').parsley().reset();
+ $('#client_id').prop("disabled", false);
+ $('#insurer_id').prop("disabled", false);
+ $('#cd_ac_no').prop("disabled", false);
+
})
@@ -261,9 +265,12 @@ table.dataTable thead th {
$('#CDMasterForm').attr('action', '');
$('#CD_Master_ID').val(res.data.id);
$('#client_id').val(res.data.client_id).change();
+ $('#client_id').prop("disabled", true);
$('#insurer_id').val(res.data.insurer_id).change();
+ $('#insurer_id').prop("disabled", true);
$('#opening_date').val(res.data.opening_date);
$('#cd_ac_no').val(res.data.cd_ac_no);
+ $('#cd_ac_no').prop("disabled", true);
$('#opening_bal').val(res.data.opening_bal);
$('#btnSubmit').html('Update');
@@ -279,6 +286,10 @@ table.dataTable thead th {
$('#cd_ac_no').change(function(){
var cd_ac_no = $(this).val();
+ console.log(cd_ac_no +'-'+cd_ac_no.length);
+ cd_ac_no = cd_ac_no.trim();
+ console.log(cd_ac_no +'-'+cd_ac_no.length);
+
$.ajax({
url: ''+cd_ac_no,
diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php
index b5ee306d..2867a42c 100644
--- a/app/Views/client_branch.php
+++ b/app/Views/client_branch.php
@@ -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');
}
}
},
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index 90bc3763..f57c5dea 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -341,7 +341,7 @@
${policy_name_data}
${item.branch_name ? item.branch_name : ' - '}
${tpaValue}
- ${(item.open_date)} / ${(item.close_date)}
+ ${(item.policy_start_date)} / ${(item.policy_end_date)}
${(enrollmentStatus)}
${checkDateStatus(item.policy_end_date, 1)}
@@ -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 = '' + 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') {
diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php
index f5d04b65..322a5eea 100644
--- a/app/Views/employee_data_list.php
+++ b/app/Views/employee_data_list.php
@@ -50,7 +50,20 @@
SNO
-
+
+
+
+ Client/Branch
+
+
+
+
+
+ Branch
+
+
+
+ Employee code
Name/code
Policy name
Insurer
name
@@ -75,6 +88,19 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
+
( - )
-
diff --git a/app/Views/employee_upload.php b/app/Views/employee_upload.php
index cc94977d..535418cc 100644
--- a/app/Views/employee_upload.php
+++ b/app/Views/employee_upload.php
@@ -1004,7 +1004,12 @@ function checkPolicyTermsAndRackRatesHasDefiend(event)
}else{
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
- $("#event_type").select2('destroy');
+
+ if ($('event_type').data('select2')) {
+ $('event_type').select2('destroy');
+ }
+
+ // $("#event_type").select2('destroy');
}
diff --git a/app/Views/file_list.php b/app/Views/file_list.php
index 3fcc2609..c2872c70 100644
--- a/app/Views/file_list.php
+++ b/app/Views/file_list.php
@@ -100,7 +100,7 @@
View
- Truncate
+ Truncate
@@ -246,7 +246,7 @@ $('body').on('click', '.upload_button', function() {
})
-$('body').on('click', '.truncate', function(event) {
+$('body').on('click', '.truncate2', function(event) {
event.preventDefault();
// console.log(event);
var fileId = JSON.parse(this.getAttribute('data-id'));
diff --git a/app/Views/insurer_export_templete.php b/app/Views/insurer_export_templete.php
index 3b4c049b..1c1f4ca0 100644
--- a/app/Views/insurer_export_templete.php
+++ b/app/Views/insurer_export_templete.php
@@ -9,14 +9,130 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ S.NO
+ Policy Type
+ Event Type
+ Import/Export
+ Template
+
+
+
+
+ $value ){ ?>
+
+ = $key+1; ?>
+ = $value['policy_type']; ?>
+ = $value['event_name']; ?>
+ = $value['type_name']; ?>
+ = $value['jsoncolumns']; ?>
+
+
+
+
+
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php
index 5227b436..469d99dc 100644
--- a/app/Views/policy_gpa_terms.php
+++ b/app/Views/policy_gpa_terms.php
@@ -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 = `
diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php
index 85405d83..d4c963fc 100644
--- a/app/Views/policy_grid.php
+++ b/app/Views/policy_grid.php
@@ -22,6 +22,10 @@
bottom: 6px;
}
+.highlight-duplicate {
+ border: 2px solid red; /* or any other style you prefer */
+}
+
/* .unitDiv{
display: none;
} */
@@ -52,7 +56,7 @@
- Primary Rack Rate
+ Primary Rack Rate
@@ -113,6 +117,7 @@
+ Rename
@@ -131,7 +136,9 @@ var grid_html = '';
$('#btnGridSubmit').hide();
$('.close').click(function()
-{
+{
+ localStorage.removeItem('client_units');
+
$('#grid_content_input').show();
$('#grid_content_from_excel').hide();
@@ -183,6 +190,11 @@ $(document).on('submit', 'form[id^="GridForm_"]', function(event) {
return;
}
+ var checkUnits = checkValideUnits(secondaryValue);
+ if (checkUnits) {
+ return;
+ }
+
// Validate the form using Parsley
var isValid = $('#' + formId).parsley().validate();
if (!isValid) {
@@ -206,8 +218,16 @@ $(document).on('submit', 'form[id^="GridForm_"]', function(event) {
}
});
+ // Ensure all desired keys are present, adding any missing keys with value 'NA'
+ desiredKeys.forEach(key => {
+ if (!formObject.hasOwnProperty(key)) {
+ formObject[key] = 'NA';
+ }
+ });
+
console.log('formObject', formObject)
- let isEqual = checkFamiliFloatersKeysDuplicate(rarc_rate_json_array, formObject);
+ let isEqual = checkFamiliFloatersKeysDuplicate(rarc_rate_json_array, formObject, secondaryValue);
+ console.log('checkFamiliFloatersKeysDuplicate', isEqual)
if(isEqual){
toastr.warning('Family floaters alerdey exist', 'warning');
@@ -249,7 +269,7 @@ $(document).on('submit', 'form[id^="GridForm_"]', function(event) {
rarc_rate_json_array.push(res.rack_rate_json);
- console.log('rarc_rate_json_array', rarc_rate_json_array)
+ console.log('rarc_rate_json_array inside the submit function', rarc_rate_json_array)
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
@@ -262,12 +282,23 @@ $(document).on('submit', 'form[id^="GridForm_"]', function(event) {
},
error: function(xhr, status, error) {
+ // Get the current timestamp
+ var timestamp = new Date().toISOString();
- console.error(xhr.responseText);
- console.error(status, error);
+ // Log detailed error information
+ console.error('Timestamp:', timestamp);
+ 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('AJAX Status:', status);
+ console.error('Error Thrown:', error);
+
+ // Handle UI elements
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
+
});
}
@@ -287,6 +318,7 @@ var employee_count = '';
var client_policy_for_additional_rack_rate = '';
var terms_si_amount_array = [];
var unit_length = 0;
+var branch_units = [];
$('body').on('click', '.btnPolicyModel', function()
@@ -307,11 +339,11 @@ $('body').on('click', '.btnPolicyModel', function()
$('.loader-mask').fadeIn();
if (policy_type_string == 'GPA' || policy_type_id == 6 || policy_type_id == 7) {
- $('#add_new_rack_rate_tab_div').hide()
- $('#rack_rate_one').hide()
+ $('#add_new_rack_rate_tab_div').hide();
+ $('#rack_rate_one').hide();
} else {
- $('#add_new_rack_rate_tab_div').show()
- $('#rack_rate_one').show()
+ $('#add_new_rack_rate_tab_div').show();
+ $('#rack_rate_one').show();
}
$('#rack_rate_one').click();
@@ -325,12 +357,15 @@ $('body').on('click', '.btnPolicyModel', function()
success: function(res) {
console.log('rack rate responce', res)
+ console.log('rack rate responce jsonArray', res.jsonArray);
// console.log('rack rate responce.premium data', res.premiumData)
// console.log('rack rate responce.premium data parsed', JSON.parse(res.premiumData));
var data_for_the_rack_rate = JSON.parse(res.premiumData) ?? [];
var groupedData = groupByRackRateName(data_for_the_rack_rate) ?? [];
+ rarc_rate_json_array.push(res.jsonArray);
+
console.log('groupedData', groupedData)
if(policy_type_string == 'GMC'){
@@ -353,7 +388,8 @@ $('body').on('click', '.btnPolicyModel', function()
employee_count = res.count;
terms_si_amount_array = res.terms_si_amount_array;
localStorage.setItem('client_units', res.branch_units)
- client_units_for_hide_unit_text_field = JSON.parse(res.branch_units);
+ var client_units_for_hide_unit_text_field = JSON.parse(res.branch_units);
+ branch_units = client_units_for_hide_unit_text_field;
if(client_units_for_hide_unit_text_field){
unit_length = client_units_for_hide_unit_text_field.length;
@@ -368,7 +404,17 @@ $('body').on('click', '.btnPolicyModel', function()
var premium_type_for_primary_rr = [];
var first = 0;
- var premiumData = groupedData.Primary ?? [];
+ var premiumData = groupedData.Primary ?? (function() {
+ var firstKey = Object.keys(groupedData)[0];
+ var firstValue = groupedData[firstKey];
+
+ if (firstValue !== undefined) {
+ delete groupedData[firstKey];
+ }
+ return firstValue || [];
+ })();
+
+
console.log('----- premiumData for primary rack rate -----', premiumData);
if (premiumData.length > 0 && premiumData != 'undefined') {
@@ -393,6 +439,8 @@ $('body').on('click', '.btnPolicyModel', function()
var checkboxdata = res.self;
+ $('#grid_content_input').empty()
+
if (policy_type_string === 'GPA' || policy_type_id === 6 || policy_type_id === 7) {
const checkboxDataObject = {
@@ -423,6 +471,9 @@ $('body').on('click', '.btnPolicyModel', function()
addGridHTML(false, premiumData[0], premiumData[0].policy_grid_id, si_or_bp_value);
+ $('#tabname').text(premiumData[0].rack_rate_name);
+ $('#rack_rate_name').val(premiumData[0].rack_rate_name);
+
premiumData.shift();
$.each(premiumData, function(index, item) {
if (item.si_or_bp == '1') {
@@ -466,6 +517,21 @@ $('body').on('click', '.btnPolicyModel', function()
// console.log('gpa_si[]', $(this));
$(this).trigger('keyup');
});
+
+ $('input[name="gpa_premium"]').each(function() {
+ // console.log('gpa_si[]', $(this));
+ $(this).trigger('keyup');
+ });
+
+ $('input[name="gpa_si29[]"]').each(function() {
+ // console.log('gpa_si[]', $(this));
+ $(this).trigger('keyup');
+ });
+
+ $('input[name="gpa_premium29[]"]').each(function() {
+ // console.log('gpa_si[]', $(this));
+ $(this).trigger('keyup');
+ });
$('input[name="gpa_sum_si[]"]').each(function() {
$(this).trigger('keyup');
@@ -528,7 +594,7 @@ $('body').on('click', '.btnPolicyModel', function()
});
-console.log(rarc_rate_json_array);
+console.log('after the form submit', rarc_rate_json_array);
$(document).on('change', 'select[id^="grid_"]', function(event)
{
@@ -628,6 +694,8 @@ $('#grid').change(function()
function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = false, unique_id = false)
{
console.log('addgridhtmll function data', data)
+ console.log('addgridhtmll function data.unit', data.unit)
+ console.log('addgridhtmll function data.unit type',typeof data.unit)
console.log('addgridhtmll function unique id', unique_id)
console.log('addGridHTML si_or_bp', si_or_bp);
console.log('addGridHTML event', event);
@@ -638,11 +706,10 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
var grid_container = document.getElementById('grid_content_input');
console.log('step 1', grid_container);
- if (secondaryValue != false) {
+ if (secondaryValue != false && secondaryValue != null) {
grid_container_id = 'grid_content_input_for_additional_' + secondaryValue;
grid_container = document.getElementById(grid_container_id);
console.log('step 2', grid_container);
-
}
console.log('step 3', grid_container);
@@ -685,7 +752,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
-
+
@@ -722,7 +789,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
-
+
@@ -802,16 +869,16 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
-
+
-
+
-
+
`;
@@ -1044,16 +1111,16 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
-
+
-
+
-
+
`;
@@ -1273,14 +1340,16 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
};
-var Count = 1
+var Count = 1;
function appendGridtHtml(ui_type = false, secondary = false, data = false)
{
console.log('appendGridtHtml function data', data);
+ console.log('appendGridtHtml function data.unit', data.unit);
+ console.log('appendGridtHtml function data.unit type',typeof data.unit);
console.log('appendGridtHtml function ui_type', ui_type);
console.log('appendGridtHtml function secondary', secondary);
- console.log('appendGridtHtml function typeof secondary', typeof secondary)
+ console.log('appendGridtHtml function typeof secondary', typeof secondary);
var html = '';
Count++;
@@ -1309,7 +1378,7 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
html = `
-
+
@@ -1335,7 +1404,7 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
html = `
-
+
@@ -1463,7 +1532,7 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
-
+
@@ -1572,22 +1641,22 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
`;
- } else if (ui_type == '9') {
+ } else if (ui_type == '2' || ui_type == '9') {
html = `
-
+
-
+
-
+
`;
@@ -1824,15 +1893,27 @@ function checkDuplicate(unique_id = null)
console.log('checkDuplicate id 3', id);
console.log('checkDuplicate container 3', container);
+ // var highlightDuplicates = function(duplicateIndices) {
+ // duplicateIndices.forEach(index => {
+ // container.find('input').eq(index).addClass('highlight-duplicate');
+ // });
+ // };
+
+ // var removeHighlight = function() {
+ // container.find('input').removeClass('highlight-duplicate');
+ // };
+
+ // removeHighlight();
+
if (id.value === '3') {
var siInputs = container.find('input[name="3_si[]"]');
- var premiumInputs = container.find('input[name="3_premium[]"]');
+ var units = container.find('input[name="3_unit[]"]');
var siValues = [];
- var premiumValues = [];
+ var unitValues = [];
+ // var duplicateIndices = [];
var siDuplicates = false;
- var premiumDuplicates = false;
// Extract values from input arrays
siInputs.each(function() {
@@ -1842,22 +1923,67 @@ function checkDuplicate(unique_id = null)
siValues.push(numericValue);
});
- premiumInputs.each(function() {
+ units.each(function() {
var value = $(this).val();
- var cleanedValue = value.replace(/,/g, '');
- var numericValue = parseFloat(cleanedValue);
- premiumValues.push(numericValue);
+ unitValues.push(value);
});
+ console.log('checkDuplicate function siValues', siValues)
+ console.log('checkDuplicate function unitValues', unitValues)
+
for (var i = 0; i < siValues.length; i++) {
for (var j = i + 1; j < siValues.length; j++) {
- if (siValues[i] === siValues[j] && premiumValues[i] === premiumValues[j]) {
+ if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j]) {
siDuplicates = true;
+ // duplicateIndices.push(i, j);
}
}
}
- if (siDuplicates || premiumDuplicates) {
+ if (siDuplicates) {
+ // highlightDuplicates(duplicateIndices);
+ toastr.warning('Duplicates found!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+ } else if (id.value === '2' || id.value === '9') {
+
+ var siInputs = container.find('input[name="gpa_si29[]"]');
+ var units = container.find('input[name="gpa_unit29[]"]');
+
+ var siValues = [];
+ var unitValues = [];
+ // var duplicateIndices = [];
+ var siDuplicates = false;
+
+ // Extract values from input arrays
+ siInputs.each(function() {
+ var value = $(this).val();
+ var cleanedValue = value.replace(/,/g, '');
+ var numericValue = parseFloat(cleanedValue);
+ siValues.push(numericValue);
+ });
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkDuplicate function siValues', siValues)
+ console.log('checkDuplicate function unitValues', unitValues)
+
+ for (var i = 0; i < siValues.length; i++) {
+ for (var j = i + 1; j < siValues.length; j++) {
+ if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j]) {
+ siDuplicates = true;
+ // duplicateIndices.push(i, j);
+ }
+ }
+ }
+
+ if (siDuplicates) {
+ // highlightDuplicates(duplicateIndices);
toastr.warning('Duplicates found!', 'warning');
return true;
} else {
@@ -1867,9 +1993,12 @@ function checkDuplicate(unique_id = null)
var ageFrom = container.find('input[name="4_age_from[]"]');
var ageTo = container.find('input[name="4_age_to[]"]');
+ var units = container.find('input[name="4_unit[]"]');
+
var ageFromValues = [];
var ageToValues = [];
+ var unitValues = [];
var ageDuplicates = false;
// Extract values from input arrays
@@ -1881,10 +2010,15 @@ function checkDuplicate(unique_id = null)
ageToValues.push($(this).val());
});
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
for (var i = 0; i < ageFromValues.length; i++) {
for (var j = i + 1; j < ageFromValues.length; j++) {
// Check for duplicates between age_from[] and age_to[]
- if (ageFromValues[i] === ageFromValues[j] && ageToValues[i] === ageToValues[j]) {
+ if (unitValues[i] === unitValues[j] && ageFromValues[i] === ageFromValues[j] && ageToValues[i] === ageToValues[j]) {
ageDuplicates = true;
}
}
@@ -1898,13 +2032,17 @@ function checkDuplicate(unique_id = null)
}
} else if (id.value === '5') {
+
var si = container.find('input[name="5_si[]"]');
var ageFrom = container.find('input[name="5_age_from[]"]');
var ageTo = container.find('input[name="5_age_to[]"]');
+ var units = container.find('input[name="5_unit[]"]');
+
var si_array = [];
var ageFrom_array = [];
var ageTo_array = [];
+ var unitValues = [];
var siDuplicates = false;
var ageDuplicates = false;
@@ -1920,10 +2058,14 @@ function checkDuplicate(unique_id = null)
ageTo_array.push($(this).val());
});
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
for (var i = 0; i < ageFrom_array.length; i++) {
for (var j = i + 1; j < ageFrom_array.length; j++) {
- if (ageFrom_array[i] === ageFrom_array[j] && ageTo_array[i] === ageTo_array[j] && si_array[i] ===
- si_array[j]) {
+ if (unitValues[i] === unitValues[j] && ageFrom_array[i] === ageFrom_array[j] && ageTo_array[i] === ageTo_array[j] && si_array[i] === si_array[j]) {
ageDuplicates = true;
}
}
@@ -1938,9 +2080,12 @@ function checkDuplicate(unique_id = null)
} else if (id.value === '6') {
var ageFrom = container.find('input[name="6_age_from[]"]');
var ageTo = container.find('input[name="6_age_to[]"]');
+ var units = container.find('input[name="6_unit[]"]');
+
var ageFromValues = [];
var ageToValues = [];
+ var unitValues = [];
var ageDuplicates = false;
// Extract values from input arrays
@@ -1952,10 +2097,15 @@ function checkDuplicate(unique_id = null)
ageToValues.push($(this).val());
});
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
for (var i = 0; i < ageFromValues.length; i++) {
for (var j = i + 1; j < ageFromValues.length; j++) {
// Check for duplicates between age_from[] and age_to[]
- if (ageFromValues[i] === ageFromValues[j] && ageToValues[i] === ageToValues[j]) {
+ if (unitValues[i] === unitValues[j] && ageFromValues[i] === ageFromValues[j] && ageToValues[i] === ageToValues[j]) {
ageDuplicates = true;
}
}
@@ -1971,10 +2121,13 @@ function checkDuplicate(unique_id = null)
var si = container.find('input[name="7_si[]"]');
var ageFrom = container.find('input[name="7_age_from[]"]');
var ageTo = container.find('input[name="7_age_to[]"]');
+ var units = container.find('input[name="7_unit[]"]');
+
var si_array = [];
var ageFrom_array = [];
var ageTo_array = [];
+ var unitValues = [];
var siDuplicates = false;
var ageDuplicates = false;
@@ -1990,9 +2143,14 @@ function checkDuplicate(unique_id = null)
ageTo_array.push($(this).val());
});
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
for (var i = 0; i < ageFrom_array.length; i++) {
for (var j = i + 1; j < ageFrom_array.length; j++) {
- if (ageFrom_array[i] === ageFrom_array[j] && ageTo_array[i] === ageTo_array[j] && si_array[i] ===
+ if (unitValues[i] === unitValues[j] && ageFrom_array[i] === ageFrom_array[j] && ageTo_array[i] === ageTo_array[j] && si_array[i] ===
si_array[j]) {
ageDuplicates = true;
}
@@ -2005,14 +2163,17 @@ function checkDuplicate(unique_id = null)
} else {
return false;
}
- } else if (id.value === '10') {
+ } else if (id.value === '10'){
var si = container.find('input[name="10_si[]"]');
var ageFrom = container.find('input[name="10_age_from[]"]');
var ageTo = container.find('input[name="10_age_to[]"]');
+ var units = container.find('input[name="10_unit[]"]');
+
var si_array = [];
var ageFrom_array = [];
var ageTo_array = [];
+ var unitValues = [];
var siDuplicates = false;
var ageDuplicates = false;
@@ -2028,9 +2189,14 @@ function checkDuplicate(unique_id = null)
ageTo_array.push($(this).val());
});
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
for (var i = 0; i < ageFrom_array.length; i++) {
for (var j = i + 1; j < ageFrom_array.length; j++) {
- if (ageFrom_array[i] === ageFrom_array[j] && ageTo_array[i] === ageTo_array[j] && si_array[i] ===
+ if (unitValues[i] === unitValues[j] && ageFrom_array[i] === ageFrom_array[j] && ageTo_array[i] === ageTo_array[j] && si_array[i] ===
si_array[j]) {
ageDuplicates = true;
}
@@ -2047,9 +2213,12 @@ function checkDuplicate(unique_id = null)
} else if (id.value === '8') {
var siInputs = container.find('input[name="8_si[]"]');
var gradeInputs = container.find('input[name="8_grade[]"]');
+ var units = container.find('input[name="8_unit[]"]');
+
var siValues = [];
var gradeValues = [];
+ var unitValues = [];
var duplicatesFound = false;
// Extract values from input arrays
@@ -2061,10 +2230,15 @@ function checkDuplicate(unique_id = null)
gradeValues.push($(this).val());
});
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
for (var i = 0; i < siValues.length; i++) {
for (var j = i + 1; j < siValues.length; j++) {
// Check for duplicates between si[] and grade[]
- if (siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j]) {
+ if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j]) {
duplicatesFound = true;
}
}
@@ -2076,46 +2250,18 @@ function checkDuplicate(unique_id = null)
} else {
return false;
}
- } else if (id.value === '9') {
- var siInputs = container.find('input[name="9_si[]"]');
- var gradeInputs = container.find('input[name="9_grade[]"]');
+ } else if (id.value === '11'){
- var siValues = [];
- var gradeValues = [];
- var duplicatesFound = false;
-
- // Extract values from input arrays
- siInputs.each(function() {
- siValues.push($(this).val());
- });
-
- gradeInputs.each(function() {
- gradeValues.push($(this).val());
- });
-
- for (var i = 0; i < siValues.length; i++) {
- for (var j = i + 1; j < siValues.length; j++) {
- // Check for duplicates between si[] and grade[]
- if (siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j]) {
- duplicatesFound = true;
- }
- }
- }
-
- if (duplicatesFound) {
- toastr.warning('Duplicates found!', 'warning');
- return true;
- } else {
- return false;
- }
- } else if (id.value === '11') {
var siInputs = container.find('input[name="11_si[]"]');
var gradeInputs = container.find('input[name="11_grade[]"]');
var maxSiInputs = container.find('input[name="11_max_si[]"]');
+ var units = container.find('input[name="11_unit[]"]');
+
var siValues = [];
var gradeValues = [];
var maxSiValues = [];
+ var unitValues = [];
var duplicatesFound = false;
// Extract values from input arrays
@@ -2131,12 +2277,17 @@ function checkDuplicate(unique_id = null)
maxSiValues.push($(this).val());
});
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
for (var i = 0; i < siValues.length; i++) {
for (var j = i + 1; j < siValues.length; j++) {
// //console.log(maxSiValues);
// //console.log("maxSiValues[i] ", maxSiValues[i] );
// //console.log("maxSiValues[j]", maxSiValues[j]);
- if (siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j] && maxSiValues[i] === maxSiValues[
+ if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j] && gradeValues[i] === gradeValues[j] && maxSiValues[i] === maxSiValues[
j]) {
duplicatesFound = true;
}
@@ -2149,42 +2300,133 @@ function checkDuplicate(unique_id = null)
} else {
return false;
}
- } else if (id.value === '1') {
+ } else if (id.value === '12'){
+
+ var siInputs = container.find('input[name="12_si[]"]');
+ var relationship = container.find('input[name="12_relationship[]"]');
+ var units = container.find('input[name="12_unit[]"]');
+
+ var siValues = [];
+ var relationshipValue = [];
+ var unitValues = [];
+ var duplicatesFound = false;
+
+ // Extract values from input arrays
+ siInputs.each(function() {
+ siValues.push($(this).val());
+ });
+
+ relationship.each(function() {
+ relationshipValue.push($(this).val());
+ });
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ for (var i = 0; i < siValues.length; i++) {
+ for (var j = i + 1; j < siValues.length; j++) {
+ if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j] && relationshipValue[i] === relationshipValue[j]) {
+ duplicatesFound = true;
+ }
+ }
+ }
+
+ if (duplicatesFound) {
+ toastr.warning('Duplicates found!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+ } else if (id.value === '13'){
+
+ var siInputs = container.find('input[name="13_si[]"]');
+ var relationship = container.find('input[name="13_relationship[]"]');
+ var units = container.find('input[name="13_unit[]"]');
+ var ageFrom = container.find('input[name="13_age_from[]"]');
+ var ageTo = container.find('input[name="13_age_to[]"]');
+
+
+ var siValues = [];
+ var relationshipValue = [];
+ var unitValues = [];
+ var fromAgeValue = [];
+ var toAgeValue = [];
+ var duplicatesFound = false;
+
+ // Extract values from input arrays
+ siInputs.each(function() {
+ siValues.push($(this).val());
+ });
+
+ relationship.each(function() {
+ relationshipValue.push($(this).val());
+ });
+
+ ageFrom.each(function() {
+ fromAgeValue.push($(this).val());
+ });
+
+ ageTo.each(function() {
+ toAgeValue.push($(this).val());
+ });
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ for (var i = 0; i < siValues.length; i++) {
+ for (var j = i + 1; j < siValues.length; j++) {
+ if (unitValues[i] === unitValues[j] &&
+ siValues[i] === siValues[j] &&
+ relationshipValue[i] === relationshipValue[j] &&
+ fromAgeValue[i] === fromAgeValue[j] &&
+ toAgeValue[i] === toAgeValue[j]
+ ) {
+ duplicatesFound = true;
+ }
+ }
+ }
+
+ if (duplicatesFound) {
+ toastr.warning('Duplicates found!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+ } else if (id.value === '1'){
var selectedValue = $('#si_or_bp').val();
if (selectedValue == 1) {
var siInputs = container.find('input[name="gpa_sum_si[]"]');
- var premiumInputs = container.find('input[name="gpa_sum_premium[]"]');
+ var units = container.find('input[name="gpa_unit_1[]"]');
var siValues = [];
- var premiumValues = [];
+ var unitValues = [];
var siDuplicates = false;
- var premiumDuplicates = false;
// Extract values from input arrays
siInputs.each(function() {
siValues.push($(this).val());
});
- premiumInputs.each(function() {
- premiumValues.push($(this).val());
+ units.each(function() {
+ unitValues.push($(this).val());
});
for (var i = 0; i < siValues.length; i++) {
for (var j = i + 1; j < siValues.length; j++) {
- if (siValues[i] === siValues[j]) {
+ if (unitValues[i] === unitValues[j] && siValues[i] === siValues[j]) {
siDuplicates = true;
}
}
}
- // //console.log('siValues', siValues);
- // //console.log('premiumValues', premiumValues);
- // //console.log('siDuplicates', siDuplicates);
- // //console.log('premiumDuplicates', premiumDuplicates);
- if (siDuplicates || premiumDuplicates) {
+ if (siDuplicates) {
toastr.warning('Duplicates found!', 'warning');
return true;
} else {
@@ -2194,53 +2436,38 @@ function checkDuplicate(unique_id = null)
} else if (selectedValue == 3) {
var siInputs = container.find('input[name="gpa_sum_si2[]"]');
- var premiumInputs = container.find('input[name="gpa_sum_premium2[]"]');
var bandInputs = container.find('input[name="gpa_band[]"]');
+ var units = container.find('input[name="gpa_unit_3[]"]');
var siValues = [];
- var premiumValues = [];
var bandValues = [];
+ var unitValues = [];
var siDuplicates = false;
- var premiumDuplicates = false;
- var bandDuplicates = false;
+
// Extract values from input arrays
siInputs.each(function() {
siValues.push($(this).val());
});
- premiumInputs.each(function() {
- premiumValues.push($(this).val());
- });
-
bandInputs.each(function() {
bandValues.push($(this).val());
});
+ units.each(function() {
+ unitValues.push($(this).val());
+ });
+
for (var i = 0; i < siValues.length; i++) {
for (var j = i + 1; j < siValues.length; j++) {
- if (siValues[i] === siValues[j]) {
+ if (unitValues[j] === unitValues[j] && siValues[i] === siValues[j] && bandValues[i] === bandValues[j]) {
siDuplicates = true;
}
}
}
- for (var i = 0; i < bandValues.length; i++) {
- for (var j = i + 1; j < bandValues.length; j++) {
- if (bandValues[i] === bandValues[j]) {
- bandDuplicates = true;
- }
- }
- }
- // //console.log('siValues', siValues);
- // //console.log('premiumValues', premiumValues);
- // //console.log('bandValues', bandValues);
- // //console.log('siDuplicates', siDuplicates);
- // //console.log('premiumDuplicates', premiumDuplicates);
- // //console.log('bandDuplicates', bandDuplicates);
-
- if (siDuplicates || bandDuplicates || premiumDuplicates) {
+ if (siDuplicates) {
toastr.warning('Duplicates found!', 'warning');
return true;
} else {
@@ -2432,19 +2659,21 @@ function si_orbp_change_function()
$('#gpa_sum_multiplier').removeAttr('required', false);
$('#gpa_sum_si').removeAttr('required', false);
$('#gpa_sum_premium').removeAttr('required', false);
+ $('#gpa_unit1').removeAttr('required', false);
$('#gpa_sum_multiplier2').removeAttr('required', false);
$('#gpa_sum_si2').removeAttr('required', false);
$('#gpa_band').removeAttr('required', false);
$('#gpa_sum_premium2').removeAttr('required', false);
+ $('#gpa_unit3').removeAttr('required', false);
-
-
+
$('#basic_multiplier').attr('required', true);
$('#premium_multiplier').attr('required', true);
$('#basic_pay').attr('required', true);
$('#gpa_basic_si').attr('required', true);
$('#gpa_basic_premium').attr('required', true);
+ $('#gpa_unit2').attr('required', true);
var gridContentInput = $('#grid_content_input');
@@ -2497,16 +2726,20 @@ function si_orbp_change_function()
$('#basic_pay').removeAttr('required', false);
$('#gpa_basic_si_first').removeAttr('required', false);
$('#gpa_basic_premium_first').removeAttr('required', false);
+ $('#gpa_unit2').removeAttr('required', false);
+
$('#gpa_sum_multiplier2').removeAttr('required', false);
$('#gpa_sum_si2').removeAttr('required', false);
$('#gpa_band').removeAttr('required', false);
$('#gpa_sum_premium2').removeAttr('required', false);
+ $('#gpa_unit3').removeAttr('required', false);
$('#gpa_sum_multiplier').attr('required', true);
$('#gpa_sum_si').attr('required', true);
$('#gpa_sum_premium').attr('required', true);
+ $('#gpa_unit1').attr('required', true);
var gridContentInput = $('#grid_content_input');
@@ -2549,15 +2782,18 @@ function si_orbp_change_function()
$('#basic_pay').removeAttr('required', false);
$('#gpa_basic_si_first').removeAttr('required', false);
$('#gpa_basic_premium_first').removeAttr('required', false);
+ $('#gpa_unit2').removeAttr('required', false);
$('#gpa_sum_multiplier').attr('required', false);
$('#gpa_sum_si').attr('required');
$('#gpa_sum_premium').attr('required');
+ $('#gpa_unit1').removeAttr('required', false);
$('#gpa_sum_multiplier2').removeAttr('required', true);
$('#gpa_sum_si2').removeAttr('required', true);
$('#gpa_band').removeAttr('required', true);
$('#gpa_sum_premium2').removeAttr('required', true);
+ $('#gpa_unit3').removeAttr('required', true);
var gridContentInput = $('#grid_content_input');
@@ -2776,10 +3012,55 @@ function createCheckboxes(obj, additional_relationship = [], unique_id = null, p
$relationshipElement.append(html);
- if(policy_type == 1 || policy_type == 6 || policy_type == 7){
-
+ if(policy_type == 1 || policy_type == 6 || policy_type == 7)
+ {
$('.radio-group .form-check').css('margin-right', '-50px');
}
+
+
+ if (obj['self'] > 0 && obj['spouse'] == 0 && obj['childrens'] == 0 && obj['parents'] == 0 && obj['parents-in-law'] == 0) {
+ $('.radio-group .form-check').css('margin-right', '-50px');
+ } else if (obj['self'] == 0 && obj['spouse'] > 0 && obj['childrens'] == 0 && obj['parents'] == 0 && obj['parents-in-law'] == 0) {
+ $('.radio-group .form-check').css('margin-right', '-50px');
+ } else if (obj['self'] == 0 && obj['spouse'] == 0 && obj['childrens'] > 0 && obj['parents'] == 0 && obj['parents-in-law'] == 0) {
+ $('.radio-group .form-check').css('margin-right', '-40px');
+ } else if (obj['self'] == 0 && obj['spouse'] == 0 && obj['childrens'] == 0 && obj['parents'] > 0 && obj['parents-in-law'] == 0) {
+ $('.radio-group .form-check').css('margin-right', '-30px');
+ } else if (obj['self'] == 0 && obj['spouse'] == 0 && obj['childrens'] == 0 && obj['parents'] == 0 && obj['parents-in-law'] > 0) {
+ $('.radio-group .form-check').css('margin-right', '-20px');
+ } else if (obj['self'] > 0 && obj['spouse'] > 0 && obj['childrens'] == 0 && obj['parents'] == 0 && obj['parents-in-law'] == 0) {
+ $('.radio-group .form-check').css('margin-right', '-10px');
+ } else if (obj['self'] > 0 && obj['spouse'] == 0 && obj['childrens'] > 0 && obj['parents'] == 0 && obj['parents-in-law'] == 0) {
+ $('.radio-group .form-check').css('margin-right', '-5px');
+ } else if (obj['self'] > 0 && obj['spouse'] == 0 && obj['childrens'] == 0 && obj['parents'] > 0 && obj['parents-in-law'] == 0) {
+ $('.radio-group .form-check').css('margin-right', '-15px');
+ } else if (obj['self'] > 0 && obj['spouse'] == 0 && obj['childrens'] == 0 && obj['parents'] == 0 && obj['parents-in-law'] > 0) {
+ $('.radio-group .form-check').css('margin-right', '-25px');
+ } else if (obj['self'] == 0 && obj['spouse'] > 0 && obj['childrens'] > 0 && obj['parents'] == 0 && obj['parents-in-law'] == 0) {
+ $('.radio-group .form-check').css('margin-right', '-35px');
+ } else if (obj['self'] == 0 && obj['spouse'] > 0 && obj['childrens'] == 0 && obj['parents'] > 0 && obj['parents-in-law'] == 0) {
+ $('.radio-group .form-check').css('margin-right', '-45px');
+ } else if (obj['self'] == 0 && obj['spouse'] > 0 && obj['childrens'] == 0 && obj['parents'] == 0 && obj['parents-in-law'] > 0) {
+ $('.radio-group .form-check').css('margin-right', '-55px');
+ } else if (obj['self'] == 0 && obj['spouse'] == 0 && obj['childrens'] > 0 && obj['parents'] > 0 && obj['parents-in-law'] == 0) {
+ $('.radio-group .form-check').css('margin-right', '-65px');
+ } else if (obj['self'] == 0 && obj['spouse'] == 0 && obj['childrens'] > 0 && obj['parents'] == 0 && obj['parents-in-law'] > 0) {
+ $('.radio-group .form-check').css('margin-right', '-75px');
+ } else if (obj['self'] == 0 && obj['spouse'] == 0 && obj['childrens'] == 0 && obj['parents'] > 0 && obj['parents-in-law'] > 0) {
+ $('.radio-group .form-check').css('margin-right', '-85px');
+ } else if (obj['self'] > 0 && obj['spouse'] > 0 && obj['childrens'] == 0 && obj['parents'] > 0 && obj['parents-in-law'] > 0){
+ $('.radio-group .form-check').css('margin-right', '-60px');
+ } else {
+ // Add more else if combinations as needed or handle default case here
+ }
+
+
+ // if (obj['self'] > 0 && obj['spouse'] > 0 && obj['childrens'] == 0 && obj['parents'] > 0 && obj['parents-in-law'] > 0)
+ // {
+ // $('.radio-group .form-check').css('margin-right', '-60px');
+ // }
+
+
}
function formatString(str)
@@ -2996,7 +3277,7 @@ function appendNewTab(tabNameData = null, data = null)
newTabLink.classList.add('nav-link', 'nav-link', 'px-3', 'py-2');
newTabLink.setAttribute('data-toggle', 'tab');
newTabLink.setAttribute('href', `#${tabId}`);
- newSpan.setAttribute('id', `link_${tabId}`);
+ // newTabLink.setAttribute('id', `link_${tabId}`);
// newTabLink.textContent = tabName;
newTabLink.appendChild(newSpan);
@@ -3017,7 +3298,7 @@ function appendNewTab(tabNameData = null, data = null)
-
+
@@ -3065,7 +3346,7 @@ function appendNewTab(tabNameData = null, data = null)
`;
tabContent.appendChild(newTabPane);
@@ -3099,6 +3380,16 @@ function appendNewTab(tabNameData = null, data = null)
appendGridtHtml(item.policy_grid_id, tabId, item);
});
+
+ $(`input[name="${policy_grid_id}_si[]"]`).each(function() {
+ // console.log(first+'_si[]', $(this));
+ $(this).trigger('keyup');
+ });
+
+ $(`input[name="${policy_grid_id}_premium[]"]`).each(function() {
+ // console.log(first+"_premium[]", $(this));
+ $(this).trigger('keyup');
+ });
}
appendGridData(rack_rate_array, policy_grid_id, tabId);
@@ -3211,55 +3502,55 @@ function removeTab(input, tabID, tabName)
$('.loader-mask').fadeIn();
var form_action = '= base_url("util/remove_rack_rate/") ?>' + tabName + '/' + client_policy_id;
- console.log(form_action)
- $.ajax({
- url: form_action,
- type: "GET",
- dataType: 'json',
- processData: false,
- contentType: false,
- success: function(res) {
-
- $('.loader').fadeOut();
- $('.loader-mask').delay(350).fadeOut('slow');
+ console.log(form_action)
+ $.ajax({
+ url: form_action,
+ type: "GET",
+ dataType: 'json',
+ processData: false,
+ contentType: false,
+ success: function(res) {
+
+ $('.loader').fadeOut();
+ $('.loader-mask').delay(350).fadeOut('slow');
- console.log(res)
+ console.log(res)
- if(res){
- if (res.status == true) {
+ if(res){
+ if (res.status == true) {
+ Swal.fire({
+ title: "Success",
+ text: res.message,
+ icon: "success"
+ });
+ // toastr.success('Policy removed successfully.', 'success');
+ } else {
+ if(res.rr_count > 0){
+ Swal.fire({
+ title: "warning!",
+ text: res.message,
+ icon: "warning"
+ });
+ }else{
Swal.fire({
title: "Success",
- text: res.message,
+ text: 'Rack Rate removed successfully',
icon: "success"
});
- // toastr.success('Policy removed successfully.', 'success');
- } else {
- if(res.rr_count > 0){
- Swal.fire({
- title: "warning!",
- text: res.message,
- icon: "warning"
- });
- }else{
- Swal.fire({
- title: "Success",
- text: 'Rack Rate removed successfully',
- icon: "success"
- });
- }
+ }
- // toastr.warning('Failed to remove policy', 'warning');
- }
- }
- },
- error: function (xhr, status, error) {
- console.error(xhr.responseText);
- console.error(status, error);
- $('.loader').fadeOut();
- $('.loader-mask').delay(350).fadeOut('slow');
- console.log('Something Wrong!', 'warning');
+ // toastr.warning('Failed to remove policy', 'warning');
}
- });
+ }
+ },
+ error: function (xhr, status, error) {
+ console.error(xhr.responseText);
+ console.error(status, error);
+ $('.loader').fadeOut();
+ $('.loader-mask').delay(350).fadeOut('slow');
+ console.log('Something Wrong!', 'warning');
+ }
+ });
}
});
@@ -3280,7 +3571,7 @@ function copyFromExcel(input, unique_id = null)
}
if ($(input).text() == "Copy from excel") {
- $(input).text("Manual entry")
+ $(input).text("Manual entry");
} else {
$(input).text("Copy from excel");
@@ -3291,24 +3582,94 @@ function copyFromExcel(input, unique_id = null)
}
-function renameRackRateTab(input)
-{
- console.log(input)
- console.log(input.id)
- var newTabName = prompt('Enter rack rate name:')
- console.log(newTabName)
- secondaryValue = '';
- if(input.id){
- var unique_id = input.id.split('_');
- if (unique_id.length > 1) {
- secondaryValue = unique_id[1];
- }
- }
- console.log(secondaryValue)
- var tabid = 'tabname_' + secondaryValue;
- console.log(tabid)
+function renameRackRateTab(input, unique_id = null, tabName = null)
+{
- $('#'+tabid).text(newTabName)
+ var client_policy_id = $('#client_policy_id').val();
+
+ var tabid = 'tabname' ;
+ if(unique_id){
+ tabid = 'tabname_' + unique_id
+ client_policy_id = $('#client_policy_id_'+unique_id).val();
+ }
+
+ if(tabName == null){
+ tabName = $('#rack_rate_name').val();
+ }
+
+ var newTabName = prompt('Enter rack rate name:')
+
+
+ console.log('renameRackRateTab function input', input);
+ console.log('renameRackRateTab function unique_id', unique_id);
+ console.log('renameRackRateTab function tabName', tabName);
+ console.log('renameRackRateTab function client_policy_id', client_policy_id);
+ console.log('renameRackRateTab function tabid', tabid);
+ console.log('renameRackRateTab function newTabName',newTabName);
+
+ if(newTabName){
+
+ $('#'+tabid).text(newTabName);
+ $('.loader').fadeIn();
+ $('.loader-mask').fadeIn();
+
+ var form_action = '= base_url("util/rename_rack_rate_tab/") ?>' + tabName + '/'+ newTabName + '/' + client_policy_id;
+ console.log(form_action)
+ $.ajax({
+ url: form_action,
+ type: "GET",
+ dataType: 'json',
+ processData: false,
+ contentType: false,
+ success: function(res) {
+
+ $('.loader').fadeOut();
+ $('.loader-mask').delay(350).fadeOut('slow');
+
+ console.log(res)
+
+ if(res){
+ if (res.status == true) {
+ Swal.fire({
+ title: "Success",
+ text: res.message,
+ icon: "success"
+ });
+
+ $('#rack_rate_name').val(newTabName);
+
+ // toastr.success('Policy removed successfully.', 'success');
+ } else {
+ if(res.rr_count > 0){
+ Swal.fire({
+ title: "warning!",
+ text: res.message,
+ icon: "warning"
+ });
+ }else{
+ Swal.fire({
+ title: "Success",
+ text: 'Rack Rate renamed successfully',
+ icon: "success"
+ });
+
+ $('#rack_rate_name').val(newTabName);
+
+ }
+
+ // toastr.warning('Failed to remove policy', 'warning');
+ }
+ }
+ },
+ error: function (xhr, status, error) {
+ console.error(xhr.responseText);
+ console.error(status, error);
+ $('.loader').fadeOut();
+ $('.loader-mask').delay(350).fadeOut('slow');
+ console.log('Something Wrong!', 'warning');
+ }
+ });
+ }
}
function groupByRackRateName(data)
@@ -3376,35 +3737,106 @@ function editPolicyPremiumCalculationSetValue(premium_type, unique_id = null)
}
-function checkFamiliFloatersKeysDuplicate(rarc_rate_json_array, formObject)
+function checkFamiliFloatersKeysDuplicate(rarc_rate_json_array, formObject, unique_id = null)
{
+ console.log('unique_id', unique_id);
+
+ console.log('rarc_rate_json_array', rarc_rate_json_array);
+ console.log('formObject', formObject);
+
console.log('rarc_rate_json_array length', rarc_rate_json_array.length);
+ console.log('formObject length', formObject.length);
+
console.log('formObject type', typeof formObject);
+ console.log('rarc_rate_json_array type', typeof rarc_rate_json_array);
+
+ var rack_rate_name = $('#rack_rate_name').val();
+
+ var grid_id = $('#grid').val();
+
+ if(unique_id != null && unique_id != ''){
+ rack_rate_name = $('#rack_rate_name_'+unique_id).val()
+ grid_id = $('#grid_'+unique_id).val();
+ }
+
+ console.log('rack rate name', rack_rate_name)
+ console.log('grid_id', grid_id)
+
+ if(grid_id != '1' || grid_id != '2'){
+
+ return false;
+
+ }
let isEqualto = false;
- if (rarc_rate_json_array.length > 0) {
- console.log('rarc_rate_json_array length', rarc_rate_json_array.length);
- $.each(rarc_rate_json_array, function(index, item){
+ if (rarc_rate_json_array.length > 0) {
+ $.each(rarc_rate_json_array, function(index, item) {
- item = JSON.parse(item);
- if(formObject['self'] == item['self'] && formObject['spouse'] == item['spouse'] && formObject['childrens'] == item['childrens'] && formObject['parents'] == item['parents'] && formObject['parents-in-law'] == item['parents-in-law']){
- console.log('true');
- isEqualto = true;
- return false;
- }else{
- console.log('false');
- isEqualto = false;
- }
- });
- }
+ let parsedItem;
+
+ if (typeof item === 'string') {
+ try {
+ // Attempt to parse the string as JSON
+ parsedItem = JSON.parse(item);
+ } catch (error) {
+ console.error('Invalid JSON string:', error);
+ parsedItem = null; // Handle as needed, or keep null
+ }
+ } else if (typeof item === 'object' && item !== null) {
+ // If it's already an object, no need to parse
+ parsedItem = item;
+ } else {
+ // Handle other types (e.g., undefined, null, numbers, etc.)
+ console.error('Item is not a valid JSON string or object:', item);
+ parsedItem = null; // Handle as needed, or keep null
+ }
+
+ console.log('Parsed item:', parsedItem);
+
+ let rackRateName = Object.keys(parsedItem)[0]; // Assuming single key per item
+ let rrItem = parsedItem[rackRateName];
+
+ // console.log('rarc_rate_json_array item', item);
+ // console.log('rarc_rate_json_array parsedItem', parsedItem);
+ // console.log('rackRateName', rackRateName);
+ // console.log('formObject', formObject);
+
+ // console.log('formObject type', typeof formObject);
+ // console.log('rarc_rate_json_array item type', typeof item);
+ // console.log('rarc_rate_json_array parsedItem type', typeof parsedItem);
+
+ // console.log('self', 'formobject : ', formObject['self'], 'rr_item : ', rrItem['self']);
+ // console.log('spouse', 'formobject : ', formObject['spouse'], 'rr_item : ', rrItem['spouse']);
+ // console.log('childrens', 'formobject : ', formObject['childrens'], 'rr_item : ', rrItem['childrens']);
+ // console.log('parents', 'formobject : ', formObject['parents'], 'rr_item : ', rrItem['parents']);
+ // console.log('parents-in-law', 'formobject : ', formObject['parents-in-law'], 'rr_item : ', rrItem['parents-in-law']);
+
+ if(rack_rate_name != rackRateName){
+
+ if (formObject['self'] == rrItem['self'] &&
+ formObject['spouse'] == rrItem['spouse'] &&
+ formObject['childrens'] == rrItem['childrens'] &&
+ formObject['parents'] == rrItem['parents'] &&
+ formObject['parents-in-law'] == rrItem['parents-in-law']) {
+ console.log('true');
+ isEqualto = true;
+ return false; // breaks out of the loop
+ } else {
+ console.log('false');
+ isEqualto = false;
+ }
+ }else{
+ console.log('false');
+ isEqualto = false;
+ }
+ });
+ }
return isEqualto;
-
}
-
function appendFourthAndSixthRackRate(data = null, uniqueId = null)
{
console.log('appendFourthAndSixthRackRate function called');
@@ -3458,4 +3890,402 @@ function appendFourthAndSixthRackRate(data = null, uniqueId = null)
$('.unitDiv').find('input').attr('required', true);
}
}
+
+function checkValideUnits(unique_id = null)
+{
+ console.log('checkValideUnits unique_id', unique_id)
+
+ var id = $('#grid')[0];
+ var container = $('#grid_content_input');
+
+ if (unique_id) {
+ id = $('#grid_'+unique_id)[0];
+ container = $('#grid_content_input_for_additional_'+unique_id);
+ }
+
+ console.log('checkValideUnits id', id);
+ console.log('checkValideUnits container', container);
+
+ if (id.value === '3') {
+
+ var units = container.find('input[name="3_unit[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+ } else if (id.value === '4') {
+
+ var units = container.find('input[name="4_unit[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ } else if (id.value === '2' || id.value === '9') {
+
+ var units = container.find('input[name="gpa_unit29[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ } else if (id.value === '5') {
+
+ var units = container.find('input[name="5_unit[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+
+ } else if (id.value === '6') {
+
+ var units = container.find('input[name="6_unit[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ } else if (id.value === '7') {
+
+ var units = container.find('input[name="7_unit[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units);
+ console.log('checkValideUnits function unitValues', unitValues);
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ } else if (id.value === '10') {
+
+ var units = container.find('input[name="10_unit[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ } else if (id.value === '8') {
+
+ var units = container.find('input[name="8_unit[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ } else if (id.value === '11') {
+
+ var units = container.find('input[name="11_unit[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ } else if (id.value === '12') {
+
+ var units = container.find('input[name="12_unit[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ } else if (id.value === '13') {
+
+ var units = container.find('input[name="13_unit[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ var value = $(this).val();
+ unitValues.push(value);
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ } else if (id.value === '1') {
+
+ var selectedValue = $('#si_or_bp').val();
+ if (selectedValue == 1) {
+
+ var units = container.find('input[name="gpa_unit_1[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ unitValues.push($(this).val());
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ } else if (selectedValue == 3) {
+
+ var units = container.find('input[name="gpa_unit_3[]"]');
+ var unitValues = [];
+
+ units.each(function() {
+ unitValues.push($(this).val());
+ });
+
+ console.log('checkValideUnits function branch_units', branch_units)
+ console.log('checkValideUnits function unitValues', unitValues)
+
+ var uncommonValues = [];
+ $.each(unitValues, function(index, value) {
+ if ($.inArray(value, branch_units) === -1) {
+ uncommonValues.push(value);
+ }
+ });
+
+ console.log('checkValideUnits function uncommonValues', uncommonValues);
+
+ if (uncommonValues.length > 0) {
+ toastr.warning('Given unit does not exist in the branch!', 'warning');
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+ }
+}
+
\ No newline at end of file
diff --git a/app/Views/policy_grid_excel.php b/app/Views/policy_grid_excel.php
index 1533ccc6..83a18775 100644
--- a/app/Views/policy_grid_excel.php
+++ b/app/Views/policy_grid_excel.php
@@ -36,91 +36,91 @@ const excel_headers = {
1: {
1: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
},
2: {
- "unit": "Units",
+ "unit": "Unit",
"basic_pay": "Basic Pay",
},
3: {
- "unit": "Units",
+ "unit": "Unit",
"band_or_grade": "Band or Grade",
"sum_insured": "Sum Insured",
}
},
2: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"premium": "Premium"
},
3: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"premium": "Premium"
},
4: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
5: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
6: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
7: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
8: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"grade": "Grade",
"premium": "Premium"
},
9: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"premium": "Premium"
},
10: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"from_age": "From Age",
"to_age": "To Age",
"premium": "Premium"
},
11: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"grade": "Grade",
"premium": "Premium",
"max_si": "Max Si"
},
12: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"relationship": "Relationship",
"premium": "Premium"
},
13: {
- "unit": "Units",
+ "unit": "Unit",
"sum_insured": "Sum Insured",
"relationship": "Relationship",
"from_age": "From Age",
@@ -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,22 +288,40 @@ 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');
+ }
- if (secondKey != 2) {
+ 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) {
+ console.log('expectedHeader' + secondKey + '-' + formatType);
+ 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: `
@@ -457,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');
@@ -473,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');
@@ -492,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');
@@ -550,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) {
@@ -569,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
+ }
}
}
});
@@ -578,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")
@@ -586,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 {
@@ -608,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() {
@@ -652,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();
+ });
+
}
diff --git a/app/Views/rack_rate_test.php b/app/Views/rack_rate_test.php
index 7573f21e..8036b1cf 100644
--- a/app/Views/rack_rate_test.php
+++ b/app/Views/rack_rate_test.php
@@ -78,10 +78,21 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="checkDependentConflict(event);" >Check Dependent conflict
" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="calculatePremium(event);" >calc premium
+
@@ -147,6 +158,34 @@
+
+
+
+
@@ -540,16 +579,31 @@
var policy_id = $('#policies').val();
var branch_id = $('#branch_id').val();
var unit_id = $('#unit_id').val();
+ var action = $('#action').val();
+ var emp_code = $('#emp_code').val();
console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select all values in dropdowns.');
return;
}
+ if (action == 'dependent_addition') {
+ if(emp_code.trim() == "")
+ {
+ alert('Enter emp code');
+ return;
+ }
+
+ }
+
+ // return;
var queryParams = {
client_id: client_id,
policy_id: policy_id,
branch_id: branch_id,
+ unit_id: unit_id,
+ action: action,
+ emp_code: emp_code,
data: tabledata,
};
@@ -577,8 +631,10 @@
displayData(response.data);
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
+ alert(response.messgae);
} else {
console.error('Something went wrong!');
+ alert('Something went wrong!');
}
},
error: function(xhr, status, error) {
@@ -659,8 +715,19 @@
function displayData(data)
{
- const tableBody = document.getElementById("restablebody");
- $("#restablebody").empty();
+ displayTable(data.new,"restablebody");
+ if(data.old.length())
+ {
+ $('#oldrestablebody').prop('display','block');
+ displayTable(data.new,"oldrestablebody");
+ }
+ }
+ function displayTable(data,tableID)
+ {
+
+ var old_data = data.old;
+ const tableBody = document.getElementById(tableID);
+ $(("#".tableID)).empty();
const existingRowCount = tableBody.rows.length;
for(i = 0; i < data.length; i++)
{