GWM:GMCDependentInsert-EntryOnEmpPolictTable
This commit is contained in:
parent
3db264e78b
commit
1520addb58
@ -189,7 +189,12 @@ class EmployeeRestController extends AdminController
|
||||
$item->family_floater_key = $this->RelationshipMap($item->relationship);
|
||||
$item->dob = $this->convertDateFormatYMD($item->dob);
|
||||
$employee = $this->employeeModel->insert($item);
|
||||
|
||||
if ($employee) {
|
||||
if(!isset($item->is_addon_value))
|
||||
{
|
||||
$this->createEmployeePolicyData($employee,$item->emp_code,$item->client_id,$item->client_policy_id);
|
||||
}
|
||||
$Count++;
|
||||
}
|
||||
|
||||
@ -211,6 +216,34 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
public function createEmployeePolicyData($employee_id,$emp_code,$client_id,$client_policy_id)
|
||||
{
|
||||
|
||||
|
||||
|
||||
$client_policy = $this->clientPolicyModel->where('id', $client_policy_id)->where('client_id', $client_id)->first();
|
||||
$policy_terms = json_decode($client_policy['policy_terms']);
|
||||
$basic_cover_si = $policy_terms->sum_insured;
|
||||
|
||||
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$client_id);
|
||||
$SlabRatesArray = $getSlabAndGridData['slab_rates'];
|
||||
$premium = $this->findPremiumAmount($SlabRatesArray, $basic_cover_si);
|
||||
|
||||
|
||||
|
||||
$data['employee_id']= $employee_id;
|
||||
$data['client_policy_id']= $client_policy_id;
|
||||
$data['basic_cover_si']= $basic_cover_si;
|
||||
$data['premium']= $premium;
|
||||
|
||||
$this->employeePolicyModel->insert($data);
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function RelationshipMap($value){
|
||||
|
||||
if ($value === 'Mother' || $value === 'Father') {
|
||||
@ -274,10 +307,8 @@ class EmployeeRestController extends AdminController
|
||||
public function getEmployeeAndDependenceByClientId()
|
||||
{
|
||||
try {
|
||||
$empData = $this->employeePolicyModel->getEmployeePolicy( $this->request->getGet('client_id'), $this->request->getGet('client_policy_id'));
|
||||
// $empData = $this->employeeModel->where('client_id', $this->request->getGet('client_id'))
|
||||
// ->where('relationship !=', null)
|
||||
|
||||
$empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0);
|
||||
|
||||
if ($empData) {
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200);
|
||||
} else {
|
||||
|
||||
@ -69,7 +69,7 @@ class EmployeePolicyModel extends Model
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
public function getEmployeePolicy($client_id,$policy_id,$status)
|
||||
{
|
||||
$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'])
|
||||
$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','emp.mobile as mobile'])
|
||||
->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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user