CHANGE_SHOW_RM_NAME

This commit is contained in:
VENKATESHWARAN 2025-12-08 11:35:12 +05:30
parent 47c49f2228
commit 03b9d3523d
3 changed files with 152 additions and 13 deletions

View File

@ -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 '<pre>';
// print_r($data['ppTeamsData']); die;

View File

@ -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.*,

View File

@ -333,6 +333,9 @@
<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="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="premium_details_unique_id">
@ -439,14 +442,21 @@
class="text-right"
style="font-size: x-small;">
</small>
<small id="salse_rm_info"
class="text-right"
style="font-size: x-small;">
</small>
</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>
<?php if (isset($salse_team)) { ?>
<?php foreach ($salse_team as $value) { ?>
<option value="<?= $value['id'];?>"
data-nbid="<?= $value['nhance_branch_id'];?>"
data-nbname="<?= $value['nhance_branch_name'];?>">
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'];?>
</option>
<?php } ?>
@ -456,12 +466,27 @@
</div>
<div class="form-group col-md-3">
<label for="serviced_by">Serviced By</label>
<select class="form-control" id="serviced_by" name="serviced_by">
<label for="serviced_by" class="d-flex align-items-center" >
<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>
<?php if (isset($ACM)) { ?>
<?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'];?>
</option>
<?php } ?>
@ -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 =
'<span class="text-success">' + rmname + '</span>' +
' <span class="vehicle-badge success">✓ RM</span>';
rmDiv.classList.add('show');
}
function setPolicyIssueMonth(){
let monthDiv = document.getElementById('policy_issue_month_info');
monthAbbr = document.getElementById('month').value;