diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index f8ebf179..540be64e 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -661,8 +661,9 @@ class ClientController extends AdminController $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'); $data['insurerName'] = $this->insurerModel->getInsurerName($insurerId, $clientId); - $data['depositdata'] = $this->clientPolicyModel->getdepositData($clientId, $insurerId); + $data['depositdata'] = $this->clientPolicyModel->getdepositData($clientId, $insurerId, $cd_ac_pk); $data['clientData'] = $this->clientPolicyModel->getClientById($clientId); $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId); diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index cb93e213..1eb7895f 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -185,7 +185,7 @@ class EmpDataServiceController extends BaseController $balance = $this->CDMasterModel ->where('client_id', $export_data['client_id']) ->where('insurer_id', $policy_details['insurer_id']) - ->where('cd_ac_no', $policy_details['cd_ac_no']) + ->where('id', $policy_details['cd_ac_pk']) ->first(); $cash_balance['balance'] = $balance['opening_bal']; @@ -683,7 +683,7 @@ class EmpDataServiceController extends BaseController $balance = $this->CDMasterModel ->where('client_id', $export_data['client_id']) ->where('insurer_id', $policy_details['insurer_id']) - ->where('cd_ac_no', $policy_details['cd_ac_no']) + ->where('id', $policy_details['cd_ac_pk']) ->first(); $cash_balance['balance'] = $balance['opening_bal']; diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 5c587221..050fe5b3 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2501,7 +2501,7 @@ class EmployeeRestController extends AdminController function getEmployeeActiveOrInactivePolicy() { - if($this->request->getGet('type') == 'Active'){ $policy_status = 1; }else{ $policy_status = 0; } + if($this->request->getGet('type') == 'Active'){ $policy_status = 1; $policy_status_key = "Active"; }else{ $policy_status = 0; $policy_status_key = "InActive";} $dayInterval = 10; $ClientPolicyData = $this->clientPolicyModel->select("client_policy.* , policy_type.policy_type as policy_type,insurers.name as insurer_name,tpa.name as tpa_name,tpa.network_hospitals as network_hospitals_url, policy_type.long_name as policy_long_name, DATE_ADD(client_policy.policy_end_date, INTERVAL {$dayInterval} DAY) as claims_grace_date") ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left') @@ -2527,12 +2527,16 @@ class EmployeeRestController extends AdminController ->get()->getRow()->name; $whereArrayForId = []; foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); } - + if(count($ClientPolicyData) > 0 && count($employeeData) > 0) { $result = []; foreach ($ClientPolicyData as $key => $ClientPolicyValue) { + if (strtotime(date('Y-m-d') > strtotime($ClientPolicyValue['claims_grace_date']))) { + continue; + } + if($ClientPolicyValue['policy_type_id'] == 1) { $policyGroup = 'gpa'; @@ -2566,7 +2570,8 @@ class EmployeeRestController extends AdminController $data['policy_start_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_start_date']); $data['policy_end_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['policy_end_date']); $data['heading'] = $ClientPolicyValue['policy_long_name']; - $data['claims_grace_date'] = $ClientPolicyValue['claims_grace_date']; + $data['claims_grace_date'] = $this->convertDateFormatDisplay($ClientPolicyValue['claims_grace_date']); + $data['policy_status'] = $policy_status_key; // $data['policy_terms'] = $terms; // if($ClientPolicyValue['policy_type_id'] == 1){ $data['heading'] = 'Group Personal Accident Coverage'; }else diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 12759036..c6801878 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -181,8 +181,9 @@ class ClientPolicyModel extends Model ->where('client_policy.client_id', $id) ->where('cd_master.id = client_policy.cd_ac_pk') ->where('cd_master.is_active', 1) - ->groupBy('client_policy.insurer_id') ->groupBy('client_policy.client_id', $id) // Group by insurer_id + ->groupBy('client_policy.insurer_id') + ->groupBy('client_policy.cd_ac_pk') ->get() ->getResult(); @@ -225,10 +226,10 @@ class ClientPolicyModel extends Model } - public function getDepositData($clientId, $insurerId) + public function getDepositData($clientId, $insurerId, $cd_ac_pk = null) { - // Fetch the deposit data based on client and insurer IDs - return $this->db->table('cash_deposit') + // Fetch the deposit data based on client and insurer IDs + $query = $this->db->table('cash_deposit') ->select('cash_deposit.*') ->select('insurers.name as insurer_name, insurers.short_name as insurer_short') ->select('clients.client_name as clientname, clients.short_name as clientshort, client_policy.policy_no') @@ -245,11 +246,14 @@ class ClientPolicyModel extends Model ->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left') ->where('cash_deposit.client_id', $clientId) ->where('cash_deposit.insurer_id', $insurerId) - ->where('cash_deposit.is_active', 1) + ->where('cash_deposit.is_active', 1); // ->where('cash_deposit.cd_ac_pk = cd_master.id') - ->orderBy('cash_deposit.id', 'DESC') - ->get() - ->getResult(); + if(!empty($cd_ac_pk)){ + $query->where('cash_deposit.cd_ac_pk', $cd_ac_pk); + } + $query->orderBy('cash_deposit.id', 'DESC'); + + return $query->get()->getResult(); } @@ -319,6 +323,7 @@ class ClientPolicyModel extends Model ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance') ->where('client_id', $id) ->groupBy('insurer_id') + ->groupBy('cd_ac_pk') ->get() ->getResult(); } diff --git a/app/Views/client_deposit_list.php b/app/Views/client_deposit_list.php index d19d0ec6..ab076ebb 100755 --- a/app/Views/client_deposit_list.php +++ b/app/Views/client_deposit_list.php @@ -49,7 +49,7 @@