diff --git a/admin/header.php b/admin/header.php index 020fd67..49e0e23 100644 --- a/admin/header.php +++ b/admin/header.php @@ -9,14 +9,14 @@
-
-
- - -
-
+
+
+ + +
+
diff --git a/admin/product-edit-action.php b/admin/product-edit-action.php index 62baaaf..09f9440 100644 --- a/admin/product-edit-action.php +++ b/admin/product-edit-action.php @@ -65,6 +65,7 @@ $response = editProduct( $color, $material, $size, + $priceMatrix, $token); $array = json_decode($response, true); $_SESSION['prodictId'] = $array['_id']; diff --git a/admin/product-edit.php b/admin/product-edit.php index 81cfeb2..1b25475 100644 --- a/admin/product-edit.php +++ b/admin/product-edit.php @@ -907,6 +907,33 @@ $vendorId = $_SESSION["vendorId"]; )
+ + +
+ + + + + + + + + + + $pair) : ?> + + + + + + + + +
QuantityPrice (PHP)
+ +
+ +
@@ -1021,6 +1048,100 @@ $vendorId = $_SESSION["vendorId"]; newquill.on('text-change', function() { document.getElementById('short-hidden-editor').value = newquill.root.innerHTML; }); + + // 3-20-24 raymart added function for price matrix + document.getElementById("add-row").addEventListener("click", function() { + var newRow = '' + + '' + + '' + + '' + + ''; + document.getElementById("price-matrix-body").insertAdjacentHTML('beforeend', newRow); + + var quantityInputs = document.querySelectorAll('.quantity-input'); + var lastIndex = quantityInputs.length - 1; + quantityInputs[lastIndex].addEventListener('blur', function(event) { + checkQuantity(event, lastIndex); + }); + }); + + document.getElementById("price-matrix-body").addEventListener("click", function(event) { + if (event.target.classList.contains("delete-row")) { + event.preventDefault(); + var rows = document.querySelectorAll("#price-matrix-body tr"); + if (rows.length > 1) { + event.target.closest("tr").remove(); + } else { + alert("At least one row is required."); + } + } + }); + + function checkQuantity(event, index) { + var currentInput = event.target; + var previousRow = currentInput.parentNode.parentNode.previousElementSibling; + var nextRow = currentInput.parentNode.parentNode.nextElementSibling; + + if (previousRow !== null) { + var previousQuantityInput = previousRow.querySelector('input[name="quantity[]"]'); + var currentQuantity = parseInt(currentInput.value); + var previousQuantity = parseInt(previousQuantityInput.value); + + if (currentQuantity <= previousQuantity) { + alert("Quantity must be greater than the previous row's quantity."); + currentInput.value = previousQuantity + 1; + } + } + + if (nextRow !== null) { + var nextQuantityInput = nextRow.querySelector('input[name="quantity[]"]'); + var nextQuantity = parseInt(nextQuantityInput.value); + + if (currentQuantity >= nextQuantity) { + alert("Quantity must be less than the next row's quantity."); + currentInput.value = nextQuantity - 1; + } + } + } + + function checkExistingQuantity(row) { + var currentInput = row.querySelector('input[name="quantity[]"]'); + var allRows = document.querySelectorAll("#price-matrix-body tr"); + var currentIndex = Array.from(allRows).indexOf(row); + + for (var i = currentIndex - 1; i >= 0; i--) { + var previousRow = allRows[i]; + var previousQuantityInput = previousRow.querySelector('input[name="quantity[]"]'); + var currentQuantity = parseInt(currentInput.value); + var previousQuantity = parseInt(previousQuantityInput.value); + + if (currentQuantity <= previousQuantity) { + alert("Quantity must be greater than the previous row's quantity."); + currentInput.value = previousQuantity + 1; + return; + } + } + + var nextRow = allRows[currentIndex + 1]; + if (nextRow !== undefined) { + var nextQuantityInput = nextRow.querySelector('input[name="quantity[]"]'); + var nextQuantity = parseInt(nextQuantityInput.value); + + if (currentQuantity >= nextQuantity) { + alert("Quantity must be less than the next row's quantity."); + currentInput.value = nextQuantity - 1; + return; + } + } + } + + document.getElementById("price-matrix-body").addEventListener("blur", function(event) { + if (event.target.tagName === "INPUT" && event.target.name === "quantity[]") { + checkExistingQuantity(event.target.closest("tr")); + } + }, true); + // 3-20-24 raymart added function for price matrix + +
+ + + +
+
+
+
+
+ + +
+
+ + +
+
+
+
+ + + +
+
+ + + +
+
+ + +
+
+ + +
+
+
+
+ +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + + + +
+
+ + +
+
+
+ + +
+
+ + +
+ + +
+ + + + + + + + + + + $pair) : ?> + + + + + + + + +
QuantityPrice (PHP)
+ +
+ + + +
+ +
+
+
+ style="background-color: blue;"> + +
+
+
+
+ style="background-color: blue;"> + +
+
+
+
+ style="background-color: blue;"> + +
+
+
+
+ +
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/admin/vendor-product-search.php b/admin/vendor-product-search.php index b39152a..6395c78 100644 --- a/admin/vendor-product-search.php +++ b/admin/vendor-product-search.php @@ -785,7 +785,7 @@ $vendorSearchResult = $_SESSION["vendorSearchResult"]; console.log("Session Token:", sessionToken); login(email, password, function() { // Removed the call to updateSessionToken - window.open("product-edit.php?id=" + productId, "_self"); + window.open("vendor-edit-product.php?id=" + productId, "_self"); }); }