MERGE_TEST_LIVE_ISSUES

This commit is contained in:
Venba 2024-10-08 11:45:36 +00:00
commit 84aa1fe1a1
3 changed files with 70 additions and 97 deletions

View File

@ -327,7 +327,10 @@ class EmployeeRestController extends AdminController
public function updatePremiumAmount($client_policy_id , $emp_code , $client_branch_id) public function updatePremiumAmount($client_policy_id , $emp_code , $client_branch_id)
{ {
$response = $this->calculatePremium($client_policy_id , $emp_code , null , $client_branch_id); $response = $this->calculatePremium($client_policy_id , $emp_code , null , $client_branch_id);
// echo '<pre>';
// print_r($response);
// echo '</pre>';
// die();
if(count($response[$emp_code])) if(count($response[$emp_code]))
{ {
@ -441,35 +444,13 @@ class EmployeeRestController extends AdminController
{ {
try { try {
$requestData = $this->request->getJSON(); $requestData = $this->request->getJSON();
if(count($requestData))
foreach ($requestData as $key => $value) { {
$this->updatePremiumAmount($requestData[0]->client_policy_id , $requestData[0]->emp_code , $requestData[0]->client_branch_id);
$checkIfExist = $this->employeePolicyModel->where('employee_id', $value->employee_id)
->where('client_policy_id', $value->client_policy_id)
->where('is_active', 1 )
->findAll();
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); return $this->respond(['status' => 'success','code' => 200,'data' => []], 200);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -1526,8 +1507,17 @@ class EmployeeRestController extends AdminController
if(count($clientPolicy)) if(count($clientPolicy))
{ {
$band = $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; $self = $this->employeeModel
->join('employee_polices', 'employees.id = employee_polices.employee_id')
->where('employees.is_active', 1)
->where('employees.emp_code', $this->request->getGet('emp_code'))
->where('employees.client_id', $this->request->getGet('client_id'))
->where('employees.client_branch_id', $this->request->getGet('client_branch_id'))
->where('employees.family_floater_key', 'self')
->get()
->getRow();
$band = $self->band;
$PolicyData = []; $PolicyData = [];
foreach ($clientPolicy as $key => $array) { foreach ($clientPolicy as $key => $array) {
$responce = []; $responce = [];
@ -1579,6 +1569,7 @@ class EmployeeRestController extends AdminController
->get() ->get()
->getResult(); ->getResult();
if(count($tpaArray)) if(count($tpaArray))
{ {
if($tpaArray[0]->tpa_id != null) if($tpaArray[0]->tpa_id != null)
@ -1603,6 +1594,12 @@ class EmployeeRestController extends AdminController
if($array['is_addon'] == 3 && $array['policy_type_id'] == 3)//dependent add on policy if($array['is_addon'] == 3 && $array['policy_type_id'] == 3)//dependent add on policy
{ {
$selfSi = $self->basic_cover_si;
$filteredSlabRates = array_filter($responce['SlabRates'], function ($rate) use ($selfSi) {
return $rate['si'] === $selfSi;
});
// To reindex the array to have a proper 0 index
$responce['SlabRates'] = array_values($filteredSlabRates);
// Map family floaters that already exist in the employee table // Map family floaters that already exist in the employee table
$familyFloates = $policy_terms->family_floaters; $familyFloates = $policy_terms->family_floaters;
@ -1614,7 +1611,6 @@ class EmployeeRestController extends AdminController
// Convert familyFloaters terms data to plain array // Convert familyFloaters terms data to plain array
$floters = $this->FloterConvertion($familyFloates); $floters = $this->FloterConvertion($familyFloates);
$data = []; $data = [];
$dependent_and_si_value = 0; $dependent_and_si_value = 0;
$dependent_and_si_premium_value = 0; $dependent_and_si_premium_value = 0;
@ -1626,7 +1622,7 @@ class EmployeeRestController extends AdminController
if ($value['family_floater_key'] === $dependent) { if ($value['family_floater_key'] === $dependent) {
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow();
if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = $employee_policy->basic_cover_si; } if(isset($employee_policy->basic_cover_si)){ $dependent_and_si_value = $employee_policy->basic_cover_si; }
if(isset($employee_policy->premium)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->premium;} if(isset($employee_policy->rata_premimum)){ $dependent_and_si_premium_value = $dependent_and_si_premium_value + $employee_policy->rata_premimum;}
if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;} if(isset($employee_policy->gst)){ $dependent_and_si_gst_value = $dependent_and_si_gst_value + $employee_policy->gst;}
$temp['is_value_exist'] = true; $temp['is_value_exist'] = true;
@ -1650,58 +1646,29 @@ class EmployeeRestController extends AdminController
} }
} }
//Remove Unwanted floter key from floters array based on either-parents-pil term value //Remove Unwanted floter key from floters array based on either-parents-pil term value
if($familyFloates->{'either-parents-pil'} == 1 && count($floters)) if($familyFloates->{'either-parents-pil'} == 1 && count($floters))
{ {
if(count($addOnEmployeeData) == 0)
{
$GMCEmpData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
->where('is_addon_value',0)
->where('is_active', 1 )
->where('family_floater_key','parent')
->findAll();
if(count($GMCEmpData) > 0){
$floters = array_diff($floters, ["parent1","parent2"]);
}else{
$floters = array_diff($floters, ["parent_in_law1","parent_in_law2"]);
}
}else{
$count_parent = 0; $count_parent = 0;
$count_parent_in_law = 0; $count_parent_in_law = 0;
foreach ($floters as $value) { foreach ($floters as $value) {
if (preg_replace('/\d/', '', $value) == 'parent') { $count_parent++; } if (preg_replace('/\d/', '', $value) == 'parent') { $count_parent++; }
if (preg_replace('/\d/', '', $value) == 'parent_in_law') {$count_parent_in_law++;} if (preg_replace('/\d/', '', $value) == 'parent_in_law') {$count_parent_in_law++;}
} }
if($count_parent != 2) { if($count_parent != 2) {
$floters = array_filter($floters, fn($value) => strpos($value, 'parent_in_law') === false); $floters = array_filter($floters, fn($value) => strpos($value, 'parent_in_law') === false);
} }
if($count_parent_in_law != 2) { if($count_parent_in_law != 2) {
$floters = array_filter($floters, fn($value) => strpos($value, 'parent') === false || strpos($value, 'parent_in_law') !== false); $floters = array_filter($floters, fn($value) => strpos($value, 'parent') === false || strpos($value, 'parent_in_law') !== false);
}
} }
} }
else if($familyFloates->{'either-parents-pil'} == 2 && count($floters)) else if($familyFloates->{'either-parents-pil'} == 2 && count($floters))
{ {
if(count($addOnEmployeeData) == 0) $count_parent = 0;
{
$GMCEmpData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
->where('is_addon_value',0)
->where('is_active', 1 )
->where('family_floater_key','parent')
->findAll();
if(count($GMCEmpData) > 0){
$floters = array_diff($floters, ["parent1","parent2"]);
}else{
$floters = array_diff($floters, ["parent_in_law1","parent_in_law2"]);
}
}else{
$count_parent = 0;
$count_parent_in_law = 0; $count_parent_in_law = 0;
foreach ($floters as $value) { foreach ($floters as $value) {
if (preg_replace('/\d/', '', $value) == 'parent') { $count_parent++; } if (preg_replace('/\d/', '', $value) == 'parent') { $count_parent++; }
@ -1710,12 +1677,10 @@ class EmployeeRestController extends AdminController
if(($count_parent + $count_parent_in_law) == 2) { if(($count_parent + $count_parent_in_law) == 2) {
$floters = array_filter($floters, fn($value) => strpos($value, 'parent') === false); $floters = array_filter($floters, fn($value) => strpos($value, 'parent') === false);
} }
}
} }
// Add family floter buttons placement data for FE validation // Add family floter buttons placement data for FE validation
if(count($floters)){ if(count($floters)){
foreach ($floters as $familyFloatesValue) { foreach ($floters as $familyFloatesValue) {
@ -1734,9 +1699,9 @@ class EmployeeRestController extends AdminController
} }
$responce['family_floaters_of_dependent_and_si_array'] = $data; $responce['family_floaters_of_dependent_and_si_array'] = $data;
$responce['family_floaters_of_dependent_and_si_value'] = $dependent_and_si_value; $responce['family_floaters_of_dependent_and_si_value'] = $dependent_and_si_value > 0 ? $dependent_and_si_value : 0;
$responce['family_floaters_of_dependent_and_si_premium_value'] = $dependent_and_si_premium_value; $responce['family_floaters_of_dependent_and_si_premium_value'] = $dependent_and_si_premium_value > 0 ? $dependent_and_si_premium_value : 0;
$responce['family_floaters_of_dependent_and_gst_value'] = $dependent_and_si_gst_value; $responce['family_floaters_of_dependent_and_gst_value'] = $dependent_and_si_gst_value > 0 ? $dependent_and_si_gst_value : 0;
@ -1774,7 +1739,7 @@ class EmployeeRestController extends AdminController
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow();
if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; } if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; }
if(isset($employee_policy->premium)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;}
if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;}
$temp3['is_value_exist'] = true; $temp3['is_value_exist'] = true;
$temp3['data']['employee_id'] = $value['id']; $temp3['data']['employee_id'] = $value['id'];
@ -1823,7 +1788,7 @@ class EmployeeRestController extends AdminController
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow(); $employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->where('is_active', 1 )->get()->getRow();
if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; } if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; }
if(isset($employee_policy->premium)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;} if(isset($employee_policy->rata_premimum)){ $only_si_premium_value = $only_si_premium_value + $employee_policy->rata_premimum;}
if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;} if(isset($employee_policy->gst)){ $only_si_gst_value = $only_si_gst_value + $employee_policy->gst;}
$temp3['is_value_exist'] = true; $temp3['is_value_exist'] = true;
$temp3['data']['employee_id'] = $value['id']; $temp3['data']['employee_id'] = $value['id'];
@ -1868,7 +1833,7 @@ class EmployeeRestController extends AdminController
$postData = json_decode($this->request->getBody(), true); $postData = json_decode($this->request->getBody(), true);
$client_policy_id = $postData['client_policy_id']; $client_policy_id = $postData['client_policy_id'];
sort($client_policy_id); sort($client_policy_id);
// Alternatively, you can use echo to see the type
$emp_code = $postData['emp_code']; $emp_code = $postData['emp_code'];
$client_id = $postData['client_id']; $client_id = $postData['client_id'];
@ -1918,16 +1883,22 @@ class EmployeeRestController extends AdminController
$account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params); $account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params);
foreach ($account_manager_wholeData as $key => $value) { if($account_manager_wholeData != null && $account_manager_wholeData != '' && count($account_manager_wholeData))
$mail_send_return1 = MailHelper::send_email($value); {
$this->myLogger->logme("info", $mail_send_return1); foreach ($account_manager_wholeData as $key => $value) {
$mail_send_return1 = MailHelper::send_email($value);
$this->myLogger->logme("info", $mail_send_return1);
}
} }
$client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params); $client_hr_wholeData =sendMailNotification::sendMailNotification('client_hr_summary_mail', $params);
foreach ($client_hr_wholeData as $key => $value) { if($client_hr_wholeData != null && $client_hr_wholeData != '' &&count($client_hr_wholeData))
$mail_send_return2 = MailHelper::send_email($value); {
$this->myLogger->logme("info", $mail_send_return2); foreach ($client_hr_wholeData as $key => $value) {
$mail_send_return2 = MailHelper::send_email($value);
$this->myLogger->logme("info", $mail_send_return2);
}
} }
} }
} }

View File

@ -1566,7 +1566,7 @@ class MasterController extends AdminController
{ {
if ($this->request->getMethod() == 'post') { if ($this->request->getMethod() == 'post') {
$gmailapi = \Config\Services::gmailapi(); // $gmailapi = \Config\Services::gmailapi();
$to = $this->request->getPost('to'); $to = $this->request->getPost('to');
$subject = $this->request->getPost('subject'); $subject = $this->request->getPost('subject');
@ -1603,7 +1603,7 @@ class MasterController extends AdminController
public function testGmailAPIViaCLI(string $email_id = 'velmurugan.s@venbainfotech.com') public function testGmailAPIViaCLI(string $email_id = 'velmurugan.s@venbainfotech.com')
{ {
// print_r($email_id);die(); // print_r($email_id);die();
$gmailapi = \Config\Services::gmailapi(); // $gmailapi = \Config\Services::gmailapi();
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => 'This is sample mail sent via CLI mode']); $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => 'This is sample mail sent via CLI mode']);
print_r($res); print_r($res);

View File

@ -95,12 +95,14 @@ class MailHelper
$message = $params['message']; $message = $params['message'];
if (isset($params['bcc'])) { if (isset($params['bcc'])) {
$bcc = $params['bcc']; $bcc = $params['bcc'];
$bcc = explode(',', $bcc);
}else{ }else{
$bcc = []; $bcc = [];
} }
if (isset($params['cc'])) { if (isset($params['cc'])) {
$cc = $params['cc']; $cc = $params['cc'];
$cc = explode(',', $cc);
}else{ }else{
$cc = []; $cc = [];
} }