From 363b43f21719571a6ada144f8322b4ccaf94cc0a Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Mon, 8 Jun 2026 14:29:38 +0530 Subject: [PATCH] FIX_BDS_COPAY_INSURER_WRONGLY_MAPPED_LEAD_LIST_STAFF_CREATED_AND_EXPIRED_POLICY_TOGGLE_ISSUE --- .../PolicyTransactionController.php | 30 ++++++- app/Models/LeadsModel.php | 4 + app/Views/client_policy.php | 10 +-- .../policy_transaction_inception_form.php | 83 +++++++++++++++++-- 4 files changed, 112 insertions(+), 15 deletions(-) diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index a8d1ab90..02852b26 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -1023,7 +1023,6 @@ class PolicyTransactionController extends BaseController 'follower_policy_no.*' => ['label' => 'Follower Policy No', 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9\/_-]+$/]', 'errors' => [ 'regex_match' => 'The {field} can only contain letters, numbers, spaces, dashes, and underscores.' ]], - 'calc_policy_issue_date.*' => ['label' => 'Policy Issue Date', 'rules' => 'required', 'errors' => ['required' => 'Policy Issue Date is required']], 'co_share_per.*' => ['label' => 'Co-Share %', 'rules' => 'permit_empty|decimal', 'errors' => ['decimal' => 'Co-Share % must be a valid decimal.']], 'non_comm_per_amt.*' => ['label' => 'Non-Comm Premium', 'rules' => 'permit_empty|decimal', 'errors' => ['decimal' => 'Amount must be numeric.']], 'base_premium.*' => ['label' => 'Base Premium','rules' => 'permit_empty|decimal', 'errors' => ['decimal' => 'Base Premium must be numeric.']], @@ -1054,6 +1053,26 @@ class PolicyTransactionController extends BaseController 'exp_amt.*' => ['label' => 'Expected Amount', 'rules' => 'permit_empty|decimal', 'errors' => ['decimal' => 'The Expected Amount field must contain a valid number.']] ]; + $isCoShare = !empty($post_data['co_share']); + $calcPolicyIssueDateRule = [ + 'label' => 'Policy Issue Date', + 'rules' => 'required', + 'errors' => ['required' => 'Policy Issue Date is required'], + ]; + + if ($isCoShare) { + $coShareTypes = $post_data['co_share_type'] ?? []; + if (is_array($coShareTypes)) { + foreach ($coShareTypes as $index => $type) { + if ((int) $type === 1) { + $rules["calc_policy_issue_date.$index"] = $calcPolicyIssueDateRule; + } + } + } + } else { + $rules['calc_policy_issue_date.*'] = $calcPolicyIssueDateRule; + } + if(isset($post_data['client_type']) && $post_data['client_type'] == 1){ $rules['client_branch_id'] = ['label' => 'Client Branch', 'rules' => 'required', 'errors' => ['required' => 'Client branch is required']]; } @@ -1181,6 +1200,15 @@ class PolicyTransactionController extends BaseController $data['co_share'] = 1; } + if ($data['co_share'] == 1 && !empty($data['follow_insurer_id']) && is_array($data['follow_insurer_id'])) { + foreach ($data['follow_insurer_id'] as $index => $followInsurer) { + if (($data['co_share_type'][$index] ?? 2) == 1 && !empty($followInsurer)) { + list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $followInsurer); + break; + } + } + } + // if (!isset($data['bro_payable_by'])) { // $data['bro_payable_by'] = 0; // } elseif ($data['bro_payable_by']) { diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php index d194375a..ef88ba21 100644 --- a/app/Models/LeadsModel.php +++ b/app/Models/LeadsModel.php @@ -176,6 +176,10 @@ class LeadsModel extends Model ->join('lead_files', 'leads.id = lead_files.lead_id AND lead_files.type = 2 AND lead_files.is_active = 1', 'left') ->where('leads.is_active', 1); + if (get_role_id() == STAFF_ROLE_ID) { + $data->where('leads.created_by', get_session_userid()); + } + if (! empty($where)) { $data->where($where); } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 26bcab2c..9ddd1899 100755 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -48,7 +48,8 @@ .switch-label .slider, .switch-label .slider_blue { - pointer-events: none; + cursor: pointer; + flex-shrink: 0; } .slider, @@ -145,9 +146,8 @@ input:checked + .slider_blue::before {
-
-