diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index 525acb3c..be0e2476 100755 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -101,6 +101,6 @@ class Autoload extends AutoloadConfig * @phpstan-var list */ public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', - 'excel_import_export', 'file', 'drive','ExcelSanitizeHelper', 'api_helper','ExceptionHelper' + 'excel_import_export', 'file', 'drive','ExcelSanitizeHelper', 'api_helper','exception' ]; } diff --git a/app/Config/Routes.php b/app/Config/Routes.php index dbf222fc..9996931c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -124,6 +124,8 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) { $routes->post("edit", "ClientController::editClientBranch"); $routes->get("list/(:any)", "ClientController::getSingleBranchDataById/$1"); $routes->get("remove/(:any)", "ClientController::removeClientBranch/$1"); + $routes->post("auto_fetch_branch","ClientController::auto_fetch_branch"); + $routes->post("auto_fetch_branch_details","ClientController::auto_fetch_branch_details"); }); $routes->group("relation", ["filter" => "authMVC"], function ($routes) { @@ -676,6 +678,7 @@ $routes->post('claimStatusCheck','VidalApiController::claimStatusCheck'); $routes->post('newClaim','VidalApiController::newClaim'); $routes->post('enrollment','VidalApiController::enrollment'); +// General Tickets $routes->post("ticketSave", "ThzController::ticketSave"); $routes->get("ticketList", "ThzController::ticketList"); diff --git a/app/Controllers/AppContentManagementController.php b/app/Controllers/AppContentManagementController.php index 300036be..33d6ce1d 100755 --- a/app/Controllers/AppContentManagementController.php +++ b/app/Controllers/AppContentManagementController.php @@ -27,7 +27,8 @@ class AppContentManagementController extends AdminController public function add_image_index() { $this->myLogger->logme('error','Addvertisement Image list function called'); - $headerData['page_name'] = 'Addvertisement Image List'; + $headerData['tab_name'] = 'Addvertisement Images'; + $headerData['page_name'] = 'Addvertisement Images'; $data['addImageList'] = $this->addImgModel->findAll(); // dd($data); @@ -86,6 +87,7 @@ class AppContentManagementController extends AdminController public function frontend_content(){ $data['test'] = $this->feContentModel->findAll(); + $headerData['tab_name'] = 'Front-End Content'; $headerData['page_name'] = 'Front-End Content'; echo view('layout/header', $headerData); diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index c3005aac..355df367 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -180,6 +180,9 @@ class BDSReportController extends AdminController 'BAP-Insurer' => 'bapInsurer', 'Client' => 'client' ]; + + $data['page_name'] = "IRBA Report"; + return $this->loadLayout('irba_report', $data); } else { @@ -914,6 +917,7 @@ class BDSReportController extends AdminController $data['default_end'] = $default_start->format('d-m-Y'); $data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y'); $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; + $data['tab_name'] = "Renewal Report"; $data['page_name'] = "Renewal Report"; return $this->loadLayout('renewal_search', $data); } else { @@ -1013,6 +1017,7 @@ class BDSReportController extends AdminController public function accountMangerStatusBDSReport() { + $data['tab_name'] = "Account Manager BDS Report"; $data['page_name'] = "Account Manager BDS Report"; $sql = " @@ -1130,6 +1135,7 @@ class BDSReportController extends AdminController public function getMultiReport($report_type){ + $data['tab_name'] = "BDS Report"; $data['page_name'] = "BDS Report"; if ($report_type == 1){ diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 164bee10..34830575 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -143,9 +143,9 @@ class ClientController extends AdminController // Perform the query $builder = $db->table($table); - if(is_array($value)){ + if (is_array($value)) { $isDuplicate = $builder->where($value)->where('is_active', 1)->countAllResults() > 0; - }else{ + } else { $isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0; } @@ -154,9 +154,9 @@ class ClientController extends AdminController } public function smapletest() - { + { $headers = [ - 'S.No', + 'S.No', 'NAME OF EMP/DEP', 'EMP ID', // 'EMP/DEP TYPE', @@ -177,13 +177,13 @@ class ClientController extends AdminController 'PRO RATA PREMIUM', 'GST', 'TOTAL AMOUNT' - ]; + ]; $filePath = generateExcelWithHeader($headers); - echo "Excel file created at: $filePath"; + echo "Excel file created at: $filePath"; } public function testMailAttachments($email = 'venkateshraman786@gmail.com') - { + { $message = '

Request for Quotation (RFQ)

Dear {{RECIPIENT_NAME}},

We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.

RFQ Details

Client name{{CLIENT_NAME}}
Coverage Type{{POLICY_LONG_NAME}}
Policy Start Date{{POLICY_START_DATE}}
Policy Duration{{DURATION}}
Please note: Additional terms and details are included in the attachment for your reference.

Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.

Best regards,

Nhance India Pvt Ltd

'; // $attachments = [ @@ -192,8 +192,8 @@ class ClientController extends AdminController // ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"] // ]; $attachments = []; - $res = MailHelper::send_email(['mail' => $email, 'subject' => 'Mail Via Attachment Testing URL', 'message' => $message,'attachments' => $attachments]); - + $res = MailHelper::send_email(['mail' => $email, 'subject' => 'Mail Via Attachment Testing URL', 'message' => $message, 'attachments' => $attachments]); + print_rr($res); echo '------------------------------------------------------------------------------------------'; // print_rr($attachments); @@ -205,21 +205,20 @@ class ClientController extends AdminController // dd($client_id, $emp_code, $policy_id, $mail_active); - if(empty($policy_id)){ + if (empty($policy_id)) { $client_policy_ids = $this->employeeModel - ->select('employee_polices.client_policy_id') - ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->where('employees.client_id', $client_id ) - ->where('employees.emp_code', $emp_code ) - ->where('employee_polices.is_active', 1 ) - ->where('employees.is_active', 1 ) - ->findAll(); + ->select('employee_polices.client_policy_id') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.client_id', $client_id) + ->where('employees.emp_code', $emp_code) + ->where('employee_polices.is_active', 1) + ->where('employees.is_active', 1) + ->findAll(); $client_policy_ids2 = array_column($client_policy_ids, 'client_policy_id'); $client_policy_id = array_unique($client_policy_ids2); - - }else{ + } else { $client_policy_id = json_decode($policy_id, true); } @@ -233,39 +232,37 @@ class ClientController extends AdminController $mail_send_return1 = ''; $mail_send_return2 = ''; - if (!is_null($client_policy_id) && is_array($client_policy_id)) - { + if (!is_null($client_policy_id) && is_array($client_policy_id)) { - $empData = $this->employeeModel->where('emp_code', $emp_code )->where('client_id', $client_id ) ->where('is_active', 1 )->findAll(); + $empData = $this->employeeModel->where('emp_code', $emp_code)->where('client_id', $client_id)->where('is_active', 1)->findAll(); // dd($empData); $filteredEmpData = array_filter($empData, fn($item) => $item['relationship'] === 'Self'); // dd($filteredEmpData); $array_list = []; - foreach ($client_policy_id as $key => $value) - { - $find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value,emp_code: $emp_code,client_id: $client_id,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']); - if(count($find) > 0){ + foreach ($client_policy_id as $key => $value) { + $find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value, emp_code: $emp_code, client_id: $client_id, emp_status: ['draft', 'enrolled'], policy_status: ['draft', 'enrolled']); + if (count($find) > 0) { $array_list[] = $find; } } // dd($array_list); - $notification = $this->notificationModel->where('client_id' ,$client_id)->where('template_name', 'member_review_and_summary_mail')->first(); + $notification = $this->notificationModel->where('client_id', $client_id)->where('template_name', 'member_review_and_summary_mail')->first(); if (isset($notification) && $notification['enabled'] == 1) { - $params ['array_list'] = $array_list; - $params ['client_policy_id'] = $client_policy_id; - $params ['emp_code'] = $emp_code; - $params ['client_id'] = $client_id; - $params ['notification'] = $notification; + $params['array_list'] = $array_list; + $params['client_policy_id'] = $client_policy_id; + $params['emp_code'] = $emp_code; + $params['client_id'] = $client_id; + $params['notification'] = $notification; $params['common'] = [ - 'client_id' => $filteredEmpData[0]['client_id'], - 'client_branch_id' => $filteredEmpData[0]['client_branch_id'], + 'client_id' => $filteredEmpData[0]['client_id'], + 'client_branch_id' => $filteredEmpData[0]['client_branch_id'], 'client_policy_id' => null, 'employee_policy_id' => null, 'employee_id' => $filteredEmpData[0]['id'], @@ -274,16 +271,16 @@ class ClientController extends AdminController // dd($params); - $wholeData =sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params); + $wholeData = sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params); // print_r($wholeData); die; - if($mail_active == 1){ + if ($mail_active == 1) { $mail_send_return = MailHelper::send_email($wholeData[0]); $this->myLogger->logme("error", $mail_send_return); } // if (isset($wholeData)) { - + // $params['common']['mail_type'] = 'account_maneger_summary_mail'; // $account_manager_wholeData =sendMailNotification::sendMailNotification('account_maneger_summary_mail', $params); // // print_r($account_manager_wholeData); die; @@ -322,12 +319,11 @@ class ClientController extends AdminController // } // } - }else{ + } else { $this->myLogger->logme("error", 'Member Review Mail Configuration not Enable for this client'); } - } - + print_r($wholeData); echo '
';
@@ -346,26 +342,25 @@ class ClientController extends AdminController
     {
         // dd($client_id, $emp_code, $policy_id, $mail_active);
 
-        if(empty($policy_id)){
+        if (empty($policy_id)) {
 
             $client_policy_ids = $this->employeeModel
-                                ->select('employee_polices.client_policy_id')
-                                ->join('employee_polices', 'employees.id = employee_polices.employee_id')
-                                ->where('employees.client_id', $client_id ) 
-                                ->where('employees.emp_code', $emp_code )
-                                ->where('employee_polices.is_active', 1 )
-                                ->where('employees.is_active', 1 )
-                                ->findAll();
+                ->select('employee_polices.client_policy_id')
+                ->join('employee_polices', 'employees.id = employee_polices.employee_id')
+                ->where('employees.client_id', $client_id)
+                ->where('employees.emp_code', $emp_code)
+                ->where('employee_polices.is_active', 1)
+                ->where('employees.is_active', 1)
+                ->findAll();
 
             $client_policy_ids2 = array_column($client_policy_ids, 'client_policy_id');
             $client_policy_id = array_unique($client_policy_ids2);
-
-        }else{
+        } else {
             $client_policy_id = json_decode($policy_id, true);
         }
 
         // dd($client_policy_id);
-    
+
         if (!is_null($client_policy_id) && is_array($client_policy_id)) {
 
             $empData = $this->employeeModel
@@ -373,9 +368,9 @@ class ClientController extends AdminController
                 ->where('client_id', $client_id)
                 ->where('is_active', 1)
                 ->findAll();
-    
+
             $filteredEmpData = array_filter($empData, fn($item) => $item['relationship'] === 'Self');
-    
+
             if (empty($filteredEmpData)) {
                 return $this->respond([
                     'status' => 'error',
@@ -383,7 +378,7 @@ class ClientController extends AdminController
                     'message' => 'No active employee data found for the given criteria.',
                 ], 404);
             }
-    
+
             $array_list = [];
             foreach ($client_policy_id as $value) {
                 $find = $this->employeeModel->getEmpFamilybyEmpCode(
@@ -393,17 +388,17 @@ class ClientController extends AdminController
                     emp_status: ['draft', 'enrolled'],
                     policy_status: ['draft', 'enrolled']
                 );
-    
+
                 if (count($find) > 0) {
                     $array_list[] = $find;
                 }
             }
-    
+
             $notification = $this->notificationModel
                 ->where('client_id', $client_id)
                 ->where('template_name', 'member_review_and_summary_mail')
                 ->first();
-    
+
             if ($notification && $notification['enabled'] == 1) {
 
                 $params = [
@@ -421,14 +416,14 @@ class ClientController extends AdminController
                         'mail_type' => 'member_review_and_summary_mail',
                     ],
                 ];
-    
+
                 $wholeData = sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params);
-    
+
                 if ($mail_active == 0) {
 
                     // $mail_send_result = [];
                     $mail_send_result = MailHelper::send_email($wholeData[0]);
-    
+
                     if ($mail_send_result['status'] === 'success') {
                         return $this->respond([
                             'status' => 'success',
@@ -445,7 +440,7 @@ class ClientController extends AdminController
                         ], 500);
                     }
                 }
-    
+
                 return $this->respond([
                     'status' => 'success',
                     'code' => 200,
@@ -453,28 +448,29 @@ class ClientController extends AdminController
                     'data' => $wholeData,
                 ], 200);
             }
-    
+
             return $this->respond([
                 'status' => 'error',
                 'code' => 400,
                 'message' => 'Member Review Mail configuration is not enabled for this client.',
             ], 400);
         }
-    
+
         return $this->respond([
             'status' => 'error',
             'code' => 404,
             'message' => 'No active client policy IDs found.',
         ], 404);
     }
-    
+
 
     //--------------------------------------------------------------------------------------------------------
 
     public function index()
     {
         $this->myLogger->logme('error', 'Client list function called');
-        $headerData['page_name'] = 'Client List';
+        $headerData['tab_name'] = 'Client List';
+        $headerData['page_name'] = 'Clients'; // Both Browser Tab name And Page name are same. 
         $data['clientList'] = $this->clientModel->getCreatedByUserName();
         $data['client_rm'] = $this->clientRMModel->getAllClientRM();
         $data['lead_data'] = $this->leadsModel->getLeadForInsertClientList();
@@ -599,7 +595,8 @@ class ClientController extends AdminController
     public function clientOnboarding()
     {
         $this->myLogger->logme('error', 'Client Onboarding function called');
-        $headerData['page_name'] = 'Client Onboarding';
+        $headerData['tab_name'] = 'Client Onboarding';
+        $headerData['page_name'] = 'Clients';
 
         $data['entity']        = $this->kycEntityTypeModel->findAll();
         $data['kyc_docs']      = $this->kycDocsModel->findAll();
@@ -621,20 +618,24 @@ class ClientController extends AdminController
 
         // dd($data['placeHolders']);
 
+        // auto fetch client list and branch list from pre
+        $data['auto_fetch_client_list'] =  $this->getClientListFromPre();
+
+
         echo view('layout/header', $headerData);
         echo view('client_onboarding', $data);
         echo view('layout/footer');
     }
 
     // In your controller
-    public function deposit($id = null , $requestFrom = null , $policyId = null)
+    public function deposit($id = null, $requestFrom = null, $policyId = null)
     {
-       
-        $headerData['page_name'] = 'Client Deposit';
-        
+        $headerData['tab_name'] = 'Client Deposit';
+        $headerData['page_name'] = 'Clients';
+
         $data['clientName'] = $this->clientModel->where('id', $id)->find();
-        $data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id,$policyId);
-        
+        $data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id, $policyId);
+
         $data['depositsummary'] = $this->clientPolicyModel->getDepositlistsummary($id);
 
         // Fetch associated insurer names and balances
@@ -642,14 +643,16 @@ class ClientController extends AdminController
         $data['balances'] = $balances;
 
         // dd($data);
-        if($requestFrom == 'rest'){ return $data; }
+        if ($requestFrom == 'rest') {
+            return $data;
+        }
 
         echo view('layout/header', $headerData);
         echo view('client_deposit_list', $data);
         echo view('layout/footer');
     }
 
-    public function view_Deposit($insurerId , $requestFrom = null , $param = null)
+    public function view_Deposit($insurerId, $requestFrom = null, $param = null)
     {
         // Load your model to fetch data based on $clientId and $insurerId
         // $subTypeOptions = [
@@ -671,26 +674,28 @@ class ClientController extends AdminController
         ];
 
         $data['subTypeOptions'] = $subTypeOptions;
-        $headerData['page_name'] = 'Client Deposit';
+        $headerData['tab_name'] = 'Client Deposit';
+        $headerData['page_name'] = 'Clients';
         $loggedInUserID = get_session_userid();
         // $data['clientData']= $this->clientPolicyModel->getinsurerswithinsurenceid($insurerId);
-        if($requestFrom == 'rest')
-        { 
+        if ($requestFrom == 'rest') {
             $clientId = $param['client_id'];
             $cd_ac_pk = $param['cd_ac_pk'];
-        }else{
+        } else {
             $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, $cd_ac_pk, $subTypeOptions);
         $data['clientData'] = $this->clientPolicyModel->getClientById($clientId);
         $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId, $cd_ac_pk);
         $data['cd_ac_pk'] = $cd_ac_pk;
 
-        if($requestFrom == 'rest'){ return $data; }
-        
+        if ($requestFrom == 'rest') {
+            return $data;
+        }
+
         // Load the view for the new list page;
         echo view('layout/header', $headerData);
         echo view('view_deposit', $data);
@@ -712,12 +717,12 @@ class ClientController extends AdminController
             ->where('is_active', 1)
             ->first();
 
-        
-        if(!empty($record_date)){
+
+        if (!empty($record_date)) {
             // Prepare the array with data
             $date = \DateTime::createFromFormat('d/m/Y', $record_date);
             $record_date = $date->format('Y-m-d');
-        }else{
+        } else {
             $record_date = null;
         }
 
@@ -751,7 +756,8 @@ class ClientController extends AdminController
     {
 
         $this->myLogger->logme('error', 'Edit Client Onboarding function called');
-        $headerData['page_name'] = 'Edit Client Onboarding';
+        $headerData['tab_name'] = 'Edit Client Onboarding';
+        $headerData['page_name'] = 'Clients';
 
         $editData['RM']             = $this->userModel->where('is_active', 1)->findAll();
         $editData['tpa']            = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
@@ -792,8 +798,12 @@ class ClientController extends AdminController
         $editData['client_policy']['role'] = get_role_id();
         $editData['notification'] = $this->notificationModel->select('template_name,enabled')->where('client_id', $id)->findAll();
         $editData['placeHolders'] = ['member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
-        $editData['api_data'] = $this->clientApi->where("client_id", $id)->where("is_active",1)->first();
+        $editData['api_data'] = $this->clientApi->where("client_id", $id)->where("is_active", 1)->first();
         // dd($editData);
+
+        $editData['auto_fetch_client_list'] =  $this->getClientListFromPre();
+
+
         echo view('layout/header', $headerData);
         echo view('client_onboarding', $editData);
         echo view('layout/footer');
@@ -817,7 +827,7 @@ class ClientController extends AdminController
             $data['is_download_btn'] = 1;
         }
 
-        if(empty($data['parent_client_id'])){
+        if (empty($data['parent_client_id'])) {
             $data['parent_client_id'] = null;
         }
 
@@ -851,7 +861,7 @@ class ClientController extends AdminController
             $data['is_download_btn'] = 1;
         }
 
-        if(empty($data['parent_client_id'])){
+        if (empty($data['parent_client_id'])) {
             $data['parent_client_id'] = null;
         }
         // print_r($data);die;
@@ -890,9 +900,9 @@ class ClientController extends AdminController
         $insert = $this->clientKYCDocsModel->insert($data);
         if ($insert) {
             // $kycDocs = $this->clientKYCDocsModel->where('client_id', $this->request->getPost('client_id'))->findAll();
-            if($form_type == "others"){
+            if ($form_type == "others") {
                 $kycDocs = $this->generateKycOthersTable($this->request->getPost('client_id'));
-            }else{
+            } else {
                 $kycDocs = $this->generateKycPrimaryTable($this->request->getPost('client_id'));
             }
             return $this->respond(['status' => true, 'code' => 200, 'data' => $kycDocs, 'file_name' => $File], 200);
@@ -920,9 +930,9 @@ class ClientController extends AdminController
 
         if ($insert) {
             // $kycDocs = $this->clientKYCDocsModel->getKycDocsName($id);
-            if($form_type == "others"){
+            if ($form_type == "others") {
                 $kycDocs = $this->generateKycOthersTable($this->request->getPost('client_id'));
-            }else{
+            } else {
                 $kycDocs = $this->generateKycPrimaryTable($this->request->getPost('client_id'));
             }
             return $this->respond(['status' => true, 'code' => 200, 'data' => $kycDocs], 200);
@@ -1070,7 +1080,7 @@ class ClientController extends AdminController
 
         $this->myLogger->logme('error', 'Client branch CREATE function called');
         $data   = $this->request->getPost();
-        // var_dump($data); die;
+
         if (!isset($data['sez'])) {
             $data['sez'] = 0;
         } elseif ($data['sez']) {
@@ -1122,9 +1132,9 @@ class ClientController extends AdminController
         $units   = $this->request->getPost('units');
 
         $emp_unit_count = 0;
-        $rr_unit_count = 0;
+        $rr_unit_count  = 0;
         $rr_unit_count2 = 0;
-        $total_count = 0;
+        $total_count    = 0;
 
         $list_of_branch_units = $this->clientBranchModel->find($id);
         $units = json_decode($list_of_branch_units['units']);
@@ -1383,9 +1393,9 @@ class ClientController extends AdminController
         $data['insurer_id']        = $insurerId;
 
         $tpaValue                  = (string) $this->request->getPost('tpa');
-        if(!empty($tpaValue) || $tpaValue !== ''){
+        if (!empty($tpaValue) || $tpaValue !== '') {
             list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
-        }else{
+        } else {
             $tpaBranchId = null;
             $tpaId = null;
         }
@@ -1461,7 +1471,7 @@ class ClientController extends AdminController
             $clientPoliceData =  $this->clientPolicyModel->getClientPolicyByClientId($client_id);
             $clientPoliceData['role'] = get_role_id();
 
-            if($policy_transaction_data > 0){
+            if ($policy_transaction_data > 0) {
                 $r = Jobs::addJob(['job_name' => 'updatePolicyTransactionDataWhileClinetPolicyUpdate', 'payload' => [
                     'old_client_policy_data' => $old_client_policy_data ?? null,
                     'new_client_policy_data' => $new_client_policy_data ?? null,
@@ -1497,14 +1507,13 @@ class ClientController extends AdminController
             $update = $this->clientPolicyModel->where('id', $id)->set($data)->update();
 
             if ($update) {
-                
+
                 $policy_transaction_update = $this->deactivatePolicyTransactionsPolicy($id);
 
                 return $this->respond(['status' => true, 'code' => 200], 200);
             } else {
                 return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove policy'], 200);
             }
-
         } else {
 
             return $this->respond(['status' => false, 'code' => 404, 'message' => 'The policy has active employees'], 200);
@@ -1536,7 +1545,7 @@ class ClientController extends AdminController
         }
     }
 
-    
+
 
     // Save Rack Rate function
     public function createClientPolicyPremium()
@@ -1990,8 +1999,15 @@ class ClientController extends AdminController
 
             // Check differences and prepare update data
             $fields_to_check = [
-                'client_branch_id', 'policy_type', 'insurer_id', 'insurer_branch_id',
-                'cd_ac_pk', 'policy_end_date', 'policy_start_date', 'tpa_id', 'tpa_branch_id'
+                'client_branch_id',
+                'policy_type',
+                'insurer_id',
+                'insurer_branch_id',
+                'cd_ac_pk',
+                'policy_end_date',
+                'policy_start_date',
+                'tpa_id',
+                'tpa_branch_id'
             ];
 
             foreach ($fields_to_check as $field) {
@@ -2039,18 +2055,16 @@ class ClientController extends AdminController
                 }
 
                 $this->myLogger->logme("error", "Policy transaction(s) updated successfully. Updated IDs: " . json_encode($updated_pt_ids));
-                
+
                 return [
                     'status' => "Success",
                     'message' => "Policy transaction(s) updated.",
                     'updated_ids' => $updated_pt_ids
                 ];
-
             } else {
                 $this->myLogger->logme("error", "No active policy_transaction records found for update.");
                 return ['status' => "Failed", 'message' => "No active policy_transaction records found."];
             }
-
         } catch (\Throwable $e) {
             $this->myLogger->logme("error", "Exception during policy_transaction update: " . $e->getMessage());
             return [
@@ -2096,7 +2110,6 @@ class ClientController extends AdminController
                         $errors[] = "No change or failed update for ID {$row['id']}";
                     }
                 }
-
             } catch (\Exception $e) {
                 $errors[] = "Error updating pt_id {$pt_id}: " . $e->getMessage();
             }
@@ -2185,7 +2198,8 @@ class ClientController extends AdminController
         }
     }
 
-    public function generateKycPrimaryTable($client_id){
+    public function generateKycPrimaryTable($client_id)
+    {
 
         $db = db_connect();
         $builder = $db->table('kyc_docs kd');
@@ -2210,16 +2224,17 @@ class ClientController extends AdminController
 
     }
 
-    public function generateKycOthersTable($client_id){
-        
+    public function generateKycOthersTable($client_id)
+    {
+
         $result['data'] = $this->clientKYCDocsModel
-                ->where('is_active', 1)
-                ->where('client_id', $client_id)
-                ->groupStart()
-                    ->where('kyc_doc_type_id', null)
-                    ->orWhere('kyc_doc_type_id', 0)
-                ->groupEnd()
-                ->findAll();
+            ->where('is_active', 1)
+            ->where('client_id', $client_id)
+            ->groupStart()
+            ->where('kyc_doc_type_id', null)
+            ->orWhere('kyc_doc_type_id', 0)
+            ->groupEnd()
+            ->findAll();
 
         $result['client_id'] = $client_id;
         $table = view('client_kyc_other_table', $result);
@@ -2647,7 +2662,7 @@ class ClientController extends AdminController
             // $data['special_condition_label'] = str_replace(',', '', $this->request->getPost("special_condition_label")) ?? [];
             // $data['special_condition_input'] = str_replace(',', '', $this->request->getPost("special_condition_input")) ?? [];
             // $data['multiple_sum_insured'] = str_replace(',', '', $this->request->getPost("multiple_sum_insured")) ?? [];
-            
+
             $fields = [
                 'waiverofpreexistingdiseases' => false,
                 'waiverof1,2,3&4thyearexclusions' => false,
@@ -2694,17 +2709,17 @@ class ClientController extends AdminController
                 'special_condition_input' => true,
                 'multiple_sum_insured' => true,
             ];
-                       
+
             foreach ($fields as $field => $needsCleanup) {
                 $value = $this->request->getPost($field);
-            
+
                 if ($value !== null && $value !== '') {
                     $data[$field] = $needsCleanup ? str_replace(',', '', $value) : $value;
-                }else{
-                     $data[$field] = $value;
+                } else {
+                    $data[$field] = $value;
                 }
             }
-            
+
             $data['enrollment_display_key'] = $this->enrollmentGMCDisplayValueTransform();
             $this->myLogger->logme('error', "contructed post data : " . json_encode($data ?? []));
             // print_r($data);die;
@@ -2747,11 +2762,11 @@ class ClientController extends AdminController
     //     if ($this->request->getPost("waiverofpreexistingdiseases_display")) {
     //         $data['Waiver of Pre-existing Diseases'] = $this->request->getPost("waiverofpreexistingdiseases");
     //     }
-        
+
     //     if ($this->request->getPost("waiverof1234thyearexclusions_display")) {
     //         $data['Waiver of 1, 2, 3 & 4th year Exclusions'] = $this->request->getPost("waiverof1,2,3&4thyearexclusions");
     //     }
-        
+
     //     if ($this->request->getPost("waiverof30dayswaitingperiod_display")) {
     //         $data['Waiver of 30 days waiting period'] = $this->request->getPost("waiverof30dayswaitingperiod");
     //     }
@@ -2759,157 +2774,157 @@ class ClientController extends AdminController
     //     if ($this->request->getPost("suminsuredenhancement_display")) {
     //         $data['Sum Insured Enhancement'] = $this->request->getPost("suminsuredenhancement");
     //     }
-        
+
     //     if ($this->request->getPost("waiver_of_90_days_waiting_period_display")) {
     //         $data['Waiver of 90 Days Waiting Period'] = $this->request->getPost("waiver_of_90_days_waiting_period");
     //     }
-        
+
     //     if ($this->request->getPost("waiver_of_other_waiting_periods_display")) {
     //         $data['Waiver of Other Waiting Periods'] = $this->request->getPost("waiver_of_other_waiting_periods");
     //     }
-        
+
     //     if ($this->request->getPost("maternity_benefit_display")) {
     //         $data['Maternity Benefit'] = $this->request->getPost("maternity_benefit");
     //     }
-        
+
     //     if ($this->request->getPost("9monthwaitingperiodwaived_display")) {
     //         $data['9-month waiting Period - waived'] = $this->request->getPost("9monthwaitingperiodwaived");
     //     }
-        
+
     //     if ($this->request->getPost("maternitycoverage_display")) {
     //         $data['Maternity Coverage'] = $this->request->getPost("maternitycoverage");
     //     }
-        
+
     //     if ($this->request->getPost("twindelivery_display")) {
     //         $data['Twin Delivery'] = $this->request->getPost("twindelivery");
     //     }
-        
+
     //     if ($this->request->getPost("well_baby_well_mother_expenses_display")) {
     //         $data['Well baby / Well Mother Expenses'] = $this->request->getPost("well_baby_well_mother_expenses");
     //     }
-        
+
     //     if ($this->request->getPost("preandpostnatal_display")) {
     //         $data['Pre and Post natal'] = $this->request->getPost("preandpostnatal");
     //     }
-        
+
     //     if ($this->request->getPost("infertility_treatment_coverage_display")) {
     //         $data['Infertility Treatment Coverage'] = $this->request->getPost("infertility_treatment_coverage");
     //     }
-        
+
     //     if ($this->request->getPost("babyday1cover_display")) {
     //         $data['Baby Day 1 Cover'] = $this->request->getPost("babyday1cover");
     //     }
-        
+
     //     if ($this->request->getPost("coverfromthedateofjoining_display")) {
     //         $data['Cover from the date of Joining'] = $this->request->getPost("coverfromthedateofjoining");
     //     }
-        
+
     //     if ($this->request->getPost("mid_term_addition_of_new_born_newly_wedded_spouse_display")) {
     //         $data['Mid Term Addition of New Born / Newly Wedded Spouse'] = $this->request->getPost("mid_term_addition_of_new_born_newly_wedded_spouse");
     //     }
-        
+
     //     if ($this->request->getPost("prehospitalizationcover_display")) {
     //         $data['Pre Hospitalization Cover'] = $this->request->getPost("prehospitalizationcover");
     //     }
-        
+
     //     if ($this->request->getPost("posthospitalizationcover_display")) {
     //         $data['Post Hospitalization Cover'] = $this->request->getPost("posthospitalizationcover");
     //     }
-        
+
     //     if ($this->request->getPost("congenitaldiseasesinternal_display")) {
     //         $data['Congenital Diseases - Internal'] = $this->request->getPost("congenitaldiseasesinternal");
     //     }
-        
+
     //     if ($this->request->getPost("congenitaldiseasesexternal_display")) {
     //         $data['Congenital Diseases - External'] = $this->request->getPost("congenitaldiseasesexternal");
     //     }
-        
+
     //     if ($this->request->getPost("copayzonewisecopay_display")) {
     //         $data['Co-Pay/Zone wise Co Pay'] = $this->request->getPost("copayzonewisecopay");
     //     }
-        
+
     //     if ($this->request->getPost("roomrentlimit_display")) {
     //         $data['Room Rent Limit'] = $this->request->getPost("roomrentlimit");
     //     }
-        
+
     //     if ($this->request->getPost("icu_limit_display")) {
     //         $data['ICU Limit'] = $this->request->getPost("icu_limit");
     //     }
-        
+
     //     if ($this->request->getPost("proportionatedeductionclause_display")) {
     //         $data['Proportionate Deduction Clause'] = $this->request->getPost("proportionatedeductionclause");
     //     }
-        
+
     //     if ($this->request->getPost("ailmentcapping_display")) {
     //         $data['Ailment capping'] = $this->request->getPost("ailmentcapping");
     //     }
-        
+
     //     if ($this->request->getPost("ailment_capping_details_display")) {
     //         $data['Ailment capping Details'] = $this->request->getPost("ailment_capping_details");
     //     }
-        
+
     //     if ($this->request->getPost("corporatebuffer_display")) {
     //         $data['Corporate Buffer'] = $this->request->getPost("corporatebuffer");
     //     }
-        
+
     //     if ($this->request->getPost("non_admissible_contingency_corporate_buffer_display")) {
     //         $data['Non-Admissible / Contingency Corporate Buffer'] = $this->request->getPost("non_admissible_contingency_corporate_buffer");
     //     }
-        
+
     //     if ($this->request->getPost("ambulancecharges_display")) {
     //         $data['Ambulance Charges'] = $this->request->getPost("ambulancecharges");
     //     }
-        
+
     //     if ($this->request->getPost("airambulance_display")) {
     //         $data['Air Ambulance'] = $this->request->getPost("airambulance");
     //     }
-        
+
     //     if ($this->request->getPost("reasonableandcustomarycharges_display")) {
     //         $data['Reasonable and Customary Charges'] = $this->request->getPost("reasonableandcustomarycharges");
     //     }
-        
+
     //     if ($this->request->getPost("daycaretreatment_display")) {
     //         $data['Day Care Treatment'] = $this->request->getPost("daycaretreatment");
     //     }
-        
+
     //     if ($this->request->getPost("lasiksurgery_display")) {
     //         $data['Lasik Surgery'] = $this->request->getPost("lasiksurgery");
     //     }
-        
+
     //     if ($this->request->getPost("ayushtreatmentcover_display")) {
     //         $data['AYUSH treatment cover'] = $this->request->getPost("ayudhtreatmentcover");
     //     }
-        
+
     //     if ($this->request->getPost("moderntreatmentsasperirdai_display")) {
     //         $data['Modern treatments as per IRDAI'] = $this->request->getPost("moderntreatmentsasperirdai");
     //     }
-        
+
     //     if ($this->request->getPost("opd_treatment_display")) {
     //         $data['OPD Treatment'] = $this->request->getPost("opd_treatment");
     //     }
-        
+
     //     if ($this->request->getPost("days_of_discharge_display")) {
     //         $data['Claim Intimation Clause'] = $this->request->getPost("days_of_discharge");
     //     }
-        
+
     //     if ($this->request->getPost("days_from_dod_display")) {
     //         $data['Claim Submission'] = $this->request->getPost("days_from_dod");
     //     }
-        
+
     //     if ($this->request->getPost("terrorism_display")) {
     //         $data['Terrorism'] = $this->request->getPost("terrorism");
     //     }
-        
+
     //     if ($this->request->getPost("widower_cover_display")) {
     //         $data['Widower Cover'] = $this->request->getPost("widower_cover");
     //     }
-        
+
     //     if ($this->request->getPost("breavement_cover_display")) {
     //         $data['Breavement Cover'] = $this->request->getPost("breavement_cover");
     //     }
 
     //     if ($this->request->getPost("special_condition_display_value")) {
-            
+
     //         $specialConditionKeyValue = $this->request->getPost("special_condition_display_value") ?? [];
     //         $specialConditionKeyValue = json_decode($specialConditionKeyValue, true);
 
@@ -2918,14 +2933,14 @@ class ClientController extends AdminController
     //             $data = array_merge($data, $mergedArray);
     //         }
     //     }
-        
+
     //     if(isset($data) && !empty($data)){
     //         return $data;
     //     }else{
     //         $data = [];
     //         return $data;
     //     }
-    
+
     // }
 
     public function enrollmentGMCDisplayValueTransform()
@@ -3092,7 +3107,7 @@ class ClientController extends AdminController
                 'gpa_special_condition_input',
                 'multiple_sum_insured',
             ];
-            
+
             $fieldsWithoutCommaRemoval = [
                 'permanentPartialDisablement',
                 'temporaryTotalDisablementBenefit',
@@ -3109,27 +3124,27 @@ class ClientController extends AdminController
                 'animalSnakeInsectBite',
                 'air_ambulance'
             ];
-            
+
             // Remove commas and assign if present
             foreach ($fieldsWithCommaRemoval as $field) {
                 $value = $this->request->getPost($field);
                 if ($value !== null) {
                     $data[$field] = str_replace(',', '', $value);
-                }else{
-                     $data[$field] = $value;
+                } else {
+                    $data[$field] = $value;
                 }
             }
-            
+
             // Direct assign if present
             foreach ($fieldsWithoutCommaRemoval as $field) {
                 $value = $this->request->getPost($field);
                 if ($value !== null) {
                     $data[$field] = $value;
-                }else{
-                     $data[$field] = $value;
+                } else {
+                    $data[$field] = $value;
                 }
             }
-            
+
             $data['enrollment_display_key'] = $this->enrollmentGPADisplayValueTransform();
 
             // print_r($data); die;
@@ -3819,10 +3834,10 @@ class ClientController extends AdminController
 
         $cd_data = array_merge($cd_data, $client_cd_data);
 
-        if($return_type == "internal"){
-            if(!empty($cd_data)){
+        if ($return_type == "internal") {
+            if (!empty($cd_data)) {
                 return $cd_data;
-            }else{
+            } else {
                 return [];
             }
         }
@@ -3850,7 +3865,7 @@ class ClientController extends AdminController
 
         $client_policy_id = $this->request->getPost("client_policy_id");
         $policy_terms = $this->request->getPost("policy_terms");
-        $policy_terms = json_decode($policy_terms, true); 
+        $policy_terms = json_decode($policy_terms, true);
 
         $data = [];
 
@@ -3858,12 +3873,11 @@ class ClientController extends AdminController
 
             if (str_ends_with($key, '_display')) {
 
-                $original_key = substr($key, 0, -8); 
+                $original_key = substr($key, 0, -8);
 
                 $newKey = implode(' ', array_map('ucfirst', explode('_', $original_key)));
 
                 $data['enrollment_display_key'][$newKey] = $policy_terms[$original_key] ?? " ";
-
             } else {
 
                 $data[$key] = $value;
@@ -3871,10 +3885,10 @@ class ClientController extends AdminController
         }
 
         if (!empty($data)) {
-            $policy_terms['is_payable_employee']['self'] = 0; 
-            $policy_terms = json_encode($data); 
+            $policy_terms['is_payable_employee']['self'] = 0;
+            $policy_terms = json_encode($data);
         }
-        
+
 
         $record = $this->clientPolicyModel->where('id', $client_policy_id)->first();
 
@@ -4296,9 +4310,9 @@ class ClientController extends AdminController
         // -----------for vehicle ---------------------------------------------------------------------------
 
         $vehicles = $this->vehicleModel
-        ->select('vehicle.*, clients.client_type')
-        ->join('clients', 'clients.id=vehicle.owner')
-        ->where('vehicle.is_active', 1)->findAll();
+            ->select('vehicle.*, clients.client_type')
+            ->join('clients', 'clients.id=vehicle.owner')
+            ->where('vehicle.is_active', 1)->findAll();
 
         // -----------for Insurer ---------------------------------------------------------------------------
 
@@ -4421,12 +4435,12 @@ class ClientController extends AdminController
         $cd_data = array_merge($cd_data, $client_cd_data);
 
         if (!empty($cd_data)) {
-            return $this->respond([ 'status' => true,'code' => 200, 'data' => $cd_data], 200);
+            return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200);
         } else {
-            return $this->respond(['status' => false,'code' => 404,'client_id' => $client_id,'insurer_id' => $insurer_id,'insurer_branch_id' => $insurer_branch_id ], 200);
+            return $this->respond(['status' => false, 'code' => 404, 'client_id' => $client_id, 'insurer_id' => $insurer_id, 'insurer_branch_id' => $insurer_branch_id], 200);
         }
     }
-    
+
     // public function getCDAccNoByClientAndInsurer($client, $insurer, $insurer_branch_id)
     // {
     //     $cdmData = $this->CDMasterModel
@@ -4461,7 +4475,7 @@ class ClientController extends AdminController
         // Add additional fields if client type is 2
         if ($client_type == 2) {
             $client_data = array_merge($client_data, [
-                'dob' => change_date_format($postData['dob'],'d/m/Y','Y-m-d'),
+                'dob' => change_date_format($postData['dob'], 'd/m/Y', 'Y-m-d'),
                 'aadhar' => $postData['aadhar'],
                 'phone' => $postData['phone'],
                 'entity_type_id' => 7
@@ -4519,7 +4533,7 @@ class ClientController extends AdminController
         $client_type = $postData['client_type'] ?? null;
 
         $client_insert = null;
-        if($client_type == 2){
+        if ($client_type == 2) {
 
             $client_data = [
                 'client_type' => $postData['client_type'],
@@ -4530,8 +4544,7 @@ class ClientController extends AdminController
             ];
 
             $client_insert = $this->clientModel->insert($client_data);
-
-        }else if($client_type == 1){
+        } else if ($client_type == 1) {
 
             $client_data = [
                 'client_type' => $postData['client_type'],
@@ -4539,10 +4552,10 @@ class ClientController extends AdminController
                 'short_name' => $postData['short_name'] ?? $postData['client_name'],
                 'client_code' => generate_client_code(),
                 'entity_type_id' => 2
-            ]; 
-        
-             $client_insert = $this->clientModel->insert($client_data);
-        }        
+            ];
+
+            $client_insert = $this->clientModel->insert($client_data);
+        }
 
         if (!$client_insert) {
             return $this->respond(['status' => false, 'message' => 'Failed to create client'], 200);
@@ -4582,7 +4595,7 @@ class ClientController extends AdminController
             ->where('client_id', $client_insert)
             ->where('is_active', 1)
             ->findAll();
-            
+
         return $this->respond([
             'status' => true,
             'data' => $postData,
@@ -4613,12 +4626,12 @@ class ClientController extends AdminController
             $vehicle_insert = $this->vehicleModel->insert($data);
 
             if ($vehicle_insert) {
-                
+
                 // $vehicles = $this->vehicleModel->where('is_active', 1)->findAll();
                 $vehicles = $this->vehicleModel->select('vehicle.*, clients.client_type')
-                            ->join('clients', 'clients.id=vehicle.owner')
-                            ->where('vehicle.is_active', 1)
-                            ->findAll();
+                    ->join('clients', 'clients.id=vehicle.owner')
+                    ->where('vehicle.is_active', 1)
+                    ->findAll();
 
                 return $this->respond([
                     'status' => true,
@@ -4656,7 +4669,6 @@ class ClientController extends AdminController
                 ];
 
                 $client_insert = $this->clientModel->insert($client_data);
-
             } else if ($client_type == 1) {
 
                 $client_data = [
@@ -4717,7 +4729,7 @@ class ClientController extends AdminController
                     ->where('is_active', 1)
                     ->findAll();
 
-                    // Fetch branches in a single query
+                // Fetch branches in a single query
                 $branches = $this->clientBranchModel
                     ->where('client_id', $client_insert)
                     ->where('is_active', 1)
@@ -4734,11 +4746,9 @@ class ClientController extends AdminController
                     'vehicles' => $vehicles,
                     'message' => 'Vehicle created successfully'
                 ], 200);
-
             } else {
                 return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200);
             }
-
         } else if (isset($data['owner']) && !empty($data['owner'])) {
 
             $vehicle_data = [
@@ -4750,7 +4760,7 @@ class ClientController extends AdminController
             ];
 
             $vehicle_insert = $this->vehicleModel->insert($vehicle_data);
-            
+
             $vehicles = $this->vehicleModel->select('vehicle.*, clients.client_type')
                 ->join('clients', 'clients.id = vehicle.owner')
                 ->where('vehicle.is_active', 1)
@@ -4761,7 +4771,7 @@ class ClientController extends AdminController
                 ->where('is_active', 1)
                 ->findAll();
 
-                // Fetch branches in a single query
+            // Fetch branches in a single query
             $branches = $this->clientBranchModel
                 ->where('client_id', $data['owner'])
                 ->where('is_active', 1)
@@ -4780,7 +4790,6 @@ class ClientController extends AdminController
                     'vehicles' => $vehicles,
                     'message' => 'Vehicle created successfully'
                 ], 200);
-                
             } else {
                 return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200);
             }
@@ -4928,7 +4937,7 @@ class ClientController extends AdminController
     //                 return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200);
     //             }
     //         }
-            
+
     //     } else {
     //         return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200);
     //     }
@@ -4944,10 +4953,10 @@ class ClientController extends AdminController
         $client_type = $this->request->getGet('client_type');
 
         $data = $this->policyTransactionModel
-                        ->where('is_active', 1)
-                        ->where('action_type', 'inception')
-                        ->where('policy_no', $policy_no)
-                        ->countAllResults();
+            ->where('is_active', 1)
+            ->where('action_type', 'inception')
+            ->where('policy_no', $policy_no)
+            ->countAllResults();
 
         if ($data > 0) {
             return $this->respond(['status' => true, 'message' => 'This policy number is already linked to another client', 'data' => $data, 'code' => 409, 'received_data' => $received_data], 200);
@@ -4957,7 +4966,7 @@ class ClientController extends AdminController
     }
 
     public function get_client_policy_data_using_policy_no_and_endo_no()
-    {   
+    {
         $policy_no = $this->request->getGet('policy_no');
         $endorsement_no = $this->request->getGet('endorsement_no');
 
@@ -4980,10 +4989,10 @@ class ClientController extends AdminController
     {
         if ($id) {
             $branch_data = $this->clientBranchModel
-                    ->select('client_branch.*, clients.pan')
-                    ->join('clients', 'client_branch.client_id = clients.id')
-                    ->where(['client_branch.id' => $id, 'client_branch.is_active' => 1])
-                    ->first();
+                ->select('client_branch.*, clients.pan')
+                ->join('clients', 'client_branch.client_id = clients.id')
+                ->where(['client_branch.id' => $id, 'client_branch.is_active' => 1])
+                ->first();
             $branch_contact_data = $this->levelContactModel->where(['ref_id' => $id, 'contact_type' => 'client', 'is_active' => 1])->findAll();
             // print_rr($branch_contact_data);die();
             return $this->respond(['status' => true, 'code' => 200, 'data' => $branch_data, 'contact' => $branch_contact_data], 200);
@@ -4993,7 +5002,7 @@ class ClientController extends AdminController
     }
 
     public function getClientData()
-    {   
+    {
         $client_id = $this->request->getGet('client_id') ?? null;
         $result = $this->clientModel->getClientData($client_id);
         dd($result);
@@ -5010,17 +5019,17 @@ class ClientController extends AdminController
             ->where("policy_terms IS NOT NULL AND policy_terms <> ''")
             ->where('is_active', 1);
 
-        
+
         if (!empty($client_id)) {
             $query->where('client_id', $client_id);
         }
-        
+
         if (!empty($policy_type_id)) {
             $query->where('policy_type_id', $policy_type_id);
         }
-        
+
         $data = $query->findAll();
-        
+
         for ($i = 0; $i < count($data); $i++) {
 
             // dd($data[$i]);
@@ -5036,30 +5045,28 @@ class ClientController extends AdminController
             $is_addon = $data[$i]['is_addon'];
 
             $payable_arr = [];
-            if (in_array($data[$i]['policy_type_id'], [2,3]) && $is_addon == 1) {
-
-                $payable_arr = [ "self" => 0, "spouse" => 0, "childern" => 0, "elders" => 0, ];
+            if (in_array($data[$i]['policy_type_id'], [2, 3]) && $is_addon == 1) {
 
+                $payable_arr = ["self" => 0, "spouse" => 0, "childern" => 0, "elders" => 0,];
             } else if ($data[$i]['policy_type_id'] == 3 && $is_addon == 3) {
 
-                $payable_arr = ["self" => 1,"spouse" => 1,"childern" => 1,"elders" => 1,];
-
+                $payable_arr = ["self" => 1, "spouse" => 1, "childern" => 1, "elders" => 1,];
             } else if (in_array($data[$i]['policy_type_id'], [4, 5])) {
 
-                $payable_arr = ["self" => 1,"spouse" => 1,"childern" => 1,"elders" => 1,];
+                $payable_arr = ["self" => 1, "spouse" => 1, "childern" => 1, "elders" => 1,];
             }
 
             // Initialize an empty array for the ordered policy terms
             $orderedPolicyTerms = [];
 
-            if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){
+            if (in_array($data[$i]['policy_type_id'], [2, 3, 4, 5])) {
 
                 // Set default value of copayzonewisecopay to "empty"
                 // $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty';
 
                 // add is_payable_employee for the GMC Policy
                 if (isset($policyTerms['age_ratio'])) {
-                    if(!isset($policyTerms['is_payable_employee'])){
+                    if (!isset($policyTerms['is_payable_employee'])) {
                         $aliment_index = array_search('age_ratio', array_keys($policyTerms));
                         $orderedPolicyTerms[] = [
                             "key" => "is_payable_employee",
@@ -5097,7 +5104,7 @@ class ClientController extends AdminController
 
                 // Add ailmentcapping and ailmentcappingdata if they exist
                 if (isset($policyTerms['ailmentcapping'])) {
-                    if(!isset($policyTerms['ailment_capping_details'])){
+                    if (!isset($policyTerms['ailment_capping_details'])) {
                         $aliment_index = array_search('ailmentcapping', array_keys($policyTerms));
                         $orderedPolicyTerms[] = [
                             "key" => "ailment_capping_details",
@@ -5106,12 +5113,11 @@ class ClientController extends AdminController
                         ];
                     }
                 }
-
-            }else {
+            } else {
 
                 // add is_payable_employee for the GMC Policy
                 if (isset($policyTerms['age_ratio'])) {
-                    if(!isset($policyTerms['is_payable_employee'])){
+                    if (!isset($policyTerms['is_payable_employee'])) {
                         $aliment_index = array_search('age_ratio', array_keys($policyTerms));
                         $orderedPolicyTerms[] = [
                             "key" => "is_payable_employee",
@@ -5121,9 +5127,9 @@ class ClientController extends AdminController
                             "position" => $aliment_index + 1,
                         ];
                     }
-                }else{
+                } else {
 
-                    if(!isset($policyTerms['is_payable_employee'])){
+                    if (!isset($policyTerms['is_payable_employee'])) {
                         $orderedPolicyTerms[] = [
                             "key" => "is_payable_employee",
                             "value" => [
@@ -5133,7 +5139,6 @@ class ClientController extends AdminController
                         ];
                     }
                 }
-
             }
 
             foreach ($orderedPolicyTerms as $term) {
@@ -5155,12 +5160,12 @@ class ClientController extends AdminController
                 }
             }
 
-            if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){
+            if (in_array($data[$i]['policy_type_id'], [2, 3, 4, 5])) {
 
                 if (!isset($policyTerms['waiver_of_90_days_waiting_period'])) {
                     $policyTerms['waiver_of_90_days_waiting_period'] = "";
                 }
-                
+
                 if (!isset($policyTerms['waiver_of_other_waiting_periods'])) {
                     $policyTerms['waiver_of_other_waiting_periods'] = "";
                 }
@@ -5168,7 +5173,7 @@ class ClientController extends AdminController
                 if (!isset($policyTerms['maternity_benefit'])) {
                     $policyTerms['maternity_benefit'] = "";
                 }
-                
+
                 if (!isset($policyTerms['well_baby_well_mother_expenses'])) {
                     $policyTerms['well_baby_well_mother_expenses'] = "";
                 }
@@ -5196,61 +5201,59 @@ class ClientController extends AdminController
                 if (!isset($policyTerms['widower_cover'])) {
                     $policyTerms['widower_cover'] = "";
                 }
-                
+
                 if (!isset($policyTerms['breavement_cover'])) {
                     $policyTerms['breavement_cover'] = "";
                 }
-                
+
                 if (!isset($policyTerms['enrollment_display_key'])) {
                     $policyTerms['enrollment_display_key'] = $this->existingGMCDisplayValueTransform($policyTerms);
                 }
-
-            } else if($data[$i]['policy_type_id'] == 1){
+            } else if ($data[$i]['policy_type_id'] == 1) {
 
                 if (!isset($policyTerms['medical_expenses_medical_extension'])) {
                     $policyTerms['medical_expenses_medical_extension'] = "";
                 }
-                
+
                 if (!isset($policyTerms['opd_treatment_cover'])) {
                     $policyTerms['opd_treatment_cover'] = "";
                 }
-                
+
                 if (!isset($policyTerms['repatriation_of_mortal_remains'])) {
                     $policyTerms['repatriation_of_mortal_remains'] = "";
                 }
-                
+
                 if (!isset($policyTerms['family_transportation_benefits'])) {
                     $policyTerms['family_transportation_benefits'] = "";
                 }
-                
+
                 if (!isset($policyTerms['fractures_dislocation_burns'])) {
                     $policyTerms['fractures_dislocation_burns'] = "";
                 }
-                
+
                 if (!isset($policyTerms['coma'])) {
                     $policyTerms['coma'] = "";
                 }
-                
+
                 if (!isset($policyTerms['travel_expenses_for_medical_treatment'])) {
                     $policyTerms['travel_expenses_for_medical_treatment'] = "";
                 }
-                
+
                 if (!isset($policyTerms['daily_cash_allowance'])) {
                     $policyTerms['daily_cash_allowance'] = "";
                 }
-                
+
                 if (!isset($policyTerms['artifical_limb_and_prosthesis'])) {
                     $policyTerms['artifical_limb_and_prosthesis'] = "";
                 }
-                
+
                 if (!isset($policyTerms['air_ambulance'])) {
                     $policyTerms['air_ambulance'] = "";
                 }
-                                
+
                 if (!isset($policyTerms['enrollment_display_key'])) {
                     $policyTerms['enrollment_display_key'] = $this->existingGPADisplayValueTransform($policyTerms);
                 }
-                
             }
 
             // dd($policyTerms);
@@ -5431,7 +5434,7 @@ class ClientController extends AdminController
     }
 
     public function existingGPADisplayValueTransform($data)
-    {   
+    {
         $transformedData = [];
 
         if (isset($data["accidentalDeathBenefit"])) {
@@ -5474,7 +5477,7 @@ class ClientController extends AdminController
             $transformedData['Fractures / Dislocation / Burns'] = $data["fractures_dislocation_burns"];
         }
         if (isset($data["coma"])) {
-            $transformedData['Coma'] = $data["coma"]; 
+            $transformedData['Coma'] = $data["coma"];
         }
         if (isset($data["carriageofDeadBody"])) {
             $transformedData['Carriage of Dead Body'] = $data["carriageofDeadBody"];
@@ -5509,24 +5512,24 @@ class ClientController extends AdminController
             ->where('is_active', 1)
             ->get()
             ->getResultArray();
-    
+
         $days = [];
         foreach ($data as $value) {
 
             $reminderDate = strtotime($value['reminder_date']);
             if ($reminderDate) {
                 $date_of_date = date('d', $reminderDate);
-                $days[] = $date_of_date; 
+                $days[] = $date_of_date;
                 $days[] = $value['reminder_date'];
                 db_connect()->table('client_policy')->where('id', $value['id'])->set('reminder_date', $date_of_date)->update();
-            } 
+            }
         }
-    
+
         dd($days);
     }
 
     public function sendextraparam()
-    {   
+    {
         //     $data = db_connect()->table('jobs')->where('id', 1677)->get()->getRowArray();
         //     // dd($data);
         //    $return = $this->updatePolicyTransactionDataWhileClinetPolicyUpdate(json_decode($data['payload'], true));
@@ -5557,7 +5560,7 @@ class ClientController extends AdminController
         // $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']);
         // $res = $empServiceController->employeeDisembark(['file_id' => '1681']); 
         // $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']); 
-        dd( $res); 
+        dd($res);
 
         $EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController();
         // $res = $EmployeeMultiEventServiceController->constructMultiEventData(['file_id' => '1069']); 
@@ -5588,7 +5591,7 @@ class ClientController extends AdminController
             'event_type' => "correction",
             'actions' => "export",
             'file_name' => "deletion_enhancement_test_file.xlsx",
-        ]; 
+        ];
 
         // $batch_data = [
         //     'client_id' => 20,
@@ -5610,7 +5613,7 @@ class ClientController extends AdminController
 
         // $emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard(12);
         // $ids = array_column($emp_data, 'id');
-        
+
         $EmpDataServiceController = new EmpDataServiceController();
         // $res = $EmpDataServiceController->generateExcelForDeletion($batch_data); dd($return); die;
         // $res = $EmpDataServiceController->generateExcelForSIEnhancement($batch_data); die;
@@ -5636,7 +5639,7 @@ class ClientController extends AdminController
         // ];
         // $res = $EmpDataServiceController->makeEntryForBDSPolicyTransaction($params);
         // dd($res);
-        
+
         // $array = [
         //         "employeeIds" => ["12800", "12798", "12797", "12799"],
         //         "client_id" => "159",
@@ -5649,7 +5652,7 @@ class ClientController extends AdminController
         //         "policy_name" => "GMC",
         //         "user_id" => "1"
         // ];
-        
+
         // $EmpDataServiceController->cashDepositCalculationForDeletion($array);
 
         // $result = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($batch_data);
@@ -5679,11 +5682,11 @@ class ClientController extends AdminController
         // dd($res);
 
         // -----------BDS REPORT CONTROLLER---------------------------------------------------------------------------------
-        
+
         // $BDSReportController = new BDSReportController();
 
         // $data['data'] = $BDSReportController->getBAPInsurerData();
-        
+
         // return $this->loadLayout('irda_bap_insurer_report_list', $data);
 
         // $data['data'] = $BDSReportController->getBAPClientData();
@@ -5700,7 +5703,7 @@ class ClientController extends AdminController
         // $email_id = 'venkateshraman786@gmail.com';
         // $common = ['mail_type'=>'test_mail_cli'];
         // $bcc = "vitvelz@gmail.com";
-        
+
         // $data = db_connect()
         // ->table('jobs')
         // ->where('id', 2264)
@@ -5708,7 +5711,7 @@ class ClientController extends AdminController
         // ->getResultArray();
 
         // $data = json_decode($data[0]['payload'], true);
-        
+
         // // dd($data);
         // // Send email and get response
         // $result = MailHelper::send_email($data[0]);
@@ -5722,7 +5725,7 @@ class ClientController extends AdminController
         // print_rr($reportData);
         // $this->loadLayout('tat_report_band_wise_list', $reportData);
         // $data = $ticketModel->getTATReport(1);
-        
+
         // $empmodel = new EmployeeModel();
         // $data = $empmodel->getEmployeePolicy(348);
         // dd($data);
@@ -5786,7 +5789,7 @@ class ClientController extends AdminController
         // $return_value = check_cd_entry_exist($baseWhere);
         // dd($return_value);
 
-        
+
 
 
         // $param = 9715454901;
@@ -5807,7 +5810,7 @@ class ClientController extends AdminController
     }
 
     // -------------------------------------------------------------------------------------------------------
-    
+
 
     public function createOtherTabContent()
     {
@@ -5830,20 +5833,16 @@ class ClientController extends AdminController
     // -------------------------------------------------------------------------------------------------------
 
     public function enrollmentAddonSIAmountDropdown($client_policy_id)
-    {   
-        if(!empty($client_policy_id)){
+    {
+        if (!empty($client_policy_id)) {
             $client_policy_details = $this->clientPolicyModel->where('id', $client_policy_id)->where('policy_status', 1)->where('is_active', 1)->first();
 
-            if(!empty($client_policy_details) && $client_policy_details['policy_type_id'] == 3 && $client_policy_details['is_addon'] == 3){
+            if (!empty($client_policy_details) && $client_policy_details['policy_type_id'] == 3 && $client_policy_details['is_addon'] == 3) {
 
                 $base_policy_id = $client_policy_details['base_policy'] ?? 0;
 
-                if(!empty($base_policy_id)){
-
-                    
-                    
+                if (!empty($base_policy_id)) {
                 }
-
             }
         }
     }
@@ -5853,12 +5852,12 @@ class ClientController extends AdminController
         $cd_ac_pk = $this->request->getGet('cd_ac_pk');
 
         $cd_amount = $this->clientDepositModel
-                ->where('is_active', 1)
-                ->where('cd_ac_pk', $cd_ac_pk)
-                ->orderBy('id', 'desc')
-                ->first();
+            ->where('is_active', 1)
+            ->where('cd_ac_pk', $cd_ac_pk)
+            ->orderBy('id', 'desc')
+            ->first();
 
-        if($cd_amount){
+        if ($cd_amount) {
             return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_amount], 200);
         } else {
             return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
@@ -5907,9 +5906,9 @@ class ClientController extends AdminController
             ->getResultArray();
 
         // print_r(db_connect()->getLastQuery()); die;
-       
+
         $dataForClientAndInsurer = $this->clientPolicyModel
-                ->select("
+            ->select("
                         clients.id AS client_id,
                         clients.client_name,
                         insurers.id AS insurer_id,
@@ -5917,12 +5916,12 @@ class ClientController extends AdminController
                         tpa.id AS tpa_id,
                         tpa.name AS tpa_name,
                     ")
-                ->join('clients', 'client_policy.client_id = clients.id', 'left')
-                ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
-                ->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
-                ->where('client_policy.id', $param)
-                ->first();
-                
+            ->join('clients', 'client_policy.client_id = clients.id', 'left')
+            ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
+            ->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
+            ->where('client_policy.id', $param)
+            ->first();
+
         $memberData = [];
 
         // Respond based on the query result
@@ -6097,9 +6096,9 @@ class ClientController extends AdminController
     {
         $db = db_connect();
         $renewalData = $db->table('old_renewal_data_copy')
-        ->where('client_id IS NOT NULL')
-        ->where('is_inserted != 1')
-        ->get()
+            ->where('client_id IS NOT NULL')
+            ->where('is_inserted != 1')
+            ->get()
             ->getResultArray();
         // dd($renewalData);
 
@@ -6123,8 +6122,8 @@ class ClientController extends AdminController
 
             // Update is_inserted field in DB
             $db->table('old_renewal_data_copy')
-            ->where('id', $value['id'])
-            ->set(['is_inserted' => 1])
+                ->where('id', $value['id'])
+                ->set(['is_inserted' => 1])
                 ->update();
 
             $successData[] = ['id' => $value['id'], 'client' => $value['insured']];
@@ -6137,8 +6136,8 @@ class ClientController extends AdminController
     {
         $db = db_connect();
         $renewalData = $db->table('old_renewal_data_copy')
-        ->where('insurer_id IS NULL')
-        ->get()
+            ->where('insurer_id IS NULL')
+            ->get()
             ->getResultArray();
         // dd($renewalData);
 
@@ -6165,11 +6164,11 @@ class ClientController extends AdminController
 
             // Update is_inserted field in DB
             $db->table('old_renewal_data_copy')
-            ->where('id', $value['id'])
-            ->set([
-                'insurer_id' => $value['insurer_id'],
-                'insurer_branch_id' => $value['insurer_branch_id'],
-            ])
+                ->where('id', $value['id'])
+                ->set([
+                    'insurer_id' => $value['insurer_id'],
+                    'insurer_branch_id' => $value['insurer_branch_id'],
+                ])
                 ->update();
 
             $successData[] = ['id' => $value['id'], 'insurer' => $value['insurer_name'], 'insurer_id' => $value['insurer_id'], 'insurer_branch_id' => $value['insurer_branch_id'],];
@@ -6184,9 +6183,9 @@ class ClientController extends AdminController
         $group = $this->request->getGet('group') ?? 2;
         $db = db_connect();
         $renewalData = $db->table('old_renewal_data_copy')
-        ->where('client_id IS NULL')
-        ->where('is_inserted = 0')
-        ->where('client_type_id', $group)
+            ->where('client_id IS NULL')
+            ->where('is_inserted = 0')
+            ->where('client_type_id', $group)
             // ->limit($limit)
             ->get()
             ->getResultArray();
@@ -6221,8 +6220,8 @@ class ClientController extends AdminController
 
             // Update is_inserted field in DB
             $db->table('old_renewal_data_copy')
-            ->where('id', $value['id'])
-            ->set(['is_inserted' => 1])
+                ->where('id', $value['id'])
+                ->set(['is_inserted' => 1])
                 ->update();
 
             $successData[] = ['id' => $value['id'], 'client' => $value['insured'], 'vehicle_id' => $value['vehicle_id']];
@@ -6313,8 +6312,8 @@ class ClientController extends AdminController
         }
 
         $vehicleData = $VehicleModel->where('owner', $renewalData['client_id'])
-        ->where('is_active', 1)
-        ->findAll();
+            ->where('is_active', 1)
+            ->findAll();
 
         if (!empty($vehicleData)) {
             $increment = count($vehicleData);
@@ -6554,17 +6553,17 @@ class ClientController extends AdminController
         return $id;
     }
 
-    private function reorderProposalsByInsurerTotal(array $data): array 
+    private function reorderProposalsByInsurerTotal(array $data): array
     {
 
         Kint::dump($data);
         if (!isset($data['premium_data']['data'])) return $data;
-    
+
         $original = $data['premium_data']['data'];
         $proposals = [];
         $others = [];
         $emptyKeyData = [];
-    
+
         foreach ($original as $key => $value) {
             // Match only keys that look like 'Proposal X'
             if (preg_match('/^Proposal\s+\d+$/', $key)) {
@@ -6573,7 +6572,7 @@ class ClientController extends AdminController
                     if ($subKey !== 'Quote Asked' && isset($subVal['Total'])) {
                         $proposals[$key] = $value;
                         break;
-                    }else{
+                    } else {
                         $proposals[$key] = $value;
                     }
                 }
@@ -6582,51 +6581,50 @@ class ClientController extends AdminController
                 if ($key === '' && isset($value['']) && is_array($value[''])) {
                     // Capture empty key to push it later
                     $emptyKeyData[$key] = $value;
-                }else{
+                } else {
                     $others[$key] = $value;
-
                 }
             }
         }
-    
+
         // dd($proposals, $others, $emptyKeyData);
         // Sort proposals by their insurer's total
-        uasort($proposals, function($a, $b) {
+        uasort($proposals, function ($a, $b) {
             $totalA = 0;
             $totalB = 0;
-    
+
             foreach ($a as $key => $val) {
                 if ($key !== 'Quote Asked' && isset($val['Total'])) {
                     $totalA = floatval($val['Total']);
                     break;
                 }
             }
-    
+
             foreach ($b as $key => $val) {
                 if ($key !== 'Quote Asked' && isset($val['Total'])) {
                     $totalB = floatval($val['Total']);
                     break;
                 }
             }
-    
+
             return $totalA <=> $totalB;
         });
-    
+
         // Merge back the sorted proposals into the full structure
         $data['premium_data']['data'] = array_merge($others, $proposals, $emptyKeyData);
         $data = $this->reorderProposalDataByPremiumOrder($data);
         return $data;
     }
 
-    private function reorderProposalDataByPremiumOrder(array $data): array 
+    private function reorderProposalDataByPremiumOrder(array $data): array
     {
         if (!isset($data['premium_data']['data'], $data['proposal_data']['over_all_column_data'])) {
             return $data;
         }
-    
+
         $premiumProposals = array_keys($data['premium_data']['data']);
         $filteredProposals = [];
-    
+
         // Collect proposal keys that match the pattern "Proposal X"
         foreach ($premiumProposals as $key) {
             if (preg_match('/^Proposal\s+\d+$/', $key) && isset($data['proposal_data']['over_all_column_data'][$key])) {
@@ -6635,13 +6633,13 @@ class ClientController extends AdminController
         }
 
         // dd($premiumProposals, $filteredProposals);
-    
+
         $data['proposal_data']['over_all_column_data'] = $filteredProposals;
         $data = $this->reorderProposalInHeaderAndData($data);
         return $data;
     }
-    
-    private function reorderProposalInHeaderAndData(array $data): array 
+
+    private function reorderProposalInHeaderAndData(array $data): array
     {
 
         // Kint::dump($data);
@@ -6649,7 +6647,7 @@ class ClientController extends AdminController
         $sortedProposalOrder = $data['proposal_data']['over_all_column_data'];
         $headers = $tableData['headers'] ?? [];
         $dataRows = $tableData['data'] ?? [];
-    
+
         // Step 1: Separate static and proposal headers
         $staticHeaders = [];
         $proposalHeaders = [];
@@ -6658,16 +6656,16 @@ class ClientController extends AdminController
             if (in_array($header['parentHeader'], array_keys($sortedProposalOrder))) {
                 $proposalHeaders[$header['parentHeader']] = $header;
             } else {
-                if($header['parentHeader'] == "Action"){
+                if ($header['parentHeader'] == "Action") {
                     $actionHeader[] = $header;
-                }else{
+                } else {
                     $staticHeaders[] = $header;
                 }
             }
         }
-    
+
         // dd($staticHeaders, $proposalHeaders, $sortedProposalOrder);
-        
+
         // Step 2: Reorder headers
         $reorderedHeaders = [];
         foreach ($sortedProposalOrder as $proposalKey => $proposalValue) {
@@ -6681,29 +6679,29 @@ class ClientController extends AdminController
             $value['parentHeader'] = 'Proposal ' . ($key + 1);
         }
         unset($value);
-        
+
 
         $reorderedHeaders = array_merge($staticHeaders, $reorderedHeaders, $actionHeader);
 
-    
+
         // Step 3: Reorder each row's `data` by matching parentth
         foreach ($dataRows as $dataRowIndex => &$row) {
             $staticData = [];
             $proposalData = [];
             $actionData = [];
-    
+
             foreach ($row['data'] as $entry) {
                 if (in_array($entry['parentth'], array_keys($sortedProposalOrder))) {
                     $proposalData[$entry['parentth']][] = $entry;
                 } else {
-                    if($entry['parentth'] == "Action"){
+                    if ($entry['parentth'] == "Action") {
                         $actionData[] = $entry;
-                    }else{
+                    } else {
                         $staticData[] = $entry;
                     }
                 }
             }
-    
+
             $reorderedProposalData = [];
             foreach ($sortedProposalOrder as $proposalKey => $proposalValue) {
                 if (isset($proposalData[$proposalKey])) {
@@ -6717,19 +6715,19 @@ class ClientController extends AdminController
             $increament = 0;
             foreach ($reorderedProposalData as $key => &$value) {
 
-                if($dubParTh == $value['parentth']){
+                if ($dubParTh == $value['parentth']) {
                     $value['parentth'] = 'Proposal ' . ($increament);
-                }else{
+                } else {
                     $dubParTh = $value['parentth'];
                     $increament = $increament + 1;
                     $value['parentth'] = 'Proposal ' . ($increament);
                 }
             }
             unset($value);
-    
+
             $row['data'] = array_merge($staticData, $reorderedProposalData, $actionData);
         }
-    
+
         $data['table_data']['headers'] = $reorderedHeaders;
         $data['table_data']['data'] = $dataRows;
 
@@ -6738,15 +6736,15 @@ class ClientController extends AdminController
         $updatedDataSet = $this->renumberProposalKeys($data['premium_data']['data']);
         $data['proposal_data']['over_all_column_data'] =  !empty($renumberedArray) ? $renumberedArray : $data['proposal_data']['over_all_column_data'];
         $data['premium_data']['data'] = !empty($updatedDataSet) ? $updatedDataSet : $data['premium_data']['data'];
-        
+
         return $data;
     }
-     
-    private function renumberProposalKeys(array $input): array 
+
+    private function renumberProposalKeys(array $input): array
     {
         $result = [];
         $counter = 1;
-    
+
         foreach ($input as $key => $value) {
             if (strpos($key, 'Proposal') === 0) {
                 $newKey = 'Proposal ' . $counter++;
@@ -6755,7 +6753,7 @@ class ClientController extends AdminController
                 $result[$key] = $value;
             }
         }
-    
+
         return $result;
     }
 
@@ -6764,20 +6762,18 @@ class ClientController extends AdminController
 
         $receivedData = $this->request->getPost();
 
-        if (!empty($receivedData['id'])){
+        if (!empty($receivedData['id'])) {
             $status = $this->clientApi->save($receivedData);
-
-        }else{
+        } else {
             $status = $this->clientApi->insert($receivedData);
         }
 
 
-        if ($status){
-            return $this->respond(['status'=>"Sucesss",'message'=>"Submitted Successfully"],200);
-        }else{
-            return $this->respond(['status'=>"Failed",'message'=>"Submission Faild"],500);
+        if ($status) {
+            return $this->respond(['status' => "Sucesss", 'message' => "Submitted Successfully"], 200);
+        } else {
+            return $this->respond(['status' => "Failed", 'message' => "Submission Faild"], 500);
         }
-
     }
 
     public function sendToken()
@@ -6787,17 +6783,17 @@ class ClientController extends AdminController
 
         $token = ClientTokenHelper::generateKey($client_id);
 
-        if ($token){
-            return $this->respond(['status' => 'success', 'token' => $token,'message' => "Token Generated Successfully"],200);
-        }else{
-            return $this->respond(['status' => "Failed","message"=>"Token Generation Failed, Try Again After some time"],500);
+        if ($token) {
+            return $this->respond(['status' => 'success', 'token' => $token, 'message' => "Token Generated Successfully"], 200);
+        } else {
+            return $this->respond(['status' => "Failed", "message" => "Token Generation Failed, Try Again After some time"], 500);
         }
     }
-    
+
     // ---------------- HR ACCESS CONTROL -----------------------------------------------------------------------------------
 
     public function viewHrAccessData()
-    {   
+    {
         $client_id = $this->request->getGet('client_id');
         $data = $this->getHrAccessData($client_id);
         // $data = [];
@@ -6817,7 +6813,8 @@ class ClientController extends AdminController
         $post_client_data = $this->clientModel->where('id', $client_id)->where('is_active', 1)->first();
 
         $hrAccessData['post_hr_data'] = $this->clientBranchModel
-            ->select('lc.id as post_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail')
+            ->select('lc.id as post_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail , 
+            client_branch.id as post_branch_id , client_branch.branch_name as post_branch_name')
             ->join('level_contacts lc', 'client_branch.id = lc.ref_id')
             ->where('client_branch.is_active', 1)
             ->where('lc.is_active', 1)
@@ -6826,7 +6823,7 @@ class ClientController extends AdminController
             ->findAll();
 
         $hrAccessData['post_policy_data'] = $this->clientPolicyModel
-            ->select('client_policy.id as client_policy_id, client_policy.policy_no as policy_no, policy_type.policy_type, client_policy.policy_status')
+            ->select('client_policy.id as client_policy_id, client_policy.policy_no as policy_no, policy_type.policy_type, client_policy.policy_status , client_policy.client_branch_id as branch_id')
             ->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
             ->where('client_policy.is_active', 1)
             ->where('client_policy.client_id', $client_id)
@@ -6855,22 +6852,23 @@ class ClientController extends AdminController
 
             $hrAccessData['pre_hr_data'] = [];
             $hrAccessData['pre_policy_data'] = [];
-            $combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id);
+            $combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id , $pre_client_data['id']??'');
             return $combinedHrAccessData;
         }
 
         $pre_client_data = $db2->table('clients')->where('is_active', 1)->where('short_name', $post_client_data['short_name'])->get()->getRowArray();
 
-        if(empty($pre_client_data)){
+        if (empty($pre_client_data)) {
 
             $hrAccessData['pre_hr_data'] = [];
             $hrAccessData['pre_policy_data'] = [];
-            $combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id);
+            $combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id , $pre_client_data['id']??'');
             return $combinedHrAccessData;
         }
 
         $hrAccessData['pre_hr_data'] = $db2->table('client_branch')
-            ->select('lc.id as pre_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail')
+            ->select('lc.id as pre_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail 
+            , client_branch.id as pre_branch_id , client_branch.branch_name as pre_branch_name ' )
             ->join('level_contacts lc', 'client_branch.id = lc.ref_id')
             ->where('client_branch.is_active', 1)
             ->where('lc.is_active', 1)
@@ -6878,9 +6876,9 @@ class ClientController extends AdminController
             ->where('client_branch.client_id', $pre_client_data['id'])
             ->get()
             ->getResultArray();
-
+        
         $hrAccessData['pre_policy_data'] = $db2->table('client_policy')
-            ->select('client_policy.id as client_policy_id, client_policy.policy_no as policy_no, policy_type.policy_type, client_policy.policy_status')
+            ->select('client_policy.id as client_policy_id, client_policy.policy_no as policy_no, policy_type.policy_type, client_policy.policy_status , client_policy.client_branch_id as branch_id')
             ->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
             ->where('client_policy.is_active', 1)
             ->where('client_policy.client_id',  $pre_client_data['id'])
@@ -6888,16 +6886,16 @@ class ClientController extends AdminController
             ->orderBy('client_policy.policy_status', 'desc')
             ->get()
             ->getResultArray();
-
         // dd($hrAccessData);
 
-        $combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id);
+        $combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id ,$pre_client_data['id']);
         return $combinedHrAccessData;
     }
 
-    public function constructHrAccessData($data, $client_id)
-    {   
-        // dd($data);
+    public function constructHrAccessData($data, $client_id , $pre_client_id)
+    {
+        // print_rr($data);die;
+
         $preHrs = $data['pre_hr_data'];
         $postHrs = $data['post_hr_data'];
         $hrAccessTableData = $data['hr_access_table_data'];
@@ -6913,7 +6911,10 @@ class ClientController extends AdminController
                         'post_hr_id' => $post['post_hr_id'],
                         'hr_name' => $post['hr_name'],
                         'hr_mobile' => $post['hr_mobile'],
-                        'hr_mail' => $post['hr_mail']
+                        'hr_mail' => $post['hr_mail'],
+                        'pre_branch_id' => $pre['pre_branch_id'] ?? null,
+                        'post_branch_id'   => $post['post_branch_id'] ?? null,
+                        'post_branch_name' => $post['post_branch_name'] ?? null 
                     ];
                     unset($preHrs[$index]); // remove matched pre_hr
                     $found = true;
@@ -6927,7 +6928,10 @@ class ClientController extends AdminController
                     'post_hr_id' => $post['post_hr_id'],
                     'hr_name' => $post['hr_name'],
                     'hr_mobile' => $post['hr_mobile'],
-                    'hr_mail' => $post['hr_mail']
+                    'hr_mail' => $post['hr_mail'],
+                    'pre_branch_id' => $pre['pre_branch_id'] ?? null,
+                    'post_branch_id' => $post['post_branch_id'] ?? null ,
+                    'post_branch_name' => $post['post_branch_name'] ?? null
                 ];
             }
         }
@@ -6939,7 +6943,10 @@ class ClientController extends AdminController
                 'post_hr_id' => null,
                 'hr_name' => $pre['hr_name'],
                 'hr_mobile' => $pre['hr_mobile'],
-                'hr_mail' => $pre['hr_mail']
+                'hr_mail' => $pre['hr_mail'],
+                'pre_branch_id' => $pre['pre_branch_id'] ?? null,
+                'post_branch_id' => $post['post_branch_id'] ?? null ,
+                'post_branch_name' => $post['post_branch_name'] ?? null
             ];
         }
 
@@ -6964,81 +6971,90 @@ class ClientController extends AdminController
                     'hr_name' => $hr['hr_name'] ?? null,
                     'hr_mobile' => $hr['hr_mobile'] ?? null,
                     'hr_mail' => $hr['hr_mail'] ?? null,
+                    'pre_branch_id' => $hr['pre_branch_id'] ?? null,
+                    'post_branch_id' => $hr['post_branch_id'] ?? null ,
+                    'post_branch_name' => $hr['post_branch_name'] ?? null ,
+                    'pre_client_id'    => $pre_client_id ?? null
                 ];
             }
-
         } else {
-                    // First create a map of HR data by post_hr_id for quick lookup
-                    $hrMap = [];
-                    foreach ($merged as $hr) {
-                        $hrMap[$hr['post_hr_id']] = $hr;
-                    }
-                    
-                    // Process access data first
-                    foreach ($hrAccessTableData as $access) {
-                        $post_hr_id = $access['post_hr_id'];
-                        
-                        // Check if this HR exists in our merged data
-                        if (isset($hrMap[$post_hr_id])) {
-                            $hr = $hrMap[$post_hr_id];
-                            $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
-                            
-                            // Parse allowed modules
-                            $allowed_modules = json_decode($access['allowed_modules'], true) ?? null;
-                            $allowed_pre_modules = $allowed_modules['pre'] ?? [];
-                            $allowed_post_modules = $allowed_modules['post'] ?? [];
-                            
-                            $result[$temp_arr_key] = [
-                                'hr_access_table_pk' => $access['id'] ?? null,
-                                'post_client_id' => $access['post_client_id'] ?? null,
-                                'pre_hr_id' => $hr['pre_hr_id'] ?? null,
-                                'post_hr_id' => $hr['post_hr_id'] ?? null,
-                                'allowed_pre_modules' => $allowed_pre_modules,
-                                'allowed_post_modules' => $allowed_post_modules,
-                                'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [],
-                                'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [],
-                                'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [],
-                                'hr_name' => $hr['hr_name'],
-                                'hr_mobile' => $hr['hr_mobile'],
-                                'hr_mail' => $hr['hr_mail']
-                            ];
-                            
-                            // Remove from map so we know it's been processed
-                            unset($hrMap[$post_hr_id]);
-                        }
-                    }
-                    
-                    // Now process any remaining HRs that didn't have access records
-                    foreach ($hrMap as $hr) {
-                        $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
-                        
-                        $result[$temp_arr_key] = [
-                            'hr_access_table_pk' => null,
-                            'post_client_id' => $client_id ?? null,
-                            'pre_hr_id' => $hr['pre_hr_id'] ?? null,
-                            'post_hr_id' => $hr['post_hr_id'] ?? null,
-                            'allowed_pre_modules' => [],
-                            'allowed_post_modules' => [],
-                            'allowed_pre_policies' => [],
-                            'allowed_active_policies' => [],
-                            'allowed_cd' => [],
-                            'hr_name' => $hr['hr_name'] ?? null,
-                            'hr_mobile' => $hr['hr_mobile'] ?? null,
-                            'hr_mail' => $hr['hr_mail'] ?? null,
-                        ];
-                    }
-        }
-        
+            // First create a map of HR data by post_hr_id for quick lookup
+            $hrMap = [];
+            foreach ($merged as $hr) {
+                $hrMap[$hr['post_hr_id']] = $hr;
+            }
 
-        $resultData['hr_access_data'] = array_values($result);
-        $resultData['pre_policy_data'] = $data['pre_policy_data'];
+            // Process access data first
+            foreach ($hrAccessTableData as $access) {
+                $post_hr_id = $access['post_hr_id'];
+
+                // Check if this HR exists in our merged data
+                if (isset($hrMap[$post_hr_id])) {
+                    $hr = $hrMap[$post_hr_id];
+                    $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
+
+                    // Parse allowed modules
+                    $allowed_modules = json_decode($access['allowed_modules'], true) ?? null;
+                    $allowed_pre_modules = $allowed_modules['pre'] ?? [];
+                    $allowed_post_modules = $allowed_modules['post'] ?? [];
+
+                    $result[$temp_arr_key] = [
+                        'hr_access_table_pk' => $access['id'] ?? null,
+                        'post_client_id' => $access['post_client_id'] ?? null,
+                        'pre_hr_id' => $hr['pre_hr_id'] ?? null,
+                        'post_hr_id' => $hr['post_hr_id'] ?? null,
+                        'allowed_pre_modules' => $allowed_pre_modules,
+                        'allowed_post_modules' => $allowed_post_modules,
+                        'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [],
+                        'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [],
+                        'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [],
+                        'hr_name' => $hr['hr_name'],
+                        'hr_mobile' => $hr['hr_mobile'],
+                        'hr_mail' => $hr['hr_mail'],
+                        'pre_branch_id' => $hr['pre_branch_id'] ?? null,
+                        'post_branch_id' => $hr['post_branch_id'] ?? null ,
+                        'post_branch_name' => $hr['post_branch_name'] ?? null ,
+                        'pre_client_id'    => $pre_client_id ?? null
+                    ];
+
+                    // Remove from map so we know it's been processed
+                    unset($hrMap[$post_hr_id]);
+                }
+            }
+
+            // Now process any remaining HRs that didn't have access records
+            foreach ($hrMap as $hr) {
+                $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
+
+                $result[$temp_arr_key] = [
+                    'hr_access_table_pk' => null,
+                    'post_client_id' => $client_id ?? null,
+                    'pre_hr_id' => $hr['pre_hr_id'] ?? null,
+                    'post_hr_id' => $hr['post_hr_id'] ?? null,
+                    'allowed_pre_modules' => [],
+                    'allowed_post_modules' => [],
+                    'allowed_pre_policies' => [],
+                    'allowed_active_policies' => [],
+                    'allowed_cd' => [],
+                    'hr_name' => $hr['hr_name'] ?? null,
+                    'hr_mobile' => $hr['hr_mobile'] ?? null,
+                    'hr_mail' => $hr['hr_mail'] ?? null,
+                    'pre_branch_id' => $hr['pre_branch_id'] ?? null,
+                    'post_branch_id' => $hr['post_branch_id'] ?? null ,
+                    'post_branch_name' => $hr['post_branch_name'] ?? null ,
+                    'pre_client_id'    => $pre_client_id ?? null
+                ];
+            }
+        }
+
+
+        $resultData['hr_access_data']   = array_values($result);
+        $resultData['pre_policy_data']  = $data['pre_policy_data'];
         $resultData['post_policy_data'] = $data['post_policy_data'];
-        $resultData['post_cd_data'] = $data['post_cd_data'];
-        // echo '**********************************************';
-        // print_rr($resultData);die();
+        $resultData['post_cd_data']     = $data['post_cd_data'];
 
         return $resultData;
-    }
+    }       
 
     public function saveHrAccessData()
     {
@@ -7078,6 +7094,10 @@ class ClientController extends AdminController
 
                     // INSERT or UPDATE
                     if (empty($value['pk']) || (int)$value['pk'] === 0) {
+                        print_rr("inside insert block");
+                        print_rr($value);die;
+
+
                         unset($value['pk']); // Prevent insert error
                         $insertedId = $this->HRAccessControlModel->insert($value);
                         if ($insertedId === false) {
@@ -7086,6 +7106,9 @@ class ClientController extends AdminController
                         $success[] = "Inserted row at index {$index} with ID {$insertedId}.";
                     } else {
                         $update = $this->HRAccessControlModel->update($value['pk'], $value);
+                        print_rr("inside update block");
+                        print_rr($value);die;
+
                         if ($update === false) {
                             throw new \Exception('Update failed for ID ' . $value['pk'] . ': ' . json_encode($this->HRAccessControlModel->errors()));
                         }
@@ -7119,7 +7142,6 @@ class ClientController extends AdminController
                     'details' => $success,
                     'data' => $html,
                 ], 200);
-
             } else {
                 return $this->respond([
                     'status' => false,
@@ -7457,6 +7479,84 @@ class ClientController extends AdminController
 
         return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200);
     }
+
+    private function getClientlistFromPre (){
+        $db2 = \Config\Database::connect('preDB');
+
+        $auto_fetch_client_list = $db2->table('clients')
+        ->select('id,client_name')
+        ->where('is_active',1)
+        ->get()->getResultArray()??[];
+
+        return $auto_fetch_client_list;
+
+    }
+
+    public function auto_fetch_branch(){
+
+        $data = $this->request->getPost();
+
+        $db2 = \Config\Database::connect('preDB');
+
+        $auto_fetch_branch_list = $db2->table('client_branch')
+        ->select('id,branch_name')
+        ->where('client_id',$data['client_id'])
+        ->where('is_active',1)
+        ->get()->getResultArray()??[];
+
+        return 
+
+        empty($auto_fetch_branch_list)
+
+        ? $this->response->setJSON([
+                'status' => false,
+                'message' => 'branch list is empty',
+                'data' => []
+            ])->setStatusCode(400)
+        
+        :   $this->response->setJSON([
+                'status' => true,
+                'message' => 'branch list is found' ,
+                 'data' => $auto_fetch_branch_list
+            ])->setStatusCode(200);
+    }
+
+    public function auto_fetch_branch_details(){
+
+        $data = $this->request->getPost();
+
+        $db2 = \Config\Database::connect('preDB');
+
+        $auto_fetch_branch_details = $db2->table('client_branch')
+                                        ->where('client_id',$data['client_id'])
+                                        ->where('id',$data['branch_id'])
+                                        ->where('is_active',1)
+                                        ->get()->getResultArray()??[];
+
+        return empty($auto_fetch_branch_details)
+
+                    ? $this->response->setJSON([
+                            'status' => false,
+                            'message' => 'branch details is empty',
+                            'data' => []
+                        ])->setStatusCode(400)
+                    
+                    :   $this->response->setJSON([
+                            'status' => true,
+                            'message' => 'branch details found' ,
+                            'data' => $auto_fetch_branch_details
+                        ])->setStatusCode(200);
+
+    }
+
+
+
+
+
+
+
+
+
+
+
 }
-
-
diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php
index b9ed11a4..73c2e31a 100755
--- a/app/Controllers/DashboardController.php
+++ b/app/Controllers/DashboardController.php
@@ -259,7 +259,7 @@ class DashboardController extends AdminController
 
         // dd(get_role_id(),user_team());
         // dd($data);
-        
+        $data['tab_name'] = 'Dashboard';
         $data['page_name'] = 'Dashboard';
 
         echo view('layout/header',  $data);
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 3751da86..a4666518 100755
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -135,6 +135,9 @@ class EmployeeController extends AdminController
 
         // dd($this->request->getGet());
         $this->myLogger->logme('error', 'list called');
+
+        $data['page_name'] = "Members";
+
         $this->loadLayout('employee_list', $data);
     }
 
@@ -307,6 +310,7 @@ class EmployeeController extends AdminController
             return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'file upload success'], 200);
         }
 
+        $data['tab_name'] = 'View Inception';
         $data['page_name'] = 'View Inception';
 
         //for TPA/insurer upload
@@ -786,6 +790,9 @@ class EmployeeController extends AdminController
         }
 
         $this->myLogger->logme('error', 'list called');
+        
+        $data['page_name'] = "Endorsement";
+
         $this->loadLayout('endorsement_list', $data);
     }
 
@@ -830,6 +837,9 @@ class EmployeeController extends AdminController
         // dd($data);
 
         $this->myLogger->logme('error', 'list called');
+
+        $data['page_name'] = "Enrollment";
+
         return $this->loadLayout('enrollment_list', $data);
     
      }
@@ -3039,6 +3049,8 @@ class EmployeeController extends AdminController
             // print_r($data); die;
         // }
 
+        $data['page_name'] = "Retail Endorsement";
+
         $this->loadLayout('retail_endorsement_list', $data);
     }
 
diff --git a/app/Controllers/ICICILombardController.php b/app/Controllers/ICICILombardController.php
index 8bf81189..928fbc2f 100644
--- a/app/Controllers/ICICILombardController.php
+++ b/app/Controllers/ICICILombardController.php
@@ -12,18 +12,18 @@ class ICICILombardController extends AdminController
     public function generateAuthToken($scope = 'esbhealth')
     {
         helper('api');
-        $url    = 'https://ilesbapigee.insurancearticlez.com/generate-jwt-token';
+        $url    = env('ICICI_TOKEN_URL');
         $method = 'POST';
         $headers = [
             'Content-Type: application/x-www-form-urlencoded'
         ];
         $body = [
-            'grant_type'  => 'password',
-            'username'   => 'Nhanceins',
-            'password' => 'SSWW7bFNaLxxQyw',
-            'scope' => $scope,
-            'client_id' => 'Nhanceins',
-            'client_secret' => 'P4W0G6TAYMa0MV8bbVSx4pTAqbCcUIg48kCWa6PJykAhGWzPmpPr0iLuNWtz5wqN'
+            'grant_type'  => env('ICICI_GRANT_TYPE'),
+            'username'   => env('ICICI_USER_NAME'),
+            'password' => env('ICICI_PASSWORD'),
+            'scope' => env('ICICI_API_SCOPE'),
+            'client_id' => env('ICICI_CLIENT_ID'),
+            'client_secret' => env('ICICI_CLIENT_SECRET')
         ];
 
         $response = call_third_party_api($url, $method, $headers, $body);
@@ -42,8 +42,6 @@ class ICICILombardController extends AdminController
 
     public function createEnrollmentBatch()
     {
-
-
         $client_id  = $this->request->getGet('client_id');
         $client_branch_id  = $this->request->getGet('client_branch_id');
         $policy_id  = $this->request->getGet('policy_id');
@@ -61,7 +59,7 @@ class ICICILombardController extends AdminController
         $token = $tokenResponse['data']['access_token'];
        
 
-        $url = 'https://ilesbapigee.insurancearticlez.com/health/ilservices/health/v1/enrollment/batchcreation';
+        $url = env('ICICI_BASE_URL').'/batchcreation';
         $headers = [
             'Authorization: Bearer ' . $token,
             'Content-Type: application/json',
@@ -71,7 +69,7 @@ class ICICILombardController extends AdminController
         //Prepare body data
         $db = \Config\Database::connect();
         $data = $db->table('employee_polices ep')
-                    ->select('cp.policy_no as policyNumber,
+                    ->select('cp.policy_no as policyNumber, cp.cd_ac_no as CDBGAccountNumber,
                             e.id,e.emp_code as MemberEmpId, e.doj as DOJ, e.name as InsuredName, e.dob as DOB, e.relationship as Relationship,
                             e.gender as Gender, ep.date_coverage as DOC,ep.basic_cover_si as SumInsured, e.email_corporate as EmailId
                             ')
@@ -85,7 +83,7 @@ class ICICILombardController extends AdminController
                     ->getResultArray();
     
         $body = $this->formatPolicyData($data);       
-        dd($body); 
+        // dd($body); 
 
         $response = call_third_party_api($url, 'POST', $headers, $body, true); // true = raw body mode
         //  print_rr(json_encode($response));die();
@@ -108,7 +106,7 @@ class ICICILombardController extends AdminController
         $token = $tokenResponse['data']['access_token'];
 
 
-        $url = 'https://ilesbapigee.insurancearticlez.com/health/ilservices/health/v1/enrollment/batchstatus';
+        $url = env('ICICI_BASE_URL').'/batchstatus';
         $headers = [
             'Authorization: Bearer ' . $token,
             'Content-Type: application/json'
@@ -144,7 +142,7 @@ class ICICILombardController extends AdminController
 
         // print_rr($token);
 
-        $url = 'https://ilesbapigee.insurancearticlez.com/health/ilservices/health/v1/enrollment/fetchuhid';
+        $url = env('ICICI_BASE_URL').'/fetchuhid';
         $headers = [
             'Authorization: Bearer ' . $token,
             'Content-Type: application/json'
@@ -161,7 +159,6 @@ class ICICILombardController extends AdminController
         return $this->response->setJSON($response);
     }
 
-
     public function formatPolicyData($data)
     {
         // Helper to format date
@@ -203,7 +200,7 @@ class ICICILombardController extends AdminController
         // Final body
         return [
             "PolicyNumber"      => $data[0]['policyNumber'] ?? null,
-            "CDBGAccountNumber" => "CD-MUM-0026",
+            "CDBGAccountNumber" => $data[0]['CDBGAccountNumber'] ?? null , // "CD-MUM-0026",
             "CorrelationId"     => $generateUUID(),
             "MemberDetails"     => $memberDetails
         ];
diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php
index 7465ad7a..308e7184 100644
--- a/app/Controllers/LeadsController.php
+++ b/app/Controllers/LeadsController.php
@@ -142,6 +142,7 @@ class LeadsController extends BaseController
 
     public function viewLeadsList()
     {
+        $data['tab_name'] = 'Leads';
         $data['page_name'] = 'Leads';
 
         // Set basic data
@@ -899,6 +900,7 @@ class LeadsController extends BaseController
             : null;
 
         $data['question_json'] = $lead_data['question_json'];
+        $data['tab_name'] = $type == 2 ? 'QCR' : 'RFQ';
         $data['page_name'] = $type == 2 ? 'QCR' : 'RFQ';
         $data['lead_data'] = $lead_data;
 
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index c26d6fb8..013a9324 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -107,7 +107,8 @@ class MasterController extends AdminController
     public function insurerList()
     {   
         $this->myLogger->logme('error','Insurer list function called');
-        $headerData['page_name'] = 'Insurer List';
+        $headerData['tab_name'] = 'Insurer List';
+        $headerData['page_name'] = 'Insurers';
         $data['insurerList'] = $this->insurerModel->where('is_active',1)->findAll();
         $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM();
         // echo '
';
@@ -154,7 +155,8 @@ class MasterController extends AdminController
     {
 
         $this->myLogger->logme('error','Edit Insurer Onboarding function called');
-        $headerData['page_name'] = 'Edit Insurer Master';
+        $headerData['tab_name'] = 'Edit Insurer Master';
+        $headerData['page_name'] = 'Insurers';
 
         $types = array(
             (object) array('id' => 'pvt', 'name' => 'PVT'),
@@ -245,7 +247,8 @@ class MasterController extends AdminController
     {
         
         $this->myLogger->logme('error','Insurer Onboarding function called');
-        $headerData['page_name'] = 'Insurer Master';
+        $headerData['tab_name'] = 'Insurer Master';
+        $headerData['page_name'] = 'Insurers';
 
         $types = array(
             (object) array('id' => 'pvt', 'name' => 'PVT'),
@@ -504,7 +507,8 @@ class MasterController extends AdminController
     public function tpaList()
     {   
         $this->myLogger->logme('error','TPA list function called');
-        $headerData['page_name'] = 'TPA List';
+        $headerData['tab_name'] = 'TPA List';
+        $headerData['page_name'] = 'TPA';
         $data['tpaList'] = $this->tpaModel->where('is_active',1)->findAll();
         // $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM();
         // echo '
';
@@ -550,7 +554,8 @@ class MasterController extends AdminController
     {
         
         $this->myLogger->logme('error','TPA Onboarding function called');
-        $headerData['page_name'] = 'TPA Master';
+        $headerData['tab_name'] = 'TPA Master';
+        $headerData['page_name'] = 'TPA';
 
 
         // print_r($data['types']);die();
@@ -664,7 +669,8 @@ class MasterController extends AdminController
     {
 
         $this->myLogger->logme('error','Edit TPA Onboarding function called');
-        $headerData['page_name'] = 'Edit TPA Master';
+        $headerData['tab_name'] = 'Edit TPA Master';
+        $headerData['page_name'] = 'TPA';
 
         $tpa_data = $this->tpaModel->where(['id' => $id, 'is_active' => 1])->first();
 
@@ -833,7 +839,8 @@ class MasterController extends AdminController
     public function kycList()
     {   
         $this->myLogger->logme('error','KYC list function called');
-        $headerData['page_name'] = 'KYC List';
+        $headerData['tab_name'] = 'KYC List';
+        $headerData['page_name'] = 'KYC';
         $data['kycList'] = $this->kycEntityTypeModel->where('is_active',1)->findAll();
         // $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM();
         // echo '
';
@@ -879,7 +886,8 @@ class MasterController extends AdminController
     {
         
         $this->myLogger->logme('error','KYC Onboarding function called');
-        $headerData['page_name'] = 'KYC Master';
+        $headerData['tab_name'] = 'KYC Master';
+        $headerData['page_name'] = 'KYC';
 
 
         // print_r($data['types']);die();
@@ -944,7 +952,8 @@ class MasterController extends AdminController
     {
 
         $this->myLogger->logme('error','Edit KYC Onboarding function called');
-        $headerData['page_name'] = 'Edit KYC Master';
+        $headerData['tab_name'] = 'Edit KYC Master';
+        $headerData['page_name'] = 'KYC';
 
         $editData['kyc']           = $this->kycEntityTypeModel->where(['id' => $id, 'is_active' => 1])->first();
         $editData['kyc_docs']    = $this->kycDocsModel->where(['kyc_type_id' => $id, 'is_active' => 1])->findAll();
@@ -1022,7 +1031,8 @@ class MasterController extends AdminController
     public function policyTypeList()
     {   
         $this->myLogger->logme('error','Policy Type list function called');
-        $headerData['page_name'] = 'Policy Type List';
+        $headerData['tab_name'] = 'Policy Type List';
+        $headerData['page_name'] = 'Policy Type';
         $data['policyList'] = $this->policyTypeModel->where('is_active',1)->findAll();
         // $data['insurer_rm'] = $this->insurerRMModel->getAllClientRM();
         // echo '
';
@@ -1068,7 +1078,8 @@ class MasterController extends AdminController
     {
         
         $this->myLogger->logme('error','Policy Type Onboarding function called');
-        $headerData['page_name'] = 'Policy Type Master';
+        $headerData['tab_name'] = 'Policy Type Master';
+        $headerData['page_name'] = 'Policy Type';
 
 
         // print_r($data['types']);die();
@@ -1130,7 +1141,8 @@ class MasterController extends AdminController
     {
 
         $this->myLogger->logme('error','Edit KYC Onboarding function called');
-        $headerData['page_name'] = 'Edit Policy Type';
+        $headerData['tab_name'] = 'Edit Policy Type';
+        $headerData['page_name'] = 'Policy Type';
 
         $editData['policytype']   = $this->policyTypeModel->where(['id' => $id, 'is_active' => 1])->first();
         $editData['policies']     = $this->policesModel->select('policies.*, insurers.name as insurer_name')
@@ -1222,7 +1234,8 @@ class MasterController extends AdminController
     //start CD Master list
     public function CDMasterList()
     {   
-        $data['page_name'] = 'CD Master List';
+        $data['tab_name'] = 'CD Master List';
+        $data['page_name'] = 'CD Master';
         $data['CD_Master_Data'] = $this->CDMasterModel->getCDMasterList();
         $data['insurers'] = $this->insurerModel->where('is_active', 1)->findAll();
         $data['insurer_branch'] = $this->insurerBranchModel->where('is_active', 1)->findAll();
@@ -1605,8 +1618,8 @@ class MasterController extends AdminController
     //Vehicle Master data Function
 
     public function VehicleMasterList()
-    {   
-        $data['page_name'] = 'Vehicle Master List';
+    {   $data['tab_name'] = 'Vehicle Master';
+        $data['page_name'] = 'Vehicles';
         $data['vehicle_type'] = [
             'two_wheeler' => 'Two Wheeler',
             'four_wheeler' => 'Four Wheeler',
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index 8e8a74e1..db8be45b 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -114,6 +114,7 @@ class PolicyTransactionController extends BaseController
     // Policy Transaction Inception
     public function viewInception()
     {
+        $data['tab_name'] = 'Policy';
         $data['page_name'] = 'Policy';
 
         // Static arrays for dropdowns
@@ -1075,6 +1076,7 @@ class PolicyTransactionController extends BaseController
         // echo '
';
         // !dd($this->getEndorsementDataForEdit(17));
 
+        $data['tab_name'] = 'Endorsement';
         $data['page_name'] = 'Endorsement';
         $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
         $data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll();
@@ -1771,7 +1773,7 @@ class PolicyTransactionController extends BaseController
     //get BDS Reports data old function
     public function reportBDSOld()
     {
-
+        $data['tab_name'] = 'BDS Report';
         $data['page_name'] = 'BDS Report';
 
         $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
@@ -1833,6 +1835,7 @@ class PolicyTransactionController extends BaseController
     public function reportBDS()
     {
 
+        $data['tab_name'] = 'BDS Report';
         $data['page_name'] = 'BDS Report';
 
         $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
@@ -1926,6 +1929,7 @@ class PolicyTransactionController extends BaseController
 
     public function reportVarience()
     {
+        $data['tab_name'] = 'Variance Report';
         $data['page_name'] = 'Variance Report';
 
         $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
@@ -1975,6 +1979,7 @@ class PolicyTransactionController extends BaseController
 
     public function reportBusinessList()
     {
+        $data['tab_name'] = 'Business Report';
         $data['page_name'] = 'Business Report';
 
         $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
@@ -2015,6 +2020,7 @@ class PolicyTransactionController extends BaseController
 
     public function reportFinanceList()
     {
+        $data['tab_name'] = 'Finance Report';
         $data['page_name'] = 'Finance Report';
 
         $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
@@ -2055,6 +2061,7 @@ class PolicyTransactionController extends BaseController
 
     public function reportOutstanding()
     {
+        $data['tab_name'] = 'Outstanding Report';
         $data['page_name'] = 'Outstanding Report';
 
         $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
@@ -2133,6 +2140,7 @@ class PolicyTransactionController extends BaseController
             ->findAll();
 
         // dd( $this->insurerStatements->getLastQuery());
+        $data['tab_name'] = 'Statement Upload';
         $data['page_name'] = 'Statement Upload';
 
         $this->loadLayout('insurer_statement_list',  $data);
@@ -2710,8 +2718,8 @@ class PolicyTransactionController extends BaseController
             $data['files'] = array_merge($pt_files, $kyc_files, $batch_files, $files);
             //  dd($data['files']);
         }
-
-        $data['page_name'] = 'Documents Search';
+        $data['tab_name'] = 'Documents Search';
+        $data['page_name'] = 'Documents';
 
         $data['customers'] = $this->clientModel->select('id,client_name,short_name as display_value')->where('is_active', 1)->get()->getResultarray();
         $data['policies'] = $this->clientPolicyModel->select("client_policy.id,client_policy.policy_no,policy_type.policy_type,concat(policy_type.policy_type,' - ',client_policy.policy_no) as display_value")
diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
index b2567d9c..f0265973 100755
--- a/app/Controllers/RestAuthenticationController.php
+++ b/app/Controllers/RestAuthenticationController.php
@@ -625,7 +625,7 @@ class RestAuthenticationController extends AdminController
 
     public function getVerifiedHrData()
     {
-        try {
+        // try {
             // mobile number 
             $otp_verification = isset($this->request->getJSON()->otp_verification) ? $this->request->getJSON()->otp_verification : null;
             $mobile_number = isset($this->request->getJSON()->mobile_no) ? $this->request->getJSON()->mobile_no : null;
@@ -656,27 +656,30 @@ class RestAuthenticationController extends AdminController
                     $this->authHistoryModel->insert($data);
                                         
                 }
-              
+
 
                 if(isset($this->request->getJSON()->mobile_no)){ 
 
-                    $hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id')
+                    $getAllhrData = $this->hrModel->select('level_contacts.mobile , level_contacts.email , clients.id as client_id, clients.client_name, clients.short_name , client_branch.id as client_branch_id,client_branch.branch_name')
                                             ->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left')
+                                            ->join('clients', 'client_branch.client_id = clients.id', 'left')
                                             ->where('level_contacts.mobile', $mobile_number )
                                             ->where('level_contacts.contact_type', 'client')
-                                            ->find();
+                                            ->findAll();
 
                 }else if(isset($this->request->getJSON()->otp)){ 
 
                     $this->hrModel->where('email', $email)->where('otp', $otp)->where('contact_type', 'client')->set(['otp'=>null])->update();
 
-                    $hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id')
+                    $getAllhrData = $this->hrModel->select('level_contacts.mobile , level_contacts.email , clients.id as client_id, clients.client_name, clients.short_name , client_branch.id as client_branch_id,client_branch.branch_name')
                                         ->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left')
+                                        ->join('clients', 'client_branch.client_id = clients.id', 'left')
                                         ->where('level_contacts.email', $email )
                                         ->where('level_contacts.contact_type', 'client')
-                                        ->find();
+                                        ->findAll();
                 }
 
+                print_rr($getAllhrData); die;
                 $HRAccessData = $this->getHRAccessData( $hrData['0']['id'] , 'post_enrollment');
 
                 if(isset($HRAccessData['allowed_modules'])){ $hrData['0']['allowed_modules'] =  json_decode($HRAccessData['allowed_modules'],true)['post']; }else{ $hrData['0']['allowed_modules'] = []; }
@@ -690,11 +693,11 @@ class RestAuthenticationController extends AdminController
 
             } else {
 
-                return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP" ],200);
+                return $this->respond(['status' => 'failed','code' => 404,'data' => "" ],200);
             }
-        } catch (\Exception $e) {
-            return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
-        }
+        // } catch (\Exception $e) {
+        //     return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
+        // }
     }
 
 
@@ -991,7 +994,7 @@ class RestAuthenticationController extends AdminController
     //             // $result = $employeeData;
     //             return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
     //         } else {
-    //             return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
+    //             return $this->respond(['status' => 'failed','code' => 404,'data' => ""],200);
     //         }
     //     } catch (\Exception $e) {
     //         return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
@@ -1016,7 +1019,7 @@ class RestAuthenticationController extends AdminController
             // print_r($mpin);
 
             if (!$mpin) {
-                return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'MPIN is required'], 400);
+                return $this->respond(['status' => 'failed', 'code' => 400, 'data'   => "", 'message' => 'MPIN is required'], 400);
             }
 
             if ($mobile_number) {
@@ -1057,7 +1060,7 @@ class RestAuthenticationController extends AdminController
                 $employeeData = $builder->orderBy('employees.id', 'desc')->first();
 
             } else {
-                return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'Mobile number or Email ID is required'], 400);
+                return $this->respond(['status' => 'failed', 'code' => 400, 'data'   => "", 'message' => 'Mobile number or Email ID is required'], 400);
             }
 
             $lastQuery = $this->employeeModel->db->getLastQuery();
@@ -1095,14 +1098,14 @@ class RestAuthenticationController extends AdminController
                 log_message('error', ' ************************************* POST END **************************************** ');
                 log_message('error', '  ');
 
-                return $this->respond(['status' => 'failed','code'   => 404,'data'   => 'Invalid MPIN'], 200);
+                return $this->respond(['status' => 'failed','code'   => 404, 'data'   => "", 'message'   => 'Invalid MPIN'], 200);
             }
         } catch (\Exception $e) {
             $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyMpin: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() .  " --- Trace: " . $e->getTraceAsString());
             log_message('error', '  ');
             log_message('error', ' ************************************* POST END **************************************** ');
             log_message('error', '  ');
-            return $this->respond(['status' => 'failed','code'   => 500, 'data'   => $e->getMessage()], 500);
+            return $this->respond(['status' => 'failed','code'   => 500, 'data'   => "", 'message'  => $e->getMessage()], 500);
         }
     }
 
diff --git a/app/Controllers/TestingController.php b/app/Controllers/TestingController.php
index cb432d24..87310adc 100644
--- a/app/Controllers/TestingController.php
+++ b/app/Controllers/TestingController.php
@@ -5,6 +5,7 @@ namespace App\Controllers;
 use App\Controllers\BaseController;
 use App\Models\EmployeePolicyModel;
 use App\Models\InsurerBranchModel;
+use App\Models\RFQModel;
 use CodeIgniter\HTTP\ResponseInterface;
 use CodeIgniter\API\ResponseTrait;
 use Dompdf\Dompdf;
@@ -313,4 +314,36 @@ class TestingController extends BaseController
         return $html;
     }
 
+    public function viewRFQNonEb()
+    {   
+        $insurerBranchModel = new InsurerBranchModel();
+        $data['page_name'] = "RFQ NON EB";
+        $data['insurer'] = $insurerBranchModel->getInsurerBranchesWithInsurerNames();
+        // dd($data);
+        return $this->loadLayout('view_rfq_non_eb_new', $data);
+    }
+
+    public function saverfq(){
+        $json = $this->request->getPost('json');
+        $json = json_encode($json);
+        print_r($json);
+
+        // $data['lead_id'] = 10000;
+        // $data['json'] = $json;
+        // $rfq = new RFQModel();
+
+        // $rfq->insert($data);
+    }
+
+    public function exportExcel()
+    {
+        $rfq = new RFQModel();
+        $policy_data = $rfq->where('lead_id', 10000)->first();
+        // print_rr($policy_data['json']); die;
+        $policy_data = json_decode($policy_data['json'], true);
+        $policy_data = array_slice($policy_data, 0, -2);
+        print_rr($policy_data); die;
+        dd($policy_data); 
+    }
+
 }
diff --git a/app/Controllers/ThzController.php b/app/Controllers/ThzController.php
index 0f8125b3..b0c893da 100644
--- a/app/Controllers/ThzController.php
+++ b/app/Controllers/ThzController.php
@@ -1,655 +1,654 @@
-thzMasterModel           = new ThzMasterModel();
-        $this->thzMasterNotesModel      = new ThzMasterNotesModel();
-        $this->thzTypeModel             = new thzTypeModel();
-        $this->thzHistoryModel          = new ThzHistoryModel();
-        $this->thzControllerCleaner     = new ThzControllerCleaner();
-        $this->userModel                = new UserModel();
-        $this->clientPolicyModel        = new ClientPolicyModel();
-        $this->clientModel              = new ClientModel();
-        $this->cientRmModel             = new ClientRMModel();
-        $this->ticketMailTemplateModel  = new TicketMailTemplateModel();
-        $this->myLogger                 = \Config\Services::mylogger();
-    }
-
-    public function index()
-    {
-        //
-    }
-
-    public function ticketSave()
-    {
-        try {
-            $data = $this->request->getPost();
-            $references   = "";
-            if (!empty($data['thz_id'])) {
-
-                $text   = "update";
-                // here insert history Status. 
-                $old = $this->thzMasterModel->where('thz_id', $data['thz_id'])->get()->getRowArray();
-                $result = $this->updateTicket($data);
-
-                $references = ($old && isset($data['status'])) ? $this->handleTicketHistory($old, $data) : "No Details" ;
-
-                $updateID = $data['thz_id'];
-            } else {
-
-                $text   = "create";
-                $insertID = $this->insertTicket($data);
-                $result = true;
-                $references   = "";
-            }
-
-            $id = isset($insertID) && !empty($insertID) ? $insertID : $updateID;
-
-            $emailNotificationResult = $this->ticketSaveNotification($data, $insertOrUpdate = $text, $id);
-
-            $this->myLogger->logme('error', 'emailNotificationResult: ' . json_encode($emailNotificationResult));
-
-            return $this->response->setJSON([
-                'status' => $result ? 'success' : 'error',
-                'message' => $result ? "Ticket {$text}d successfully " : "Unable to {$text} ticket. Please try again.",
-                'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed..!!',
-                'ref' => $references
-            ])->setStatusCode($result ? 200 : 400);
-
-
-        } catch (\Throwable $e) {
-            return handle_exception($e, $this->myLogger, $this->response);
-        }
-    }
-
-    public function ticketList()
-    {
-
-        $data['tab_name'] = "Tickets";
-        $data['page_name'] = "Tickets";
-        try {
-            $returnType = strtolower($this->request->getGet('return_type') ?? 'api');
-
-
-            $data = $this->request->getGet();
-
-            if ($returnType === 'web' && in_array(get_role_id(), [3, 4])) {
-                $data['assign_to'] = $data['assign_to'] ?? get_session_userid();
-            }
-
-
-            $tickets = $this->fetchTicketsBasedOnrole($data);
-
-
-            if ($returnType === 'api') {
-                if (empty($tickets)) {
-                    //  return $this->response->setJSON([ 'status'  => 'error','message' => 'No tickets found'])->setStatusCode(404);
-                    $this->myLogger->logme('error', 'empty tickets in ticket list: ' . json_encode($tickets));
-                    throw new \RuntimeException('No tickets found', 400);
-                }
-            } else {
-                $data['ticket_data'] = $tickets;
-                $data['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['3', '4'])->findAll();
-                // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu  , 2-"manager l2 " - ivangalum  assign pannalam
-                // 3,4 remain person varannum. 
-                $data['client_list'] = $this->clientModel->getCreatedByUserName();
-                $data['ticket_type'] = $this->thzTypeModel->where('is_active', 1)->findAll();
-
-                return $this->loadLayout('thz_list', $data);
-            }
-
-
-            return $this->response->setJSON([
-                'status' => 'success',
-                'data'   => $tickets,
-            ])->setStatusCode(200);
-        } catch (\Throwable $e) {
-            return handle_exception($e, $this->myLogger, $this->response);
-        }
-    }
-
-    public function ticketConversationSave()
-    {
-
-        try {
-            $data = $this->request->getPost();
-
-            $data['notes_type'] = $data['notes_type'] ?? 'External';
-
-            $result = $this->thzMasterNotesModel->insert($data);
-
-            if (empty($result)) {
-                $this->myLogger->logme('error', 'Ticket conversation insert failed..!!: ' . json_encode($result));
-                throw new \RuntimeException('No tickets found', 404);
-            }
-
-            $emailNotificationResult = ($data['notes_type'] === "External") 
-                ? $this->ticketConversationSaveNotification($data) 
-                : false;
-
-            return $this->response->setJSON([
-                'status' => $result ? 'success' : 'error',
-                'message' => $result ? "Ticket Notes created successfully" : "Unable to create ticket notes. Please try again.",
-                'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed Or No Need..!!'
-            ])->setStatusCode($result ? 200 : 400);
-
-
-        } catch (\Throwable $e) {
-            return handle_exception($e, $this->myLogger, $this->response);
-        }
-    }
-
-    public function ticketAutoFetchDetails()
-    {
-        try {
-            $data = $this->request->getPost();
-
-            $client_id = $data['client_id'] ?? null;
-            $mobile    = $data['mobile'] ?? null;
-
-            if ($client_id && $mobile) {
-                $details = $this->thzMasterModel->ticketAutoFetchDetails($client_id, $mobile);
-
-                if (empty($details)) {
-                    $this->myLogger->logme('error', 'empty AutoFetchDetails for client_id : ' . json_encode($client_id));
-                    throw new \RuntimeException('No Data found', 400);
-                }
-
-                $policyIds    = array_filter(array_column($details, 'policy_id'));
-                $clientPolicy = !empty($policyIds)
-                    ? $this->clientPolicyModel->whereIn('id', $policyIds)->where('is_active', 1)->get()->getResultArray()
-                    : [];
-
-                $result['client_details'] = $details;
-                $result['policy_details'] = $clientPolicy ?? [];
-            } else {
-                throw new \RuntimeException('Client and Mobile Not found', 400);
-            }
-
-            return $this->response->setJSON(['status' => 'success', 'data' => $result])->setStatusCode(200);
-        } catch (\Throwable $e) {
-            return handle_exception($e, $this->myLogger, $this->response);
-        }
-    }
-
-    public function ticketConversationList()
-    {
-        $data       = $this->request->getGet();
-
-        $returnType = strtolower($this->request->getGet('return_type') ?? 'api');
-
-        $thz_id     = $data['thz_id'] ?? null;
-
-        $ticketType = $data['notes_type'] ?? 'External';
-
-        if ($thz_id) {
-            $result['master'] = $this->thzMasterModel
-                ->select('thz_master.*, user_profiles.first_name  as assignee_name')
-                ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
-                ->where('thz_master.thz_id', $thz_id)
-                ->findAll();
-
-            if (!empty($result['master'])) {
-                $notes = $this->thzMasterNotesModel->ticketConversationList($thz_id, $returnType);
-                $result['notes'] = !empty($notes) ? $notes : [];
-            } else {
-                $this->myLogger->logme('error', 'No tickets found for ticket id ' . json_encode($thz_id));
-                throw new \RuntimeException('No tickets found', 400);
-            }
-        } else {
-            // return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404);
-            throw new \RuntimeException('No tickets found', 404);
-        }
-
-        if ($returnType === 'api') {
-            try {
-                return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200);
-            } catch (\Throwable $e) {
-                return handle_exception($e, $this->myLogger, $this->response);
-            }
-        } else {
-
-            $assign_to = $result['master'][0]['assign_to'];
-            $mobile    = $result['master'][0]['mobile'];
-
-            $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.*, user_profiles.first_name  as assignee_name')
-                ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
-                ->where('thz_master.assign_to', $assign_to)
-                ->where('thz_master.mobile', $mobile)
-                ->where('thz_master.thz_id !=', $thz_id)
-                ->where('thz_master.status !=', 'Closed')
-                ->where('thz_master.status !=', 'Resolved')
-                ->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) : '';
-
-            $result['ticket_type']  = $this->thzTypeModel->where('is_active', 1)->findAll();
-
-            return $this->loadLayout('thz_notes', $result);
-        }
-    }
-
-    public function ticketType()
-    {
-        $method = $this->request->getMethod(); // get, post
-        try {
-            if ($method === 'get') {
-                $types = $this->thzTypeModel->select('id,name,is_active')->where('is_active', 1)->findAll();
-                if (empty($types)) {
-                    $this->myLogger->logme('error', 'No ticket types found ');
-                    return $this->response->setJSON(['status'  => 'error', 'message' => 'No ticket types found'])->setStatusCode(404);
-                }
-                return $this->response->setJSON(['status' => 'success', 'data'   => $types])->setStatusCode(200);
-            }
-
-            if ($method === 'post') {
-
-                $data = $this->request->getPost();
-                if (!empty($data['id'])) {
-                    $text   = "update";
-                    $result = $this->thzTypeModel->update($data['id'], $data);
-                    $updateID = $data['id'];
-                } else {
-                    $text   = "create";
-                    $insertID  = $this->thzTypeModel->insert($data);
-                    $result = true;
-                }
-
-                $id = isset($insertID) && !empty($insertID) ? $insertID : ($updateID ?? null);
-
-                return $this->response->setJSON([
-                    'status'  => $id ? 'success' : 'error',
-                    'message' => $id ? "Ticket Type {$text}d successfully" : "Unable to {$text} ticket type. Please try again.",
-                    'id'      => $id
-                ])->setStatusCode($id ? 200 : 400);
-            }
-            return $this->response->setJSON(['status'  => 'error', 'message' => 'Invalid request method'])->setStatusCode(405);
-        } catch (\Throwable $e) {
-            return handle_exception($e, $this->myLogger, $this->response);
-        }
-    }
-
-    public function ticketHistoryList()
-    {
-        try {
-            $data = $this->request->getGet();
-            $thz_id = $data['thz_id'];
-            // $details = $this->thzHistoryModal->whereIn('thz_id', $thz_id)->where('is_active', 1)->get()->getResultArray();
-            $details = $this->thzHistoryModel->select('thz_history.*, user_profiles.first_name  as created_name')
-                ->join('user_profiles', 'user_profiles.id = thz_history.created_by', 'left')
-                ->where('thz_history.thz_id', $thz_id)->where('thz_history.is_active', 1)
-                ->orderBy('thz_history.created_at', 'desc')
-                ->get()->getResultArray();
-
-
-
-            if (empty($details)) {
-                $this->myLogger->logme('error', 'No history details found for ticket id  ' . json_encode($thz_id));
-                throw new \RuntimeException('No History found', 404);
-            }
-
-
-            return $this->response->setJSON(['status' => 'success', 'data'   => $details])->setStatusCode(200);
-        } catch (\Throwable $e) {
-            return handle_exception($e, $this->myLogger, $this->response);
-        }
-    }
-
-
-    /**************************************************   PRIVATE FUNCTIONS  ********************************************************/
-
-
-    private function fetchTicketsBasedOnrole(array $data): array
-    {
-        // $id        = $data['thz_id']    ?? null;
-        $assign_to = $data['assign_to'] ?? null;
-        $mobile    = $data['mobile']    ?? null;
-
-        if (!empty($assign_to)) {
-            // Tickets assigned to a staff
-            return $this->thzMasterModel
-                ->select('thz_master.*, user_profiles.first_name as assignee_name')
-                ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
-                ->where('thz_master.assign_to', $assign_to)
-                ->orderBy('thz_master.created_at', 'desc')
-                ->findAll();
-        }
-
-        // if (!empty($id) && !empty($mobile)) {
-        if (!empty($mobile)) {
-            // Specific ticket by ID and mobile
-            return $this->thzMasterModel
-                ->select('thz_master.*, user_profiles.first_name as assignee_name')
-                ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
-                // ->where('thz_id', $id)
-                ->where('thz_master.mobile', $mobile)
-                ->orderBy('thz_master.created_at', 'desc')
-                ->findAll();
-        }
-
-        // All tickets (e.g., for managers)
-        return $this->thzMasterModel
-            ->select('thz_master.*, user_profiles.first_name as assignee_name')
-            ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
-            ->orderBy('thz_master.created_at', 'desc')
-            ->findAll();
-    }
-
-
-
-    private function ticketSaveNotification($data, $insertOrUpdate, $id)
-    {
-
-        $user_email  = $data['email'] ?? null;
-
-        $assignee_id = $data['assign_to'] ?? null;
-
-        $assignee_email = $this->findAssigneeEmail($assignee_id);
-
-        $client_id     = $data['client_id'] ?? null;
-
-        $emailToNotified = [
-            'user_email' => $user_email,
-            'assignee_email' => $assignee_email
-        ];
-
-        $ticketId = $id;
-
-        $result = $this->ticketSaveEmailNotificationBasedOnRole($emailToNotified, $insertOrUpdate, $ticketId, $data, $client_id);
-
-        return $result;
-    }
-
-    private function ticketConversationSaveNotification($data)
-    {
-
-        $thz_id = $data['thz_id']; // thz is alias of ticket
-
-        $data['subject'] = $this->findSubject($data['thz_id']);
-
-        $assignee_id    = $this->findAssigneeId($data['thz_id']);
-
-        $user_email     =  $this->findUserEmail($data['thz_id']);
-
-        $assignee_email = $this->findAssigneeEmail($assignee_id) ?? '';
-
-        $sender_mail     =  $data['notes_by'] == "User" ? $user_email        : $assignee_email;
-        $receiver_mail   =  $data['notes_by'] == "User" ? $assignee_email    : $user_email;
-
-        $templateName   = "ticket_conversation_save_notification";
-
-        $to_email       = $receiver_mail;
-
-        $ticketId       = $thz_id;
-
-        //        $message        = $data['notes'] ?? '';
-
-        $this->sendEmail($templateName, $data, $to_email, $ticketId);
-
-        return true;
-    }
-
-
-    private function findAssigneeEmail($assignee_id)
-    {
-
-        $row = $this->userModel->where('id', $assignee_id)->get()->getRow();
-        $assigneeEmail = $row ? $row->email : null;
-        return $assigneeEmail ? $assigneeEmail : "";
-    }
-
-    private function findAssigneeId($ticketId)
-    {
-        $row = $this->thzMasterModel->where('thz_id', $ticketId)->get()->getRow();
-        $assigneeId = $row ? $row->assign_to : null;
-        return $assigneeId ? $assigneeId : 0;
-    }
-
-    private function findUserEmail($ticket_id)
-    {
-        $row = $this->thzMasterModel->where('thz_id', $ticket_id)->get()->getRow();
-        $email = $row ? $row->email : null;
-        return $email ? $email : " ";
-    }
-
-    private function findSubject($ticketId)
-    {
-        $row = $this->thzMasterModel->where('thz_id', $ticketId)->get()->getRow();
-        $subject = $row ? $row->subject : null;
-        return $subject ? $subject : " ";
-    }
-
-    private function ticketSaveEmailNotificationBasedOnRole($emailToNotified,  $insertOrUpdate, $ticketId, $data, $client_id)
-    {
-
-        $user_email     = $emailToNotified['user_email'] ?? null;
-        $assignee_email = $emailToNotified['assignee_email'] ?? null;
-
-
-        if (!empty($assignee_email)) {
-
-            switch ($insertOrUpdate) {
-
-                case 'update':
-
-                    $this->sendEmail('ticket_save_update_assignee', $data, $assignee_email, $ticketId);
-
-                    break;
-
-                case 'create':
-
-                    $this->sendEmail('ticket_save_create_assignee', $data, $assignee_email, $ticketId);
-
-                    break;
-
-                default:
-                    # code...
-                    break;
-            }
-        }
-
-        if (!empty($user_email)) {
-
-            switch ($insertOrUpdate) {
-
-                case 'update':
-
-                    $data['assigneeAndStatus'] = empty($assignee_email)
-                        ? "Not Yet Assigned"
-                        : "Assigned With {$assignee_email}";
-
-                    $this->sendEmail('ticket_save_update_user', $data, $user_email, $ticketId);
-
-
-                    break;
-
-                case 'create':
-
-                    $account_manager_email = $this->cientRmModel->findAccountManagerEmail($client_id);
-
-                    $cc = getenv('G_ticketing_system_cc');
-
-                    $this->myLogger->logme('error',  "env for cc G_ticketing_system_cc " . $cc);
-
-                    $template = empty($assignee_email)
-                        ? 'ticket_save_create_user_unassigned'
-                        : 'ticket_save_create_user_assigned';
-
-                    if (!empty($assignee_email)) {
-                        $data['assignee_email'] = $assignee_email;
-                    }
-
-                    $this->sendEmail($template, $data, $user_email, $ticketId);
-
-                    // send to account manager and if it is more than one email also no problem we send to all account managers
-                    if (!empty($account_manager_email)) {
-                        $this->myLogger->logme('error',  "mail sent for account manager " . json_encode($account_manager_email));
-                        $this->sendEmail($template, $data, $account_manager_email, $ticketId, $cc);
-                    } else {
-                        $this->myLogger->logme('error',  "mail not  sent for account manager ");
-                    }
-
-                    break;
-
-                default:
-                    # code...
-                    break;
-            }
-        }
-
-        return true;
-    }
-
-    private function updateTicket($data)
-    {
-
-        $data['updated_by'] = get_session_userid();
-        $ticket_id = $data['thz_id'];
-        $result = $this->thzMasterModel->where('thz_id', $ticket_id)->set($data)->update();
-
-        return $result;
-    }
-
-    private function insertTicket($data)
-    {
-        $data['created_by'] = get_session_userid();
-        $this->thzMasterModel->insert($data);
-
-        return $this->thzMasterModel->insertID(); // returns the inserted row's ID
-    }
-
-
-    private function sendEmail($templateName, $data, $to_email, $ticketId, $cc = "", $bcc = "")
-    {
-
-        $mailTemplate    =  $this->ticketMailTemplateModel->where('template_name', $templateName)->findAll()[0] ?? [];
-
-        if (empty($mailTemplate)) {
-            $this->myLogger->logme('error', 'No Mail Template Found To send email in ticketing system');
-            return;
-        }
-
-        if (empty($cc)) {
-            $this->myLogger->logme('error', 'empty cc attached for  template name : ' . json_encode($templateName));
-        } else {
-            $this->myLogger->logme('error',  "cc attached for  template name : " . json_encode($templateName));
-        }
-
-        $mailTemplate['subject'] = str_replace('%subject%', $data['subject'] ?? '', $mailTemplate['subject']);
-
-        $mailTemplate['mail_content'] = str_replace('%subject%', $data['subject'] ?? '', $mailTemplate['mail_content']);
-
-        $mailTemplate['mail_content'] = str_replace('%ticketId%', $ticketId ?? '', $mailTemplate['mail_content']);
-
-        $mailTemplate['mail_content'] = str_replace('%message%', $data['notes'] ?? '', $mailTemplate['mail_content']);
-
-        $mailTemplate['mail_content'] = str_replace('%assignee_email%', $data['assignee_email'] ?? '', $mailTemplate['mail_content']);
-
-        $mailTemplate['mail_content'] = str_replace('%assigneeAndStatus%', $data['assigneeAndStatus'] ?? '', $mailTemplate['mail_content']);
-
-        $from_mail      =  "";
-        $to_mail        =  $to_email;
-        $cc_string      =  $cc;
-        $subject        =  $mailTemplate['subject'];
-        $message        =  $mailTemplate['mail_content'];
-        $attachments    =  "";
-        $reply_to       =  "";
-        $bcc_string     =  $bcc;
-
-        $res = MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $to_mail, 'cc' => $cc_string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]);
-
-        $this->myLogger->logme('error', 'Mail Response : ' . json_encode($res));
-    }
-
-
-    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);
-    }
-
-
-    private function handleTicketHistory(array $old, array $data): string
-    {
-        if ($old['status'] != $data['status']) {
-            $history = [
-                'thz_id'       => $data['thz_id'],
-                'field_name'   => 'status',
-                'display_name' => 'Status',
-                'old_value'    => $old['status'],
-                'new_value'    => $data['status'],
-                'is_active'    => 1
-            ];
-
-            if (!empty(get_session_userid())) {
-                $history['created_by'] = get_session_userid();
-            }
-
-            $hist_id = $this->thzHistoryModel->insert($history);
-
-            return $old['status'] . " - " . $data['status'] . " - " . $hist_id;
-        }
-
-        return $old['status'] . " - " . $data['status'];
-    }
-
-
-
-
-
-}
+thzMasterModel           = new ThzMasterModel();
+        $this->thzMasterNotesModel      = new ThzMasterNotesModel();
+        $this->thzTypeModel             = new thzTypeModel();
+        $this->thzHistoryModel          = new ThzHistoryModel();
+        $this->thzControllerCleaner     = new ThzControllerCleaner();
+        $this->userModel                = new UserModel();
+        $this->clientPolicyModel        = new ClientPolicyModel();
+        $this->clientModel              = new ClientModel();
+        $this->cientRmModel             = new ClientRMModel();
+        $this->ticketMailTemplateModel  = new TicketMailTemplateModel();
+        $this->myLogger                 = \Config\Services::mylogger();
+    }
+
+    public function index()
+    {
+        //
+    }
+
+    public function ticketSave()
+    {
+        try {
+            $data = $this->request->getPost();
+            $references   = "";
+            if (!empty($data['thz_id'])) {
+
+                $text   = "update";
+                // here insert history Status. 
+                $old = $this->thzMasterModel->where('thz_id', $data['thz_id'])->get()->getRowArray();
+                $result = $this->updateTicket($data);
+
+                $references = ($old && isset($data['status'])) ? $this->handleTicketHistory($old, $data) : "No Details" ;
+
+                $updateID = $data['thz_id'];
+            } else {
+
+                $text   = "create";
+                $insertID = $this->insertTicket($data);
+                $result = true;
+                $references   = "";
+            }
+
+            $id = isset($insertID) && !empty($insertID) ? $insertID : $updateID;
+
+            $emailNotificationResult = $this->ticketSaveNotification($data, $insertOrUpdate = $text, $id);
+
+            $this->myLogger->logme('error', 'emailNotificationResult: ' . json_encode($emailNotificationResult));
+
+            return $this->response->setJSON([
+                'status' => $result ? 'success' : 'error',
+                'message' => $result ? "Ticket {$text}d successfully " : "Unable to {$text} ticket. Please try again.",
+                'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed..!!',
+                'ref' => $references
+            ])->setStatusCode($result ? 200 : 400);
+
+
+        } catch (\Throwable $e) {
+            return handle_exception($e, $this->myLogger, $this->response);
+        }
+    }
+
+    public function ticketList()
+    {
+
+        $data['tab_name'] = "Tickets";
+        $data['page_name'] = "Tickets";
+        try {
+            $returnType = strtolower($this->request->getGet('return_type') ?? 'api');
+
+
+            $data = $this->request->getGet();
+
+            if ($returnType === 'web' && in_array(get_role_id(), [3, 4])) {
+                $data['assign_to'] = $data['assign_to'] ?? get_session_userid();
+            }
+
+
+            $tickets = $this->fetchTicketsBasedOnrole($data);
+
+
+            if ($returnType === 'api') {
+                if (empty($tickets)) {
+                    $this->myLogger->logme('error', 'empty tickets in ticket list: ' . json_encode($tickets));
+                    return $this->response->setJSON([ 'status'  => 'error','message' => 'No tickets found'])->setStatusCode(404);
+                }
+            } else {
+                $data['ticket_data'] = $tickets;
+                $data['assignee'] = $this->userModel->where('is_active', 1)->whereIn('role', ['3', '4'])->findAll();
+                // enga 5-"head" and 1-"admin" assign pannvaga so dropdown la varakudhathu  , 2-"manager l2 " - ivangalum  assign pannalam
+                // 3,4 remain person varannum. 
+                $data['client_list'] = $this->clientModel->getCreatedByUserName();
+                $data['ticket_type'] = $this->thzTypeModel->where('is_active', 1)->findAll();
+
+                return $this->loadLayout('thz_list', $data);
+            }
+
+
+            return $this->response->setJSON([
+                'status' => 'success',
+                'data'   => $tickets,
+            ])->setStatusCode(200);
+        } catch (\Throwable $e) {
+            return handle_exception($e, $this->myLogger, $this->response);
+        }
+    }
+
+    public function ticketConversationSave()
+    {
+
+        try {
+            $data = $this->request->getPost();
+
+            $data['notes_type'] = $data['notes_type'] ?? 'External';
+
+            $result = $this->thzMasterNotesModel->insert($data);
+
+            if (empty($result)) {
+                $this->myLogger->logme('error', 'Ticket conversation insert failed..!!: ' . json_encode($result));
+                throw new \RuntimeException('No tickets found', 404);
+            }
+
+            $emailNotificationResult = ($data['notes_type'] === "External") 
+                ? $this->ticketConversationSaveNotification($data) 
+                : false;
+
+            return $this->response->setJSON([
+                'status' => $result ? 'success' : 'error',
+                'message' => $result ? "Ticket Notes created successfully" : "Unable to create ticket notes. Please try again.",
+                'notification' => $emailNotificationResult ? 'Email Notification Success..!!' : 'Email Notification Failed Or No Need..!!'
+            ])->setStatusCode($result ? 200 : 400);
+
+
+        } catch (\Throwable $e) {
+            return handle_exception($e, $this->myLogger, $this->response);
+        }
+    }
+
+    public function ticketAutoFetchDetails()
+    {
+        try {
+            $data = $this->request->getPost();
+
+            $client_id = $data['client_id'] ?? null;
+            $mobile    = $data['mobile'] ?? null;
+
+            if ($client_id && $mobile) {
+                $details = $this->thzMasterModel->ticketAutoFetchDetails($client_id, $mobile);
+
+                if (empty($details)) {
+                    $this->myLogger->logme('error', 'empty AutoFetchDetails for client_id : ' . json_encode($client_id));
+                    throw new \RuntimeException('No Data found', 400);
+                }
+
+                $policyIds    = array_filter(array_column($details, 'policy_id'));
+                $clientPolicy = !empty($policyIds)
+                    ? $this->clientPolicyModel->whereIn('id', $policyIds)->where('is_active', 1)->get()->getResultArray()
+                    : [];
+
+                $result['client_details'] = $details;
+                $result['policy_details'] = $clientPolicy ?? [];
+            } else {
+                throw new \RuntimeException('Client and Mobile Not found', 400);
+            }
+
+            return $this->response->setJSON(['status' => 'success', 'data' => $result])->setStatusCode(200);
+        } catch (\Throwable $e) {
+            return handle_exception($e, $this->myLogger, $this->response);
+        }
+    }
+
+    public function ticketConversationList()
+    {
+        $data       = $this->request->getGet();
+
+        $returnType = strtolower($this->request->getGet('return_type') ?? 'api');
+
+        $thz_id     = $data['thz_id'] ?? null;
+
+        $ticketType = $data['notes_type'] ?? 'External';
+
+        if ($thz_id) {
+            $result['master'] = $this->thzMasterModel
+                ->select('thz_master.*, user_profiles.first_name  as assignee_name')
+                ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
+                ->where('thz_master.thz_id', $thz_id)
+                ->findAll();
+
+            if (!empty($result['master'])) {
+                $notes = $this->thzMasterNotesModel->ticketConversationList($thz_id, $returnType);
+                $result['notes'] = !empty($notes) ? $notes : [];
+            } else {
+                $this->myLogger->logme('error', 'No tickets found for ticket id ' . json_encode($thz_id));
+                throw new \RuntimeException('No tickets found', 400);
+            }
+        } else {
+            // return $this->response->setJSON((['status' => 'error', 'message' => 'No tickets found']))->setStatusCode(404);
+            throw new \RuntimeException('No tickets found', 404);
+        }
+
+        if ($returnType === 'api') {
+            try {
+                return $this->response->setJSON((['status' => 'success', 'data' => $result]))->setStatusCode(200);
+            } catch (\Throwable $e) {
+                return handle_exception($e, $this->myLogger, $this->response);
+            }
+        } else {
+
+            $assign_to = $result['master'][0]['assign_to'];
+            $mobile    = $result['master'][0]['mobile'];
+
+            $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.*, user_profiles.first_name  as assignee_name')
+                ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
+                ->where('thz_master.assign_to', $assign_to)
+                ->where('thz_master.mobile', $mobile)
+                ->where('thz_master.thz_id !=', $thz_id)
+                ->where('thz_master.status !=', 'Closed')
+                ->where('thz_master.status !=', 'Resolved')
+                ->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) : '';
+
+            $result['ticket_type']  = $this->thzTypeModel->where('is_active', 1)->findAll();
+
+            return $this->loadLayout('thz_notes', $result);
+        }
+    }
+
+    public function ticketType()
+    {
+        $method = $this->request->getMethod(); // get, post
+        try {
+            if ($method === 'get') {
+                $types = $this->thzTypeModel->select('id,name,is_active')->where('is_active', 1)->findAll();
+                if (empty($types)) {
+                    $this->myLogger->logme('error', 'No ticket types found ');
+                    return $this->response->setJSON(['status'  => 'error', 'message' => 'No ticket types found'])->setStatusCode(404);
+                }
+                return $this->response->setJSON(['status' => 'success', 'data'   => $types])->setStatusCode(200);
+            }
+
+            if ($method === 'post') {
+
+                $data = $this->request->getPost();
+                if (!empty($data['id'])) {
+                    $text   = "update";
+                    $result = $this->thzTypeModel->update($data['id'], $data);
+                    $updateID = $data['id'];
+                } else {
+                    $text   = "create";
+                    $insertID  = $this->thzTypeModel->insert($data);
+                    $result = true;
+                }
+
+                $id = isset($insertID) && !empty($insertID) ? $insertID : ($updateID ?? null);
+
+                return $this->response->setJSON([
+                    'status'  => $id ? 'success' : 'error',
+                    'message' => $id ? "Ticket Type {$text}d successfully" : "Unable to {$text} ticket type. Please try again.",
+                    'id'      => $id
+                ])->setStatusCode($id ? 200 : 400);
+            }
+            return $this->response->setJSON(['status'  => 'error', 'message' => 'Invalid request method'])->setStatusCode(405);
+        } catch (\Throwable $e) {
+            return handle_exception($e, $this->myLogger, $this->response);
+        }
+    }
+
+    public function ticketHistoryList()
+    {
+        try {
+            $data = $this->request->getGet();
+            $thz_id = $data['thz_id'];
+            // $details = $this->thzHistoryModal->whereIn('thz_id', $thz_id)->where('is_active', 1)->get()->getResultArray();
+            $details = $this->thzHistoryModel->select('thz_history.*, user_profiles.first_name  as created_name')
+                ->join('user_profiles', 'user_profiles.id = thz_history.created_by', 'left')
+                ->where('thz_history.thz_id', $thz_id)->where('thz_history.is_active', 1)
+                ->orderBy('thz_history.created_at', 'desc')
+                ->get()->getResultArray();
+
+
+
+            if (empty($details)) {
+                $this->myLogger->logme('error', 'No history details found for ticket id  ' . json_encode($thz_id));
+                throw new \RuntimeException('No History found', 404);
+            }
+
+
+            return $this->response->setJSON(['status' => 'success', 'data'   => $details])->setStatusCode(200);
+        } catch (\Throwable $e) {
+            return handle_exception($e, $this->myLogger, $this->response);
+        }
+    }
+
+
+    /**************************************************   PRIVATE FUNCTIONS  ********************************************************/
+
+
+    private function fetchTicketsBasedOnrole(array $data): array
+    {
+        // $id        = $data['thz_id']    ?? null;
+        $assign_to = $data['assign_to'] ?? null;
+        $mobile    = $data['mobile']    ?? null;
+
+        if (!empty($assign_to)) {
+            // Tickets assigned to a staff
+            return $this->thzMasterModel
+                ->select('thz_master.*, user_profiles.first_name as assignee_name')
+                ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
+                ->where('thz_master.assign_to', $assign_to)
+                ->orderBy('thz_master.created_at', 'desc')
+                ->findAll();
+        }
+
+        // if (!empty($id) && !empty($mobile)) {
+        if (!empty($mobile)) {
+            // Specific ticket by ID and mobile
+            return $this->thzMasterModel
+                ->select('thz_master.*, user_profiles.first_name as assignee_name')
+                ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
+                // ->where('thz_id', $id)
+                ->where('thz_master.mobile', $mobile)
+                ->orderBy('thz_master.created_at', 'desc')
+                ->findAll();
+        }
+
+        // All tickets (e.g., for managers)
+        return $this->thzMasterModel
+            ->select('thz_master.*, user_profiles.first_name as assignee_name')
+            ->join('user_profiles', 'user_profiles.id = thz_master.assign_to', 'left')
+            ->orderBy('thz_master.created_at', 'desc')
+            ->findAll();
+    }
+
+
+
+    private function ticketSaveNotification($data, $insertOrUpdate, $id)
+    {
+
+        $user_email  = $data['email'] ?? null;
+
+        $assignee_id = $data['assign_to'] ?? null;
+
+        $assignee_email = $this->findAssigneeEmail($assignee_id);
+
+        $client_id     = $data['client_id'] ?? null;
+
+        $emailToNotified = [
+            'user_email' => $user_email,
+            'assignee_email' => $assignee_email
+        ];
+
+        $ticketId = $id;
+
+        $result = $this->ticketSaveEmailNotificationBasedOnRole($emailToNotified, $insertOrUpdate, $ticketId, $data, $client_id);
+
+        return $result;
+    }
+
+    private function ticketConversationSaveNotification($data)
+    {
+
+        $thz_id = $data['thz_id']; // thz is alias of ticket
+
+        $data['subject'] = $this->findSubject($data['thz_id']);
+
+        $assignee_id    = $this->findAssigneeId($data['thz_id']);
+
+        $user_email     =  $this->findUserEmail($data['thz_id']);
+
+        $assignee_email = $this->findAssigneeEmail($assignee_id) ?? '';
+
+        $sender_mail     =  $data['notes_by'] == "User" ? $user_email        : $assignee_email;
+        $receiver_mail   =  $data['notes_by'] == "User" ? $assignee_email    : $user_email;
+
+        $templateName   = "ticket_conversation_save_notification";
+
+        $to_email       = $receiver_mail;
+
+        $ticketId       = $thz_id;
+
+        //        $message        = $data['notes'] ?? '';
+
+        $this->sendEmail($templateName, $data, $to_email, $ticketId);
+
+        return true;
+    }
+
+
+    private function findAssigneeEmail($assignee_id)
+    {
+
+        $row = $this->userModel->where('id', $assignee_id)->get()->getRow();
+        $assigneeEmail = $row ? $row->email : null;
+        return $assigneeEmail ? $assigneeEmail : "";
+    }
+
+    private function findAssigneeId($ticketId)
+    {
+        $row = $this->thzMasterModel->where('thz_id', $ticketId)->get()->getRow();
+        $assigneeId = $row ? $row->assign_to : null;
+        return $assigneeId ? $assigneeId : 0;
+    }
+
+    private function findUserEmail($ticket_id)
+    {
+        $row = $this->thzMasterModel->where('thz_id', $ticket_id)->get()->getRow();
+        $email = $row ? $row->email : null;
+        return $email ? $email : " ";
+    }
+
+    private function findSubject($ticketId)
+    {
+        $row = $this->thzMasterModel->where('thz_id', $ticketId)->get()->getRow();
+        $subject = $row ? $row->subject : null;
+        return $subject ? $subject : " ";
+    }
+
+    private function ticketSaveEmailNotificationBasedOnRole($emailToNotified,  $insertOrUpdate, $ticketId, $data, $client_id)
+    {
+
+        $user_email     = $emailToNotified['user_email'] ?? null;
+        $assignee_email = $emailToNotified['assignee_email'] ?? null;
+
+
+        if (!empty($assignee_email)) {
+
+            switch ($insertOrUpdate) {
+
+                case 'update':
+
+                    $this->sendEmail('ticket_save_update_assignee', $data, $assignee_email, $ticketId);
+
+                    break;
+
+                case 'create':
+
+                    $this->sendEmail('ticket_save_create_assignee', $data, $assignee_email, $ticketId);
+
+                    break;
+
+                default:
+                    # code...
+                    break;
+            }
+        }
+
+        if (!empty($user_email)) {
+
+            switch ($insertOrUpdate) {
+
+                case 'update':
+
+                    $data['assigneeAndStatus'] = empty($assignee_email)
+                        ? "Not Yet Assigned"
+                        : "Assigned With {$assignee_email}";
+
+                    $this->sendEmail('ticket_save_update_user', $data, $user_email, $ticketId);
+
+
+                    break;
+
+                case 'create':
+
+                    $account_manager_email = $this->cientRmModel->findAccountManagerEmail($client_id);
+
+                    $cc = getenv('G_ticketing_system_cc');
+
+                    $this->myLogger->logme('error',  "env for cc G_ticketing_system_cc " . $cc);
+
+                    $template = empty($assignee_email)
+                        ? 'ticket_save_create_user_unassigned'
+                        : 'ticket_save_create_user_assigned';
+
+                    if (!empty($assignee_email)) {
+                        $data['assignee_email'] = $assignee_email;
+                    }
+
+                    $this->sendEmail($template, $data, $user_email, $ticketId);
+
+                    // send to account manager and if it is more than one email also no problem we send to all account managers
+                    if (!empty($account_manager_email)) {
+                        $this->myLogger->logme('error',  "mail sent for account manager " . json_encode($account_manager_email));
+                        $this->sendEmail($template, $data, $account_manager_email, $ticketId, $cc);
+                    } else {
+                        $this->myLogger->logme('error',  "mail not  sent for account manager ");
+                    }
+
+                    break;
+
+                default:
+                    # code...
+                    break;
+            }
+        }
+
+        return true;
+    }
+
+    private function updateTicket($data)
+    {
+
+        $data['updated_by'] = get_session_userid();
+        $ticket_id = $data['thz_id'];
+        $result = $this->thzMasterModel->where('thz_id', $ticket_id)->set($data)->update();
+
+        return $result;
+    }
+
+    private function insertTicket($data)
+    {
+        $data['created_by'] = get_session_userid();
+        $this->thzMasterModel->insert($data);
+
+        return $this->thzMasterModel->insertID(); // returns the inserted row's ID
+    }
+
+
+    private function sendEmail($templateName, $data, $to_email, $ticketId, $cc = "", $bcc = "")
+    {
+
+        $mailTemplate    =  $this->ticketMailTemplateModel->where('template_name', $templateName)->findAll()[0] ?? [];
+
+        if (empty($mailTemplate)) {
+            $this->myLogger->logme('error', 'No Mail Template Found To send email in ticketing system');
+            return;
+        }
+
+        if (empty($cc)) {
+            $this->myLogger->logme('error', 'empty cc attached for  template name : ' . json_encode($templateName));
+        } else {
+            $this->myLogger->logme('error',  "cc attached for  template name : " . json_encode($templateName));
+        }
+
+        $mailTemplate['subject'] = str_replace('%subject%', $data['subject'] ?? '', $mailTemplate['subject']);
+
+        $mailTemplate['mail_content'] = str_replace('%subject%', $data['subject'] ?? '', $mailTemplate['mail_content']);
+
+        $mailTemplate['mail_content'] = str_replace('%ticketId%', $ticketId ?? '', $mailTemplate['mail_content']);
+
+        $mailTemplate['mail_content'] = str_replace('%message%', $data['notes'] ?? '', $mailTemplate['mail_content']);
+
+        $mailTemplate['mail_content'] = str_replace('%assignee_email%', $data['assignee_email'] ?? '', $mailTemplate['mail_content']);
+
+        $mailTemplate['mail_content'] = str_replace('%assigneeAndStatus%', $data['assigneeAndStatus'] ?? '', $mailTemplate['mail_content']);
+
+        $from_mail      =  "";
+        $to_mail        =  $to_email;
+        $cc_string      =  $cc;
+        $subject        =  $mailTemplate['subject'];
+        $message        =  $mailTemplate['mail_content'];
+        $attachments    =  "";
+        $reply_to       =  "";
+        $bcc_string     =  $bcc;
+
+        $res = MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $to_mail, 'cc' => $cc_string, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to, 'bcc' => $bcc_string]);
+
+        $this->myLogger->logme('error', 'Mail Response : ' . json_encode($res));
+    }
+
+
+    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);
+    }
+
+
+    private function handleTicketHistory(array $old, array $data): string
+    {
+        if ($old['status'] != $data['status']) {
+            $history = [
+                'thz_id'       => $data['thz_id'],
+                'field_name'   => 'status',
+                'display_name' => 'Status',
+                'old_value'    => $old['status'],
+                'new_value'    => $data['status'],
+                'is_active'    => 1
+            ];
+
+            if (!empty(get_session_userid())) {
+                $history['created_by'] = get_session_userid();
+            }
+
+            $hist_id = $this->thzHistoryModel->insert($history);
+
+            return $old['status'] . " - " . $data['status'] . " - " . $hist_id;
+        }
+
+        return $old['status'] . " - " . $data['status'];
+    }
+
+
+
+
+
+}
diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php
index 5d930c71..eb7e894b 100644
--- a/app/Controllers/TicketController.php
+++ b/app/Controllers/TicketController.php
@@ -362,6 +362,7 @@ class TicketController extends BaseController
         $data['modeOFIntimate'] = $this->modeOFIntimate;
         $data['priorityType'] = $this->priorityType;
         $data['claimType'] = $this->claimType;
+        $data['tab_name'] = "Claims";
         if ($this->request->is('get')) {
             $data['page_name'] = "Claims";
             $data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll();
@@ -1123,6 +1124,9 @@ class TicketController extends BaseController
         // dd($data['ticket_data']);
         $data['ticket_type']  = $this->ticketType;
         $data['trigger_type'] = $this->triggerType;
+
+        $data['page_name'] = "Claims";
+
         return $this->loadLayout('ticket_mail_template', $data);
     }
 
@@ -1744,6 +1748,8 @@ class TicketController extends BaseController
                 'tat_band_wise'          => 'TAT Wise Status Report'
             ];
             //
+            $data['tab_name'] = "Claim Reports";
+            $data['page_name'] = "Claims";
             $this->loadLayout('ticket_reports', $data);
         } else {
             $received_data = $this->request->getPost();
@@ -2187,6 +2193,8 @@ class TicketController extends BaseController
 
 
             $data['viewer'] = !empty($empView) ? $empView : 0; 
+
+           
             // dd($data);
             return view('ticket_feedback_form', $data);    
         }else{
@@ -2217,7 +2225,7 @@ class TicketController extends BaseController
     public function feedbackList(){
 
         $data['feedback_data'] = $this->ticketMasterModel->select("ticket_master.*,clients.client_name")->join("clients","clients.id = ticket_master.client_id")->where("ticket_master.is_active",1)->where("ticket_master.feedback_json IS NOT NULL", null, false)->where("ticket_master.feedback_json !=", "")->findAll();
-
+        $data['page_name'] = "Claims";
         // dd($data);
         $this->loadLayout("ticket_feedback_list",$data);
     }
@@ -2610,7 +2618,8 @@ class TicketController extends BaseController
 
     public function claimDumpUpload()
     {   
-        $data['page_name'] = "Claim Dupm Upload";
+        $data['tab_name'] = "Claim Dupm Upload";
+        $data['page_name'] = "Claims";
 
         if($this->request->is('get')){
 
diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php
index 255b6507..d393b71c 100755
--- a/app/Controllers/UserController.php
+++ b/app/Controllers/UserController.php
@@ -55,7 +55,8 @@ class UserController extends AdminController
 
     public function list()
     {   
-        $data['page_name'] = 'User';
+        $data['tab_name'] = 'Users';
+        $data['page_name'] = 'Users';
         $this->myLogger->logme('error','User list function called');
         $data['UserList'] = $this->userModel->getUserList();
         // echo '
';
@@ -588,6 +589,7 @@ class UserController extends AdminController
                 $data = $this->request->getPost();
                 if (!empty($data['id'])) {
                     $text   = "update";            
+                    $data['updated_by'] =  get_session_userid();
                     $result = $this->partnerStaffModel->update($data['id'], $data);
                     $updateID = $data['id'];
                 } else {
@@ -595,6 +597,11 @@ class UserController extends AdminController
                     $data['role_id'] = 1;
                     $data['created_by'] =  get_session_userid();
                     $insertID  = $this->partnerStaffModel->insert($data);
+                    if($insertID){
+                        $details['manager_id'] = $insertID;
+                        $details['updated_by'] =  get_session_userid();
+                        $this->partnerStaffModel->update($insertID, $details);
+                    }
                     $result = true;
                 }
 
diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php
index 54ffba09..b7418dbf 100644
--- a/app/Controllers/VidalApiController.php
+++ b/app/Controllers/VidalApiController.php
@@ -198,7 +198,7 @@ class VidalApiController extends BaseController
 
         helper('api');
 
-        $url    = ''. getenv('VIDAL_API_BASE_URL').'/enrollmendataservice';
+        $url    = getenv('VIDAL_API_BASE_URL').'/enrollmendataservice';
         $method = 'POST';
 
         $headers = [
diff --git a/app/Helpers/ExceptionHelper.php b/app/Helpers/exception_helper.php
similarity index 100%
rename from app/Helpers/ExceptionHelper.php
rename to app/Helpers/exception_helper.php
diff --git a/app/Models/ClientBranchModel.php b/app/Models/ClientBranchModel.php
index 100f503d..a813221a 100755
--- a/app/Models/ClientBranchModel.php
+++ b/app/Models/ClientBranchModel.php
@@ -25,6 +25,7 @@ class ClientBranchModel extends Model
         "gst",
         "sez",
         "units",
+        "pre_branch_id"
     ];
 
     public function getBranchAndContactByBranchId($branch_id){
diff --git a/app/Models/HRAccessControlModel.php b/app/Models/HRAccessControlModel.php
index a9a4e2c7..a754536d 100644
--- a/app/Models/HRAccessControlModel.php
+++ b/app/Models/HRAccessControlModel.php
@@ -13,6 +13,9 @@ class HRAccessControlModel extends Model
         'pre_hr_id',
         'post_hr_id',
         'post_client_id',
+        'pre_client_id',
+        'pre_branch_id',
+        'post_branch_id',
         'allowed_modules',
         'allowed_pre_policies',
         'allowed_active_policies',
diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php
index 67a354b1..005eacd2 100644
--- a/app/Models/LeadsModel.php
+++ b/app/Models/LeadsModel.php
@@ -105,6 +105,7 @@ class LeadsModel extends Model
         'next_reminder_date',
         'is_insurer_auto_mail',
         'quote_received_insurer',
+        'acm_id',
     ];
 
 
diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php
index 6acad55b..ba72d495 100755
--- a/app/Views/DashBoard.php
+++ b/app/Views/DashBoard.php
@@ -182,21 +182,20 @@
 
 
 
-

Dashboard

-
+
-
- +
- - - - - - - - - + + + + + + + + + @@ -45,7 +44,7 @@ ?> - + @@ -461,28 +460,57 @@ $('body').on('click', '.reload', function() { $(document).ready(function() { $('#tickets-table').DataTable({ - dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + + + dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" + + + + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", - "buttons": [{ - "extend": 'csv', - "text": 'CSV', - "title": 'Employee-Upload-List', - "className": 'my_class', - "exportOptions": { - "columns": ':not(:last-child)' + buttons: [{ + extend: 'collection', + text: ' Export ', + className: 'btn app-btn-secondary ', + buttons: [ + { + extend: 'csv', + text: ' CSV ', + title: 'Employee-Upload-List', + className: 'app-btn-primary ', + exportOptions: { + columns: ':not(:last-child)' + }, + } + ] + } + ], + language: { + search: ` +
+ _INPUT_ + +
`, + searchPlaceholder: "Search" }, - }], - "initComplete": function(settings, json) { - $('.my_class').css({ - "position": "relative", - "left": "79px" - }); - }, - language: { - search: "_INPUT_", - searchPlaceholder: "Search..." - }, + // "buttons": [{ + // "extend": 'csv', + // "text": 'CSV', + // "title": 'Employee-Upload-List', + // "className": 'my_class', + // "exportOptions": { + // "columns": ':not(:last-child)' + // }, + // }], + // "initComplete": function(settings, json) { + // $('.my_class').css({ + // "position": "relative", + // "left": "79px" + // }); + // }, + // language: { + // search: "_INPUT_", + // searchPlaceholder: "Search..." + // }, paging: true, }); diff --git a/app/Views/finance_team_list.php b/app/Views/finance_team_list.php index ffb991ea..0ec2aed9 100644 --- a/app/Views/finance_team_list.php +++ b/app/Views/finance_team_list.php @@ -1,59 +1,62 @@ -
-
+ +
+
-
+

+ Filter -

+
@@ -64,11 +67,11 @@ table.dataTable tbody td {
@@ -79,9 +82,9 @@ table.dataTable tbody td {
@@ -91,11 +94,11 @@ table.dataTable tbody td {
@@ -105,11 +108,11 @@ table.dataTable tbody td {
@@ -124,35 +127,34 @@ table.dataTable tbody td { onchange="hideDateField()"> $value) { - echo ""; - } + if (isset($date_type) && count($date_type)) { + foreach ($date_type as $key => $value) { + echo ""; } + } ?>
+ + + -

+

branch -

+

Mail -

@@ -128,6 +135,15 @@ $policies) { $statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active'; $statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive'; + if ( + in_array($policies['branch_id'].'-'.$policies['policy_no'], $listed_pre) + && + $value['pre_branch_id'] != $policies['branch_id'] + ) { + continue; + } else { + $listed_pre[] = $policies['branch_id'].'-'.$policies['policy_no']; + } ?>
$policies) { $statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active'; $statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive'; + if( + in_array($policies['branch_id'].'-'.$policies['policy_no'] , $listed_post) + && + $value['post_branch_id'] != $policies['branch_id'] + ) + { + continue; + } + else + { + $listed_post[] = $policies['branch_id'].'-'.$policies['policy_no']; + } + ?>
> +   
SNOFile nameClientClient BranchPolicyEventUser/TimeStatusActionS.No File name Client Client Branch Policy Event User/Time Status Action 
+
@@ -93,15 +97,16 @@ $(document).ready(function () { if (ticketsTable.length) { var table = ticketsTable.DataTable({ scrollX: true, - dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // search left, buttons right - "<'row'<'col-sm-12'tr>>" + - "<'row'<'col-sm-3'i><'col-sm-2'l><'col-sm-7'p>>", + + dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" + + "<'row'<'col-sm-12'tr>>" + + "<'row'<'col-sm-5'i><'col-sm-7'p>>", language: { search: "_INPUT_", searchPlaceholder: "Search..." }, paging: true, - pageLength: 25, + pageLength: 10, ordering: false, buttons: [ { @@ -120,6 +125,17 @@ $(document).ready(function () { ] }); + // run after DataTable is ready +$('.dataTables_filter input').css({ + 'background': '#F0F0F0', + 'border': 'none', + 'border-radius': '8px', + 'padding-right': '35px' +}).wrap('
') + .after(''); + + // Attach submit handler separately so it works $(document).on("click", "#submitBtn", function () { appendHrActivityHistoryHtml(this, true); diff --git a/app/Views/hr_file_upload.php b/app/Views/hr_file_upload.php index 936d603f..dd0c7b33 100644 --- a/app/Views/hr_file_upload.php +++ b/app/Views/hr_file_upload.php @@ -10,11 +10,26 @@
-
+ +

+ Filters -

+ + + +
@@ -103,15 +118,15 @@ id="hr_tickets_table">
- - - - - - - - - + + + + + + + + + @@ -341,27 +356,33 @@ // for datatable $(document).ready(function() { $('#hr_tickets_table').DataTable({ - dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + + dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", - "buttons": [{ - "extend": 'csv', - "text": 'CSV', - "title": 'Employee-Upload-List', - "className": 'my_class', - "exportOptions": { - "columns": ':not(:last-child)' - }, - }], - "initComplete": function(settings, json) { - $('.my_class').css({ - "position": "relative", - "left": "79px" - }); - }, + buttons: [{ + extend: 'collection', + text: ' Export ', + className: 'btn app-btn-secondary ', + buttons: [ + { + extend: 'csv', + text: ' CSV ', + title: 'Employee-Upload-List', + className: 'app-btn-primary ', + exportOptions: { + columns: ':not(:last-child)' + }, + } + ] + } + ], language: { - search: "_INPUT_", - searchPlaceholder: "Search..." + search: ` +
+ _INPUT_ + +
`, + searchPlaceholder: "Search" }, paging: true, }); diff --git a/app/Views/import_export.php b/app/Views/import_export.php index da473af6..276b51fd 100755 --- a/app/Views/import_export.php +++ b/app/Views/import_export.php @@ -10,19 +10,17 @@
-

Inception

-
- + +
@@ -107,7 +112,7 @@ function formatTextToCamelCase(str) { return str .replace(/_/g, ' ') // replace underscores with spaces - .toLowerCase() // convert everything to lowercase + .toLowerCase() // convert everything to lowercase .replace(/\b\w/g, char => char.toUpperCase()); // capitalize each word } \ No newline at end of file diff --git a/app/Views/insurer_export_templete.php b/app/Views/insurer_export_templete.php index 800d4e70..a92543a4 100755 --- a/app/Views/insurer_export_templete.php +++ b/app/Views/insurer_export_templete.php @@ -80,19 +80,19 @@
- - - - - - + + + + + + $value ){ ?> - + diff --git a/app/Views/insurer_list.php b/app/Views/insurer_list.php index 9b52aa41..59727f76 100755 --- a/app/Views/insurer_list.php +++ b/app/Views/insurer_list.php @@ -1,6 +1,5 @@ -
+ +
+
-
-
-
+
+
+ +
S. No
SNOFile nameClientClient BranchPolicyEventUser/TimeStatusActionS.No File name Client Client Branch Policy Event User/Time Status Action 
S.NOPolicy TypeEvent TypeUpload/DownloadTemplateActionS.NO Policy Type Event Type Upload/Download Template Action 
+ + + + + + + - - - - - - - - + + + + + + + + - -
NameTypeAction
( ) - -
( ) + +
-
+ +
+
+ + \ No newline at end of file diff --git a/app/Views/insurer_onboarding.php b/app/Views/insurer_onboarding.php index 2c290d15..2889ba13 100755 --- a/app/Views/insurer_onboarding.php +++ b/app/Views/insurer_onboarding.php @@ -20,34 +20,44 @@ Insurer -
@@ -60,17 +70,18 @@ - - + \ No newline at end of file diff --git a/app/Views/insurer_or_tpa_data.php b/app/Views/insurer_or_tpa_data.php index fc822a52..b4c615b3 100755 --- a/app/Views/insurer_or_tpa_data.php +++ b/app/Views/insurer_or_tpa_data.php @@ -10,11 +10,21 @@
-
+ +

+ Filters -

+ + + +
@@ -48,7 +58,7 @@
-
+

- + +
+
+
+
+
+ + +
-
-
- +
+ +
-
-
-
- - - - - - - - - - - - - - - +
+
+
+
Insurer
Month
Statement
sno
Filename
Line
items
File
status
Invoice
status
User/Time
Action
+ + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - + + + + - - - - - - - - - -
+
Insurer
+
+
Month
+
+
Statement
sno
+
+
Filename
+
+
Line
items
+
+
File
status
+
+
Invoice
status
+
+
User/Time
+
+
Action
+
"; - } - ?> -
"; + } + ?> + - - - - + + + + + + + + + by ' . $row['first_name'] ?> + + + +
'.$row['first_name'] ?> - - - -
+ + +
-
-
+
+
+ + + \ No newline at end of file diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 76ae987c..4ccac05a 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -141,6 +141,22 @@ font-size: 24px; } +/** newly implemented */ +#insurerTable thead th:first-child { + border-top: 0px solid #fff !important; + border-bottom: 0px solid #fff !important; + background-color: transparent !important; +} +#insurerTable tbody td { + border-top: 0px solid #fff !important; + border-bottom: 0px solid #fff !important; + background-color: transparent !important; +} +#insurerTable th{ + color: black !important; + background-color: transparent !important; +} +
@@ -184,15 +200,18 @@
-
+
-
-

Client Details - - - -

-
+ +
+
+
@@ -281,15 +300,15 @@
+
-
+
-
@@ -297,16 +316,18 @@
-
+
-
-

Pre Sales - - - -

-
- + +
+
+
+
-
+
-
+
+
+ +
+ -
+
@@ -4089,8 +4117,10 @@ // Update header $('#insurerTable thead tr').append(` + Insurer ${insurerCount} ${insurerCount > 1 ? `` : ''} + `); diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php index c3e72dcf..ef7ff681 100644 --- a/app/Views/policy_transaction_inception_list.php +++ b/app/Views/policy_transaction_inception_list.php @@ -146,15 +146,16 @@ table.dataTable tbody td {
-
+
-

- - - -

+

+ Filter + + + +

@@ -256,7 +257,11 @@ table.dataTable tbody td {
-
+ +
+
+ + @@ -309,21 +314,21 @@ table.dataTable tbody td { $row){ ?> - + - - + + - - - - - - - - - - + + + + + + + + + +