CODE_MERGE : AADHAVAN

This commit is contained in:
aadhavan valli 2024-03-18 19:41:00 +05:30
commit b7dc303d61
7 changed files with 228 additions and 18 deletions

View File

@ -195,9 +195,12 @@ $routes->cli('processjob', 'JobWorker::processJob');
// $routes->get("/api", "RestAuthenticationController::index");
//Employee login api's
$routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber");
$routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
//HR login api's
$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber");
$routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData");
$routes->group("/api", ["filter" => "authJWT"], function($routes){
$routes->post("logined", "RestAuthenticationController::logined");
@ -208,7 +211,7 @@ $routes->group("/api", ["filter" => "authJWT"], function($routes){
$routes->get("/getEmployeeProfile", "EmployeeRestController::getEmployeeProfile/$1");
$routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfile");
$routes->get("/getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
$routes->post("/employeeUpload", "EmployeeRestController::employeeUpload");
$routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence");
@ -218,6 +221,11 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){
$routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence");
$routes->post("editEmployeeAndDependence", "EmployeeRestController::editEmployeeAndDependence");
$routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence");
$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
$routes->post("createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount");
$routes->get("deleteDependence", "EmployeeRestController::deleteDependence");
$routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId");
});
$routes->post("sendEmail", "EmployeeRestController::send_email");

View File

@ -74,7 +74,7 @@ class EmployeeRestController extends AdminController
} catch (\Throwable $th) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
}
}
}
public function editEmployeeProfile()
@ -190,30 +190,117 @@ class EmployeeRestController extends AdminController
}
public function deleteDependence()
{
try {
$delete = $this->employeeModel->where('id', $this->request->getGet('id'))->delete();
if ($delete) {
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);
}
}
public function getEmployeeAndDependenceByClientId()
{
try {
$empData = $this->employeeModel
->where('client_id', $this->request->getGet('client_id'))
->where('relationship', 'self')
->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 ($result) {
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 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);
}
}
public function getEmployeePolicy()
{
// $id= 4;
try {
$id = $this->request->getGet('id');
$keysToRemove = ["sum_insured","family_floater","corporatebuffer","family_floaters"];
$keysToRemove = ["removable_keys"];
$empPolicy = $this->employeeModel->getEmployeePolicy($id);
// dd($empPolicy);
if ($empPolicy) {
$result = [];
foreach ($empPolicy as $array) {
$decodedArray = json_decode($array->Policy_Terms);
$refusingData = (object) array_diff_key((array) $decodedArray, array_flip($keysToRemove));
// $client_id =$array->ClientId;
// $policy_id =$array->PolicyId;
// $rackRate = $this->policesModel->getPolicySlabRatesForEmpOnboard($policy_id, $client_id);
// $array->Policy_Terms = json_encode($refusingData);
$array->Policy_Terms = $refusingData;
$getSlabAndGridData = $this->policesModel->getPolicySlabRatesForEmpOnboard($array->ClientPolicyId,$array->ClientId);
$array->SlabRates = $getSlabAndGridData['slab_rates'];
$array->GridMaster = $getSlabAndGridData['grid_master'];
if($getSlabAndGridData['grid_master']['policy_type'] == "GPA"){
$default_si = $array->Policy_Terms->sumInsured2;
$index = -1;
foreach ($array->SlabRates as $key => $value) {
if ($value['si'] == $default_si) {
$index = $key;
break;
}
}
if ($index >= 0) {
$element =$array->SlabRates[$index];
array_splice($array->SlabRates, $index, 1);
array_unshift($array->SlabRates, $element);
}
}else if($getSlabAndGridData['grid_master']['policy_type'] == "GMC"){
// re-arranging order of si
$default_si = $array->Policy_Terms->sum_insured;
$index = -1;
foreach ($array->SlabRates as $key => $value) {
if ($value['si'] == $default_si) {
$index = $key;
break;
}
}
if ($index >= 0) {
$element =$array->SlabRates[$index];
array_splice($array->SlabRates, $index, 1);
array_unshift($array->SlabRates, $element);
}
}
$result[] = $array;
}
return $this->respond(['status' => 'success','code' => 200,'data' => $result], 200);
@ -226,6 +313,39 @@ class EmployeeRestController extends AdminController
}
// Get the RelationShip list
public function createOrUpdateEmployeePolicySiAmount()
{
try {
$requestData = $this->request->getJSON();
$checkIfExist = $this->employeePolicyModel->where('employee_id', $requestData['employee_id'])
->where('client_policy_id', $requestData['client_policy_id'])
->findAll();
// dd($checkIfExist);
if ($checkIfExist) {
$empPolicy = $this->employeePolicyModel->updateSiAndPremium($requestData['client_policy_id'], $requestData['employee_id'], $requestData['basic_cover_si']);
}else{
$data['employee_id']= $requestData['employee_id'];
$data['client_policy_id']= $requestData['client_policy_id'];
$data['basic_cover_si']= $requestData['basic_cover_si'];
$this->employeePolicyModel->insert($data);
}
return $this->respond(['status' => 'success','code' => 200,'data' => []], 200);
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
}
}
public function relationshipList()
{
try {

View File

@ -20,6 +20,7 @@ use CodeIgniter\API\ResponseTrait;
use App\Models\EmployeeModel;
use App\Models\AuthHistoryModel;
use App\Models\LevelContactModel;
use Firebase\JWT\JWT;
// require_once('../vendor/autoload.php');
@ -33,6 +34,7 @@ class RestAuthenticationController extends AdminController
protected $myLogger;
protected $employeeModel;
protected $authHistoryModel;
protected $hrModel;
public function __construct()
@ -42,6 +44,7 @@ class RestAuthenticationController extends AdminController
$this->employeeModel = new EmployeeModel();
$this->authHistoryModel = new AuthHistoryModel();
$this->hrModel = new LevelContactModel();
}
@ -121,6 +124,68 @@ class RestAuthenticationController extends AdminController
}
}
public function verifyHrWithMobileNumber()
{
try {
$mobile_number = $this->request->getJSON()->mobile_number;
$randomNumber = rand(100000, 999999);
$HrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first();
if ($HrData) {
$id= $HrData["id"];
$otp = $this->hrModel->where('id', $id)->set('otp', $randomNumber)->update();
$result = ['user_verification' => true , 'otp'=>$randomNumber];
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else {
$result = ['user_verification' => false];
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
}
} catch (\Throwable $th) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
}
}
public function getVerifiedHrData()
{
try {
$mobile_number = $this->request->getJSON()->mobile_number;
$otp = $this->request->getJSON()->otp;
$hrData = $this->hrModel->where('mobile', $mobile_number)->first();
if ($hrData && $otp == $hrData["otp"]) {
$auth = HttpRequestHelper::getRequestInfo();
if ($auth) {
$data = [
'user_id' => $hrData['id'],
'user_type' => 'hr',
'ip' => $auth['ip'],
'platform' => $auth['platform'],
'broswer' => $auth['browser'],
];
$authdata= $this->authHistoryModel->insert($data);
}
$otp_null = $this->hrModel->where('id', $hrData["id"])->set('otp', null)->update();
$hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id')
->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left')
->where('level_contacts.mobile', $mobile_number )
->find();
$result = JWTToken::encode($hrData);
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else {
return $this->respond(['status' => 'failed','code' => 404,'data' => "No data"],404);
}
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
}
}
public function employeeLogout()

View File

@ -37,7 +37,7 @@ class EmployeeModel extends Model
{
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.open_for_enrollment as OpenForEnrollment') // Select all columns from both tables
->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)

View File

@ -189,5 +189,18 @@ class EmployeePolicyModel extends Model
->find();
}
public function updateSiAndPremium( $client_policy_id, $employee_id,$basic_cover_si)
{
$query = "UPDATE employee_polices
SET employee_polices.basic_cover_si = '{$basic_cover_si}'
WHERE employee_polices.employee_id = '{$employee_id}'
AND employee_polices.client_policy_id = '{$client_policy_id}'";
$this->query($query);
}
//------------------------------------------------------------------
}

View File

@ -20,6 +20,7 @@ class LevelContactModel extends Model
"designation",
"created_by",
"updated_by",
"otp",
"is_active",
];

View File

@ -1,7 +1,9 @@
<?php
namespace App\Models;
use App\Models\PolicyPremium1Model;
use App\Models\PolicyPremium2Model;
use App\Models\PolicyGridModel;
use CodeIgniter\Model;
class PolicesModel extends Model
@ -35,16 +37,17 @@ class PolicesModel extends Model
{
$premium_slab_data = null;
$policyPremium1Model = new policyPremium1Model();
$policyPremium1Model = new PolicyPremium1Model();
$premium_slab_data = $policyPremium1Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll();
if((isset($premium_slab_data)))
if((!count($premium_slab_data)))
{
$policyPremium2Model = new policyPremium2Model();
$policyPremium2Model = new PolicyPremium2Model();
$premium_slab_data = $policyPremium2Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll();
}
$grid_id = $premium_slab_data[0]['policy_grid_id'];
$policyGridModel = new policyGridModel();
$policyGridModel = new PolicyGridModel();
$results = $policyGridModel->find($grid_id);
return ['slab_rates' => $premium_slab_data,'grid_master' => $results];
}