<%@ page import="gov.va.med.esr.common.model.lookup.Capability" %>
<%@ page import="gov.va.med.esr.common.model.lookup.AssociationType"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:set var="editAddress" value="false"/>
<c:set var="editAssociates" value="false"/>
<c:set var="editContactsPermission" value="false"/>
<c:set var="addContactsPermission" value="false"/>

<auth:authorize ifAnyGranted="<%=Capability.UPDATE_ADDRESS%>">
  <c:set var="editAddress" value="true"/>
</auth:authorize>
<auth:authorize ifAnyGranted="<%=Capability.UPDATE_ASSOCIATES%>">
  <c:set var="editAssociates" value="true"/>
</auth:authorize>
<auth:authorize ifAnyGranted="<%=Capability.EDIT_CONTACT_EXCLUDE_NEXT_OF_KIN.getName()%>">
  <c:set var="editContactsPermission" value="true"/>
</auth:authorize>
<auth:authorize ifAnyGranted="<%=Capability.ADD_CONTACT_EXCLUDE_NEXT_OF_KIN.getName()%>">
  <c:set var="addContactsPermission" value="true"/>
</auth:authorize>

<%-- Person Locked Check --%>
<c:set var="appData" value="${AppData}" scope="session"/>
<c:set var="personKey" value="SelectedPerson"/>
<c:set var="personLocked" value="${appData[personKey].personLocked}"/>
<c:if test="${personLocked}">
  <c:set var="editAddress" value="false"/>
  <c:set var="editAssociates" value="false"/>
  <c:set var="editContactsPermission" value="false"/>
  <c:set var="addContactsPermission" value="false"/>
</c:if>



        <%-- Mailing Address - Demographics --%>
        <c:set var="updateAddress" value="false"/>
        <c:set var="viewDemographics" value="false"/>
        <auth:authorize ifAnyGranted="<%=Capability.UPDATE_ADDRESS%>">
          <c:set var="updateAddress" value="true"/>
        </auth:authorize>
        <auth:authorize ifAnyGranted="<%=Capability.DEMOGRAPHICS%>">
          <c:set var="viewDemographics" value="true"/>
        </auth:authorize>

      
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="" role="presentation">
              <tr>
                <td>
                  <table width="100%"  cellpadding="0" cellspacing="0" class="moduleShell" role="presentation">
                    <tr>
                      <td width="100%">
                   
                        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableHead" role="presentation">
                          <tr>
                            <td class="moduleBlueBox"><img alt="" src="../images/spacer.gif" width="25" height="17"/></td>
                            <td nowrap> <bean:message key="text.updateAddressLink"/></td>
                             <td width="100%"><img alt=""  src="../images/spacer.gif"></td>
						
      
			                               <td nowrap class="moduleBlueLink" style="padding: 1 8 1 8">
			                               <c:choose>
			                               <c:when test="${editAddress == true}">
			                                 <fw:link action="/demographicAddresses.do?methodName=ADD ADDRESS" module="/demographic"><bean:message key="text.addAddressLink"/></fw:link>
			                               </c:when>
			                               <c:otherwise>
			                                 <bean:message key="text.addAddressLink"/>
			                               </c:otherwise>
			                               </c:choose>
                            </td>
                            
					
                          </tr>
                        </table>
                        
                        
                      </td>
                    </tr>

                    <tr>
                      <td>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="" role="presentation">
        
                       
                       <auth:authorize ifAnyGranted="<%=Capability.ADDRESS%>"> 
                   
					<c:if test="${not empty demographicOverviewForm.residentialAddress }">
						<tr>
				
							<td  width="30%" class="label" valign="top"><fw:link action="/demographicAddresses.do?methodName=Addresses&addressType=P" module="/demographic">
							<c:if test="${demographicOverviewForm.activeAddress == 'P'}">
								<span><img alt=""  src="../images/check_green.gif"></span>										
							</c:if>
							<bean:message key="label.address.residentialaddress"/></fw:link>:</td>
							<td width="5"><img alt=""  src="../images/spacer.gif"></td>
							<td width="30%"class="value">
							<esrcore:displayValue name="demographicOverviewForm" property="residentialAddress"/>
							<br/>
							<esrcore:displayValue name="demographicOverviewForm" property="phoneNumber"/>
							</td>
						   <td width="80" class="value"></td>
 <td width="50" class="value"></td>
  <td width="80" class="value"></td>
						</tr>
					</c:if>
				
				
					  <c:if test="${not empty demographicOverviewForm.permanentAddress }">
					      <tr>
						  								
						 	<td  width="30%"  class="label" valign="top" >
														<c:if test="${demographicOverviewForm.activeAddress == 'M'}">
								<span><img alt=""  src="../images/check_green.gif"></span>
							</c:if>
						 	<fw:link action="/demographicAddresses.do?methodName=Addresses&addressType=M" module="/demographic"><bean:message key="label.address.permanentaddress"/>:</fw:link></td>
						   	<td width="5"><img alt=""  src="../images/spacer.gif"></td>
							<td width="30%" class="value">
							  <c:if test="${demographicOverviewForm.badAddressReasonPerm != null}">
							    <span style="color: red" class="darklabel"><bean:message key="label.addresses.badAddressReason"/>:</span><br/>
							    <span class="darkvalue"><esrcore:displayValue name="demographicOverviewForm" property="badAddressReasonPerm"/></span><br/>
							  </c:if>
						   	<esrcore:displayValue name="demographicOverviewForm" property="permanentAddress"/>
						   	<br/>
						   	<esrcore:displayValue name="demographicOverviewForm" property="phoneNumber"/>
						   </td>
						   <td width="80" class="value"></td>
 <td width="50" class="value"></td>
  <td width="80" class="value"></td>
						</tr>
					</c:if>
				
				
					  <c:if test="${not empty demographicOverviewForm.temporaryAddress}">
	
					      <tr>
						 	<td  width="30%"  class="label" valign="top" >
							<c:if test="${demographicOverviewForm.activeAddress == 'C'}">
								<span><img alt=""  src="../images/check_green.gif"></span>
							</c:if>
						 	<fw:link action="/demographicAddresses.do?methodName=Addresses&addressType=C" module="/demographic"><bean:message key="label.address.temporaryAddress"/></fw:link>:</td>
						   	<td width="5"><img alt=""  src="../images/spacer.gif"></td>
							<td width="30%" class="value">
							 
						   	<esrcore:displayValue name="demographicOverviewForm" property="temporaryAddress"/>
						   	<br/>
						   	<esrcore:displayValue name="demographicOverviewForm" property="phoneNumber"/>
						   </td>
   <td nowrap class="value" style="align:center" >
					   <b><bean:message key="label.address.cassCertifiedStartDate"/></b><br>
					   <esrcore:displayValue name="demographicOverviewForm" property="tempStartDate"/>
					   </td>
					   <td nowrap class="value" style="align:center">
					   <b><bean:message key="label.address.cassCertifiedEndDate"/></b><br>
					   
					   <esrcore:displayValue name="demographicOverviewForm" property="tempEndDate"/>
					   </td>
					     <td width="80" class="value"></td>
						</tr>

				    </c:if>
				
				    <c:if test="${not empty demographicOverviewForm.confidentialAddress}">

				      <tr width="100%">
					  		
					 	<td  width="30%" class="label" valign="top">
													<c:if test="${demographicOverviewForm.activeAddress == 'CNF'}">
								<span><img alt=""  src="../images/check_green.gif"></span>
							</c:if>
					 	<fw:link action="/demographicAddresses.do?methodName=Addresses&addressType=CNF" module="/demographic"><bean:message key="label.address.confidentialrddress"/></fw:link>:</td>
					   	<td width="5"><img alt=""  src="../images/spacer.gif"></td>
						<td width="30%"  class="value">
						 
					   	<esrcore:displayValue name="demographicOverviewForm" property="confidentialAddress"/>
					   	<br/>
					   	<esrcore:displayValue name="demographicOverviewForm" property="phoneNumber"/>
					   </td>
						<td nowrap class="value" style="align:center" >
					   <b><bean:message key="label.address.cassCertifiedStartDate"/></b><br>
					   <esrcore:displayValue name="demographicOverviewForm" property="confStartDate"/>
					   </td>
					   <td nowrap class="value" style="align:center">
					   <b><bean:message key="label.address.cassCertifiedEndDate"/></b><br>
					   <esrcore:displayValue name="demographicOverviewForm" property="confEndDate"/>
					   </td>
					  	  <td width="80" class="value"></td>
					</tr>

				</c:if>
			

                      </auth:authorize>
                      
                      </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
        
