From 0589f98891fcf7ca9cfe170da17d94691a1ea78a Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Tue, 27 Jan 2026 14:48:54 +0530 Subject: [PATCH] getDepositSummary function error fix : GWM --- app/Models/ClientPolicyModel.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 7811843e..a466e712 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -368,10 +368,11 @@ class ClientPolicyModel extends Model return null; } - // Client condition (raw vs MD5) - $clientWhere = 'client_id = :clientId:'; + // Build SAFE client condition (NO BINDS!) if (is_string($clientId) && preg_match('/^[a-f0-9]{32}$/i', $clientId)) { - $clientWhere = 'MD5(client_id) = :clientId:'; + $clientCondition = 'MD5(client_id) = ' . $this->db->escape($clientId); + } else { + $clientCondition = 'client_id = ' . $this->db->escape($clientId); } /* ------------------------------------------------- @@ -379,7 +380,7 @@ class ClientPolicyModel extends Model ------------------------------------------------- */ $subQuery = $this->db->table('cash_deposit') ->select('balance') - ->where($clientWhere, ['clientId' => $clientId]) + ->where($clientCondition, null, false) ->where('insurer_id', $insurerId) ->where('cd_ac_pk', $cd_ac_pk) ->where('is_active', 1) @@ -395,7 +396,7 @@ class ClientPolicyModel extends Model ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE 0 END) AS total_credit') ->select('SUM(CASE WHEN transaction_type = "Debit" THEN amount ELSE 0 END) AS total_withdraw') ->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund') - ->where($clientWhere, ['clientId' => $clientId]) + ->where($clientCondition, null, false) ->where('insurer_id', $insurerId) ->where('cd_ac_pk', $cd_ac_pk) ->where('cash_deposit.is_active', 1) @@ -406,6 +407,7 @@ class ClientPolicyModel extends Model return $data; } + // Inside your clientPolicyModel // Inside your clientPolicyModel // public function getDepositDataWithBalance($clientId, $insurerId)