Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
9d22244b20
@ -452,7 +452,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
|
||||
$routes->post("sendEmail", "EmployeeRestController::send_email");
|
||||
|
||||
// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
|
||||
$routes->get("getFamilyPolicyDetails", "EmployeeRestController::getFamilyPolicyDetails");
|
||||
|
||||
// Ticketing System
|
||||
|
||||
|
||||
@ -346,7 +346,7 @@ class EmployeeRestController extends AdminController
|
||||
->where('client_policy_id',$value['policy_details']['client_policy_id'] )
|
||||
->where('employee_id' , $value['temp']['emp_id'] )
|
||||
->where('is_active', 1 )
|
||||
->set(array('premium'=> $value['policy_details']['premium'] , 'rata_premimum'=> $value['policy_details']['rata_premimum'] , 'gst'=> $value['policy_details']['gst'] ))
|
||||
->set(array('basic_cover_si' => $value['policy_details']['basic_cover_si'],'premium'=> $value['policy_details']['premium'] , 'rata_premimum'=> $value['policy_details']['rata_premimum'] , 'gst'=> $value['policy_details']['gst'] ))
|
||||
->update();
|
||||
|
||||
}
|
||||
@ -845,7 +845,7 @@ class EmployeeRestController extends AdminController
|
||||
'basic_pay'=> $extra['11'][$index],
|
||||
'unit'=> isset($extra['12'][$index]) ? $extra['12'][$index] : null,
|
||||
'client_branch_id' => $client_branch_id,
|
||||
'date_coverage' => $extra['13'][$index]
|
||||
'date_coverage' => $extra['13'][$index] != "" && $extra['13'][$index] != null ? change_date_format($extra['13'][$index],'d-M-Y','Y-m-d') : null
|
||||
|
||||
];
|
||||
$basic_cover_si_value = null;
|
||||
@ -1691,6 +1691,10 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
if($array['is_addon'] == 3 && $array['policy_type_id'] == 3)//dependent add on policy
|
||||
{
|
||||
|
||||
if($this->request->getGet('client_id') == 8) // This changes only for client "sterling"
|
||||
{
|
||||
|
||||
$selfGMC = $this->employeeModel->select('employees.name , employee_polices.basic_cover_si')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id AND client_policy.policy_type_id = 2')
|
||||
@ -1709,6 +1713,9 @@ class EmployeeRestController extends AdminController
|
||||
// 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
|
||||
$familyFloates = $policy_terms->family_floaters;
|
||||
// remove parent and parent-in-law from familyFloaters
|
||||
@ -1729,7 +1736,7 @@ class EmployeeRestController extends AdminController
|
||||
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'])->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 = ($dependent_and_si_value == 0) ? $employee_policy->basic_cover_si : $dependent_and_si_value; }
|
||||
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;}
|
||||
|
||||
@ -1828,8 +1835,12 @@ class EmployeeRestController extends AdminController
|
||||
$whereArray = [];
|
||||
foreach ( $decodedArray->family_floaters as $key => $value) {
|
||||
if($value != 0){
|
||||
if($key == 'parents'){ $text = 'parent'; }else if($key == 'childrens'){ $text = 'child'; }else if($key == 'parents-in-law'){$text = 'parent_in_law';}else{ $text = $key; }
|
||||
array_push($whereArray,$text);
|
||||
if($key == 'parents'){ $text = ["parent"]; }
|
||||
else if($key == 'childrens'){ $text = ["child"]; }
|
||||
else if($key == 'parents-in-law'){ $text = ["parent_in_law"];}
|
||||
else if($key ==='either-parents-pil') { $text = ["parent", "parent_in_law"];}
|
||||
else{ $text = [$key]; }
|
||||
$whereArray = array_merge($whereArray, $text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1846,7 +1857,7 @@ class EmployeeRestController extends AdminController
|
||||
foreach ($BasePolicyEmployeeData as $key => $value) {
|
||||
|
||||
$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 = ($only_si_value == 0) ? $employee_policy->basic_cover_si : $only_si_value; }
|
||||
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;}
|
||||
$temp3['is_value_exist'] = true;
|
||||
@ -1878,8 +1889,12 @@ class EmployeeRestController extends AdminController
|
||||
$whereArray = [];
|
||||
foreach ( $decodedArray->family_floaters as $key => $value) {
|
||||
if($value != 0){
|
||||
if($key == 'parents'){ $text = 'parent'; }else if($key == 'childrens'){ $text = 'child'; }else if($key == 'parents-in-law'){$text = 'parent_in_law';}else{ $text = $key; }
|
||||
array_push($whereArray,$text);
|
||||
if($key == 'parents'){ $text = ["parent"]; }
|
||||
else if($key == 'childrens'){ $text = ["child"]; }
|
||||
else if($key == 'parents-in-law'){ $text = ["parent_in_law"];}
|
||||
else if($key ==='either-parents-pil') { $text = ["parent", "parent_in_law"];}
|
||||
else{ $text = [$key]; }
|
||||
$whereArray = array_merge($whereArray, $text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1895,7 +1910,7 @@ class EmployeeRestController extends AdminController
|
||||
foreach ($BasePolicyEmployeeData as $key => $value) {
|
||||
|
||||
$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 = ($only_si_value == 0) ? $employee_policy->basic_cover_si : $only_si_value; }
|
||||
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;}
|
||||
$temp3['is_value_exist'] = true;
|
||||
@ -2267,8 +2282,19 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
if($clientPolicy[0]['is_addon'] == 2)//Topup
|
||||
{
|
||||
$empData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
||||
->where('is_addon_value', 0 )->findAll();
|
||||
|
||||
if($clientPolicy[0]['policy_type_id'] == 4)//GMC-Topup
|
||||
{
|
||||
$empData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
||||
->where('is_addon_value', 0 )
|
||||
->findAll();
|
||||
}else if($clientPolicy[0]['policy_type_id'] == 5)//GMC-Parent-Topup
|
||||
{
|
||||
$empData = $this->employeeModel->where('emp_code',$this->request->getGet('emp_code'))
|
||||
->where('is_addon_value', 1 )
|
||||
->findAll();
|
||||
}
|
||||
|
||||
if(count($empData))
|
||||
{
|
||||
foreach ($empData as $key => $value) {
|
||||
@ -2637,6 +2663,62 @@ class EmployeeRestController extends AdminController
|
||||
// log_message('error', $e->getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public function getFamilyPolicyDetails()
|
||||
{
|
||||
// Get query parameters
|
||||
$empCode = $this->request->getGet('emp_code');
|
||||
$clientId = $this->request->getGet('client_id');
|
||||
$clientBranchId = $this->request->getGet('client_branch_id');
|
||||
|
||||
if (!$empCode || !$clientId || !$clientBranchId) {
|
||||
return $this->fail("emp_code, client_id, and client_branch_id are required parameters.");
|
||||
}
|
||||
|
||||
// Fetch employee family details
|
||||
$employees = $this->employeeModel->select('id,emp_code,name,relationship,dob,emp_status,is_addon_value')->where([
|
||||
'emp_code' => $empCode,
|
||||
'client_id' => $clientId,
|
||||
'client_branch_id' => $clientBranchId,
|
||||
'is_active' => 1
|
||||
])->findAll();
|
||||
|
||||
if (empty($employees)) {
|
||||
return $this->failNotFound("No employees found for the provided parameters.");
|
||||
}
|
||||
|
||||
// Collect employee IDs
|
||||
$employeeIds = array_column($employees, 'id');
|
||||
|
||||
// Fetch policies related to the employee IDs
|
||||
$policies = $this->employeePolicyModel->whereIn('employee_id', $employeeIds)->where('is_active',1)->findAll();
|
||||
|
||||
if (empty($policies)) {
|
||||
return $this->failNotFound("No policies found for the provided employees.");
|
||||
}
|
||||
|
||||
// Structure the response
|
||||
$result = [];
|
||||
foreach ($policies as $policy) {
|
||||
$policyEmployees = array_filter($employees, function ($emp) use ($policy) {
|
||||
return $emp['id'] === $policy['employee_id'];
|
||||
});
|
||||
|
||||
$result[] = [
|
||||
'policy_id' => $policy['id'],
|
||||
'client_policy_id' => $policy['client_policy_id'],
|
||||
'uhid' => $policy['uhid'],
|
||||
'status' => $policy['status'],
|
||||
'basic_cover_si' => $policy['basic_cover_si'],
|
||||
'date_coverage' => $policy['date_coverage'],
|
||||
'policy_end_date' => $policy['policy_end_date'],
|
||||
'members' => array_values($policyEmployees),
|
||||
];
|
||||
}
|
||||
|
||||
return $this->respond(['family_policies' => $result]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1036,7 +1036,7 @@ class EmployeeServiceController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
if(($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms) && ($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0)) // 3 is GMC parents dep addon)
|
||||
if((($file['action'] == 'inception' || $file['action'] == 'missed_inception' || $file['action'] == 'addition' || $file['action'] == 'enrollment') || ($policy_details['policy_type_id'] == 3 && $is_self_available_in_policy_terms)) && ($policy_details['base_policy'] == null || $policy_details['base_policy'] == 0)) // 3 is GMC parents dep addon)
|
||||
{
|
||||
$res = check_self_available_in_family($family,$file['action']);
|
||||
if(!$res['is_self_found'])
|
||||
@ -1049,7 +1049,7 @@ class EmployeeServiceController extends AdminController
|
||||
//check self avaialbe either same policy DB level(i.e.) gMC parents
|
||||
if($file['action'] == 'dependent_addition' || ($policy_details['policy_type_id'] == 3 && !$is_self_available_in_policy_terms)) // 3 is GMC parents as base policy not as dep addon)
|
||||
{
|
||||
$self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: trim($emp_id),client_id: $file['client_id'],emp_status: ['active'],policy_status:['active'],client_branch_id:[ $file['client_branch_id'] ],relationship:['self']);
|
||||
$self_details = $this->employeeModel->getEmpFamilybyEmpCode(emp_code: trim($emp_id),client_id: $file['client_id'],emp_status: ['active','draft','enrolled'],policy_status:['active','draft','enrolled'],client_branch_id:[ $file['client_branch_id'] ],relationship:['self']);
|
||||
// dd($self_details);
|
||||
if(!count($self_details))
|
||||
{
|
||||
@ -1928,297 +1928,200 @@ public function getFileMetaDataByFileId($file_id, $status = 'success'){
|
||||
|
||||
}
|
||||
|
||||
public function employeesEnrollmentInsert($params)
|
||||
{
|
||||
|
||||
public function employeesEnrollmentInsert($params)
|
||||
{
|
||||
|
||||
helper('excel_util_helper');
|
||||
//get file name
|
||||
$file_id = $params['file_id'];
|
||||
$file = $this->fileModel->find($file_id);
|
||||
// dd($file);
|
||||
$return = [];
|
||||
if (!isset($file)) {
|
||||
//file not found in DB
|
||||
return array('status' => false, 'msg' => 'file not found in DB');
|
||||
}
|
||||
$file_name_with_path = WRITEPATH . "/uploads/excel/" . $file['file_name'];
|
||||
|
||||
//check physical file
|
||||
if (!file_exists($file_name_with_path)) {
|
||||
//file not found update status and reason
|
||||
$message = "Physical file not found";
|
||||
// echo $message;
|
||||
$this->myLogger->logme('error', ($message . ' for file id ' . $file_id));
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'failed', 'reason' => json_encode(['error_summary' => array_count_values([5]), 'error_data' => $message])])->update();
|
||||
return array('error_summary' => [5], 'error_data' => $message);
|
||||
}
|
||||
|
||||
//get excel data
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$result = ['error_type' => 2, 'error_summary' => [], 'error_data' => []];
|
||||
$columns_to_check = $this->enrollment_excel_columns;
|
||||
$keys = array_keys($columns_to_check);
|
||||
$allowedHighestColumn = end($columns_to_check);
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
|
||||
// print_r($keys);die();
|
||||
//get existing units in the current branch
|
||||
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'], client_branch_id: $file['client_branch_id']);
|
||||
//remove header
|
||||
unset($excel_data[0]);
|
||||
// dd($excel_data);
|
||||
$emp_emails = [];
|
||||
|
||||
//check is welcome notification enabled
|
||||
$notification = $this->notificationModel->where('client_id', $file['client_id'])->where('template_name', 'member_welcome_mail')->first();
|
||||
// dd($notification);
|
||||
$client_details = $this->clientModel->where('id', $file['client_id'])->first();
|
||||
|
||||
// dd($excel_data);
|
||||
$emp_emails = []; // Initialize an empty array to store employee email.
|
||||
|
||||
foreach ($excel_data as $key => $row) {
|
||||
$is_row_empty = check_row_is_empty_or_null($row);
|
||||
if (!$is_row_empty) {
|
||||
$value = [];
|
||||
$policy_data = [];
|
||||
$temp_unit = '';
|
||||
if (empty($row[12])) {
|
||||
$temp_unit = $existing_units[0];
|
||||
helper('excel_util_helper');
|
||||
//get file name
|
||||
$file_id = $params['file_id'];
|
||||
$file = $this->fileModel->find($file_id);
|
||||
// dd($file);
|
||||
$return = [];
|
||||
if(!isset($file))
|
||||
{
|
||||
//file not found in DB
|
||||
return array('status' => false, 'msg' => 'file not found in DB');
|
||||
}
|
||||
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
|
||||
|
||||
//check physical file
|
||||
if(!file_exists($file_name_with_path))
|
||||
{
|
||||
//file not found update status and reason
|
||||
$message = "Physical file not found";
|
||||
// echo $message;
|
||||
$this->myLogger->logme('error',($message . ' for file id ' . $file_id));
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'failed','reason' => json_encode(['error_summary' => array_count_values([5]),'error_data' => $message])])->update();
|
||||
return array('error_summary' => [5], 'error_data' => $message);
|
||||
}
|
||||
|
||||
$value['emp_code'] = $row[1];
|
||||
$value['name'] = $row[2];
|
||||
$value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3], 'Y-m-d') : null);
|
||||
$value['gender'] = $row[4];
|
||||
$value['relationship'] = ucfirst(trim($row[5]));
|
||||
$value['dob'] = convert_string_to_date($row[6], 'Y-m-d');
|
||||
$value['email_corporate'] = $row[7];
|
||||
$value['mobile'] = $row[8];
|
||||
$value['band'] = $row[10];
|
||||
$value['basic_pay'] = $row[11];
|
||||
$value['unit'] = $temp_unit;
|
||||
$value['family_floater_key'] = null;
|
||||
$value['client_id'] = $file['client_id'];
|
||||
$value['client_branch_id'] = $file['client_branch_id'];
|
||||
$value['file_id'] = $file_id;
|
||||
//get excel data
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$highestRowAndColumn = $sheet->getHighestRowAndColumn();
|
||||
$result = ['error_type' => 2,'error_summary' => [], 'error_data' => [] ];
|
||||
$columns_to_check = $this->enrollment_excel_columns;
|
||||
$keys = array_keys($columns_to_check);
|
||||
$allowedHighestColumn = end($columns_to_check);
|
||||
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
|
||||
// print_r($keys);die();
|
||||
//get existing units in the current branch
|
||||
$existing_units = $this->clientBranchModel->getExisitingUnits(client_id: $file['client_id'],client_branch_id: $file['client_branch_id']);
|
||||
//remove header
|
||||
unset($excel_data[0]);
|
||||
// dd($excel_data);
|
||||
$emp_emails = [];
|
||||
|
||||
//check is welcome notification enabled
|
||||
$notification = $this->notificationModel->where('client_id',$file['client_id'])->where('template_name','member_welcome_mail')->first();
|
||||
// dd($notification);
|
||||
$client_details = $this->clientModel->where('id', $file['client_id'])->first();
|
||||
$policy_details = $this->clientPolicyModel->where('id', $file['policy_id'])->first();
|
||||
|
||||
$value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model
|
||||
if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') {
|
||||
$relation = 'parent';
|
||||
} else if (strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter') {
|
||||
$relation = 'child';
|
||||
} else if (strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law') {
|
||||
$relation = 'parent_in_law';
|
||||
} else if (strtolower(trim($value['relationship'])) === 'spouse') {
|
||||
$relation = 'spouse';
|
||||
} else {
|
||||
$relation = 'self';
|
||||
}
|
||||
$value['family_floater_key'] = $relation;
|
||||
// dd($policy_details);
|
||||
|
||||
$policy_data['basic_cover_si'] = $row[9];
|
||||
$policy_data['date_coverage'] = $row[13];
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
foreach ($excel_data as $key => $row)
|
||||
{
|
||||
$is_row_empty = check_row_is_empty_or_null($row);
|
||||
if(!$is_row_empty)
|
||||
{
|
||||
|
||||
$employee = $this->employeeModel->checkExistingEmployee($value, $file['client_branch_id']);
|
||||
unset($value['temp']);
|
||||
//save employee table
|
||||
// dd($employee['id']);
|
||||
if ($employee !== null) {
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
$value['id'] = $employee['id'];
|
||||
$value['emp_status'] = 'draft';
|
||||
|
||||
$log_message = 'Enrollment Update Employee - ' . $employee['name'] . '(' . $employee['emp_code'] . ') with PK ' . $employee['id'];
|
||||
} else {
|
||||
$value['emp_status'] = 'draft';
|
||||
$value['created_by'] = $file['created_by'];
|
||||
$log_message = 'Enrollment Insert Employee- ' . $value['name'] . '(' . $value['emp_code'] . ') with PK ';
|
||||
}
|
||||
|
||||
$this->employeeModel->save($value);
|
||||
if (isset($value['id'])) {
|
||||
$emp_id = $value['id'];
|
||||
} else {
|
||||
$emp_id = $this->employeeModel->getInsertID();
|
||||
$log_message .= $emp_id;
|
||||
}
|
||||
|
||||
// $emp_id = $this->employeeModel->getInsertID();
|
||||
// if($emp_id != 0){ $log_message .= $emp_id; }
|
||||
// else{ $emp_id = $employee['id']; }
|
||||
|
||||
$this->myLogger->logme('error', $log_message);
|
||||
|
||||
//save policy table
|
||||
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id, 'client_policy_id' => $file['policy_id']]);
|
||||
if (count($employee_policy)) {
|
||||
$policy_data['updated_by'] = $file['created_by'];
|
||||
$policy_data['id'] = $employee_policy[0]['id'];
|
||||
$policy_data['status'] = 'draft';
|
||||
|
||||
$log_message = 'Update Employee Policy for ' . $value['name'] . '(' . $value['emp_code'] . ') with PK- ' . $employee_policy[0]['id'] . ' client policy ID ' . $employee_policy[0]['client_policy_id'] . ' with SI ' . $policy_data['basic_cover_si'];
|
||||
// echo 'insert policy';
|
||||
} else {
|
||||
$policy_data['employee_id'] = $emp_id;
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
$policy_data['created_by'] = $file['created_by'];
|
||||
$policy_data['status'] = 'draft';
|
||||
$log_message = 'Insert Employee Policy for ' . $value['name'] . '(' . $value['emp_code'] . ') - client policy id -' . $file['policy_id'] . ' - with SI ' . $policy_data['basic_cover_si'];
|
||||
// echo 'update policy';
|
||||
}
|
||||
|
||||
$this->employeePolicyModel->save($policy_data);
|
||||
// $emp_policy_id = $this->employeePolicyModel->getInsertID();
|
||||
$emp_policy_id = isset($policy_data['id']) ? $policy_data['id'] : $this->employeePolicyModel->getInsertID();
|
||||
$this->myLogger->logme('error', $log_message);
|
||||
|
||||
//save email of self for send mail later
|
||||
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '') {
|
||||
if (strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "") {
|
||||
$params['dataToInsert'] = $value; //holds employee master data
|
||||
$params['notification'] = $notification;
|
||||
$params['client_data'] = $client_details;
|
||||
$params['common'] = [
|
||||
'client_id' => $file['client_id'],
|
||||
'client_branch_id' => $file['client_branch_id'],
|
||||
'client_policy_id' => $file['policy_id'],
|
||||
'employee_policy_id' => $emp_policy_id ?? null,
|
||||
'employee_id' => $emp_id,
|
||||
'mail_type' => 'member_welcome_mail',
|
||||
];
|
||||
|
||||
//store email and mail content via helper to send notification
|
||||
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
|
||||
// Kint::dump($emp_emails);
|
||||
// Kint::dump($key.'-'.count($excel_data));
|
||||
// if mail count is 20 send bulk mail and reset emp_emails variable
|
||||
// if (count($emp_emails) == 20 || $key == count($excel_data) ) {
|
||||
// $job_details = new Jobs();
|
||||
// $r = Jobs::addJob(['job_name' => 'bulk_mail','payload' => $emp_emails]);
|
||||
// // echo 'Mail triggered';
|
||||
// $emp_emails = [];
|
||||
// }
|
||||
|
||||
}
|
||||
$value['family_floater_key'] = $relation;
|
||||
|
||||
$policy_data['basic_cover_si'] = $row[9];
|
||||
$policy_data['date_coverage'] = $row[13];
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
|
||||
$employee = $this->employeeModel->checkExistingEmployee($value, $file['client_branch_id']);
|
||||
unset($value['temp']);
|
||||
//save employee table
|
||||
// dd($employee['id']);
|
||||
if ($employee !== null) {
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
$value['id'] = $employee['id'];
|
||||
$value['emp_status'] = 'draft';
|
||||
|
||||
$log_message = 'Enrollment Update Employee - ' . $employee['name'] . '(' . $employee['emp_code'] . ') with PK ' . $employee['id'];
|
||||
} else {
|
||||
$value['emp_status'] = 'draft';
|
||||
$value['created_by'] = $file['created_by'];
|
||||
$log_message = 'Enrollment Insert Employee- ' . $value['name'] . '(' . $value['emp_code'] . ') with PK ';
|
||||
}
|
||||
|
||||
$this->employeeModel->save($value);
|
||||
if (isset($value['id'])) {
|
||||
$emp_id = $value['id'];
|
||||
} else {
|
||||
$emp_id = $this->employeeModel->getInsertID();
|
||||
$log_message .= $emp_id;
|
||||
}
|
||||
|
||||
// $emp_id = $this->employeeModel->getInsertID();
|
||||
// if($emp_id != 0){ $log_message .= $emp_id; }
|
||||
// else{ $emp_id = $employee['id']; }
|
||||
|
||||
$this->myLogger->logme('error', $log_message);
|
||||
|
||||
//save policy table
|
||||
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id, 'client_policy_id' => $file['policy_id']]);
|
||||
if (count($employee_policy)) {
|
||||
$policy_data['updated_by'] = $file['created_by'];
|
||||
$policy_data['id'] = $employee_policy[0]['id'];
|
||||
$policy_data['status'] = 'draft';
|
||||
|
||||
$log_message = 'Update Employee Policy for ' . $value['name'] . '(' . $value['emp_code'] . ') with PK- ' . $employee_policy[0]['id'] . ' client policy ID ' . $employee_policy[0]['client_policy_id'] . ' with SI ' . $policy_data['basic_cover_si'];
|
||||
// echo 'insert policy';
|
||||
} else {
|
||||
$policy_data['employee_id'] = $emp_id;
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
$policy_data['created_by'] = $file['created_by'];
|
||||
$policy_data['status'] = 'draft';
|
||||
$log_message = 'Insert Employee Policy for ' . $value['name'] . '(' . $value['emp_code'] . ') - client policy id -' . $file['policy_id'] . ' - with SI ' . $policy_data['basic_cover_si'];
|
||||
// echo 'update policy';
|
||||
}
|
||||
|
||||
$this->employeePolicyModel->save($policy_data);
|
||||
$emp_policy_id = $this->employeePolicyModel->getInsertID();
|
||||
$this->myLogger->logme('error', $log_message);
|
||||
|
||||
//save email of self for send mail later
|
||||
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '') {
|
||||
if (strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "") {
|
||||
$params['dataToInsert'] = $value; //holds employee master data
|
||||
$params['notification'] = $notification;
|
||||
$params['client_data'] = $client_details;
|
||||
$params['common'] = [
|
||||
'client_id' => $file['client_id'],
|
||||
'client_branch_id' => $file['client_branch_id'],
|
||||
'client_policy_id' => $file['policy_id'],
|
||||
'employee_policy_id' => $emp_policy_id ?? null,
|
||||
'employee_id' => $emp_id,
|
||||
'mail_type' => 'member_welcome_mail',
|
||||
];
|
||||
|
||||
//store email and mail content via helper to send notification
|
||||
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
|
||||
// Kint::dump($emp_emails);
|
||||
// Kint::dump($key.'-'.count($excel_data));
|
||||
// if mail count is 20 send bulk mail and reset emp_emails variable
|
||||
// if (count($emp_emails) == 20 || $key == count($excel_data)) {
|
||||
// $job_details = new Jobs();
|
||||
// $r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $emp_emails]);
|
||||
// // echo 'Mail triggered';
|
||||
// $emp_emails = [];
|
||||
// }
|
||||
$value = [];
|
||||
$policy_data = [];
|
||||
$temp_unit = '';
|
||||
if(empty($row[12]))
|
||||
{
|
||||
$temp_unit = $existing_units[0];
|
||||
}
|
||||
|
||||
$value['emp_code'] = $row[1];
|
||||
$value['name'] = $row[2];
|
||||
$value['doj'] = (!empty($row[3]) ? convert_string_to_date($row[3],'Y-m-d'): null);
|
||||
$value['gender'] = $row[4];
|
||||
$value['relationship'] = ucfirst(trim($row[5]));
|
||||
$value['dob'] = convert_string_to_date($row[6],'Y-m-d');
|
||||
$value['email_corporate'] = $row[7];
|
||||
$value['mobile'] = $row[8];
|
||||
$value['band'] = $row[10];
|
||||
$value['basic_pay'] = $row[11];
|
||||
$value['unit'] = $temp_unit;
|
||||
$value['family_floater_key'] = null;
|
||||
$value['client_id'] = $file['client_id'];
|
||||
$value['client_branch_id'] = $file['client_branch_id'];
|
||||
$value['file_id'] = $file_id;
|
||||
$value['is_addon_value'] = $policy_details['policy_type_id'] == 3 ? 1 : 0;
|
||||
|
||||
$value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model
|
||||
if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') {
|
||||
$relation = 'parent';
|
||||
} else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){
|
||||
$relation = 'child';
|
||||
}else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){
|
||||
$relation = 'parent_in_law';
|
||||
}else if(strtolower(trim($value['relationship'])) === 'spouse'){
|
||||
$relation = 'spouse';
|
||||
}else{
|
||||
$relation = 'self';
|
||||
}
|
||||
$value['family_floater_key'] = $relation;
|
||||
|
||||
$policy_data['basic_cover_si'] = $row[9];
|
||||
$policy_data['date_coverage'] = $row[13] != "" && $row[13] != null ? change_date_format($row[13],'d-M-Y','Y-m-d') : null;
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
|
||||
$employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']);
|
||||
unset($value['temp']);
|
||||
//save employee table
|
||||
// dd($employee['id']);
|
||||
if($employee !== null)
|
||||
{
|
||||
$value['updated_by'] = $file['created_by'];
|
||||
$value['id'] = $employee['id'];
|
||||
$value['emp_status'] = 'draft';
|
||||
|
||||
$log_message = 'Enrollment Update Employee - '.$employee['name'].'('.$employee['emp_code'].') with PK '.$employee['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$value['emp_status'] = 'draft';
|
||||
$value['created_by'] = $file['created_by'];
|
||||
$log_message = 'Enrollment Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK ';
|
||||
}
|
||||
|
||||
$this->employeeModel->save($value);
|
||||
if (isset($value['id']))
|
||||
{ $emp_id = $value['id']; }
|
||||
else { $emp_id = $this->employeeModel->getInsertID();
|
||||
$log_message .= $emp_id;
|
||||
}
|
||||
|
||||
// $emp_id = $this->employeeModel->getInsertID();
|
||||
// if($emp_id != 0){ $log_message .= $emp_id; }
|
||||
// else{ $emp_id = $employee['id']; }
|
||||
|
||||
$this->myLogger->logme('error',$log_message);
|
||||
|
||||
//save policy table
|
||||
$employee_policy = $this->employeePolicyModel->checkExistingEmpPolicy(['employee_id' => $emp_id,'client_policy_id' => $file['policy_id']]);
|
||||
if(count($employee_policy))
|
||||
{
|
||||
$policy_data['updated_by'] = $file['created_by'];
|
||||
$policy_data['id'] = $employee_policy[0]['id'];
|
||||
$policy_data['status'] = 'draft';
|
||||
|
||||
$log_message = 'Update Employee Policy for '. $value['name'].'('. $value['emp_code'].') with PK- ' . $employee_policy[0]['id'] .' client policy ID '.$employee_policy[0]['client_policy_id'].' with SI '.$policy_data['basic_cover_si'];
|
||||
// echo 'insert policy';
|
||||
}
|
||||
else
|
||||
{
|
||||
$policy_data['employee_id'] = $emp_id;
|
||||
$policy_data['client_policy_id'] = $file['policy_id'];
|
||||
$policy_data['created_by'] = $file['created_by'];
|
||||
$policy_data['status'] = 'draft';
|
||||
$log_message = 'Insert Employee Policy for '. $value['name'].'('. $value['emp_code'].') - client policy id -'. $file['policy_id'].' - with SI '.$policy_data['basic_cover_si'];
|
||||
// echo 'update policy';
|
||||
}
|
||||
|
||||
$this->employeePolicyModel->save($policy_data);
|
||||
$emp_policy_id = $this->employeePolicyModel->getInsertID();
|
||||
$this->myLogger->logme('error',$log_message);
|
||||
|
||||
//save email of self for send mail later
|
||||
if (isset($notification) && $notification['enabled'] == 1 && $notification['mail_content'] != '')
|
||||
{
|
||||
if(strtolower($value['relationship']) == 'self' && $value['email_corporate'] != "")
|
||||
{
|
||||
$params['dataToInsert'] = $value; //holds employee master data
|
||||
$params['notification'] = $notification;
|
||||
$params['client_data'] = $client_details;
|
||||
|
||||
//store email and mail content via helper to send notification
|
||||
$emp_emails[] = sendMailNotification::sendMailNotification('member_welcome_mail', $params);
|
||||
}
|
||||
}
|
||||
}// endof if row is empty check
|
||||
} //end of for loop
|
||||
|
||||
|
||||
// for bulk mail queue job push
|
||||
if (!empty($emp_emails) && count($emp_emails) > 0) {
|
||||
|
||||
$emp_emails = array_chunk($emp_emails, 20);
|
||||
|
||||
foreach ($emp_emails as $key => $value) {
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]);
|
||||
}
|
||||
} // endof if row is empty check
|
||||
} //end of for loop
|
||||
|
||||
// dd($emp_emails);
|
||||
|
||||
// for bulk mail queue job push
|
||||
if (!empty($emp_emails) && count($emp_emails) > 0) {
|
||||
|
||||
$emp_emails = array_chunk($emp_emails, 20);
|
||||
|
||||
foreach ($emp_emails as $key => $value) {
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'bulk_mail', 'payload' => $value]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'success', 'reason' => ''])->update();
|
||||
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => ''])->update();
|
||||
$this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]);
|
||||
|
||||
$this->setPullNotification($this->getFileMetaDataByFileId($file_id, 'success'));
|
||||
$this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success'));
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}//end of employeesEnrollmentInsert
|
||||
|
||||
}
|
||||
@ -123,30 +123,22 @@ class RestAuthenticationController extends AdminController
|
||||
try {
|
||||
|
||||
$otp_verification = $this->request->getJSON()->otp_verification;
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
|
||||
if (isset($this->request->getJSON()->login_by_hr))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('id', $this->request->getJSON()->employee_id)->where('relationship', 'self')->first();
|
||||
$employeeData = $this->employeeModel->where('id', $this->request->getJSON()->employee_id)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||
}else{
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$email_id = $this->request->getJSON()->email_id;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('relationship', 'self');
|
||||
|
||||
if (isset($mobile_number)) {
|
||||
$employeeData = $employeeData->where('mobile', $mobile_number);
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||
} else {
|
||||
$employeeData = $employeeData->where('email', $email_id);
|
||||
}
|
||||
|
||||
$employeeData = $employeeData->first();
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr)) {
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
@ -257,11 +249,20 @@ class RestAuthenticationController extends AdminController
|
||||
public function saveMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
|
||||
if (isset($mobile_number)) {
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
} else {
|
||||
$employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->first();
|
||||
}
|
||||
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
@ -288,12 +289,20 @@ class RestAuthenticationController extends AdminController
|
||||
public function updateMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$old_mpin = $this->request->getJSON()->old_mpin;
|
||||
$mpin = $this->request->getJSON()->new_mpin;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('email', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
@ -320,10 +329,17 @@ class RestAuthenticationController extends AdminController
|
||||
public function verifyMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->first();
|
||||
}
|
||||
|
||||
if ($employeeData && $mpin == $employeeData["mpin"]) {
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
@ -355,10 +371,19 @@ class RestAuthenticationController extends AdminController
|
||||
public function checkMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('email', $email_id)->where('relationship', 'self')->first();
|
||||
}
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
|
||||
|
||||
if ($employeeData && $employeeData["mpin"] != null) {
|
||||
|
||||
|
||||
@ -282,11 +282,11 @@ class sendMailNotification
|
||||
$premium = '';
|
||||
$gst_forself = '';
|
||||
|
||||
if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
|
||||
// if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){
|
||||
$si = '₹ ' .format_indian_number($inner_item['basic_cover_si']);
|
||||
$premium = '₹ ' .format_indian_number(round($inner_item['premium']));
|
||||
$gst_forself = '₹ ' .format_indian_number(round($inner_item['gst']));
|
||||
}
|
||||
// }
|
||||
|
||||
$temp_data .= '<tr>';
|
||||
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
|
||||
|
||||
@ -149,7 +149,7 @@ class EmployeeModel extends Model
|
||||
{
|
||||
|
||||
return $this->db->table('employee_polices')
|
||||
->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment, client_policy.is_member_modify_allowed, client_policy.disclaimer,client_policy.policy_type_id , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
|
||||
->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment,client_policy.disclaimer,client_policy.policy_type_id , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
|
||||
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->where('client_policy.policy_status', 1)
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user