463 lines
16 KiB
PHP
Executable File
463 lines
16 KiB
PHP
Executable File
<style>
|
|
.table th,
|
|
.table td {
|
|
padding: 8px;
|
|
}
|
|
|
|
table.dataTable tbody td {
|
|
padding: 4px 4px !important;
|
|
}
|
|
|
|
.col-12 {
|
|
max-width: 98% !important;
|
|
}
|
|
|
|
.dataTables_filter {
|
|
position: absolute;
|
|
}
|
|
|
|
.highlight {
|
|
border: 2px solid red;
|
|
background-color: #ffe6e6;
|
|
}
|
|
|
|
.column-header {
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.form-section {
|
|
border: 1px solid #ccc;
|
|
padding: 15px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.row-box {
|
|
border: 1px solid #ccc;
|
|
padding: 10px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
|
|
.custom-dropdown-menu {
|
|
display: none;
|
|
position: absolute;
|
|
background-color: #ffffff !important;
|
|
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
border-radius: 0.25rem;
|
|
padding: 0.5rem 0;
|
|
min-width: 10rem;
|
|
z-index: 9999;
|
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.custom-dropdown-menu .dropdown-item {
|
|
display: block !important;
|
|
width: 100% !important;
|
|
padding: 0.5rem 1rem !important;
|
|
color: #212529 !important;
|
|
text-decoration: none !important;
|
|
background-color: transparent !important;
|
|
}
|
|
|
|
.custom-dropdown-menu .dropdown-item:hover {
|
|
background-color: #f8f9fa !important;
|
|
color: #16181b !important;
|
|
cursor: pointer !important;
|
|
}
|
|
</style>
|
|
|
|
|
|
<div class="row" id="leads_list">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row" style="margin-bottom:1rem;">
|
|
<div class="col-6" style="align-self: center;">
|
|
<h4 style="position: relative;">Leads List</h4>
|
|
</div>
|
|
|
|
<div class="col-3" id="status_change" style="text-align: right; position: relative;top: 56px; left: 291px;">
|
|
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" onclick="hide_list_show_add();">Add</button>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="table-responsive">
|
|
<table class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
|
|
|
|
<thead class="bg-light">
|
|
<tr>
|
|
<th><div class="column-header">S.No.</div></th>
|
|
<th><div class="column-header">Lead Type</div></th>
|
|
<th><div class="column-header">Issuer</div></th>
|
|
<th><div class="column-header">Client Type</div></th>
|
|
<th><div class="column-header">Client / Branch</div></th>
|
|
<th><div class="column-header">Entity Type</div></th>
|
|
<th><div class="column-header">Branch Name</div></th>
|
|
<th><div class="column-header">Branch Code</div></th>
|
|
<th><div class="column-header">Contact Person Name</div></th>
|
|
<th><div class="column-header">Contact Person Mobile</div></th>
|
|
<th><div class="column-header">Policy Type</div></th>
|
|
<th><div class="column-header">Status</div></th>
|
|
<th><div class="column-header">Action</div></th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
<?php if(isset($lead_data_list)) { ?>
|
|
<?php foreach($lead_data_list as $index => $row){ ?>
|
|
<tr>
|
|
<td><?php echo $index + 1; ?></td>
|
|
<td><?php echo $lead_type[$row['lead_type']] ?? '-'; ?></td>
|
|
<td><?php echo $issuer[$row['issuer']] ?? '-'; ?></td>
|
|
<td><?php echo $client_type[$row['client_type']] ?? '-'; ?></td>
|
|
<td><?php echo $row['client_type'] == 2 ? ($row['client_name'] ?? '-') : (($row['client_short_name'] ?? '-') . ' - ' . ($row['branch_name'] ?? '-')); ?></td>
|
|
<td><?php echo $row['entity_type'] ?? '-'; ?></td>
|
|
<td><?php echo $row['branch_name'] ?? '-'; ?></td>
|
|
<td><?php echo $row['branch_code'] ?? '-'; ?></td>
|
|
<td><?php echo $row['contact_person_name'] ?? '-'; ?></td>
|
|
<td><?php echo $row['contact_person_mobile'] ?? '-'; ?></td>
|
|
<td><?php echo $row['policy_type'] ?? '-'; ?></td>
|
|
<td><?php echo $lead_status[$row['status']] ?? '-'; ?></td>
|
|
<td>
|
|
<div class="btn-group dropdown">
|
|
<a href="javascript:void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false">
|
|
<i class="mdi mdi-dots-horizontal"></i>
|
|
</a>
|
|
<div class="dropdown-menu dropdown-menu-right">
|
|
<a class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>" onclick="getLeadsDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
|
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
|
</a>
|
|
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 1; ?>" class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>">
|
|
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>RFQ
|
|
</a>
|
|
<!-- <?php if($row['qcr_count'] > 0) { ?>
|
|
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 2; ?>" class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>">
|
|
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>QCR
|
|
</a>
|
|
<?php } ?> -->
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php } else { ?>
|
|
<tr>
|
|
<td colspan="14" class="text-center">No data available</td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div><!-- end col -->
|
|
</div>
|
|
|
|
|
|
<?php include('leads_form.php'); ?>
|
|
|
|
<script>
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
const table = document.getElementById("tickets-table");
|
|
|
|
// Create custom dropdown
|
|
function createCustomDropdown(row) {
|
|
// Get the original dropdown items
|
|
const originalDropdown = row.querySelector('.dropdown-menu');
|
|
if (!originalDropdown) return null;
|
|
|
|
// Create new dropdown with proper background and spacing
|
|
const customDropdown = document.createElement('div');
|
|
customDropdown.className = 'custom-dropdown-menu';
|
|
|
|
// Copy inner content while maintaining icon alignment
|
|
customDropdown.innerHTML = originalDropdown.innerHTML;
|
|
|
|
return customDropdown;
|
|
}
|
|
|
|
let activeDropdown = null;
|
|
|
|
// Add click event listener to rows
|
|
table.querySelectorAll("tbody tr").forEach(row => {
|
|
const customDropdown = createCustomDropdown(row);
|
|
if (!customDropdown) return;
|
|
|
|
document.body.appendChild(customDropdown);
|
|
|
|
row.addEventListener("click", function(event) {
|
|
// Ignore clicks on the action column
|
|
if (event.target.closest('td:last-child')) {
|
|
return;
|
|
}
|
|
|
|
// Hide any active dropdown
|
|
if (activeDropdown) {
|
|
activeDropdown.style.display = 'none';
|
|
}
|
|
|
|
// Get click position
|
|
const rect = event.target.getBoundingClientRect();
|
|
|
|
// Position the dropdown with some offset
|
|
customDropdown.style.display = 'block';
|
|
customDropdown.style.position = 'fixed';
|
|
customDropdown.style.left = `${rect.left}px`;
|
|
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
|
|
|
|
// Set as active dropdown
|
|
activeDropdown = customDropdown;
|
|
|
|
event.stopPropagation();
|
|
});
|
|
|
|
// 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;
|
|
}
|
|
|
|
// Close the dropdown after handling the click
|
|
if (activeDropdown) {
|
|
activeDropdown.style.display = 'none';
|
|
activeDropdown = null;
|
|
}
|
|
|
|
e.stopPropagation();
|
|
});
|
|
});
|
|
});
|
|
|
|
// Close dropdown when clicking outside
|
|
document.addEventListener("click", function() {
|
|
if (activeDropdown) {
|
|
activeDropdown.style.display = 'none';
|
|
activeDropdown = null;
|
|
}
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
var client_list = ''; // local variable for storing the client branch list
|
|
var branch_list = ''; // local variable for storing the client branch list
|
|
var policy_list = ''; // local variable for storing the client policy list
|
|
|
|
|
|
// select2 document ready
|
|
$(document).ready(function(){
|
|
|
|
getClientAndBranchAndPolicy()
|
|
|
|
<?php if (session()->has('create_failed')) : ?>
|
|
toastr.error('<?= session()->getFlashdata('create_failed') ?>', 'Failed');
|
|
<?php endif; ?>
|
|
|
|
<?php if (session()->has('update_failed')) : ?>
|
|
toastr.error('<?= session()->getFlashdata('update_failed') ?>', 'Failed');
|
|
<?php endif; ?>
|
|
|
|
<?php if (session()->has('create_success')) : ?>
|
|
toastr.success('<?= session()->getFlashdata('create_success') ?>', 'Success');
|
|
<?php endif; ?>
|
|
|
|
<?php if (session()->has('update_success')) : ?>
|
|
toastr.success('<?= session()->getFlashdata('update_success') ?>', 'Success');
|
|
<?php endif; ?>
|
|
|
|
|
|
$('#client_id').select2();
|
|
$('#client_branch_id').select2();
|
|
$('#source_policy_id').select2();
|
|
$('#salse_person_id').select2({
|
|
placeholder: "Select Salse Person",
|
|
});
|
|
|
|
$('#policy_type_id').select2();
|
|
})
|
|
|
|
// Datatable document ready
|
|
$(document).ready(function() {
|
|
|
|
var ticketsTable = $('#tickets-table');
|
|
|
|
if (ticketsTable.length) {
|
|
ticketsTable.DataTable({
|
|
// scrollX: true,
|
|
dom: "<'row'<'col-sm-6'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
|
"<'row'<'col-sm-12'tr>>" +
|
|
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
|
buttons: [{
|
|
extend: 'csv',
|
|
text: 'CSV',
|
|
title: 'Policy-Tranction-Inception-List',
|
|
exportOptions: {
|
|
columns: ':not(:last-child)'
|
|
},
|
|
}, ],
|
|
language: {
|
|
search: "_INPUT_",
|
|
searchPlaceholder: "Search..."
|
|
},
|
|
paging: true, // Enable pagination
|
|
pageLength: 25, // Set default number of rows per page (optional)
|
|
// ordering: false,
|
|
});
|
|
} else {
|
|
console.error("Table not found.");
|
|
}
|
|
});
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------
|
|
|
|
function hide_list_show_add()
|
|
{
|
|
$('#leads_list').hide()
|
|
$('#leads_form').show()
|
|
}
|
|
|
|
function show_list_hide_add()
|
|
{
|
|
$('#leads_list').show()
|
|
$('#leads_form').hide()
|
|
}
|
|
|
|
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;
|
|
policy_list = res.policy_data;
|
|
appendClients(res.client_data);
|
|
}else{
|
|
console.log('No data found');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
}
|
|
|
|
function appendClients(data)
|
|
{
|
|
$('#client_id').empty();
|
|
|
|
$('#client_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Client'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.client_name,
|
|
'data-cn': item.client_name,
|
|
'data-ct': item.client_type,
|
|
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
|
|
});
|
|
|
|
$('#client_id').append(option);
|
|
});
|
|
|
|
}
|
|
|
|
function appendBranch(data)
|
|
{
|
|
|
|
$('#client_branch_id').empty();
|
|
|
|
$('#client_branch_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Branch'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.branch_name
|
|
});
|
|
$('#client_branch_id').append(option);
|
|
});
|
|
}
|
|
|
|
function appendRenewalPolicies(data)
|
|
{
|
|
console.log('appendRenewalPolicies', data);
|
|
|
|
$('#source_policy_id').empty();
|
|
|
|
$('#source_policy_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Policy',
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.policy_type + '-' + item.policy_no,
|
|
});
|
|
$('#source_policy_id').append(option);
|
|
});
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
$('#client_id').change(function(){
|
|
|
|
let client_id = $(this).val();
|
|
let client_type = $('#client_id option:selected').data('ct');
|
|
|
|
if(branch_list != '' && client_id != '') {
|
|
console.log('branch_list', branch_list[client_id]);
|
|
let data = branch_list[client_id];
|
|
appendBranch(data);
|
|
}
|
|
|
|
})
|
|
|
|
$('#client_branch_id').change(function(){
|
|
|
|
let client_branch_id = $(this).val();
|
|
|
|
if(policy_list != '' && client_branch_id != '') {
|
|
console.log('policy_list', policy_list[client_branch_id]);
|
|
let data = policy_list[client_branch_id];
|
|
appendRenewalPolicies(data);
|
|
}
|
|
|
|
})
|
|
});
|
|
|
|
//--------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
</script>
|