From a744b8e105f672a4efdb79b19e04814f3afa556c Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 1 Apr 2025 15:29:13 +0530 Subject: [PATCH] FIX_BDS_PT_CO_RMV_ISSUE : RV --- .../PolicyTransactionController.php | 19 ++++++++++++------- app/Models/EmployeePolicyModel.php | 8 +++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 2c40bd30..3f7f36df 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -418,7 +418,7 @@ class PolicyTransactionController extends BaseController // die; if(isset($data['co_share_id']) && !empty($data['co_share_id'])){ - $this->removePtCoShareRecords($data['co_share_id']); + $this->removePtCoShareRecords($data['co_share_id'], $pt_id); } if(isset($data['follow_insurer_id'])){ @@ -967,21 +967,26 @@ class PolicyTransactionController extends BaseController } //function for soft delete for pt_co_share_details records - public function removePtCoShareRecords($primaryKeys) + public function removePtCoShareRecords($primaryKeys, $pt_id) { - // print_r($primaryKeys); die; if (empty($primaryKeys)) { return false; } - // Convert array to a comma-separated string for query binding + // Convert array to a comma-separated string of placeholders for query binding $placeholders = implode(',', array_fill(0, count($primaryKeys), '?')); - $sql = "UPDATE pt_co_share_details SET is_active = 0 WHERE id NOT IN ($placeholders)"; - - return db_connect()->query($sql, $primaryKeys); + // Prepare the query with proper binding + $sql = "UPDATE pt_co_share_details SET is_active = 0 WHERE pt_id = ? AND id NOT IN ($placeholders)"; + + // Merge pt_id with primary keys for binding + $params = array_merge([$pt_id], $primaryKeys); + + // Execute the query with bound parameters + return db_connect()->query($sql, $params); } + //------------------------------------------------------------------------------------------------ diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 98271bb7..175be311 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -319,9 +319,11 @@ class EmployeePolicyModel extends Model } // Always check these conditions - $result->where('employee_polices.is_active', 1) - ->where('emp.is_active', 1); - + $result + ->where('employee_polices.is_active', 1) + ->where('emp.is_active', 1) + ->where('employee_polices.status !=', 'inactive'); + $res = $result->findAll(); // dd($this->db->getLastQuery());