<%@ page import="gov.va.med.esr.ui.util.SessionManager"%>
<%@ 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/valuelist" prefix="vlh" %>
<%@ taglib uri="/tags/fw" prefix="fw" %>
<%@ page import='gov.va.med.esr.common.model.lookup.Relationship' %>

<c:set var="spouseCode"><%=Relationship.CODE_SPOUSE.getCode()%></c:set>
<c:set var="incomeYear"><%= session.getAttribute(SessionManager.SELECTED_FINANCIAL_INCOME_YEAR) %></c:set>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShell">
<%-- add a person flag --%>
<c:set var="isAddAPerson" value="false"></c:set>
<c:if test="${financialsDependentOverviewForm.addAPerson == 'true'}">
    <c:set var="isAddAPerson" value="true"></c:set>
</c:if>

<html-el:form action="/financialsDependentOverview" method="post">
  <%@ include file="/admin/csrfgentoken.jsp" %>
  <tr>
    <td>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTable">
        <%-- Dependents Overview Header --%>
        <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 nowrap style="padding-left: 7"><bean-el:message key="financials.depOverview.title"/></td>
                <td align="left" nowrap>&nbsp;(<bean-el:message key="title.incomeyear"/>&nbsp;<c:out value="${incomeYear}"/>)</td>
                <td width="100%"><img alt=""  src="../images/spacer.gif"></td>

                <td nowrap class="moduleBlueLink" style="padding: 1 8 1 8">
					<fw:link action="financialDetailsEdit?methodName=DISPLAY">
						<bean-el:message key="link.button.viewEditFinancials"/>
					</fw:link></td>
                <td><img alt=""  src="../images/spacer.gif" width="5"/></td>
				<td nowrap class="moduleBlueLink" style="padding: 1 8 1 8">
					<fw:link action="/financialsDependentHistory?methodName=DISPLAY&amp;history=viewHistoricalDependents">
						<bean-el:message key="label.viewDepHistory"/>
					</fw:link>
				</td>								
              </tr>
            </table>
          </td>
        </tr>

        <tr>
          <td>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody">
              <tr>
              <c:choose>
              <c:when test="${financialsDependentOverviewForm.isDependentListEmpty == 'true'}">
                <td class="darkValue" style="padding:10 0 10 10; text-align: left"><bean-el:message key="label.noDataAvailable"/></td>
              </c:when>
              <c:otherwise>
			        <td vAlign="top" align="center">
			          <div id="financialDependent" style="border-width:0px;">
			            <table id="financialDependentResult" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleTable">
			              <vlh:root id="financialDependentTableId" value="vlhlist" url="?" includeParameters="*" configName="valueListConfigBeanLookAndFeel">
			              <tr>
			                <td colspan="5">
			                  <table class="pagelinks">
			                    <tr>
			                      <td width="45%"><img alt=""  src="../images/spacer.gif"></td>
			                        <td width="5%" 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:choose>
			                      <c:when test="${vlhlist.valueListInfo.totalNumberOfPages > 1}">
			                        <vlh:paging attributes="class=\"pagelinks\"" pages="10"><c:out value="${pagefutureEGTSettingsTableId}"/>&nbsp;</vlh:paging>
			                      </c:when>
			                      <c:otherwise>
			                        &nbsp;
			                      </c:otherwise>
			                      </c:choose>
			                    </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 Dependents for the Income Year" rules="all" class="TableDisplay">
			                    <tr>
			                      <vlh:row bean="relationFinancialInfoBean">
			                      <c:set var="financialsId" value="${relationFinancialInfoBean.financialsId}" scope="request"/> 
				                  <c:choose>
				                   <c:when test="${isAddAPerson}">	
				                    	<vlh:column title="SSN" property="displaySSN"  sortable="asc" attributes="align=\"left\" scope='col'" default="">
				                    		<vlh:attribute name="scope">row</vlh:attribute>
				                    	</vlh:column>	
				                   </c:when>
				                   <c:otherwise>
				                        <vlh:column title="SSN" property="displaySSN"  sortable="asc" attributes="align=\"left\" scope='col'" default="">
				                    		<vlh:attribute name="scope">row</vlh:attribute>
				                    		<html-el:link action="financialsDependentEdit.do?methodName=DISPLAY" paramId="dependentId" paramName="financialsId">
                        						<c:out value="${relationFinancialInfoBean.displaySSN}"/>
                        					</html-el:link> 				                    		
				                    	</vlh:column>
				                   </c:otherwise>
				                   </c:choose>							  
			                        <vlh:column title="Name" property="name" sortable="asc" attributes="align=\"left\" scope='col'" default="">
			                          <esrcore:displayValue name="relationFinancialInfoBean" property="name" nullText=""/>
			                        </vlh:column>

					               <vlh:column title="Relationship" property="relationship" sortable="asc" attributes="align=\"left\" scope='col'" default="">
			                          <esrcore:displayValue name="relationFinancialInfoBean" property="relationship" nullText=""/>
			                        </vlh:column>

			                        <vlh:column title="Status" attributes="align=\"left\" scope='col'" default="">
			                        	<c:choose>
                      					<c:when test="${relationFinancialInfoBean.active == 'true'}">Active</c:when>
										<c:otherwise>Inactive</c:otherwise>
                      					</c:choose>
			                        </vlh:column> 
			
			                      </vlh:row>
			                    </tr>
			                  </table>
			                </td>
			               </tr>
			              </vlh:root>
			            </table>
			          </div>
			        </td>
              </c:otherwise>
              </c:choose>
              </tr>

              <tr>
                <td colspan=2 height="50">
                  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody">
                    <tr>
                      <td width="45%"><img alt=""  src="../images/spacer.gif"/></td>
                      <td><img alt=""  src="../images/buttonEndLeft.gif"/></td>
                      <td><html-el:submit property="methodName" style="width:70; vertical-align: top;" styleClass="buttonText"><bean-el:message key="button.addDepChild"/></html-el:submit></td>
                      <td><img alt=""  src="../images/buttonEndRight.gif"/></td>
                      <td width="1%"><img alt=""  src="../images/spacer.gif"/></td>
                    <c:if test="${financialsDependentOverviewForm.spouseAvaliableInd == 'false'}">
                      <td><img alt=""  src="../images/buttonEndLeft.gif"/></td>
                      <td><html-el:submit property="methodName" style="width:70; vertical-align: top;" styleClass="buttonText"><bean-el:message key="button.addDepSpouse"/></html-el:submit></td>
                      <td><img alt=""  src="../images/buttonEndRight.gif"/></td>
                      <td width="1%"><img alt=""  src="../images/spacer.gif"/></td>
                    </c:if>
                      <td><img alt=""  src="../images/buttonEndLeft.gif"/></td>
                      <td><html-el:submit property="methodName" style="width:105; vertical-align: top;" styleClass="buttonText"><bean-el:message key="button.copyDependents"/></html-el:submit></td>
                      <td><img alt=""  src="../images/buttonEndRight.gif"/></td>
                      <td width="1%"><img alt=""  src="../images/spacer.gif"/></td>
                      <td><img alt=""  src="../images/buttonEndLeft.gif"/></td>
                      <td><html-el:submit property="methodName" style="width:60; vertical-align: top;" styleClass="buttonText"><bean-el:message key="button.cancel"/></html-el:submit></td>
                      <td><img alt=""  src="../images/buttonEndRight.gif"/></td>
                      <td width="45%"><img alt=""  src="../images/spacer.gif"/></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <html-el:hidden name="financialsDependentOverviewForm" property="addAPerson"/>
</html-el:form>
</table>
