<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="/tags/struts-bean-el" prefix="bean-el" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html-el" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/tags/valuelist" prefix="vlh" %>
<%@ taglib uri="/tags/fw" prefix="fw" %>
<%@ taglib uri="/tags/esr-core" prefix="esrcore" %>
<%@ taglib uri="/tags/authz" prefix="auth" %>
<%@ page import='gov.va.med.esr.common.model.lookup.Capability' %>

<c:set var="viewParsedMessage" value="false"/>
<c:set var="viewRawMessage" value="false"/>
<auth:authorize ifAnyGranted="<%=Capability.VIEW_PARSED_MESSAGE.getName()%>"> 
	<c:set var="viewParsedMessage" value="true"/>   	
</auth:authorize>
<auth:authorize ifAnyGranted="<%=Capability.VIEW_RAW_MESSAGE.getName()%>"> 
	<c:set var="viewRawMessage" value="true"/>   	
</auth:authorize>

<c:if test="${vlhlist.valueListInfo.totalNumberOfEntries > 0}">

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShell">
<html-el:form action="/hl7Message" method="post">
  <%@ include file="/admin/csrfgentoken.jsp" %>
<tr>
<td>
 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTable">
  <tr>
   <td>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableHead">
     <tr>
        <td class="moduleBlueBox"><img alt=""  src="../images/spacer.gif" width="28" height="23"/></td>
	<td>&nbsp;<bean-el:message key="title.message.archivedSearchResult" /><c:if test="${pageName == 'siteMessages' && selectedSite != null}"> : <c:out value="${selectedSite.description}" /> (#<c:out value="${selectedSite.stationNumber}" />)</c:if></td>
     </tr>
    </table>
   </td>
  </tr>
  <tr><td>

   <table id="tableResult" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleTable" role="presentation">
    <vlh:root id="archivedMessageSearchTableId" value="vlhlist" url="?" includeParameters="*" configName="valueListConfigBeanLookAndFeel">
	<vlh:addParam name="checkboxName" value="Select" temp="false"/>
	<tr><td>

	    <table class="pagelinks" cellpadding="0" cellspacing="0" border="0">
	      <tr>
		<td width="45%"><img alt=""  src="../images/spacer.gif"></td>
		<td width="5%" height="21" nowrap="true"><span class="pagebanner"><c:out value="${vlhlist.valueListInfo.totalNumberOfEntries}"/> Total - Page (<c:out value="${vlhlist.valueListInfo.pagingPage}"/> of <c:out value="${vlhlist.valueListInfo.totalNumberOfPages}"/>).&nbsp;</span></td>
		<td width="5%">
			<c:if test="${vlhlist.valueListInfo.totalNumberOfPages > 1}">
				<vlh:paging attributes="class=\"pagelinks\"" pages="10"><c:out value="${pagemessageSearchTableId}"/>&nbsp;</vlh:paging>
			</c:if>
		</td>
		<td width="45%"><img alt=""  src="../images/spacer.gif"></td>
	      </tr>
	    </table>

	</td></tr>
	<tr vAlign="top">
	 <td vAlign="top" align="center">

	    <table summary="List of Archived Messages" rules="all" class="TableDisplay" cellspacing="0" cellpadding="3">
	      <tr>
		<vlh:row bean="msgLog">
		  <c:set var="messageId" value="${msgLog.messageLogEntryId}" scope="request"/> 
		  <%  			
			java.util.HashMap params = new java.util.HashMap();		    
			String selectedSiteId = (String)request.getAttribute(gov.va.med.esr.ui.message.action.MessageConstants.SELECTED_SITE_ID);
			if(selectedSiteId != null && selectedSiteId.length() > 0) params.put("selectedSiteId",selectedSiteId);
			params.put("selectedMsgId",(String)request.getAttribute("messageId"));			
			pageContext.setAttribute("parameters",params);
		  %>
		  <vlh:column title="Transmission Date" property="transmissionDate" format="yyyy/MM/dd HH:mm:ss" sortable="asc" attributes="class='valuelistRow1' align='left' scope='col'" default="">
		  	<vlh:attribute name="scope">row</vlh:attribute>
		  </vlh:column>
		  <vlh:column title="Status" property="status.description" sortable="asc" attributes="class='valuelistRow1' align='left' scope='col'" default="">
		    <c:choose>
		      <c:when test="${msgLog.error == true}">
			<fw:link action="messageDetail.do?methodName=viewArchivedErrorMessage&selectedSiteId=${selectedSiteId}" paramId="selectedMsgId" paramName="messageId"><c:out value="${msgLog.status.description}" /></fw:link>
		      </c:when>
		      <c:otherwise>
			<c:out value="${msgLog.status.description}" />
		      </c:otherwise>
		    </c:choose>
		  </vlh:column>
		  <vlh:column title="Message Type" property="messageTypeString" sortable="asc" attributes="class='valuelistRow1' align='left' scope='col'" default="">
			<c:choose>
				<c:when test="${viewParsedMessage == true}">
			        <fw:link action="messageDetail.do?methodName=viewArchivedParsedMessage" name="parameters">
					<c:out value="${msgLog.messageTypeString}" /></fw:link>					
				</c:when>
				<c:otherwise>
					<c:out value="${msgLog.messageTypeString}" />
				</c:otherwise>
			</c:choose>  
		  </vlh:column>
		  <c:if test="${pageName != 'siteMessages'}">
			<vlh:column title="Facility" property="facilityString" sortable="asc" attributes="class='valuelistRow1' align='left' scope='col'" default=""/>
		  </c:if>
		  <vlh:column title="Raw Data" attributes="class='valuelistRow1' align='center'  scope='col'" default="">
			<table width="100" border="0" align="center" cellspacing="0" cellpadding="0">
				<tr><td style="text-align: center;font-size:10pt">
					<c:if test="${viewRawMessage == true}">
						    <fw:link action="messageDetail.do?methodName=viewArchivedRawMessage" name="parameters">View</fw:link>
					</c:if>
				</td></tr>
			</table>
		  </vlh:column>
		  <vlh:column title="Transmission<br>Details" attributes="class='valuelistRow1' align='center' scope='col'" default="">
			<table width="100" border="0" align="center" cellspacing="0" cellpadding="0">
				<tr><td style="text-align: center;font-size:10pt"><fw:link action="messageDetail.do?methodName=viewArchivedDetail" name="parameters">View</fw:link></td></tr>
			</table>
		  </vlh:column>
		  <vlh:column title="Retransmit" attributes="class='valuelistRow1' align='center' scope='col'" default="">
		     <!--<c:if test="${msgLog.transmittableMessageType == true}">
				 <auth:authorize ifAnyGranted="${msgLog.retransmitPermissionCode}"> 					 	 
					<table width="100" border="0" align="center" cellspacing="0" cellpadding="0">
						<tr><td><img alt=""  src="../images/buttonEndLeft.gif" width="12" height="21" /></td>
							<td class="buttonText">
								<fw:link style="text-decoration: none; color: #FFFFFF;" action="hl7Message.do?methodName=RETRANSMIT" name="parameters">
									<bean-el:message key="buttom.retransmit"/>
								</fw:link>
							</td>
							<td><img alt=""  src="../images/buttonEndRight.gif" width="12" height="21" /></td></tr>
					</table>
				 </auth:authorize>
		     </c:if> -->
		  </vlh:column>
		</vlh:row>
	      </tr>
	    </table>

	</td>
       </tr>
    </vlh:root>
   </table>
</td>
</tr>
</table>
</td>
</tr>
</html-el:form>
</table>

</c:if>
