Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
9d86bd0a33
@ -233,7 +233,6 @@ $routes->get("/getEmployeeProfile", "EmployeeRestController::getEmployeeProfile/
|
||||
$routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfile");
|
||||
|
||||
|
||||
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function($routes){
|
||||
$routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
|
||||
$routes->get("relationshipList", "EmployeeRestController::relationshipList");
|
||||
@ -246,6 +245,8 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){
|
||||
$routes->get("deleteDependence", "EmployeeRestController::deleteDependence");
|
||||
$routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId");
|
||||
$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy");
|
||||
$routes->get("getClientDetails", "EmployeeRestController::getClientDetails");
|
||||
$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
|
||||
});
|
||||
|
||||
$routes->post("sendEmail", "EmployeeRestController::send_email");
|
||||
|
||||
@ -307,6 +307,8 @@ class ClientController extends AdminController
|
||||
} elseif ($data['is_download_btn']) {
|
||||
$data['is_download_btn'] = 1;
|
||||
}
|
||||
|
||||
// print_r($data);die;
|
||||
|
||||
$update = $this->clientModel->update($id,$data);
|
||||
|
||||
@ -1311,7 +1313,7 @@ class ClientController extends AdminController
|
||||
|
||||
$termsData = $this->clientPolicyModel->where(['id' => $client_policy_id, 'is_active' => 1])->first();
|
||||
if(empty($termsData['policy_terms'])){
|
||||
return $this->respond(['status' => false,'code' => 200,'message' => 'This Policy does not Create Terms'], 200);
|
||||
return $this->respond(['status' => false,'code' => 200,'message' => 'Please define policy terms '], 200);
|
||||
}
|
||||
|
||||
|
||||
@ -1338,11 +1340,21 @@ class ClientController extends AdminController
|
||||
|
||||
if($racRate == 0){
|
||||
|
||||
return $this->respond(['status' => false,'code' => 200,'message' => 'The Policy has no Data for Rac Rate'], 200);
|
||||
return $this->respond(['status' => false,'code' => 200,'message' => 'Please define policy premium'], 200);
|
||||
}
|
||||
|
||||
$policy_status = $this->clientPolicyModel->where('id', $client_policy_id )->set('policy_status', 1)->update();
|
||||
return $this->respond(['status' => true,'code' => 200, 'message' => 'Policy Status Updated Successfully', 'data' => $termsData, 'racRate' => $racRate], 200);
|
||||
$json_data ='';
|
||||
$open_for_enrollment = $this->clientPolicyModel->where('id', $client_policy_id )->set('open_for_enrollment', 1)->update();
|
||||
if ($open_for_enrollment) {
|
||||
$open_for_enrollment_1 = $this->clientPolicyModel->where('id', $client_policy_id )->find();
|
||||
$open_for_enrollment_value = $open_for_enrollment_1[0]['open_for_enrollment'];
|
||||
$client_policy_id_value = $client_policy_id;
|
||||
|
||||
$json_data = json_encode(['open_for_enrollment' => $open_for_enrollment_value, 'client_policy_id' => $client_policy_id_value]);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => true,'code' => 200, 'message' => 'Policy Status Updated Successfully', 'data' => $termsData, 'racRate' => $racRate, 'open_for_enrollment' => $json_data], 200);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
foreach ($data as $item) {
|
||||
$id = $item->id;
|
||||
$item->dob = $this->convertDateFormat($item->dob);
|
||||
$item->dob = $this->convertDateFormatYMD($item->dob);
|
||||
$employee = $this->employeeModel->update($id, (array)$item);
|
||||
if ($employee) {
|
||||
$updatedCount++;
|
||||
@ -179,7 +179,7 @@ class EmployeeRestController extends AdminController
|
||||
//update old data
|
||||
$id = $item->id;
|
||||
$item->family_floater_key = $this->RelationshipMap($item->relationship);
|
||||
$item->dob = $this->convertDateFormat($item->dob);
|
||||
$item->dob = $this->convertDateFormatYMD($item->dob);
|
||||
$employee = $this->employeeModel->update($id, (array)$item);
|
||||
if ($employee) {
|
||||
$Count++;
|
||||
@ -187,7 +187,7 @@ class EmployeeRestController extends AdminController
|
||||
}else{
|
||||
//create new data
|
||||
$item->family_floater_key = $this->RelationshipMap($item->relationship);
|
||||
$item->dob = $this->convertDateFormat($item->dob);
|
||||
$item->dob = $this->convertDateFormatYMD($item->dob);
|
||||
$employee = $this->employeeModel->insert($item);
|
||||
if ($employee) {
|
||||
$Count++;
|
||||
@ -224,24 +224,32 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
private function convertDateFormat($dateString)
|
||||
private function convertDateFormatYMD($dateString)
|
||||
{
|
||||
// Attempt to create a DateTime object from the provided date string
|
||||
$dateTime = \DateTime::createFromFormat('d-m-Y', $dateString);
|
||||
|
||||
// Check if the conversion was successful and the date string is in the format dd-mm-yyyy
|
||||
if ($dateTime instanceof \DateTime) {
|
||||
// Format the date to yyyy-mm-dd
|
||||
return $dateTime->format('Y-m-d');
|
||||
} else {
|
||||
// If the date string is not in the format dd-mm-yyyy, return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function convertDateFormatDMY($dateString)
|
||||
{
|
||||
// Attempt to create a DateTime object from the provided date string
|
||||
$dateTime = \DateTime::createFromFormat('Y-m-d', $dateString);
|
||||
|
||||
if ($dateTime instanceof \DateTime) {
|
||||
return $dateTime->format('d-m-Y');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public function deleteDependence()
|
||||
{
|
||||
try {
|
||||
print_r($this->rquest);die;
|
||||
|
||||
if($this->request->getGet('id'))
|
||||
{
|
||||
$delete = $this->employeeModel->where('id', $this->request->getGet('id'))->delete();
|
||||
@ -511,12 +519,17 @@ class EmployeeRestController extends AdminController
|
||||
$client_id = $this->request->getPost('client_id');
|
||||
$policy_id = $this->request->getPost('policy_id');
|
||||
|
||||
$token = $this->request->headers()['Auth']->getValue();
|
||||
$decodedPayload = json_decode(base64_decode(explode('.', $token)[1]), true);
|
||||
$jwt = $this->request->getHeader('Authorization');
|
||||
$jwtParts = explode(' ', $jwt);
|
||||
$token = $jwtParts[1];
|
||||
|
||||
|
||||
$decodedPayload = json_decode(base64_decode(explode('.', $token)[1]), true);
|
||||
// get the employee id from token
|
||||
$employee_id = $decodedPayload['id'];
|
||||
|
||||
|
||||
|
||||
$client_policy = $this->clientPolicyModel->where('id', $policy_id)->where('client_id', $client_id)->first();
|
||||
|
||||
if ($client_policy) {
|
||||
@ -689,6 +702,7 @@ class EmployeeRestController extends AdminController
|
||||
$basic_cover_si[]= $basic_cover_si_value;
|
||||
}
|
||||
}
|
||||
$count = 0;
|
||||
for ($a=0; $a <count($dataToInsert) ; $a++)
|
||||
{
|
||||
$employee = $this->employeeModel->checkExistingEmployee($dataToInsert[$a]);
|
||||
@ -765,10 +779,23 @@ class EmployeeRestController extends AdminController
|
||||
$data['policy_name']=$policy['name'];
|
||||
|
||||
$message = view('mail_welcome', $data);
|
||||
|
||||
if ($dataToInsert[$a]['relationship'] == 'Self' && $mail != null || $mail != '') {
|
||||
$count++;
|
||||
$wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $message];
|
||||
}
|
||||
|
||||
// print_r($wholeData);
|
||||
// if ($dataToInsert[$a]['email_corporate'] != null || $dataToInsert[$a]['email_corporate'] != '' && $dataToInsert[$a]['relationship'] == 'Self') {
|
||||
// $job_details = new Jobs();
|
||||
// $r = Jobs::addJob(['job_name' => 'send_email','payload' => ['mail' => $mail, 'subject' => $subject,'message'=> $message]]);
|
||||
// }
|
||||
if($count == 20 || $a == count($dataToInsert)-1){
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $wholeData]);
|
||||
// $wholeData[]= $r;
|
||||
|
||||
// Mailhelper::bulk_mail($wholeData);
|
||||
$wholeData = [];
|
||||
$count = 0;
|
||||
}
|
||||
|
||||
// print_r($r);//die();
|
||||
// $jobWorker = new JobWorker();
|
||||
@ -795,55 +822,71 @@ class EmployeeRestController extends AdminController
|
||||
public function getEmployeePolicy()
|
||||
{
|
||||
try {
|
||||
|
||||
$id = $this->request->getGet('id');
|
||||
$emp_code = $this->request->getGet('emp_code');
|
||||
|
||||
|
||||
// This is an array containing keys to be removed from the terms and conditions array
|
||||
$keysToRemove = ["removable_keys"];
|
||||
|
||||
// Retrieve employee policy data by passing the employee primary key
|
||||
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
|
||||
|
||||
$empData = $this->employeeModel->where('emp_code',$emp_code)->findAll();
|
||||
// print_r($empData);die;
|
||||
// Retrieve employee and dependents data by passing the employee code
|
||||
$employeeData = $this->employeeModel->where('emp_code',$emp_code)->where('is_addon_value',0)->findAll();
|
||||
|
||||
|
||||
if ($empPolicy) {
|
||||
|
||||
$result = [];
|
||||
foreach ($empPolicy as $array) {
|
||||
|
||||
// Reset employee array
|
||||
$empData = $employeeData;
|
||||
|
||||
// Removes specific keys from the decoded array and assigns the result to $refusingData
|
||||
$decodedArray = json_decode($array->Policy_Terms);
|
||||
$refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
|
||||
|
||||
|
||||
$array->Policy_Terms = $refusingData;
|
||||
|
||||
// Retrieve slab rate and grid master data by passing the ClientPolicyId and ClientId
|
||||
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
|
||||
$array->SlabRates = $getSlabAndGridData['slab_rates'];
|
||||
$array->GridMaster = $getSlabAndGridData['grid_master'];
|
||||
|
||||
// Construct value for policy type GPA
|
||||
if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
|
||||
|
||||
$selfData = array_filter($empData, fn($arr) => $arr['family_floater_key'] === 'self');
|
||||
// Filter employee data where the family_floater_key is 'self'
|
||||
$selfData = array_filter($empData, fn($arr) => trim(strtolower($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']['dob'] = $this->convertDateFormatDMY($selfData[0]['dob']);
|
||||
$self['data']['mobile'] = $selfData[0]['mobile'];
|
||||
$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);
|
||||
// Return result
|
||||
if($this->request->getGet('policy') == 'GPA')
|
||||
{
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $array], 200);
|
||||
}
|
||||
|
||||
|
||||
// Construct value for policy type GMC
|
||||
}else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
|
||||
|
||||
|
||||
|
||||
//map family floates array to employee and dependent
|
||||
// Map family floaters that already exist in the employee table
|
||||
$familyFloates = $array->Policy_Terms->family_floaters;
|
||||
// Generate Notes string based on familyFloates terms
|
||||
$array->notes = $this->FloterNotesConvertion($familyFloates);
|
||||
// Convert familyFloaters terms data to plain array
|
||||
$floters = $this->FloterConvertion($familyFloates);
|
||||
|
||||
$data = [];
|
||||
foreach ($familyFloates as $familyFloatesValue) {
|
||||
foreach ($floters as $familyFloatesValue) {
|
||||
$dependent = preg_replace('/\d/', '', $familyFloatesValue);
|
||||
if(count($empData)){
|
||||
foreach ($empData as $key => $value) {
|
||||
@ -853,29 +896,49 @@ public function getEmployeePolicy()
|
||||
$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;
|
||||
$temp['data']['dob'] = $this->convertDateFormatDMY($value['dob']);
|
||||
$temp['data']['client_policy_id'] = $array->ClientPolicyId;
|
||||
$temp['data']['form_type'] = $dependent;
|
||||
array_push($data,$temp);
|
||||
unset($empData[$key]);
|
||||
$familyFloates = array_diff($familyFloates, [$familyFloatesValue]);
|
||||
$floters = array_diff($floters, [$familyFloatesValue]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($familyFloates as $familyFloatesValue) {
|
||||
|
||||
// Remove Unwanted floter key from floters array based on either-parents-pil term value
|
||||
if($familyFloates->{'either-parents-pil'} == 1 && count($floters))
|
||||
{
|
||||
$count_parent = 0;
|
||||
$count_parent_in_law = 0;
|
||||
foreach ($floters as $value) {
|
||||
if (preg_replace('/\d/', '', $value) == 'parent') { $count_parent++; }
|
||||
if (preg_replace('/\d/', '', $value) == 'parent_in_law') {$count_parent_in_law++;}
|
||||
}
|
||||
if($count_parent != 2) {
|
||||
$floters = array_filter($floters, fn($value) => strpos($value, 'parent_in_law') === false);
|
||||
}
|
||||
if($count_parent_in_law != 2) {
|
||||
$floters = array_filter($floters, fn($value) => strpos($value, 'parent') === false || strpos($value, 'parent_in_law') !== false);
|
||||
}
|
||||
}
|
||||
|
||||
// Add family floter buttons placement data for FE validation
|
||||
if(count($floters)){
|
||||
foreach ($floters 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']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue)));
|
||||
$temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
|
||||
|
||||
array_push($data,$temp2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$array->mapped_family_floaters = $data;
|
||||
|
||||
@ -889,7 +952,9 @@ public function getEmployeePolicy()
|
||||
|
||||
$result[] = $array;
|
||||
}
|
||||
//return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => []], 404);
|
||||
}
|
||||
@ -898,4 +963,245 @@ public function getEmployeePolicy()
|
||||
}
|
||||
}
|
||||
|
||||
public function FloterConvertion($array){
|
||||
|
||||
$result = [];
|
||||
foreach ($array as $key => $value) {
|
||||
if ($value > 0) {
|
||||
if ($value != 0 && $key === 'childrens') {
|
||||
for ($i = 1; $i <= $value; $i++) {
|
||||
$result[] = "child" . $i;
|
||||
}
|
||||
} else if($value != 0 && $key ==='parents') {
|
||||
for ($i = 1; $i <= $value; $i++) {
|
||||
$result[] = "parent" . $i;
|
||||
}
|
||||
}else if($value != 0 && $key ==='parents-in-law') {
|
||||
for ($i = 1; $i <= $value; $i++) {
|
||||
$result[] = "parent_in_law" . $i;
|
||||
}
|
||||
}else if($value != 0 && $key ==='either-parents-pil') {
|
||||
for ($i = 1; $i <= 2; $i++) {
|
||||
$result[] = "parent" . $i;
|
||||
$result[] = "parent_in_law" . $i;
|
||||
}
|
||||
}else {
|
||||
$result[] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function FloterNotesConvertion($array){
|
||||
|
||||
$result = 'Can Add Self ';
|
||||
foreach ($array as $key => $value) {
|
||||
if ($value > 0) {
|
||||
if($value != 0 && $key ==='either-parents-pil') {
|
||||
$result .= ' + Either 2 Parents or 2 Parents in law';
|
||||
}else if($value != 0 && $key ==='spouse') {
|
||||
$string = str_replace('-', ' ', $key);
|
||||
$string = ucwords($string);
|
||||
$result .= ' + '.$string;
|
||||
}else if($value != 0 && $key ==='self') {
|
||||
}else{
|
||||
$string = str_replace('-', ' ', $key);
|
||||
$string = ucwords($string);
|
||||
$result .= ' + '.$value.' '.$string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getClientDetails()
|
||||
{
|
||||
try {
|
||||
|
||||
$client = $this->clientModel->where('id',$this->request->getGet('client_id'))->first();
|
||||
if($client) {
|
||||
$client['client_logo'] = base_url().'public/uploads/logo/'.$client['client_logo'];
|
||||
$clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))->findAll();
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => ['client'=>$client,'client_policy'=>$clientPolicy]], 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);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAddOnPolicy()
|
||||
{
|
||||
try {
|
||||
|
||||
$addOnEmployeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))->where('is_addon_value',1)->findAll();
|
||||
$GMCEmployeeData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))->where('is_addon_value',0)->findAll();
|
||||
|
||||
$clientPolicy = $this->clientPolicyModel->where('client_id',$this->request->getGet('client_id'))->findAll();
|
||||
if(count($clientPolicy))
|
||||
{
|
||||
$PolicyData = [];
|
||||
foreach ($clientPolicy as $key => $array) {
|
||||
|
||||
|
||||
$decodedArray = json_decode($array['policy_terms']);
|
||||
$policy_terms = $decodedArray;
|
||||
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array['id'],$array['client_id']);
|
||||
|
||||
if($array['is_addon'] == 1)
|
||||
{
|
||||
|
||||
$responce['SlabRates'] = $getSlabAndGridData['slab_rates'];
|
||||
$responce['GridMaster'] = $getSlabAndGridData['grid_master'];
|
||||
$responce['client_id'] = $array['client_id'];
|
||||
$responce['client_policy_id'] = $array['id'];
|
||||
$responce['is_addon'] = $array['is_addon'];
|
||||
$responce['open_for_enrollment'] = $array['open_for_enrollment'];
|
||||
$responce['policy_terms'] = $decodedArray;
|
||||
|
||||
|
||||
// Map family floaters that already exist in the employee table
|
||||
$familyFloates = $policy_terms->family_floaters;
|
||||
// Convert familyFloaters terms data to plain array
|
||||
$floters = $this->FloterConvertion($familyFloates);
|
||||
|
||||
|
||||
$data = [];
|
||||
$dependent_and_si_value = null;
|
||||
$dependent_and_si_premium_value = null;
|
||||
foreach ($floters as $familyFloatesValue) {
|
||||
$dependent = preg_replace('/\d/', '', $familyFloatesValue);
|
||||
if(count($addOnEmployeeData)){
|
||||
foreach ($addOnEmployeeData as $key => $value) {
|
||||
if ($value['family_floater_key'] === $dependent) {
|
||||
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->get()->getRow();
|
||||
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 = $employee_policy->premium;}
|
||||
|
||||
$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'] = $this->convertDateFormatDMY($value['dob']);
|
||||
$temp['data']['client_policy_id'] = $array['id'];
|
||||
$temp['data']['form_type'] = $dependent;
|
||||
$temp['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
|
||||
$temp['data']['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
|
||||
array_push($data,$temp);
|
||||
unset($addOnEmployeeData[$key]);
|
||||
$floters = array_diff($floters, [$familyFloatesValue]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Remove Unwanted floter key from floters array based on either-parents-pil term value
|
||||
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('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;
|
||||
foreach ($floters as $value) {
|
||||
if (preg_replace('/\d/', '', $value) == 'parent') { $count_parent++; }
|
||||
if (preg_replace('/\d/', '', $value) == 'parent_in_law') {$count_parent_in_law++;}
|
||||
}
|
||||
if($count_parent != 2) {
|
||||
$floters = array_filter($floters, fn($value) => strpos($value, 'parent_in_law') === false);
|
||||
}
|
||||
if($count_parent_in_law != 2) {
|
||||
$floters = array_filter($floters, fn($value) => strpos($value, 'parent') === false || strpos($value, 'parent_in_law') !== false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add family floter buttons placement data for FE validation
|
||||
if(count($floters)){
|
||||
foreach ($floters as $familyFloatesValue) {
|
||||
|
||||
$temp2['is_value_exist'] = false;
|
||||
$temp2['data']['family_floater_key'] = $familyFloatesValue;
|
||||
$temp2['data']['client_policy_id'] = $array['id'];
|
||||
$temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue)));
|
||||
$temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue);
|
||||
|
||||
array_push($data,$temp2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$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_premium_value'] = $dependent_and_si_premium_value;
|
||||
|
||||
|
||||
$only_si_array = [];
|
||||
$only_si_value = null;
|
||||
$only_si_premium_value = null;
|
||||
foreach ($GMCEmployeeData as $key => $value) {
|
||||
|
||||
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array['id'])->get()->getRow();
|
||||
if(isset($employee_policy->basic_cover_si)){ $only_si_value = $employee_policy->basic_cover_si; }
|
||||
if(isset($employee_policy->premium)){ $only_si_premium_value = $employee_policy->premium;}
|
||||
$temp3['is_value_exist'] = true;
|
||||
$temp3['data']['employee_id'] = $value['id'];
|
||||
$temp3['data']['relationship'] = $value['relationship'];
|
||||
$temp3['data']['name'] = $value['name'];
|
||||
$temp3['data']['dob'] = $this->convertDateFormatDMY($value['dob']);
|
||||
$temp3['data']['client_policy_id'] = $array['id'];
|
||||
$temp3['data']['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
|
||||
$temp3['data']['premium'] = isset($employee_policy->premium) ? $employee_policy->premium : null;
|
||||
array_push($only_si_array,$temp3);
|
||||
|
||||
}
|
||||
|
||||
$responce['family_floaters_of_only_si_array'] = $only_si_array;
|
||||
$responce['family_floaters_of_only_si_value'] = $only_si_value;
|
||||
$responce['family_floaters_of_only_si_premium_value'] = $only_si_premium_value;
|
||||
|
||||
|
||||
|
||||
|
||||
array_push($PolicyData, $responce);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => ['addon_policy'=>$responce]], 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -14,7 +14,7 @@ class JobWorker extends AdminController
|
||||
* Constructs the class
|
||||
*/
|
||||
|
||||
private static $event_class_mapping = ['add' => ['type' => 'HC','handler' => 'App\\Helpers\\HttpRequestHelper'], 'sub' => ['type' => 'CC','handler' => 'App\\Controllers\\Jobs\SubJob'],'fancy_date_time_format' => [ 'type' => 'HF','handler' => 'fancy_date_time_format'],'addNumber' => ['type' => 'HC','handler' => 'App\\Model\\HttpRequestHelper'],'excelFileFormatValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'excelFileDataValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'employeeOnboard' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'send_email' => ['type' => 'HC','handler' => 'App\\Helpers\\MailHelper']];
|
||||
private static $event_class_mapping = ['add' => ['type' => 'HC','handler' => 'App\\Helpers\\HttpRequestHelper'], 'sub' => ['type' => 'CC','handler' => 'App\\Controllers\\Jobs\SubJob'],'fancy_date_time_format' => [ 'type' => 'HF','handler' => 'fancy_date_time_format'],'addNumber' => ['type' => 'HC','handler' => 'App\\Model\\HttpRequestHelper'],'excelFileFormatValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'excelFileDataValidation' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'employeeOnboard' => ['type' => 'CC','handler' => 'App\\Controllers\\EmployeeServiceController'],'send_email' => ['type' => 'HC','handler' => 'App\\Helpers\\MailHelper'],'bulk_mail' => ['type' => 'HC','handler' => 'App\\Helpers\\MailHelper']];
|
||||
public function __construct()
|
||||
{
|
||||
// echo 'HiC';//die();
|
||||
@ -199,4 +199,7 @@ class JobWorker extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
use App\Models\JobModel;
|
||||
|
||||
|
||||
class MailHelper
|
||||
{
|
||||
@ -18,6 +20,7 @@ class MailHelper
|
||||
$subject = $params['subject'];
|
||||
$message = $params['message'];
|
||||
try {
|
||||
|
||||
$email = \Config\Services::email();
|
||||
$email->setMailType('html');
|
||||
$email->setFrom('bbone@venbait.in', 'Nhance');
|
||||
@ -37,5 +40,26 @@ class MailHelper
|
||||
return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function bulk_mail(array $mails = [])
|
||||
{
|
||||
$model = new JobModel();
|
||||
$start = microtime(true);
|
||||
$runtime= 0;
|
||||
try {
|
||||
foreach ( $mails as $index=>$mail) {
|
||||
$runtime = microtime(true) - $start;
|
||||
$send_mail = self::send_email($mail);
|
||||
}
|
||||
|
||||
return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200);
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
return json_encode(['status' => 'failed','code' => 500],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@ -86,31 +86,34 @@ if (!function_exists('compressImage')) {
|
||||
if (!function_exists('fancy_date_time_format'))
|
||||
{
|
||||
function fancy_date_time_format($datetime,$return_type = 'fancy') {
|
||||
date_default_timezone_set('Asia/Kolkata');
|
||||
|
||||
$currentDateTime = new DateTime();
|
||||
$passedDateTime = new DateTime($datetime);
|
||||
|
||||
|
||||
// Calculate the interval between the current time and the passed datetime
|
||||
$interval = $currentDateTime->diff($passedDateTime);
|
||||
// return change_date_format($datetime,'Y-m-d H:i:s','d M Y h:i a');
|
||||
// If the interval is more than 1 month, return the original datetime
|
||||
if ($interval->m > 1 || $interval->y > 0) {
|
||||
if($return_type = 'fancy'){ return change_date_format($datetime,'Y-m-d H:i:s','d M Y h:i a'); }
|
||||
return $datetime;
|
||||
} elseif ($interval->m == 1 && $interval->y == 0) {
|
||||
return "1 month ago";
|
||||
} elseif ($interval->d >= 7) {
|
||||
$weeks = floor($interval->d / 7);
|
||||
return $weeks == 1 ? "1 week ago" : "$weeks weeks ago";
|
||||
} elseif ($interval->d >= 1) {
|
||||
return $interval->d == 1 ? "1 day ago" : $interval->d . " days ago";
|
||||
} elseif ($interval->h >= 1) {
|
||||
return $interval->h == 1 ? "1 hour ago" : $interval->h . " hours ago";
|
||||
} elseif ($interval->i >= 1) {
|
||||
return $interval->i == 1 ? "1 minute ago" : $interval->i . " minutes ago";
|
||||
} else {
|
||||
return "Just now";
|
||||
|
||||
// Calculate the interval between the current time and the passed datetime
|
||||
$interval = $currentDateTime->diff($passedDateTime);
|
||||
|
||||
// If the interval is more than 1 month or the year is different, return the original datetime
|
||||
if ($interval->m > 1 || $interval->y != 0) {
|
||||
if ($return_type == 'fancy') {
|
||||
return change_date_format($datetime, 'Y-m-d H:i:s', 'd M Y h:i a');
|
||||
}
|
||||
return $datetime;
|
||||
} elseif ($interval->m == 1 && $interval->y == 0) {
|
||||
return "1 month ago";
|
||||
} elseif ($interval->d >= 7) {
|
||||
$weeks = floor($interval->d / 7);
|
||||
return $weeks == 1 ? "1 week ago" : "$weeks weeks ago";
|
||||
} elseif ($interval->d >= 1) {
|
||||
return $interval->d == 1 ? "1 day ago" : $interval->d . " days ago";
|
||||
} elseif ($interval->h >= 1) {
|
||||
return $interval->h == 1 ? "1 hour ago" : $interval->h . " hours ago";
|
||||
} elseif ($interval->i >= 1) {
|
||||
return $interval->i == 1 ? "1 minute ago" : $interval->i . " minutes ago";
|
||||
} else {
|
||||
return "Just now";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -35,7 +35,8 @@ class EmployeeModel extends Model
|
||||
"updated_by",
|
||||
"updated_at",
|
||||
"is_active",
|
||||
"file_id"
|
||||
"file_id",
|
||||
"is_addon_value"
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
|
||||
@ -192,9 +192,9 @@
|
||||
if (policy_PrimaryKey !== '') {
|
||||
var policyTable = '';
|
||||
var data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
|
||||
console.log('client_policy_data',data)
|
||||
// console.log('client_policy_data',data)
|
||||
data.forEach(function(item) {
|
||||
|
||||
console.log(item.open_for_enrollment);
|
||||
var patternGMC = /gmc/i; // Case insensitive pattern for 'gmc'
|
||||
var patternGPA = /gpa/i; // Case insensitive pattern for 'gpa'
|
||||
var subject = item.policy_type_name;
|
||||
@ -223,8 +223,13 @@
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}"class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rac Rate</a>
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment</a>
|
||||
</div>
|
||||
`;
|
||||
if (item.open_for_enrollment == 0) {
|
||||
policyTable +=`<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle"></i>Open Enrollment</a> `;
|
||||
}else{
|
||||
policyTable +=`<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnOpenEnroll" style="pointer-events:none; background-color: lightgrey;"><i class="mdi mdi-file-lock mr-2 text-muted font-18 vertical-middle" ></i>Open Enrollment</a> `;
|
||||
}
|
||||
policyTable += ` </div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -507,13 +512,28 @@
|
||||
client_policy_id : client_policy_id,
|
||||
},
|
||||
success: function(res) {
|
||||
// console.log(res);
|
||||
console.log(res);
|
||||
if(res) {
|
||||
if (res.open_for_enrollment) {
|
||||
var json_decode=JSON.parse(res.open_for_enrollment);
|
||||
var open_for_enrollment=json_decode.open_for_enrollment;
|
||||
var client_policy_id=json_decode.client_policy_id;
|
||||
if (open_for_enrollment == 1) {
|
||||
// console.log($('[data-id="' + client_policy_id + '"]');
|
||||
$('.btnOpenEnroll').each(function(index, element) {
|
||||
if ($(element).data('id') == client_policy_id) {
|
||||
$(element).css({'background-color': 'lightgrey', 'pointer-events': 'none'});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
if(res.status === true){
|
||||
toastr.success(res.message, 'Success');
|
||||
|
||||
}else if(res.status === false){
|
||||
toastr.warning(res.message, 'Warning');
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ paths:
|
||||
summary: 'Add a new EmployeeUpload to the store'
|
||||
operationId: EmployeeUpload
|
||||
parameters:
|
||||
- name: auth
|
||||
- name: Authorization
|
||||
in: header
|
||||
description: an authorization header
|
||||
required: true
|
||||
@ -317,7 +317,7 @@ paths:
|
||||
summary: 'RelationshipList'
|
||||
operationId: RelationshipList
|
||||
parameters:
|
||||
- name: auth
|
||||
- name: Authorization
|
||||
in: header
|
||||
description: an authorization header
|
||||
required: true
|
||||
@ -340,7 +340,7 @@ paths:
|
||||
summary: 'GetEmployeeAndDependence'
|
||||
operationId: GetEmployeeAndDependence
|
||||
parameters:
|
||||
- name: auth
|
||||
- name: Authorization
|
||||
in: header
|
||||
description: an authorization header
|
||||
required: true
|
||||
@ -368,7 +368,7 @@ paths:
|
||||
summary: 'EditEmployeeAndDependence'
|
||||
operationId: EditEmployeeAndDependence
|
||||
parameters:
|
||||
- name: auth
|
||||
- name: Authorization
|
||||
in: header
|
||||
description: an authorization header
|
||||
required: true
|
||||
@ -461,7 +461,7 @@ paths:
|
||||
summary: 'AddEmployeeAndDependence'
|
||||
operationId: AddEmployeeAndDependence
|
||||
parameters:
|
||||
- name: auth
|
||||
- name: Authorization
|
||||
in: header
|
||||
description: an authorization header
|
||||
required: true
|
||||
@ -551,7 +551,7 @@ paths:
|
||||
summary: 'GetEmployeePolicy'
|
||||
operationId: GetEmployeePolicy
|
||||
parameters:
|
||||
- name: auth
|
||||
- name: Authorization
|
||||
in: header
|
||||
description: an authorization header
|
||||
required: true
|
||||
@ -584,7 +584,7 @@ paths:
|
||||
summary: 'CreateOrUpdateEmployeePolicySiAmount'
|
||||
operationId: CreateOrUpdateEmployeePolicySiAmount
|
||||
parameters:
|
||||
- name: auth
|
||||
- name: Authorization
|
||||
in: header
|
||||
description: an authorization header
|
||||
required: true
|
||||
@ -627,7 +627,7 @@ paths:
|
||||
summary: 'DeleteDependence'
|
||||
operationId: DeleteDependence
|
||||
parameters:
|
||||
- name: auth
|
||||
- name: Authorization
|
||||
in: header
|
||||
description: an authorization header
|
||||
required: true
|
||||
@ -655,7 +655,7 @@ paths:
|
||||
summary: 'GetEmployeeAndDependenceByClientId'
|
||||
operationId: GetEmployeeAndDependenceByClientId
|
||||
parameters:
|
||||
- name: auth
|
||||
- name: Authorization
|
||||
in: header
|
||||
description: an authorization header
|
||||
required: true
|
||||
@ -688,7 +688,7 @@ paths:
|
||||
summary: 'GetClientPolicy'
|
||||
operationId: GetClientPolicy
|
||||
parameters:
|
||||
- name: auth
|
||||
- name: Authorization
|
||||
in: header
|
||||
description: an authorization header
|
||||
required: true
|
||||
|
||||
Loading…
Reference in New Issue
Block a user