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

<script type="text/javascript" src="${j:getResourceUrlOfModule('domande', 'js/richiesteUtils.js')}"></script>
<script type="text/javascript">
	var master = true;	
	
	function setGiorniSettimanaCheck(giorni) {
		for (var i=0; i<7; i++) {
			document.getElementById("gsCheck_" + i).checked = (giorni.charAt(i) == 1);
		}	
	}
	
	function getDataInizioRifSoggettiFittizi() {
		var dataInizioRegola = document.getElementById('dataInizioCld').value;
		if (dataInizioRegola != '') {
			return dataInizioRegola;
		} 
		return cpGetMasterColumnValueOfCurrentRow('dataInizioGrid');
	}
	
	function getDataFineRifSoggettiFittizi() {	
		var dataFineRegola = document.getElementById('dataFineCld').value;
		if (dataFineRegola != '') {
			return dataFineRegola;
		} 
		return cpGetMasterColumnValueOfCurrentRow('dataTermineGrid');
	}
</script>

<c:if test="${!empty _slave}">
	<script type="text/javascript">
		var master = false;	
	</script>
	
	<j:tile slave="${_slave}" name="shell.slaveToolbar" />
	<icare:grid description="tipoFrequenza,20%; tariffario,30%; importoTab,10%; quantita,20%; dataInizio,10%; descrizioneFine,10%" slave="${_slave}" />
</c:if>

<script type="text/javascript">	
	registerOnDocumentLoad(function() {
		if (!bui_datamanagement.getMode().isView()) {
			sceltaTariffarioDisplay();
						
			var txtHidden = document.getElementById('tipoFineId');
			if (txtHidden) onChangeTipoFine(txtHidden.value);	
			
			if (naturaPagamentoRefreshVideo)naturaPagamentoRefreshVideo();			 		
		}
		
		if ((master && bui_datamanagement.getMode().isCreate()) || 
			(!master && bui_datamanagement.getMode().getActiveSlave() == 'regolePagamenti' && 
				bui_datamanagement.getMode().isCreate())) {		
			var tipoFrequenza = document.getElementById('cmbTipoFrequenza');
			var idTipoFrequenza = tipoFrequenza.options[tipoFrequenza.selectedIndex].value;
			showFestivi(idTipoFrequenza);
			
			var mostra = (document.getElementById('hdnTarPers').value == 'true');			
			switchTariffaPersonale(mostra, true);
		}
	});	

	registerOnLoadMaster(function() {
		if (!bui_datamanagement.getMode().isView()) {
		checkImpostazioniCalcImportoRegPag();
		}
	});
		
	function eformat_cpmt_segno(element, value) {
		var mostra = (cpGetMasterColumnValueOfCurrentRow('tariffarioPersonalizzato') == 'true');
		var idTipoFrequenza = cpGetMasterColumnValueOfCurrentRow('tipoFrequenzaCode');	
		onSlaveRowChange(mostra, idTipoFrequenza);
	}	
	function eformat_cpst_regolePagamenti_segno(element, value) {
		var mostra = (cpGetSlaveColumnValueOfCurrentRow('regolePagamenti', 'tariffarioPersonalizzato') == 'true');
		var idTipoFrequenza = cpGetSlaveColumnValueOfCurrentRow('regolePagamenti', 'tipoFrequenzaCode');
		onSlaveRowChange(mostra, idTipoFrequenza);
	}
	function onSlaveRowChange(mostra, idTipoFrequenza) {
		if (!bui_datamanagement.getMode().isCreate()) {			
			switchTariffaPersonale(mostra, true);
			showFestivi(idTipoFrequenza);				
		}		
	}
	
	function onChangeTipoFrequenza() {		
		var tipoFrequenza = document.getElementById('cmbTipoFrequenza');
		var idTipoFrequenza = tipoFrequenza.options[tipoFrequenza.selectedIndex].value;
		
		var param = '';
		if (idTipoFrequenza != '') {
			param = 'tipoFrequenza=' + idTipoFrequenza;
		}		
		jsLoadMultipleSelectOptions('it.cedaf.icare.domande.commons.LoadTariffarioMultiSelectOptions', param, JS_SYNC);

		showFestivi(idTipoFrequenza);
	}		

	function checkImpostazioniCalcImportoRegPag() {
		var idTipoFrequenza = '';
		var tipoFrequenza = document.getElementById('cmbTipoFrequenza');
		if (tipoFrequenza) {
			idTipoFrequenza = tipoFrequenza.options[tipoFrequenza.selectedIndex].value;
		} else {
			idTipoFrequenza = cpGetSlaveColumnValueOfCurrentRow('regolePagamenti', 'tipoFrequenzaCode');
		}
		if (idTipoFrequenza != '') {
			var idRichiesta = cpGetMasterColumnValueOfCurrentRow('idRichiesta');
			var params = "idRichiesta=" + idRichiesta + "&tipoFrequenza=" + idTipoFrequenza;
			jsLoadMap('it.cedaf.icare.interventi.control.action.CheckImpostazioniCalcoloImportoRegolaPagamentoExecutor', params, 'post_checkImpostazioniCalcImportoRegPag', JS_SYNC);
		}
	}
	
	function post_checkImpostazioniCalcImportoRegPag(resultMap) {
		var importoPersCalcolabile = false;
		var importoPersEditabile = true;

		if (resultMap != null) {
			var tmpVal = resultMap.get('importoCalcolabile');
			importoPersCalcolabile = tmpVal != null && tmpVal == 'true';
			if (importoPersCalcolabile) {
				tmpVal = resultMap.get('importoEditabile');
				importoPersEditabile = tmpVal != null && tmpVal == 'true';
			}
		}
		document.getElementById('importoCalcBtn').style.display = importoPersCalcolabile ? '' : 'none';
		document.getElementById('spanImportoCalcBtn').style.display = importoPersCalcolabile ? '' : 'none';			
		document.getElementById("inputImportoPers").readOnly = importoPersEditabile ? '' : 'readonly'; 
	}
	
	function afterLoadMultipleSelectOptions_vspDummy(elements) {
		for(var i=0; i<elements.length; i++) {
			if (elements[i].get('id') == 'mostraSceltaTariffPers') {
				var value = elements[i].get('value');
				var hdnScelta = document.getElementById('sceltaTariffarioHidden');
				if (hdnScelta) hdnScelta.value = value;
				sceltaTariffarioDisplay();
				
			} else if (elements[i].get('id') == 'mostraTariffaPersonale') {
				var mostra = (elements[i].get('value') == 'true');
				switchTariffaPersonale(mostra, true);
				checkImpostazioniCalcImportoRegPag();
			} else if (elements[i].get('id') == 'naturaPag') {
				var value = elements[i].get('value');
				var ctrlNatPag = document.getElementById('naturaPagamentoHiddenId');
				if (ctrlNatPag) {
					ctrlNatPag.value = value;
				}
				
				var benefIntervento = document.getElementById('beneficiarioInterventoId');
				if (benefIntervento) benefIntervento.value = 'false';
				
			} else if (elements[i].get('id') == 'benefSoloSoggSign') {
				var benefSoloSoggSignCmp = document.getElementById('benefSoloSoggSignHiddenId');
				if (benefSoloSoggSignCmp) {
					benefSoloSoggSignCmp.value = elements[i].get('value');
				}												
			} else if (elements[i].get('id') == 'soggettiFittizi') {
				var soggettoFittizioCmp = document.getElementById('codSoggFittiziHiddenId');
				if (soggettoFittizioCmp) {
					soggettoFittizioCmp.value = elements[i].get('value');
				}
			} else if (elements[i].get('id') == 'benefObbligatorio') {
				var benefObbligatorio = document.getElementById('benefObbligatorioHiddenId');
				if (benefObbligatorio) {
					benefObbligatorio.value = elements[i].get('value');
				}												
			} 
		}
		if (naturaPagamentoRefreshVideo) {
			naturaPagamentoRefreshVideo();	
		}		
	}

	
	function showFestivi(idTipoFrequenza) {		
		var elFestivi = document.getElementById('trFestivi');
				
		if (elFestivi) elFestivi.style.display = (idTipoFrequenza == 'D' ? '' : 'none');
				
		if (idTipoFrequenza != 'D') {
			var txtImportoFestivi = document.getElementById('txtImportoFestivi');
			if(txtImportoFestivi) txtImportoFestivi.value = '';
		}
						
		var tdTipoFine = document.getElementById('tdTipoFine');
		var showTrFine = (idTipoFrequenza != 'O' && idTipoFrequenza != '');	
		if (tdTipoFine) tdTipoFine.style.display = (showTrFine ? '' : 'none');
		
		var includiGiorni = document.getElementById('includiGiorni');
		var showIncludiGiorni = (idTipoFrequenza == 'D');
		if (includiGiorni) {
			includiGiorni.style.display = (showIncludiGiorni ? '' : 'none');
			if (showIncludiGiorni) {
				var radioButton = document.getElementsByName('includiGiorniFestivi');
				if (radioButton) {
					var almostOneChecked = false;
					for (var i = 0; i < radioButton.length; i++) {					
						if (radioButton[i].checked) almostOneChecked = true;
					}
					if (!almostOneChecked && radioButton.length > 0) radioButton[0].checked = true;
				}
			}
		}
	}	
	
	function clickTariffaPers(ctrl) {
		switchTariffaPersonale(ctrl.checked, false);			
	} 
	
	function switchTariffaPersonale(showTarPers, scriviCheck) {
		var tariffa = document.getElementById('hdnTarPers');
		var trComboTariffa = document.getElementById('trComboTariffa');
		var trTariffa = document.getElementById('trTariffaPersonalizzata');			
		if (showTarPers) {
			if (tariffa) tariffa.value = 'true';
			trComboTariffa.style.display='none';
			trTariffa.style.display='';
		} else {
			if (tariffa) tariffa.value = 'false';
			trComboTariffa.style.display='';
			trTariffa.style.display='none';
		}
		
		if (scriviCheck) {
			var chkTariffa = document.getElementsByName('persTar');
			if (chkTariffa[0]) chkTariffa[0].checked = showTarPers;
		}
	}
	
	
	function onChangeTipoFine(value) {
		var txtDataFine = document.getElementById('dataFineCld');
		txtDataFine.disabled = value != 'D';
		if (txtDataFine.disabled) {
			txtDataFine.value = '';
		}
		var txtOccorrenze = document.getElementById('occorrenzeTxt');
		txtOccorrenze.disabled = value != 'N';
		if (txtOccorrenze.disabled) {
			txtOccorrenze.value = '';
		}
				
		var radioButton = document.getElementsByName('tipoFineRB');
		if (radioButton) {
			for (var i = 0; i < radioButton.length; i++) {					
				if (radioButton[i].value == value) radioButton[i].checked = true;
			}
		}
		
		var txtHidden = document.getElementById('tipoFineId');
		if (txtHidden) txtHidden.value = value;
	}	
	
	
	function sceltaTariffarioDisplay() {
		var hdnScelta = document.getElementById('sceltaTariffarioHidden');
		if (hdnScelta) {
			var trScelta = document.getElementById('sceltaPers');
			if (trScelta) trScelta.style.display = (hdnScelta.value == 'true' ? '' : 'none');	
		}
	}

	function calcolaImportoRegola() {
		var idTipoFrequenza = '';
		var tipoFrequenza = document.getElementById('cmbTipoFrequenza');
		if (tipoFrequenza) {
			idTipoFrequenza = tipoFrequenza.options[tipoFrequenza.selectedIndex].value;
		} else {
			idTipoFrequenza = cpGetSlaveColumnValueOfCurrentRow('regolePagamenti', 'tipoFrequenzaCode');
		}
		var idRichiesta = cpGetMasterColumnValueOfCurrentRow('idRichiesta');
		var params = "idRichiesta=" + idRichiesta + "&tipoFrequenza=" + idTipoFrequenza;
		jsLoadMap('it.cedaf.icare.interventi.control.action.CalcolaImportoRegolaPagamentoExecutor', params, 'post_calcolaImportoRegola', JS_SYNC);
	}	

	function post_calcolaImportoRegola(resultMap) {
		var inputImportoPers = document.getElementById("inputImportoPers");
		var error = resultMap.get('error');
		if (error != null && error != 'undefined' && error != '') {
			inputImportoPers.value = '';
			inputImportoPers.readOnly = '';
			var msg = '____________________________________________________________________\n\n';
			msg += 'ERRORE: \n';
			msg += '____________________________________________________________________\n\n';
			msg += error;			
			alert(msg);
			return false;
		}
		var importoCalc = resultMap.get('importoCalc');
		if (importoCalc != null && importoCalc != 'undefined' && importoCalc != '') {
			inputImportoPers.value = importoCalc;
		} else {
			inputImportoPers.value = '';
			inputImportoPers.readOnly = '';
		}
	}

	<bui:out modes="view">
	function checkRegolaCreataComm() {
		var outputElem = document.getElementById('tr_RegolaCreataComm');
		if (outputElem != null) {
			var creataComm = cpGetSlaveColumnValueOfCurrentRow('${_slave}', 'creataDaCommissione');
			if (creataComm=='si') {
				outputElem.style.display='';
			} else {
				outputElem.style.display='none';
			}
		}
	}
	function eformat_cpmt_quantita(element, value, name) { 
		element.innerHTML = value;	
	    if (cpGetMasterCurrentRow()>-1) {
	    	formatDiffValorePropCommissione('','quantita','quantitaPropComm', '');
		}
	}	
	function eformat_cpmt_dataInizio(element, value, name) { 
		element.innerHTML = value;	
	    if (cpGetMasterCurrentRow()>-1) {
	    	formatDiffValorePropCommissione('','dataInizio','dataInizioPropComm', '');
		}
	}

	function eformat_cpmt_descrizioneFine(element, value, name) { 
		element.innerHTML = value;	
	    if (cpGetMasterCurrentRow()>-1) {
	    	formatDiffValorePropCommissione('','descrizioneFine','descrizioneFinePropComm', '');
		}
	}

	function eformat_cpmt_tariffario(element, value, name) { 
		element.innerHTML = value;	
	    if (cpGetMasterCurrentRow()>-1) {
	    	formatDiffValorePropCommissione('','tariffario','tariffarioPropComm', '');
			var span = document.getElementById('diffComm_${_slave}_tariffario');
			if (span != null && span.style.display=='') {
				var spanViewStorico = document.getElementById('diffComm_${_slave}_tariffarioStImp');
				if (spanViewStorico != null) {
					spanViewStorico.style.display='';
				}
			} else {
				var spanViewStorico = document.getElementById('diffComm_${_slave}_tariffarioStImp');
				if (spanViewStorico != null) {
					spanViewStorico.style.display='none';
				}
			}
		}
	}
	
	function eformat_cpmt_importo(element, value, name) { 
		element.innerHTML = value;	
	    if (cpGetMasterCurrentRow()>-1) {
	    	formatDiffValorePropCommissione('','importo','importoPropComm', '');
		}
	}

	function eformat_cpmt_includiGiorniFestivi(element, value, name) { 
		element.innerHTML = value;	
	    if (cpGetMasterCurrentRow()>-1) {
	    	formatDiffValorePropCommissione('','includiGiorniFestivi','includiGiorniFestiviPropComm', '');
		}
	}
	function eformat_cpmt_giorniSettimana(element, value, name) { 
		element.innerHTML = value;	
	    if (cpGetMasterCurrentRow()>-1) {
	    	formatDiffValorePropCommissione('','giorniSettimana','giorniSettimanaPropComm', '');
		}
	}
	
	function eformat_cpst_${_slave}_quantita(element, value, name) {
		element.innerHTML = value;	
		formatDiffValorePropCommissione('${_slave}','quantita','quantitaPropComm', '');
	}
	function eformat_cpst_${_slave}_dataInizio(element, value, name) {
		element.innerHTML = value;	
		formatDiffValorePropCommissione('${_slave}','dataInizio','dataInizioPropComm', '');
		checkRegolaCreataComm();
	}

	function eformat_cpst_${_slave}_descrizioneFine(element, value, name) { 
		element.innerHTML = value;	
		formatDiffValorePropCommissione('${_slave}','descrizioneFine','descrizioneFinePropComm', '');
	}
	function eformat_cpst_${_slave}_tariffario(element, value, name) { 
		element.innerHTML = value;	
		formatDiffValorePropCommissione('${_slave}','tariffario','tariffarioPropComm', '');
		var span = document.getElementById('diffComm_${_slave}_tariffario');
		if (span != null && span.style.display=='') {
			var spanViewStorico = document.getElementById('diffComm_${_slave}_tariffarioStImp');
			if (spanViewStorico != null) {
				spanViewStorico.style.display='';
			}
		} else {
			var spanViewStorico = document.getElementById('diffComm_${_slave}_tariffarioStImp');
			if (spanViewStorico != null) {
				spanViewStorico.style.display='none';
			}
		}
	}
	function eformat_cpst_${_slave}_importo(element, value, name) { 
		element.innerHTML = value;	
		formatDiffValorePropCommissione('${_slave}','importo','importoPropComm', '');
	}
	function eformat_cpst_${_slave}_includiGiorniFestivi(element, value, name) { 
		element.innerHTML = value;	
		formatDiffValorePropCommissione('${_slave}','includiGiorniFestivi','includiGiorniFestiviPropComm', '');
	}
	function eformat_cpst_${_slave}_giorniSettimana(element, value, name) { 
		element.innerHTML = value;	
		formatDiffValorePropCommissione('${_slave}','giorniSettimana','giorniSettimanaPropComm', '');
	}
	</bui:out>	
</script>

<shell:fieldset title="Informazioni regola">
	<bui:out slave="${_slave}" modes="create,update">									
		<j:bind prop="segno">
			<j:hidden  id="hdnSegno" />
		</j:bind>
		<j:bind prop="tariffarioPersonalizzato">
			<j:hidden id="hdnTarPers"/>
		</j:bind>
		<j:bind prop="sceltaTariffario">
			<j:hidden id="sceltaTariffarioHidden"/>
		</j:bind>
	</bui:out>
	<c:choose>
		<c:when test="${empty _slave}">
			<span id="cpmt_segno"/>
		</c:when>
		<c:otherwise>
			<span id="cpst_${_slave}_segno"/>
		</c:otherwise>
	</c:choose>
	<table border="0" cellspacing="3" cellpadding="0" align="left">
		<tr id="tr_RegolaCreataComm" style="display:none"><td colspan="2" class="form-values">[*** ${j:bundle('LBL_creataDaCommissione')} ***]</td></tr>
		<tr>
			<td class="form-label">
				<shell:label prop="tipoFrequenza" />
			</td>
			<td class="form-values">	
				<c:choose>
					<c:when test="${bui:isMode(_slave, 'record_created')}">
						<j:bind prop="tipoFrequenza">
							<j:select class="form-input" id="cmbTipoFrequenza" emptyOptionDescr="" onChange="javascript:onChangeTipoFrequenza();"/>												
							<shell:error />
						</j:bind>
					</c:when>
					<c:otherwise>
						<j:tile slave="${_slave}" name="shell.plaintext" prop="tipoFrequenza" />
					</c:otherwise>
				</c:choose>				
			</td>			
		</tr>
		<c:if test="${bui:isMode(_slave, 'record_created')}">
			<tr id="sceltaPers" style="display:none">
				<td class="form-label">
					&nbsp;
				</td>
				<td class="form-values">					
					<input type="checkbox" name="persTar" onClick="javascript:clickTariffaPers(this);"/>Tariffa	personalizzata									
				</td>			
			</tr>
		</c:if>
		<tr id="trComboTariffa">
			<td colspan="2">
				<table align="center" width="100%" cellspacing="0" >
					<tr>
						 <td class="form-label">			 
							<shell:label prop="tariffario" forceRequired="true"/>
						</td>		
						<bui:out slave="${_slave}" modes="view">
							<td class="form-values">
								<j:tile slave="${_slave}" name="shell.plaintext" prop="tariffario" />&nbsp;&nbsp;									
								<icare:viewStorico  provider="it.cedaf.icare.commons.supports.HqlByNamedQueryStoricoInfoProvider" idField="idTariffario" params="stQueryName=interventi.Tariffario&stColumns=importo;50;it.cedaf.icare.commons.control.binding.requestbean.formatters.ImportoFormatter|importoFestivi;50;it.cedaf.icare.commons.control.binding.requestbean.formatters.ImportoFormatter" slave="${_slave}"/>
								<span id="diffComm_${_slave}_tariffario" name="diffComm_${_slave}_tariffario" class="form-data-compare" style="display:none"></span>
								<span id="diffComm_${_slave}_tariffarioStImp" name="diffComm_${_slave}_tariffarioStImp" style="display:none">
								<icare:viewStorico provider="it.cedaf.icare.commons.supports.HqlByNamedQueryStoricoInfoProvider" idField="idTariffarioPropComm" params="stQueryName=interventi.Tariffario&stColumns=importo;50;it.cedaf.icare.commons.control.binding.requestbean.formatters.ImportoFormatter|importoFestivi;50;it.cedaf.icare.commons.control.binding.requestbean.formatters.ImportoFormatter" slave="${_slave}"/>
								</span>																		
							</td>
						</bui:out>							
						<bui:out slave="${_slave}" modes="create,update">
							<td class="form-values">
								<j:bind prop="tariffario">
									<j:select class="form-input" id="cmbTariffario" emptyOptionDescr=""/>
									<shell:error />						
								</j:bind>						
							</td>
						</bui:out>
					</tr>					
				</table>
			</td>
		</tr>
		<tr id="trTariffaPersonalizzata" style="display:none">
			<td colspan="2">
				<table align="center" width="100%">
					<tr>
						<td class="form-label">
							<shell:label prop="importo" forceRequired="true"/>
						</td>
						<bui:out slave="${_slave}" modes="view">
							<td class="form-values">
								<j:tile slave="${_slave}" name="shell.plaintext" prop="importo" />
								<span id="diffComm_${_slave}_importo" name="diffComm_${_slave}_importo" class="form-data-compare" style="display:none"></span>	
							</td>
						</bui:out>					
						<bui:out slave="${_slave}" modes="create,update">
							<td class="form-values">
								<j:bind prop="importo">
									<j:text id="inputImportoPers" class="form-short-text" />
									<span id="spanImportoCalcBtn" style="display:none;"><shell:button id="importoCalcBtn" style="display:none;" text="Calcola" img="commons.calcolatrice" title="Calcola importo" href="javascript:calcolaImportoRegola();" /></span>
									<shell:error />
								</j:bind>								
							</td>
						</bui:out>
					</tr>
					<tr id="trFestivi" style="display:none">
						<td class="form-label">
							<shell:label prop="importoFestivi" />
						</td>
						<bui:out slave="${_slave}" modes="view">
							<td class="form-values" >
								<j:tile slave="${_slave}" name="shell.plaintext" prop="importoFestivi" />
							</td>
						</bui:out>
						<bui:out slave="${_slave}" modes="create,update">
							<td class="form-values">
								<j:bind prop="importoFestivi">
									<j:text class="form-short-text" id="txtImportoFestivi"/>		
									<shell:error />							
								</j:bind>
							</td>
						</bui:out>												
					</tr>					
					<bui:out slave="${_slave}" modes="view">
						<tr>
							<td class="form-label">Visualizza storico</td>
							<td class="form-values">									
								<icare:viewStorico prop="vsImportoTariffarioPers" provider="it.cedaf.icare.interventi.etc.ImportoTariffarioStoricoInfoProvider" idField="idObject" 
									params="storicoPropertyName=importoTariffario&stQueryName=interventi.TariffarioGestioneInterventi&stColumns=importo;50;it.cedaf.icare.commons.control.binding.requestbean.formatters.ImportoFormatter|importoFestivi;50;it.cedaf.icare.commons.control.binding.requestbean.formatters.ImportoFormatter" slave="${_slave}"/>
							</td>
						</tr>
					</bui:out>					
					<icare:storicizza2 prop="storicizzaImportoPers" />							
				</table>
			</td>
		</tr>
		<tr>
			<td class="form-label">
				<shell:label prop="quantita" />
			</td>
			<td class="form-values">
				<bui:out slave="${_slave}" modes="view">
					<j:tile slave="${_slave}" name="shell.plaintext" prop="quantita" />
					<span id="diffComm_${_slave}_quantita" name="diffComm_${_slave}_quantita" class="form-data-compare" style="display:none"></span>					
				</bui:out>				
				<bui:out slave="${_slave}" modes="create,update">									
					<j:bind prop="quantita">
						<j:text class="form-short-text" />						
						<shell:error />
					</j:bind>
				</bui:out>
			</td>
		</tr>		
	</table>	
</shell:fieldset>

<shell:fieldset title="Informazioni periodo erogazione">
	<bui:out  slave="${_slave}" modes="create,update">
		<j:bind prop="tipoFine">
			<j:hidden id="tipoFineId" />
		</j:bind>
	</bui:out>
	<table align="center" width="100%">
		<tr>
			<td width="50%" valign="top">
				<table>
					<tr>
						<td class="form-label">
							<shell:label prop="dataInizio" />
						</td>
						<td class="form-values">
							<bui:out  slave="${_slave}" modes="view">
								<j:tile  slave="${_slave}" name="shell.plaintext" prop="dataInizio" />
								<span id="diffComm_${_slave}_dataInizio" name="diffComm_${_slave}_dataInizio" class="form-data-compare" style="display:none"></span>
							</bui:out>				
							<bui:out  slave="${_slave}" modes="create,update">									
								<j:bind prop="dataInizio">
									<j:text class="form-date" id="dataInizioCld" />
									<shell:calendar inputId="dataInizioCld" />						
									<shell:error />
								</j:bind>
							</bui:out>
						</td>
					</tr>
				
				<tr id="tdTipoFine">
						<td class="form-label">
							<shell:label prop="descrizioneFine" />
						</td>	
						<bui:out slave="${_slave}" modes="view">
							<td class="form-values">
								<j:tile slave="${_slave}" name="shell.plaintext" prop="descrizioneFine" />
								<span id="diffComm_${_slave}_descrizioneFine" name="diffComm_${_slave}_descrizioneFine" class="form-data-compare" style="display:none"></span>
							</td>
						</bui:out>
						<bui:out slave="${_slave}" modes="create,update">
							<td class="form-values">
								<table>
									<tr>							
										<td class="form-values">
											<input type="radio" name="tipoFineRB" value="D"  onClick="javascript:onChangeTipoFine(this.value);"/>Data fine &nbsp;&nbsp;&nbsp;
											<j:bind prop="dataFine">
												<j:text class="form-date" id="dataFineCld" />
												<shell:calendar inputId="dataFineCld" />						
												<shell:error />
											</j:bind>							
										</td>					
									</tr>
									<tr>							
										<td class="form-values">
											<input type="radio" name="tipoFineRB" value="N" onClick="javascript:onChangeTipoFine(this.value);"/>Numero occorrenze &nbsp;&nbsp;&nbsp;		
											<j:bind prop="occorrenze">
												<j:text class="form-short-text" id="occorrenzeTxt"/>															
												<shell:error />
											</j:bind>					
										</td>					
									</tr>
									<tr>							
										<td class="form-values">
											<input type="radio" name="tipoFineRB" value="F"  onClick="javascript:onChangeTipoFine(this.value);"/>Nessun termine							
										</td>				
									</tr>						
								</table>
							</td>
						</bui:out>
					</tr>
				
				</table>
			</td>
			
			<td width="50%" valign="top">
				<table id="includiGiorni">
					<tr>
						<td class="form-label">
							<shell:label prop="includiGiorniFestivi" />
						</td>
						<td class="form-values">
							<bui:out slave="${_slave}" modes="view">
								<j:tile  slave="${_slave}" name="shell.plaintext" prop="includiGiorniFestivi" />
								<span id="diffComm_${_slave}_includiGiorniFestivi" name="diffComm_${_slave}_includiGiorniFestivi" class="form-data-compare" style="display:none"></span>
							</bui:out>				
							<bui:out slave="${_slave}" modes="create,update">									
								<j:bind prop="includiGiorniFestivi">
									<j:valueSetIterator>
										<j:radio/>${j:getValueSetItem().description}&nbsp;&nbsp;
									</j:valueSetIterator>
									<shell:error />
								</j:bind>
							</bui:out>
						</td>
					</tr>
					<tr>
						<td class="form-label">
							<shell:label prop="giorniSettimana" />
						</td>
						<td class="form-values">
							
							<table><tr>
							<td class="form-values">
								<bui:out slave="${_slave}" modes="view">
									<j:tile slave="${_slave}" name="shell.plaintext" prop="giorniSettimana" />
									<span id="diffComm_${_slave}_giorniSettimana" name="diffComm_${_slave}_giorniSettimana" class="form-data-compare" style="display:none"></span>
								</bui:out>				
								<bui:out slave="${_slave}" modes="create,update">									
									<j:bind prop="giorniSettimana">
										<j:valueSetIterator>
											<j:checkbox id="gsCheck" />${j:getValueSetItem().description}<br>
								        </j:valueSetIterator>
										<shell:error />
									</j:bind>
								</bui:out>
							</td>
							<td style="vertical-align:top;">
								<bui:out slave="${_slave}" modes="create,update">
									&nbsp;&nbsp;<button class="generic-button ui-state-default ui-corner-all" onClick="javascript:setGiorniSettimanaCheck('1111100'); return false;">&nbsp;Lun-Ven&nbsp;</button>
									<br><div style="height:5px;"></div>
									&nbsp;&nbsp;<button class="generic-button ui-state-default ui-corner-all" onClick="javascript:setGiorniSettimanaCheck('1111110'); return false;">&nbsp;Lun-Sab&nbsp;</button>
									<br><div style="height:5px;"></div>
									&nbsp;&nbsp;<button class="generic-button ui-state-default ui-corner-all" onClick="javascript:setGiorniSettimanaCheck('1111111'); return false;">&nbsp;Lun-Dom&nbsp;</button>
								</bui:out>
								&nbsp;
							</td>
							</tr></table>
							
						</td>
						
					</tr>
				</table>
			</td>
						
		</tr>
	</table>
</shell:fieldset>

<icare:div prop="BAD_optField" slave="${_slave}">	
<shell:fieldset title="Badante">
	<table align="center" width="100%">
		<tr>
			<td class="form-label">
				<shell:label prop="nominativoBadante"/>
			</td>
			<td class="form-values">
				<bui:out modes="view" slave="${_slave}">
					<j:tile  slave="${_slave}" name="shell.plaintext" prop="nominativoBadante" />
				</bui:out>
				<bui:out modes="create,update" slave="${_slave}">
					<j:bind prop="nominativoBadante">
						<j:text class="form-normal-text" readonly="true" id="nominativo_badanteLookup" />
						<shell:error />
					</j:bind>
					<j:bind prop="idBadante">
						<j:hidden id="id_badanteLookup"/>						
					</j:bind>
					<shell:lookup lookupId="badanteLookup" identifier="anagrafiche.soggetto" 
								init="it.cedaf.icare.anagrafiche.model.datamanagement.SoggettoLookupInitializer" 
								params="disableComplete=true;" clearVisible="false" noCommitOnCreate="id=-1" />
					&nbsp; <a id="badanteLookup_clear" href="javascript:clearLookup('badanteLookup');"><img id="badanteLookup_clear_img" src="${j:getResourceUrlOfModule('shell', 'img/lookup/clear.gif')}" alt="Cancella" align="absmiddle" border="0"></a>
				</bui:out>
			</td>
		</tr>
		<bui:out modes="create,update" slave="${_slave}">
			<tr>
				<td class="form-label">
					<shell:label prop="tipoDatore"/>
				</td>
				<td class="form-values">
					<script type="text/javascript">
						function showHideDatore() {
							setDisplayableElementVisible(getRadioCheckedValue('tipoDatore') == 'S', 'trDatoreBadante', '${_slave}');							
						}						
					</script>
					<j:bind prop="tipoDatore">
						<j:valueSetIterator>
							<j:radio id="tipoDatoreId" onchange="javascript:showHideDatore();"/> ${j:getValueSetItem().description} &nbsp;
						</j:valueSetIterator>
						<shell:error />
					</j:bind>						
				</td>
			</tr>
		</bui:out>
		<icare:tr prop="trDatoreBadante" slave="${_slave}" defaultVisible="true">
			<td class="form-label">
				<shell:label prop="nominativoDatoreBadante"/>
			</td>
			<td class="form-values">
				<bui:out modes="view" slave="${_slave}">
					<j:tile  slave="${_slave}" name="shell.plaintext" prop="nominativoDatoreBadante" />
				</bui:out>
				<bui:out modes="create,update" slave="${_slave}">
					<j:bind prop="nominativoDatoreBadante">
						<j:text class="form-normal-text" readonly="true" id="nominativo_datoreLookup" />
						<shell:error />
					</j:bind>
					<j:bind prop="idDatoreBadante">
						<j:hidden id="id_datoreLookup"/>						
					</j:bind>
					<shell:lookup lookupId="datoreLookup" identifier="anagrafiche.soggetto" 
								init="it.cedaf.icare.anagrafiche.model.datamanagement.SoggettoLookupInitializer" 
								params="disableComplete=true;" clearVisible="false" noCommitOnCreate="id=-1" />
					&nbsp; <a id="datoreLookup_clear" href="javascript:clearLookup('datoreLookup');"><img id="datoreLookup_clear_img" src="${j:getResourceUrlOfModule('shell', 'img/lookup/clear.gif')}" alt="Cancella" align="absmiddle" border="0"></a>
				</bui:out>
			</td>
		</icare:tr>
		<tr>
			<td class="form-label">
				<shell:label prop="oreContrattoBadante" />
			</td>
			<td class="form-values">
				<bui:out slave="${_slave}" modes="view">
					<j:tile slave="${_slave}" name="shell.plaintext" prop="oreContrattoBadante" />
				</bui:out>				
				<bui:out slave="${_slave}" modes="create,update">									
					<j:bind prop="oreContrattoBadante">
						<j:text class="form-short-text" />						
					</j:bind>
				</bui:out>
			</td>
		</tr>
	</table>	
</shell:fieldset>

</icare:div>


<j:tile name="interventi.modalitaPagamento" 
	paramsStorico="storicoPropertyName=storicoModalitaPagamento&stQueryName=interventi.ModalitaPagamentoRegola&stColumns=beneficiario;40|tipoPagamento;30|banca;15|delegato;15|iban;15|quietanzante;15" 
	gestSoggLookup="true" gestSoggFields="false" fromRichiesta="true"/>


<shell:fieldset title="Informazioni aggiuntive">
	<table align="center" width="100%">
		<tr>
			<td class="form-label">
				<shell:label prop="note" />
			</td>
			<td class="form-values">
				<bui:out slave="${_slave}" modes="view">
					<j:tile slave="${_slave}" name="shell.plaintext" prop="note" />
				</bui:out>				
				<bui:out slave="${_slave}" modes="create,update">									
					<j:bind prop="note">
						<j:textarea class="form-normal-textarea" />						
					</j:bind>
				</bui:out>
			</td>
		</tr>
	</table>
</shell:fieldset>