FEATURE_ removeEmpAndEmpPolicyData new API : GWM

This commit is contained in:
bitbucket 2024-04-25 12:41:44 +05:30
parent ded7f75840
commit 850adec634
2 changed files with 72 additions and 0 deletions

View File

@ -268,6 +268,10 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){
$routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId");
$routes->get("getCashDepositData", "EmployeeRestController::getCashDepositData");
$routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData");
$routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData");
});
$routes->post("sendEmail", "EmployeeRestController::send_email");

View File

@ -1661,4 +1661,72 @@ public function exportCashDepositData()
}
public function removeEmpAndEmpPolicyData()
{
try {
$clientPolicy = $this->clientPolicyModel->where('id',$this->request->getGet('client_policy_id'))->findAll();
if(count($clientPolicy))
{
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(count($empData))
{
foreach ($empData as $key => $value) {
$this->employeePolicyModel->where('client_policy_id',$this->request->getGet('client_policy_id') )
->where('employee_id', $value['id'] )
->set(array('is_active'=> 0 ))
->update();
}
}
}
else if($clientPolicy[0]['is_addon'] == 3)//Dependent addon
{
$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) {
$this->employeePolicyModel->where('client_policy_id',$this->request->getGet('client_policy_id') )
->where('employee_id', $value['id'] )
->set(array('is_active'=> 0 ))
->update();
}
$this->employeeModel->where('emp_code', $this->request->getGet('emp_code') )
->where('is_active', 1 )->where('is_addon_value', 1 )
->set(array('is_active'=> 0 ))
->update();
}
}
return $this->respond(['status' => 'success','code' => 200,'data' =>[] ], 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);
}
}
}