Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
68769f6242
@ -214,7 +214,7 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy");
|
|
||||||
|
|
||||||
$routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
|
$routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
|
||||||
|
|
||||||
|
|||||||
57
app/Controllers/EmployeeModel.php
Normal file
57
app/Controllers/EmployeeModel.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
|
||||||
|
class EmployeeModel extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'employees';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $allowedFields = [
|
||||||
|
"id",
|
||||||
|
"client_id",
|
||||||
|
"employee_id",
|
||||||
|
"change_event",
|
||||||
|
"relationship_id",
|
||||||
|
"relationship",
|
||||||
|
"batch_id",
|
||||||
|
"emp_code",
|
||||||
|
"name",
|
||||||
|
"email_personal",
|
||||||
|
"email_corporate",
|
||||||
|
"mobile",
|
||||||
|
"gender",
|
||||||
|
"dob",
|
||||||
|
"otp",
|
||||||
|
"emp_status",
|
||||||
|
"created_by",
|
||||||
|
"updated_by",
|
||||||
|
"is_active",
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getEmployeePolicy($id)
|
||||||
|
{
|
||||||
|
|
||||||
|
return $this->db->table('employee_polices')
|
||||||
|
->select(' policies.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') // Select all columns from both tables
|
||||||
|
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
|
||||||
|
->join('policies', 'policies.id = client_policy.policy_id')
|
||||||
|
->where('employee_polices.employee_id', $id)
|
||||||
|
->get()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// for EMP rest API process do not change
|
||||||
|
public function checkExistingEmpEntrollment($arr)
|
||||||
|
{
|
||||||
|
return $this->where('emp_code',$arr['emp_code'])->where('name',$arr['name'])->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -108,14 +108,20 @@ class EmployeeRestController extends AdminController
|
|||||||
try {
|
try {
|
||||||
$emp_code = $this->request->getGet('emp_code');
|
$emp_code = $this->request->getGet('emp_code');
|
||||||
if ($emp_code) {
|
if ($emp_code) {
|
||||||
$employee = $this->employeeModel->where('emp_code', $emp_code)
|
$employee = $this->employeeModel->where('emp_code', $emp_code)->findAll();
|
||||||
->findAll();
|
$dateConverter = function($item) {
|
||||||
|
if ($item['dob'] !== '0000-00-00') {
|
||||||
|
$dateTime = \DateTime::createFromFormat('Y-m-d', $item['dob']);
|
||||||
|
$item['dob'] = $dateTime->format('d-m-Y');
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
};
|
||||||
|
$employee = array_map($dateConverter, $employee);
|
||||||
|
return $this->respond(['status' => 'success','code' => 200,'data' => $employee],200);
|
||||||
|
|
||||||
$result = $employee;
|
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
|
||||||
} else {
|
} else {
|
||||||
$result = "No Match's";
|
|
||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
|
return $this->respond(['status' => 'failed','code' => 404,'data' => []],404);
|
||||||
}
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||||
@ -132,6 +138,7 @@ class EmployeeRestController extends AdminController
|
|||||||
$updatedCount = 0;
|
$updatedCount = 0;
|
||||||
foreach ($data as $item) {
|
foreach ($data as $item) {
|
||||||
$id = $item->id;
|
$id = $item->id;
|
||||||
|
$item->dob = $this->convertDateFormat($item->dob);
|
||||||
$employee = $this->employeeModel->update($id, (array)$item);
|
$employee = $this->employeeModel->update($id, (array)$item);
|
||||||
if ($employee) {
|
if ($employee) {
|
||||||
$updatedCount++;
|
$updatedCount++;
|
||||||
@ -164,12 +171,16 @@ class EmployeeRestController extends AdminController
|
|||||||
if (isset($item->id)) {
|
if (isset($item->id)) {
|
||||||
//update old data
|
//update old data
|
||||||
$id = $item->id;
|
$id = $item->id;
|
||||||
|
$item->family_floater_key = $this->RelationshipMap($item->relationship);
|
||||||
|
$item->dob = $this->convertDateFormat($item->dob);
|
||||||
$employee = $this->employeeModel->update($id, (array)$item);
|
$employee = $this->employeeModel->update($id, (array)$item);
|
||||||
if ($employee) {
|
if ($employee) {
|
||||||
$Count++;
|
$Count++;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//create new data
|
//create new data
|
||||||
|
$item->family_floater_key = $this->RelationshipMap($item->relationship);
|
||||||
|
$item->dob = $this->convertDateFormat($item->dob);
|
||||||
$employee = $this->employeeModel->insert($item);
|
$employee = $this->employeeModel->insert($item);
|
||||||
if ($employee) {
|
if ($employee) {
|
||||||
$Count++;
|
$Count++;
|
||||||
@ -193,9 +204,38 @@ class EmployeeRestController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function RelationshipMap($value){
|
||||||
|
|
||||||
|
if ($value === 'Mother' || $value === 'Father') {
|
||||||
|
return 'parent';
|
||||||
|
} else if($value === 'Son' || $value === 'Daughter'){
|
||||||
|
return 'child';
|
||||||
|
}else if($value === 'Father in Law' || $value === 'Mother in Law'){
|
||||||
|
return 'parent_in_law';
|
||||||
|
}else if($value === 'Spouse'){
|
||||||
|
return 'spouse';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function convertDateFormat($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;
|
||||||
|
}
|
||||||
|
}
|
||||||
public function deleteDependence()
|
public function deleteDependence()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
if($this->request->getGet('id'))
|
||||||
|
{
|
||||||
$delete = $this->employeeModel->where('id', $this->request->getGet('id'))->delete();
|
$delete = $this->employeeModel->where('id', $this->request->getGet('id'))->delete();
|
||||||
|
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
@ -203,6 +243,10 @@ class EmployeeRestController extends AdminController
|
|||||||
} else {
|
} else {
|
||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 404);
|
return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 404);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||||
@ -214,26 +258,10 @@ class EmployeeRestController extends AdminController
|
|||||||
public function getEmployeeAndDependenceByClientId()
|
public function getEmployeeAndDependenceByClientId()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$empData = $this->employeePolicyModel->getEmployeePolicy( $this->request->getGet('client_id'), $this->request->getGet('client_policy_id'));
|
||||||
|
// $empData = $this->employeeModel->where('client_id', $this->request->getGet('client_id'))
|
||||||
|
// ->where('relationship !=', null)
|
||||||
|
|
||||||
$empData = $this->employeeModel->where('client_id', $this->request->getGet('client_id'))
|
|
||||||
->where('relationship !=', null)
|
|
||||||
->orderBy('emp_code')->orderBy('id')->findAll();
|
|
||||||
|
|
||||||
// $result = [];
|
|
||||||
|
|
||||||
// foreach ($empData as $employee) {
|
|
||||||
// $employeeDependence = $this->employeeModel
|
|
||||||
// ->where('emp_code', $employee['emp_code'])
|
|
||||||
// ->where('relationship !=', 'self')
|
|
||||||
// ->findAll();
|
|
||||||
|
|
||||||
// // Use object notation to access properties and set 'dependence'
|
|
||||||
// $employee['dependence'] = $employeeDependence ?: [];
|
|
||||||
|
|
||||||
// $result[] = $employee;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// You probably meant to check $result, not $data
|
|
||||||
if ($empData) {
|
if ($empData) {
|
||||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200);
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200);
|
||||||
} else {
|
} else {
|
||||||
@ -255,9 +283,11 @@ class EmployeeRestController extends AdminController
|
|||||||
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
$result[] = $ClientPolicyData[0];
|
||||||
|
$result[] = $ClientPolicyData[2];
|
||||||
// You probably meant to check $result, not $data
|
// You probably meant to check $result, not $data
|
||||||
if ($ClientPolicyData) {
|
if ($ClientPolicyData) {
|
||||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $ClientPolicyData], 200);
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
||||||
} else {
|
} else {
|
||||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404);
|
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404);
|
||||||
}
|
}
|
||||||
@ -274,10 +304,12 @@ class EmployeeRestController extends AdminController
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$id = $this->request->getGet('id');
|
$id = $this->request->getGet('id');
|
||||||
|
$emp_code = $this->request->getGet('emp_code');
|
||||||
|
|
||||||
$keysToRemove = ["removable_keys"];
|
$keysToRemove = ["removable_keys"];
|
||||||
|
|
||||||
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
|
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
|
||||||
// dd($empPolicy);
|
$empData = $this->employeeModel->where('emp_code',$emp_code)->findAll();
|
||||||
if ($empPolicy) {
|
if ($empPolicy) {
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
@ -323,6 +355,32 @@ class EmployeeRestController extends AdminController
|
|||||||
array_splice($array->SlabRates, $index, 1);
|
array_splice($array->SlabRates, $index, 1);
|
||||||
array_unshift($array->SlabRates, $element);
|
array_unshift($array->SlabRates, $element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//map family floates array to employee and dependent
|
||||||
|
$familyFloates = $array->Policy_Terms->family_floaters;
|
||||||
|
$data = [];
|
||||||
|
foreach ($familyFloates as $familyFloatesValue) {
|
||||||
|
$dependent = preg_replace('/\d/', '', $familyFloatesValue);
|
||||||
|
if(count($empData)){
|
||||||
|
foreach ($empData as $key => $value) {
|
||||||
|
if ($value['family_floater_key'] === $dependent) {
|
||||||
|
$employee_policy = $this->employeePolicyModel->where('employee_id',$value['id'])->where('client_policy_id',$array->ClientPolicyId)->get()->getRow();
|
||||||
|
$temp['family_floater_key'] = $familyFloatesValue;
|
||||||
|
$temp['label'] = $value['relationship'];
|
||||||
|
$temp['name'] = $value['name'];
|
||||||
|
$temp['employee_id'] = $value['id'];
|
||||||
|
$temp['basic_cover_si'] = isset($employee_policy->basic_cover_si) ? $employee_policy->basic_cover_si : null;
|
||||||
|
$temp['client_policy_id'] = $array->ClientPolicyId;
|
||||||
|
|
||||||
|
array_push($data,$temp);
|
||||||
|
unset($empData[$key]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$array->mapped_family_floaters = $data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[] = $array;
|
$result[] = $array;
|
||||||
|
|||||||
@ -70,6 +70,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
try {
|
try {
|
||||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||||
$randomNumber = rand(100000, 999999);
|
$randomNumber = rand(100000, 999999);
|
||||||
|
$randomNumber = 123456;
|
||||||
|
|
||||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||||
|
|
||||||
@ -129,7 +130,7 @@ class RestAuthenticationController extends AdminController
|
|||||||
try {
|
try {
|
||||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||||
$randomNumber = rand(100000, 999999);
|
$randomNumber = rand(100000, 999999);
|
||||||
|
$randomNumber = 123456;
|
||||||
$HrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first();
|
$HrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first();
|
||||||
|
|
||||||
if ($HrData) {
|
if ($HrData) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user