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/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/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/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);
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index 1d752149..1ac58a29 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',
];
@@ -1784,7 +1787,63 @@
//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');
+
+ 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.*,
+ 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_co.is_active', 1)
+ ->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)) {
+ $query->where('c.client_type', $client_type);
+ }
+ if (!empty($client)) {
+ $query->where('pt.client_id', $client);
+ }
+ if (!empty($issuer_branch)) { // Corrected condition to check $issuer
+ $query->where('pt.issuer_branch', $issuer_branch);
+ }
+
+ $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');
@@ -2477,6 +2536,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 +2624,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 +2639,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 +2766,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/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
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_form_2.php b/app/Views/policy_transaction_inception_form_2.php
index 79ac1444..a1db7f44 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;">
+
+
-
-
-
+
+
-
@@ -3303,6 +3328,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 +4816,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;
@@ -6543,7 +6624,7 @@
}
- function setNhanceBranch(select) {
+ function setNhanceBranch(select, show_id) {
if (!select || !select.options || select.selectedIndex < 0) {
console.warn('No option selected yet');
@@ -6558,9 +6639,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 +6660,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;
diff --git a/app/Views/policy_transaction_inception_list.php b/app/Views/policy_transaction_inception_list.php
index ae82bc2c..2c443446 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
+
+
@@ -641,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 c5aedf93..99ef4eb2 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
+
+
@@ -641,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
}
});
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 = '= base_url('/bdsReport/renewal_report') ?>';
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
+
+
+
+
+
+
$row){ ?>
-
+
= $index + 1 ?>
-
+
-
+
%
@@ -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