From 84752c66201353363056a0a2f5a97b564a772b9b Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 6 Dec 2025 12:24:29 +0530 Subject: [PATCH 1/7] CHANGE_BDS_REPOR_AND_DELETE_OPTION_ONLY_HEAD --- app/Models/PolicyTransactionModel.php | 14 +++++ .../policy_transaction_endorsement_list.php | 8 ++- .../policy_transaction_inception_list.php | 9 ++- .../policy_transaction_inception_list_2.php | 8 ++- app/Views/report_bds.php | 58 +++++++++++++++---- 5 files changed, 78 insertions(+), 19 deletions(-) diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index 1d752149..44a0550d 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -2477,6 +2477,12 @@ pt.id AS id, pt.endorsement_no, pt.ref, + + pt.data_received_date, + pt.renewal_date, + pt.installment, + nhance_branch.branch_name as nhance_branch, + DATE_FORMAT(pt.policy_issue_date, '%d %b %Y') AS policy_issue_date, DATE_FORMAT(pcsd.pt_policy_issue_date, '%b %Y') AS policy_issue_month, pt.month as statement_month, @@ -2559,6 +2565,7 @@ LEFT JOIN user_profiles su ON pt.sales_generated_by = su.id LEFT JOIN user_profiles se ON pt.serviced_by = se.id LEFT JOIN user_profiles created_user ON pt.created_by = created_user.id + LEFT JOIN nhance_branch ON pt.issuer_branch = nhance_branch.id WHERE pt.is_active = 1 AND pcsd.is_active = 1 @@ -2573,6 +2580,12 @@ pt.id AS id, pt.endorsement_no, pt.ref, + + pt.data_received_date, + pt.renewal_date, + pt.installment, + nhance_branch.branch_name as nhance_branch, + DATE_FORMAT(pt.policy_issue_date, '%d %b %Y') AS policy_issue_date, DATE_FORMAT(IF(insq.month IS NULL, pcsd.pt_policy_issue_date, insq.month),'%b %Y') AS policy_issue_month, insq.month as statement_month, @@ -2694,6 +2707,7 @@ LEFT JOIN user_profiles su ON pt.sales_generated_by = su.id LEFT JOIN user_profiles se ON pt.serviced_by = se.id LEFT JOIN user_profiles created_user ON pt.created_by = created_user.id + LEFT JOIN nhance_branch ON pt.issuer_branch = nhance_branch.id WHERE pt.is_active = 1 AND pcsd.is_active = 1 diff --git a/app/Views/policy_transaction_endorsement_list.php b/app/Views/policy_transaction_endorsement_list.php index 5d739144..1fbc415c 100644 --- a/app/Views/policy_transaction_endorsement_list.php +++ b/app/Views/policy_transaction_endorsement_list.php @@ -346,9 +346,11 @@ table.dataTable thead th { Edit - - Delete - + + + Delete + + diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php index ae82bc2c..82054906 100644 --- a/app/Views/policy_transaction_inception_list.php +++ b/app/Views/policy_transaction_inception_list.php @@ -337,9 +337,12 @@ table.dataTable tbody td { Edit - - Delete - + + + + Delete + + diff --git a/app/Views/policy_transaction_inception_list_2.php b/app/Views/policy_transaction_inception_list_2.php index c5aedf93..0096365d 100644 --- a/app/Views/policy_transaction_inception_list_2.php +++ b/app/Views/policy_transaction_inception_list_2.php @@ -337,9 +337,11 @@ table.dataTable tbody td { Edit - - Delete - + + + Delete + + diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php index fc51a5c8..db84e64e 100644 --- a/app/Views/report_bds.php +++ b/app/Views/report_bds.php @@ -109,13 +109,19 @@ table.dataTable tbody td { Agreed Amount Invoiced Amount Outstanding Amount + Salse Person + Service Person + Nhance Branch + Installment + Data Received Date + Renewal Date $row){ ?> - +   - + - + % @@ -186,6 +192,12 @@ table.dataTable tbody td { number_format((float)$row['unbilled_amount'],2, '.', ''); ?> + + + + + + @@ -546,6 +558,33 @@ $(document).ready(function() { // $('#total_billed').text(totalBilled.toFixed(2)); // $('#total_unbilled').text(totalUnbilled.toFixed(2)); + var getUniqueUnbilled = function(colIndex) { + + var rows = api.rows({ search: 'applied' }).nodes(); // get filtered nodes + var maxRowPerId = {}; // store only the greatest row + + $(rows).each(function() { + var rowId = $(this).data('id'); // read data-id + var rowIndex = $(this).index(); // row index + + // Keep only the greatest row index per data-id + if (!maxRowPerId[rowId] || rowIndex > maxRowPerId[rowId]) { + maxRowPerId[rowId] = rowIndex; + } + }); + + var total = 0; + + // Now sum only the selected rows + $.each(maxRowPerId, function(id, rowIndex) { + var value = api.cell(rowIndex, colIndex).data(); + value = parseFloat((typeof value === 'string') ? value.replace(/[^0-9.\-]+/g, '') : value) || 0; + total += value; + }); + + return total; + }; + // Helper to sum numeric values safely var getTotal = function(colIndex) { return api.column(colIndex, { search: 'applied' }).data() @@ -563,17 +602,16 @@ $(document).ready(function() { var totalRewards = getTotal(24); var totalIrda = getTotal(25); var totalBilled = getTotal(26); - var totalUnbilled = getTotal(27); + // var totalUnbilled = getTotal(27); // Update the totals section above the table $('#total_premium').text(totalPremium.toFixed(2)); $('#total_rewards').text(totalRewards.toFixed(2)); $('#total_irda').text(totalIrda.toFixed(2)); $('#total_billed').text(totalBilled.toFixed(2)); + // $('#total_unbilled').text(totalUnbilled.toFixed(2)); + var totalUnbilled = getUniqueUnbilled(27); $('#total_unbilled').text(totalUnbilled.toFixed(2)); - - - } }); } else { @@ -641,9 +679,9 @@ function appendTableData(data) { } $('table tbody').on('click', 'td', function () { - var index = $(this).index(); - console.log('Clicked TD index:', index); + var colIndex = $(this).index(); + var rowIndex = $(this).closest('tr').index(); + console.log('Row:', rowIndex, 'Column:', colIndex); }); - \ No newline at end of file From 1620ced65338d9f1afa1b12d44784a058438db86 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Sat, 6 Dec 2025 14:39:05 +0530 Subject: [PATCH 2/7] merge --- app/Controllers/VidalApiController.php | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php index 3dd1b69c..a2875028 100644 --- a/app/Controllers/VidalApiController.php +++ b/app/Controllers/VidalApiController.php @@ -118,7 +118,7 @@ class VidalApiController extends BaseController tm.hospital_name as hospitalName, tm.claim_amount as requestedAmount, cp.policy_no as policyNo, - e.id as dependentUniqueId, + e.id as dependentUniqueIdOld, e.emp_code as memberId, tn.note as disease, tn.note as reasonForHospitalization, @@ -126,6 +126,7 @@ class VidalApiController extends BaseController cf.url as filePath, pt.policy_type as typeOfClaim, ep.tpa_id as empanelmentNo, + ep.tpa_id as dependentUniqueId, ') ->join('employees e', 'e.id = tm.emp_id', 'left') ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') @@ -172,26 +173,26 @@ class VidalApiController extends BaseController $body = [ 'policyNo' => $data['policyNo'], 'dependentUniqueId' => $data['dependentUniqueId'], - 'typeOfClaim' => $data['typeOfClaim'], - 'claimSubType' => "Test", + 'typeOfClaim' => "Main hospitalization claim", + 'claimSubType' => "OPD", 'requestedAmount' => $data['requestedAmount'], 'ailmentType' => "Non covid", 'admissionDate' => change_date_format($data['admissionDate'], 'Y-m-d', 'd-m-Y'), 'dischargeDate' => change_date_format($data['dischargeDate'], 'Y-m-d', 'd-m-Y'), 'hospitalName' => $data['hospitalName'], - 'empanelmentNo' => $data['empanelmentNo'], - "ailmentName" => "Fever", - "hospitalAddress" => "No. 6, Officers Colony, Puthur.,dfgdfgdfg,dfgdfg,560058", - "hospitalState" => "karnataka", - "hospitalCity" => "bangalore", - "hospitalPinCode" => "560036", - "hospitalPhoneNo" => "1234567890", + 'empanelmentNo' => 0, + "ailmentName" => "hospitalization", + "hospitalAddress" => $data['hospitalAddress'] ?? null, + "hospitalState" => $data['hospitalState'] ?? null, + "hospitalCity" => $data['hospitalCity'] ?? null, + "hospitalPinCode" => $data['hospitalPinCode'] ?? null, + "hospitalPhoneNo" => $data['hospitalPhoneNo'] ?? null, "fileId" => $fileId, "bankDetails" => [ - "accountHolderName" =>"Testing claim", - "accountType" =>"savings", - "accountNo" =>"1234567890", - "ifscCode" =>"ICICI098768" + "accountHolderName" => null, + "accountType" => null, + "accountNo" => null, + "ifscCode" => null, ], ]; // dd($body); From cbdf8ad8eb53c9bf3181db7864ab969f017e5ef3 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 6 Dec 2025 16:54:13 +0530 Subject: [PATCH 3/7] CHANGE_ADD_REPOTING_MANAGER_FIELDS --- app/Controllers/UserController.php | 3 +- app/Models/UserModel.php | 1 + app/Views/UserList.php | 45 ++++++++++++++++++++++++++---- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index ee62c702..3879b49d 100755 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -66,6 +66,7 @@ class UserController extends AdminController // print_r($data); die; $data['roleData'] = $this->roleModel->select('id, role')->findAll(); $data['teamData'] = $this->teamModel->select('id, name')->where('is_active',1)->findAll(); + $data['user_data'] = $this->userModel->where('is_active',1)->findAll(); $data['NHanceBranchData'] = $this->nhanceBranchModel->select('id, branch_name')->where('is_active',1)->findAll(); $this->loadLayout('UserList', $data); } @@ -74,7 +75,7 @@ class UserController extends AdminController public function create() { $this->myLogger->logme('error', 'User create function called'); - dd($this->request->getPost()); + // dd($this->request->getPost()); $teams = $this->request->getPost('team'); //if this is get method return to user creation page diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 20baa54c..32272925 100755 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -28,6 +28,7 @@ class UserModel extends Model "updated_at", "is_active", "nhance_branch_id", + "rm_id", ]; // Dates diff --git a/app/Views/UserList.php b/app/Views/UserList.php index 94442753..1382369b 100755 --- a/app/Views/UserList.php +++ b/app/Views/UserList.php @@ -488,7 +488,7 @@ table.dataTable tbody td {
-
+
+
+ + +
- +
- +
@@ -514,7 +523,7 @@ table.dataTable tbody td {
- +
@@ -863,6 +872,7 @@ table.dataTable tbody td { $(document).ready(function () { $('#nhance_branch_id').select2(); + $('#rm_id').select2(); $('#nhance_branch_id') .val(null) // ✅ MUST be null @@ -1070,12 +1080,13 @@ table.dataTable tbody td { $('#mobile').val(res.data.mobile); $('#emp_code').val(res.data.emp_code); $('#role option[value="' + res.data.role + '"]').prop('selected', true); + $('#rm_id').val(res.data.rm_id).select2(); // ✅ correct trigger if (res.data.nhance_branch_id !== null && res.data.nhance_branch_id !== "" && res.data.nhance_branch_id !== 0) { $('#nhance_branch_id') .val(res.data.nhance_branch_id) - .trigger('change.select2'); // ✅ correct trigger + .trigger('change.select2'); } else { $('#nhance_branch_id') .val(null) // ✅ MUST be null @@ -1819,6 +1830,7 @@ table.dataTable tbody td { $('#mobile').val(''); $('#emp_code').val(''); $('#nhance_branch_id').val('0'); + $('#rm_id').val('0'); $('#UserForm').attr('action', ''); let myModal = new bootstrap.Modal(document.getElementById('con-close-modal')); myModal.show(); // open modal @@ -1836,6 +1848,29 @@ table.dataTable tbody td { myModal.show(); // open modal }); + + function validateInput(input, table, field, submitButId){ + + let value = $(input).val(); + let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim(); + + let message = "Value is duplicate!"; + if(label){ + message = label + " already exists!"; + } + + checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { + if (isDuplicate) { + toastr.warning(message, 'WARNING'); + // $(input).val('') + $('#' + submitButId).prop('disabled', true); + } else{ + $('#' + submitButId).prop('disabled', false); + } + }); + + } + \ No newline at end of file From 47c49f2228056a3ede8607544240ad1da6b575ee Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 6 Dec 2025 17:43:26 +0530 Subject: [PATCH 4/7] CHANGE_SET_RENEWAL_MAX_DATE_AS_END_DATE --- app/Views/policy_transaction_inception_list.php | 1 + app/Views/policy_transaction_inception_list_2.php | 1 + 2 files changed, 2 insertions(+) diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php index 82054906..2c443446 100644 --- a/app/Views/policy_transaction_inception_list.php +++ b/app/Views/policy_transaction_inception_list.php @@ -644,6 +644,7 @@ $(document).ready(function(){ var renewal_date = new Date(policy_end_date); // renewal_date.setMonth(renewal_date.getMonth() - 1); renewal_datePicker.setDate(renewal_date); // Set renewal date + renewal_datePicker.set('maxDate', policy_end_date); // set max date } }); diff --git a/app/Views/policy_transaction_inception_list_2.php b/app/Views/policy_transaction_inception_list_2.php index 0096365d..99ef4eb2 100644 --- a/app/Views/policy_transaction_inception_list_2.php +++ b/app/Views/policy_transaction_inception_list_2.php @@ -643,6 +643,7 @@ $(document).ready(function(){ var renewal_date = new Date(policy_end_date); // renewal_date.setMonth(renewal_date.getMonth() - 1); renewal_datePicker.setDate(renewal_date); // Set renewal date + renewal_datePicker.set('maxDate', policy_end_date); // set max date } }); From 3ea58e570c7a5e9b341a3f20b6d5a557d71873de Mon Sep 17 00:00:00 2001 From: "sanjeev.p" Date: Sat, 6 Dec 2025 18:27:24 +0530 Subject: [PATCH 5/7] FIX_Populated card based on policy start end date and Cd account number --- .../policy_transaction_inception_form_2.php | 132 +++++++++++++----- 1 file changed, 94 insertions(+), 38 deletions(-) diff --git a/app/Views/policy_transaction_inception_form_2.php b/app/Views/policy_transaction_inception_form_2.php index 79ac1444..3832eca9 100644 --- a/app/Views/policy_transaction_inception_form_2.php +++ b/app/Views/policy_transaction_inception_form_2.php @@ -3303,6 +3303,30 @@ if(res.status == true){ // appendCDAccountNumber(res.data[0].cd_ac_no, unique_id) appendCDAccountNumber(res.data, unique_id) + + + let balanceDiv = document.getElementById('cd_current_balance_info_' + unique_id); + setTimeout(function(){ + let dropdown_value = $('#cd_ac_no_' + unique_id).val(); + + console.log("dropdown_value",dropdown_value) + + res.data.forEach(function(item) { + if (item.id == dropdown_value) { // match found + if (item.opening_bal !== null) { + $('#cd_current_balance_info_' + unique_id).val(item.opening_bal); + balanceDiv.innerHTML = + '' + item.opening_bal + '' + + ' ✓ CD balance Amount'; + balanceDiv.classList.add('show'); + } + } + }); + $('.card_group_34').show(); + $('.card_group_37').show(); + $("select[name='cd_ac_no_for_child[]']").attr('required', 'required'); + }, 1000); + // if(res.data[0].id){ // $('#cd_ac_pk_for_leader').val(res.data[0].id) // } @@ -4767,53 +4791,85 @@ $('#policy_end_date').on('change', function () { - - let startDateStr = $('#policy_start_date').val(); - let endDateStr = $('#policy_end_date').val(); - if (!startDateStr || !endDateStr) { - alert('Please select both Start and End dates'); - return; - } + let startDateStr = $('#policy_start_date').val(); + let endDateStr = $('#policy_end_date').val(); - // Convert DD/MM/YYYY → Date object - let startParts = startDateStr.split('/'); - let endParts = endDateStr.split('/'); + if (!startDateStr || !endDateStr) { + alert('Please select both Start and End dates'); + return; + } - let startDate = new Date(startParts[2], startParts[1] - 1, startParts[0]); - let endDate = new Date(endParts[2], endParts[1] - 1, endParts[0]); + // Convert DD/MM/YYYY → Date object + let startParts = startDateStr.split('/'); + let endParts = endDateStr.split('/'); - if (endDate <= startDate) { - alert('End Date must be greater than Start Date'); - return; - } + let startDate = new Date(startParts[2], startParts[1] - 1, startParts[0]); + let endDate = new Date(endParts[2], endParts[1] - 1, endParts[0]); - // ✅ Calculate Year Difference - let yearDiff = endDate.getFullYear() - startDate.getFullYear(); + if (endDate <= startDate) { + alert('End Date must be greater than Start Date'); + return; + } - // Adjust if end date is before anniversary - if ( - endDate.getMonth() < startDate.getMonth() || - (endDate.getMonth() === startDate.getMonth() && endDate.getDate() < startDate.getDate()) - ) { - yearDiff--; - } - - console.log('Year Difference:', yearDiff); - - // Clear existing cards (optional but recommended) - // $('#allInsurerCards').empty(); - // $('.insurer-card').remove(); - // insurerCount = 0; - resetInsurerCards(); - - // Add cards equal to year difference - for (let i = 0; i < yearDiff; i++) { - addInsurerColumn(); - } + let yearDiff = calculateYearCount(startDate, endDate); + console.log(`YDiff: ${yearDiff}`); + adjustInsurerCards(yearDiff); }); + + function calculateYearCount(start, end) { + let startDate = new Date(start); + let endDate = new Date(end); + + let years = endDate.getFullYear() - startDate.getFullYear(); + + // Build the anniversary date for calculated years + let anniversary = new Date( + startDate.getFullYear() + years, + startDate.getMonth(), + startDate.getDate() + ); + + // If end date is before anniversary → reduce 1 year + if (endDate < anniversary) { + years--; + } + + // If there are extra days beyond exact year → round up + // (endDate >= anniversary) + return years + 1; + } + + function adjustInsurerCards(yearDiff) { + + console.log("CurrCount:", insurerCount); + + if (yearDiff > insurerCount) { + // ADD missing cards + let cardsToAdd = yearDiff - insurerCount; + console.log("CaAd:", cardsToAdd); + + for (let i = 0; i < cardsToAdd; i++) { + addInsurerColumn(); // your function + } + + } else if (yearDiff < insurerCount) { + // REMOVE extra cards + let cardsToRemove = insurerCount - yearDiff; + console.log("CaRe:", cardsToRemove); + + for (let i = 0; i < cardsToRemove; i++) { + removeInsurerCard(insurerCount); // remove last + } + } + + console.log("UpdatedCa:", insurerCount); + } + + + function resetInsurerCards() { $('#allInsurerCards').empty(); insurerCount = 0; From 03b9d3523de7fcbb4092d3b4c549d7173db941ab Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 8 Dec 2025 11:35:12 +0530 Subject: [PATCH 6/7] CHANGE_SHOW_RM_NAME --- .../PolicyTransactionController.php | 24 +++++- app/Models/PolicyTransactionModel.php | 58 +++++++++++++ .../policy_transaction_inception_form_2.php | 83 +++++++++++++++++-- 3 files changed, 152 insertions(+), 13 deletions(-) diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 5b348a0f..2708abc4 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -825,9 +825,15 @@ // Fetch Sales Team $data['salse_team'] = $this->userModel - ->select('user_profiles.*,nhance_branch.id as nhance_branch_id, nhance_branch.branch_name as nhance_branch_name') + ->select(' + user_profiles.*, + nhance_branch.id as nhance_branch_id, + nhance_branch.branch_name as nhance_branch_name, + rm.first_name AS rm_name + ') ->join('user_teams', 'user_profiles.id = user_teams.user_id') ->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id','left') + ->join('user_profiles AS rm', 'user_profiles.rm_id = rm.id', 'left') ->where('user_teams.team_id', 5) ->where('user_teams.is_active', 1) ->where('user_profiles.is_active', 1) @@ -841,9 +847,19 @@ // Fetch ACM $data['ACM'] = $this->userModel - ->where('role', 3) // Assuming `role` is in `user_profiles` - ->where('is_active', 1) - ->findAll(); + ->select(' + user_profiles.*, + nhance_branch.id AS nhance_branch_id, + nhance_branch.branch_name AS nhance_branch_name, + rm.first_name AS rm_name + ') + ->join('user_teams', 'user_profiles.id = user_teams.user_id') + ->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id', 'left') + ->join('user_profiles AS rm', 'user_profiles.rm_id = rm.id', 'left') + ->where('user_profiles.role', 3) + ->where('user_profiles.is_active', 1) + ->findAll(); + // echo '
';
             
             // print_r($data['ppTeamsData']); die;
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index 44a0550d..7fed2681 100644
--- a/app/Models/PolicyTransactionModel.php
+++ b/app/Models/PolicyTransactionModel.php
@@ -85,6 +85,9 @@
             'agent_code',
             'file_id',
             'entry_from',
+            'salse_person_manager_id',
+            'service_person_manager_id',
+            'service_person_branch_id',
         ];
 
 
@@ -1794,6 +1797,61 @@
                 $toDate = change_date_format($end_date);
             }
 
+            $query = $this->db->table('policy_transaction pt')
+                ->select('
+                    pt.*, 
+                    c.client_name, 
+                    c.short_name AS client_short_name, 
+                    c.client_type,
+                    policy_type.policy_type,
+                    i.name as insurer_name,
+                    ib.branch_name as insurer_branch_name,
+                    vehicle.vehicle_no,
+                    leads.status as lead_status
+                ')
+                ->join('clients c', 'pt.client_id = c.id', 'left')
+                ->join('pt_co_share_details pt_co', 'pt.id = pt_co.pt_id and pt_co.co_share_type = 1', 'left')
+                ->join('insurers i', 'pt_co.insurer_id = i.id', 'left')
+                ->join('insurer_branch ib', 'pt_co.insurer_branch_id = ib.id', 'left')
+                ->join('policy_type', 'pt.policy_type_id = policy_type.id', 'left')
+                ->join('vehicle', 'pt.vehicle_id = vehicle.id and vehicle.is_active = 1', 'left')
+                // ->join('leads', 'pt.client_policy_id = leads.source_policy_id and leads.source_policy_id != 0 and leads.is_active = 1', 'left')
+                ->where('pt.renewal_date >=', $fromDate)
+                ->where('pt.renewal_date <=', $toDate)
+                ->where('pt.is_active', 1)
+                ->where('pt.source_client_policy_id != pt.client_policy_id')
+                ->where('pt_co.is_active', 1)
+                ->where('pt.action_type', "inception");
+
+            // Apply filters if parameters are provided
+            if (!empty($client_type)) {
+                $query->where('c.client_type', $client_type);
+            }
+            if (!empty($client)) {
+                $query->where('pt.client_id', $client);
+            }
+            if (!empty($issuer)) { // Corrected condition to check $issuer
+                $query->where('pt.issuer', $issuer);
+            }
+
+            $query->groupBy('pt.id');
+            $query->orderBy('pt.id', 'DESC');
+            // Fetch and return results
+            $results = $query->get()->getResultArray();
+            // print($this->db->getLastQuery()); die;
+            return $results;
+        }
+        
+        public function getRenewalReportDataOld($start_date = null, $end_date = null, $client_type = null, $client = null, $issuer = null)
+        {
+            $fromDate = date('Y-m-d', strtotime('-90 days'));
+            $toDate = date('Y-m-d 23:59:59');
+
+            if (!empty($start_date) && !empty($end_date)) {
+                $fromDate = change_date_format($start_date);
+                $toDate = change_date_format($end_date);
+            }
+
             $query = $this->db->table('policy_transaction pt')
                 ->select('
                     pt.*, 
diff --git a/app/Views/policy_transaction_inception_form_2.php b/app/Views/policy_transaction_inception_form_2.php
index 79ac1444..dfd6a662 100644
--- a/app/Views/policy_transaction_inception_form_2.php
+++ b/app/Views/policy_transaction_inception_form_2.php
@@ -333,6 +333,9 @@
                         
                         
                         
+                        
+                        
+                        
 
                         
                         
@@ -439,14 +442,21 @@
                                                             class="text-right"
                                                             style="font-size: x-small;">
                                                         
+                                                        
+                                                        
                                                     
-                                                    
                                                         
                                                         
                                                             
                                                                 
                                                             
@@ -456,12 +466,27 @@
                                                 
- - - @@ -6543,7 +6568,7 @@ } - function setNhanceBranch(select) { + function setNhanceBranch(select, show_id) { if (!select || !select.options || select.selectedIndex < 0) { console.warn('No option selected yet'); @@ -6558,9 +6583,13 @@ console.log('NB ID:', nbID); console.log('NB Name:', nbName); - $('#issuer_branch').val(nbID ? nbID : ''); + if(show_id == "nhance_branch_info"){ + $('#issuer_branch').val(nbID ? nbID : ''); + }else{ + $('#service_person_branch_id').val(nbID ? nbID : ''); + } - let nbDiv = document.getElementById('nhance_branch_info'); + let nbDiv = document.getElementById(show_id); if (!nbID || !nbName) { nbDiv.innerHTML = ''; @@ -6575,6 +6604,42 @@ nbDiv.classList.add('show'); } + function setRM(select, show_id) { + + if (!select || !select.options || select.selectedIndex < 0) { + console.warn('No option selected yet'); + return; + } + + let selectedOption = select.options[select.selectedIndex]; + + let rmid = selectedOption.getAttribute('data-rmid'); + let rmname = selectedOption.getAttribute('data-rmname'); + + console.log('RM ID:', rmid); + console.log('RM Name:', rmname); + + if(show_id == "salse_rm_info"){ + $('#salse_person_manager_id').val(rmid ? rmid : ''); + }else{ + $('#service_person_manager_id').val(rmid ? rmid : ''); + } + + let rmDiv = document.getElementById(show_id); + + if (!rmid || !rmname) { + rmDiv.innerHTML = ''; + rmDiv.classList.remove('show'); + return; + } + + rmDiv.innerHTML = + '' + rmname + '' + + ' ✓ RM'; + + rmDiv.classList.add('show'); + } + function setPolicyIssueMonth(){ let monthDiv = document.getElementById('policy_issue_month_info'); monthAbbr = document.getElementById('month').value; From fff305be38edfd828341914279ee077120d72abb Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 8 Dec 2025 12:10:39 +0530 Subject: [PATCH 7/7] CHANGE_RENEWAL_REPORT_CHANGE --- app/Controllers/BDSReportController.php | 11 +++++++---- app/Models/PolicyTransactionModel.php | 13 +++++++------ app/Views/renewal_search.php | 16 ++++++++-------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index d0dd5ac9..6a9d90f1 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -15,6 +15,7 @@ use App\Models\PolicyTransactionModel; use App\Models\PTCOShareDetailsModel; use App\Models\COShareStmtDetailsModel; use App\Models\PolicyTypeModel; +use App\Models\NhanceBranchModel; use CodeIgniter\API\ResponseTrait; @@ -34,6 +35,7 @@ class BDSReportController extends AdminController protected $coShareStmtDetailsModel; protected $policyTypeModel; protected $policyTatReportType; + protected $nhanceBranchModel; public function __construct() { @@ -47,6 +49,7 @@ class BDSReportController extends AdminController $this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->policyTypeModel = new PolicyTypeModel(); + $this->nhanceBranchModel = new NhanceBranchModel(); $this->policyTatReportType = [ @@ -925,7 +928,7 @@ class BDSReportController extends AdminController $default_start = new \DateTime(); $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['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll();; $data['tab_name'] = "Renewal Reports"; $data['page_name'] = "Renewal Report"; return $this->loadLayout('renewal_search', $data); @@ -935,11 +938,11 @@ class BDSReportController extends AdminController $toDate = $this->request->getPost('toDate'); $client_id = $this->request->getPost('client_id'); $client_type = $this->request->getPost('client_type'); - $issuer = $this->request->getPost('issuer'); + $issuer_branch = $this->request->getPost('issuer_branch'); - $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; + $data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll(); $data['client_type'] = [1 => 'Group', 2 => 'Individual']; - $data['renewal_data'] = $this->policyTransactionModel->getRenewalReportData($fromDate, $toDate, $client_type, $client_id, $issuer); + $data['renewal_data'] = $this->policyTransactionModel->getRenewalReportData($fromDate, $toDate, $client_type, $client_id, $issuer_branch); // print_r($data); die; $view_name = "bds_renewal_report_list"; $html = view('bds_renewal_report_list', $data); diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index 7fed2681..1ac58a29 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -1787,7 +1787,7 @@ //function for fetch renewal report data - public function getRenewalReportData($start_date = null, $end_date = null, $client_type = null, $client = null, $issuer = null) + public function getRenewalReportData($start_date = null, $end_date = null, $client_type = null, $client = null, $issuer_branch = null) { $fromDate = date('Y-m-d', strtotime('-90 days')); $toDate = date('Y-m-d 23:59:59'); @@ -1815,13 +1815,14 @@ ->join('insurer_branch ib', 'pt_co.insurer_branch_id = ib.id', 'left') ->join('policy_type', 'pt.policy_type_id = policy_type.id', 'left') ->join('vehicle', 'pt.vehicle_id = vehicle.id and vehicle.is_active = 1', 'left') - // ->join('leads', 'pt.client_policy_id = leads.source_policy_id and leads.source_policy_id != 0 and leads.is_active = 1', 'left') + ->join('leads', 'pt.client_policy_id = leads.source_policy_id and leads.source_policy_id != 0 and leads.is_active = 1', 'left') ->where('pt.renewal_date >=', $fromDate) ->where('pt.renewal_date <=', $toDate) ->where('pt.is_active', 1) - ->where('pt.source_client_policy_id != pt.client_policy_id') ->where('pt_co.is_active', 1) - ->where('pt.action_type', "inception"); + ->where('pt.action_type', "inception") + ->where("NOT EXISTS (SELECT 1 FROM policy_transaction p2 WHERE p2.source_client_policy_id = pt.client_policy_id AND p2.is_active = 1)"); + // Apply filters if parameters are provided if (!empty($client_type)) { @@ -1830,8 +1831,8 @@ if (!empty($client)) { $query->where('pt.client_id', $client); } - if (!empty($issuer)) { // Corrected condition to check $issuer - $query->where('pt.issuer', $issuer); + if (!empty($issuer_branch)) { // Corrected condition to check $issuer + $query->where('pt.issuer_branch', $issuer_branch); } $query->groupBy('pt.id'); diff --git a/app/Views/renewal_search.php b/app/Views/renewal_search.php index 5aa04e50..6cdca11d 100644 --- a/app/Views/renewal_search.php +++ b/app/Views/renewal_search.php @@ -30,13 +30,13 @@
- - + $value) { - echo ""; + if (isset($issuer_branch) && count($issuer_branch)) { + foreach ($issuer_branch as $key => $value) { + echo ""; } } ?> @@ -133,13 +133,13 @@ var toDate = $('#endDate').val(); var client_id = $('#client_id').val(); var client_type = $('#client_type').val(); - var issuer = $('#issuer').val(); + var issuer_branch = $('#issuer_branch').val(); var requestData = { fromDate: fromDate, toDate: toDate, client_id: client_id, client_type: client_type, - issuer: issuer, + issuer_branch: issuer_branch, }; console.log(typeof fromDate); var url = '';