From 9346baf9d98e1e537cf53fcce3828b105d90bed0 Mon Sep 17 00:00:00 2001 From: Sirapob Lapanakokiat <65160126@go.buu.ac.th> Date: Thu, 20 Mar 2025 12:45:47 +0700 Subject: [PATCH] Update Edit Product --- routes/products.js | 3 --- views/products.ejs | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/routes/products.js b/routes/products.js index fd5a6bc..ff91dd4 100644 --- a/routes/products.js +++ b/routes/products.js @@ -147,7 +147,6 @@ router.put('/:id', isAuthenticated, async (req, res) => { const { name, price, - stock_quantity, minimum_stock, location, category_id @@ -157,7 +156,6 @@ router.put('/:id', isAuthenticated, async (req, res) => { UPDATE products SET name = ?, price = ?, - stock_quantity = ?, minimum_stock = ?, location = ?, category_id = ? @@ -165,7 +163,6 @@ router.put('/:id', isAuthenticated, async (req, res) => { `, [ name, price, - stock_quantity, minimum_stock, location, category_id, diff --git a/views/products.ejs b/views/products.ejs index 73dde27..bee6867 100644 --- a/views/products.ejs +++ b/views/products.ejs @@ -125,7 +125,10 @@ <input type="number" id="editPrice" placeholder="ราคา" required> </div> <div class="form-row"> + <input type="number" id="editMinimumStock" placeholder="จำนวนขั้นต่ำ" required> <input type="text" id="editLocation" placeholder="ตำแหน่งจัดเก็บ"> + </div> + <div class="form-row"> <select id="editCategory" required> <option value="">เลือกหมวดหมู่</option> <% categories.forEach(category => { %> @@ -186,7 +189,6 @@ .then(product => { document.getElementById('editName').value = product.name; document.getElementById('editPrice').value = product.price; - document.getElementById('editStockQuantity').value = product.stock_quantity; document.getElementById('editMinimumStock').value = product.minimum_stock; document.getElementById('editLocation').value = product.location || ''; document.getElementById('editCategory').value = product.category_id; @@ -203,7 +205,6 @@ const data = { name: document.getElementById('editName').value, price: document.getElementById('editPrice').value, - stock_quantity: document.getElementById('editStockQuantity').value, minimum_stock: document.getElementById('editMinimumStock').value, location: document.getElementById('editLocation').value, category_id: document.getElementById('editCategory').value -- GitLab