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

<script type="text/javascript">
function accessoGenerabile(value) {
	var params = 'conAccesso=' + value + shellGetSelectedRowParam() + shellGetSelectedTabParam();
	jsLoadString('it.cedaf.icare.customers.zcmgp.control.action.CambiaStatoAttivitaExecutor', params);
	cpReload();
}

function generaAccessi() {
	if (!confirm('Attenzione!\nUna volta generato un accesso, sar� eliminabile solo manualmente.\nContinuare?')) return;
	
	var vRet = jqLoadJSON('it.cedaf.icare.customers.zcmgp.control.action.GeneraAccessiExecutor');	
	alert("Generati " + vRet.nrFatti + " accessi. \n" +
			"Tralasciate " + vRet.nrNonFatti + " righe.\n" + 
			"Errori: " + vRet.problems.length);
	cpReload();
}

function aggiornaUm() {
	var prestazione = getComboValueById('selPrestazione');
	var idPianoAssistenza = prestazione.split('-')[0];
	var um = jsLoadString('it.cedaf.icare.customers.zcmgp.control.action.FindUMbyIdPianoAssistenzaExecutor', 'idPianoAssistenza=' + idPianoAssistenza);
	
	var cpmt_um = $("#cpmt_unitaMisura");
	cpmt_um.text(um);

	// preimpostazione valore 1 per pasti e lavanderia
	var cpmt_qta = $("#quantita");
	if (cpmt_um.html().toLowerCase() == "chilogrammi" || cpmt_um.html().toLowerCase() == "unitario") {
		cpmt_qta.removeAttr('readonly');
		if (cpmt_qta.val() == "")
			cpmt_qta.val("1");
	} else {
		cpmt_qta.attr('readonly','readonly');
	}
}

function getPrestazioniBySoggetto(idSoggetto) {
	if (idSoggetto != '') {
		var params = 'idSoggetto=' + idSoggetto;
		params += '&dataRif=' + $("#cpmt_data").html();
		loadStandardSelectOptionsAndFill('selPrestazione', 
			'it.cedaf.icare.customers.zcmgp.control.binding.requestbean.valuesetproviders.GruppiPrestazioniPerVerificaProgrammazioneValueSetProvider(idSoggetto,dataRif)',params);
	} else {
		clearCombo('selPrestazione');
	}
}

function onChangeLookup_soggettoLookup() {
	getPrestazioniBySoggetto($("#id_soggettoLookup").val());
}
</script>

<shell:fieldset title="Letture">
	<table border="0" cellspacing="0" cellpadding="0" width="90%">	
		<tr>
			<td valign="top" width="70%">
				<table border="0" cellspacing="3" cellpadding="0" >			
					<tr>
						<td class="form-label">
							<shell:label prop="operatore" />
						</td>
						<td class="form-values">
							<j:tile name="shell.plaintext" prop="operatore" />
						</td>
					</tr>
					<tr>
						<td class="form-label">
							<shell:label prop="data" />
						</td>
						<td class="form-values">
							<j:tile name="shell.plaintext" prop="data" />
						</td>
					</tr>
					<tr>
						<td class="form-label">
							<shell:label prop="descrizioneAttivita" />
						</td>
						<td class="form-values">
							<j:tile name="shell.plaintext" prop="descrizioneAttivita" />  <j:tile name="shell.plaintext" prop="prestazioni" />
						</td>
					</tr>
				</table>												
			</td>
			<td valign="top">
				<bui:out modes="view">
					<shell:button id="sh_tb__conAccesso" text="Record esamintato" img="zcmgp.checkAcc" title="Record esamintato" href="javascript: accessoGenerabile(true);" enabled="true" ext="true" />
					<br/><br/>
					<shell:button id="sh_tb__noAccesso" text="Record esamintato" img="zcmgp.noAcc" title="Record non esamintato" href="javascript: accessoGenerabile(false);" enabled="true" ext="true" />
				</bui:out>
			</td>			
		</tr>
	</table>

	<table border="0" cellspacing="3" cellpadding="0" >	
		<tr>
			<td class="form-label">
				<shell:label prop="Orari" />
			</td>
			<td class="form-values">
				<table border="0" cellspacing="3" cellpadding="0" >
					<tr>
						<td class="form-label">&nbsp;</td>
						<td class="form-label">Pianificata</td>
						<td class="form-label">Timbratura</td>
						<td class="form-label">Correzione manuale</td>						
					</tr>
					<tr>
						<td class="form-label">Ora inizio</td>
						<td class="form-values"><j:tile name="shell.plaintext" prop="oraInizioPianificata" /></td>
						<td class="form-values"><j:tile name="shell.plaintext" prop="oraInizioTimbratura" /></td>
						<td class="form-values"><j:tile name="shell.plaintext" prop="oraInizioUtente" /></td>						
					</tr>
					<tr>
						<td class="form-label">Ora Fine</td>
						<td class="form-values"><j:tile name="shell.plaintext" prop="oraFinePianificata" /></td>
						<td class="form-values"><j:tile name="shell.plaintext" prop="oraFineTimbratura" /></td>
						<td class="form-values"><j:tile name="shell.plaintext" prop="oraFineUtente" /></td>						
					</tr>
				</table>								
			</td>
		</tr>		
	</table>
</shell:fieldset>

<bui:out modes="create, update">
<shell:fieldset title="Correzioni manuali">
	<table border="0" cellspacing="3" cellpadding="0" > 
		<tr>
			<td class="form-label">
				<shell:label prop="oraInizioUtente"/>
			</td>
			<td class="form-values">
				<j:bind prop="oraInizio">
					<j:text class="form-short-text" maxlength="5"/>
					<shell:error />
				</j:bind>
			</td>			
		</tr>		
		<tr>
			<td class="form-label">
				<shell:label prop="oraFineUtente"/>
			</td>
			<td class="form-values">
				<j:bind prop="oraFine">
					<j:text class="form-short-text" maxlength="5"/>
					<shell:error />
				</j:bind>
			</td>			
		</tr>
		<c:if test="${prestazione_unitaria_dto}">
			<tr>
				<td class="form-label">
					<shell:label prop="quantita" />
				</td>
				<td class="form-values">
					<j:bind prop="quantita">
						<j:text class="form-short-text" maxlength="5"/>
						<shell:error />
					</j:bind>
					&nbsp; <j:tile name="shell.plaintext" prop="unitaMisura" />
				</td>
			</tr>
		</c:if>
	</table>
	
</shell:fieldset>
</bui:out>



<shell:fieldset title="Giustificativi">
	<table border="0" cellspacing="3" cellpadding="0" >
		<tr>
			<td class="form-label">
				<shell:label prop="attivitaEseguita" />
			</td>
			<td class="form-values">
				<j:tile name="shell.plaintext" prop="attivitaEseguita" />
			</td>
		</tr>
		<tr>
			<td class="form-label">
				<shell:label prop="giustificativo" />
			</td>
			<td class="form-values">
				<j:tile name="shell.plaintext" prop="giustificativo" />
			</td>
		</tr>
		<tr>
			<td class="form-label">
				<shell:label prop="scostamento" />
			</td>
			<td class="form-values">
				<j:tile name="shell.plaintext" prop="scostamento" />
			</td>
		</tr>
		<tr>
			<td class="form-label">
				<shell:label prop="descrizioneOperatore" />
			</td>
			<td class="form-values">
				<j:tile name="shell.plaintext" prop="descrizioneOperatore" />
			</td>
		</tr>
	</table>
</shell:fieldset>


<shell:fieldset title="Attivit� soggetto">
	<table border="0" cellspacing="3" cellpadding="0" >			
		<tr>
			<td class="form-label">
				<shell:label prop="soggetto" />
			</td>
			<td class="form-values">
				<c:choose>
					<c:when test="${attivita_blu_dto}">
						<j:bind prop="soggettoDesc">
							<j:text class="form-normal-text" readonly="true" id="nominativo_soggettoLookup"/>
							<shell:error />
						</j:bind>
						<j:bind prop="soggetto">
							<j:hidden id="id_soggettoLookup" />
							<shell:error />
						</j:bind>
						<shell:lookup lookupId="soggettoLookup" identifier="anagrafiche.soggetto" 
							init="it.cedaf.icare.anagrafiche.model.datamanagement.SoggettoLookupInitializer"
							params="onlySearch=true"/>
					</c:when>
					<c:otherwise>
						<j:tile name="shell.plaintext" prop="soggettoDesc" />
					</c:otherwise>
				</c:choose>
			</td>
		</tr>
		<tr>
			<td class="form-label">
				<shell:label prop="prestazione" />
			</td>
			<td class="form-values">
				<c:choose>
					<c:when test="${attivita_blu_dto}">
						<j:bind prop="prestazione">
							<j:select class="form-input" emptyOptionDescr="" onchange="aggiornaUm();" id="selPrestazione" />
							<shell:error />
						</j:bind>
					</c:when>
					<c:otherwise>
						<j:tile name="shell.plaintext" prop="gruppoPrestazione" />
					</c:otherwise>
				</c:choose>
			</td>
		</tr>
		<tr>
			<td class="form-label">
				<shell:label prop="quantita" />
			</td>
			<td class="form-values">
				<c:choose>
					<c:when test="${attivita_blu_dto}">
						<j:bind prop="quantita">
							<j:text class="form-normal-text" id="quantita" />
							<shell:error />
						</j:bind>
					</c:when>
					<c:otherwise>
						<j:tile name="shell.plaintext" prop="gruppoPrestazione" />
					</c:otherwise>
				</c:choose>
				&nbsp; <j:tile name="shell.plaintext" prop="unitaMisura" />
			</td>
		</tr>
	</table>
</shell:fieldset>