Однако он должен получить причину отказа от всплывающего окна и вставить его в колонку Deagement_reason и изменить статус для отклонения. Кроме того, у меня есть уведомления для консультанта, который должен обновляться соответствующим образом (при принятии/отклонении, она изменится: самоочеку с кодом). Это не работает, как это предназначено. class = "Snippet-Code-JS Lang-JS PrettyPrint-Override">
Код: Выделить всё
function toggleNotifications() {
const dropdown = document.getElementById('notificationsDropdown');
const overlay = document.getElementById('overlay');
// Toggle Dropdown Visibility
const isVisible = dropdown.style.display === 'block';
dropdown.style.display = isVisible ? 'none' : 'block';
overlay.style.display = isVisible ? 'none' : 'block';
// If opening, fetch notifications & reset unread count
if (!isVisible) {
fetch('consultant_consult.php?fetchConsultations=true')
.then(response => response.json())
.then(data => {
const notificationList = document.getElementById("notification-list");
notificationList.innerHTML = "";
if (data.error) {
notificationList.innerHTML = `
${data.error}
`;
return;
}
if (data.length === 0) {
notificationList.innerHTML = `
Nothing Here!
`;
return;
}
// Display consultations in the dropdown
data.forEach(consultation => {
const consultationHTML = `
[b]From:[/b] ${consultation.user_name}
[b]Symptoms:[/b] ${consultation.symptoms}
[b]Date:[/b] ${consultation.date} | [b]Time:[/b] ${consultation.time}
${consultation.medical_docs ? `
[url=${consultation.medical_docs}]View Medical Documents[/url]
` : ""}
Accept
Reject
`;
notificationList.innerHTML += consultationHTML;
});
// Reset unread count to zero (since the user has now read them)
unreadNotificationCount = 0;
document.getElementById("notification-count").innerText = unreadNotificationCount;
})
.catch(error => console.error("Error fetching consultations:", error));
}
}
// Fetch notification count on page load
document.addEventListener("DOMContentLoaded", fetchNotificationCount);
// Allow clicking on overlay to close the dropdown
document.getElementById('overlay').addEventListener('click', function() {
document.getElementById('notificationsDropdown').style.display = 'none';
this.style.display = 'none';
});
function processConsultation(consultationId, action) {
fetch('process_consult.php', {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: `consultation_id=${consultationId}&action=${action}`
})
.then(response => response.text())
.then(data => {
alert(data);
toggleNotifications(); // Refresh Notifications List
})
.catch(error => console.error("Error:", error));
}
// Rejection Reason and Reject System
let rejectConsultationId = null;
function openRejectionPopup(consultationId) {
rejectConsultationId = consultationId; // Store the consultation ID
document.getElementById("rejectionPopup").style.display = "flex";
}
function closeRejectionPopup() {
document.getElementById("rejectionPopup").style.display = "none";
}
function submitRejection() {
let reason = document.getElementById("rejectionReason").value.trim();
if (reason === "") {
alert("Please provide a reason for rejection.");
return;
}
fetch("process_consult.php", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: `reject=true&consultation_id=${rejectConsultationId}&rejection_reason=${encodeURIComponent(reason)}`
})
.then(response => response.text())
.then(data => {
alert(data);
closeRejectionPopup();
location.reload(); // Refresh page to update consultations
})
.catch(error => console.error("Error:", error));
}< /code>
Why are you rejecting this patient?
Reject
Cancel
process_consult.php
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/79510682/rejection-system-for-consultancy-system[/url]
Мобильная версия