diff --git a/src/main/java/io/hardingadonis/saledock/controller/management/customer/UpdateCustomerServlet.java b/src/main/java/io/hardingadonis/saledock/controller/management/customer/UpdateCustomerServlet.java index e1b4e9c..5a6ebef 100644 --- a/src/main/java/io/hardingadonis/saledock/controller/management/customer/UpdateCustomerServlet.java +++ b/src/main/java/io/hardingadonis/saledock/controller/management/customer/UpdateCustomerServlet.java @@ -58,11 +58,11 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) Integer id_customer = Integer.valueOf(id); Customer customer = Singleton.customerDAO.getByID(id_customer).get(); - if (!name.isEmpty()) { - customer.setName(name); + if (!name.trim().isEmpty()) { + customer.setName(name.trim()); } - if (!address.isEmpty()) { - customer.setAddress(address); + if (!address.trim().isEmpty()) { + customer.setAddress(address.trim()); } Singleton.customerDAO.save(customer); response.sendRedirect(request.getContextPath() + "/customer-detail?id="+id); diff --git a/src/main/java/io/hardingadonis/saledock/controller/management/order/UpdateOrderServlet.java b/src/main/java/io/hardingadonis/saledock/controller/management/order/UpdateOrderServlet.java index 893ff6f..e4b1521 100644 --- a/src/main/java/io/hardingadonis/saledock/controller/management/order/UpdateOrderServlet.java +++ b/src/main/java/io/hardingadonis/saledock/controller/management/order/UpdateOrderServlet.java @@ -10,6 +10,7 @@ @WebServlet(name = "UpdateOrderServlet", urlPatterns = {"/update-order"}) public class UpdateOrderServlet extends HttpServlet { + @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { @@ -43,26 +44,27 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) String ID = request.getParameter("id"); Order order = Singleton.orderDAO.getByID(Integer.valueOf(ID)).orElse(null); - + String status = request.getParameter("status"); - - - if (status != null && !status.equals(order.getStatus()) ) { - - order.setStatus(Order.Status.valueOf(status)); - Singleton.orderDAO.save(order); + String note = request.getParameter("note"); - response.sendRedirect("./order"); - return; - } - else { - response.sendRedirect("./order"); - return; + if (status != null && !status.equals(order.getStatus())) { + + order.setStatus(Order.Status.valueOf(status)); + + } + if(!note.trim().isEmpty()){ + order.setNote(note.trim()); } + Singleton.orderDAO.save(order); + + response.sendRedirect(request.getContextPath() + "/order-detail?id=" + ID); +// else { +// response.sendRedirect(request.getContextPath() + "/order-detail?id=" + ID); +// return; +// } + } - - - - + } diff --git a/src/main/webapp/view/jsp/management/order/update-order.jsp b/src/main/webapp/view/jsp/management/order/update-order.jsp index d937ac6..c9c5384 100644 --- a/src/main/webapp/view/jsp/management/order/update-order.jsp +++ b/src/main/webapp/view/jsp/management/order/update-order.jsp @@ -169,7 +169,10 @@