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

<script type="text/javascript">	  	
  	var idRichiedenteOld = '';
  	var nominativoRichiedenteOld = '';
  	var denominazioneRichiedenteOld = '';
  	var tipoSoggettoRichiedenteSelect;
  	var tipoSoggettoRichiedenteSelectedIndex = -1;
  	var tipoSoggettoRichiedenteUtenteId = '${idTipoFirmatarioUtente}';
  	var tipoSoggettoRichiedenteUtenteDescription;
  	var defaultOptions;

  	function switchLuogoProvenienza(clear) {
  		if (this.document.getElementById("esteroProvenienzaId_0")) {
	  		var estero = this.document.getElementById("esteroProvenienzaId_0").checked;
	  		if (estero) {
	  			this.document.getElementById('luogoProvenienzaLabelId').innerHTML = "Stato estero di provenienza";
	  			this.document.getElementById('luogoProvenienza_lookup').href = "javascript:shellLookup('luogoProvenienza', 'tabelleterritoriali.nazione', 'it.cedaf.icare.commons.model.datamanagement.NazioneLookupInitializer', 'estero=true', 'nome_luogoProvenienza|nome');";
	  		} else {
	  			this.document.getElementById('luogoProvenienzaLabelId').innerHTML = "Comune di provenienza";
	  			this.document.getElementById('luogoProvenienza_lookup').href = "javascript:shellLookup('luogoProvenienza', 'tabelleterritoriali.comune', 'it.cedaf.icare.commons.model.datamanagement.ComuneLookupInitializer', null, 'nome_luogoProvenienza|nome');";
	  		}
	  		if (clear) {
	  			this.document.getElementById('nome_luogoProvenienza').value = '';
	  			this.document.getElementById('id_luogoProvenienza').value = '';
	  		}
  		}
  	}
  	
	function changeIdLuogoProvenienzaLookup(){
		clearIdLookup('luogoProvenienza');
	}
	
  	function checkAssistitoIsRichiedente() {
  		var denomRichiedente = document.getElementById('denomRichiedente');
  		if (document.getElementById('assistitoIsRichiedenteId').checked){
  			if (document.getElementById('id_richiedenteLookup')) {
  				idRichiedenteOld = document.getElementById('id_richiedenteLookup').value;
				nominativoRichiedenteOld = document.getElementById('nominativo_richiedenteLookup').value;
  			} 
  			if (document.getElementById('denomRichiedente')) {
  				denominazioneRichiedenteOld = document.getElementById('denomRichiedente').value;
  			}
			tipoSoggettoRichiedenteSelectedIndex = tipoSoggettoRichiedenteSelect.selectedIndex;
			tipoSoggettoRichiedenteSelect.options.length = 1;
			tipoSoggettoRichiedenteSelect.options[0].value = tipoSoggettoRichiedenteUtenteId;
			tipoSoggettoRichiedenteSelect.options[0].text = tipoSoggettoRichiedenteUtenteDescription;
			document.getElementById('assistitoIsRichiedenteHiddenId').value = "true";
			if (document.getElementById('id_richiedenteLookup')) {
				document.getElementById('id_richiedenteLookup').value = '';
				document.getElementById('nominativo_richiedenteLookup').value = document.getElementById('nominativo_assistitoLookup').value;
				document.getElementById('idDivLookupRichiedente').style.visibility = 'hidden';
				document.getElementById('idDivChooseRichiedenteSoggSignNucleoId').style.visibility = 'hidden';
				if (denomRichiedente) {
					denomRichiedente.value = '';
					denomRichiedente.readOnly = true;
				}
			} else if (denomRichiedente) {
				denomRichiedente.value = document.getElementById('nominativo_assistitoLookup').value;
				denomRichiedente.readOnly = true;
			}			
		} else {
			document.getElementById('assistitoIsRichiedenteHiddenId').value = "false";
			if (document.getElementById('id_richiedenteLookup')) {
				document.getElementById('id_richiedenteLookup').value = idRichiedenteOld;
				document.getElementById('nominativo_richiedenteLookup').value = nominativoRichiedenteOld;
				document.getElementById('idDivLookupRichiedente').style.visibility = 'visible';
				document.getElementById('idDivChooseRichiedenteSoggSignNucleoId').style.visibility = 'visible';				
			}
			if (denomRichiedente) {
				denomRichiedente.value = denominazioneRichiedenteOld;
				denomRichiedente.readOnly = false;
			}
			tipoSoggettoRichiedenteSelect.options.length = 0;
			for (var i=0; i<defaultOptions.length; i++) {
				tipoSoggettoRichiedenteSelect.options[i] = new Option(defaultOptions[i].text, defaultOptions[i].value);
				tipoSoggettoRichiedenteSelect.options[i].selected = (i == tipoSoggettoRichiedenteSelectedIndex);
			}			
		}
	}
	
	function initCheckAssistitoIsRichiedente() {
		if (document.getElementById('assistitoIsRichiedenteHiddenId')) {
			tipoSoggettoRichiedenteSelect = document.getElementById('tipoSoggettoRichiedenteSelectId');
			defaultOptions = new Array();
			for (var i=0; i<tipoSoggettoRichiedenteSelect.options.length; i++) {
				defaultOptions[i] = new Object();
				defaultOptions[i].value = tipoSoggettoRichiedenteSelect.options[i].value;
				defaultOptions[i].text = tipoSoggettoRichiedenteSelect.options[i].text;
				if (tipoSoggettoRichiedenteSelect.options[i].value == tipoSoggettoRichiedenteUtenteId) {
					tipoSoggettoRichiedenteUtenteDescription = tipoSoggettoRichiedenteSelect.options[i].text;
				}				
			}
			var hiddenValue = document.getElementById('assistitoIsRichiedenteHiddenId').value;
			var assistitoIsRichiedenteChechBox = document.getElementById('assistitoIsRichiedenteId');
			if (hiddenValue == "true") {				
				if (assistitoIsRichiedenteChechBox) assistitoIsRichiedenteChechBox.checked = true;
				if (document.getElementById('id_richiedenteLookup')) {
					document.getElementById('idDivLookupRichiedente').style.visibility = 'hidden';
					document.getElementById('idDivChooseRichiedenteSoggSignNucleoId').style.visibility = 'hidden';	
				}
				if (document.getElementById('denomRichiedente')) {					
					document.getElementById('denomRichiedente').readOnly = true;
				}
				tipoSoggettoRichiedenteSelect.options.length = 1;
				tipoSoggettoRichiedenteSelect.options[0].value = tipoSoggettoRichiedenteUtenteId;
				tipoSoggettoRichiedenteSelect.options[0].text = tipoSoggettoRichiedenteUtenteDescription;
			} else {
				if (assistitoIsRichiedenteChechBox) assistitoIsRichiedenteChechBox.checked = false;
				if (document.getElementById('id_richiedenteLookup')) {
					document.getElementById('idDivLookupRichiedente').style.visibility = 'visible';
					document.getElementById('idDivChooseRichiedenteSoggSignNucleoId').style.visibility = 'visible';	
				}
				if (document.getElementById('denomRichiedente')) {					
					document.getElementById('denomRichiedente').readOnly = false;
				}
			}
		}
	}
	registerOnDocumentLoad(initCheckAssistitoIsRichiedente);
	var _mode = bui_datamanagement.getMode();
	if (_mode.isCreate() || _mode.isUpdate()) {
		registerOnDocumentLoad(switchLuogoProvenienza);
	}
	function importaDataInizioResidenza() {
		var nominativoAssistito = document.getElementById("nominativo_assistitoLookup").value;
		var idSoggetto = document.getElementById("id_assistitoLookup").value;	

		if (nominativoAssistito == '') {
			alert('Obbligatorio selezionare il Soggetto della Domanda prima di importare da Anagrafe Centrale la data inizio residenza nel Comune');
			return;
		}

		var dataInizioResidenzaRet = getDataInizioResidenza(idSoggetto);
		
		if (dataInizioResidenzaRet == 'Errore') {
			alert("Si � verificato un errore di comunicazione con l'Anagrafe Centrale");
		} else if (dataInizioResidenzaRet == 'null' || parseDate(dataInizioResidenzaRet, 'dd/MM/yyyy') == null) {
			alert('Informazione non disponibile in Anagrafe Centrale');
		} else if (dataInizioResidenzaRet == 'NoServizio') {
			alert('Non � disponibile un servizio di riferimento');
		} else {
			document.getElementById("dataInizioResidenzaCLD").value = dataInizioResidenzaRet;
		} 
	}
	
	
	var _dataInizioResidenza;
	
	function getDataInizioResidenza(idSoggetto) {
		_dataInizioResidenza = null;
		jsLoadString('it.cedaf.icare.anagrafiche.control.action.GetInizioDataResidenzaExecutor', '&idSoggetto=' + idSoggetto + "&idDomanda=" + cpGetMasterColumnValueOfCurrentRow('id'), '_setDataInizioResidenza', JS_SYNC);		
		return _dataInizioResidenza;
	}	
	
	function _setDataInizioResidenza(dataResid) {
		_dataInizioResidenza = dataResid;
	}
	
	function controllaAssistito() {
		var creaPIC = document.getElementById('creaPICId_0');
		var creaPIC_no = document.getElementById('creaPICId_1');
		var idSoggetto = document.getElementById('id_assistitoLookup').value;
		var soggAss = document.getElementById('assistito_assistitoLookup').value;
		if (creaPIC.checked && idSoggetto != '' && soggAss != 'si') {
			// Controllo sul soggetto
			var hasRequiredData = jsLoadString('it.cedaf.icare.anagrafiche.control.action.HasRequiredDataPICExecutor', 
				'&id=' + idSoggetto + '&funzione=domanda');
			if (hasRequiredData == 'false') {
				alert('Non � possibile creare la presa in carico perch� il soggetto \nselezionato non ha tutte le informazioni richieste dal sistema');
				creaPIC.checked = false;
				creaPIC_no.checked = true;
			}			
		}		
	}

	/**  */
	function importaSoggSignNucleo() {
		var idSoggettoDom;
		var idSoggettoDomCmp = document.getElementById('id_assistitoLookup');
		if (idSoggettoDomCmp != null) {
			idSoggettoDom = idSoggettoDomCmp.value;
		}

		shellSingleChoose('soggettoSignificativoNucleoRichiedente', 
			'it.cedaf.icare.domande.commons.SoggettiSignificativiNucleoRichiedenteDomendaMultipleChooseInitializer', 
			'idSoggettoDom=' + idSoggettoDom + '&key=' + bui_datamanagement.getKey() + shellGetSelectedRowParam(), null, 700, 300);
	}	
	
	function onChangeMultipleChoose_soggettoSignificativoNucleoRichiedente() {
		var idSoggRichiedente = getMultipleChooseColumnValues("id")[0];
		if (idSoggRichiedente != '') {
			var cognome_label = $BundleHandler.getBundle('LBL_cognome', null);
			var nome_label = $BundleHandler.getBundle('LBL_nome', null);
			var cognome = getMultipleChooseColumnValues(cognome_label)[0];
			var nome = getMultipleChooseColumnValues(nome_label)[0];			
			document.getElementById('id_richiedenteLookup').value = idSoggRichiedente;
			document.getElementById('nominativo_richiedenteLookup').value = cognome + ' ' + nome;
		}

	}

	function onChangeLookup_assistitoLookup() {
		selectAUSLComuneProvenienzaDefault();
	}

	function onClearLookup_assistitoLookup() {
		selectAUSLComuneProvenienzaDefault();
	}

	function onChangeDataDomanda() {
		selectAUSLComuneProvenienzaDefault();
	}
	
	function selectAUSLComuneProvenienzaDefault() { 
		var idSoggetto = document.getElementById('id_assistitoLookup').value;
		var dataDomanda = document.getElementById("dataCollocazioneCLD").value;
		var idComboAuslProvenienza = 'idAuslProvenienza';
		if (document.getElementById(idComboAuslProvenienza)) {
			var params = '';
			params += 'idSoggetto=' + idSoggetto;
			params += '&dataRif=' + dataDomanda;
			jsLoadSelectOptionsAndFill(idComboAuslProvenienza, 'it.cedaf.icare.domande.commons.AuslProvenienzaDomandaSelectOptions', params, ' ', null, false, 'false');
		}
		if (idSoggetto!='') {
			var nomeComuneProvenienza = 'nome_luogoProvenienza';
			if (document.getElementById(nomeComuneProvenienza)) {
				jsLoadMap('it.cedaf.icare.domande.control.action.LoadComuneProvenienzaExecutor', 
						'idSoggetto=' + idSoggetto, 'selectComuneProvenienzaDefault', JS_SYNC);
				
			}
		} else {
			switchLuogoProvenienza(true);
			document.getElementById('esteroProvenienzaId_0').checked=false;
			document.getElementById('esteroProvenienzaId_1').checked=false;
		}
	}

	function selectComuneProvenienzaDefault(map) {
		if (map) {
			var inputNomeComuneProvenienza = document.getElementById('nome_luogoProvenienza');
			if (inputNomeComuneProvenienza) {
				var nomeComune = map.get('nome_comune');
				var idComune = map.get('id_comune');
				if (nomeComune && idComune) {
					inputNomeComuneProvenienza.value=nomeComune;
					var inputIdComuneProvenienza = document.getElementById('id_luogoProvenienza');
					if (inputIdComuneProvenienza) {
						document.getElementById('esteroProvenienzaId_1').checked=true;
						inputIdComuneProvenienza.value=idComune;
						return;
					}
				}	
			}
		}
		switchLuogoProvenienza(true);
		document.getElementById('esteroProvenienzaId_0').checked=false;
		document.getElementById('esteroProvenienzaId_1').checked=false;
	}

	<bui:out modes="view">
		function eformat_cpmt_nominativoAssistito(element, value, name) {
			linkToSoggetto('idAssistito', element, value);			
		}

		function eformat_cpmt_nominativoRichiedente(element, value, name) { 
			if (value != null && value != '' && value !='@null') {
				linkToSoggetto('idRichiedente', element, value);
			}
			else {
				// altrimenti non lo sbianca se passo a uno che non ce l'ha
				element.innerHTML = "";
			}
		}
	</bui:out>
</script>

<shell:fieldset title="${j:bundle('LBL_domande_domanda_infoSogg_SET')}">
	<table border="0" cellpadding="0" cellspacing="3" width="100%">	
        <tr>
        	<td valign="top" width="50%">
				<table border="0" cellpadding="0" cellspacing="3">
					<tr>
						<td class="form-label">
							<shell:label prop="nominativoAssistito" />
						</td>
						<td class="form-values">
							<c:choose>
								<c:when test="${bui:isMode(null, 'record_created')}">
									<j:bind prop="nominativoAssistito">
										<j:text class="form-normal-text" readonly="true" id="nominativo_assistitoLookup" />
										<shell:error />
									</j:bind>
								  	<j:bind prop="idSoggettoEntita">
										<j:hidden id="id_assistitoLookup"/>
										<shell:error />
									</j:bind>
									<j:bind prop="codiceFiscaleAssistito">
										<j:hidden id="codFisc_assistitoLookup"/>										
									</j:bind>
									<input type="hidden" id="assistito_assistitoLookup">
									<c:if test="${empty nascondiLookup || nascondiLookup == 'false'}">
										<shell:lookup lookupId="assistitoLookup" 
											identifier="anagrafiche.soggetto" init="it.cedaf.icare.anagrafiche.model.datamanagement.SoggettoLookupInitializer" 
											params="entityIdentifier=domanda&importNucleo=true&disableComplete=true" noCommitOnCreate="id=-1" />
									</c:if>
								</c:when>
								<c:otherwise>
									<j:tile name="shell.plaintext" prop="nominativoAssistito" />
									<bui:out modes="create,update">
										<j:bind prop="codiceFiscaleAssistito">
											<j:hidden id="codFisc_assistitoLookup"/>										
										</j:bind>
										<j:bind prop="nominativoAssistito">
											<j:hidden id="nominativo_assistitoLookup"/>										
										</j:bind>
										<j:bind prop="idSoggettoEntita">
											<j:hidden id="id_assistitoLookup"/>
										</j:bind>
									</bui:out>
								</c:otherwise>
							</c:choose>
						</td>
 					</tr>
    			</table>
    		</td>
    		<td valign="top" width="50%">
				<table border="0" cellpadding="0" cellspacing="3">
					<tr>
						<bui:out modes="create,update">
							<td class="form-values">
								<c:if test="${empty nascondiChk || nascondiChk == 'false'}">
									<j:bind prop="assistitoIsRichiedente">
										<j:hidden id="assistitoIsRichiedenteHiddenId" />
										<input type="checkbox" id="assistitoIsRichiedenteId" name="assistitoIsRichiedenteCheckBox" onclick="javascript:checkAssistitoIsRichiedente();">
										<shell:label prop="assistitoIsRichiedente" />
									</j:bind>
								</c:if>
							</td>
						</bui:out>
					</tr>
				</table>
			</td>
    	</tr>
    </table>
</shell:fieldset>

<table border="0" cellpadding="0" cellspacing="3" width="100%">
	<tr>
		<td valign="top" width="50%">				
			<shell:fieldset title="${j:bundle('LBL_domande_domanda_infoDom_SET')}">			
				<bui:out modes="create, update">
					<j:bind prop="nuovaTipologiaRichiesta">
						<j:hidden id="idNuovaTipologiaRichiesta"/>
					</j:bind>	
				</bui:out>
				<table border="0" cellpadding="0" cellspacing="3">
					<tr>
						<td class="form-label">
							<shell:label prop="icaroCode" />
						</td>
						<td class="form-values">
							<j:tile name="shell.plaintext" prop="icaroCode" />	
						</td>
 					</tr>
					<icare:ifOptional prop="Firmatario [p]">						
					<tr>
						<td class="form-label">
							<shell:label prop="nominativoRichiedente" />
						</td>
						<td class="form-values">
							<bui:out modes="view">
								<j:tile name="shell.plaintext" prop="nominativoRichiedente" />
							</bui:out>
							<bui:out modes="create, update">
								<j:bind prop="nominativoRichiedente">
									<j:text class="form-normal-text" readonly="true" id="nominativo_richiedenteLookup" />
									<shell:error />
								</j:bind>
							  	<j:bind prop="idRichiedente">
									<j:hidden id="id_richiedenteLookup"/>
									<shell:error />
								</j:bind>
								<span id="idDivChooseRichiedenteSoggSignNucleoId" >
									<a href="javascript:importaSoggSignNucleo();"><img src="${j:getResourceUrlOfModule('commons', 'img/user_import_small.gif')}" alt="${j:bundle('LBL_domande_domanda_importaSoggSignNucleo_TOOLTIP')}" title="${j:bundle('LBL_domande_domanda_importaSoggSignNucleo_TOOLTIP')}" align="absmiddle" border="0" /></a>
								</span>&nbsp;									
								<span id="idDivLookupRichiedente">
									<shell:lookup lookupId="richiedenteLookup" identifier="anagrafiche.soggetto" init="it.cedaf.icare.anagrafiche.model.datamanagement.SoggettoLookupInitializer" params="disableComplete=true" noCommitOnCreate="id=-1" />									
								</span>
							</bui:out>	
						</td>
 					</tr>
 					</icare:ifOptional>
 					<icare:ifOptional prop="Denominazione firmatario [p]"> 					
 					<tr>
						<td class="form-label">
							<shell:label prop="denominazioneRichiedente" />
						</td>
						<td class="form-values">
							<bui:out modes="view">
								<j:tile name="shell.plaintext" prop="denominazioneRichiedente" />
							</bui:out>
							<bui:out modes="create, update">
								<j:bind prop="denominazioneRichiedente">
									<j:text class="form-normal-text" id="denomRichiedente" />
									<shell:error />
								</j:bind>
							</bui:out>	
						</td>
 					</tr>
 					</icare:ifOptional>
					<tr>   
						<td class="form-label">
					    	<shell:label prop="tipoSoggettoRichiedente" />
			    		</td>
						<td class="form-values">
					    	<bui:out modes="view">   
								<j:tile name="shell.plaintext" prop="tipoSoggettoRichiedente" />
							</bui:out>
							<bui:out modes="update,create">
						    	<j:bind prop="tipoSoggettoRichiedente">
									<j:select id="tipoSoggettoRichiedenteSelectId" class="form-input" emptyOptionDescr=" " selectIfUnique="true"/> 
								    <shell:error />
								</j:bind>
						   	</bui:out> 
						</td>
					</tr>				
					<tr>
						<td class="form-label">
							<shell:label prop="dataCollocazione" />
						</td>
						<td class="form-values">
							<bui:out modes="view">
								<j:tile name="shell.plaintext" prop="dataCollocazione" />
							</bui:out>
							<bui:out modes="create, update">
								<j:bind prop="dataCollocazione">
									<j:text class="form-date" id="dataCollocazioneCLD" onChange="getOperatoriRiferimento('storicizzaOperatoreRiferimento');onChangeDataDomanda();" />
									<shell:calendar inputId="dataCollocazioneCLD" />
									<shell:error />
								</j:bind>
							</bui:out>
						</td>						
					</tr>
					<icare:ifOptional prop="AUSL Provenienza [p]">
					<tr>   
						<td class="form-label">
				    		<shell:label prop="auslProvenienza" />
				    	</td>
						<td class="form-values">
					    	<bui:out modes="view">   
								<j:tile name="shell.plaintext" prop="auslProvenienza" />
							</bui:out>
							<bui:out modes="create, update">
								<j:bind prop="auslProvenienza">
									<j:select class="form-input" emptyOptionDescr=" " id="idAuslProvenienza"/> 
								    <shell:error />
								</j:bind>
							</bui:out> 
						</td>
					</tr>		
					</icare:ifOptional>	
					<icare:ifOptional prop="Comune/Stato Estero Provenienza [p]">
					<tr>   
				      	<td class="form-label">
				    		<shell:label prop="esteroProvenienza" />
				    	</td>
				    	<td class="form-values">
				    		<bui:out modes="view">   
						  		<j:tile name="shell.plaintext" prop="esteroProvenienza" />
							</bui:out>
							<bui:out modes="update,create">
						    	<j:bind prop="esteroProvenienza">	
							    	<j:radio id="esteroProvenienzaId_0" displayValue="si" onclick="switchLuogoProvenienza(true);"  />${j:bundle('LBL_si')}
									<j:radio id="esteroProvenienzaId_1" displayValue="no" onclick="switchLuogoProvenienza(true);"  />${j:bundle('LBL_no')}
									<shell:error />
								</j:bind>
					   		</bui:out>
					   	</td>
				  	</tr>
				  	<tr>   
				      	<td class="form-label">
				      		<shell:label prop="nomeLuogoProvenienza" labelId="luogoProvenienzaLabelId"/>
				    	</td>
				    	<td class="form-values">
				    		<bui:out modes="view">   
						  		<j:tile name="shell.plaintext" prop="luogoProvenienza" />
							</bui:out>
				   			<bui:out modes="update,create">
					    		<j:bind prop="nomeLuogoProvenienza">
								 	<j:text class="form-normal-text" id="nome_luogoProvenienza" onChange="javascript:changeIdLuogoProvenienzaLookup();"/>
									<shell:error />
								</j:bind>
								<j:bind prop="luogoProvenienza">
									<j:hidden id="id_luogoProvenienza"/>
								</j:bind>
								<shell:lookup lookupId="luogoProvenienza" identifier="tabelleterritoriali.comune" 
									init="it.cedaf.icare.commons.model.datamanagement.ComuneLookupInitializer" 
									formParams="nome_luogoProvenienza|nome" />
				   			</bui:out>
				   		</td>
				  	</tr>	
					</icare:ifOptional>								
					<tr>   
						<td class="form-label">
				    		<shell:label prop="enteDestinatario" />
				    	</td>
						<td class="form-values">
					    	<bui:out modes="view">   
								<j:tile name="shell.plaintext" prop="enteDestinatario" />
							</bui:out>
							<bui:out modes="create, update">
								<j:bind prop="enteDestinatario">
									<j:select class="form-input" emptyOptionDescr=" "/> 
								    <shell:error />
								</j:bind>
							</bui:out> 
						</td>
					</tr>
					<icare:ifOptional prop="Creazione contestuale PIC [p]">
					<c:if test="${bui:isMode(null, 'record_created') && j:isAuthorizedAction('prese_in_carico', 'create')}">
						<tr>   
							<td class="form-label">
					    		<shell:label prop="creaPIC" />
					    	</td>
							<td class="form-values">
								<j:bind prop="creaPIC">
									<j:radio id="creaPICId_0" displayValue="si" onClick="javascript:controllaAssistito();"/>${j:bundle('LBL_si')}
									<j:radio id="creaPICId_1" displayValue="no" />${j:bundle('LBL_no')}
									<shell:error />
								</j:bind>								
							</td>
						</tr>
					</c:if>	
					</icare:ifOptional>	
					<icare:ifOptional prop="Consenso Informato [p]">
			 		<tr>
						<td class="form-label">
							<shell:label prop="consensoInformato" />
						</td>
						<td class="form-values">
							<bui:out modes="view">
								<j:tile name="shell.plaintext" prop="consensoInformato"/>
							</bui:out>
							<bui:out modes="create,update">
								<j:bind prop="consensoInformato">
									<j:radio displayValue="" />${j:bundle('LBL_nonRilevato')}
							    	<j:radio displayValue="si" />${j:bundle('LBL_si')}
									<j:radio displayValue="no" />${j:bundle('LBL_no')}
									<shell:error />
								</j:bind>
							</bui:out>
						</td>
			 		</tr>
			 		</icare:ifOptional>									
				</table>		
			</shell:fieldset>
		</td>
		<td valign="top" width="50%">				
			<shell:fieldset title="${j:bundle('LBL_domande_domanda_infoOp_SET')}">
				<table border="0" cellpadding="0" cellspacing="3">
					<j:tile name="commons.opRifStoricizzato" idSoggettoIBeanDescriptorName="idAssistito" objectName="Domanda" idField="id"/>
					<j:tile name="commons.opAbilitato" objectName="Domanda" idField="id" sendToAbilitato="true"/>
 				</table>		
			</shell:fieldset>
		</td>
	</tr>
</table>	

<icare:ifOptional prop="Protocollo [f]" dataManagement="domande.domanda" >	
<shell:fieldset title="${j:bundle('LBL_domande_domanda_infoProt_SET')}">		
	<c:choose>
		<c:when test="${!empty protocolloNonModificabile && protocolloNonModificabile == 'true'}">
			<table border="0" cellpadding="0" cellspacing="3" width="100%">
				 <tr>
					<td class="form-label">
						<shell:label prop="numeroProtocollo" />
					</td>
					<td class="form-values">
						<j:tile name="shell.plaintext" prop="numeroProtocollo" />
					</td>
				</tr>
				<tr>
					<td class="form-label">
						<shell:label prop="dataProtocollo" />
					</td>
					<td class="form-values">
						<j:tile name="shell.plaintext" prop="dataProtocollo" />
					</td>
				</tr>
			</table>
			</td><td valign="top">
			<table border="0" cellpadding="0" cellspacing="3" width="100%">
				 <tr>
					<td class="form-label">
						<shell:label prop="classificaProtocollo" />
					</td>
					<td class="form-values">
						<j:tile name="shell.plaintext" prop="classificaProtocollo" />
					</td>
				</tr>
				<tr>
					<td class="form-label">
						<shell:label prop="fascicoloProtocollo" />
					</td>
					<td class="form-values">
						<j:tile name="shell.plaintext" prop="fascicoloProtocollo" />
					</td>
				</tr>
			</table>
		</c:when>
		<c:otherwise>
			<table border="0" cellpadding="0" cellspacing="3" width="100%">
				<tr>
					<td class="form-label">
						<shell:label prop="numeroProtocollo" />
					</td>
					<td class="form-values">
						<bui:out modes="view">
							<j:tile name="shell.plaintext" prop="numeroProtocollo" />
						</bui:out>
						<bui:out modes="create, update">
							<j:bind prop="numeroProtocollo">
								<j:text class="form-normal-text" />
								<shell:error />
							</j:bind>
						</bui:out>
					</td>						
				</tr>
				<tr>
					<td class="form-label">
						<shell:label prop="dataProtocollo" />
					</td>
					<td class="form-values">
						<bui:out modes="view">
							<j:tile name="shell.plaintext" prop="dataProtocollo" />
						</bui:out>
						<bui:out modes="create, update">
							<j:bind prop="dataProtocollo">
								<j:text class="form-date" id="dataProtocolloCLD" />
								<shell:calendar inputId="dataProtocolloCLD" />
								<shell:error />
							</j:bind>
						</bui:out>
					</td>						
				</tr>
				<tr>
					<td>
						&nbsp;
					</td>
					<td class="form-values">
						<j:tile name="commons.protocollazione" protContext="DO_A" />
					</td>					
				</tr>
			</table>
			</td><td valign="top">
			<table border="0" cellpadding="0" cellspacing="3" width="100%">
				<tr>
					<td class="form-label">
						<shell:label prop="classificaProtocollo" />
					</td>
					<td class="form-values">
						<bui:out modes="view">
							<j:tile name="shell.plaintext" prop="classificaProtocollo" />
						</bui:out>
						<bui:out modes="create, update">
							<j:bind prop="classificaProtocollo">
								<j:text class="form-normal-text" />
								<shell:error />
							</j:bind>
						</bui:out>
					</td>						
				</tr>
				<tr>
					<td class="form-label">
						<shell:label prop="fascicoloProtocollo" />
					</td>
					<td class="form-values">
						<bui:out modes="view">
							<j:tile name="shell.plaintext" prop="fascicoloProtocollo" />
						</bui:out>
						<bui:out modes="create, update">
							<j:bind prop="fascicoloProtocollo">
								<j:text class="form-normal-text" />
								<shell:error />
							</j:bind>
						</bui:out>
					</td>						
				</tr>
			</table>
		</c:otherwise>		
	</c:choose>	
</shell:fieldset>
</icare:ifOptional>	

<icare:ifOptional prop="Residenza Comune [f]">	
<shell:fieldset title="Informazioni residenza nel Comune">
	<table border="0" cellpadding="0" cellspacing="3" width="100%"> 	
		<tr>
			<td class="form-label">
				<shell:label prop="dataInizioResidenza" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="dataInizioResidenza" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="dataInizioResidenza">
						<j:text class="form-date" id="dataInizioResidenzaCLD" />
						<shell:calendar inputId="dataInizioResidenzaCLD" />
						<shell:button id="dataInizioResidenzaHref" text="Importa da Anagrafe Centrale" img="commons.calcolatrice" title="Importa data inizio residenza" href="javascript: importaDataInizioResidenza();" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>						
		</tr>
	</table>
</shell:fieldset>
</icare:ifOptional>

<icare:ifOptional prop="Riferimento [f]" dataManagement="domande.domanda">
	<shell:fieldset title="${j:bundle('LBL_domande_domanda_riferimenti_SET')}">
		<table border="0" cellpadding="0" cellspacing="3" width="100%">
			<tr>
				<td valign="top" width="50%">	
					<table align="left" border="0" cellspacing="3" cellpadding="0">
						<tr>
							<td class="form-label" rowspan="3">
								<shell:label prop="riferimento"/>							
							</td>						
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_nominativoRiferimento')}
							</td>
							<td class="form-values" colspan="3">
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="nominativoRiferimento" />
								</bui:out>
								<bui:out slave="${_slave}" modes="create,update">
									<j:bind prop="nominativoRiferimento">
										<j:text class="form-long-text" />
										<shell:error />
									</j:bind>
								</bui:out>
							</td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_telRiferimento')} 
							</td>
							<td class="form-values" style="width:10em;">						
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="telRiferimento" />
								</bui:out>
						 		<bui:out modes="create,update" slave="${_slave}">
							 		<j:bind prop="telRiferimento">
						 				<j:text class="form-normal-text" style="width:8em;" />
						 				<shell:error />
						 			</j:bind>
						 		</bui:out>
							</td>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_emailRiferimento')}
							</td>
							<td class="form-values" style="width:22em;">
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="emailRiferimento" />
								</bui:out>
								<bui:out modes="create,update" slave="${_slave}">
									<j:bind prop="emailRiferimento">
										<j:text class="form-normal-text" />
										<shell:error />
									</j:bind>
								</bui:out>
							</td>
						</tr>
						<tr>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_indirizzoRiferimento')} 
							</td>
							<td class="form-values" colspan="3">						
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="indirizzoRiferimento" />
								</bui:out>
						 		<bui:out modes="create,update" slave="${_slave}">
							 		<j:bind prop="indirizzoRiferimento">
						 				<j:text class="form-normal-text" />
						 				<shell:error />
						 			</j:bind>
						 		</bui:out>
							</td>
							<td></td>
							<td></td>
						</tr>
					</table>
				</td>	
				<td valign="top" width="50%">
		<icare:ifOptional prop="Riferimenti aggiuntivi [p]">				
					<table align="left" border="0" cellspacing="3" cellpadding="0">
						<tr>
							<td class="form-label" rowspan="3">
								<shell:label prop="riferimento2"/>							
							</td>						
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_nominativoRiferimento2')}
							</td>
							<td class="form-values" colspan="3">
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="nominativoRiferimento2" />
								</bui:out>
								<bui:out slave="${_slave}" modes="create,update">
									<j:bind prop="nominativoRiferimento2">
										<j:text class="form-long-text"/>
										<shell:error />
									</j:bind>
								</bui:out>
							</td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_telRiferimento2')} 
							</td>
							<td class="form-values"  style="width:10em;">								
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="telRiferimento2" />
								</bui:out>
						 		<bui:out modes="create,update" slave="${_slave}">
							 		<j:bind prop="telRiferimento2">
						 				<j:text class="form-normal-text" style="width:8em;"/>
						 				<shell:error />
						 			</j:bind>
						 		</bui:out>
							</td>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_emailRiferimento2')}
							</td>
							<td class="form-values" style="width:22em;">
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="emailRiferimento2" />
								</bui:out>
								<bui:out modes="create,update" slave="${_slave}">
									<j:bind prop="emailRiferimento2">
										<j:text class="form-normal-text" />
										<shell:error />
									</j:bind>
								</bui:out>
							</td>
						</tr>
						<tr>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_indirizzoRiferimento2')} 
							</td>
							<td class="form-values" colspan="3">						
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="indirizzoRiferimento2" />
								</bui:out>
						 		<bui:out modes="create,update" slave="${_slave}">
							 		<j:bind prop="indirizzoRiferimento2">
						 				<j:text class="form-normal-text" />
						 				<shell:error />
						 			</j:bind>
						 		</bui:out>
							</td>
							<td></td>
							<td></td>
						</tr>
					</table>		
			</icare:ifOptional>
				</td>			
			</tr>
		<icare:ifOptional prop="Riferimenti aggiuntivi [p]">
			<tr> 				
				<td valign="top" width="50%">
					<table align="left" border="0" cellspacing="3" cellpadding="0">
						<tr>
							<td class="form-label" rowspan="3">
								<shell:label prop="riferimento3"/>							
							</td>						
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_nominativoRiferimento3')}
							</td>
							<td class="form-values" colspan="3">
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="nominativoRiferimento3" />
								</bui:out>
								<bui:out slave="${_slave}" modes="create,update">
									<j:bind prop="nominativoRiferimento3">
										<j:text class="form-long-text"/>
										<shell:error />
									</j:bind>
								</bui:out>
							</td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_telRiferimento3')} 
							</td>
							<td class="form-values"  style="width:10em;">								
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="telRiferimento3" />
								</bui:out>
						 		<bui:out modes="create,update" slave="${_slave}">
							 		<j:bind prop="telRiferimento3">
						 				<j:text class="form-normal-text" style="width:8em;"/>
						 				<shell:error />
						 			</j:bind>
						 		</bui:out>
							</td>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_emailRiferimento3')}
							</td>
							<td class="form-values" style="width:22em;">
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="emailRiferimento3" />
								</bui:out>
								<bui:out modes="create,update" slave="${_slave}">
									<j:bind prop="emailRiferimento3">
										<j:text class="form-normal-text" />
										<shell:error />
									</j:bind>
								</bui:out>
							</td>
						</tr>
						<tr>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_indirizzoRiferimento3')} 
							</td>
							<td class="form-values" colspan="3">						
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="indirizzoRiferimento3" />
								</bui:out>
						 		<bui:out modes="create,update" slave="${_slave}">
							 		<j:bind prop="indirizzoRiferimento3">
						 				<j:text class="form-normal-text" />
						 				<shell:error />
						 			</j:bind>
						 		</bui:out>
							</td>
							<td></td>
							<td></td>
						</tr>
					</table>
				</td>
				<td valign="top" width="50%">
					<table align="left" border="0" cellspacing="3" cellpadding="0">
						<tr>
							<td class="form-label" rowspan="3">
								<shell:label prop="riferimento4"/>							
							</td>						
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_nominativoRiferimento4')}
							</td>
							<td class="form-values" colspan="3">
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="nominativoRiferimento4" />
								</bui:out>
								<bui:out slave="${_slave}" modes="create,update">
									<j:bind prop="nominativoRiferimento4">
										<j:text class="form-long-text"/>
										<shell:error />
									</j:bind>
								</bui:out>
							</td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_telRiferimento4')} 
							</td>
							<td class="form-values"  style="width:10em;">								
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="telRiferimento4" />
								</bui:out>
						 		<bui:out modes="create,update" slave="${_slave}">
							 		<j:bind prop="telRiferimento4">
						 				<j:text class="form-normal-text" style="width:8em;"/>
						 				<shell:error />
						 			</j:bind>
						 		</bui:out>
							</td>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_emailRiferimento4')}
							</td>
							<td class="form-values" style="width:22em;">
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="emailRiferimento4" />
								</bui:out>
								<bui:out modes="create,update" slave="${_slave}">
									<j:bind prop="emailRiferimento4">
										<j:text class="form-normal-text" />
										<shell:error />
									</j:bind>
								</bui:out>
							</td>
						</tr>
						<tr>
							<td class="form-values" align="right">
								${j:bundle('LBL_domande_domanda_indirizzoRiferimento4')} 
							</td>
							<td class="form-values" colspan="3">						
								<bui:out modes="view" slave="${_slave}">
									<j:tile  slave="${_slave}" name="shell.plaintext" prop="indirizzoRiferimento4" />
								</bui:out>
						 		<bui:out modes="create,update" slave="${_slave}">
							 		<j:bind prop="indirizzoRiferimento4">
						 				<j:text class="form-normal-text" />
						 				<shell:error />
						 			</j:bind>
						 		</bui:out>
							</td>
							<td></td>
							<td></td>
						</tr>
					</table>				
				</td>			 
			</tr>		
		</icare:ifOptional>
		</table>		
	</shell:fieldset>
</icare:ifOptional>

<shell:fieldset title="${j:bundle('LBL_domande_domanda_infoAgg_SET')}">
	<table border="0" cellpadding="0" cellspacing="3" width="100%"> 	
		<tr>
			<td class="form-label">
				<shell:label prop="note" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="note" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="note">
						<j:textarea class="form-normal-textarea" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>						
		</tr>
	</table>
</shell:fieldset>