CHANGE_ADD_NEW_API_FIREBASE_TOKEN_API_EMP_REST : AADHAVAN
This commit is contained in:
parent
ba4ad6bb62
commit
5e3c126b0b
@ -136,6 +136,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("upload", "EmployeeController::employeesUplodWithEvents");
|
||||
$routes->get("excel_error/(:any)", "EmployeeController::getExcelFileErrors/$1");
|
||||
$routes->get("endorsement-list", "EmployeeController::endorsementList");
|
||||
$routes->get("enrollment-list", "EmployeeController::enrollmentList");
|
||||
$routes->get("truncate/(:any)", "EmployeeController::truncateFileData/$1");
|
||||
});
|
||||
|
||||
@ -287,6 +288,7 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
||||
|
||||
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->post("storeFireBase", "EmployeeRestController::storeFireBase");
|
||||
$routes->post("saveMpin", "RestAuthenticationController::saveMpin");
|
||||
$routes->post("updateMpin", "RestAuthenticationController::updateMpin");
|
||||
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
|
||||
|
||||
@ -928,9 +928,9 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
public function getAgeRange($terms,$familyFloatesValue)
|
||||
{
|
||||
//-------------------------------------
|
||||
public function getAgeRange($terms,$familyFloatesValue)
|
||||
{
|
||||
|
||||
$ageRangeArray = ['self' => ['min' => 18, 'max' => 60] , 'spouse' => ['min' => 18, 'max' => 60] , 'child' => ['min' => 0, 'max' => 25] , 'elders' => ['min' => 18, 'max' => 60] ];
|
||||
|
||||
@ -942,10 +942,10 @@ public function getAgeRange($terms,$familyFloatesValue)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function getEmployeePolicy()
|
||||
{
|
||||
public function getEmployeePolicy()
|
||||
{
|
||||
// try {
|
||||
|
||||
$id = $this->request->getGet('id');
|
||||
@ -1159,11 +1159,11 @@ public function getEmployeePolicy()
|
||||
// } catch (\Exception $e) {
|
||||
// return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id,$client_branch_id)
|
||||
{
|
||||
public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id,$client_branch_id)
|
||||
{
|
||||
|
||||
$employeeData = $this->employeeModel->where('emp_code',$emp_code)
|
||||
->where('client_id',$client_id)
|
||||
@ -1316,9 +1316,9 @@ public function getGmcParrentsPolicy($GmcParrentsPolicy,$emp_code,$client_id,$cl
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function FloterConvertion($array){
|
||||
public function FloterConvertion($array){
|
||||
|
||||
$result = [];
|
||||
|
||||
@ -1348,9 +1348,9 @@ public function FloterConvertion($array){
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function FloterNotesConvertion($array){
|
||||
public function FloterNotesConvertion($array){
|
||||
|
||||
$result = ' ';
|
||||
foreach ($array as $key => $value) {
|
||||
@ -1374,10 +1374,10 @@ public function FloterNotesConvertion($array){
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function getClientDetails()
|
||||
{
|
||||
public function getClientDetails()
|
||||
{
|
||||
try {
|
||||
|
||||
$client = $this->clientModel->where('id',$this->request->getGet('client_id'))->first();
|
||||
@ -1393,10 +1393,10 @@ public function getClientDetails()
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAddOnPolicy()
|
||||
{
|
||||
public function getAddOnPolicy()
|
||||
{
|
||||
try {
|
||||
|
||||
$addOnEmployeeData = $this->employeeModel->where('is_active', 1 )
|
||||
@ -1748,10 +1748,10 @@ public function getAddOnPolicy()
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function iAgreeForAddOn()
|
||||
{
|
||||
public function iAgreeForAddOn()
|
||||
{
|
||||
$postData = json_decode($this->request->getBody(), true);
|
||||
$client_policy_id = $postData['client_policy_id'];
|
||||
sort($client_policy_id);
|
||||
@ -1822,13 +1822,13 @@ public function iAgreeForAddOn()
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => [] ], 200);
|
||||
}
|
||||
}
|
||||
|
||||
//Post method - which receives client_policy id and empcode of the family.
|
||||
//Pull records againest emp code and calculate premium
|
||||
// retun array
|
||||
public function calculatePremium($clientPolicyId = null , $empCode = null, $default_si = null)//family level
|
||||
{
|
||||
//Post method - which receives client_policy id and empcode of the family.
|
||||
//Pull records againest emp code and calculate premium
|
||||
// retun array
|
||||
public function calculatePremium($clientPolicyId = null , $empCode = null, $default_si = null)//family level
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
$client_policy_id = $this->request->getVar('client_policy_id') ?? $clientPolicyId;
|
||||
$emp_code = $this->request->getVar('emp_code') ?? $empCode;
|
||||
@ -1881,11 +1881,11 @@ public function calculatePremium($clientPolicyId = null , $empCode = null, $defa
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getCashDepositData()
|
||||
{
|
||||
public function getCashDepositData()
|
||||
{
|
||||
|
||||
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.client_id as clientId , client_policy.insurer_id as insurerId,insurers.name as insurer_name')
|
||||
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
|
||||
@ -1957,13 +1957,13 @@ public function getCashDepositData()
|
||||
return $this->respond(['status' => 'failed','code' => (count($result) ? 200 : 404),'data' => [] ], 200);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function exportCashDepositData()
|
||||
{
|
||||
public function exportCashDepositData()
|
||||
{
|
||||
|
||||
$CashDepositData = $this->clientPolicyModel->getdepositData($this->request->getGet('client_id'),$this->request->getGet('insurer_id'));
|
||||
|
||||
@ -2025,11 +2025,11 @@ public function exportCashDepositData()
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function removeEmpAndEmpPolicyData()
|
||||
{
|
||||
public function removeEmpAndEmpPolicyData()
|
||||
{
|
||||
try {
|
||||
|
||||
$clientPolicy = $this->clientPolicyModel->where('id',$this->request->getGet('client_policy_id'))->findAll();
|
||||
@ -2091,11 +2091,11 @@ public function removeEmpAndEmpPolicyData()
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getEmployeeActiveOrInactivePolicy()
|
||||
{
|
||||
function getEmployeeActiveOrInactivePolicy()
|
||||
{
|
||||
|
||||
if($this->request->getGet('type') == 'Active'){ $policy_status = 1; }else{ $policy_status = 0; }
|
||||
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.* , policies.name as policy_name , policy_type.policy_type as policy_type')
|
||||
@ -2196,11 +2196,11 @@ function getEmployeeActiveOrInactivePolicy()
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => [] ], 200);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function policyTermsFiter($terms , $type)
|
||||
{
|
||||
function policyTermsFiter($terms , $type)
|
||||
{
|
||||
|
||||
$gpa = [
|
||||
"sumInsured2" => "Sum Insured",
|
||||
@ -2262,11 +2262,11 @@ function policyTermsFiter($terms , $type)
|
||||
|
||||
return $finalarray;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function convertDateFormatDisplay($dateString)
|
||||
{
|
||||
private function convertDateFormatDisplay($dateString)
|
||||
{
|
||||
// Attempt to create a DateTime object from the provided date string
|
||||
$dateTime = \DateTime::createFromFormat('Y-m-d', $dateString);
|
||||
|
||||
@ -2275,10 +2275,10 @@ private function convertDateFormatDisplay($dateString)
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getFEContent()
|
||||
{
|
||||
public function getFEContent()
|
||||
{
|
||||
try {
|
||||
|
||||
$feContentData = $this->feContentModel->findAll();
|
||||
@ -2293,10 +2293,10 @@ public function getFEContent()
|
||||
} catch (\Throwable $th) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAdvertisementImage()
|
||||
{
|
||||
public function getAdvertisementImage()
|
||||
{
|
||||
try {
|
||||
|
||||
$img = $this->addImgModel->where('is_active',1)->findAll();
|
||||
@ -2317,6 +2317,61 @@ public function getAdvertisementImage()
|
||||
} catch (\Throwable $th) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function storeFireBase()
|
||||
{
|
||||
try {
|
||||
$firebase_token = $this->request->getPost('firebase_token');
|
||||
$mobile = $this->request->getPost('mobile');
|
||||
|
||||
// Ensure the mobile number is provided
|
||||
if (empty($mobile)) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Mobile number is required'], 400);
|
||||
}
|
||||
|
||||
// Fetch employee by mobile number
|
||||
$employee = $this->employeeModel->where('mobile', $mobile)->first();
|
||||
|
||||
if ($employee) {
|
||||
// Check if firebase_token is provided
|
||||
if (!empty($firebase_token)) {
|
||||
|
||||
// Check if the current firebase_token is different from the new one
|
||||
if ($employee['firebase_token'] !== $firebase_token) {
|
||||
// Update the employee's firebase_token
|
||||
$data['firebase_token'] = $firebase_token;
|
||||
$id = $employee['id'];
|
||||
// return json_encode($data);
|
||||
// Direct database update query for testing
|
||||
$db = \Config\Database::connect();
|
||||
$builder = $db->table('employees');
|
||||
$update_emp = $builder->update($data, ['id' => $id]);
|
||||
|
||||
// Check if the update was successful
|
||||
if ($db->affectedRows() > 0) {
|
||||
// Fetch the updated employee data
|
||||
$updated_employee = $this->employeeModel->find($id);
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $updated_employee], 200);
|
||||
} else {
|
||||
log_message('error', 'Update failed. No rows affected.');
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'message' => 'Failed to update employee data'], 500);
|
||||
}
|
||||
} else {
|
||||
return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'New Firebase Token is the same as the current one'], 400);
|
||||
}
|
||||
} else {
|
||||
return $this->respond(['status' => 'failed', 'code' => 400, 'message' => 'Firebase Token is required'], 400);
|
||||
}
|
||||
} else {
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'message' => 'Employee not found'], 404);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
log_message('error', 'An error occurred: ' . $th->getMessage());
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'message' => 'An error occurred', 'error' => $th->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user