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

<script type="text/javascript">	
	function onChangeServizio() {
		var idServizio = getComboValueById('idServizio');
		var params = 'idServizio=' + idServizio;
		jsLoadMultipleSelectOptions('it.cedaf.icare.interventi.commons.ServizioTabellaAccessiSearchMultiSelectOptions', params, JS_SYNC);
		onChangeTipoIntervento();
	}

	function onChangeTipoIntervento() {
		var macrotipologia = document.getElementById('idMacrotipologia').value;
		var params = 'macrotipologia=' + macrotipologia;
		
		var idServizio = getComboValueById('idServizio');
		params = params + '&idServizio=' + idServizio;
		
		var idTipoIntervento = getComboValueById('idTipoIntervento');
		if (idTipoIntervento != '') params = params + '&idTipoIntervento=' + idTipoIntervento;
		
		var idStato = getComboValueById('idStato');
		if (idStato != '') params = params + '&idStato=' + idStato;
		
		var idLivelloAssistenza = getComboValueById('idLivelloAssistenza');
		if (idLivelloAssistenza != '') params = params + '&idLivAssistenza=' + idLivelloAssistenza;
		
		var idOpRif = getComboValueById('opRif');
		if (idOpRif != '') params = params + '&idOpRif=' + idOpRif;
		
		var idEnteErogatore = '';
		var selectEnteErogatore = document.getElementById('selEnteErogatore');
		if (selectEnteErogatore) {
			idEnteErogatore = getComboValueById('selEnteErogatore');
		} else {
			idEnteErogatore = document.getElementById('idEnteErogatore').value
		}
		if (idEnteErogatore != '') params = params + '&idEnteErogatore=' + idEnteErogatore;
		
		var idStruttura = getComboValueById('selStruttura');
		if (idStruttura != '') params = params + '&idStruttura=' + idStruttura;
		
		jsLoadMultipleSelectOptions('it.cedaf.icare.interventi.commons.TipoInterventoTabellaAccessiSearchMultiSelectOptions', params, JS_SYNC);
	}	
	
	function onChangeOperatore() {
		var idServizio = getComboValueById('idServizio');
		var params = 'idServizio=' + idServizio;
		var idOpRif = getComboValueById('opRif');
		if (idOpRif) params = params + '&idOpRif=' + idOpRif;
		jsLoadSelectOptionsAndFill("uoRif", 'it.cedaf.icare.interventi.commons.UnitaOperativaByOperatoreSelectOptions', params, '', null, false, false);
	}
	
	function abilitaComboMedico(enable) {
		if (document.getElementById('idMedico')) {
			var selectMedici = document.getElementById('idMedico');
			
			if (enable) {
				if (selectMedici.length < 2) {
					loadStandardSelectOptionsAndFill('idMedico', 
						'it.cedaf.icare.anagrafiche.control.binding.requestbean.valuesetproviders.MedicoBaseValueSetProvider()', null, ' '); 
				}				
				selectMedici.disabled = false;
			} else {
				selectMedici.selectedIndex = 0;
				selectMedici.disabled = true;
			}
		}				
	}
	
	registerOnDocumentLoad(function() {	
		if (document.getElementById('idMedico')) {
			if (document.getElementById('siContratto').checked) {
				document.getElementById('idMedico').disabled = false;
			}
		}					
	});

	function doSearch(){
		var form = document.getElementById('formSearch');
		juiceSubmitForm(form);
	}
		
</script>
<j:form id="formSearch" name="formSearch" event="loadTabellaAccessi" method="POST">
<table border="0" width="100%" cellpadding="5">
	<tr>
		<td width="50%" valign="top">
			<j:bind prop="servizio">
			<c:choose>
			<c:when test="${fn:length(j:getStatus().valueSet) gt 1}">
				<shell:fieldset title="Servizio">
					<table border="0" cellspacing="3" cellpadding="0" >
						<tr>   
					      	<td class="form-label">
					    		<shell:label prop="servizio" />
					    	</td>
							<td class="form-values">
								<j:select class="form-input" id="idServizio" onChange="javascript:onChangeServizio();" />
							</td>
						</tr>
					</table>
				</shell:fieldset>
			</c:when>
			<c:otherwise>
				<table border="0" cellspacing="3" cellpadding="0" style="display: none">
					<tr>   
				      	<td class="form-label">
				    		<shell:label prop="servizio" />
				    	</td>
						<td class="form-values">
							<j:select class="form-input" id="idServizio" />
						</td>
					</tr>
				</table>
			</c:otherwise>
			</c:choose>
			
			</j:bind>
			<shell:fieldset title="${j:bundle('LBL_interventi_tabellaAccessi_periodoRif_SET')}">
				<table border="0" cellspacing="3" cellpadding="0" >
					<tr>
						<td class="form-label">
							<shell:label prop="meseRiferimento" />
						</td>
						<td class="form-values">
							<j:bind prop="meseRiferimento">
								<j:select class="form-input" id="idMeseRiferimento" emptyOptionDescr=""/>
								<shell:error />
							</j:bind>
						</td>
					</tr>
				</table>
			</shell:fieldset>
			<shell:fieldset title="${j:bundle('LBL_interventi_tabellaAccessi_infoInterv_SET')}">
				<table border="0" cellspacing="3" cellpadding="0" >
			    	<j:bind prop="macrotipologia">
						<j:hidden id="idMacrotipologia" />
					</j:bind>
					
					<tr>
						<td class="form-label">
							<shell:label prop="icaroCode" />
						</td>
						<td class="form-values">
							<j:bind prop="icaroCode">
								<j:text class="form-normal-text" />
							</j:bind>
						</td>
					</tr>
					<%-- 
					<tr>
						<td class="form-label">
							<shell:label prop="intervento" />
						</td>
						<td class="form-values">
							<j:bind prop="erogato">
								<j:radio displayValue="no" />${j:bundle('LBL_pianificato')}
								<j:radio displayValue="si" />${j:bundle('LBL_erogato')}
								<j:radio displayValue="" />${j:bundle('LBL_tutti')}
							</j:bind>
						</td>
					</tr>
					--%>
					<tr>
						<td class="form-label">
							<shell:label prop="dataInizio" />
						</td>
						<td class="form-values">
							<j:bind prop="dataInizioDa">
								${j:bundle('LBL_ricercaDa')} <j:text class="form-date" id="dataInizioDaCld" />
								<shell:calendar inputId="dataInizioDaCld" />
								<shell:error />
							</j:bind>
							<j:bind prop="dataInizioA">
								a: <j:text class="form-date" id="dataInizioACld" />
								<shell:calendar inputId="dataInizioACld" />
								<shell:error />
							</j:bind>
						</td>					
			 		</tr>
					<tr>
						<td class="form-label">
							<shell:label prop="dataTermine" />
						</td>
						<td class="form-values">
							<j:bind prop="dataTermineDa">
								${j:bundle('LBL_ricercaDa')} <j:text class="form-date" id="dataTermineDaCld" />
								<shell:calendar inputId="dataTermineDaCld" />
								<shell:error />
							</j:bind>
							<j:bind prop="dataTermineA">
								a: <j:text class="form-date" id="dataTermineACld" />
								<shell:calendar inputId="dataTermineACld" />
								<shell:error />
							</j:bind>	
						</td>					
			 		</tr>
			 		<tr>   
				      	<td class="form-label">
				    		<shell:label prop="tipoIntervento" />
				    	</td>
						<td class="form-values">
					    	<j:bind prop="idTipoIntervento">
								<j:select class="form-input" id="idTipoIntervento" emptyOptionDescr="" onChange="javascript:onChangeTipoIntervento();"/>
							</j:bind>
						</td>
					</tr>
			 		<tr>   
				      	<td class="form-label">
				    		<shell:label prop="livelloAssistenza" />
				    	</td>
						<td class="form-values">
					    	<j:bind prop="idLivelloAssistenza">
								<j:select class="form-input" id="idLivelloAssistenza" emptyOptionDescr="" />
							</j:bind>
						</td>
					</tr>
				  	<tr>   
				      	<td class="form-label">
				    		<shell:label prop="stato" />
				    	</td>
						<td class="form-values">
					    	<j:bind prop="idStato">
								<j:select class="form-input" id="idStato" emptyOptionDescr=""/>
							</j:bind>
						</td>
					</tr>
			 	</table>
			</shell:fieldset>
			<c:if test="${empty dto_enteEsternoMode || dto_enteEsternoMode == 'false'}">
				<shell:fieldset title="${j:bundle('LBL_interventi_tabellaAccessi_OperaRifer_SET')}">
					<table border="0" cellspacing="3" cellpadding="0" >
						<tr>
							<td class="form-label">
								<shell:label prop="operatoreRiferimento" />
							</td>
							<td class="form-values">
								<j:bind prop="operatoreRiferimento">
									<j:select class="form-input" id="opRif" emptyOptionDescr=" " onchange="javascript:onChangeOperatore();" />
								</j:bind>
							</td>
						</tr>
						<tr>
							<td class="form-label">
								<shell:label prop="uoRiferimento" />
							</td>
							<td class="form-values">
								<j:bind prop="uoRiferimento">
									<j:select class="form-input" id="uoRif" onchange="juiceClearSelectTitleOptions(this);"/>
								</j:bind>
							</td>
						</tr>
					</table>
				</shell:fieldset>			
			</c:if>
		</td>
		<td width="50%" valign="top">
			<!--  ======================  INIZIO DELLA SECONDA COLONNA  ======================  -->
			<j:tile name="anagrafiche.soggettoSearchTile"/>
			<shell:fieldset title="${j:bundle('LBL_interventi_tabellaAccessi_infoEnteEr_SET')}">
				<table border="0" cellspacing="3" cellpadding="0" >
					<tr>
						<td class="form-label">
							<shell:label prop="enteErogatore" />
						</td>
						<td class="form-values">
							<c:choose>
								<c:when test="${dto_enteEsternoMode == 'false'}">
									<j:bind prop="idEnteErogatore">
										<j:select class="form-input" id="selEnteErogatore" emptyOptionDescr=" " selectIfUnique="true"/>
									</j:bind>
								</c:when>
								<c:otherwise>
									<j:bind prop="denominazioneEnteErogatore">
										<j:text class="form-normal-text" readonly="true"  />
									</j:bind>	
									<j:bind prop="idEnteErogatore">
										<j:hidden id="idEnteErogatore" />
									</j:bind>
								</c:otherwise>
							</c:choose>
						</td>
					</tr>				
					<tr>
						<td class="form-label">
							<shell:label prop="strutturaInserimento" />
						</td>
						<td class="form-values">
							<j:bind prop="idStrutturaInserimento">
								<j:select class="form-input" id="selStruttura" emptyOptionDescr=" "/>
							</j:bind>
						</td>
					</tr>
				</table>
			</shell:fieldset>	
			<shell:fieldset title="${j:bundle('LBL_interventi_tabellaAccessi_infoContMed_SET')}">
				<table border="0" cellspacing="3" cellpadding="0" >
					<tr>
						<td class="form-label">
							<shell:label prop="conContrattoMedico" />
						</td>
						<td class="form-values">
							<j:bind prop="conContrattoMedico">
								<j:radio displayValue="no" onclick="abilitaComboMedico(false);"/>${j:bundle('LBL_no')}
								<j:radio displayValue="si" onclick="abilitaComboMedico(true);" id="siContratto"/>${j:bundle('LBL_si')}
								<j:radio displayValue="" onclick="abilitaComboMedico(false);"/>${j:bundle('LBL_tutti')}
							</j:bind>
						</td>
					</tr>
					<tr>
						<td class="form-label">
							<shell:label prop="medicoRichiedente" />
						</td>
						<td class="form-values">
							<j:bind prop="medicoRichiedente">
								<j:select class="form-input" id="idMedico" emptyOptionDescr=" " disabled="true"/>
							</j:bind>
						</td>
					</tr>
				</table>
			</shell:fieldset>	
		</td>
	</tr>
</table>
</j:form>