Skip to content

Bugs #111

Merged
merged 6 commits into from
Apr 13, 2017
Merged

Bugs #111

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions WebContent/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Application Name </display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/html/webpages/error.jsp</location>
</error-page>
</web-app>
17 changes: 12 additions & 5 deletions WebContent/adminLogin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,28 @@ String pass;
Cookie adminCookie;
ssoNum = Integer.parseInt(request.getParameter("ssoNum2"));
pass = request.getParameter("pass");
MySQLAccess myaccess = new MySQLAccess();
Statement statement = myaccess.getStatement();
String database = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317";
String user = "b372dfe7409692";
String password = "74f6e317";
System.getenv("VCAP_SERVICES");
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(database, user, password);
Statement stmt = connection.createStatement();
ResultSet result;
result = statement.executeQuery("select * FROM admin where Admin_ID='" + ssoNum + "' AND Password='" + pass + "'");
result = stmt.executeQuery("select * FROM admin where Admin_ID='" + ssoNum + "' AND Password='" + pass + "'");
if (result.next()){
request.getSession();
session.setAttribute("ssoNum", ssoNum);
adminCookie = new Cookie("ssoNum", Integer.toString(ssoNum));
adminCookie.setMaxAge(30*60);
response.addCookie(adminCookie);
statement.close();
stmt.close();
connection.close();
response.sendRedirect("html/webpages/admin.jsp");
} else {
statement.close();
stmt.close();
connection.close();
response.sendRedirect("index.jsp");
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions WebContent/html/webpages/adminDeviceSettings.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,13 @@ window.onclick = function(e){var add = document.getElementById('addModal'); var
var manuHTML = '<option value="" disabled selected>Choose Manufacturer</option>';
var hardwareHTML = '<option value="" disabled selected>Choose Hardware</option>';
var availabilityHTML = '<option value="" disable selected>Choose Availability</option>';
manufacturers.sort();
for(var i = 0; i < manufacturers.length; i++)
manuHTML += '<option value="' + manufacturers[i] + '">' + manufacturers[i] + '</option>';
hardwares.sort();
for(var i = 0; i < hardwares.length; i++)
hardwareHTML += '<option value="' + hardwares[i] + '">' + hardwares[i] + '</option>';
availabilities.sort();
for(var i = 0; i < availabilities.length; i++)
availabilityHTML += '<option value="' + availabilities[i] + '">' + availabilities[i] + '</option>';
document.getElementById('addManu').innerHTML = manuHTML;
Expand Down
13 changes: 11 additions & 2 deletions WebContent/html/webpages/adminLocation.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@
<label for="modifyZip">Zip Code *</label>
<input style = "width: 100px;" name = "zip" type = "number" class="form-control" id="modifyZip" required = "true">
</div>
<button type = "submit" name = "modify" value = "Save Changes" class="btn btn-primary">Save Changes</button>
<button style = "display: inline-block;" type = "submit" name = "delete" value = "Delete Entry" class="btn btn-primary">Delete</button>
<button id = "themodifybutton" type = "submit" name = "modify" value = "Save Changes" class="btn btn-primary">Save Changes</button>
<button id = "thedeletebutton" type = "submit" name = "delete" value = "Delete Entry" class="btn btn-primary" style = "display: inline-block;" title = "hello">Delete</button>
<input type = "text" id = "modifyID" name = "id" style = "display: none;">
</form>
</div>
Expand Down Expand Up @@ -323,6 +323,15 @@ function modifyModal(){
$("#modifyState").val(locations[i].state);
$("#modifyZip").val(locations[i].zip);
$("#modifyID").val(locations[i].id);
if(locations[i].numDevices > 0 || locations[i].numEmployees > 0){
$('#thedeletebutton').attr('disabled',true);
$('#thedeletebutton').attr('title','Cannot delete because devices and/or employees are at this location!');
}
else{
$('#thedeletebutton').attr('disabled',false);
$('#thedeletebutton').removeAttr('title');
}
$("#modifyModal").show();
}
Expand Down
2 changes: 1 addition & 1 deletion WebContent/html/webpages/deviceRedirect.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<link rel = "stylesheet" type = "text/css" href = "../css/stylesheet.css">
<link rel = "shortcut icon" href = "../imgs/synchrony-financial-logo-dlpx_1.ico">
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.jsp"%>
</nav>
</head>
<body>
Expand All @@ -28,7 +29,6 @@

<%
//make instance
MySQLAccess myaccess = new MySQLAccess();
String name = request.getParameter("name").replace("\"","\\\"");
String description = request.getParameter("description").replace("\"","\\\"");
String status = request.getParameter("status");
Expand Down
40 changes: 40 additions & 0 deletions WebContent/html/webpages/error.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">

<title>Synchrony Financial</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel = "stylesheet" type = "text/css" href = "../css/stylesheet.css">
<link rel = "shortcut icon" href = "../imgs/synchrony-financial-logo-dlpx_1.ico">
<style>
div.error{
text-align: center;
position: absolute;
top: 50%;
left: 50%;
margin-top: -126px;
margin-left: -138px;
}
</style>
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.jsp"%>
</nav>
<div class = "error">
<h2>Error</h2>
<img src="../imgs/my-icons-collection-128px/png/warning.png"/>
<h2>Page Does Not Exist</h2>
</div>
</body>
</html>
6 changes: 5 additions & 1 deletion WebContent/html/webpages/locationRedirect.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ String address = request.getParameter("address").replace("\"","\\\"");
String town = request.getParameter("town").replace("\"","\\\"");
String state = request.getParameter("state");
String zip = request.getParameter("zip");
int er = 0;
//add form was submitted
if(request.getParameter("add") != null){
Location location = new Location(name,address,town,state,zip,0);
Expand All @@ -52,11 +53,14 @@ if(request.getParameter("modify") != null){
if(request.getParameter("delete") != null){
String strID = request.getParameter("id");
int id = Integer.parseInt(strID);
LocationQueries.deleteLocation(id);
er = LocationQueries.deleteLocation(id);
}
%>
<script>
if(<%=er%> == 0)
window.location.replace("adminLocation.jsp");
else
window.location.replace("somethingwrong.jsp");
</script>
<!-- Navbar generation. -->
</body>
Expand Down
31 changes: 16 additions & 15 deletions WebContent/html/webpages/navbar.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../webpages/admin.jsp">
<a class="navbar-brand" href="index.jsp">
<img src="../imgs/synchrony-financial-logo-dlpx_1.png" style = "height: 100%; display: inline-block;">
&nbsp;&nbsp;&nbsp;&nbsp;
<p style = "display: inline-block" id = "user"></p>
</a>
<a class="navbar-brand" href="profileSettings.jsp">
<p style = "display: inline-block" id = "user"></p>
</a>
</div>
<div id="navbar" class="navbar-collapse collapse" aria-expanded="false">
Expand All @@ -27,25 +28,25 @@
Cookie[] usercookies = request.getCookies();
String navsso = "invalid";
String navname = "error";
User self = new User();
Cookie newCookie;
//iterate cookies
System.out.println("Cookies:\n----------\n");
for(Cookie c : usercookies){
System.out.println(c.getName());
if(c.getName().equals("ssoNum")){//when (and if) we get to user cookie we want to reset it
navsso = c.getValue();
c.setMaxAge(0);//delete current
newCookie = new Cookie("ssoNum",navsso);//make new one
newCookie.setMaxAge(30*60);
response.addCookie(newCookie);
break;
if(usercookies != null){
for(Cookie c : usercookies){
if(c.getName().equals("ssoNum")){//when (and if) we get to user cookie we want to reset it
navsso = c.getValue();
c.setMaxAge(0);//delete current
newCookie = new Cookie("ssoNum",navsso);//make new one
newCookie.setMaxAge(30*60);
response.addCookie(newCookie);
break;
}
}
}
System.out.println("\nnavsso = "+navsso+"\n");
if(navsso.equals("invalid"))//if we didn't get a cookie, redirect to the homepage to log in again!
response.sendRedirect("../../index.jsp");
else{
User self = EmployeeQueries.getEmployeeByID(Integer.parseInt(navsso));
self = EmployeeQueries.getEmployeeByID(Integer.parseInt(navsso));
navname = self.getName();
}
%>
Expand Down
17 changes: 6 additions & 11 deletions WebContent/html/webpages/orderFormHandler.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@ pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.jsp"%>
</nav>
<script type="text/javascript">
<%
Cookie[] cookies = request.getCookies();
int sso = 0;
for(Cookie c : cookies)
{
if(c.getName().equals("ssoNum")) sso = Integer.parseInt(c.getValue());
}
// 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;
if(Integer.parseInt(request.getParameter("location_dropdown"))==0)
Expand All @@ -28,7 +23,7 @@ if(Integer.parseInt(request.getParameter("location_dropdown"))==0)
request.getParameter("address"),
request.getParameter("town"),
request.getParameter("zip"),
sso
Integer.parseInt(navsso)
);
}
Expand All @@ -38,7 +33,7 @@ String phone = request.getParameter("phone");
String email = request.getParameter("email");
// read location ID, but only if we haven't already generated it when adding new location to db
if(location==-1){ location = Integer.parseInt(request.getParameter("location_dropdown"));}
EmployeeQueries.updateEmployee(sso, userName, phone, location, email);
EmployeeQueries.updateEmployee(Integer.parseInt(navsso), userName, phone, location, email);
System.out.print("updated employee "+userName);
// And now for the ticket
Expand All @@ -59,7 +54,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++)
{
TicketQueries.generateTicket(sso, location, devIDs[i], request.getParameter("timeNeeded"));//TODO get ID somehow
TicketQueries.generateTicket(Integer.parseInt(navsso), location, devIDs[i], request.getParameter("timeNeeded"));//TODO get ID somehow
}
%>
Expand Down
1 change: 0 additions & 1 deletion WebContent/html/webpages/profileSettingsRedirect.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

<%
//make instance
MySQLAccess myaccess = new MySQLAccess();
String name = request.getParameter("name").replace("\"","\\\"");
int id = Integer.parseInt(request.getParameter("sso"));
String phone = request.getParameter("phone");
Expand Down
13 changes: 2 additions & 11 deletions WebContent/html/webpages/shoppingCart.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">

<%
Cookie[] cookies = request.getCookies();
int sso = 0;
for(Cookie c : cookies)
{
if(c.getName().equals("ssoNum")) sso = Integer.parseInt(c.getValue());
}
%>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down Expand Up @@ -85,7 +75,7 @@ if(c.getName().equals("ssoNum")) sso = Integer.parseInt(c.getValue());
</div>
<div class="form-group row">
<label for="phone">Phone Number</label><br/>
<input type="tel" class="form-control" name="phone" placeholder="203-867-5309" style="margin: 0 auto; width:60%" required>
<input type="tel" class="form-control" name="phone" placeholder="xxx-xxx-xxxx" style="margin: 0 auto; width:60%" required>
</div>
<div class="form-group row">
<label for="email">Email</label><br/>
Expand Down Expand Up @@ -354,6 +344,7 @@ function hidePopup(){
function autoFillFields(orderAllBool) {
// get employee
<%
int sso = Integer.parseInt(navsso);
User employee = EmployeeQueries.getEmployeeByID(sso);
int locationID = employee.getLocation();
String name = employee.getName();
Expand Down
40 changes: 40 additions & 0 deletions WebContent/html/webpages/somethingwrong.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">

<title>Synchrony Financial</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel = "stylesheet" type = "text/css" href = "../css/stylesheet.css">
<link rel = "shortcut icon" href = "../imgs/synchrony-financial-logo-dlpx_1.ico">
<style>
div.error{
text-align: center;
position: absolute;
top: 50%;
left: 50%;
margin-top: -126px;
margin-left: -138px;
}
</style>
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.jsp"%>
</nav>
<div class = "error">
<h2>Something Went Wrong!</h2>
<img src="../imgs/my-icons-collection-128px/png/wrong.png"/>
<h2>Try Again Later.</h2>
</div>
</body>
</html>
Loading