diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 5c613da1..9d3f9ad8 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -112,6 +112,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function($routes){ $routes->get("upload", "EmployeeController::employeesUplodWithEvents"); $routes->post("upload", "EmployeeController::employeesUplodWithEvents"); $routes->get("excel_error/(:any)", "EmployeeController::getExcelFileErrors/$1"); + $routes->get("endorsement-list", "EmployeeController::endorsementList"); }); @@ -232,7 +233,6 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi - $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); $routes->get("relationshipList", "EmployeeRestController::relationshipList"); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 5c76efe6..1c1e0214 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -451,4 +451,17 @@ class EmployeeController extends AdminController } // ------------------------------------------------------------------------------------------- + + public function endorsementList(){ + $data = []; + if(count($this->request->getGet())) + { + $filterData = $this->request->getGet(); + $data['employees'] = $this->employeePolicyModel->getEmployeeEndorsementList(client_id: $filterData['client_id'],policy_id: $filterData['policy_id']); + $data['getData'] = $filterData; + } + + $this->myLogger->logme('error','list called'); + $this->loadLayout('endorsement_list',$data); + } } \ No newline at end of file diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 70abe646..546fb32c 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -308,134 +308,134 @@ class EmployeeRestController extends AdminController } - public function getEmployeePolicy() - { - try { - $id = $this->request->getGet('id'); - $emp_code = $this->request->getGet('emp_code'); + // public function getEmployeePolicy() + // { + // try { + // $id = $this->request->getGet('id'); + // $emp_code = $this->request->getGet('emp_code'); - $keysToRemove = ["removable_keys"]; + // $keysToRemove = ["removable_keys"]; - $empPolicy = $this->employeeModel->getEmployeePolicy($id); + // $empPolicy = $this->employeeModel->getEmployeePolicy($id); - $empData = $this->employeeModel->where('emp_code',$emp_code)->findAll(); - if ($empPolicy) { + // $empData = $this->employeeModel->where('emp_code',$emp_code)->findAll(); + // if ($empPolicy) { - $result = []; - foreach ($empPolicy as $array) { + // $result = []; + // foreach ($empPolicy as $array) { - $decodedArray = json_decode($array->Policy_Terms); - $refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove)); + // $decodedArray = json_decode($array->Policy_Terms); + // $refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove)); - $array->Policy_Terms = $refusingData; - $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId); - $array->SlabRates = $getSlabAndGridData['slab_rates']; - $array->GridMaster = $getSlabAndGridData['grid_master']; + // $array->Policy_Terms = $refusingData; + // $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId); + // $array->SlabRates = $getSlabAndGridData['slab_rates']; + // $array->GridMaster = $getSlabAndGridData['grid_master']; - if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){ - $default_si = $array->Policy_Terms->sumInsured2; - $index = -1; - foreach ($array->SlabRates as $key => $value) { - if ($value['si'] == $default_si) { - $index = $key; - break; - } - } - if ($index >= 0) { - $element =$array->SlabRates[$index]; - array_splice($array->SlabRates, $index, 1); - array_unshift($array->SlabRates, $element); - } + // if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){ + // $default_si = $array->Policy_Terms->sumInsured2; + // $index = -1; + // foreach ($array->SlabRates as $key => $value) { + // if ($value['si'] == $default_si) { + // $index = $key; + // break; + // } + // } + // if ($index >= 0) { + // $element =$array->SlabRates[$index]; + // array_splice($array->SlabRates, $index, 1); + // array_unshift($array->SlabRates, $element); + // } - $employee_policy = $this->employeePolicyModel->where('employee_id',$id)->where('client_policy_id',$array->ClientPolicyId)->get()->getRow(); - if($employee_policy){ - $gpaSI['family_floater_key'] = 'self'; - $gpaSI['label'] = 'Self'; - $gpaSI['employee_id'] = $employee_policy->employee_id; - $gpaSI['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null; - $gpaSI['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null; - $gpaSI['client_policy_id'] = $array->ClientPolicyId; + // $employee_policy = $this->employeePolicyModel->where('employee_id',$id)->where('client_policy_id',$array->ClientPolicyId)->get()->getRow(); + // if($employee_policy){ + // $gpaSI['family_floater_key'] = 'self'; + // $gpaSI['label'] = 'Self'; + // $gpaSI['employee_id'] = $employee_policy->employee_id; + // $gpaSI['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null; + // $gpaSI['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null; + // $gpaSI['client_policy_id'] = $array->ClientPolicyId; - $array->mapped_family_floaters = $gpaSI; - }else{ - $gpaSI['family_floater_key'] = 'self'; - $gpaSI['label'] = 'Self'; - $gpaSI['employee_id'] = $id; - $gpaSI['basic_cover_si'] = null; - $gpaSI['premium'] = null; - $gpaSI['client_policy_id'] = $array->ClientPolicyId; + // $array->mapped_family_floaters = $gpaSI; + // }else{ + // $gpaSI['family_floater_key'] = 'self'; + // $gpaSI['label'] = 'Self'; + // $gpaSI['employee_id'] = $id; + // $gpaSI['basic_cover_si'] = null; + // $gpaSI['premium'] = null; + // $gpaSI['client_policy_id'] = $array->ClientPolicyId; - $array->mapped_family_floaters = $gpaSI; - } + // $array->mapped_family_floaters = $gpaSI; + // } - }else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){ + // }else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){ - // re-arranging order of si - $default_si = $array->Policy_Terms->sum_insured; - // Filter the array using the callback function - $getPremium = array_filter($array->SlabRates , function ($value) use ($default_si) { return $value['si'] == $default_si; } ); - $default_premium = $getPremium[0]['premium']; + // // re-arranging order of si + // $default_si = $array->Policy_Terms->sum_insured; + // // Filter the array using the callback function + // $getPremium = array_filter($array->SlabRates , function ($value) use ($default_si) { return $value['si'] == $default_si; } ); + // $default_premium = $getPremium[0]['premium']; - $index = -1; - foreach ($array->SlabRates as $key => $value) { - if ($value['si'] == $default_si) { - $index = $key; - break; - } - } - if ($index >= 0) { - $element =$array->SlabRates[$index]; - array_splice($array->SlabRates, $index, 1); - array_unshift($array->SlabRates, $element); - } + // $index = -1; + // foreach ($array->SlabRates as $key => $value) { + // if ($value['si'] == $default_si) { + // $index = $key; + // break; + // } + // } + // if ($index >= 0) { + // $element =$array->SlabRates[$index]; + // array_splice($array->SlabRates, $index, 1); + // array_unshift($array->SlabRates, $element); + // } - //map family floates array to employee and dependent - $familyFloates = $array->Policy_Terms->family_floaters; - $data = []; - foreach ($familyFloates as $familyFloatesValue) { - $dependent = preg_replace('/\d/', '', $familyFloatesValue); - if(count($empData)){ - foreach ($empData as $key => $value) { - if ($value['family_floater_key'] === $dependent) { - $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->get()->getRow(); - $temp['family_floater_key'] = $familyFloatesValue; - $temp['label'] = $value['relationship']; - $temp['name'] = $value['name']; - $temp['employee_id'] = $value['id']; - $temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null; - $temp['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null; - $temp['client_policy_id'] = $array->ClientPolicyId; - array_push($data,$temp); - unset($empData[$key]); - break; - } - } - } - } - $array->mapped_family_floaters = $data; + // //map family floates array to employee and dependent + // $familyFloates = $array->Policy_Terms->family_floaters; + // $data = []; + // foreach ($familyFloates as $familyFloatesValue) { + // $dependent = preg_replace('/\d/', '', $familyFloatesValue); + // if(count($empData)){ + // foreach ($empData as $key => $value) { + // if ($value['family_floater_key'] === $dependent) { + // $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->get()->getRow(); + // $temp['family_floater_key'] = $familyFloatesValue; + // $temp['label'] = $value['relationship']; + // $temp['name'] = $value['name']; + // $temp['employee_id'] = $value['id']; + // $temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null; + // $temp['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null; + // $temp['client_policy_id'] = $array->ClientPolicyId; + // array_push($data,$temp); + // unset($empData[$key]); + // break; + // } + // } + // } + // } + // $array->mapped_family_floaters = $data; - $temp2=[]; - foreach ($array->SlabRates as $key => $value) { - $value['additional_premium'] = $value['premium'] - $default_premium; - array_push($temp2,$value); - } - $array->SlabRates = $temp2; + // $temp2=[]; + // foreach ($array->SlabRates as $key => $value) { + // $value['additional_premium'] = $value['premium'] - $default_premium; + // array_push($temp2,$value); + // } + // $array->SlabRates = $temp2; - } + // } - $result[] = $array; - } - return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200); - }else{ - return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404); - } - } catch (\Exception $e) { - return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); - } - } + // $result[] = $array; + // } + // return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200); + // }else{ + // return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404); + // } + // } catch (\Exception $e) { + // return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + // } + // } // Get the RelationShip list @@ -451,17 +451,21 @@ class EmployeeRestController extends AdminController $checkIfExist = $this->employeePolicyModel->where('employee_id', $value->employee_id) ->where('client_policy_id', $value->client_policy_id) ->findAll(); + $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($value->client_policy_id,$value->client_id); + $SlabRatesArray = $getSlabAndGridData['slab_rates']; + $premium = $this->findPremiumAmount($SlabRatesArray, $value->basic_cover_si); + // dd($checkIfExist); if ($checkIfExist) { - $empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si,$value->premium); + $empPolicy = $this->employeePolicyModel->updateSiAndPremium($value->client_policy_id, $value->employee_id, $value->basic_cover_si,$premium); }else{ $data['employee_id']= $value->employee_id; $data['client_policy_id']= $value->client_policy_id; $data['basic_cover_si']= $value->basic_cover_si; - $data['premium']= $value->premium; + $data['premium']= $premium; $this->employeePolicyModel->insert($data); } @@ -473,7 +477,15 @@ class EmployeeRestController extends AdminController } } - + public function findPremiumAmount($slabArray,$siAmount) + { + foreach ($slabArray as $key => $value) { + if($value['si'] == $siAmount){ + return $value['premium']; + break; + } + } + } public function relationshipList() { try { @@ -778,6 +790,112 @@ class EmployeeRestController extends AdminController } +//------------------------------------- +public function getEmployeePolicy() +{ + try { + $id = $this->request->getGet('id'); + $emp_code = $this->request->getGet('emp_code'); + + $keysToRemove = ["removable_keys"]; + + $empPolicy = $this->employeeModel->getEmployeePolicy($id); + + $empData = $this->employeeModel->where('emp_code',$emp_code)->findAll(); + // print_r($empData);die; + if ($empPolicy) { + + $result = []; + foreach ($empPolicy as $array) { + + $decodedArray = json_decode($array->Policy_Terms); + $refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove)); + + + $array->Policy_Terms = $refusingData; + $getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId); + $array->SlabRates = $getSlabAndGridData['slab_rates']; + $array->GridMaster = $getSlabAndGridData['grid_master']; + + if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){ + + $selfData = array_filter($empData, fn($arr) => $arr['family_floater_key'] === 'self'); + $self['is_value_exist'] = true; + $self['data']['family_floater_key'] = 'self'; + $self['data']['employee_id'] = $id; + $self['data']['relationship'] = 'Self'; + $self['data']['name'] = $selfData[0]['name']; + $self['data']['dob'] = $selfData[0]['dob']; + $self['data']['client_policy_id'] = $array->ClientPolicyId; + + $array->mapped_family_floaters = $self; + + + if($this->request->getGet('policy') == 'GPA'){ + return $this->respond(['status' => 'success','code' => 200,'data' => $array], 200); + } + + }else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){ + + + + //map family floates array to employee and dependent + $familyFloates = $array->Policy_Terms->family_floaters; + $data = []; + foreach ($familyFloates as $familyFloatesValue) { + $dependent = preg_replace('/\d/', '', $familyFloatesValue); + if(count($empData)){ + foreach ($empData as $key => $value) { + if ($value['family_floater_key'] === $dependent) { + $temp['is_value_exist'] = true; + $temp['data']['family_floater_key'] = $familyFloatesValue; + $temp['data']['employee_id'] = $value['id']; + $temp['data']['relationship'] = $value['relationship']; + $temp['data']['name'] = $value['name']; + $temp['data']['dob'] = $value['dob']; + $temp['data']['client_policy_id'] = $array->ClientPolicyId; + array_push($data,$temp); + unset($empData[$key]); + $familyFloates = array_diff($familyFloates, [$familyFloatesValue]); + break; + } + } + } + } + + foreach ($familyFloates as $familyFloatesValue) { + + $temp2['is_value_exist'] = false; + $temp2['data']['family_floater_key'] = $familyFloatesValue; + $temp2['data']['client_policy_id'] = $array->ClientPolicyId; + $temp2['data']['button_name'] = 'Add '.ucfirst(preg_replace('/\d/', '', $familyFloatesValue)); + $temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue); + + array_push($data,$temp2); + + } + + + $array->mapped_family_floaters = $data; + + + + if($this->request->getGet('policy') == 'GMC'){ + return $this->respond(['status' => 'success','code' => 200,'data' => $array], 200); + } + + } + + $result[] = $array; + } + //return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200); + }else{ + return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404); + } + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } +} } \ No newline at end of file diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 01bc2a2c..8008ad8d 100644 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -71,12 +71,13 @@ class ClientPolicyModel extends Model ->select('policy_type.policy_type as policy_type_name') ->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code') ->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code') + ->select('policy_type.policy_type as policy_type_name') ->join('insurers', 'insurers.id = client_policy.insurer_id') ->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id') ->join('tpa', 'tpa.id = client_policy.tpa_id') ->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id') ->join('policies', 'policies.id = client_policy.policy_id') - ->join('policy_type', 'policy_type.id = policies.policy_type_id') + ->join('policy_type', 'policy_type.id = policies.policy_type_id') ->where('client_policy.client_id', $client_id) ->get() ->getResult(); diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 94a6e80e..ca0418b5 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -560,6 +560,23 @@ class EmployeePolicyModel extends Model $this->query($query); } + + public function getEmployeeEndorsementList($client_id,$policy_id) + { + $result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active']) + ->join('employees emp', 'employee_polices.employee_id = emp.id') + ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy + ->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master + ->join('insurers im', 'cp.insurer_id = im.id') //im - insurar master + ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurar branch + ->join('tpa tpam', 'cp.tpa_id = tpam.id') //tpam - tpa master + ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id') //tpab - tpa brach + ->join('clients cm', 'cp.client_id = cm.id') //cm - client master + ->where('emp.client_id',$client_id) + ->where('employee_polices.client_policy_id',$policy_id) + ->findAll(); + return ($result); + } //------------------------------------------------------------------ } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index a4e893ab..ec0afb9c 100644 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -36,8 +36,8 @@
- - + +
@@ -94,12 +94,10 @@
- +
-
-
@@ -159,6 +157,7 @@ $('.btnAdd').click(function(){ + $('#policy_form')[0].reset(); $('#add_form').show(); $('#table_list').hide(); $('.btnBack').show(); @@ -170,12 +169,13 @@ $('#policy').html(''); $('#is_addon').prop('checked', false); $('#policy_form_action').val(''); + $('#policy_status_field').hide() }) $('.btnBack').click(function(){ - + $('#policy_form')[0].reset(); $('#GMC').remove(); $('#GPA').remove(); $('#add_form').hide(); @@ -194,10 +194,22 @@ if (policy_PrimaryKey !== '') { var policyTable = ''; var data = ; + console.log('client_policy_data',data) data.forEach(function(item) { - // console.log("----------------------------"); - // console.log(item); + var patternGMC = /gmc/i; // Case insensitive pattern for 'gmc' + var patternGPA = /gpa/i; // Case insensitive pattern for 'gpa' + var subject = item.policy_type_name; + + if (patternGMC.test(subject)) { + search_term = 'GMC'; + } else if (patternGPA.test(subject)) { + search_term = 'GPA'; + } else { + search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists + } + + console.log('search_term :', search_term) policyTable += ` @@ -211,8 +223,8 @@
@@ -271,7 +283,7 @@ success: function(res) { console.log(res); - + $('#policy_form')[0].reset(); if (res.status === false) { toastr.error('Policy Dose Not Create', 'Error'); return; @@ -295,6 +307,21 @@ $('#policy_table tr').remove(); var policyTable = ''; $.each(res.data, function(index, item) { + + var patternGMC = /gmc/i; // Case insensitive pattern for 'gmc' + var patternGPA = /gpa/i; // Case insensitive pattern for 'gpa' + var subject = item.policy_type_name; + + if (patternGMC.test(subject)) { + search_term = 'GMC'; + } else if (patternGPA.test(subject)) { + search_term = 'GPA'; + } else { + search_term = subject; // Set default value if neither 'GMC' nor 'GPA' exists + } + + console.log('search_term :', search_term) + policyTable += ` ${item.insurer_short} - ${item.insurer_branch_name} @@ -307,7 +334,7 @@ diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index db60f466..db203bcd 100644 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -75,7 +75,7 @@ table.dataTable tbody td { Name/code Policy name - Insurar name + Insurer name TPA ID UHID ID Policy status diff --git a/app/Views/endorsement_list.php b/app/Views/endorsement_list.php new file mode 100644 index 00000000..75e5509c --- /dev/null +++ b/app/Views/endorsement_list.php @@ -0,0 +1,259 @@ + + +
+
+
+
+
+ + + +
+
+
+ +
+
+
+
+ +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+
+ + + +
+
+
+
+
+
+

Endorsement List

+
+ +
+ + + + + + + + + + + + + + + + + $employee) { ?> + + + + + + + + + + + + + + + + +
SNOName/codePolicy nameInsurar nameTPA IDUHID IDPolicy statusPremiumAction
( )active + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/app/Views/kyc_docs.php b/app/Views/kyc_docs.php index 0ec33c05..6567df7c 100644 --- a/app/Views/kyc_docs.php +++ b/app/Views/kyc_docs.php @@ -324,6 +324,7 @@ $(document).ready(function () { function removeKYCDocs(element) { + var kyc_docs_id_for_reload = $('#kyc_type_id').val(); var id = element.getAttribute('data-id'); var form_action = '' + id; $.ajax({ @@ -338,7 +339,8 @@ $(document).ready(function () { if (res.status == true) { toastr.success('Remove Done!', 'success'); - location.reload(); + // location.reload(); + window.location.href = '' + kyc_docs_id_for_reload; } else { toastr.warning('Remove Not Done!', 'warning'); diff --git a/app/Views/policies.php b/app/Views/policies.php index 83560c37..6ae8f361 100644 --- a/app/Views/policies.php +++ b/app/Views/policies.php @@ -340,57 +340,58 @@ $(document).ready(function () { function loadPoliciesList() { var base_url = ''; - var insurer_branch_action = base_url + policy_type_PrimaryKey; + var insurer_branch_action = base_url + policy_type_PrimaryKey; - if ($('#policy_type_id').val() != '') { - - $('.loader').fadeIn(); - $('.loader-mask').fadeIn(); - $.ajax({ - url: insurer_branch_action, - type: 'GET', - success: function(response) { + if ($('#policy_type_id').val() != '') { + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + $.ajax({ + url: insurer_branch_action, + type: 'GET', + success: function(response) { - console.log("response", response); + console.log("response", response); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - }, 1000); - var branchTable = ''; - $.each(response.policies, function(index, item) { - console.log(item); - branchTable += ` - - ${item.insurer.name} - ${item.policy.name} - - - - - - `; - }); - $('#policies_list').append(branchTable); - }, - error: function(xhr, status, error) { - console.error(xhr.responseText); - console.error(status, error); + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }, 1000); + var branchTable = ''; + $.each(response.policies, function(index, item) { + console.log(item); + branchTable += ` + + ${item.insurer.name} + ${item.policy.name} + + + + + + `; + }); + $('#policies_list').append(branchTable); + }, + error: function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); - setTimeout(function() { - $('.loader').fadeOut(); - $('.loader-mask').delay(350).fadeOut('slow'); - toastr.warning('Something Wrong!', 'warning'); - }, 1000); - } - }); - } + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.warning('Something Wrong!', 'warning'); + }, 1000); + } + }); + } } }); function removePolicies(element) { + var policy_id_for_reload = $('#policy_type_id').val() var id = element.getAttribute('data-id'); var form_action = '' + id; $.ajax({ @@ -407,7 +408,8 @@ function removePolicies(element) { // $('#branch_table').empty(); - location.reload(); + // location.reload(); + window.location.href = '' + policy_id_for_reload; } else { toastr.warning('Remove Not Done!', 'warning'); diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index 0f556978..3779a258 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -643,9 +643,9 @@ var grid_html = ''; var gmc_policy_type_id = $(this).attr('id'); - + console.log(gmc_policy_type_id) - if(gmc_policy_type_id >= 2){ + if(gmc_policy_type_id == 'GMC'){ $('#policyGMCTerms').css('display', ''); $('#police-tab').css('display', 'none'); @@ -802,6 +802,8 @@ var grid_html = ''; } }); + }else if(gmc_policy_type_id != 'GPA' && gmc_policy_type_id != 'GMC'){ + // toastr.warning('The terms has no data ', 'warning'); } }); diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php index 9797867c..b20c7f04 100644 --- a/app/Views/policy_gpa_terms.php +++ b/app/Views/policy_gpa_terms.php @@ -446,7 +446,7 @@ var gpa_policy_type_id = $(this).attr('id'); // console.log('gpa_policy_type_id', gpa_policy_type_id) - if(gpa_policy_type_id == '1'){ + if(gpa_policy_type_id == 'GPA'){ $('#policyGPATermsForm').css('display', ''); $('#police-tab').css('display', 'none'); @@ -548,6 +548,8 @@ } }); + }else if(gpa_policy_type_id != 'GPA' && gpa_policy_type_id != 'GMC'){ + toastr.warning("This policy has no policy terms.", 'warning'); } }); diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 8cc5b360..13655d71 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -7,6 +7,9 @@