Fix: Update table index references for user status and quota in edit user modal

This commit is contained in:
Seyed Mahdi
2025-04-09 18:55:25 +03:30
parent f17ab3aa19
commit e38bb4f864

View File

@ -311,10 +311,10 @@
showRow = $(this).find("td:eq(1) i").hasClass("text-danger"); showRow = $(this).find("td:eq(1) i").hasClass("text-danger");
break; break;
case "enable": case "enable":
showRow = $(this).find("td:eq(7) i").hasClass("text-success"); showRow = $(this).find("td:eq(6) i").hasClass("text-success");
break; break;
case "disable": case "disable":
showRow = $(this).find("td:eq(7) i").hasClass("text-danger"); showRow = $(this).find("td:eq(6) i").hasClass("text-danger");
break; break;
} }
@ -456,14 +456,14 @@
$(document).on("click", ".edit-user", function () { $(document).on("click", ".edit-user", function () {
const username = $(this).data("user"); const username = $(this).data("user");
const row = $(this).closest("tr"); const row = $(this).closest("tr");
const quota = row.find("td:eq(3)").text().trim(); const quota = row.find("td:eq(3)").text().trim(); // Now refers to Traffic Usage
const expiry = row.find("td:eq(5)").text().trim(); // Get expiry from the table const expiry = row.find("td:eq(4)").text().trim(); // Now expiry date is at index 4
const expiry_days = row.find("td:eq(6)").text().trim(); const expiry_days = row.find("td:eq(5)").text().trim(); // Now expiry days is at index 5
const blocked = row.find("td:eq(7)").text().trim().toLowerCase() === 'disabled'; // Check if 'disabled' const blocked = row.find("td:eq(6) i").hasClass("text-danger"); // Now Enable column is at index 6
// Extract numeric values from quota and expiry strings // Extract quota value from the combined format like "1.25 GB/10.00 GB (12.5%)"
const quotaValue = parseFloat(quota); const quotaMatch = quota.match(/\/\s*([\d.]+)/);
const expiryValue = parseInt(expiry); // Parse expiry as integer const quotaValue = quotaMatch ? parseFloat(quotaMatch[1]) : 0;
// Populate the modal fields // Populate the modal fields
$("#originalUsername").val(username); $("#originalUsername").val(username);