From d9b750941ae0b8a01752566b91eceffc9a87d603 Mon Sep 17 00:00:00 2001 From: Adam Claxton Date: Wed, 22 Mar 2017 21:08:57 -0400 Subject: [PATCH] Ticket generation incorporates return date Added Return_Date field to the ticket table. Presumably, the corresponding field will be updated in the device table when admin approves request, but for that to happen it will need to be able to read from somewhere. The 'date' selector provides dates as a simple "dd-mm-yyyy" string, so I just stored it that way. Given that it would probably be better if I just store the other dates as simple string; I will probably do that --- WebContent/html/webpages/orderFormHandler.jsp | 4 +--- src/database/MySQLAccess.java | 7 ++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/WebContent/html/webpages/orderFormHandler.jsp b/WebContent/html/webpages/orderFormHandler.jsp index 32b5f00..a7c133f 100644 --- a/WebContent/html/webpages/orderFormHandler.jsp +++ b/WebContent/html/webpages/orderFormHandler.jsp @@ -12,8 +12,6 @@ pageEncoding="ISO-8859-1"%> <% MySQLAccess access = new MySQLAccess(); -// How are dates done? -// %>alert(<%=request.getParameter("timeNeeded")%>);<% // If location id is 0, it is a custom location which must be added to the database before employee preffered location can be updated int location=-1; @@ -55,7 +53,7 @@ for(int i=0; i diff --git a/src/database/MySQLAccess.java b/src/database/MySQLAccess.java index 949af2c..a72d869 100644 --- a/src/database/MySQLAccess.java +++ b/src/database/MySQLAccess.java @@ -176,7 +176,7 @@ public Location[] getLocations(int userID) throws SQLException, ClassNotFoundExc connect.close(); return locations; } - public void generateTicket(int requester, int location, int device) throws ClassNotFoundException, SQLException + public void generateTicket(int requester, int location, int device, String returnDate) throws ClassNotFoundException, SQLException { long time = new Date().getTime(); //Using milliseconds because sql is annoying with dates. int ticketID = (int)((time+requester+device+location)%10000); @@ -185,7 +185,7 @@ public void generateTicket(int requester, int location, int device) throws Class Connection connect = DriverManager.getConnection(database,user,password); Statement statement = connect.createStatement(); String query = ""; - query+="INSERT INTO ticket (Ticket_ID, Requestor, Request_Date, Location, Device_ID, Status, Status_Date_Fields) "; + query+="INSERT INTO ticket (Ticket_ID, Requestor, Request_Date, Location, Device_ID, Status, Status_Date_Fields, Return_Date) "; query+="VALUES ("; query+= ticketID +", "; query+= requester +", "; @@ -193,7 +193,8 @@ public void generateTicket(int requester, int location, int device) throws Class query+= location +", "; query+= device +", "; query+= "'"+stat+"'" +", "; - query+= "'"+time+"'" +");"; + query+= "'"+time+"'" +","; + query+= "'"+returnDate+"'" +");"; System.out.println(query); statement.executeUpdate(query); statement.close();