349 lines
14 KiB
PHP
349 lines
14 KiB
PHP
<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="openLeadTypeAskModal();">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']; ?>" data-ft="<?= $row['lead_form_type']; ?>" onclick="getLeadsDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', '<?= htmlspecialchars($row['lead_form_type'], 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 btnEdit2" 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>
|
||
|
||
|
||
<div class="modal fade" id="New_Lead_modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myCenterModalLabel"></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="lead_form_type"> Policy Type <span class="text-danger"></span></label>
|
||
<select class="form-control" id="openLeadTypeAskModal">
|
||
<option value="1">Lead EB</option>
|
||
<option value="2">Lead Non-EB</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-primary" onclick="submitToRedirectLeadNewUrl(this)">Submit</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
|
||
document.addEventListener("DOMContentLoaded", function () {
|
||
const table = document.getElementById("tickets-table");
|
||
|
||
function createCustomDropdown(row) {
|
||
const originalDropdown = row.querySelector('.dropdown-menu');
|
||
if (!originalDropdown) return null;
|
||
|
||
const customDropdown = document.createElement('div');
|
||
customDropdown.className = 'custom-dropdown-menu';
|
||
|
||
// Clone the items but remove their original click handlers
|
||
const items = originalDropdown.querySelectorAll('.dropdown-item');
|
||
items.forEach(item => {
|
||
const newItem = item.cloneNode(true);
|
||
// Preserve the attributes but remove the onclick
|
||
newItem.removeAttribute('onclick');
|
||
customDropdown.appendChild(newItem);
|
||
});
|
||
|
||
return customDropdown;
|
||
}
|
||
|
||
let activeDropdown = null;
|
||
|
||
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;
|
||
}
|
||
|
||
if (activeDropdown) {
|
||
activeDropdown.style.display = 'none';
|
||
}
|
||
|
||
const rect = event.target.getBoundingClientRect();
|
||
|
||
customDropdown.style.display = 'block';
|
||
customDropdown.style.position = 'fixed';
|
||
customDropdown.style.left = `${rect.left}px`;
|
||
customDropdown.style.top = `${rect.bottom + 5}px`;
|
||
|
||
activeDropdown = customDropdown;
|
||
event.stopPropagation();
|
||
});
|
||
|
||
// Handle clicks on dropdown items
|
||
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
||
item.addEventListener('click', function(e) {
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
|
||
// Get the data-id and other attributes from the original button
|
||
const originalItem = row.querySelector(`.dropdown-item[data-id="${this.getAttribute('data-id')}"]`);
|
||
|
||
// For edit functionality
|
||
if (this.classList.contains('btnEdit')) {
|
||
const id = this.getAttribute('data-id');
|
||
const lead_form_type = this.getAttribute('data-ft');
|
||
console.log('second drop lead_form_type', lead_form_type)
|
||
if (id) {
|
||
getLeadsDataForEdit(id, lead_form_type);
|
||
}
|
||
}else{
|
||
const onclickAttr = this.getAttribute('onclick');
|
||
if (onclickAttr) {
|
||
eval(onclickAttr);
|
||
}
|
||
}
|
||
|
||
// For RFQ links
|
||
const href = this.getAttribute('href');
|
||
if (href && href !== '#' && !this.classList.contains('btnEdit')) {
|
||
window.location.href = href;
|
||
}
|
||
|
||
// Close the dropdown
|
||
if (activeDropdown) {
|
||
activeDropdown.style.display = 'none';
|
||
activeDropdown = null;
|
||
}
|
||
});
|
||
});
|
||
});
|
||
|
||
// Close dropdown when clicking outside
|
||
document.addEventListener("click", function() {
|
||
if (activeDropdown) {
|
||
activeDropdown.style.display = 'none';
|
||
activeDropdown = null;
|
||
}
|
||
});
|
||
});
|
||
|
||
</script>
|
||
|
||
<script>
|
||
|
||
// 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 openLeadTypeAskModal(){
|
||
var myModal = new bootstrap.Modal(document.getElementById('New_Lead_modal'));
|
||
myModal.show();
|
||
}
|
||
|
||
function submitToRedirectLeadNewUrl(){
|
||
|
||
console.log('function called')
|
||
|
||
let Lead_type = $('#openLeadTypeAskModal').val()
|
||
console.log('Lead_type ', Lead_type)
|
||
let url = '<?=base_url('/util/getLeadNonEB/')?>' + Lead_type
|
||
console.log('url ', url)
|
||
window.location.href = url;
|
||
|
||
}
|
||
|
||
function getLeadsDataForEdit(lead_id, lead_form_type){
|
||
|
||
console.log('lead_id', lead_id);
|
||
console.log('lead_form_type', lead_form_type);
|
||
|
||
let url = '<?=base_url('/util/getLeadNonEB/')?>' + lead_form_type + '/' + lead_id
|
||
console.log('url ', url)
|
||
window.location.href = url;
|
||
|
||
}
|
||
</script>
|