diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php index 0141ef61..059ebfce 100644 --- a/app/Controllers/ThzController.php +++ b/app/Controllers/ThzController.php @@ -96,6 +96,7 @@ class ThzController extends BaseController $data['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['2', '3','4'])->findAll(); // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu // 2,3,4 remain person varannum. $data['client_list'] = $this->clientModel->getCreatedByUserName(); + return $this->loadLayout('thz_list', $data); } @@ -149,7 +150,7 @@ class ThzController extends BaseController $policyIds = array_column($details, 'policy_id'); $policyIds = array_filter($policyIds); - $clientPolicy = $this->clientPolicyModel->whereIn('policy_id', $policyIds)->where('is_active', 1)->get()->getResultArray(); + $clientPolicy = $this->clientPolicyModel->whereIn('id', $policyIds)->where('is_active', 1)->get()->getResultArray(); $result['client_details'] = $details; $result['policy_details'] = empty($clientPolicy) ? [] : $clientPolicy ; @@ -195,14 +196,19 @@ class ThzController extends BaseController if ($returnType === 'api') { return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200); }else{ - $toGetRelated = $result['master'][0]['created_by']; + $toGetCreatedBy = $result['master'][0]['created_by']; + $toGetPolicyId = (!empty($result['master'][0]['policy_id']) && strtolower($result['master'][0]['policy_id']) !== 'null') + ? $result['master'][0]['policy_id'] + : ''; + $result['related_tickets'] = $this->thzMasterModel ->select('thz_master.*, CONCAT(user_profiles.first_name, " ", user_profiles.last_name) as assignee_name') ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left') - ->where('thz_master.created_by', $toGetRelated) + ->where('thz_master.created_by', $toGetCreatedBy) ->findAll(); $result['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['2', '3','4'])->findAll(); // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu // 2,3,4 remain person varannum. + $result['policy_terms'] = $toGetPolicyId ? $this->getPolicyTerms($toGetPolicyId) : ''; return $this->loadLayout('thz_notes', $result); } @@ -449,6 +455,23 @@ class ThzController extends BaseController } + public function getPolicyTerms($client_policy_id) + { + $policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $client_policy_id)->first(); + + $policy_terms = []; + if(isset($policy_data['policy_terms']) && !empty($policy_data['policy_terms'])){ + + $raw_terms = json_decode($policy_data['policy_terms'] ?? [] , true) ?? []; + + $ticketController = new TicketController(); + $policy_terms = $ticketController->convertTermsToDisplay($raw_terms); + } + + $data['policy_terms'] = $policy_terms; + return view('view_policy_terms', $data); + } + } diff --git a/app/Views/thz_list.php b/app/Views/thz_list.php index b56b45fd..986c4594 100644 --- a/app/Views/thz_list.php +++ b/app/Views/thz_list.php @@ -498,14 +498,14 @@ td .text-muted { let opt = document.createElement("option"); opt.value = p.policy_no; opt.text = p.policy_no; - opt.setAttribute("data-id", p.policy_id); + opt.setAttribute("data-id", p.id); policySelect.appendChild(opt); }); // If you want to auto-select the first real policy instead of "Select Policy" policySelect.value = policies[0].policy_no; document.getElementById('policy_no').value = policies[0].policy_no || ""; - document.getElementById('policy_id').value = policies[0].policy_id; + document.getElementById('policy_id').value = policies[0].id; } } else { toastr.warning(response.message || "No details found.", 'warning'); diff --git a/app/Views/thz_notes.php b/app/Views/thz_notes.php index be63f5e7..070d88d8 100644 --- a/app/Views/thz_notes.php +++ b/app/Views/thz_notes.php @@ -126,10 +126,19 @@
Policy Number
-
-
+
+ + ' + .$master[0]['policy_no'].' + + ' + : 'N/A'; ?> +
Assigned To
@@ -207,7 +216,7 @@ -
+

No Data Found

@@ -336,6 +345,29 @@
+ +