diff --git a/controllers/productController.js b/controllers/productController.js index 3c632959765fe1abdd7a011acb20d47cd6ceab6a..d976f13f30e61bc1e5b86548a4830e687a79cc48 100644 --- a/controllers/productController.js +++ b/controllers/productController.js @@ -86,7 +86,7 @@ exports.updateProduct = (req, res) => { exports.deleteProduct = (req, res) => { const { id } = req.params; - // ลบสินค้าโดยตรง ไม่ต้องตรวจสอบ orders + // ลบสินค้าโดยตรงไม่ต้องตรวจสอบ orders const deleteQuery = 'DELETE FROM products WHERE id = ?'; db.query(deleteQuery, [id], (err, result) => { if (err) { diff --git a/routes/productRoutes.js b/routes/productRoutes.js index b7afb062769c530e388279f16044cf907364f22a..e548262568a4452434100d9ef8081f0dbb1b68ca 100644 --- a/routes/productRoutes.js +++ b/routes/productRoutes.js @@ -15,7 +15,7 @@ router.post('/create', productController.createProduct); router.get('/edit/:id', productController.editProductPage); // อัพเดทสินค้า -router.post('/update/:id', productController.updateProduct); +router.put('/update/:id', productController.updateProduct); // ลบสินค้า router.post('/delete/:id', productController.deleteProduct); @@ -25,5 +25,6 @@ router.get('/search', productController.searchProducts); // เบิกสินค้า router.post('/withdraw', productController.withdrawProduct); +router.post('/confirm-withdraw', productController.confirmWithdraw); module.exports = router; diff --git a/views/index.ejs b/views/index.ejs index ebe8868dfcb9a17fef5303f788566b3444991704..a4d883bed4eb25c25e57d4c1e7ec9655bbbab28f 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -45,13 +45,11 @@ <td><%= product.price %></td> <td> <div class="d-flex gap-2"> - <form action="/products/withdraw" method="POST" class="d-inline"> + <form action="/products/withdraw" method="POST" class="d-flex align-items-center gap-2"> <input type="hidden" name="product_id" value="<%= product.id %>"> - <div class="input-group input-group-sm" style="width: 150px;"> - <input type="number" name="quantity" class="form-control" - min="1" max="<%= product.quantity %>" value="1" required> - <button type="submit" class="btn btn-primary">เบิกสินค้า</button> - </div> + <input type="number" name="quantity" class="form-control form-control-sm quantity-input" + min="1" max="<%= product.quantity %>" value="1" required> + <button type="submit" class="btn btn-primary btn-sm">เบิก</button> </form> <a href="/products/edit/<%= product.id %>" class="btn btn-warning btn-sm">แก้ไข</a>