<%@ 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/displaytag" prefix="display" %>
<%@ taglib uri="/tags/esr-core" prefix="esrcore" %>
<%@ taglib uri="/tags/fw" prefix="fw" %>

<%@ page import="gov.va.med.esr.ui.militaryservice.action.MilitaryServiceConstants" %>
<%@ page import="gov.va.med.esr.common.model.lookup.VAFacility" %>

<%-- add a person flag --%>
<c:set var="isAddAPerson" value="false"></c:set>
<c:if test="${AppData.addAPerson != null && AppData.addAPerson == true}">
        <c:set var="isAddAPerson" value="true"></c:set>    	
</c:if>

<c:set var="readOnlyMS" value="false"/>
<c:set var="personKey" value="SelectedPerson"/>
<c:set var="personLocked" value="${AppData[personKey].personLocked}"/>

<c:if test="${personLocked}">
  <c:set var="readOnlyMS" value="true"/>
</c:if>

<c:set var="expandableSectionCollapsed" scope="page"><bean-el:message key="label.expandableSectionCollapsed"/></c:set>
<c:if test="${militaryServiceInfoForm.msdsBrokerService == 'true'}">
<table id="tblMilitarySvc" cellSpacing="0" cellPadding="0" width=100%
	border=0 class="moduleShell" border="0">
	<tr>
		<td colspan="2">
		<table width="100%" border="0" cellspacing="0" cellpadding="0"
			class="moduleShellTableHead">
			<tr>
				<td class="moduleBrownBox"><img alt=""
					src="../images/spacer.gif" width="28" height="23" /></td>
				<td nowrap>&nbsp;</td>
				<td width="10%" nowrap>
				<table width="20%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="50%"><img alt="" src="../images/spacer.gif" /></td>
						<td><img alt="" src="../images/buttonEndLeft.gif" /></td>
						<td><html-el:submit property="methodName" disabled="${isAddAPerson || readOnlyMS}"
							style="width:170; vertical-align: top;" styleClass="buttonText initfocus">
							<bean-el:message key="button.sendBrokerQuery" />
						</html-el:submit></td>
						<td><img alt="" src="../images/buttonEndRight.gif" /></td>
						<td width="50%"><img alt="" src="../images/spacer.gif" /></td>
						<td width="1" style="padding:0 5 0 0"><img alt=""
							src="../images/spacer.gif" /></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
</table>

<br>
</c:if>
<table id="tblMilitarySvc" cellSpacing="0" cellPadding="0" width=100% border=0 class="moduleShell" border="0">
 <tr>
   <td>
   	<c:set var="siteRecordCount" value="0" />
   	<c:set var="HEC_STATION_NUMBER"><%= VAFacility.CODE_HEC.getName() %></c:set>
   	<c:choose>
    	    <c:when test="${not empty militaryServiceSiteRecordList}">

		<c:forEach var="siteRecord" items="${militaryServiceSiteRecordList}">

		<!-- Donnot display HEC Record here -->
		<c:if test="${siteRecord.site.stationNumber != HEC_STATION_NUMBER}">

		    <c:set var="siteRecordCount" value="1" />
		    <c:set var="expandOrCollapseMethod">expandOrCollapse(id<c:out value="${siteRecord.site.stationNumber}" />,imgId<c:out value="${siteRecord.site.stationNumber}" />,hId<c:out value="${siteRecord.site.stationNumber}" />); return false;</c:set>

		    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableHead">
          <tr>
            <td class="moduleLabel" nowrap style="text-align: left; padding-left: 5">
              <fw:link href="." onclick="${expandOrCollapseMethod}">
                <html-el:img alt="${expandableSectionCollapsed}" align="center" border="0" styleId="imgId${siteRecord.site.stationNumber}" src="../images/redArrowRight.gif"/><c:out value="${siteRecord.site.name}" /> (<c:out value="${siteRecord.site.stationNumber}" />)
              </fw:link>
              <input name="hId<c:out value="${siteRecord.site.stationNumber}" />" ID="hId<c:out value="${siteRecord.site.stationNumber}" />" type="hidden" value="false"/>
            </td>
          </tr>

		    <tr>
        <td>
				<div id="id<c:out value="${siteRecord.site.stationNumber}" />" class="expandCollapseBody">
				<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody" >
				<caption>Military Service Episode Records from the Selected Facility</caption>

					<c:if test="${not empty siteRecord.militaryServiceEpisodes}">
					    <thead>
					    <tr>
						<th scope="col" width="10" class="darkValue">&nbsp;</td>
						<th scope="col" width="12%" class="darkValue" valign="bottom"><b><bean-el:message key="label.military"/><br><bean-el:message key="label.serviceNumber"/></b></th>
						<th scope="col" width="12%" class="darkValue" valign="bottom"><b><bean-el:message key="label.branchOfService"/></b></th>
						<th scope="col" width="12%" class="darkValue" valign="bottom"><b><bean-el:message key="label.periodOfService"/></b></th>
						<th scope="col" width="12%" class="darkValue" valign="bottom"><b><bean-el:message key="label.serviceComponent"/></b></th>
						<th scope="col" width="12%" class="darkValue" valign="bottom"><b><bean-el:message key="label.dischargeType"/></b></th>
						<th scope="col" width="12%" class="darkValue" valign="bottom"><b><bean-el:message key="label.filipinoVeteranProof"/></b></th>
						<th scope="col" width="12%" class="darkValue" valign="bottom"><b><bean-el:message key="label.service"/><br><bean-el:message key="label.entryDate"/></b></th>
						<th scope="col" width="12%" class="darkValue" valign="bottom"><b><bean-el:message key="label.service"/><br><bean-el:message key="label.seperationDate"/></b></th>
						<th scope="col" class="darkValue">&nbsp;</th>
					    </tr>
                                            </thead>
                                            
                                            <tbody>
					    <c:set var="rowColor" value="darkValue" />
					    <c:forEach var="militaryServiceEpisode" items="${siteRecord.militaryServiceEpisodes}">
					    <c:choose>
						<c:when test="${rowColor == 'darkValue'}">
							<c:set var="rowColor" value="value" />
						</c:when>
						<c:otherwise>
							<c:set var="rowColor" value="darkValue" />
						</c:otherwise>
					    </c:choose>

					    <tr>
						<td class="<c:out value="${rowColor}"/>">&nbsp;</td>
						<td scope="row" class="<c:out value="${rowColor}"/>"><c:out value="${militaryServiceEpisode.serviceNumber}" />&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>"><esrcore:displayValue name="militaryServiceEpisode" property="serviceBranch.description"/>&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>"><esrcore:displayValue name="siteRecord" property="servicePeriod.name"/>&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>"><esrcore:displayValue name="militaryServiceEpisode" property="militaryServiceComponent.description"/>&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>"><esrcore:displayValue name="militaryServiceEpisode" property="dischargeType.description"/>&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>"><esrcore:displayValue name="siteRecord" property="filipinoVeteranProof.description"/>&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>"><esrcore:displayValue name="militaryServiceEpisode" property="startDate"/>&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>"><esrcore:displayValue name="militaryServiceEpisode" property="endDate"/>&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>">&nbsp;</td>
					    </tr>
					    </c:forEach>
					    </tbody>
					</c:if>

					<tr><td colspan="10">&nbsp;</td></tr>

					<c:if test="${not empty siteRecord.conflictExperiences}">
					    <thead>
					    <tr>
						<th scope="col" class="darkValue">&nbsp;</th>
						<th scope="col" class="darkValue"><b><bean-el:message key="label.conflictservicelocation"/></b></th>
						<th scope="col" class="darkValue"><b><bean-el:message key="label.conflict"/><br><bean-el:message key="label.startDate"/></b></th>
						<th scope="col" class="darkValue"><b><bean-el:message key="label.conflict"/><br><bean-el:message key="label.endDate"/></b></th>
						<th scope="col" class="darkValue">&nbsp;</th>
						<th scope="col" class="darkValue">&nbsp;</th>
						<th scope="col" class="darkValue">&nbsp;</th>
						<th scope="col" class="darkValue">&nbsp;</th>
						<th scope="col" class="darkValue">&nbsp;</th>
						<th scope="col" class="darkValue">&nbsp;</th>
					    </tr>
					    </thead>
					    
					    <tbody>
					    <c:set var="rowColor" value="darkValue" />
					    <c:forEach var="conflictExperience" items="${siteRecord.conflictExperiences}">
					    <c:choose>
						<c:when test="${rowColor == 'darkValue'}">
							<c:set var="rowColor" value="value" />
						</c:when>
						<c:otherwise>
							<c:set var="rowColor" value="darkValue" />
						</c:otherwise>
					    </c:choose>

					    <tr>
						<td class="<c:out value="${rowColor}"/>">&nbsp;</td>
						<td scope="row" class="<c:out value="${rowColor}"/>"><esrcore:displayValue name="conflictExperience" property="conflictLocation"/>&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>"><esrcore:displayValue name="conflictExperience" property="startDate"/>&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>"><esrcore:displayValue name="conflictExperience" property="endDate"/>&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>">&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>">&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>">&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>">&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>">&nbsp;</td>
						<td class="<c:out value="${rowColor}"/>">&nbsp;</td>
					    </tr>
					    </c:forEach>
					    </tbody>
					</c:if>
				</table>
				</div>
			</td>
		    </tr>
		    </table>
		</c:if>
		</c:forEach>
	    </c:when>
	    <c:otherwise>
	    	<c:set var="siteRecordCount" value="0" />
	    </c:otherwise>
	</c:choose>
	<c:if test="${siteRecordCount == 0}">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody">
	    		<tr><td class="value">&nbsp;</td></tr>
	    		<tr><td class="value"><bean-el:message key="label.noDataAvailable" /></td></tr>
	    		<tr><td class="value">&nbsp;</td></tr>
		</table>
	</c:if>
   </td>
 </tr>
</table>
