Skip to content

Commit

Permalink
Ticket generation incorporates return date
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Adam Claxton authored and Adam Claxton committed Mar 23, 2017
1 parent 14a49ee commit d9b7509
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions WebContent/html/webpages/orderFormHandler.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,7 +53,7 @@ for(int i=0; i<idStringArray.length; i++)
// Now just call generateTicket once for each device
for(int i=0; i<devIDs.length; i++)
{
access.generateTicket(1, location, devIDs[i]);//TODO get ID somehow
access.generateTicket(1, location, devIDs[i], request.getParameter("timeNeeded"));//TODO get ID somehow
}
%>
</script>
Expand Down
7 changes: 4 additions & 3 deletions src/database/MySQLAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -185,15 +185,16 @@ 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 +", ";
query+= "'"+time+"'" +", ";
query+= location +", ";
query+= device +", ";
query+= "'"+stat+"'" +", ";
query+= "'"+time+"'" +");";
query+= "'"+time+"'" +",";
query+= "'"+returnDate+"'" +");";
System.out.println(query);
statement.executeUpdate(query);
statement.close();
Expand Down

0 comments on commit d9b7509

Please sign in to comment.