diff --git a/app/Config/Routes.php b/app/Config/Routes.php index b12373ad..06e9d1c5 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -489,7 +489,7 @@ $routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMp $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); $routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy"); -$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { +// $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); @@ -516,7 +516,10 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn"); $routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId"); - $routes->get("getCashDepositData", "EmployeeRestController::getCashDepositData"); + + $routes->get("getPolicyLevelEmployeeSummaryData", "EmployeeRestController::getPolicyLevelEmployeeSummaryData"); + $routes->get("cdSummaryData", "EmployeeRestController::cdSummaryData"); + $routes->get("cdTransactionData", "EmployeeRestController::cdTransactionData"); $routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData"); $routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData"); @@ -530,7 +533,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("getWellnessURL", "EmployeeRestController::getWellnessURL"); // $routes->post('postDataForTicket',"EmployeeRestController::postDataForTicket"); -}); +// }); $routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy"); $routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification"); $routes->post("sendEmail", "EmployeeRestController::send_email"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index f256d374..be5f2664 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -618,7 +618,7 @@ class ClientController extends AdminController } // In your controller - public function deposit($id = null) + public function deposit($id = null , $requestFrom = null ) { $headerData['page_name'] = 'Client Deposit'; @@ -629,13 +629,15 @@ class ClientController extends AdminController // Fetch associated insurer names and balances $balances = $this->clientPolicyModel->getBalances($id); $data['balances'] = $balances; - // dd($data); + + if($requestFrom == 'rest'){ return $data; } + echo view('layout/header', $headerData); echo view('client_deposit_list', $data); echo view('layout/footer'); } - public function view_Deposit($insurerId) + public function view_Deposit($insurerId , $requestFrom = null , $param = null) { // Load your model to fetch data based on $clientId and $insurerId // $subTypeOptions = [ @@ -660,17 +662,23 @@ class ClientController extends AdminController $headerData['page_name'] = 'Client Deposit'; $loggedInUserID = get_session_userid(); // $data['clientData']= $this->clientPolicyModel->getinsurerswithinsurenceid($insurerId); - $clientId = $this->request->getGet('client_id'); - $cd_ac_pk = $this->request->getGet('cd_ac_pk'); + if($requestFrom == 'rest') + { + $clientId = $param['client_id']; + $cd_ac_pk = $param['cd_ac_pk']; + }else{ + $clientId = $this->request->getGet('client_id'); + $cd_ac_pk = $this->request->getGet('cd_ac_pk'); + } + $data['insurerName'] = $this->insurerModel->getInsurerName($insurerId, $clientId); $data['depositdata'] = $this->clientPolicyModel->getdepositData($clientId, $insurerId, $cd_ac_pk); $data['clientData'] = $this->clientPolicyModel->getClientById($clientId); $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId, $cd_ac_pk); $data['cd_ac_pk'] = $cd_ac_pk; - // dd($data); - - // print_r($data['depositdata'] );die; + if($requestFrom == 'rest'){ return $data; } + // Load the view for the new list page; echo view('layout/header', $headerData); echo view('view_deposit', $data); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 050fe5b3..ca6d65d5 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2276,72 +2276,47 @@ class EmployeeRestController extends AdminController } - public function getCashDepositData() + public function getPolicyLevelEmployeeSummaryData() { - $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') - ->where('client_policy.client_id', $this->request->getGet('client_id') ) - ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) - ->where('client_policy.is_active', 1 ) - ->where('client_policy.policy_status', 1) - ->groupBy('client_policy.insurer_id') - ->findAll(); - $result = []; - - if(count($ClientPolicyData)) - { - foreach ($ClientPolicyData as $key => $value) { - - $data['clientId'] = $value['clientId']; - $data['insurerId'] = $value['insurerId']; - $data['insurerName'] = $value['insurer_name']; - $data['depositData'] = $this->clientPolicyModel->getdepositData($value['clientId'],$value['insurerId']); - $data['balance'] = count($data['depositData']) ? $data['depositData'][0]->balance : 0; - - $data['policyDetails'] = []; - $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ') - - ->where('client_policy.insurer_id', $value['insurerId'] ) - ->where('client_policy.client_id', $this->request->getGet('client_id') ) - ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) - ->where('client_policy.is_active', 1 ) - ->where('client_policy.policy_status', 1) - ->findAll(); - // dd( $ClientPolicyData); - foreach ($ClientPolicyData as $key => $value) + + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ') + ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) + ->where('client_policy.is_active', 1 ) + ->where('client_policy.policy_status', $this->request->getGet('policy_status')) + ->findAll(); + $result = []; + // dd( $ClientPolicyData); + foreach ($ClientPolicyData as $key => $value) + { + $policyTypeData = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow(); + $value['type'] = $policyTypeData->policy_type; + $value['policy_name'] = $policyTypeData->long_name; + $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0,branch_id:$this->request->getGet('client_branch_id')); + // dd($employeeDetails); + $activeCount = 0; + $inactiveCount = 0; + if(count($employeeDetails)) { - $policyTypeData = $this->policyTypeModel->where('id',$value['policy_type_id'])->get()->getRow(); - $value['type'] = $policyTypeData->policy_type; - $value['policy_name'] = $policyTypeData->long_name; - $employeeDetails = $this->employeePolicyModel->getEmployeePolicy( client_id:$value['client_id'],policy_id: $value['client_policy_id'],status:0,branch_id:$this->request->getGet('client_branch_id')); - $enrolledCount = 0; - $draftCount = 0; - if(count($employeeDetails)) - { - foreach ($employeeDetails as $item) { - if ($item['emp_status'] === 'enrolled') { - $enrolledCount++; - } elseif ($item['emp_status'] === 'draft') { - $draftCount++; - } + foreach ($employeeDetails as $item) { + if ($item['emp_status'] === 'active') { + $activeCount++; + } elseif ($item['emp_status'] === 'inactive') { + $inactiveCount++; } } - - $value['totalMembersCount'] = count($employeeDetails); - $value['membersCountOfEnrolled'] = $enrolledCount; - $value['membersCountOfDraft'] = $draftCount; - - array_push($data['policyDetails'],$value); } - - - array_push($result,$data); - } - } - + $value['totalMembersCount'] = count($employeeDetails); + $value['membersCountOfActive'] = $activeCount; + $value['membersCountOfInactive'] = $inactiveCount; + + array_push($result,$value); + } + + if($result) { @@ -2353,6 +2328,74 @@ class EmployeeRestController extends AdminController } + public function cdSummaryData() + { + + $clientId = $this->request->getGet('client_id'); + + $clientController = new ClientController; + $result = $clientController->deposit($clientId , $requestFrom = 'rest'); + + $data = []; + + foreach ($result['clientData'] as $key => $value) + { + $temp['client_id'] = $value->client_id; + $temp['insurer_id'] = $value->insurer_id; + $temp['cd_ac_pk'] = $value->cd_ac_pk; + $temp['insurer_name'] = $value->insurer_name; + $temp['cd_master_account_no'] = $value->cd_master_account_no; + if (isset($result['balances'][$temp['insurer_id']])) { + $balance = $result['balances'][$temp['insurer_id']]->balance; + $temp['balance'] = $balance; + } else { + $temp['balance'] = "N/A"; + } + + array_push($data,$temp); + } + + + if($data) + { + return $this->respond(['status' => 'success','code' => (count($data) ? 200 : 404),'data' => $data ], 200); + }else{ + return $this->respond(['status' => 'failed','code' => (count($data) ? 200 : 404),'data' => [] ], 200); + } + + } + + public function cdTransactionData() + { + + $clientId = $this->request->getGet('client_id'); + $insurerId = $this->request->getGet('insurer_id'); + $cdAccountPrimaryKey = $this->request->getGet('cd_ac_pk'); + + $clientController = new ClientController; + $result = $clientController->view_Deposit($insurerId , $requestFrom = 'rest' , $param = ['client_id'=>$clientId, 'cd_ac_pk'=>$cdAccountPrimaryKey ]); + + $data['insurer_name'] = $result['insurerName']->name; + $data['account_number'] = $result['insurerName']->cd_master_account_no; + $data['total_deposit'] = $result['deposiamount']->total_credit; + $data['total_consumed'] = $result['deposiamount']->total_withdraw; + $data['total_refund'] = $result['deposiamount']->total_refund; + $data['currect_balance'] = $result['deposiamount']->balance; + $data['deposit_data'] = $result['depositdata']; + + + // dd($data); + + if($data) + { + return $this->respond(['status' => 'success','code' => (count($data) ? 200 : 404),'data' => $data ], 200); + }else{ + return $this->respond(['status' => 'failed','code' => (count($data) ? 200 : 404),'data' => [] ], 200); + } + + } + + public function exportCashDepositData()