Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Ideas are conceptualized, no testing done yet. May the debugging
commence!
  • Loading branch information
clj13001 committed Mar 1, 2017
1 parent 44bb506 commit e2b5cf5
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 16 deletions.
2 changes: 1 addition & 1 deletion WebContent/html/webpages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2>Request</h2>
<p>Check out our selection of devices that YOU have the chance to check out!</p>
</div>
</a>
<a class = "divlink" href="returnPage.html">
<a class = "divlink" href="returnPage.jsp">
<div class = "menuOption">
<h2>Return</h2>
<p>All set with a device? No problem! You can return it here!</p>
Expand Down
37 changes: 37 additions & 0 deletions WebContent/html/webpages/returnComplete.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<%@ page import = "database.MySQLAccess,entities.RentedDevice" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
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">
<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" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<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">
</nav>
</head>
<body>
<h2>Returning Devices</h2>
<p>Thanks for returning some devices!</p>

<%
//make instance
MySQLAccess myaccess = new MySQLAccess();
//get string from request form
String devices = request.getParameter("devicesToReturn");
myaccess.returnDevices(devices);
%>
</body>
</html>
50 changes: 35 additions & 15 deletions WebContent/html/webpages/returnPage.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,22 @@
<h4>Please Review Your Return Choices</h4>
</div><br>
<div class="modal-body">
<!-- Table to display review data. -->
<table class="table table-bordered table-hover" id = "tabledisplay">
<thread>
<tr>
<th>Device Name</th>
<th>Model</th>
<th>Hardware</th>
</tr>
</thread>
<tbody id = "tablebody">
</tbody>
</table><br>
<button>Continue</button>
<!-- Table to display review data. -->
<table class="table table-bordered table-hover" id = "tabledisplay">
<thread>
<tr>
<th>Device Name</th>
<th>Model</th>
<th>Hardware</th>
</tr>
</thread>
<tbody id = "tablebody">
</tbody>
</table><br>
<form ACTION = "returnComplete.jsp" METHOD = "POST">
<input type = "text" id = "deviceArray" style = "display: none;" name = "devicesToReturn"></input>
<input type = "submit" value = "Submit">Continue</button>
</form>
</div>
</div>
</div>
Expand Down Expand Up @@ -244,15 +247,32 @@ function returnDevice()
}
//place html in body
document.getElementById("tablebody").innerHTML = html;
//show modal
//place input in form
$('#deviceArray').val(arrayToString(toReturn));
//show modal
$('#orderInfoModal').show();
}
//Call to exit modal
function hidePopup(){
$('#orderInfoModal').hide();
}
//Turns array to string, which can be submitted on the form when actually returning
//The string will contain the ID's of devices to be returned, and this will be sent to the database!
function arrayToString(array){
var sb = "["
for(var i = 0; i < array.length; i++){
//get the return id, go to that index in queried devices, and get that id!
sb+= devices[array[i]].id;
if(i != array.length-1)
sb+=","
}
sb+="]"
return sb;
}
</script>
<!-- Navbar generation. -->
<script src = "../javascript/navbar.js"></script>
</body>
</body>
</html>
21 changes: 21 additions & 0 deletions src/database/MySQLAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ public ListedDevice[] getAllDevices() throws SQLException, ClassNotFoundExceptio
return devices;
}

/**
* This function will take devices as input and return them.
* More specifically, the input will be a string that looks like an array.
* The values in this array correspond to device ID's.
* @param devices
* @throws ClassNotFoundException
* @throws SQLException
*/
public void returnDevices(String devices) throws ClassNotFoundException, SQLException{
//connect to DB
System.getenv("VCAP_SERVICES");
Class.forName("com.mysql.jdbc.Driver");
Connection connect = DriverManager.getConnection("jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317", "b372dfe7409692", "74f6e317");
Statement stmt = connect.createStatement();
//make into string array; queries need to have numbers as strings!
String[] deviceArray = devices.replaceAll("\\[","").replaceAll("\\]","").replaceAll("\\s","").split(",");
for(int i = 0; i < deviceArray.length; i++){
String current = deviceArray[i];
}
}

public String[][] getResult(){
return result;
}
Expand Down

0 comments on commit e2b5cf5

Please sign in to comment.