Skip to content

Commit

Permalink
Accept Tickets -- tickets still need to be viewable
Browse files Browse the repository at this point in the history
  • Loading branch information
Brianna authored and Brianna committed Apr 6, 2017
1 parent 4ac508d commit 8449075
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 15 deletions.
2 changes: 1 addition & 1 deletion WebContent/html/webpages/admin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ div.approveConfirm {
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<h4>Admin Options</h4>
<li class="option"><a href="../webpages/adminApprove.html">Approve Devices</a></li>
<li class="option"><a href="../webpages/adminApprove.jsp">Approve Devices</a></li>
<li class="option"><a href="#">Manage Admins</a></li>
<li class="option"><a href="#">Manage Devices</a></li>
</ul>
Expand Down
35 changes: 23 additions & 12 deletions WebContent/html/webpages/adminApprove.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<%@ page import = "database.TicketQueries" %>
<%@ 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">
Expand All @@ -22,27 +26,22 @@
background-color: #E9EAEB;
display: inline-block;
}
div.imgContainer{
display: inline-block;
text-align: center;
}
img.device{
display: block;
}
div.deviceDescp{
display: inline-block;
width: 200px;
text-align: center;
}
button.approvebutton{
display: block;
margin: auto;
}
div.approveConfirm{
display: none;
top: 50%;
Expand All @@ -57,7 +56,6 @@
border-color: #3B3C43;
border-radius: 5px;
}
div.displayDevice{
left: 0px;
}
Expand All @@ -66,18 +64,31 @@

<body>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.html"%>
</nav>

<div class = "displayDevice">
<h2>Admin View Approvals</h2>
<div id = "devContainer"></div>
<form action="approve.jsp" method="post">
<table border="0" cellpadding="10">
<thead>
<tr>
<th>Id</th>
<th>Requestor</th>
<th>Location</th>
<th>Device ID</th>
<th>Status</th>
<th>Return Date</th>
</tr>
</thead>
<tbody>
<%TicketQueries tickets = new TicketQueries();
tickets.getTickets(); %>
<input type="submit" value="approve these devices" />
<!-- need to be able to check off devices and approve just one or all at once --this is a thing for java beans -->
</form>
</div>

<div class = "approveConfirm" id = "approved">
<p>Approved!</p>
</div>

<script src="../javascript/admin.js"></script>
<script src = "../javascript/navbar.js"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions WebContent/html/webpages/approve.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<%@ page import = "database.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import = "java.sql.*" %>
<%
MySQLAccess myaccess = new MySQLAccess();
Statement statement = myaccess.getStatement();
ResultSet result = statement.executeQuery("select * FROM ticket where Status='Requested'");
if (result.next()){
statement.executeQuery("UPDATE ticket SET Status='Approved'"); //is this the right status we wanted??
myaccess.closeConnection();
response.sendRedirect("html/webpages/adminApprove.jsp");
} else {
myaccess.closeConnection();
response.sendRedirect("adminApprove.jsp");
}
%>
2 changes: 1 addition & 1 deletion WebContent/html/webpages/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../webpages/admin.jsp">
<a >
<img src="../imgs/synchrony-financial-logo-dlpx_1.png" style = "height: 100%;">
</a>
</div>
Expand Down
30 changes: 29 additions & 1 deletion src/database/TicketQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.sql.*;
import java.util.Date;
import entities.Ticket;

public class TicketQueries {

Expand All @@ -27,4 +28,31 @@ public static void generateTicket(int requester, int location, int device, Strin
statement.executeUpdate(query);
access.closeConnection();
}
}

//get all tickets
public Ticket[] getTickets() throws SQLException, ClassNotFoundException{
String status = "Requested";
int i = 0;
MySQLAccess myaccess = new MySQLAccess();
Statement statement = myaccess.getStatement();
ResultSet resultSet = statement.executeQuery("Select COUNT(Ticket_ID) FROM ticket WHERE Status = '" +status + "'");
resultSet.next();
Ticket[] tickets = new Ticket[resultSet.getInt("COUNT(Ticket_ID)")];
resultSet = statement.executeQuery("Select * FROM ticket WHERE Status = '" +status + "'");
while(resultSet.next()){
tickets[i] = new Ticket(
resultSet.getInt("Ticket_ID"),
resultSet.getInt("Requestor"),
//resultSet.getInt("Request_Date"),
resultSet.getInt("Location"),
resultSet.getInt("Device_ID"),
status,
resultSet.getString("Return_Date")
);
i++;
}
myaccess.closeConnection();
return tickets;
}
}

73 changes: 73 additions & 0 deletions src/entities/Ticket.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package entities;

import java.math.BigInteger;

//class for tickets
public class Ticket {
private int _id;
private int _requestor;
//private BigInteger _requestDate;
private int _location;
private int _deviceId;
private String _status;
private String _returnDate;

public Ticket(int id, int requestor, int location, int deviceId, String status, String returnDate){
this._id = id;
this._requestor = requestor;
//this._requestDate = requestDate;
this._location = location;
this._deviceId = deviceId;
this._status = status;
this._returnDate = returnDate;
}

public int getId(){
return _id;
}
public void setId(int id){
this._id = id;
}

public int getRequestor(){
return _requestor;
}
public void setRequestor(int requestor){
this._requestor = requestor;
}

/*public BigInteger getRequestDate(){
return _requestDate;
}
public void setRequestDate(BigInteger requestDate){
this._requestDate = requestDate;
}*/

public int getLocation(){
return _location;
}
public void setLocation(int location){
this._location = location;
}

public int getDeviceId(){
return _deviceId;
}
public void setDeviceId(int deviceId){
this._deviceId = deviceId;
}

public String getStatus(){
return _status;
}
public void setStatus(String status){
this._status = status;
}

public String getReturnDate(){
return _returnDate;
}
public void setReturnDate(String returnDate){
this._returnDate = returnDate;
}
}

0 comments on commit 8449075

Please sign in to comment.