Skip to content

Bugs #142

Merged
merged 2 commits into from
Apr 19, 2017
Merged

Bugs #142

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
54 changes: 54 additions & 0 deletions WebContent/html/webpages/redirect/createProfile.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<%@ page import = "database.*,entities.Device" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 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">
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<div class="container-fluid"><div class="navbar-header"><button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="../index.jsp"><img src="../imgs/synchrony-financial-logo-dlpx_1.png" style = "height: 100%;"></a></div><div id="navbar" class="navbar-collapse collapse" aria-expanded="false"><ul class="nav navbar-nav navbar-right"><li><a href="../index.jsp">Synchrony Device Request System</a></li></ul></div></div>
</nav>
</head>
<body>
<h2>Redirect Page</h2>
<p>You shouldn't be seeing this page :)</p>

<%
//make instance
Cookie userCookie,newCookie;
String sso = request.getParameter("sso");
String name = request.getParameter("name");
String loc = request.getParameter("loc");
String ph = request.getParameter("ph");
String email = request.getParameter("email");
//form was submitted
if(request.getParameter("submit") != null){
EmployeeQueries.addEmployee(sso,loc,name,ph,email);
request.getSession();
session.setAttribute("ssoNum", sso);
userCookie = new Cookie("ssoNum", sso);
userCookie.setMaxAge(30*60);
userCookie.setPath("/");
response.addCookie(userCookie);
newCookie = new Cookie("name",name);
newCookie.setMaxAge(30*60);
newCookie.setPath("/");
response.addCookie(newCookie);
response.sendRedirect("../index.jsp");
}
%>
</body>
</html>
108 changes: 108 additions & 0 deletions WebContent/html/webpages/userLogin.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<%@ page import = "database.*,entities.Location" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import = "java.sql.*" %>
<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>
input.form-control{
width: 200px;
}
</style>
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<div class="container-fluid"><div class="navbar-header"><button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="../index.jsp"><img src="../imgs/synchrony-financial-logo-dlpx_1.png" style = "height: 100%;"></a></div><div id="navbar" class="navbar-collapse collapse" aria-expanded="false"><ul class="nav navbar-nav navbar-right"><li><a href="../index.jsp">Synchrony Device Request System</a></li></ul></div></div>
</nav>
<!-- Form information where user changes password -->
<div id = "newuser" style = "margin-left: 30px; visibility: hidden;">
<!-- Where main user information is edited -->
<form action = "redirect/createProfile.jsp" class = "infobar">
<h2>Create Your Account</h2>
<h3>Since this is your first time accessing the system, please provide some important information!</h3>
<div class = "form-group">
<label for="sso">SSO Number *</label>
<input name = "sso" class="form-control" id="sso" required = "true" placeholder = "9 digit SSO">
</div>
<div class = "form-group">
<label for="name">Full Name *</label>
<input name = "name" class="form-control" id="name" required = "true" placeholder = "Full Name">
</div>
<div class = "form-group">
<label for="loc">Home Location *</label>
<select required style = "width: 200px; margin: 0;" name = "loc" class="form-control" id="loc">
</select>
</div>
<div class = "form-group">
<label for="ph">Phone Number *</label>
<input name = "ph" type = "tel" class="form-control" id="ph" required = "true" placeholder = "(xxx) xxx-xxxx">
</div>
<div class = "form-group">
<label for="email">Email *</label>
<input name = "email" type = "email" class="form-control" id="email" required = "true" placeholder = "email@email.com">
</div>
<button name = "submit" type="submit" class="btn btn-primary" id = "submit">Create Profile</button>
</form>
</div>
</body>
</html>
<%
Cookie userCookie,newCookie;
int ssoNum = Integer.parseInt(request.getParameter("username"));
Class.forName("com.mysql.jdbc.Driver");
String database = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317";
String user = "b372dfe7409692";
String password = "74f6e317";
Connection connection = DriverManager.getConnection(database, user, password);
Statement stmt = connection.createStatement();
ResultSet result;
result = stmt.executeQuery("select * FROM employee where Employee_ID='" + ssoNum + "'");
if (result.next()){
request.getSession();
session.setAttribute("ssoNum", ssoNum);
userCookie = new Cookie("ssoNum", Integer.toString(ssoNum));
userCookie.setMaxAge(30*60);
userCookie.setPath("/");
response.addCookie(userCookie);
newCookie = new Cookie("name",result.getString("Name"));
newCookie.setMaxAge(30*60);
newCookie.setPath("/");
response.addCookie(newCookie);
stmt.close();
connection.close();
response.sendRedirect("index.jsp");
}
connection.close();
stmt.close();
String locations = Location.arrayToString(LocationQueries.getLocations(ssoNum));
%>

<script>
var locations = JSON.parse('<%=locations%>');
var locationHTML = '<option value="" disabled selected>Choose Location</option>';
for(var i = 0; i < locations.length; i++){
locationHTML += '<option value="' + locations[i].id + '">' + locations[i].name + '</option>';
}
document.getElementById('loc').innerHTML = locationHTML;
$("#sso").val(<%=ssoNum%>);
$("#loc").val(1);
document.getElementById('newuser').style.visibility='visible';
</script>
2 changes: 1 addition & 1 deletion WebContent/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<div>
<div class = "menuOption">
<h2>User Login</h2>
<form action="userLogin.jsp" method="post">
<form action="html/webpages/userLogin.jsp" method="post">
<input class = "form-control" type="text" pattern="[0-9]{9}" name="username" placeholder="9 digit SSO Number" /><br>
<button type = "submit" value = "Add" class="btn btn-primary">Login</button>
</form>
Expand Down
39 changes: 0 additions & 39 deletions WebContent/userLogin.jsp

This file was deleted.

10 changes: 10 additions & 0 deletions src/database/EmployeeQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ public static void initializeEmployee(int id) throws ClassNotFoundException, SQL
stmt.close();
connection.close();
}

public static void addEmployee(String sso, String loc, String name, String ph, String email) throws SQLException, ClassNotFoundException{
System.getenv("VCAP_SERVICES");
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(database, user, password);
Statement stmt = connection.createStatement();
stmt.executeUpdate("INSERT INTO employee (Employee_ID,Location_ID,Name,Phone_Number,Email) VALUES ("+Integer.parseInt(sso)+", " + Integer.parseInt(loc) + ", \"" + name + "\", \"" + ph + "\", \"" + email + "\");");
stmt.close();
connection.close();
}

public static void updateEmployee(int id, String name, String phone, int location, String email) throws ClassNotFoundException, SQLException
{
Expand Down