nhance/app/Views/leads_list.php

473 lines
17 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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;
}
.addbtnStyle{
margin-left: 20px !important;
}
/* Modeal class */
.modal-content {
border-radius: 4px;
border: 1px solid #dee2e6;
}
.modal-header {
background: #f8f9fa;
border-bottom: 1px solid #dee2e6;
padding: 1rem 1.5rem;
}
.modal-title {
font-size: 1.1rem;
font-weight: 500;
color: #495057;
}
.modal-body {
padding: 1.5rem;
}
.policy-label {
font-weight: 500;
color: #495057;
margin-bottom: 1rem;
}
.radio-option {
border: 1px solid #dee2e6;
border-radius: 4px;
padding: 0.75rem 1rem;
margin-bottom: 0.5rem;
cursor: pointer;
background: #fff;
}
.radio-option:hover {
border-color: #007bff;
background: #f8f9fa;
}
.radio-option.selected {
border-color: #007bff;
background: #e7f3ff;
}
.form-check {
margin-bottom: 0;
}
.form-check-input {
margin-right: 0.5rem;
}
.form-check-label {
cursor: pointer;
font-weight: normal;
margin-bottom: 0;
}
.modal-footer {
border-top: 1px solid #dee2e6;
padding: 1rem 1.5rem;
}
.btn {
font-size: 0.9rem;
padding: 0.5rem 1rem;
}
/* Modeal class */
</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(!in_array($row['status'], ['queued', 'rfq_created', 'rfq_sent'])) { ?>
<?php if(in_array(get_role_id(), [1, 5, 2, 3]) || in_array(BUSINESS_SUPPORT_TEAM_ID, user_team()) ) { ?>
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 2; ?>" class="dropdown-item btnEdit3" data-id="<?= $row['id']; ?>">
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>QCR
</a>
<?php } ?>
<?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">Select Leaad Type</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="radio-option selected" onclick="selectOption(this, 'lead_eb')">
<div class="form-check">
<input class="form-check-input" type="radio" name="lead_form_type" id="lead_eb" value="1" checked>
<label class="form-check-label" for="lead_eb">Lead EB</label>
</div>
</div>
<div class="radio-option" onclick="selectOption(this, 'lead_non_eb')">
<div class="form-check">
<input class="form-check-input" type="radio" name="lead_form_type" id="lead_non_eb" value="2">
<label class="form-check-label" for="lead_non_eb">Lead Non-EB</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<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-7'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)'
},
},
{
text: 'Add',
className: 'buttons-html5 addbtnStyle',
action: function (e, dt, node, config) {
openLeadTypeAskModal();
}
}
],
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()
let Lead_type = $('input[name="lead_form_type"]:checked').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>
<script>
function selectOption(element, radioId) {
// Remove selected class from all options
document.querySelectorAll('.radio-option').forEach(option => {
option.classList.remove('selected');
});
// Add selected class to clicked option
element.classList.add('selected');
// Check the corresponding radio button
document.getElementById(radioId).checked = true;
}
// Add click event to radio inputs directly
document.querySelectorAll('input[name="lead_form_type"]').forEach(radio => {
radio.addEventListener('change', function() {
// Remove selected class from all options
document.querySelectorAll('.radio-option').forEach(option => {
option.classList.remove('selected');
});
// Add selected class to parent of checked radio
this.closest('.radio-option').classList.add('selected');
});
});
</script>