FEAT_LEAD_FILTER_AND_OTHER_CHANGES : RV

This commit is contained in:
VENKATESHWARAN 2025-02-12 14:10:23 +05:30
parent 39a7770cbb
commit 65d6d5a8cd
7 changed files with 451 additions and 30 deletions

View File

@ -387,15 +387,14 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
$routes->group("leads", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "LeadsController::viewLeadsList");
$routes->match(['get', 'post'],"list", "LeadsController::viewLeadsList");
$routes->post("create", "LeadsController::createLead");
$routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1");
$routes->get("sendMail", "LeadsController::sendMailWithAttachement");
$routes->post("sendMail", "LeadsController::sendMailWithAttachement");
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
});
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {

View File

@ -1011,14 +1011,33 @@ class EmpDataServiceController extends BaseController
// dd($inceptionData, $additionData, $dependentAdditionData, $correctionData, $enhancementData, $deletionData, $mergedData);
$template_json = $this->clientPolicyModel
->select('insurer_excel_export_template.jsoncolumns')
->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id')
->where('client_policy.id', $export_data['client_policy_id'])
->where('insurer_excel_export_template.event_name', 'all')
->where('insurer_excel_export_template.is_active', 1) //Live issue changes 17-10-2024
->where('insurer_excel_export_template.type_name', $export_data['actions'])
->first();
// $template_json = $this->clientPolicyModel
// ->select('insurer_excel_export_template.jsoncolumns')
// ->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id')
// ->where('client_policy.id', $export_data['client_policy_id'])
// ->where('insurer_excel_export_template.event_name', 'all')
// ->where('insurer_excel_export_template.is_active', 1) //Live issue changes 17-10-2024
// ->where('insurer_excel_export_template.type_name', $export_data['actions'])
// ->first();
$sql = "
SELECT `insurer_excel_export_template`.`jsoncolumns`
FROM `client_policy`
JOIN `insurer_excel_export_template`
ON `insurer_excel_export_template`.`insurer_id` = `client_policy`.`insurer_id`
AND `insurer_excel_export_template`.`policy_type_id` =
CASE
WHEN `client_policy`.`policy_type_id` IN (2, 3, 4, 5) THEN 2
ELSE `client_policy`.`policy_type_id`
END
WHERE `client_policy`.`id` = '".$export_data['client_policy_id']."'
AND `insurer_excel_export_template`.`event_name` = 'all'
AND `insurer_excel_export_template`.`is_active` = 1
AND `insurer_excel_export_template`.`type_name` = '".$export_data['actions']."'
LIMIT 1";
$query = db_connect()->query($sql);
$template_json = $query->getRowArray();
if(!empty($template_json) && $template_json != null){

View File

@ -107,6 +107,7 @@ class LeadsController extends BaseController
// $d = $this->calculateMembersDemography(['lead_id' => 24]);
//$this->mergeQuoteExcelFileWithMembersListExcelFile(24, 1, $propsal_and_insurer = null);
// dd($d);
$data['page_name'] = 'Leads';
// Set basic data
@ -134,11 +135,27 @@ class LeadsController extends BaseController
// dd($data);
// Fetch leads data
$data ['lead_data_list'] = $this->leadsModel->getLeadDataForLising();
// Load layout and pass data
$this->loadLayout('leads_list', $data);
if ($this->request->is('get')) {
// Fetch leads data
$data ['lead_data_list'] = $this->leadsModel->getLeadDataForLising();
// Load layout and pass data
$this->loadLayout('lead_filter', $data);
}else{
$search_data = $this->request->getPost();
// print_r($search_data);
$where = [];
foreach ($search_data as $search_objects => $key) {
if ($key != null && $key != '' && $key != 0) {
$where[$search_objects] = $key;
}
}
$data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where);
$html = view('leads_list', $data);
return $this->respond(['status' => true, 'html' => $html], 200);
}
}
public function createLead()

View File

@ -120,10 +120,10 @@ class LeadsModel extends Model
return $data;
}
public function getLeadDataForLising()
public function getLeadDataForLising($where = null)
{
return $this->select('
$data = $this->select('
leads.*,
kyc_entity_type.name as entity_type,
policy_type.policy_type,
@ -144,13 +144,16 @@ class LeadsModel extends Model
) AS rfq_count
')
->join('kyc_entity_type', 'leads.entity_type_id = kyc_entity_type.id', 'left')
->join('user_profiles', 'leads.salse_person_id = user_profiles.id', 'left')
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
->where('leads.is_active', 1)
->orderBy('id', 'desc')
->findAll();
->join('kyc_entity_type', 'leads.entity_type_id = kyc_entity_type.id', 'left')
->join('user_profiles', 'leads.salse_person_id = user_profiles.id', 'left')
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
->where('leads.is_active', 1);
if (!empty($where)) {
$data->where($where);
}
return $data->orderBy('leads.id', 'desc')->findAll();
}
public function getLeadForInsertClientList($type = null, $client_id = null)

367
app/Views/lead_filter.php Normal file
View File

@ -0,0 +1,367 @@
<style>
.col-12 {
max-width: 98% !important;
}
</style>
<div class="row" id="lead_filter_div">
<div class="col-12" style="margin-top: -12px;">
<div id="accordion" class="mb-3">
<div class="card mb-1">
<h5 class="m-1">
<div class="row">
<div class="col-md-6" style="position: relative;left: 17px;">
<h4 style="text-align: left;">Lead Filter</h4>
</div>
<div class="col-md-6">
<a style="text-align: right;" id="toggleIcon" class="text-dark float-right"
data-toggle="collapse" href="#collapseOne" aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary"
style="font-size: 28px;"></i>
</a>
</div>
</div>
</h5>
<div id="collapseOne" class="collapse hide" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-3">
<label for="filter_issuer_type"> Issuer Type <span
class="text-danger"></span></label>
<select class="form-control" id="filter_issuer_type" name="filter_issuer_type">
<option value="0">Select</option>
<?php
if (isset($issuer) && count($issuer)) {
foreach ($issuer as $key => $value) {
echo "<option value='" . $key . "'>" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="filter_lead_type"> Lead Type <span class="text-danger"></span></label>
<select class="form-control" id="filter_lead_type" name="filter_lead_type">
<option value="0">Select</option>
<?php
if (isset($lead_type) && count($lead_type)) {
foreach ($lead_type as $key => $value) {
echo "<option value='" . $key . "'>" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="filter_client_type"> Client Type <span
class="text-danger"></span></label>
<select class="form-control" id="filter_client_type" name="filter_client_type">
<option value="0">Select</option>
<?php
if (isset($client_type) && count($client_type)) {
foreach ($client_type as $key => $value) {
echo "<option value='" . $key . "'>" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="filter_policy_type"> Policy Type <span
class="text-danger"></span></label>
<select class="form-control" id="filter_policy_type" name="filter_policy_type">
<option value="0">Select</option>
<?php
if (isset($policy_type) && count($policy_type)) {
foreach ($policy_type as $key => $value) {
echo "<option value='" . $value['id'] . "'>" . $value['policy_type'] . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="filter_client_id">Client<span class="text-danger"></span></label>
<select class="form-control" id="filter_client_id" name="filter_client_id">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="filter_client_branch_id">Client Branch<span
class="text-danger"></span></label>
<select class="form-control" id="filter_client_branch_id"
name="filter_client_branch_id">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-3">
<label for="filter_lead_status">Status<span class="text-danger"></span></label>
<select class="form-control" id="filter_lead_status" name="filter_lead_status">
<option value="0">Select</option>
<?php
if (isset($lead_status) && count($lead_status)) {
foreach ($lead_status as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-12 text-right m-b-0" style="margin-bottom: -15px;">
<a href="<?= base_url("/leads/list"); ?>" class="btn btn-secondary"
id="clear-filters">Clear</a>
<a class="btn btn-primary" id="get-emp-list"
onclick="fetchTicketListData();">Submit</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div id="lead_list_div">
<?php include('leads_list.php'); ?>
</div>
<script>
var client_list = [];
var branch_list = [];
$(document).ready(function() {
$('#filter_client_id').select2();
$('#filter_client_branch_id').select2();
$('#filter_policy_type').select2();
});
$(document).ready(function() {
$('#filter_client_id').change(function() {
let client_id = $(this).val();
if (branch_list != '') {
// console.log(branch_list[client_id]);
let data = branch_list[client_id];
appendBranch(data);
}
})
});
//----- AJAX FUNCTIONS --------------------------------------------------------------------------------
function fetchTicketListData() {
var issuer_type = $('#filter_issuer_type').val();
var lead_type = $('#filter_lead_type').val();
var policy_type = $('#filter_policy_type').val();
var client_type = $('#filter_client_type').val();
var status = $('#filter_lead_status').val();
var client_id = $('#filter_client_id').val();
var client_branch_id = $('#filter_client_branch_id').val();
var requestData = {
issuer: issuer_type,
lead_type: lead_type,
policy_type_id: policy_type,
client_type: client_type,
status: status,
client_id: client_id,
client_branch_id: client_branch_id,
};
console.log("requestData", requestData);
var url = '<?= base_url('/leads/list') ?>';
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
console.log('Filter Responce', response);
if (response.status == true) {
$('#lead_list_div').empty();
$('#lead_list_div').html(response.html);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
setTimeout(function(){
additionalDropdown();
}, 1000);
} else {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
let message = response.message;
toastr.error(message, 'ERROR');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the data.', 'ERROR');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
//function for fetch client, branch
function getClientAndBranchAndPolicy() {
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if (res.status == true) {
client_list = res.client_data;
branch_list = res.branch_data;
appendClients(res.client_data);
} else {
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
//----- END AJAX FUNCTIONS --------------------------------------------------------------------------------
function appendClients(data) {
$('#filter_client_id').empty();
$('#filter_client_id').append($('<option>', {
value: 0,
text: 'Select'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.client_name,
});
$('#filter_client_id').append(option);
});
}
function appendBranch(data) {
$('#filter_client_branch_id').empty();
$('#filter_client_branch_id').append($('<option>', {
value: '',
text: 'Select'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#filter_client_branch_id').append(option);
});
}
// -----------------------------------------------------------------------------------------------------------
function additionalDropdown() {
const table = document.getElementById("tickets-table");
if (!table) return; // Prevent errors if the table is not found
let activeDropdown = null;
function handleDropdownClick(row, event) {
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
let customDropdown = row.customDropdown;
if (!customDropdown) {
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return;
customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
customDropdown.innerHTML = originalDropdown.innerHTML;
document.body.appendChild(customDropdown);
row.customDropdown = customDropdown;
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function (e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) eval(onclickAttr);
const href = this.getAttribute('href');
if (href && href !== '#') window.location.href = href;
customDropdown.style.display = 'none';
activeDropdown = null;
e.stopPropagation();
});
});
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
activeDropdown = customDropdown;
event.stopPropagation();
}
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
row.addEventListener("click", function (event) {
if (!event.target.closest('td:last-child')) {
handleDropdownClick(row, event);
}
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function () {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
}
</script>

View File

@ -161,6 +161,7 @@ table.dataTable tbody td {
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
@ -326,12 +327,14 @@ $(document).ready(function() {
function hide_list_show_add()
{
$('#leads_list').hide()
$('#lead_filter_div').hide()
$('#leads_form').show()
}
function show_list_hide_add()
{
$('#leads_list').show()
$('#lead_filter_div').show()
$('#leads_form').hide()
}

View File

@ -641,7 +641,7 @@
// Check if data is valid (not null or undefined) and is an object
if (data && typeof data === 'object') {
insurer_count = data.proposal_data.over_all_column_data['Proposal 1']['insurers'].length;
let insurer_count = data.proposal_data.over_all_column_data['Proposal 1']?.insurers?.length || 0;
jsonToTable(data);
} else {
addSuggestionsToTable();
@ -1030,16 +1030,29 @@ function addSuggestionsToTable() {
console.log(' addSuggestionsToTable suggestions ', suggestions);
console.log(' addSuggestionsToTable suggestions type', typeof suggestions);
console.log(' over_all_column_data', over_all_column_data);
let leadType = <?= isset($lead_data) && isset($lead_data['lead_type']) ? $lead_data['lead_type'] : 1; ?>;
console.log('leadType', leadType);
let renewal_or_rollover = "Proposal 1";
if(leadType == 2){
renewal_or_rollover = "Existing Renewal"
}else if(leadType == 3){
renewal_or_rollover = "Existing Rollover"
if (leadType == 2) {
renewal_or_rollover = "Existing Renewal";
} else if (leadType == 3) {
renewal_or_rollover = "Existing Rollover";
}
over_all_column_data = {
[renewal_or_rollover]: {
"qcr": 1,
"stc": 1,
"insurers": []
}
};
console.log('renewal_or_rollover', renewal_or_rollover);
console.log(' over_all_column_data', over_all_column_data);
$('#first_proposel_title').html(`
${renewal_or_rollover}
<span class="dropdown" onclick="showThreeDottedMenu(event)">
@ -3806,7 +3819,7 @@ function constructInsurerNameWithVersion(proposal_name, insurerName) {
let newDisplayName = `${insurerName}-V${maxVersion + 1}`;
return newDisplayName;
}
return false;
return insurerName;
}
function checkTheTableDataChanged(redirect_type, url){