This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from hardingadonis/dev
Sale Dock - v0.5.0
- Loading branch information
Showing
53 changed files
with
1,455 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/bin/bash | ||
|
||
major_version=0 | ||
minor_version=4 | ||
minor_version=5 | ||
path_version=0 | ||
|
||
echo "$major_version.$minor_version.$path_version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 46 additions & 1 deletion
47
src/main/java/io/hardingadonis/saledock/controller/management/order/AddOrderServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,65 @@ | ||
package io.hardingadonis.saledock.controller.management.order; | ||
|
||
import java.io.*; | ||
import io.hardingadonis.saledock.model.*; | ||
import io.hardingadonis.saledock.utils.*; | ||
import jakarta.servlet.*; | ||
import jakarta.servlet.annotation.*; | ||
import jakarta.servlet.http.*; | ||
import java.io.*; | ||
|
||
@WebServlet(name = "AddOrderServlet", urlPatterns = {"/add-order"}) | ||
public class AddOrderServlet extends HttpServlet { | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
request.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/html; charset=UTF-8"); | ||
|
||
request.setAttribute("page", "order"); | ||
|
||
RequestDispatcher requestDispatcher = request.getRequestDispatcher("/view/jsp/management/order/add-order.jsp"); | ||
requestDispatcher.forward(request, response); | ||
} | ||
|
||
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
String customerID = request.getParameter("customerID"); | ||
String productID = request.getParameter("productID"); | ||
String quantity = request.getParameter("quantity"); | ||
|
||
if (customerID == null || productID == null || quantity == null) { | ||
response.sendError(404, "Please provide Customer ID, Product ID and Quantity"); | ||
return; | ||
} | ||
|
||
Integer id_customer = Integer.valueOf(customerID); | ||
Integer id_product = Integer.valueOf(productID); | ||
|
||
Customer customer = Singleton.customerDAO.getByID(id_customer).orElse(null); | ||
Product product = Singleton.productDAO.getByID(id_product).orElse(null); | ||
HttpSession session = request.getSession(); | ||
Employee employee = (Employee) session.getAttribute("employee"); | ||
|
||
// Check if an employee is logged in | ||
if (employee == null) { | ||
response.sendRedirect(request.getContextPath() + "/login?message=notLoggedIn"); | ||
return; | ||
} | ||
|
||
if (customer == null || product == null) { | ||
response.sendError(404, "Please provide correct Customer ID and Product ID"); | ||
return; | ||
} | ||
|
||
Order order = new Order(); | ||
order.setCustomer(customer); | ||
order.setEmployee(employee); | ||
|
||
order.addProduct(product, Integer.valueOf(quantity)); | ||
|
||
Singleton.orderDAO.save(order); | ||
response.sendRedirect(request.getContextPath() + "/order"); | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/main/java/io/hardingadonis/saledock/controller/management/order/DetailOrderServlet.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
src/main/java/io/hardingadonis/saledock/controller/management/order/OrderDetailServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.hardingadonis.saledock.controller.management.order; | ||
|
||
import io.hardingadonis.saledock.model.*; | ||
import io.hardingadonis.saledock.utils.*; | ||
import java.io.*; | ||
import jakarta.servlet.*; | ||
import jakarta.servlet.annotation.*; | ||
import jakarta.servlet.http.*; | ||
import java.util.Optional; | ||
|
||
@WebServlet(name = "OrderDetailServlet", urlPatterns = {"/order-detail"}) | ||
public class OrderDetailServlet extends HttpServlet { | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
request.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/html; charset=UTF-8"); | ||
|
||
request.setAttribute("page", "order"); | ||
|
||
String id = request.getParameter("id"); | ||
if (id == null) { | ||
response.sendError(404); | ||
return; | ||
} | ||
|
||
Integer id_order = Integer.parseInt(id); | ||
Optional<Order> order = Singleton.orderDAO.getByID(id_order); | ||
|
||
if (order.isPresent()) { | ||
var ord = order.get(); | ||
request.setAttribute("ord", ord); | ||
|
||
request.getRequestDispatcher("/view/jsp/management/order/order-detail.jsp").forward(request, response); | ||
} else { | ||
response.sendRedirect(request.getContextPath() + "/order"); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
} | ||
} |
13 changes: 12 additions & 1 deletion
13
src/main/java/io/hardingadonis/saledock/controller/management/order/OrderServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.