<%@ 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}">
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShell">
 <tr><td width="100%">
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody">
   <tr><td>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableHead" role="presentation">
     <tr>
	<td width="5%" class="moduleBlueBox">&nbsp;</td>
	<td class="moduleHeadline"><bean-el:message key="title.message.searchResult" /></td>
     </tr>
    </table>
   </td></tr>

   <tr><td class="moduleValue">
	<table id="tableResult" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleTable" role="presentation">
	    <vlh:root id="messageSearchTableId" 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 Message Search Result" rules="all" class="TableDisplay" cellspacing="0" cellpadding="3">
		      <tr>
			<vlh:row bean="msgLog">
			  <c:set var="messageId" value="${msgLog.messageLogEntryId}" scope="request"/>
			  <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=viewErrorMessage" 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=viewParsedMessage" paramId="selectedMsgId" paramName="messageId">
						<c:out value="${msgLog.messageTypeString}" /></fw:link>
				  </c:when>
				  <c:otherwise>
					<c:out value="${msgLog.messageTypeString}" />
				  </c:otherwise>
			    </c:choose>
			  </vlh:column>
			  <vlh:column title="Facility" property="facilityString" sortable="asc" attributes="class='valuelistRow1' align='left' scope='col'" default=""/>
			  <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=viewRawMessage" paramId="selectedMsgId" paramName="messageId">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=viewDetail" paramId="selectedMsgId" paramName="messageId">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="messageAction.do?methodName=RETRANSMIT" paramId="selectedMsgId" paramName="messageId"><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>
</table>
</c:if>
