diff --git a/iTrust/WebRoot/auth/admin/viewTransactionLogs.jsp b/iTrust/WebRoot/auth/admin/viewTransactionLogs.jsp index ae162899ad98776a78c4724c369e2ad3ff115193..1f82e2308ceb9c83568ce57bc4ad0d93b5844eeb 100644 --- a/iTrust/WebRoot/auth/admin/viewTransactionLogs.jsp +++ b/iTrust/WebRoot/auth/admin/viewTransactionLogs.jsp @@ -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="viewGraph" value="Summarize"></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> </table> </form> <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(); - SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); - Date convertedSimpleDate = null; - Date startSimpleDate = null; - Date endSimpleDate = null; - - if(startDate != ""){ - startSimpleDate = sdf.parse(startDate); - } - else{ - startSimpleDate = sdf.parse("01/01/2000"); - } - if(endDate != ""){ - endSimpleDate = sdf.parse(endDate); - } - else{ - endSimpleDate = sdf.parse(formatted); - } + if(startDate != ""){ + startSimpleDate = sdf.parse(startDate); + } + else{ + startSimpleDate = sdf.parse("01/01/2000"); + } + if(endDate != ""){ + endSimpleDate = sdf.parse(endDate); + } + else{ + endSimpleDate = sdf.parse(formatted); + } - boolean dateFormatError = false; - 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("")); - if(!result) { - dateFormatError = true; - %> - <span class="iTrustError">ERROR: Date must by in the format: MM/dd/yyyy</span> - <% - } - else if(endSimpleDate.before(startSimpleDate)){ - dateFormatError = true; - %> - <span class="iTrustError">ERROR: End Date cannot be before Start Date</span> - <% - } + boolean dateFormatError = false; + 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("")); + if(!result) { + dateFormatError = true; + %> + <span class="iTrustError">ERROR: Date must by in the format: MM/dd/yyyy</span> + <% + } + else if(endSimpleDate.before(startSimpleDate)){ + dateFormatError = true; + %> + <span class="iTrustError">ERROR: End Date cannot be before Start Date</span> + <% + } - int countEntries = 0; - if(!dateFormatError){ - %> - <tr> - <th>Main Role</th> - <th>Secondary Role</th> - <th>Type</th> - <th>Extra Info</th> - <th>Time Logged</th> - </tr> - <% - for (TransactionWithRoleBean t : list) { - - convertedSimpleDate = sdf.parse(StringEscapeUtils.escapeHtml("" + (t.getConvertedDate()))); + int countEntries = 0; + if(!dateFormatError){ + %> + <tr> + <th>Main Role</th> + <th>Secondary Role</th> + <th>Type</th> + <th>Extra Info</th> + <th>Time Logged</th> + </tr> + <% + 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))){ - countEntries++; - %> - <tr id="resultRow"> - <td id="mainTD"><%= StringEscapeUtils.escapeHtml("" + (t.getMainRole())) %></td> - <td id="secondTD"><%= StringEscapeUtils.escapeHtml("" + (t.getSecondaryRole())) %></td> - <td id="typeTD"><%= StringEscapeUtils.escapeHtml("" + (t.getTransactionType().name())) %></td> - <td id="infoTD"><%= StringEscapeUtils.escapeHtml("" + (t.getAddedInfo())) %></td> - <td id="timeTD"><%= StringEscapeUtils.escapeHtml("" + (t.getTimeLogged())) %></td> - </tr> - <% + 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))){ + countEntries++; + %> + <tr id="resultRow"> + <td id="mainTD"><%= StringEscapeUtils.escapeHtml("" + (t.getMainRole())) %></td> + <td id="secondTD"><%= StringEscapeUtils.escapeHtml("" + (t.getSecondaryRole())) %></td> + <td id="typeTD"><%= StringEscapeUtils.escapeHtml("" + (t.getTransactionType().name())) %></td> + <td id="infoTD"><%= StringEscapeUtils.escapeHtml("" + (t.getAddedInfo())) %></td> + <td id="timeTD"><%= StringEscapeUtils.escapeHtml("" + (t.getTimeLogged())) %></td> + </tr> + <% + } } } } } - } - if(countEntries == 0){ - %> - <tr id="resultRow"> - <td style="color:red;" id="noResults" colspan="5">There are no results for the criteria specified</td> - </tr> - <% + if(countEntries == 0){ + %> + <tr id="resultRow"> + <td style="color:red;" id="noResults" colspan="5">There are no results for the criteria specified</td> + </tr> + <% + } } - } - %> -</table> + %> + </table> <% } %> <br />