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

[frontend] fixed reset button to work now

parent 234f3ee1
No related branches found
No related tags found
1 merge request!21UC39
...@@ -103,100 +103,104 @@ String view = request.getParameter("viewSelect"); ...@@ -103,100 +103,104 @@ String view = request.getParameter("viewSelect");
<td colspan="1" style="text-align: center;"><input type="submit" id="viewReport" value="View Report" onclick="viewSelect='showList'"></td> <td colspan="1" style="text-align: center;"><input type="submit" id="viewReport" value="View Report" onclick="viewSelect='showList'"></td>
<td colspan="1" style="text-align: center;"><input type="submit" id="viewGraph" value="Summarize"></td> <td colspan="1" style="text-align: center;"><input type="submit" id="viewGraph" value="Summarize"></td>
<td> </td> <td> </td>
<td colspan="1" style="text-align: center;"><input type="submit" id="viewReset" onclick="window.location.reload();" value="Reset"></td> <td colspan="1" style="text-align: center;"><button><a href="viewTransactionLogs.jsp?reset=true" style="text-decoration:none; padding: 0.4em;color:black;">Reset</a></button></td>
</tr> </tr>
</table> </table>
</form> </form>
<br /> <br />
<%
<% if (view != null) { %> String resetCheck = null;
if(request.getParameter("reset")!= null){
resetCheck = request.getParameter("reset");
}
<table border=1 align="center"> if (view != null && resetCheck != "true") { %>
<table border=1 align="center">
<% <%
List<TransactionWithRoleBean> list = DAOFactory.getProductionInstance().getTransactionDAO().getAllTransactionsWithRoles();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
Date convertedSimpleDate = null;
Date startSimpleDate = null;
Date endSimpleDate = null;
List<TransactionWithRoleBean> list = DAOFactory.getProductionInstance().getTransactionDAO().getAllTransactionsWithRoles(); if(startDate != ""){
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); startSimpleDate = sdf.parse(startDate);
Date convertedSimpleDate = null; }
Date startSimpleDate = null; else{
Date endSimpleDate = null; startSimpleDate = sdf.parse("01/01/2000");
}
if(startDate != ""){ if(endDate != ""){
startSimpleDate = sdf.parse(startDate); endSimpleDate = sdf.parse(endDate);
} }
else{ else{
startSimpleDate = sdf.parse("01/01/2000"); endSimpleDate = sdf.parse(formatted);
} }
if(endDate != ""){
endSimpleDate = sdf.parse(endDate);
}
else{
endSimpleDate = sdf.parse(formatted);
}
boolean dateFormatError = false; boolean dateFormatError = false;
String regex = "^(1[0-2]|0[1-9])/(3[01]|[12][0-9]|0[1-9])/[0-9]{4}$"; String regex = "^(1[0-2]|0[1-9])/(3[01]|[12][0-9]|0[1-9])/[0-9]{4}$";
boolean result = (startDate.matches(regex)||startDate.equals("")) && (endDate.matches(regex)||endDate.equals("")); boolean result = (startDate.matches(regex)||startDate.equals("")) && (endDate.matches(regex)||endDate.equals(""));
if(!result) { if(!result) {
dateFormatError = true; dateFormatError = true;
%> %>
<span class="iTrustError">ERROR: Date must by in the format: MM/dd/yyyy</span> <span class="iTrustError">ERROR: Date must by in the format: MM/dd/yyyy</span>
<% <%
} }
else if(endSimpleDate.before(startSimpleDate)){ else if(endSimpleDate.before(startSimpleDate)){
dateFormatError = true; dateFormatError = true;
%> %>
<span class="iTrustError">ERROR: End Date cannot be before Start Date</span> <span class="iTrustError">ERROR: End Date cannot be before Start Date</span>
<% <%
} }
int countEntries = 0; int countEntries = 0;
if(!dateFormatError){ if(!dateFormatError){
%> %>
<tr> <tr>
<th>Main Role</th> <th>Main Role</th>
<th>Secondary Role</th> <th>Secondary Role</th>
<th>Type</th> <th>Type</th>
<th>Extra Info</th> <th>Extra Info</th>
<th>Time Logged</th> <th>Time Logged</th>
</tr> </tr>
<% <%
for (TransactionWithRoleBean t : list) { for (TransactionWithRoleBean t : list) {
convertedSimpleDate = sdf.parse(StringEscapeUtils.escapeHtml("" + (t.getConvertedDate()))); convertedSimpleDate = sdf.parse(StringEscapeUtils.escapeHtml("" + (t.getConvertedDate())));
if(StringEscapeUtils.escapeHtml("" + (t.getMainRole())).equals(StringEscapeUtils.escapeHtml(mainRole)) if(StringEscapeUtils.escapeHtml("" + (t.getMainRole())).equals(StringEscapeUtils.escapeHtml(mainRole))
|| StringEscapeUtils.escapeHtml(mainRole).equals("All")){ || StringEscapeUtils.escapeHtml(mainRole).equals("All")){
if(StringEscapeUtils.escapeHtml("" + (t.getSecondaryRole())).equals(StringEscapeUtils.escapeHtml(secondRole)) if(StringEscapeUtils.escapeHtml("" + (t.getSecondaryRole())).equals(StringEscapeUtils.escapeHtml(secondRole))
|| StringEscapeUtils.escapeHtml(secondRole).equals("All")){ || StringEscapeUtils.escapeHtml(secondRole).equals("All")){
if(StringEscapeUtils.escapeHtml("" + (t.getTransactionType().name())).equals(StringEscapeUtils.escapeHtml (transactionType)) || StringEscapeUtils.escapeHtml(transactionType).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))){ if((convertedSimpleDate.before(endSimpleDate) || convertedSimpleDate.equals(endSimpleDate)) && (convertedSimpleDate.after(startSimpleDate) || convertedSimpleDate.equals(startSimpleDate))){
countEntries++; countEntries++;
%> %>
<tr id="resultRow"> <tr id="resultRow">
<td id="mainTD"><%= StringEscapeUtils.escapeHtml("" + (t.getMainRole())) %></td> <td id="mainTD"><%= StringEscapeUtils.escapeHtml("" + (t.getMainRole())) %></td>
<td id="secondTD"><%= StringEscapeUtils.escapeHtml("" + (t.getSecondaryRole())) %></td> <td id="secondTD"><%= StringEscapeUtils.escapeHtml("" + (t.getSecondaryRole())) %></td>
<td id="typeTD"><%= StringEscapeUtils.escapeHtml("" + (t.getTransactionType().name())) %></td> <td id="typeTD"><%= StringEscapeUtils.escapeHtml("" + (t.getTransactionType().name())) %></td>
<td id="infoTD"><%= StringEscapeUtils.escapeHtml("" + (t.getAddedInfo())) %></td> <td id="infoTD"><%= StringEscapeUtils.escapeHtml("" + (t.getAddedInfo())) %></td>
<td id="timeTD"><%= StringEscapeUtils.escapeHtml("" + (t.getTimeLogged())) %></td> <td id="timeTD"><%= StringEscapeUtils.escapeHtml("" + (t.getTimeLogged())) %></td>
</tr> </tr>
<% <%
}
} }
} }
} }
} }
}
if(countEntries == 0){ if(countEntries == 0){
%> %>
<tr id="resultRow"> <tr id="resultRow">
<td style="color:red;" id="noResults" colspan="5">There are no results for the criteria specified</td> <td style="color:red;" id="noResults" colspan="5">There are no results for the criteria specified</td>
</tr> </tr>
<% <%
}
} }
} %>
%> </table>
</table>
<% } %> <% } %>
<br /> <br />
......
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