GWM:CHANGES-IN-EMP-POLICY-API
This commit is contained in:
parent
39374c0b4b
commit
bcb83b85bf
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();
|
||||
}
|
||||
|
||||
}
|
||||
@ -161,12 +161,14 @@ class EmployeeRestController extends AdminController
|
||||
if (isset($item->id)) {
|
||||
//update old data
|
||||
$id = $item->id;
|
||||
$item->family_floater_key = $this->RelationshipMap($item->relationship);
|
||||
$employee = $this->employeeModel->update($id, (array)$item);
|
||||
if ($employee) {
|
||||
$Count++;
|
||||
}
|
||||
}else{
|
||||
//create new data
|
||||
$item->family_floater_key = $this->RelationshipMap($item->relationship);
|
||||
$employee = $this->employeeModel->insert($item);
|
||||
if ($employee) {
|
||||
$Count++;
|
||||
@ -190,6 +192,18 @@ 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';
|
||||
}
|
||||
}
|
||||
public function deleteDependence()
|
||||
{
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user