FIX_Lead History
This commit is contained in:
parent
bcaf62c12a
commit
8c4eba72a1
@ -215,8 +215,7 @@ table.dataTable tbody td {
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<a href="javascript:void(0);"
|
||||
class="dropdown-item btnHistory app-text-black"
|
||||
<a class="dropdown-item btnHistory app-text-black"
|
||||
data-id="<?= $row['id']; ?>"
|
||||
title="Click to view Mail History">
|
||||
<i class="mdi mdi-history mr-2 text-muted font-18 vertical-middle"></i>Email History
|
||||
@ -344,6 +343,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
// Handle clicks on dropdown items
|
||||
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
||||
item.addEventListener('click', function(e) {
|
||||
console.log("##############");
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
@ -358,7 +358,13 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
if (id) {
|
||||
getLeadsDataForEdit(id, lead_form_type);
|
||||
}
|
||||
}else{
|
||||
}else if (this.classList.contains('btnHistory')) {
|
||||
let lead_id = this.getAttribute('data-id');
|
||||
if(lead_id){ console.log("******** Clicked from td lead_id-", lead_id); getLeadsDataForMailHistory(lead_id); }
|
||||
else{ console.log("******** Clicked from td but i don`t have lead_id"); }
|
||||
|
||||
}
|
||||
else{
|
||||
const onclickAttr = this.getAttribute('onclick');
|
||||
if (onclickAttr) {
|
||||
eval(onclickAttr);
|
||||
@ -387,6 +393,16 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
activeDropdown = null;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("click", function(e) {
|
||||
if (e.target.closest(".btnHistory")) {
|
||||
let lead_id = e.target.closest(".btnHistory").dataset.id;
|
||||
console.log("******** in triple dot id available - " + lead_id);
|
||||
getLeadsDataForMailHistory(lead_id);
|
||||
}
|
||||
else{ console.log("******** in triple dot but id not available"); }
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -462,25 +478,21 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
window.location.href = url;
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener("click", function(e) {
|
||||
if (e.target.closest(".btnHistory")) {
|
||||
let lead_id = e.target.closest(".btnHistory").dataset.id;
|
||||
console.log("*********" + lead_id);
|
||||
function getLeadsDataForMailHistory(lead_id){
|
||||
|
||||
console.log("******** Inside Fnz :", lead_id);
|
||||
let url = '<?= base_url('/util/getLeadEmailHistory/') ?>' + lead_id;
|
||||
console.log("*********" + url);
|
||||
fetch('<?= base_url('/util/getLeadEmailHistory/') ?>' + lead_id, {
|
||||
console.log("******** Fetching:", url);
|
||||
|
||||
fetch(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
}
|
||||
headers: { "Accept": "application/json" }
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
let container = document.querySelector(".history-container");
|
||||
container.innerHTML = ""; // clear old content
|
||||
container.innerHTML = "";
|
||||
if (response.status === "success" && response.data.length > 0) {
|
||||
console.log("******** 1" + response.status);
|
||||
let table = `
|
||||
@ -576,24 +588,24 @@ document.addEventListener("click", function(e) {
|
||||
|
||||
table += `</tbody></table>`;
|
||||
container.innerHTML = table;
|
||||
// show modal (if using Bootstrap 5)
|
||||
} else {
|
||||
console.log("******** 2" + response.status);
|
||||
|
||||
container.innerHTML = `
|
||||
<div class="d-flex justify-content-center align-items-center" style="height: 50vh; width:100%;">
|
||||
<p class="text-center"><i>${response.message ?? 'No history found'}</i></p>
|
||||
<p class="text-center font-color-black"><i>${response.message ?? "No History Available"}</i></p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
// Show modal always
|
||||
new bootstrap.Modal(document.getElementById("EmailModal")).show();
|
||||
|
||||
// show modal (if using Bootstrap 5)
|
||||
let EmailModal = new bootstrap.Modal(document.getElementById("EmailModal"));
|
||||
EmailModal.show();
|
||||
})
|
||||
.catch(error => {
|
||||
console.log("******** 3" + error);
|
||||
document.querySelector(".history-container").innerHTML = `
|
||||
<div class="d-flex justify-content-center align-items-center" style="height: 50vh; width:100%;">
|
||||
<p class="text-center"><i>No Data Found</i></p>
|
||||
<p class="text-center font-color-black"><i>No Data Found</i></p>
|
||||
</div>
|
||||
`;
|
||||
let EmailModal = new bootstrap.Modal(document.getElementById("EmailModal"));
|
||||
@ -601,7 +613,6 @@ document.addEventListener("click", function(e) {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user