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

<script type="text/javascript">
	function changeTipoRegola(elem) {
		showInfoGiornaliere(elem.value == 'D' && elem.checked);
	}
	
	function eformat_cpmt_importoFestivi(element, value) {
		if (bui_datamanagement.getMode().isView()) {
			element.innerHTML = value;
		}
		var tipoRegolaCode = cpGetMasterColumnValueOfCurrentRow('tipoRegolaCode');
		showInfoGiornaliere(tipoRegolaCode == 'D');
	}
	
	function showInfoGiornaliere(value) {
		var display = (value ? '' : 'none');
		document.getElementById('trImportoFestivi').style.display = display;
		if (!value && bui_datamanagement.getMode().isCreate()) {
			buiForm['importoFestivi'].value = '';
		}
	}
</script>
		
<shell:fieldset title="Informazioni generali">
	<table border="0" cellspacing="3" cellpadding="0" >
		<tr>
			<td class="form-label">
				<shell:label prop="descrizione" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="descrizione" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="descrizione">
						<j:text class="form-long-text" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>						
		</tr>
		<tr>
			<td class="form-label">
				<shell:label prop="tipoRegola" />
			</td>
			<td class="form-values">
				<bui:out modes="view, update">
					<j:tile name="shell.plaintext" prop="tipoRegola" />
				</bui:out>
				<bui:out modes="create">
					<j:bind prop="tipoRegola">
						<j:valueSetIterator>
							<j:radio onclick="javascript:changeTipoRegola(this);"/> ${j:getValueSetItem().description}<br/>
						</j:valueSetIterator>
						<shell:error />
					</j:bind>
				</bui:out>
			</td>						
		</tr>	
		<tr>
			<td class="form-label">
				<shell:label prop="codice" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="codice" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="codice">
						<j:text class="form-short-text" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>						
		</tr>
				   			
	</table>
</shell:fieldset>

<shell:fieldset title="Tariffa">
	<table border="0" cellspacing="3" cellpadding="0" width="100%">
		<tr>
			<td class="form-label">
	    		<shell:label prop="importo" />
	    	</td>
	    	<td class="form-values">
	    		<bui:out modes="view">   
			  		<j:tile name="shell.plaintext" prop="importo" />
				</bui:out>
				<bui:out modes="update,create">
			    	<j:bind prop="importo">
						<j:text class="form-short-text" />
						<shell:error />
					</j:bind>
		   		</bui:out>
		   	</td>
		</tr>
					
		<tr id="trImportoFestivi" style="display: none">   
	      	<td class="form-label">
	    		<shell:label prop="importoFestivi" />
	    	</td>
	    	<td class="form-values">
	    		<bui:out modes="view">   
			  		<j:tile name="shell.plaintext" prop="importoFestivi" />
				</bui:out>
				<span id="cpmt_importoFestivi">
				<bui:out modes="update,create">
			    	<j:bind prop="importoFestivi">
						<j:text class="form-short-text" />
						<shell:error />
					</j:bind>
		   		</bui:out>
		   	</td>
		</tr>
		
		<bui:out modes="view">
			<tr>
				<td class="form-label">Visualizza storico</td>
				<td class="form-values">
					<icare:viewStorico prop="vsImporto" provider="it.cedaf.icare.commons.supports.HqlByNamedQueryStoricoInfoProvider" idField="id" 
						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"/>
				</td>
			</tr>
		</bui:out>
		<icare:storicizza2 prop="storicizzaImporti" />
	
	</table>
</shell:fieldset>