diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 4edaa27..13613ef 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -430,6 +430,8 @@ $routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController
$routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin");
$routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin");
$routes->post("/employeeRest/verifyEmployeeEmailId", "RestAuthenticationController::verifyEmployeeWithEmailId");
+// $routes->post("/employeeRest/saveMpin", "RestAuthenticationController::saveMpin");
+
//HR login api's
$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber");
diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
index 216e461..95ba5d5 100755
--- a/app/Controllers/RestAuthenticationController.php
+++ b/app/Controllers/RestAuthenticationController.php
@@ -346,6 +346,7 @@ class RestAuthenticationController extends AdminController
$id= $employeeData["id"];
$updateMpin = $this->employeeModel->where('id', $id)->set('mpin', $mpin)->update();
if($updateMpin){
+ $this->callThirdPartyAPI($this->request->getJSON(), 'updateEmpMPIN');
$result = ['user_verification' => true , 'message' => "Mpin Updated"];
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
}else{
@@ -355,10 +356,10 @@ class RestAuthenticationController extends AdminController
} else {
- $result = ['user_verification' => false , 'message' => "User not found"];
- return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
+ return $this->callThirdPartyAPI($this->request->getJSON(), 'saveMpin');
}
+
} catch (\Throwable $th) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
}
@@ -386,6 +387,7 @@ class RestAuthenticationController extends AdminController
$id= $employeeData["id"];
$updateMpin = $this->employeeModel->where('id', $id)->set('mpin', $mpin)->update();
if($updateMpin){
+ $this->callThirdPartyAPI($this->request->getJSON(), 'updateEmpMPIN');
$result = ['mpin_verification' => true , 'message' => "Mpin Updated"];
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
}else{
@@ -395,8 +397,7 @@ class RestAuthenticationController extends AdminController
} else {
- $result = ['mpin_verification' => false , 'message' => "Wrong Mpin"];
- return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
+ return $this->callThirdPartyAPI($this->request->getJSON(), 'updateMpin');
}
} catch (\Throwable $th) {
@@ -465,7 +466,9 @@ class RestAuthenticationController extends AdminController
return $this->respond(['status' => 'success','code' => 200,'data' => "Mpin - exist" , 'Mpin' =>$employeeData["mpin"]],200);
} else {
- return $this->respond(['status' => 'failed','code' => 404,'data' => "Mpin - not found", 'Mpin' =>null],200);
+ // return $this->respond(['status' => 'failed','code' => 404,'data' => "Mpin - not found", 'Mpin' =>null],200);
+ return $this->callThirdPartyAPI($this->request->getJSON(), 'checkMpin');
+
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php
index b584f42..c29345c 100755
--- a/app/Models/EmployeePolicyModel.php
+++ b/app/Models/EmployeePolicyModel.php
@@ -112,10 +112,40 @@ class EmployeePolicyModel extends Model
'emp.basic_pay',
'emp.band as grade',
'policy_type.policy_type',
- 'policy_type.id as policy_type_id',
'client_branch.branch_name as client_branch_name',
'client_branch.branch_code as client_branch_code',
'cp.policy_no',
+ 'cp.policy_type_id',
+
+ // Name audit trail
+ '(SELECT old_value FROM auditing_history WHERE pk = emp.id AND field_name = "name" AND table_name = "employees" ORDER BY id ASC LIMIT 1) AS name_first_old',
+ '(SELECT new_value FROM auditing_history WHERE pk = emp.id AND field_name = "name" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS name_last_new',
+
+ // DOB audit trail
+ '(SELECT old_value FROM auditing_history WHERE pk = emp.id AND field_name = "dob" AND table_name = "employees" ORDER BY id ASC LIMIT 1) AS dob_first_old',
+ '(SELECT new_value FROM auditing_history WHERE pk = emp.id AND field_name = "dob" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS dob_last_new',
+
+ // Gender audit trail
+ '(SELECT old_value FROM auditing_history WHERE pk = emp.id AND field_name = "gender" AND table_name = "employees" ORDER BY id ASC LIMIT 1) AS gender_first_old',
+ '(SELECT new_value FROM auditing_history WHERE pk = emp.id AND field_name = "gender" AND table_name = "employees" ORDER BY id DESC LIMIT 1) AS gender_last_new',
+
+ '(CASE
+ WHEN emp.relationship = "Self"
+ THEN (SELECT COUNT(id) FROM employees WHERE emp_code = emp.emp_code AND is_active = 0 AND emp_status != "truncated")
+ ELSE NULL
+ END) AS removed_count',
+
+ '(CASE
+ WHEN emp.relationship != "Self" AND emp.created_at != (
+ SELECT created_at
+ FROM employees
+ WHERE emp_code = emp.emp_code AND relationship = "Self" AND is_active = 1
+ LIMIT 1
+ )
+ THEN "Newly Added"
+ ELSE NULL
+ END) AS newly_added',
+
])
->join('employees emp', 'employee_polices.employee_id = emp.id')
->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
@@ -129,7 +159,9 @@ class EmployeePolicyModel extends Model
->join('client_branch', 'emp.client_branch_id = client_branch.id') //cm - client master
->orderBy('emp.emp_code', 'ASC')
->orderBy('employee_polices.employee_id', 'ASC');
- // Conditionally add where clauses
+
+
+ // Conditionally add where clauses
if ($client_id != 0 && !empty($client_id)) {
$result->where('emp.client_id', $client_id);
}
@@ -187,6 +219,114 @@ class EmployeePolicyModel extends Model
return $res;
}
+
+ // public function getEmployeePolicy($client_id = 0, $policy_id = 0, $status = [], $branch_id = 0, $emp_code = "", $emp_name = "")
+ // {
+ // // dd($status);
+
+ // $result = $this->select([
+ // 'employee_polices.*',
+ // 'policy_type.policy_type as policy_name',
+ // 'im.short_name as insurer_short_name',
+ // 'ib.branch_name as insurer_branch_name',
+ // 'ib.branch_code as insurer_branch_code',
+ // 'tpam.name as tpa_name',
+ // 'tpam.short_name as tpa_short_name',
+ // 'tpab.branch_code as tpa_branch_code',
+ // 'cm.client_name',
+ // 'cm.short_name as client_short_name',
+ // // 'emp.id as employee_primary_id',
+ // 'emp.relationship',
+ // 'emp.relationship_code',
+ // 'emp.change_event',
+ // 'emp.emp_code',
+ // 'emp.name',
+ // 'emp.email_corporate',
+ // 'emp.dob',
+ // 'DATE_FORMAT(emp.dob, "%d/%m/%Y") AS formatted_dob',
+ // 'emp.gender',
+ // 'emp.emp_status',
+ // 'emp.is_active as emp_is_active',
+ // 'emp.mobile as mobile',
+ // 'emp.doj',
+ // 'emp.basic_pay',
+ // 'emp.band as grade',
+ // 'policy_type.policy_type',
+ // 'policy_type.id as policy_type_id',
+ // 'client_branch.branch_name as client_branch_name',
+ // 'client_branch.branch_code as client_branch_code',
+ // 'cp.policy_no',
+ // ])
+ // ->join('employees emp', 'employee_polices.employee_id = emp.id')
+ // ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
+ // ->join('policies pm', 'cp.policy_id = pm.id', 'left') //pm - policy master
+ // ->join('policy_type', 'policy_type.id = cp.policy_type_id')
+ // ->join('insurers im', 'cp.insurer_id = im.id') //im - insurer master
+ // ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurer branch
+ // ->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master
+ // ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id', 'left') //tpab - tpa branch
+ // ->join('clients cm', 'cp.client_id = cm.id') //cm - client master
+ // ->join('client_branch', 'emp.client_branch_id = client_branch.id') //cm - client master
+ // ->orderBy('emp.emp_code', 'ASC')
+ // ->orderBy('employee_polices.employee_id', 'ASC');
+ // // Conditionally add where clauses
+ // if ($client_id != 0 && !empty($client_id)) {
+ // $result->where('emp.client_id', $client_id);
+ // }
+ // if ($branch_id != 0 && !empty($branch_id)) {
+ // $result->where('emp.client_branch_id', $branch_id);
+ // }
+ // if ($policy_id != 0 && !empty($policy_id)) {
+ // $result->where('employee_polices.client_policy_id', $policy_id);
+ // }
+
+ // if (is_array($status) && count($status) > 0) {
+
+ // $result->where('employee_polices.status !=', 'expired');
+
+ // if (in_array("active", $status)) {
+
+ // $result->where('employee_polices.tpa_id IS NOT NULL');
+ // $result->where('employee_polices.uhid IS NOT NULL');
+ // $result->whereIn('employee_polices.status', $status);
+ // } elseif (in_array("pending", $status)) {
+
+ // $result->where('employee_polices.tpa_id IS NULL');
+ // $result->where('employee_polices.uhid IS NULL');
+ // $result->whereIn('employee_polices.status', array_merge($status, ['active']));
+ // } else {
+
+ // $result->whereIn('employee_polices.status', $status);
+ // }
+
+ // // if($status == 'active'){
+ // // $result->where('employee_polices.tpa_id IS NOT NULL');
+ // // $result->where('employee_polices.uhid IS NOT NULL');
+ // // }else if($status == 'pending'){
+ // // $status = 'active';
+ // // $result->where('employee_polices.status', $status);
+ // // }else{
+ // // $result->where('employee_polices.status', $status);
+ // // }
+ // }
+
+ // if (!empty($emp_code)) {
+ // $result->where('emp.emp_code', $emp_code);
+ // }
+ // if (!empty($emp_name)) {
+ // $result->like('emp.name', $emp_name);
+ // }
+
+ // // Always check these conditions
+ // $result->where('employee_polices.is_active', 1)
+ // ->where('emp.is_active', 1);
+
+ // $res = $result->findAll();
+
+ // // dd($this->db->getLastQuery());
+
+ // return $res;
+ // }
public function getEmployeePolicyForEcard($policy_id = 0)
{
diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php
index caee58a..b01fd75 100755
--- a/app/Views/employee_data_list.php
+++ b/app/Views/employee_data_list.php
@@ -117,6 +117,7 @@
(₹)Pro Rata
Premium
DOB : " . change_date_format($employee['dob_first_old'], null, 'd/m/Y') . ' => ' . change_date_format($employee['dob_last_new'], null, 'd/m/Y') . "
"; + } + if(!empty($employee['gender_first_old'])){ + echo "Gender : " . $employee['gender_first_old'] . ' => ' . $employee['gender_last_new'] . "
"; + } + if(!empty($employee['newly_added'])){ + echo "" . $employee['newly_added'] . "
"; + } + if(!empty($employee['removed_count'])){ + echo "" . $employee['removed_count'] . " People removed
"; + } + if(empty($employee['name_first_old']) && empty($employee['dob_first_old']) && empty($employee['gender_first_old']) && empty($employee['removed_count'] ) && empty($employee['newly_added'] )){ + echo " - "; + } + ?> +