Skip to content
Snippets Groups Projects
Commit fe580422 authored by Moss's avatar Moss
Browse files

[frontend/backend] coded functionality into buttons for viewing Transactions...

[frontend/backend] coded functionality into buttons for viewing Transactions based on filtered elements
parent 49107d0b
No related branches found
No related tags found
1 merge request!21UC39
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
<%@page import="java.util.List"%> <%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%> <%@page import="java.util.ArrayList"%>
<%@page import="java.util.Iterator"%> <%@page import="java.util.Iterator"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.sql.Timestamp"%>
<%@page import="edu.ncsu.csc.itrust.exception.FormValidationException"%> <%@page import="edu.ncsu.csc.itrust.exception.FormValidationException"%>
<%@page import="edu.ncsu.csc.itrust.enums.TransactionType"%> <%@page import="edu.ncsu.csc.itrust.enums.TransactionType"%>
<%@page import="edu.ncsu.csc.itrust.dao.DAOFactory"%> <%@page import="edu.ncsu.csc.itrust.dao.DAOFactory"%>
...@@ -27,55 +31,28 @@ String view = request.getParameter("viewSelect"); ...@@ -27,55 +31,28 @@ String view = request.getParameter("viewSelect");
<%@include file="/header.jsp" %> <%@include file="/header.jsp" %>
<% <%
//loggingAction.logEvent(TransactionType.typeofaction, loggedInMID.longValue(), 0, "View Transaction Logs");
//CauseOfDeathTrendsReportDAO report = new CauseOfDeathTrendsReportDAO(prodDAO);
//List<CauseOfDeathTrendsReportBean> allDeaths = null;
//get form data //get form data
long mid = Long.valueOf(request.getUserPrincipal().getName()); long mid = Long.valueOf(request.getUserPrincipal().getName());
String startDate = request.getParameter("startDate"); String startDate = request.getParameter("startDate");
String endDate = request.getParameter("endDate"); String endDate = request.getParameter("endDate");
String mainRole = request.getParameter("mainRole");
String secondRole = request.getParameter("secondRole");
String transactionType = request.getParameter("transactionType");
String convertedDate = request.getParameter("convertedDate");
SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
String formatted = df.format(new Date());
String gender = request.getParameter("gender");
String patients = request.getParameter("patients");
if (patients == null)
patients = "";
//try to get the report. If there's an error, print it. If null is returned, it's the first page load
/*
if(patients.equalsIgnoreCase("My Patients")) {
try {
allDeaths = report.getTopTwoDeathsForHCP(mid, gender, startDate, endDate);
} catch(FormValidationException e){
e.printHTML(pageContext.getOut());
}
}
if(patients.equalsIgnoreCase("All Patients") || patients.equalsIgnoreCase("")) {
try {
allDeaths = report.getTopTwoDeathsForAll(gender, startDate, endDate);
} catch(FormValidationException e){
e.printHTML(pageContext.getOut());
}
}
if (gender == null)
gender = "";
if (startDate == null) if (startDate == null)
startDate = ""; startDate = "01/01/2000";
if (endDate == null) if (endDate == null)
endDate = ""; endDate = formatted;
*/
%> %>
<br /> <br />
<form action="causeOfDeathTrendsReport.jsp" method="post" id="formMain"> <form action="viewTransactionLogs.jsp" method="post" id="formMain">
<input type="hidden" name="viewSelect" /> <input type="hidden" name="viewSelect" />
<table class="fTable" align="center" id="causeOfDeathTrendsReportTable"> <table class="fTable" align="center" id="transactionLogsTable">
<tr> <tr>
<th colspan="4">View Transaction Logs</th> <th colspan="4">View Transaction Logs</th>
</tr> </tr>
...@@ -99,7 +76,7 @@ String view = request.getParameter("viewSelect"); ...@@ -99,7 +76,7 @@ String view = request.getParameter("viewSelect");
<option value="All"> All</option> <option value="All"> All</option>
<% <%
for(Role type : Role.values()){ for(Role type : Role.values()){
%><option value=type.getUserRolesString()><%=type.getUserRolesString()%></option><% %><option value="<%= StringEscapeUtils.escapeHtml("" + (type.getUserRolesString()))%>"><%=type.getUserRolesString()%></option><%
} }
%> %>
...@@ -112,7 +89,7 @@ String view = request.getParameter("viewSelect"); ...@@ -112,7 +89,7 @@ String view = request.getParameter("viewSelect");
<option value="All"> All</option> <option value="All"> All</option>
<% <%
for(Role type : Role.values()){ for(Role type : Role.values()){
%><option value=type.getUserRolesString()><%=type.getUserRolesString()%></option><% %><option value="<%= StringEscapeUtils.escapeHtml("" + (type.getUserRolesString()))%>"><%=type.getUserRolesString()%></option><%
} }
%> %>
...@@ -129,7 +106,7 @@ String view = request.getParameter("viewSelect"); ...@@ -129,7 +106,7 @@ String view = request.getParameter("viewSelect");
<option value="All"> All</option> <option value="All"> All</option>
<% <%
for(TransactionType type : TransactionType.values()){ for(TransactionType type : TransactionType.values()){
%><option value=type.name()><%=type.name()%></option><% %><option value="<%= StringEscapeUtils.escapeHtml("" + (type.name()))%>"><%=type.name()%></option><%
} }
%> %>
...@@ -140,10 +117,10 @@ String view = request.getParameter("viewSelect"); ...@@ -140,10 +117,10 @@ String view = request.getParameter("viewSelect");
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="1" style="text-align: center;"><input type="submit" id="view_report" value="View Report"></td> <td colspan="1" style="text-align: center;"><input type="submit" id="view_report" value="View Report" onclick="viewSelect='showList'"></td>
<td colspan="1" style="text-align: center;"><input type="submit" id="view_graph" value="Summarize"></td> <td colspan="1" style="text-align: center;"><input type="submit" id="view_graph" value="Summarize"></td>
<td> </td> <td> </td>
<td colspan="1" style="text-align: center;"><input type="submit" id="view_reset" value="Reset"></td> <td colspan="1" style="text-align: center;"><input type="submit" id="view_reset" onclick="window.location.reload();" value="Reset"></td>
</tr> </tr>
...@@ -154,9 +131,9 @@ String view = request.getParameter("viewSelect"); ...@@ -154,9 +131,9 @@ String view = request.getParameter("viewSelect");
<br /> <br />
<%-- <% if (clickedButton != null) { %> --%> <% if (view != null) { %>
<table border=1> <table border=1 align="center">
<tr> <tr>
<th>Main Role</th> <th>Main Role</th>
<th>Secondary Role</th> <th>Secondary Role</th>
...@@ -166,22 +143,47 @@ String view = request.getParameter("viewSelect"); ...@@ -166,22 +143,47 @@ String view = request.getParameter("viewSelect");
</tr> </tr>
<% <%
List<TransactionWithRoleBean> list = DAOFactory.getProductionInstance().getTransactionDAO().getAllTransactionsWithRoles(); List<TransactionWithRoleBean> list = DAOFactory.getProductionInstance().getTransactionDAO().getAllTransactionsWithRoles();
for (TransactionWithRoleBean t : list) { SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
Date convertedSimpleDate = null;
Date startSimpleDate = null;
Date endSimpleDate = null;
if(startDate != ""){
startSimpleDate = sdf.parse(startDate);
}
if(endDate != ""){
endSimpleDate = sdf.parse(endDate);
}
for (TransactionWithRoleBean t : list) {
convertedSimpleDate = sdf.parse(StringEscapeUtils.escapeHtml("" + (t.getConvertedDate())));
if(StringEscapeUtils.escapeHtml("" + (t.getMainRole())).equals(StringEscapeUtils.escapeHtml(mainRole))
|| StringEscapeUtils.escapeHtml(mainRole).equals("All")){
if(StringEscapeUtils.escapeHtml("" + (t.getSecondaryRole())).equals(StringEscapeUtils.escapeHtml(secondRole))
|| StringEscapeUtils.escapeHtml(secondRole).equals("All")){
if(StringEscapeUtils.escapeHtml("" + (t.getTransactionType().name())).equals(StringEscapeUtils.escapeHtml(transactionType)) || StringEscapeUtils.escapeHtml(transactionType).equals("All")){
if((convertedSimpleDate.before(endSimpleDate) || convertedSimpleDate.equals(endSimpleDate)) && (convertedSimpleDate.after(startSimpleDate) || convertedSimpleDate.equals(startSimpleDate))){
%> %>
<tr> <tr>
<td><%= StringEscapeUtils.escapeHtml("" + (t.getMainRole())) %></td> <td><%= StringEscapeUtils.escapeHtml("" + (t.getMainRole())) %></td>
<td><%= StringEscapeUtils.escapeHtml("" + (t.getSecondaryRole())) %></td> <td><%= StringEscapeUtils.escapeHtml("" + (t.getSecondaryRole())) %></td>
<td><%= StringEscapeUtils.escapeHtml("" + (t.getTransactionType().name())) %></td> <td><%= StringEscapeUtils.escapeHtml("" + (t.getTransactionType().name())) %></td>
<td><%= StringEscapeUtils.escapeHtml("" + (t.getAddedInfo())) %></td> <td><%= StringEscapeUtils.escapeHtml("" + (t.getAddedInfo())) %></td>
<td><%= StringEscapeUtils.escapeHtml("" + (t.getTimeLogged())) %></td> <td><%= StringEscapeUtils.escapeHtml("" + (t.getTimeLogged())) %></td>
</tr> </tr>
<% <%
}
}
}
}
} }
%> %>
</table> </table>
<%-- <% } %> --%> <% } %>
<br /> <br />
<%@include file="/footer.jsp" %> <%@include file="/footer.jsp" %>
\ No newline at end of file
...@@ -21,7 +21,7 @@ public class TransactionWithRoleBean { ...@@ -21,7 +21,7 @@ public class TransactionWithRoleBean {
private TransactionType transactionType; private TransactionType transactionType;
private Timestamp timeLogged; private Timestamp timeLogged;
private String addedInfo; private String addedInfo;
// private String role; private String convertedDate;
public TransactionWithRoleBean() { public TransactionWithRoleBean() {
} }
...@@ -89,4 +89,12 @@ public class TransactionWithRoleBean { ...@@ -89,4 +89,12 @@ public class TransactionWithRoleBean {
public void setTransactionID(long transactionID) { public void setTransactionID(long transactionID) {
this.transactionID = transactionID; this.transactionID = transactionID;
} }
public String getConvertedDate() {
return convertedDate;
}
public void setConvertedDate(String convertedDate) {
this.convertedDate = convertedDate;
}
} }
...@@ -39,6 +39,7 @@ public class TransactionBeanWithRoleLoader implements BeanLoader<TransactionWith ...@@ -39,6 +39,7 @@ public class TransactionBeanWithRoleLoader implements BeanLoader<TransactionWith
t.setTimeLogged(rs.getTimestamp("timeLogged")); t.setTimeLogged(rs.getTimestamp("timeLogged"));
t.setTransactionType(TransactionType.parse(rs.getInt("transactionCode"))); t.setTransactionType(TransactionType.parse(rs.getInt("transactionCode")));
t.setTransactionID(rs.getLong("transactionID")); t.setTransactionID(rs.getLong("transactionID"));
t.setConvertedDate(rs.getString("convertedDate"));
return t; return t;
} }
......
...@@ -87,14 +87,14 @@ public class TransactionDAO { ...@@ -87,14 +87,14 @@ public class TransactionDAO {
try { try {
conn = factory.getConnection(); conn = factory.getConnection();
ps = conn.prepareStatement( ps = conn.prepareStatement(
"SELECT users.Role mainRole, u2.Role secondaryRole,t.transactionID,t.loggedInMID,t.secondaryMID,t.transactionCode,t.timeLogged,t.addedInfo FROM users, transactionlog t, users u2 WHERE t.loggedinMID = users.MID and t.secondaryMID = u2.MID ORDER BY timeLogged DESC"); "SELECT users.Role mainRole, u2.Role secondaryRole,t.transactionID,t.loggedInMID,t.secondaryMID,t.transactionCode,t.timeLogged,t.addedInfo, DATE_FORMAT(timeLogged,'%m/%d/%Y') convertedDate FROM users, transactionlog t, users u2 WHERE t.loggedinMID = users.MID and t.secondaryMID = u2.MID ORDER BY timeLogged DESC");
ResultSet rs = ps.executeQuery(); ResultSet rs = ps.executeQuery();
List<TransactionWithRoleBean> loadlist = loaderWithRole.loadList(rs); List<TransactionWithRoleBean> loadlist = loaderWithRole.loadList(rs);
rs.close(); rs.close();
ps.close(); ps.close();
return loadlist; return loadlist;
} catch (SQLException e) { } catch (SQLException e) {
throw new DBException(e); throw new DBException(e);
} finally { } finally {
DBUtil.closeConnection(conn, ps); DBUtil.closeConnection(conn, ps);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment