<%@ include file="/project/include.jsp" %>

<link rel="stylesheet" type="text/css" href="${j:getResourceUrlOfModule('anagrafiche','css/compareNucleo.css')}" />

<script type="text/javascript">
function allineaRapportoParentela(key) {
	var $sel = $('#' + key);
	var value = $sel.attr('propValue');
	$sel.val(value);
}

function showDetails(key) {
	$('#divTarget').html($('#' + key).html());
	
	var buttons = [
					{ 'img'		: juiceGetResource('shell', 'img/misc/confirm-small.gif'),
					  'text'	: 'Ok',
					  'onclick'	: 
					  	function() { 
						  hideModal('idDivInfoCompare');
						}
					}
				];
	var rec = getClientAreaRectangle().resize(670, 420, HORIZONTAL_CENTER | VERTICAL_CENTER);	
	showDivModal('idDivInfoCompare', 'Confronto', rec, false, false, buttons);	
}

</script>


<br/><br/>

<c:choose>
<c:when test="${empty componentiDto}">
<span>Non ci sono componenti da confrontare</span>
</c:when>
<c:otherwise>

<shell:fieldset title="Confronto dei componenti del nucleo">
<table border="0" cellspacing="3" cellpadding="0" width="100%">
	<c:forEach var="cmp" items="${componentiDto}">
		<tr>
			<td class="form-label" rowspan="2">
				<c:set var="imgName" value="img/${cmp.tipo}.gif"/>
				<img src="${j:getResourceUrlOfModule('anagrafiche', imgName)}" width="64" height="24" border="0" align="absmiddle">
				&nbsp;${cmp.soggetto}
			</td>
			<%-- 
			<td class="compare-form-label">${cmp.descrizione}</td>
			--%>			
			<td class="compare-form-label">
				<a href="javascript: showDetails('detail_${cmp.index}')">
					<img src="${j:getResourceUrlOfModule('anagrafiche', 'img/showDetails.gif')}" width="16" height="16" border="0" align="absmiddle"/>
				</a>
				${cmp.descrizione}
				<div id="detail_${cmp.index}" class="compare-hidden-box">
					<table border="0" cellspacing="5" cellpadding="0" width="100%" >
						<tr>
							<td colspan="2" class="compare-form-header">
								${cmp.soggetto}
							</td>
						</tr>
						<tr>
							<td width="50%" valign="top">
								<table border="0" cellspacing="3" cellpadding="0" width="100%" >
									<tr>
										<td class="compare-form-header" colspan="2"><shell:label prop="sitAnagrafe" /></td>
									</tr>
									<c:if test="${! empty cmp.anag.nucleoValid}">
									<tr>
										<td class="form-label" rowspan="2"><shell:label prop="statoDemografico" /></td>
										<td class="form-values">${cmp.anag.stDemog}</td>
									</tr>
									<tr>											
										<td class="form-values">${cmp.anag.stDemogValid}</td>
									</tr>
									<tr>
										<td class="form-label"><shell:label prop="gradoPar" /></td>
										<td class="form-values">${cmp.anag.gradoPar}</td>
									</tr>
									</c:if>
									
									<tr>
										<td class="form-label"><shell:label prop="nucleo" /></td>
										<td class="form-values">${cmp.anag.nucleo}</td>
									</tr>
									
									<c:if test="${! empty cmp.anag.nucleoValid}">
									<tr>
										<td class="form-label"><shell:label prop="validita" /></td>
										<td class="form-values">${cmp.anag.nucleoValid}</td>
									</tr>
									<tr>
										<td class="form-label"><shell:label prop="nucleoCod" /></td>
										<td class="form-values">${cmp.anag.nucleoCod}</td>
									</tr>
									</c:if>
									
								</table>
							</td>
							
							<td valign="top">
								<table border="0" cellspacing="3" cellpadding="0" width="100%" >
									<tr>
										<td class="compare-form-header" colspan="2"><shell:label prop="sitIcaro" /></td>
									</tr>
									<c:if test="${! empty cmp.icaro.sogg}">
									<tr>
										<td class="form-values" colspan="2">${cmp.icaro.sogg}</td>
									</tr>
									</c:if>
									
									<c:if test="${empty cmp.icaro.sogg}">
										<tr>
											<td class="form-label"><shell:label prop="nucleo" /></td>
											<td class="form-values">${cmp.icaro.nucleo}</td>
										</tr>
										
										<c:if test="${! empty cmp.icaro.lastNucleo}">
										<tr>
											<td class="form-label"><shell:label prop="lastNucleo" /></td>
											<td class="form-values">${cmp.icaro.lastNucleo}</td>
										</tr>
										</c:if>
										
										
										<c:if test="${! empty cmp.icaro.nucleoValid}">
										<tr>
											<td class="form-label"><shell:label prop="validita" /></td>
											<td class="form-values">${cmp.icaro.nucleoValid}</td>
										</tr>
										<tr>
											<td class="form-label"><shell:label prop="nucleoCod" /></td>
											<td class="form-values">${cmp.icaro.nucleoCod}</td>
										</tr>
										</c:if>
																			
									</c:if>
									
								</table>
							</td>
						</tr>
					</table>
				</div>
			</td>
		</tr>	
		<tr>
			<td class="form-values">
				<table border="0" cellspacing="3" cellpadding="0" width="100%" >
					<tr>
						<td class="form-values" width="65%" valign="top">
							<j:bind prop="prop_${cmp.index}1">
								<j:valueSetIterator>
									<j:radio/> ${j:getValueSetItem().description}
								</j:valueSetIterator>										
								<shell:error />
							</j:bind>
							<c:if test="${cmp.showDataLimite}">
								<j:bind prop="prop_${cmp.index}2">
									<j:text class="form-date" id="dataLimite${cmp.index}Cld"/>
									<shell:calendar inputId="dataLimite${cmp.index}Cld" />						
									<shell:error />
								</j:bind>
							</c:if>
						</td>
						<td width="35%" valign="top">
							<table border="0" cellspacing="3" cellpadding="0" width="100%" >
								<tr>
									<td class="form-label" colspan="2">Rel. parentela</td>
								</tr>
								<tr>
									<td class="form-label">Anagrafe:</td>
									<td class="form-values"><a href="javascript:allineaRapportoParentela('selCmp_${cmp.index}')">${cmp.anag.relPar}</a></td>
								</tr>
								<tr>
									<td class="form-label">Icaro:</td>
									<td class="form-values">
										<j:bind prop="prop_${cmp.index}0">
											<j:select class="form-input" id="selCmp_${cmp.index}" emptyOptionDescr="" propValue="${cmp.anag.relParId}"/>						
											<shell:error />
										</j:bind>
									</td>
								</tr>
								
							</table>
						</td>
					</tr>				
				</table>								
	  		</td>
		</tr>
	</c:forEach>
</table>
</shell:fieldset>
</c:otherwise>
</c:choose>

<div id="idDivInfoCompare" class="modalElement">
	<div id="divTarget"></div>
</div>