Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
6b34f4121e
@ -1165,21 +1165,24 @@ class ClientController extends AdminController
|
|||||||
$self = $policy_terms_data->family_floaters;
|
$self = $policy_terms_data->family_floaters;
|
||||||
}
|
}
|
||||||
|
|
||||||
$emp_count = $this->employeeModel->join('client_policy cp', "employees.client_id = cp.client_id")
|
// $emp_count = $this->employeeModel
|
||||||
->join('employee_polices ep', "cp.id = ep.client_policy_id AND employees.id = ep.employee_id")
|
// ->join('client_policy cp', "employees.client_id = cp.client_id")
|
||||||
->where("employees.client_id", $record['client_id'])
|
// ->join('employee_polices ep', "cp.id = ep.client_policy_id AND employees.id = ep.employee_id")
|
||||||
->where("employees.emp_status", 'active')
|
// ->where("employees.client_id", $record['client_id'])
|
||||||
->where("ep.status", 'active')
|
// ->where("employees.emp_status", 'active')
|
||||||
->where("employees.is_active", 1)
|
// ->where("ep.status", 'active')
|
||||||
->where("ep.is_active", 1)
|
// ->where("employees.is_active", 1)
|
||||||
|
// ->where("ep.is_active", 1)
|
||||||
|
// ->countAllResults();
|
||||||
|
|
||||||
|
|
||||||
|
$emp_count = $this->employeePolicyModel
|
||||||
|
->join('client_policy cp', "cp.id = employee_polices.client_policy_id")
|
||||||
|
->where("employee_polices.client_policy_id", $client_policy_id)
|
||||||
|
->where("employee_polices.status", 'active')
|
||||||
|
->where("employee_polices.is_active", 1)
|
||||||
->countAllResults();
|
->countAllResults();
|
||||||
|
|
||||||
|
|
||||||
// $data = $this->employeePolicyModel->select('employee_polices.id')
|
|
||||||
// ->where('employee_polices.is_active', 1)
|
|
||||||
// ->where('employee_polices.client_policy_id', $client_policy_id)
|
|
||||||
// ->findAll();
|
|
||||||
|
|
||||||
// $emp_count = count($data);
|
// $emp_count = count($data);
|
||||||
|
|
||||||
// if($emp_count == 0){
|
// if($emp_count == 0){
|
||||||
@ -1289,14 +1292,14 @@ class ClientController extends AdminController
|
|||||||
// print_r($premium1);
|
// print_r($premium1);
|
||||||
// print_r($premium2); die;
|
// print_r($premium2); die;
|
||||||
|
|
||||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200);
|
return $this->respond(['status' => true, 'code' => 200, 'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200);
|
||||||
|
|
||||||
} else if ($search_term === 'GPA') {
|
} else if ($search_term === 'GPA') {
|
||||||
|
|
||||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200);
|
return $this->respond(['status' => true, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return $this->respond(['status' => false, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200);
|
return $this->respond(['status' => false, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -84,10 +84,12 @@ class EmployeeRestController extends AdminController
|
|||||||
try {
|
try {
|
||||||
$emp_code = $this->request->getGet('emp_code');
|
$emp_code = $this->request->getGet('emp_code');
|
||||||
$client_id = $this->request->getGet('client_id');
|
$client_id = $this->request->getGet('client_id');
|
||||||
|
$client_branch_id = $this->request->getGet('client_branch_id');
|
||||||
if ($emp_code) {
|
if ($emp_code) {
|
||||||
$relationship = 'self';
|
$relationship = 'self';
|
||||||
$employee = $this->employeeModel->where('emp_code', $emp_code)
|
$employee = $this->employeeModel->where('emp_code', $emp_code)
|
||||||
->where('client_id', $client_id)
|
->where('client_id', $client_id)
|
||||||
|
->where('client_branch_id', $client_branch_id)
|
||||||
->where('is_active', 1 )
|
->where('is_active', 1 )
|
||||||
->where('relationship', $relationship)
|
->where('relationship', $relationship)
|
||||||
->first();
|
->first();
|
||||||
@ -102,7 +104,7 @@ class EmployeeRestController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//not in use
|
||||||
public function editEmployeeProfile()
|
public function editEmployeeProfile()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -125,7 +127,7 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//not in use
|
||||||
public function getEmployeeAndDependence()
|
public function getEmployeeAndDependence()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -152,7 +154,7 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//not in use
|
||||||
public function editEmployeeAndDependence()
|
public function editEmployeeAndDependence()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -372,6 +374,7 @@ class EmployeeRestController extends AdminController
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteDependence()
|
public function deleteDependence()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -400,11 +403,78 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the RelationShip list
|
||||||
|
public function createOrUpdateEmployeePolicySiAmount()
|
||||||
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
$requestData = $this->request->getJSON();
|
||||||
|
|
||||||
|
foreach ($requestData as $key => $value) {
|
||||||
|
|
||||||
|
|
||||||
|
$checkIfExist = $this->employeePolicyModel->where('employee_id', $value->employee_id)
|
||||||
|
->where('client_policy_id', $value->client_policy_id)
|
||||||
|
->where('is_active', 1 )
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
|
||||||
|
// dd($checkIfExist);
|
||||||
|
if ($checkIfExist) {
|
||||||
|
|
||||||
|
$empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$data['employee_id']= $value->employee_id;
|
||||||
|
$data['client_policy_id']= $value->client_policy_id;
|
||||||
|
$data['basic_cover_si']= $value->basic_cover_si;
|
||||||
|
$data['status'] = 'draft';
|
||||||
|
|
||||||
|
$this->employeePolicyModel->insert($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->updatePremiumAmount($requestData[0]->client_policy_id , $requestData[0]->emp_code);
|
||||||
|
|
||||||
|
return $this->respond(['status' => 'success','code' => 200,'data' => []], 200);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findPremiumAmount($slabArray,$siAmount)
|
||||||
|
{
|
||||||
|
foreach ($slabArray as $key => $value) {
|
||||||
|
if($value['si'] == $siAmount){
|
||||||
|
return $value['premium'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function relationshipList()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$relation_ships= $this->relationshipModel->findAll();
|
||||||
|
|
||||||
|
if(count($relation_ships) > 0){
|
||||||
|
return $this->respond(['status' => 'success','code' => 200,'data' => $relation_ships], 200);
|
||||||
|
}else{
|
||||||
|
return $this->respond(['status' => 'success','code' => 200,'data' => "No Data..!"], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getEmployeeAndDependenceByClientId()
|
public function getEmployeeAndDependenceByClientId()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0);
|
$empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0,branch_id:$this->request->getGet('client_branch_id'));
|
||||||
|
|
||||||
if ($empData) {
|
if ($empData) {
|
||||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200);
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200);
|
||||||
@ -419,11 +489,11 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function exportDataByClientPolicyId()
|
public function exportDataByClientPolicyId()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0);
|
|
||||||
|
$empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0,branch_id:$this->request->getGet('client_branch_id'));
|
||||||
|
|
||||||
if(count($empData))
|
if(count($empData))
|
||||||
{
|
{
|
||||||
@ -496,6 +566,7 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//not in use
|
||||||
public function getClientPolicy()
|
public function getClientPolicy()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -534,73 +605,7 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Get the RelationShip list
|
|
||||||
|
|
||||||
public function createOrUpdateEmployeePolicySiAmount()
|
|
||||||
{
|
|
||||||
|
|
||||||
try {
|
|
||||||
$requestData = $this->request->getJSON();
|
|
||||||
|
|
||||||
foreach ($requestData as $key => $value) {
|
|
||||||
|
|
||||||
|
|
||||||
$checkIfExist = $this->employeePolicyModel->where('employee_id', $value->employee_id)
|
|
||||||
->where('client_policy_id', $value->client_policy_id)
|
|
||||||
->where('is_active', 1 )
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
|
|
||||||
// dd($checkIfExist);
|
|
||||||
if ($checkIfExist) {
|
|
||||||
|
|
||||||
$empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
$data['employee_id']= $value->employee_id;
|
|
||||||
$data['client_policy_id']= $value->client_policy_id;
|
|
||||||
$data['basic_cover_si']= $value->basic_cover_si;
|
|
||||||
$data['status'] = 'draft';
|
|
||||||
|
|
||||||
$this->employeePolicyModel->insert($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->updatePremiumAmount($requestData[0]->client_policy_id , $requestData[0]->emp_code);
|
|
||||||
|
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => []], 200);
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findPremiumAmount($slabArray,$siAmount)
|
|
||||||
{
|
|
||||||
foreach ($slabArray as $key => $value) {
|
|
||||||
if($value['si'] == $siAmount){
|
|
||||||
return $value['premium'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public function relationshipList()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
|
|
||||||
$relation_ships= $this->relationshipModel->findAll();
|
|
||||||
|
|
||||||
if(count($relation_ships) > 0){
|
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => $relation_ships], 200);
|
|
||||||
}else{
|
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => "No Data..!"], 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Upload the Employee Detail in DB by Sheet Data
|
// Upload the Employee Detail in DB by Sheet Data
|
||||||
public function employeeUpload()
|
public function employeeUpload()
|
||||||
@ -614,6 +619,7 @@ class EmployeeRestController extends AdminController
|
|||||||
// die;
|
// die;
|
||||||
$file = $this->request->getFile('file');
|
$file = $this->request->getFile('file');
|
||||||
$client_id = $this->request->getPost('client_id');
|
$client_id = $this->request->getPost('client_id');
|
||||||
|
$client_branch_id = $this->request->getPost('client_branch_id');
|
||||||
$policy_id = $this->request->getPost('policy_id');
|
$policy_id = $this->request->getPost('policy_id');
|
||||||
|
|
||||||
$client_data = $this->clientModel->where('id', $client_id)->first();
|
$client_data = $this->clientModel->where('id', $client_id)->first();
|
||||||
@ -632,7 +638,7 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$client_policy = $this->clientPolicyModel->where('id', $policy_id)->where('client_id', $client_id)->first();
|
$client_policy = $this->clientPolicyModel->where('id', $policy_id)->where('client_id', $client_id)->where('client_branch_id', $client_branch_id)->first();
|
||||||
if ($client_policy) {
|
if ($client_policy) {
|
||||||
$policy = $this->policesModel->where('id', $client_policy['policy_id'])->first();
|
$policy = $this->policesModel->where('id', $client_policy['policy_id'])->first();
|
||||||
$policy_permium_1 = $this->policyPremium1Model->where(['client_id' => $client_id , 'client_policy_id' => $policy_id,'is_active' =>1])-> first();
|
$policy_permium_1 = $this->policyPremium1Model->where(['client_id' => $client_id , 'client_policy_id' => $policy_id,'is_active' =>1])-> first();
|
||||||
@ -666,6 +672,7 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
$extractData['file_name']= $filename;
|
$extractData['file_name']= $filename;
|
||||||
$extractData['client_id']= $client_id;
|
$extractData['client_id']= $client_id;
|
||||||
|
$extractData['client_branch_id']= $client_branch_id;
|
||||||
$extractData['status']= 'success';
|
$extractData['status']= 'success';
|
||||||
$extractData['policy_id']= $policy_id;
|
$extractData['policy_id']= $policy_id;
|
||||||
$extractData['action']= 'enrollment';
|
$extractData['action']= 'enrollment';
|
||||||
@ -928,13 +935,15 @@ public function getAgeRange($terms,$familyFloatesValue)
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmployeePolicy()
|
public function getEmployeePolicy()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$id = $this->request->getGet('id');
|
$id = $this->request->getGet('id');
|
||||||
$emp_code = $this->request->getGet('emp_code');
|
$emp_code = $this->request->getGet('emp_code');
|
||||||
$client_id = $this->request->getGet('client_id');
|
$client_id = $this->request->getGet('client_id');
|
||||||
|
$client_branch_id = $this->request->getGet('client_branch_id');
|
||||||
|
|
||||||
// This is an array containing keys to be removed from the terms and conditions array
|
// This is an array containing keys to be removed from the terms and conditions array
|
||||||
$keysToRemove = ["removable_keys"];
|
$keysToRemove = ["removable_keys"];
|
||||||
@ -942,8 +951,11 @@ public function getEmployeePolicy()
|
|||||||
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
|
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
|
||||||
|
|
||||||
// Retrieve employee and dependents data by passing the employee code
|
// Retrieve employee and dependents data by passing the employee code
|
||||||
$employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('client_id',$client_id)
|
$employeeData = $this->employeeModel->where('emp_code',$emp_code)
|
||||||
->where('is_active', 1 )->where('is_addon_value',0)->findAll();
|
->where('client_id',$client_id)
|
||||||
|
->where('client_branch_id',$client_branch_id)
|
||||||
|
->where('is_active', 1 )
|
||||||
|
->where('is_addon_value',0)->findAll();
|
||||||
|
|
||||||
|
|
||||||
if ($empPolicy) {
|
if ($empPolicy) {
|
||||||
@ -1091,12 +1103,13 @@ public function getEmployeePolicy()
|
|||||||
->where('client_policy.policy_type_id', 3 )
|
->where('client_policy.policy_type_id', 3 )
|
||||||
->where('client_policy.is_addon', 1 )
|
->where('client_policy.is_addon', 1 )
|
||||||
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
||||||
|
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') )
|
||||||
->where('client_policy.is_active', 1 )
|
->where('client_policy.is_active', 1 )
|
||||||
->get()
|
->get()
|
||||||
->getResult();
|
->getResult();
|
||||||
if($checkGmcParentsPolicyExist)
|
if($checkGmcParentsPolicyExist)
|
||||||
{
|
{
|
||||||
$GmcParrentsData = $this->getGmcParrentsPolicy($checkGmcParentsPolicyExist,$emp_code,$client_id);
|
$GmcParrentsData = $this->getGmcParrentsPolicy($checkGmcParentsPolicyExist,$emp_code,$client_id,$client_branch_id);
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => [$array,$GmcParrentsData]], 200);
|
return $this->respond(['status' => 'success','code' => 200,'data' => [$array,$GmcParrentsData]], 200);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1122,11 +1135,14 @@ public function getEmployeePolicy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id)
|
public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id,$client_branch_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
$employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('client_id',$client_id)
|
$employeeData = $this->employeeModel->where('emp_code',$emp_code)
|
||||||
->where('is_active', 1 )->where('is_addon_value',0)->findAll();
|
->where('client_id',$client_id)
|
||||||
|
->where('client_branch_id',$client_branch_id)
|
||||||
|
->where('is_active', 1 )
|
||||||
|
->where('is_addon_value',0)->findAll();
|
||||||
foreach ($GmcParrentsPolicy as $key => $array) {
|
foreach ($GmcParrentsPolicy as $key => $array) {
|
||||||
|
|
||||||
|
|
||||||
@ -1163,9 +1179,7 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id)
|
|||||||
$array->eCardDownload = null;
|
$array->eCardDownload = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if($array->tpa_id != null){
|
|
||||||
// $array->eCardDownload = base_url('download-e-card/') . $array->rand_string;
|
|
||||||
// }else{ $array->eCardDownload = null; }
|
|
||||||
$array->eCardDownload = null;
|
$array->eCardDownload = null;
|
||||||
|
|
||||||
// Map family floaters that already exist in the employee table
|
// Map family floaters that already exist in the employee table
|
||||||
@ -1256,6 +1270,7 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function FloterConvertion($array){
|
public function FloterConvertion($array){
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
@ -1320,7 +1335,8 @@ public function getClientDetails()
|
|||||||
$client = $this->clientModel->where('id',$this->request->getGet('client_id'))->first();
|
$client = $this->clientModel->where('id',$this->request->getGet('client_id'))->first();
|
||||||
if($client) {
|
if($client) {
|
||||||
$client['client_logo'] = base_url().'public/uploads/logo/'.$client['client_logo'];
|
$client['client_logo'] = base_url().'public/uploads/logo/'.$client['client_logo'];
|
||||||
$clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))->findAll();
|
$clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))
|
||||||
|
->where('client_branch_id',$this->request->getGet('client_branch_id'))->findAll();
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => ['client'=>$client,'client_policy'=>$clientPolicy]], 200);
|
return $this->respond(['status' => 'success','code' => 200,'data' => ['client'=>$client,'client_policy'=>$clientPolicy]], 200);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
@ -1335,17 +1351,22 @@ public function getAddOnPolicy()
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('is_addon_value',1)->findAll();
|
$addOnEmployeeData = $this->employeeModel->where('is_active', 1 )
|
||||||
|
->where('emp_code',$this->request->getGet('emp_code'))
|
||||||
|
->where('client_id',$this->request->getGet('client_id'))
|
||||||
|
->where('client_branch_id',$this->request->getGet('client_branch_id'))
|
||||||
|
->where('is_addon_value',1)->findAll();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))
|
$clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))
|
||||||
|
->where('client_branch_id',$this->request->getGet('client_branch_id'))
|
||||||
->where('policy_status', 1)
|
->where('policy_status', 1)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
if(count($clientPolicy))
|
if(count($clientPolicy))
|
||||||
{
|
{
|
||||||
$band = $addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('family_floater_key','self')->get()->getRow()->band;
|
$band = $addOnEmployeeData = $this->employeeModel->where('is_active', 1 )->where('emp_code',$this->request->getGet('emp_code'))->where('client_id',$this->request->getGet('client_id'))->where('client_branch_id',$this->request->getGet('client_branch_id'))->where('family_floater_key','self')->get()->getRow()->band;
|
||||||
$PolicyData = [];
|
$PolicyData = [];
|
||||||
foreach ($clientPolicy as $key => $array) {
|
foreach ($clientPolicy as $key => $array) {
|
||||||
$responce = [];
|
$responce = [];
|
||||||
@ -1768,6 +1789,7 @@ public function getCashDepositData()
|
|||||||
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.client_id as clientId , client_policy.insurer_id as insurerId,insurers.name as insurer_name')
|
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.client_id as clientId , client_policy.insurer_id as insurerId,insurers.name as insurer_name')
|
||||||
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
|
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
|
||||||
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
||||||
|
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') )
|
||||||
->where('client_policy.is_active', 1 )
|
->where('client_policy.is_active', 1 )
|
||||||
->where('client_policy.policy_status', 1)
|
->where('client_policy.policy_status', 1)
|
||||||
->groupBy('client_policy.insurer_id')
|
->groupBy('client_policy.insurer_id')
|
||||||
@ -1789,6 +1811,7 @@ public function getCashDepositData()
|
|||||||
->join('policies', 'client_policy.policy_id = policies.id', 'left')
|
->join('policies', 'client_policy.policy_id = policies.id', 'left')
|
||||||
->where('client_policy.insurer_id', $value['insurerId'] )
|
->where('client_policy.insurer_id', $value['insurerId'] )
|
||||||
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
||||||
|
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') )
|
||||||
->where('client_policy.is_active', 1 )
|
->where('client_policy.is_active', 1 )
|
||||||
->where('client_policy.policy_status', 1)
|
->where('client_policy.policy_status', 1)
|
||||||
->findAll();
|
->findAll();
|
||||||
@ -1797,7 +1820,7 @@ public function getCashDepositData()
|
|||||||
{
|
{
|
||||||
|
|
||||||
$value['type'] = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow()->policy_type;
|
$value['type'] = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow()->policy_type;
|
||||||
$employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0);
|
$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;
|
$enrolledCount = 0;
|
||||||
$draftCount = 0;
|
$draftCount = 0;
|
||||||
if(count($employeeDetails))
|
if(count($employeeDetails))
|
||||||
@ -1970,83 +1993,6 @@ public function removeEmpAndEmpPolicyData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getEmployeeOldPolicy()
|
|
||||||
{
|
|
||||||
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policies.name as policy_name , policy_type.policy_type as policy_type')
|
|
||||||
->join('policies', 'client_policy.policy_id = policies.id', 'left')
|
|
||||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
|
|
||||||
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
|
||||||
->where('client_policy.is_active', 1 )
|
|
||||||
->where('client_policy.policy_status', 0)
|
|
||||||
->orderby('client_policy.id' , 'ASC')
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
// Retrieve employee and dependents data by passing the employee code
|
|
||||||
$employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
|
||||||
->where('client_id',$this->request->getGet('client_id'))
|
|
||||||
->where('is_active', 1 )->findAll();
|
|
||||||
$whereArrayForId = [];
|
|
||||||
foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); }
|
|
||||||
|
|
||||||
if(count($ClientPolicyData) > 0 && count($employeeData) > 0)
|
|
||||||
{
|
|
||||||
$result = [];
|
|
||||||
foreach ($ClientPolicyData as $key => $ClientPolicyValue) {
|
|
||||||
|
|
||||||
$terms = json_decode($ClientPolicyValue['policy_terms']);
|
|
||||||
// dd($terms);
|
|
||||||
$data['client_id'] = $ClientPolicyValue['client_id'];
|
|
||||||
$data['client_policy_id'] = $ClientPolicyValue['id'];
|
|
||||||
$data['policy_name'] = $ClientPolicyValue['policy_name'];
|
|
||||||
$data['policy_type'] = $ClientPolicyValue['policy_type'];
|
|
||||||
$data['policy_type'] = $ClientPolicyValue['policy_type'];
|
|
||||||
$data['policy_start_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_start_date']);
|
|
||||||
$data['policy_end_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_end_date']);
|
|
||||||
|
|
||||||
if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else
|
|
||||||
if($ClientPolicyValue['policy_type_id'] == 2){ $data['heading'] = 'Group Medical Coverage'; }else
|
|
||||||
if($ClientPolicyValue['policy_type_id'] == 3){ $data['heading'] = 'Group Medical Coverage - Parents'; }else
|
|
||||||
if($ClientPolicyValue['policy_type_id'] == 4){ $data['heading'] = 'Group Medical Coverage - Top Up'; }else
|
|
||||||
if($ClientPolicyValue['policy_type_id'] == 5){ $data['heading'] = 'Group Medical Coverage - Parents (Top Up)'; }
|
|
||||||
|
|
||||||
if($ClientPolicyValue['policy_type_id'] == 1){ $data['floter_text_heading'] = 'Sum Insured'; }
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($terms->family_floater == 1){ $data['floter_text_heading'] = 'Floter Sum Insured'; }else{ $data['floter_text_heading'] = 'Sum Insured'; }
|
|
||||||
}
|
|
||||||
|
|
||||||
$employee_policy = $this->employeePolicyModel->select('employees.*,employee_polices.employee_id , employee_polices.basic_cover_si , employee_polices.premium , employee_polices.gst , employee_polices.tpa_id , employee_polices.rand_string')
|
|
||||||
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
|
|
||||||
->whereIn('employee_polices.employee_id',$whereArrayForId)
|
|
||||||
->where('employee_polices.client_policy_id',$ClientPolicyValue['id'])
|
|
||||||
->where('employee_polices.is_active', 1 )->findAll();
|
|
||||||
$si_value = 0;
|
|
||||||
$si_premium_value = 0;
|
|
||||||
$si_gst_value = 0;
|
|
||||||
foreach ($employee_policy as $key => $value) {
|
|
||||||
if(isset($value['basic_cover_si'])){ $si_value = $value['basic_cover_si']; }
|
|
||||||
if(isset($value['premium'])){ $si_premium_value = $si_premium_value + $value['premium'];}
|
|
||||||
if(isset($value['gst'])){ $si_gst_value = $si_gst_value + $value['gst'];}
|
|
||||||
}
|
|
||||||
|
|
||||||
$data['si_value'] = $si_value;
|
|
||||||
$data['si_premium_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : $si_premium_value;
|
|
||||||
$data['si_gst_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : $si_gst_value;
|
|
||||||
|
|
||||||
$data['EmployeePolicy'] = $employee_policy;
|
|
||||||
array_push($result, $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result ], 200);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEmployeeActiveOrInactivePolicy()
|
function getEmployeeActiveOrInactivePolicy()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -2055,6 +2001,7 @@ function getEmployeeActiveOrInactivePolicy()
|
|||||||
->join('policies', 'client_policy.policy_id = policies.id', 'left')
|
->join('policies', 'client_policy.policy_id = policies.id', 'left')
|
||||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
|
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
|
||||||
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
||||||
|
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') )
|
||||||
->where('client_policy.is_active', 1 )
|
->where('client_policy.is_active', 1 )
|
||||||
->where('client_policy.policy_status', $policy_status)
|
->where('client_policy.policy_status', $policy_status)
|
||||||
->orderby('client_policy.id' , 'ASC')
|
->orderby('client_policy.id' , 'ASC')
|
||||||
@ -2063,9 +2010,11 @@ function getEmployeeActiveOrInactivePolicy()
|
|||||||
// Retrieve employee and dependents data by passing the employee code
|
// Retrieve employee and dependents data by passing the employee code
|
||||||
$employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
$employeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
||||||
->where('client_id',$this->request->getGet('client_id'))
|
->where('client_id',$this->request->getGet('client_id'))
|
||||||
|
->where('client_branch_id',$this->request->getGet('client_branch_id'))
|
||||||
->where('is_active', 1 )->findAll();
|
->where('is_active', 1 )->findAll();
|
||||||
$employeeName = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
$employeeName = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
||||||
->where('client_id',$this->request->getGet('client_id'))
|
->where('client_id',$this->request->getGet('client_id'))
|
||||||
|
->where('client_branch_id',$this->request->getGet('client_branch_id'))
|
||||||
->where('family_floater_key','self')->where('is_active', 1 )
|
->where('family_floater_key','self')->where('is_active', 1 )
|
||||||
->get()->getRow()->name;
|
->get()->getRow()->name;
|
||||||
$whereArrayForId = [];
|
$whereArrayForId = [];
|
||||||
|
|||||||
@ -101,7 +101,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
$auth = HttpRequestHelper::getRequestInfo();
|
$auth = HttpRequestHelper::getRequestInfo();
|
||||||
if ($auth) {
|
if ($auth) {
|
||||||
$data = [
|
$data = [
|
||||||
'user_id' => $employeeData['id'],
|
'user_id' => $employeeData['id'],
|
||||||
'user_type' => 'employee',
|
'user_type' => 'employee',
|
||||||
'ip' => $auth['ip'],
|
'ip' => $auth['ip'],
|
||||||
'platform' => $auth['platform'],
|
'platform' => $auth['platform'],
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
<?php include('policy_grid_excel.php')?>
|
||||||
|
|
||||||
<!-- Modal content for the Large example -->
|
<!-- Modal content for the Large example -->
|
||||||
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
||||||
aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right: 15px">
|
aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right: 15px">
|
||||||
@ -71,11 +73,15 @@
|
|||||||
|
|
||||||
<div class="form-row" id="grid_content_input" style="display: true;">
|
<div class="form-row" id="grid_content_input" style="display: true;">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row" id="grid_content_from_excel" style="display: none;">
|
|
||||||
<?php include('policy_grid_excel.php')?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row" id="grid_content_input">
|
|
||||||
|
<div class="form-row" id="grid_content_from_excel" style="display: none;">
|
||||||
|
|
||||||
|
<p>Paste excel data here: <a href="#" type="button" onclick="copyHeaders(0)">Copy Excel Headers</a></p>
|
||||||
|
<textarea class="form-control excel_textarea" id="copied_excel_data" name="copied_excel_data" style="width:100%;height:200px;" oninput="generateTable(0)"></textarea><br>
|
||||||
|
<hr>
|
||||||
|
<div class="excel_table_class" id="excel_table" style="display: none;"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -121,16 +127,25 @@
|
|||||||
Insurance </label>
|
Insurance </label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-row" id="relationship">
|
<div class="form-row" id="relationship">
|
||||||
</div>
|
</div> <br>
|
||||||
|
|
||||||
|
<a href="#" id='copyfromexcelforadditional'>Copy from excel</a>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div class="form-row" id="additional_grid_content_input">
|
<div class="form-row" id="additional_grid_content_input" style="display: true;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row" id="additional_grid_content_from_excel" style="display: none;">
|
||||||
|
|
||||||
|
<p>Paste excel data here: <a href="#" type="button" onclick="copyHeaders(1)">Copy Excel Headers</a></p>
|
||||||
|
<textarea class="form-control excel_textarea" id="additional_copied_excel_data" name="additional_copied_excel_data" style="width:100%;height:200px;" oninput="generateTable(1)"></textarea><br>
|
||||||
|
<hr>
|
||||||
|
<div class="excel_table_class" id="additional_excel_table" style="display: none;"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -158,6 +173,26 @@ $('#btnGridSubmit').hide();
|
|||||||
|
|
||||||
$('.close').click(function() {
|
$('.close').click(function() {
|
||||||
|
|
||||||
|
$('#grid_content_input').show();
|
||||||
|
$('#grid_content_from_excel').hide();
|
||||||
|
|
||||||
|
if ($('#copyfromexcel').text() == "Manual entry") {
|
||||||
|
$('#copyfromexcel').text("Copy from excel")
|
||||||
|
} else {
|
||||||
|
$('#copyfromexcel').text("Copy from excel");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$('#additional_grid_content_input').show();
|
||||||
|
$('#additional_grid_content_from_excel').hide();
|
||||||
|
|
||||||
|
if ($('#copyfromexcelforadditional').text() == "Manual entry") {
|
||||||
|
$('#copyfromexcelforadditional').text("Copy from excel")
|
||||||
|
} else {
|
||||||
|
$('#copyfromexcelforadditional').text("Copy from excel");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for (var i = 1; i <= 13; i++) {
|
for (var i = 1; i <= 13; i++) {
|
||||||
$('#grid_' + i).remove();
|
$('#grid_' + i).remove();
|
||||||
$('#add_grid_' + i).remove();
|
$('#add_grid_' + i).remove();
|
||||||
@ -166,6 +201,7 @@ $('.close').click(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#copyfromexcel').click(function() {
|
$('#copyfromexcel').click(function() {
|
||||||
|
|
||||||
// alert('called');
|
// alert('called');
|
||||||
// $('#copyfromexcel').toggle();
|
// $('#copyfromexcel').toggle();
|
||||||
// $("#copied_excel_data").val(result.exampleMessage);
|
// $("#copied_excel_data").val(result.exampleMessage);
|
||||||
@ -182,6 +218,22 @@ $('#copyfromexcel').click(function() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#copyfromexcelforadditional').click(function() {
|
||||||
|
|
||||||
|
if ($(this).text() == "Copy from excel") {
|
||||||
|
$(this).text("Manual entry")
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$(this).text("Copy from excel");
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#additional_grid_content_input').toggle();
|
||||||
|
$('#additional_grid_content_from_excel').toggle();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = false, rr_type = false) {
|
function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = false, rr_type = false) {
|
||||||
@ -807,8 +859,7 @@ $("#GridForm").submit(function(event) {
|
|||||||
|
|
||||||
$('.loader').fadeOut();
|
$('.loader').fadeOut();
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
var message = (policy_PrimaryKey === '') ? 'Policy Premium Added successfully' :
|
var message = (policy_PrimaryKey === '') ? 'Policy Premium Added successfully' :'Policy Premium Added Successfully';
|
||||||
'Policy Premium Added Successfully';
|
|
||||||
toastr.success(message, 'Success');
|
toastr.success(message, 'Success');
|
||||||
// $('.close').click();
|
// $('.close').click();
|
||||||
|
|
||||||
@ -829,7 +880,6 @@ $("#GridForm").submit(function(event) {
|
|||||||
$("#AdditionalGridForm").submit(function(event) {
|
$("#AdditionalGridForm").submit(function(event) {
|
||||||
|
|
||||||
var check = checkDuplicate(1);
|
var check = checkDuplicate(1);
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if ($('#grid_emp_count').val() == 'false') {
|
if ($('#grid_emp_count').val() == 'false') {
|
||||||
@ -966,18 +1016,21 @@ $('body').on('click', '.btnPolicyModel', function() {
|
|||||||
res.premiumData = JSON.parse(res.premiumData);
|
res.premiumData = JSON.parse(res.premiumData);
|
||||||
|
|
||||||
console.log('policy grid responce', res.premiumData);
|
console.log('policy grid responce', res.premiumData);
|
||||||
console.log('policy grid responce', res.policy_name);
|
console.log('policy name', res.policy_name);
|
||||||
|
|
||||||
|
|
||||||
$('#nameOfThePolicy').html(' - ' + res.policy_name);
|
$('#nameOfThePolicy').text(' - ' + res.policy_name);
|
||||||
$('#grid_emp_count').val(res.count);
|
$('#grid_emp_count').val(res.count);
|
||||||
|
|
||||||
|
|
||||||
if (res.count > 0) {
|
if (res.count > 0) {
|
||||||
$("#hide_smbt_btn").hide();
|
$("#hide_smbt_btn").hide();
|
||||||
|
$("#secondary_rack_rate_btn_grp").hide();
|
||||||
} else {
|
} else {
|
||||||
$("#hide_smbt_btn").show();
|
$("#hide_smbt_btn").show();
|
||||||
|
$("#secondary_rack_rate_btn_grp").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (res.status === false) {
|
if (res.status === false) {
|
||||||
toastr.error(res.status);
|
toastr.error(res.status);
|
||||||
@ -1037,8 +1090,6 @@ $('body').on('click', '.btnPolicyModel', function() {
|
|||||||
console.log('policy_grid_id_value', policy_grid_id_value);
|
console.log('policy_grid_id_value', policy_grid_id_value);
|
||||||
console.log('secondary_policy_grid_id_value', secondary_policy_grid_id_value);
|
console.log('secondary_policy_grid_id_value', secondary_policy_grid_id_value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#grid_content_input').empty();
|
$('#grid_content_input').empty();
|
||||||
var policeGridOptionHTML = '';
|
var policeGridOptionHTML = '';
|
||||||
policeGridOptionHTML += ` <option value="">Select Premium Type</option>`;
|
policeGridOptionHTML += ` <option value="">Select Premium Type</option>`;
|
||||||
@ -1050,7 +1101,7 @@ $('body').on('click', '.btnPolicyModel', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('#additional_grid_content_input').empty();
|
||||||
var policeGridOptionHTMLforSecondary = '';
|
var policeGridOptionHTMLforSecondary = '';
|
||||||
policeGridOptionHTMLforSecondary +=
|
policeGridOptionHTMLforSecondary +=
|
||||||
` <option value="">Select Premium Type</option>`;
|
` <option value="">Select Premium Type</option>`;
|
||||||
@ -1129,7 +1180,12 @@ $('body').on('click', '.btnPolicyModel', function() {
|
|||||||
$(this).trigger('keyup');
|
$(this).trigger('keyup');
|
||||||
});
|
});
|
||||||
|
|
||||||
var id_for_trigger = temp_for_premiumData[0].policy_grid_id;
|
var id_for_trigger = [];
|
||||||
|
if (temp_for_premiumData.length > 0 && temp_for_premiumData[0] !== undefined) {
|
||||||
|
id_for_trigger = temp_for_premiumData[0].policy_grid_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$(`input[name="${id_for_trigger}_si[]"]`).each(function() {
|
$(`input[name="${id_for_trigger}_si[]"]`).each(function() {
|
||||||
// console.log($(this));
|
// console.log($(this));
|
||||||
$(this).trigger('keyup');
|
$(this).trigger('keyup');
|
||||||
@ -1167,6 +1223,8 @@ $('body').on('click', '.btnPolicyModel', function() {
|
|||||||
|
|
||||||
$('#grid').change(function() {
|
$('#grid').change(function() {
|
||||||
|
|
||||||
|
$('.excel_textarea').val('');
|
||||||
|
|
||||||
var grid_id = $(this)[0].value;
|
var grid_id = $(this)[0].value;
|
||||||
var client_policy_id = $('#client_policy_id')[0].value;
|
var client_policy_id = $('#client_policy_id')[0].value;
|
||||||
|
|
||||||
@ -1239,7 +1297,6 @@ $('#grid').change(function() {
|
|||||||
si_or_bp_value = res.premiumData[0].si_or_bp;
|
si_or_bp_value = res.premiumData[0].si_or_bp;
|
||||||
|
|
||||||
$('#si_or_bp').val(si_or_bp_value);
|
$('#si_or_bp').val(si_or_bp_value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1277,6 +1334,8 @@ $('#grid').change(function() {
|
|||||||
|
|
||||||
$('#additional_grid').change(function() {
|
$('#additional_grid').change(function() {
|
||||||
|
|
||||||
|
$('.excel_textarea').val('');
|
||||||
|
|
||||||
var grid_id = $(this)[0].value;
|
var grid_id = $(this)[0].value;
|
||||||
var client_policy_id = $('#client_policy_id')[0].value;
|
var client_policy_id = $('#client_policy_id')[0].value;
|
||||||
|
|
||||||
@ -1302,9 +1361,9 @@ $('#additional_grid').change(function() {
|
|||||||
|
|
||||||
if (res.count > 0) {
|
if (res.count > 0) {
|
||||||
// console.log(' hide submit btn count ', res.count);
|
// console.log(' hide submit btn count ', res.count);
|
||||||
$("#hide_smbt_btn").hide();
|
$("#secondary_rack_rate_btn_grp").hide();
|
||||||
} else {
|
} else {
|
||||||
$("#hide_smbt_btn").show();
|
$("#secondary_rack_rate_btn_grp").show();
|
||||||
// console.log('show submit btn count ', res.count);
|
// console.log('show submit btn count ', res.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1315,9 +1374,9 @@ $('#additional_grid').change(function() {
|
|||||||
|
|
||||||
if (res.count > 0) {
|
if (res.count > 0) {
|
||||||
// console.log(' hide submit btn count ', res.count);
|
// console.log(' hide submit btn count ', res.count);
|
||||||
$("#hide_smbt_btn").hide();
|
$("#secondary_rack_rate_btn_grp").hide();
|
||||||
} else {
|
} else {
|
||||||
$("#hide_smbt_btn").show();
|
$("#secondary_rack_rate_btn_grp").show();
|
||||||
// console.log('show submit btn count ', res.count);
|
// console.log('show submit btn count ', res.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1332,7 +1391,7 @@ $('#additional_grid').change(function() {
|
|||||||
policy_grid_id_value = res.premiumData[0].policy_grid_id;
|
policy_grid_id_value = res.premiumData[0].policy_grid_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#grid_content_input').empty();
|
$('#additional_grid_content_input').empty();
|
||||||
var policeGridOptionHTML = '';
|
var policeGridOptionHTML = '';
|
||||||
policeGridOptionHTML += ` <option value="">Select Premium Type</option>`;
|
policeGridOptionHTML += ` <option value="">Select Premium Type</option>`;
|
||||||
$.each(res.data, function(index, item) {
|
$.each(res.data, function(index, item) {
|
||||||
@ -1341,7 +1400,9 @@ $('#additional_grid').change(function() {
|
|||||||
'selected="selected"' : '') + '>' + item.policy_grid_type +
|
'selected="selected"' : '') + '>' + item.policy_grid_type +
|
||||||
'</option>';
|
'</option>';
|
||||||
});
|
});
|
||||||
|
|
||||||
// $('#grid').html(policeGridOptionHTML);
|
// $('#grid').html(policeGridOptionHTML);
|
||||||
|
|
||||||
var si_or_bp_value = '';
|
var si_or_bp_value = '';
|
||||||
if (res.premiumData && res.premiumData.length > 0) {
|
if (res.premiumData && res.premiumData.length > 0) {
|
||||||
|
|
||||||
@ -2530,12 +2591,16 @@ function getCurrentTime() {
|
|||||||
|
|
||||||
|
|
||||||
function createCheckboxes(obj, additional_relationship) {
|
function createCheckboxes(obj, additional_relationship) {
|
||||||
|
|
||||||
console.log('createCheckboxes function called');
|
console.log('createCheckboxes function called');
|
||||||
|
|
||||||
console.log(additional_relationship)
|
console.log(additional_relationship);
|
||||||
additional_relationship = JSON.parse(additional_relationship);
|
try {
|
||||||
console.log(additional_relationship)
|
additional_relationship = JSON.parse(additional_relationship);
|
||||||
|
console.log(additional_relationship);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error parsing additional_relationship:", error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$('#relationship').empty();
|
$('#relationship').empty();
|
||||||
const $relationshipElement = $('#relationship');
|
const $relationshipElement = $('#relationship');
|
||||||
@ -2545,24 +2610,24 @@ function createCheckboxes(obj, additional_relationship) {
|
|||||||
const multiplier = 7; // Adjust this value as needed
|
const multiplier = 7; // Adjust this value as needed
|
||||||
|
|
||||||
$.each(obj, function(key, value) {
|
$.each(obj, function(key, value) {
|
||||||
|
|
||||||
if (value > 0 && key != 'either-parents-pil') {
|
if (value > 0 && key != 'either-parents-pil') {
|
||||||
|
const isChecked = additional_relationship && typeof additional_relationship === 'object' && additional_relationship[key] == 1 ? 'checked' : '';
|
||||||
key = formatString(key);
|
key = formatString(key);
|
||||||
const isChecked = additional_relationship && additional_relationship[key] === 1 ? 'checked' : '';
|
console.log('isChecked', isChecked);
|
||||||
html += `
|
html += `
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<input type="checkbox" ${isChecked} name="${key}">
|
<input type="checkbox" name="${key}" ${isChecked}>
|
||||||
<label style="position: relative;left: 18px;bottom: 30px;">${key}</label>
|
<label style="position: relative;left: 18px;bottom: 30px;">${key}</label>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
// console.log(html);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$relationshipElement.append(html);
|
$relationshipElement.append(html);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function formatString(str) {
|
function formatString(str) {
|
||||||
return str.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
return str.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,241 +1,412 @@
|
|||||||
<style>
|
<style>
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
td, th {
|
|
||||||
padding: 0.2rem; /* Adjust padding as needed */
|
|
||||||
}
|
|
||||||
.error {
|
|
||||||
background-color: #f8d7da;
|
|
||||||
}
|
|
||||||
.duplicate {
|
|
||||||
background-color: #fff3cd;
|
|
||||||
}
|
|
||||||
.container {
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
.compact-table td, .compact-table th {
|
|
||||||
padding: 0.1rem; /* Adjust padding as needed */
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div>
|
td,
|
||||||
|
th {
|
||||||
<!-- <div> -->
|
padding: 0.2rem;
|
||||||
<p>Paste excel data here: <a href="#" type="button" onclick="copyHeaders()">Copy Excel Headers</a></p>
|
}
|
||||||
<textarea id="copied_excel_data" name="copied_excel_data" style="width:100%;height:200px;" oninput="generateTable()"></textarea><br>
|
|
||||||
|
|
||||||
<!-- </div> -->
|
|
||||||
<hr>
|
|
||||||
<div id="excel_table"></div>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
<div>
|
|
||||||
<input type="button" id="submitBtn" onclick="submitData()" value="Submit" disabled/>
|
|
||||||
<br><br>
|
|
||||||
<p>JSON output:</p>
|
|
||||||
<div id="json_output"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
.error {
|
||||||
const formatType = 0; // Specify the format type here
|
background-color: #f8d7da;
|
||||||
const excel_headers = {
|
}
|
||||||
3: {
|
|
||||||
"sum_insured": "Sum Insured",
|
.duplicate {
|
||||||
"premium": "Premium"
|
background-color: #fff3cd;
|
||||||
},
|
}
|
||||||
4: {
|
|
||||||
"sum_insured": "Sum Insured",
|
.container {
|
||||||
"from_age": "From Age",
|
margin-top: 20px;
|
||||||
"to_age": "To Age",
|
}
|
||||||
"premium": "Premium"
|
|
||||||
},
|
.compact-table td,
|
||||||
5: {
|
.compact-table th {
|
||||||
"sum_insured": "Sum Insured",
|
padding: 0.1rem;
|
||||||
"from_age": "From Age",
|
}
|
||||||
"to_age": "To Age",
|
</style>
|
||||||
"premium": "Premium"
|
|
||||||
},
|
|
||||||
6: {
|
|
||||||
"sum_insured": "Sum Insured",
|
<script>
|
||||||
"from_age": "From Age",
|
const formatType = 0; // Specify the format type here
|
||||||
"to_age": "To Age",
|
const excel_headers = {
|
||||||
"premium": "Premium"
|
3: {
|
||||||
},
|
"sum_insured": "Sum Insured",
|
||||||
7: {
|
"premium": "Premium"
|
||||||
"sum_insured": "Sum Insured",
|
},
|
||||||
"from_age": "From Age",
|
4: {
|
||||||
"to_age": "To Age",
|
"sum_insured": "Sum Insured",
|
||||||
"premium": "Premium"
|
"from_age": "From Age",
|
||||||
},
|
"to_age": "To Age",
|
||||||
8: {
|
"premium": "Premium"
|
||||||
"sum_insured": "Sum Insured",
|
},
|
||||||
"grade": "Grade",
|
5: {
|
||||||
"premium": "Premium"
|
"sum_insured": "Sum Insured",
|
||||||
},
|
"from_age": "From Age",
|
||||||
9:
|
"to_age": "To Age",
|
||||||
{
|
"premium": "Premium"
|
||||||
"sum_insured": "Sum Insured",
|
},
|
||||||
"premium": "Premium"
|
6: {
|
||||||
},
|
"sum_insured": "Sum Insured",
|
||||||
10: {
|
"from_age": "From Age",
|
||||||
"sum_insured": "Sum Insured",
|
"to_age": "To Age",
|
||||||
"from_age": "From Age",
|
"premium": "Premium"
|
||||||
"to_age": "To Age",
|
},
|
||||||
"premium": "Premium"
|
7: {
|
||||||
},
|
"sum_insured": "Sum Insured",
|
||||||
11: {
|
"from_age": "From Age",
|
||||||
"sum_insured": "Sum Insured",
|
"to_age": "To Age",
|
||||||
"grade": "Grade",
|
"premium": "Premium"
|
||||||
"premium": "Premium",
|
},
|
||||||
"max_si": "Max Si"
|
8: {
|
||||||
},
|
"sum_insured": "Sum Insured",
|
||||||
12: {
|
"grade": "Grade",
|
||||||
"sum_insured": "Sum Insured",
|
"premium": "Premium"
|
||||||
"relationship": "Relationship",
|
},
|
||||||
"premium": "Premium"
|
9: {
|
||||||
},
|
"sum_insured": "Sum Insured",
|
||||||
13: {
|
"premium": "Premium"
|
||||||
"sum_insured": "Sum Insured",
|
},
|
||||||
"relationship": "Relationship",
|
10: {
|
||||||
"from_age": "From Age",
|
"sum_insured": "Sum Insured",
|
||||||
"to_age": "To Age",
|
"from_age": "From Age",
|
||||||
"premium": "Premium"
|
"to_age": "To Age",
|
||||||
|
"premium": "Premium"
|
||||||
|
},
|
||||||
|
11: {
|
||||||
|
"sum_insured": "Sum Insured",
|
||||||
|
"grade": "Grade",
|
||||||
|
"premium": "Premium",
|
||||||
|
"max_si": "Max Si"
|
||||||
|
},
|
||||||
|
12: {
|
||||||
|
"sum_insured": "Sum Insured",
|
||||||
|
"relationship": "Relationship",
|
||||||
|
"premium": "Premium"
|
||||||
|
},
|
||||||
|
13: {
|
||||||
|
"sum_insured": "Sum Insured",
|
||||||
|
"relationship": "Relationship",
|
||||||
|
"from_age": "From Age",
|
||||||
|
"to_age": "To Age",
|
||||||
|
"premium": "Premium"
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
function slugify(text) {
|
||||||
|
return text.toString().toLowerCase().replace(/\s+/g, '_').replace(/[^\w\-]+/g, '').replace(/\-\-+/g, '_')
|
||||||
|
.replace(/^-+/, '').replace(/-+$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyHeaders(rack_rate_type) {
|
||||||
|
|
||||||
|
let formatType = $('#grid').val();
|
||||||
|
var obj = $('#grid');
|
||||||
|
if(rack_rate_type == 1){
|
||||||
|
formatType = $('#additional_grid').val();
|
||||||
|
obj = $('#additional_grid');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(obj)
|
||||||
|
console.log(formatType)
|
||||||
|
|
||||||
|
if(!formatType && formatType == ""){
|
||||||
|
toastr.warning('Please select the Policy Premium Type', 'Warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const headerString = Object.values(excel_headers[formatType]).join("\t"); // Using specified format type for copying headers
|
||||||
|
navigator.clipboard.writeText(headerString).then(function() {
|
||||||
|
toastr.success('Headers copied to clipboard', 'success');
|
||||||
|
}, function(err) {
|
||||||
|
toastr.error(err, 'Could not copy headers:');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateTable(rack_rate_type) {
|
||||||
|
|
||||||
|
var data = $('#copied_excel_data').val();
|
||||||
|
let formatType = $('#grid').val();
|
||||||
|
var obj = $('#grid');
|
||||||
|
|
||||||
|
if (rack_rate_type == 1) {
|
||||||
|
data = $('#additional_copied_excel_data').val();
|
||||||
|
formatType = $('#additional_grid').val();
|
||||||
|
obj = $('#additional_grid');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(obj);
|
||||||
|
console.log(formatType);
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
if (!formatType || formatType == "") {
|
||||||
|
$('.excel_table_class').empty();
|
||||||
|
$('.excel_textarea').val('');
|
||||||
|
toastr.warning('Please select the Policy Premium Type', 'Warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if Excel data is empty
|
||||||
|
if (!data.trim()) {
|
||||||
|
toastr.warning('Excel data is empty.', 'Warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rows = data.split("\n");
|
||||||
|
|
||||||
|
// Filter out empty rows
|
||||||
|
rows = rows.filter(rowText => rowText.split("\t").some(cell => cell.trim()));
|
||||||
|
|
||||||
|
if (rows.length === 0) {
|
||||||
|
toastr.warning('All rows are empty after filtering.', 'Warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var header = rows[0].split("\t");
|
||||||
|
|
||||||
|
// Determine the columns to keep (non-empty columns)
|
||||||
|
var columnsToKeep = [];
|
||||||
|
for (let i = 0; i < header.length; i++) {
|
||||||
|
if (rows.some(rowText => rowText.split("\t")[i].trim())) {
|
||||||
|
columnsToKeep.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
function slugify(text) {
|
|
||||||
return text.toString().toLowerCase().replace(/\s+/g, '_').replace(/[^\w\-]+/g, '').replace(/\-\-+/g, '_').replace(/^-+/, '').replace(/-+$/, '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyHeaders() {
|
// Filter header based on columns to keep
|
||||||
const headerString = Object.values(excel_headers[formatType]).join("\t"); // Using specified format type for copying headers
|
header = columnsToKeep.map(i => slugify(header[i]));
|
||||||
navigator.clipboard.writeText(headerString).then(function() {
|
|
||||||
alert('Headers copied to clipboard');
|
if (!excel_headers[formatType]) {
|
||||||
}, function(err) {
|
toastr.warning("Unknown format type. Please check the header columns.", 'Warning');
|
||||||
alert('Could not copy headers: ', err);
|
$('.excel_table_class').empty();
|
||||||
|
$('.excel_textarea').val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var expectedHeader = Object.keys(excel_headers[formatType]);
|
||||||
|
|
||||||
|
if (JSON.stringify(header) !== JSON.stringify(expectedHeader)) {
|
||||||
|
const expectedHeaders = JSON.stringify(Object.values(excel_headers[formatType]));
|
||||||
|
const receivedHeaders = JSON.stringify(columnsToKeep.map(i => rows[0].split("\t")[i]));
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: "Header Mismatch",
|
||||||
|
html: `
|
||||||
|
<p>Header columns do not match expected format:</p>
|
||||||
|
<p><strong>Expected:</strong> ${expectedHeaders}</p>
|
||||||
|
<p><strong>Received:</strong> ${receivedHeaders}</p>
|
||||||
|
`,
|
||||||
|
icon: "error"
|
||||||
});
|
});
|
||||||
|
$('.excel_table_class').empty();
|
||||||
|
$('.excel_textarea').val('');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateTable() {
|
var table = $('<table class="table table-striped compact-table" />');
|
||||||
var data = $('#copied_excel_data').val();
|
var uniqueRows = new Set();
|
||||||
const formatType = $('#grid').val();
|
var emptyCellCount = 0;
|
||||||
alert(formatType);
|
|
||||||
// Check if Excel data is empty
|
|
||||||
if (!data.trim()) {
|
|
||||||
alert('Excel data is empty.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var rows = data.split("\n");
|
|
||||||
var table = $('<table class="table table-striped compact-table" />');
|
|
||||||
var header = rows[0].split("\t").map(cell => slugify(cell));
|
|
||||||
|
|
||||||
if (!excel_headers[formatType]) {
|
rows.forEach((rowText, y) => {
|
||||||
alert("Unknown format type. Please check the header columns.");
|
var cells = rowText.split("\t").filter((_, i) => columnsToKeep.includes(i));
|
||||||
$('#submitBtn').prop('disabled', true);
|
var row = $('<tr />');
|
||||||
$('#excel_table').empty();
|
|
||||||
|
// Skip empty rows after filtering columns
|
||||||
|
if (cells.every(cell => !cell.trim())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var expectedHeader = Object.keys(excel_headers[formatType]);
|
cells.forEach(cellText => {
|
||||||
|
row.append('<td>' + cellText + '</td>');
|
||||||
if (JSON.stringify(header) !== JSON.stringify(expectedHeader)) {
|
if (!cellText.trim()) {
|
||||||
alert("Header columns do not match expected format:\nExpected: " + JSON.stringify(Object.values(excel_headers[formatType])) + "\nReceived: " + JSON.stringify(rows[0].split("\t")));
|
emptyCellCount++;
|
||||||
$('#submitBtn').prop('disabled', true);
|
|
||||||
$('#excel_table').empty();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var uniqueRows = new Set();
|
|
||||||
var emptyCellCount = 0;
|
|
||||||
|
|
||||||
rows.forEach((rowText, y) => {
|
|
||||||
var cells = rowText.split("\t");
|
|
||||||
|
|
||||||
// Skip empty rows
|
|
||||||
if (cells.every(cell => !cell.trim())) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var row = $('<tr />');
|
|
||||||
cells.forEach(cellText => {
|
|
||||||
row.append('<td>'+cellText+'</td>');
|
|
||||||
if (!cellText.trim()) {
|
|
||||||
emptyCellCount++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var key;
|
|
||||||
switch(formatType) {
|
|
||||||
case 1:
|
|
||||||
key = cells[0] + "|" + cells[1] + "|" + cells[2]; // Sum Insured, From Age, To Age
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
key = cells[0] + "|" + cells[1]; // Sum Insured, Grade
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, Relationship, From Age, To Age
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
key = cells[0]; // Sum Insured
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
key = cells[0] + "|" + cells[1]; // Sum Insured, Grade
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
key = cells.join("|");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y > 0 && uniqueRows.has(key)) {
|
|
||||||
row.addClass('duplicate');
|
|
||||||
} else {
|
|
||||||
uniqueRows.add(key);
|
|
||||||
}
|
|
||||||
table.append(row);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#submitBtn').prop('disabled', $('.duplicate').length > 0);
|
var key;
|
||||||
|
switch (formatType) {
|
||||||
|
case 3:
|
||||||
|
key = cells[0] + "|" + cells[1] // Sum Insured, Premium
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, From Age, To Age, Premium
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, From Age, To Age, Premium
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, From Age, To Age, Premium
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, From Age, To Age, Premium
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
key = cells[0] + "|" + cells[1] + "|" + cells[2]; // Sum Insured, Grade, Premium
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
key = cells[0] + "|" + cells[1]; // Sum Insured, Premium
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, From Age, To Age, Premium
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3]; // Sum Insured, Grade, Premium, Max SI
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
key = cells[0] + "|" + cells[1] + "|" + cells[2]; // Sum Insured, Relationship, Premium
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
key = cells[0] + "|" + cells[1] + "|" + cells[2] + "|" + cells[3] + "|" + cells[4]; // Sum Insured, Relationship, From Age, To Age, Premium
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
key = cells.join("|");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y > 0 && uniqueRows.has(key)) {
|
||||||
|
row.addClass('duplicate');
|
||||||
|
} else {
|
||||||
|
uniqueRows.add(key);
|
||||||
|
}
|
||||||
|
table.append(row);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (rack_rate_type == 1) {
|
||||||
|
$('#additional_excel_table').empty();
|
||||||
|
$('#additional_excel_table').html(table);
|
||||||
|
} else if (rack_rate_type == 0) {
|
||||||
|
$('#excel_table').empty();
|
||||||
$('#excel_table').html(table);
|
$('#excel_table').html(table);
|
||||||
|
}
|
||||||
|
|
||||||
if ($('.duplicate').length > 0) {
|
if ($('.duplicate').length > 0) {
|
||||||
alert("Duplicate records found.");
|
console.log('test');
|
||||||
|
toastr.warning("Duplicates found!", "warning");
|
||||||
|
$('.excel_table_class').empty();
|
||||||
|
$('.excel_textarea').val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (emptyCellCount > 0) {
|
||||||
|
toastr.warning('Number of empty cells: ' + emptyCellCount);
|
||||||
|
$('.excel_table_class').empty();
|
||||||
|
$('.excel_textarea').val('');
|
||||||
|
}
|
||||||
|
submitData(rack_rate_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function submitData(rack_rate_type) {
|
||||||
|
|
||||||
|
let formatType = $('#grid').val();
|
||||||
|
var table = $('#excel_table table');
|
||||||
|
var obj = $('#grid');
|
||||||
|
|
||||||
|
if(rack_rate_type == 1){
|
||||||
|
|
||||||
|
formatType = $('#additional_grid').val();
|
||||||
|
table = $('#additional_excel_table table');
|
||||||
|
obj = $('#additional_grid');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var headers = $(table).find('tr').first().find('td').map(function() {
|
||||||
|
return slugify($(this).text());
|
||||||
|
}).get();
|
||||||
|
|
||||||
|
var rows = $(table).find('tr:gt(0)').map(function() {
|
||||||
|
return $(this).find('td').map(function() {
|
||||||
|
return $(this).text();
|
||||||
|
}).get();
|
||||||
|
}).get();
|
||||||
|
|
||||||
|
var jsonData = [];
|
||||||
|
|
||||||
|
$(table).find('tr:gt(0)').each(function(idx) {
|
||||||
|
var row = $(this).find('td').map(function() {
|
||||||
|
return $(this).text();
|
||||||
|
}).get();
|
||||||
|
var rowData = {};
|
||||||
|
row.forEach((cell, colIdx) => {
|
||||||
|
rowData[headers[colIdx]] = cell;
|
||||||
|
});
|
||||||
|
jsonData.push(rowData);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(jsonData);
|
||||||
|
|
||||||
|
jsonData.forEach(obj => {
|
||||||
|
|
||||||
|
if ('sum_insured' in obj) {
|
||||||
|
obj.si = obj.sum_insured;
|
||||||
|
delete obj.sum_insured;
|
||||||
}
|
}
|
||||||
|
|
||||||
alert('Number of empty cells: ' + emptyCellCount);
|
if ('from_age' in obj) {
|
||||||
submitData();
|
obj.age_from = obj.from_age;
|
||||||
|
delete obj.from_age;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('to_age' in obj) {
|
||||||
|
obj.age_to = obj.to_age;
|
||||||
|
delete obj.to_age;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(jsonData);
|
||||||
|
|
||||||
|
|
||||||
|
if(rack_rate_type == 1){
|
||||||
|
|
||||||
|
$('#additional_grid_content_input').empty()
|
||||||
|
|
||||||
|
if ($('#copyfromexcelforadditional').text() == "Manual entry") {
|
||||||
|
$('#copyfromexcelforadditional').text("Copy from excel")
|
||||||
|
} else {
|
||||||
|
$('#copyfromexcelforadditional').text("Copy from excel");
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#additional_grid_content_input').toggle();
|
||||||
|
$('#additional_grid_content_from_excel').toggle();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$('#grid_content_input').empty()
|
||||||
|
|
||||||
|
if ($('#copyfromexcel').text() == "Manual entry") {
|
||||||
|
$('#copyfromexcel').text("Copy from excel")
|
||||||
|
} else {
|
||||||
|
$('#copyfromexcel').text("Copy from excel");
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#grid_content_input').toggle();
|
||||||
|
$('#grid_content_from_excel').toggle();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitData() {
|
$.each(jsonData, function(index, item) {
|
||||||
$('#json_output').empty(); // Clear existing JSON output
|
appendGridtHtml(formatType, rack_rate_type, item)
|
||||||
|
});
|
||||||
|
|
||||||
var table = $('#excel_table table');
|
|
||||||
var headers = $(table).find('tr').first().find('td').map(function() {
|
|
||||||
return slugify($(this).text());
|
|
||||||
}).get();
|
|
||||||
|
|
||||||
var rows = $(table).find('tr:gt(0)').map(function() {
|
$('input[name="11_max_si[]"]').each(function() {
|
||||||
return $(this).find('td').map(function() {
|
$(this).trigger('keyup');
|
||||||
return $(this).text();
|
});
|
||||||
}).get();
|
|
||||||
}).get();
|
|
||||||
|
|
||||||
var jsonData = [];
|
|
||||||
|
|
||||||
$(table).find('tr:gt(0)').each(function(idx) {
|
$(`input[name="${formatType}_si[]"]`).each(function() {
|
||||||
var row = $(this).find('td').map(function() {
|
// console.log($(this));
|
||||||
return $(this).text();
|
$(this).trigger('keyup');
|
||||||
}).get();
|
});
|
||||||
var rowData = {};
|
|
||||||
row.forEach((cell, colIdx) => {
|
|
||||||
rowData[headers[colIdx]] = cell;
|
|
||||||
});
|
|
||||||
jsonData.push(rowData);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#json_output').text(JSON.stringify(jsonData, null, 2));
|
$(`input[name="${formatType}_premium[]"]`).each(function() {
|
||||||
}
|
// console.log($(this));
|
||||||
</script>
|
$(this).trigger('keyup');
|
||||||
</div>
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user