Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
velz 2025-12-08 13:08:57 +05:30
commit 5ccc482d35
13 changed files with 401 additions and 103 deletions

View File

@ -15,6 +15,7 @@ use App\Models\PolicyTransactionModel;
use App\Models\PTCOShareDetailsModel; use App\Models\PTCOShareDetailsModel;
use App\Models\COShareStmtDetailsModel; use App\Models\COShareStmtDetailsModel;
use App\Models\PolicyTypeModel; use App\Models\PolicyTypeModel;
use App\Models\NhanceBranchModel;
use CodeIgniter\API\ResponseTrait; use CodeIgniter\API\ResponseTrait;
@ -34,6 +35,7 @@ class BDSReportController extends AdminController
protected $coShareStmtDetailsModel; protected $coShareStmtDetailsModel;
protected $policyTypeModel; protected $policyTypeModel;
protected $policyTatReportType; protected $policyTatReportType;
protected $nhanceBranchModel;
public function __construct() public function __construct()
{ {
@ -47,6 +49,7 @@ class BDSReportController extends AdminController
$this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); $this->PTCOShareDetailsModel = new PTCOShareDetailsModel();
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
$this->policyTypeModel = new PolicyTypeModel(); $this->policyTypeModel = new PolicyTypeModel();
$this->nhanceBranchModel = new NhanceBranchModel();
$this->policyTatReportType = [ $this->policyTatReportType = [
@ -925,7 +928,7 @@ class BDSReportController extends AdminController
$default_start = new \DateTime(); $default_start = new \DateTime();
$data['default_end'] = $default_start->format('d-m-Y'); $data['default_end'] = $default_start->format('d-m-Y');
$data['default_start'] = $default_start->modify('-60 days')->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['tab_name'] = "Renewal Reports";
$data['page_name'] = "Renewal Report"; $data['page_name'] = "Renewal Report";
return $this->loadLayout('renewal_search', $data); return $this->loadLayout('renewal_search', $data);
@ -935,11 +938,11 @@ class BDSReportController extends AdminController
$toDate = $this->request->getPost('toDate'); $toDate = $this->request->getPost('toDate');
$client_id = $this->request->getPost('client_id'); $client_id = $this->request->getPost('client_id');
$client_type = $this->request->getPost('client_type'); $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['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; // print_r($data); die;
$view_name = "bds_renewal_report_list"; $view_name = "bds_renewal_report_list";
$html = view('bds_renewal_report_list', $data); $html = view('bds_renewal_report_list', $data);

View File

@ -825,9 +825,15 @@
// Fetch Sales Team // Fetch Sales Team
$data['salse_team'] = $this->userModel $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('user_teams', 'user_profiles.id = user_teams.user_id')
->join('nhance_branch', 'user_profiles.nhance_branch_id = nhance_branch.id','left') ->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.team_id', 5)
->where('user_teams.is_active', 1) ->where('user_teams.is_active', 1)
->where('user_profiles.is_active', 1) ->where('user_profiles.is_active', 1)
@ -841,9 +847,19 @@
// Fetch ACM // Fetch ACM
$data['ACM'] = $this->userModel $data['ACM'] = $this->userModel
->where('role', 3) // Assuming `role` is in `user_profiles` ->select('
->where('is_active', 1) 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(); ->findAll();
// echo '<pre>'; // echo '<pre>';
// print_r($data['ppTeamsData']); die; // print_r($data['ppTeamsData']); die;

View File

@ -66,6 +66,7 @@ class UserController extends AdminController
// print_r($data); die; // print_r($data); die;
$data['roleData'] = $this->roleModel->select('id, role')->findAll(); $data['roleData'] = $this->roleModel->select('id, role')->findAll();
$data['teamData'] = $this->teamModel->select('id, name')->where('is_active',1)->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(); $data['NHanceBranchData'] = $this->nhanceBranchModel->select('id, branch_name')->where('is_active',1)->findAll();
$this->loadLayout('UserList', $data); $this->loadLayout('UserList', $data);
} }
@ -74,7 +75,7 @@ class UserController extends AdminController
public function create() public function create()
{ {
$this->myLogger->logme('error', 'User create function called'); $this->myLogger->logme('error', 'User create function called');
dd($this->request->getPost()); // dd($this->request->getPost());
$teams = $this->request->getPost('team'); $teams = $this->request->getPost('team');
//if this is get method return to user creation page //if this is get method return to user creation page

View File

@ -118,7 +118,7 @@ class VidalApiController extends BaseController
tm.hospital_name as hospitalName, tm.hospital_name as hospitalName,
tm.claim_amount as requestedAmount, tm.claim_amount as requestedAmount,
cp.policy_no as policyNo, cp.policy_no as policyNo,
e.id as dependentUniqueId, e.id as dependentUniqueIdOld,
e.emp_code as memberId, e.emp_code as memberId,
tn.note as disease, tn.note as disease,
tn.note as reasonForHospitalization, tn.note as reasonForHospitalization,
@ -126,6 +126,7 @@ class VidalApiController extends BaseController
cf.url as filePath, cf.url as filePath,
pt.policy_type as typeOfClaim, pt.policy_type as typeOfClaim,
ep.tpa_id as empanelmentNo, ep.tpa_id as empanelmentNo,
ep.tpa_id as dependentUniqueId,
') ')
->join('employees e', 'e.id = tm.emp_id', 'left') ->join('employees e', 'e.id = tm.emp_id', 'left')
->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left')
@ -172,26 +173,26 @@ class VidalApiController extends BaseController
$body = [ $body = [
'policyNo' => $data['policyNo'], 'policyNo' => $data['policyNo'],
'dependentUniqueId' => $data['dependentUniqueId'], 'dependentUniqueId' => $data['dependentUniqueId'],
'typeOfClaim' => $data['typeOfClaim'], 'typeOfClaim' => "Main hospitalization claim",
'claimSubType' => "Test", 'claimSubType' => "OPD",
'requestedAmount' => $data['requestedAmount'], 'requestedAmount' => $data['requestedAmount'],
'ailmentType' => "Non covid", 'ailmentType' => "Non covid",
'admissionDate' => change_date_format($data['admissionDate'], 'Y-m-d', 'd-m-Y'), 'admissionDate' => change_date_format($data['admissionDate'], 'Y-m-d', 'd-m-Y'),
'dischargeDate' => change_date_format($data['dischargeDate'], 'Y-m-d', 'd-m-Y'), 'dischargeDate' => change_date_format($data['dischargeDate'], 'Y-m-d', 'd-m-Y'),
'hospitalName' => $data['hospitalName'], 'hospitalName' => $data['hospitalName'],
'empanelmentNo' => $data['empanelmentNo'], 'empanelmentNo' => 0,
"ailmentName" => "Fever", "ailmentName" => "hospitalization",
"hospitalAddress" => "No. 6, Officers Colony, Puthur.,dfgdfgdfg,dfgdfg,560058", "hospitalAddress" => $data['hospitalAddress'] ?? null,
"hospitalState" => "karnataka", "hospitalState" => $data['hospitalState'] ?? null,
"hospitalCity" => "bangalore", "hospitalCity" => $data['hospitalCity'] ?? null,
"hospitalPinCode" => "560036", "hospitalPinCode" => $data['hospitalPinCode'] ?? null,
"hospitalPhoneNo" => "1234567890", "hospitalPhoneNo" => $data['hospitalPhoneNo'] ?? null,
"fileId" => $fileId, "fileId" => $fileId,
"bankDetails" => [ "bankDetails" => [
"accountHolderName" =>"Testing claim", "accountHolderName" => null,
"accountType" =>"savings", "accountType" => null,
"accountNo" =>"1234567890", "accountNo" => null,
"ifscCode" =>"ICICI098768" "ifscCode" => null,
], ],
]; ];
// dd($body); // dd($body);

View File

@ -85,6 +85,9 @@
'agent_code', 'agent_code',
'file_id', 'file_id',
'entry_from', 'entry_from',
'salse_person_manager_id',
'service_person_manager_id',
'service_person_branch_id',
]; ];
@ -1784,7 +1787,63 @@
//function for fetch renewal report data //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')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
@ -2477,6 +2536,12 @@
pt.id AS id, pt.id AS id,
pt.endorsement_no, pt.endorsement_no,
pt.ref, 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(pt.policy_issue_date, '%d %b %Y') AS policy_issue_date,
DATE_FORMAT(pcsd.pt_policy_issue_date, '%b %Y') AS policy_issue_month, DATE_FORMAT(pcsd.pt_policy_issue_date, '%b %Y') AS policy_issue_month,
pt.month as statement_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 su ON pt.sales_generated_by = su.id
LEFT JOIN user_profiles se ON pt.serviced_by = se.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 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 WHERE pt.is_active = 1
AND pcsd.is_active = 1 AND pcsd.is_active = 1
@ -2573,6 +2639,12 @@
pt.id AS id, pt.id AS id,
pt.endorsement_no, pt.endorsement_no,
pt.ref, 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(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, 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, 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 su ON pt.sales_generated_by = su.id
LEFT JOIN user_profiles se ON pt.serviced_by = se.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 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 WHERE pt.is_active = 1
AND pcsd.is_active = 1 AND pcsd.is_active = 1

View File

@ -28,6 +28,7 @@ class UserModel extends Model
"updated_at", "updated_at",
"is_active", "is_active",
"nhance_branch_id", "nhance_branch_id",
"rm_id",
]; ];
// Dates // Dates

View File

@ -488,7 +488,7 @@ table.dataTable tbody td {
<div class="form-group"> <div class="form-group">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-6">
<label for="nhance_branch_id">NHance Branch<span class="text-danger">*</span></label> <label for="nhance_branch_id">NHance Branch<span class="text-danger">*</span></label>
<select class="form-control" id="nhance_branch_id" name="nhance_branch_id" required> <select class="form-control" id="nhance_branch_id" name="nhance_branch_id" required>
<option value="">Select NHance Branch</option> <option value="">Select NHance Branch</option>
@ -497,16 +497,25 @@ table.dataTable tbody td {
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
<div class="form-group col-md-6">
<label for="rm_id">Reporting Manager<span class="text-danger">*</span></label>
<select class="form-control" id="rm_id" name="rm_id" required>
<option value="">Select Reporting Manager</option>
<?php foreach($user_data as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['first_name'] ?></option>
<?php } ?>
</select>
</div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="emp_code">Employee Code<span class="text-danger">*</span></label> <label for="emp_code">Employee Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="emp_code" placeholder="Enter Code" name="emp_code" required> <input type="text" class="form-control" id="emp_code" placeholder="Enter Code" name="emp_code" onchange="validateInput(this, 'user_profiles', 'emp_code', 'btnSubmit')" required>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="first_name">Name<span class="text-danger">*</span></label> <label for="first_name">Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name" placeholder="Ente Name" name="first_name" required> <input type="text" class="form-control" id="first_name" placeholder="Enter Name" name="first_name" required>
</div> </div>
</div> </div>
@ -514,7 +523,7 @@ table.dataTable tbody td {
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="email">Email<span class="text-danger">*</span></label> <label for="email">Email<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="email" placeholder="Enter Email" name="email" data-parsley-trigger="change" data-parsley-type="email" required> <input type="text" class="form-control" id="email" placeholder="Enter Email" name="email" data-parsley-trigger="change" data-parsley-type="email" onchange="validateInput(this, 'user_profiles', 'email', 'btnSubmit')" required>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
@ -863,6 +872,7 @@ table.dataTable tbody td {
$(document).ready(function () { $(document).ready(function () {
$('#nhance_branch_id').select2(); $('#nhance_branch_id').select2();
$('#rm_id').select2();
$('#nhance_branch_id') $('#nhance_branch_id')
.val(null) // ✅ MUST be null .val(null) // ✅ MUST be null
@ -1070,12 +1080,13 @@ table.dataTable tbody td {
$('#mobile').val(res.data.mobile); $('#mobile').val(res.data.mobile);
$('#emp_code').val(res.data.emp_code); $('#emp_code').val(res.data.emp_code);
$('#role option[value="' + res.data.role + '"]').prop('selected', true); $('#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 && if (res.data.nhance_branch_id !== null &&
res.data.nhance_branch_id !== "" && res.data.nhance_branch_id !== "" &&
res.data.nhance_branch_id !== 0) { res.data.nhance_branch_id !== 0) {
$('#nhance_branch_id') $('#nhance_branch_id')
.val(res.data.nhance_branch_id) .val(res.data.nhance_branch_id)
.trigger('change.select2'); // ✅ correct trigger .trigger('change.select2');
} else { } else {
$('#nhance_branch_id') $('#nhance_branch_id')
.val(null) // ✅ MUST be null .val(null) // ✅ MUST be null
@ -1819,6 +1830,7 @@ table.dataTable tbody td {
$('#mobile').val(''); $('#mobile').val('');
$('#emp_code').val(''); $('#emp_code').val('');
$('#nhance_branch_id').val('0'); $('#nhance_branch_id').val('0');
$('#rm_id').val('0');
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>'); $('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
let myModal = new bootstrap.Modal(document.getElementById('con-close-modal')); let myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show(); // open modal myModal.show(); // open modal
@ -1837,5 +1849,28 @@ table.dataTable tbody td {
}); });
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);
}
});
}
</script> </script>

View File

@ -346,9 +346,11 @@ table.dataTable thead th {
<a class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>" onclick="getPolicyTransactionDataForEndorsementEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')"> <a class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>" onclick="getPolicyTransactionDataForEndorsementEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a> </a>
<?php if(get_role_id() == 5): ?>
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)"> <a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete <i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a> </a>
<?php endif; ?>
</div> </div>
</div> </div>
</td> </td>

View File

@ -333,6 +333,9 @@
<input type="hidden" name="cd_amt_changed" id="cd_amt_changed" disabled> <input type="hidden" name="cd_amt_changed" id="cd_amt_changed" disabled>
<input type="hidden" name="agent_code" id="agent_code"> <input type="hidden" name="agent_code" id="agent_code">
<input type="hidden" name="issuer_branch" id="issuer_branch"> <input type="hidden" name="issuer_branch" id="issuer_branch">
<input type="hidden" name="salse_person_manager_id" id="salse_person_manager_id">
<input type="hidden" name="service_person_manager_id" id="service_person_manager_id">
<input type="hidden" name="service_person_branch_id" id="service_person_branch_id">
<!-- <input type="hidden" id="cd_ac_no_for_edit"> --> <!-- <input type="hidden" id="cd_ac_no_for_edit"> -->
<input type="hidden" id="premium_details_unique_id"> <input type="hidden" id="premium_details_unique_id">
@ -439,14 +442,21 @@
class="text-right" class="text-right"
style="font-size: x-small;"> style="font-size: x-small;">
</small> </small>
<small id="salse_rm_info"
class="text-right"
style="font-size: x-small;">
</small>
</label> </label>
<select class="form-control" id="sales_generated_by" name="sales_generated_by" onchange="setNhanceBranch(this)" autocomplete="off"> <select class="form-control" id="sales_generated_by" name="sales_generated_by" onchange="setNhanceBranch(this, 'nhance_branch_info'); setRM(this, 'salse_rm_info')" autocomplete="off">
<option value="" selected>Select Sales Person</option> <option value="" selected>Select Sales Person</option>
<?php if (isset($salse_team)) { ?> <?php if (isset($salse_team)) { ?>
<?php foreach ($salse_team as $value) { ?> <?php foreach ($salse_team as $value) { ?>
<option value="<?= $value['id'];?>" <option value="<?= $value['id'];?>"
data-nbid="<?= $value['nhance_branch_id'];?>" data-nbid="<?= $value['nhance_branch_id'];?>"
data-nbname="<?= $value['nhance_branch_name'];?>"> data-nbname="<?= $value['nhance_branch_name'];?>"
data-rmid="<?= $value['rm_id'];?>"
data-rmname="<?= $value['rm_name'];?>"
>
<?= $value['first_name'];?> <?= $value['first_name'];?>
</option> </option>
<?php } ?> <?php } ?>
@ -456,12 +466,27 @@
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="serviced_by">Serviced By</label> <label for="serviced_by" class="d-flex align-items-center" >
<select class="form-control" id="serviced_by" name="serviced_by"> <span class="flex-grow-1">Serviced By</span>
<small id="service_nhance_branch_info"
class="text-right"
style="font-size: x-small;">
</small>
<small id="service_rm_info"
class="text-right"
style="font-size: x-small;">
</small>
</label>
<select class="form-control" id="serviced_by" name="serviced_by" onchange="setNhanceBranch(this, 'service_nhance_branch_info'); setRM(this, 'service_rm_info')">
<option value="" selected>Select Service Person</option> <option value="" selected>Select Service Person</option>
<?php if (isset($ACM)) { ?> <?php if (isset($ACM)) { ?>
<?php foreach ($ACM as $value) { ?> <?php foreach ($ACM as $value) { ?>
<option value="<?= $value['id'];?>"> <option value="<?= $value['id'];?>"
data-nbid="<?= $value['nhance_branch_id'];?>"
data-nbname="<?= $value['nhance_branch_name'];?>"
data-rmid="<?= $value['rm_id'];?>"
data-rmname="<?= $value['rm_name'];?>"
>
<?= $value['first_name'];?> <?= $value['first_name'];?>
</option> </option>
<?php } ?> <?php } ?>
@ -3303,6 +3328,30 @@
if(res.status == true){ if(res.status == true){
// appendCDAccountNumber(res.data[0].cd_ac_no, unique_id) // appendCDAccountNumber(res.data[0].cd_ac_no, unique_id)
appendCDAccountNumber(res.data, 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 =
'<span class="text-success">' + item.opening_bal + '</span>' +
' <span class="vehicle-badge success">✓ CD balance Amount</span>';
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){ // if(res.data[0].id){
// $('#cd_ac_pk_for_leader').val(res.data[0].id) // $('#cd_ac_pk_for_leader').val(res.data[0].id)
// } // }
@ -4788,32 +4837,64 @@
return; return;
} }
// ✅ Calculate Year Difference let yearDiff = calculateYearCount(startDate, endDate);
let yearDiff = endDate.getFullYear() - startDate.getFullYear(); console.log(`YDiff: ${yearDiff}`);
adjustInsurerCards(yearDiff);
// 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();
}
}); });
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() { function resetInsurerCards() {
$('#allInsurerCards').empty(); $('#allInsurerCards').empty();
insurerCount = 0; insurerCount = 0;
@ -6543,7 +6624,7 @@
} }
function setNhanceBranch(select) { function setNhanceBranch(select, show_id) {
if (!select || !select.options || select.selectedIndex < 0) { if (!select || !select.options || select.selectedIndex < 0) {
console.warn('No option selected yet'); console.warn('No option selected yet');
@ -6558,9 +6639,13 @@
console.log('NB ID:', nbID); console.log('NB ID:', nbID);
console.log('NB Name:', nbName); console.log('NB Name:', nbName);
if(show_id == "nhance_branch_info"){
$('#issuer_branch').val(nbID ? nbID : ''); $('#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) { if (!nbID || !nbName) {
nbDiv.innerHTML = ''; nbDiv.innerHTML = '';
@ -6575,6 +6660,42 @@
nbDiv.classList.add('show'); 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 =
'<span class="text-success">' + rmname + '</span>' +
' <span class="vehicle-badge success">✓ RM</span>';
rmDiv.classList.add('show');
}
function setPolicyIssueMonth(){ function setPolicyIssueMonth(){
let monthDiv = document.getElementById('policy_issue_month_info'); let monthDiv = document.getElementById('policy_issue_month_info');
monthAbbr = document.getElementById('month').value; monthAbbr = document.getElementById('month').value;

View File

@ -337,9 +337,12 @@ table.dataTable tbody td {
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')"> <a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a> </a>
<?php if(get_role_id() == 5): ?>
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)"> <a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete <i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a> </a>
<?php endif; ?>
</div> </div>
</div> </div>
</td> </td>
@ -641,6 +644,7 @@ $(document).ready(function(){
var renewal_date = new Date(policy_end_date); var renewal_date = new Date(policy_end_date);
// renewal_date.setMonth(renewal_date.getMonth() - 1); // renewal_date.setMonth(renewal_date.getMonth() - 1);
renewal_datePicker.setDate(renewal_date); // Set renewal date renewal_datePicker.setDate(renewal_date); // Set renewal date
renewal_datePicker.set('maxDate', policy_end_date); // set max date
} }
}); });

View File

@ -337,9 +337,11 @@ table.dataTable tbody td {
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')"> <a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a> </a>
<?php if(get_role_id() == 5): ?>
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)"> <a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete <i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a> </a>
<?php endif; ?>
</div> </div>
</div> </div>
</td> </td>
@ -641,6 +643,7 @@ $(document).ready(function(){
var renewal_date = new Date(policy_end_date); var renewal_date = new Date(policy_end_date);
// renewal_date.setMonth(renewal_date.getMonth() - 1); // renewal_date.setMonth(renewal_date.getMonth() - 1);
renewal_datePicker.setDate(renewal_date); // Set renewal date renewal_datePicker.setDate(renewal_date); // Set renewal date
renewal_datePicker.set('maxDate', policy_end_date); // set max date
} }
}); });

View File

@ -30,13 +30,13 @@
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="client_branch">Issuer<span class="text-danger"></span></label> <label for="client_branch">Nhance Branch<span class="text-danger"></span></label>
<select class="form-control" id="issuer" name="issuer"> <select class="form-control" id="issuer_branch" name="issuer_branch">
<option value="">Select Issuer</option> <option value="">Select Branch</option>
<?php <?php
if (isset($issuer) && count($issuer)) { if (isset($issuer_branch) && count($issuer_branch)) {
foreach ($issuer as $key => $value) { foreach ($issuer_branch as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>"; echo "<option value=" . $value['id'] . ">" . $value['branch_name'] . "</option>";
} }
} }
?> ?>
@ -133,13 +133,13 @@
var toDate = $('#endDate').val(); var toDate = $('#endDate').val();
var client_id = $('#client_id').val(); var client_id = $('#client_id').val();
var client_type = $('#client_type').val(); var client_type = $('#client_type').val();
var issuer = $('#issuer').val(); var issuer_branch = $('#issuer_branch').val();
var requestData = { var requestData = {
fromDate: fromDate, fromDate: fromDate,
toDate: toDate, toDate: toDate,
client_id: client_id, client_id: client_id,
client_type: client_type, client_type: client_type,
issuer: issuer, issuer_branch: issuer_branch,
}; };
console.log(typeof fromDate); console.log(typeof fromDate);
var url = '<?= base_url('/bdsReport/renewal_report') ?>'; var url = '<?= base_url('/bdsReport/renewal_report') ?>';

View File

@ -109,13 +109,19 @@ table.dataTable tbody td {
<th>Agreed Amount</th> <th>Agreed Amount</th>
<th>Invoiced Amount</th> <th>Invoiced Amount</th>
<th>Outstanding Amount</th> <th>Outstanding Amount</th>
<th style="display: none;">Salse Person</th>
<th style="display: none;">Service Person</th>
<th style="display: none;">Nhance Branch</th>
<th style="display: none;">Installment</th>
<th style="display: none;">Data Received Date</th>
<th style="display: none;">Renewal Date</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php if (isset($report_list)) { ?> <?php if (isset($report_list)) { ?>
<?php foreach($report_list as $index => $row){ ?> <?php foreach($report_list as $index => $row){ ?>
<tr> <tr data-id="<?= $row['pt_id'] ?>">
<td><?= $index + 1 ?> &nbsp; <a href="<?php <td><?= $index + 1 ?> &nbsp; <a href="<?php
if(strtolower($row['action_type']) == "policy"){ if(strtolower($row['action_type']) == "policy"){
echo base_url('policy_tranction/inception/list') . '?pt_id=' . $row['id'] ; echo base_url('policy_tranction/inception/list') . '?pt_id=' . $row['id'] ;
@ -142,9 +148,9 @@ table.dataTable tbody td {
<td style="display: none;"><?php echo empty($row['policy_end_date']) ? 'N/A' : date('d/m/Y', strtotime($row['policy_end_date'])); ?></td> <td style="display: none;"><?php echo empty($row['policy_end_date']) ? 'N/A' : date('d/m/Y', strtotime($row['policy_end_date'])); ?></td>
<td style="display: none;"><?php echo $row['ref'] ?: 'N/A'; ?></td> <td style="display: none;"><?php echo $row['ref'] ?: 'N/A'; ?></td>
<td style="display: none;"><?php echo $row['remarks'] ?: 'N/A'; ?></td> <td style="display: none;"><?php echo $row['remarks'] ?: 'N/A'; ?></td>
<td class="right-align-input"><?php echo $row['bp_amt'] ?: '0.00'; ?></td> <td class="right-align-input"><?php echo ($row['total_irda_amt'] != 0.00) ? ($row['bp_amt'] ?: '0.00') : '0.00'; ?></td>
<td class="right-align-input"><?php echo $row['tp_or_ter'] ?: '0.00'; ?></td> <td class="right-align-input"><?php echo $row['tp_or_ter'] ?: '0.00'; ?></td>
<td class="right-align-input"><?php echo $row['premium_wo_gst']; ?></td> <td class="right-align-input"><?php echo ($row['total_irda_amt'] != 0.00) ? ($row['premium_wo_gst'] ?: '0.00') : '0.00'; ?></td>
<!-- <td class="right-align-input" style="display: none;"><?php echo $row['gst_amount']; ?></td> --> <!-- <td class="right-align-input" style="display: none;"><?php echo $row['gst_amount']; ?></td> -->
<td class="right-align-input" style="display: none;"><?php echo $row['total_premium'] ?: '0.00'; ?></td> <td class="right-align-input" style="display: none;"><?php echo $row['total_premium'] ?: '0.00'; ?></td>
<td class="right-align-input"><?php echo $row['agreed_bp_per'] ?: '0.00'; ?>%</td> <td class="right-align-input"><?php echo $row['agreed_bp_per'] ?: '0.00'; ?>%</td>
@ -186,6 +192,12 @@ table.dataTable tbody td {
number_format((float)$row['unbilled_amount'],2, '.', ''); number_format((float)$row['unbilled_amount'],2, '.', '');
?> ?>
</td> </td>
<td style="display: none;"><?php echo $row['salse_person_name'] ?: 'N/A'; ?></td>
<td style="display: none;"><?php echo $row['service_person_name'] ?: 'N/A'; ?></td>
<td style="display: none;"><?php echo $row['nhance_branch'] ?: 'N/A'; ?></td>
<td style="display: none;"><?php echo $row['installment'] ?: 'N/A'; ?></td>
<td style="display: none;"><?php echo empty($row['data_received_date']) ? 'N/A' : date('d/m/Y', strtotime($row['data_received_date'])) ?></td>
<td style="display: none;"><?php echo empty($row['renewal_date']) ? 'N/A' : date('d/m/Y', strtotime($row['renewal_date'])) ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
@ -546,6 +558,33 @@ $(document).ready(function() {
// $('#total_billed').text(totalBilled.toFixed(2)); // $('#total_billed').text(totalBilled.toFixed(2));
// $('#total_unbilled').text(totalUnbilled.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 // Helper to sum numeric values safely
var getTotal = function(colIndex) { var getTotal = function(colIndex) {
return api.column(colIndex, { search: 'applied' }).data() return api.column(colIndex, { search: 'applied' }).data()
@ -563,17 +602,16 @@ $(document).ready(function() {
var totalRewards = getTotal(24); var totalRewards = getTotal(24);
var totalIrda = getTotal(25); var totalIrda = getTotal(25);
var totalBilled = getTotal(26); var totalBilled = getTotal(26);
var totalUnbilled = getTotal(27); // var totalUnbilled = getTotal(27);
// Update the totals section above the table // Update the totals section above the table
$('#total_premium').text(totalPremium.toFixed(2)); $('#total_premium').text(totalPremium.toFixed(2));
$('#total_rewards').text(totalRewards.toFixed(2)); $('#total_rewards').text(totalRewards.toFixed(2));
$('#total_irda').text(totalIrda.toFixed(2)); $('#total_irda').text(totalIrda.toFixed(2));
$('#total_billed').text(totalBilled.toFixed(2)); $('#total_billed').text(totalBilled.toFixed(2));
// $('#total_unbilled').text(totalUnbilled.toFixed(2));
var totalUnbilled = getUniqueUnbilled(27);
$('#total_unbilled').text(totalUnbilled.toFixed(2)); $('#total_unbilled').text(totalUnbilled.toFixed(2));
} }
}); });
} else { } else {
@ -641,9 +679,9 @@ function appendTableData(data) {
} }
$('table tbody').on('click', 'td', function () { $('table tbody').on('click', 'td', function () {
var index = $(this).index(); var colIndex = $(this).index();
console.log('Clicked TD index:', index); var rowIndex = $(this).closest('tr').index();
console.log('Row:', rowIndex, 'Column:', colIndex);
}); });
</script> </script>