tileTabellaAccessiPrestazioneExt.jsp 7.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
<%@ include file="/project/include.jsp" %>

<%@page import="it.cedaf.icare.interventi.view.dto.TabellaAccessiConfDto"%>

<% TabellaAccessiConfDto confDto = (TabellaAccessiConfDto)request.getAttribute("confDto"); %>

<script type="text/javascript">

registerOnEnableDisablePrestazioneForm('<%=confDto.getIdentifier()%>',
	function enableDisablePrestForm(enable) {
		enableDisableInput('durata', enable);
		enableDisableInput('numOp', enable);
		enableDisableInput('motVar', enable);
		enableDisableInput('codPacchetto', enable);
	}
);

/**  */
registerOnLoadPropertiesToForm('<%=confDto.getIdentifier()%>',
	function loadPropertiesToForm(prestazione) { 
		jsLoadMap('it.cedaf.icare.customers.zcompar.control.action.LoadMotiviVariazioniTabellaAccessiExecutor', '', 'fillMapMotiviVar', JS_SYNC);		
		var tableRow = tableController.currentlySelectedTableRow;
		if (tableRow) {
			var idInt = tableRow.cells[0].objects[0].idIntervento;
			jsLoadMap('it.cedaf.icare.customers.zcompar.control.action.LoadCodiciPacchettiTabellaAccessiExecutor', 'idIntervento=' + idInt, 'fillComboPacchetti', JS_SYNC);
		}		


		if (!prestazione) {
			document.getElementById('durata').value = '';
			document.getElementById('numOp').value = '';
			document.getElementById('motVar').selectedIndex = -1;
			document.getElementById('codPacchetto').selectedIndex = -1;
		} else {
			var durata = prestazione.getProperty('durata');
			if (durata) {
				document.getElementById('durata').value = durata;
			} else {
				document.getElementById('durata').value = '';
			}		
			var numOp = prestazione.getProperty('numOp');
			if (numOp) {
				document.getElementById('numOp').value = numOp;
			} else {
				document.getElementById('numOp').value = '';
			}	
			
			var motVar = prestazione.getProperty('motVar');

			if (motVar) {
				var _motVar = motVar.split(';');
				var combo = document.getElementById('motVar');
				var count = combo.length;

				for (var m = 0; m < _motVar.length; m++) {
					for (var i = 0; i < count; i++){
						if (combo.options[i].value==_motVar[m]) {
							combo.options[i].selected = true;
						}
					}
				}
			} else {
				document.getElementById('motVar').selectedIndex = -1;
			}
			
			var codPacchetto = prestazione.getProperty('codPacchetto');
			if (codPacchetto) {
				var combo = document.getElementById('codPacchetto');
				var count = combo.length;

				for (var i = 0; i < count; i++){
					if (combo.options[i].value==codPacchetto) {
						combo.options[i].selected = true;
					}
				}
			} else {
				document.getElementById('codPacchetto').selectedIndex = -1;
			}
		}
	}
);

registerOnSaveProperties('<%=confDto.getIdentifier()%>',
	function saveCustomProperties(prestazione, errMsgPrest) { 
		/** */
		var durataValue = document.getElementById('durata').value.trim();	
		if (durataValue != '') {
			var errInt = new IntegerValidator(document.getElementById('durata')).validate(0);
		
			if (errInt != null) {
				errMsgPrest.push('La durata deve essere un numero intero maggiore di zero.');
				return false;
			}
		}
		prestazione.setProperty('durata', durataValue); 
		
		/** */
		var numOpValue = document.getElementById('numOp').value.trim();	
		if (numOpValue != '') {
			var errInt = new IntegerValidator(document.getElementById('numOp')).validate(0);
		
			if (errInt != null) {
				errMsgPrest.push('Il numero operatori deve essere un numero intero maggiore di zero.');
				return false;
			}		
		}
		prestazione.setProperty('numOp', numOpValue);
					
		/**  */
		var motVar = '';
		var combo = document.getElementById('motVar');
		var count = combo.length;
		for (var i = 0; i < count; i++){
			if (combo.options[i].selected) {
				if (motVar != '') {
					motVar+=';';
				}	
				motVar += combo.options[i].value;
			}
		}
		
		var codPacchetto = document.getElementById('codPacchetto').value;
		
		if (motVar=='' && (prestFormIsChanged() || !prestazione.id)) {
			if (!codPacchetto) {
				errMsgPrest.push('Specificare almeno un motivo variazione.');
				return;
			}
		}
		
		prestazione.setProperty('motVar', motVar);
		
		prestazione.setProperty('codPacchetto', codPacchetto);
	
	}
);	

registerOnChangeGruppoPrestazioni('<%=confDto.getIdentifier()%>',
	function onChangeGruppoPrestazioni(codGp) {
		var selectTP = document.getElementById('tipoPrestazione');
		if (selectTP.options.length == 2) {
			selectTP.options[1].selected = true;
			var codTp = selectTP.options[1].value;
			jsLoadMap('it.cedaf.icare.customers.zcompar.control.action.LoadInfoTipoPrestazioneTabellaAccessiExecutor', 'codTp=' + codTp, 'setValoriTipoPrestazione', JS_SYNC);
		}
	}
);

registerOnChangeTipoPrestazione('<%=confDto.getIdentifier()%>',
	function loadInfoPrestCustom(codTp) {
	/** in inserimento nuova prestazione, valorizzo durata e numero operatori */ 
	/** con i valori definiti in anagrafica per il tipo prestazione */
		jsLoadMap('it.cedaf.icare.customers.zcompar.control.action.LoadInfoTipoPrestazioneTabellaAccessiExecutor', 'codTp=' + codTp, 'setValoriTipoPrestazione', JS_SYNC);		
	}
);

function setValoriTipoPrestazione(map) {
	var durata = map.get('durata');
	if (durata) {
		document.getElementById('durata').value = durata;
	}		
	var numOp = map.get('numOp');
	if (numOp) {
		document.getElementById('numOp').value = numOp;
	}
	
}

function fillMapMotiviVar(map) { 
	motVarOptions = new Array();
	var keys = map.keys;
	clearCombo('motVar');

	var combo = document.getElementById('motVar');
	
	for (var k = 0; k < keys.length; k++){
	
		var key = keys[k];
		var description = map.get(keys[k]);
		/** var display_description = description.substring(0, Math.min(35,description.length)); */
		/**if (description.length > 35) { */
		/**	display_description += '...'; */
		/**} */
		combo.options[k] = 	new Option(description, key);
		combo.options[k].title = description;
	}		
}

function fillComboPacchetti(map) { 
	motVarOptions = new Array();
	var keys = map.keys;
	clearCombo('codPacchetto');

	var combo = document.getElementById('codPacchetto');
	combo.options[0] = 	new Option('','');
	for (var k = 0; k < keys.length; k++){
	
		var key = keys[k];
		var description = map.get(keys[k]);
		combo.options[k+1] = 	new Option(key + ' - ' + description, key);
		combo.options[k+1].title = key + ' - ' + description;
	}		
}
</script>

<table cellspacing="3" cellpadding="0" border="0" width="100%">
	<tr>
		<tr>
			<td class="form-label" style="width:80px;"><span>Durata</span></td>
			<td class="form-values" colspan="2">
				<input id="durata" class="form-short-text" type="text" value="" name="durata" onblur="elementOnBlur();"/>
			</td>
		</tr>
		<tr>
			<td class="form-label" style="width:80px;"><span>Nr. operatori</span></td>
			<td class="form-values" colspan="2">
				<input id="numOp" class="form-short-text" type="text" value="" name="numOp" onblur="elementOnBlur();"/>
			</td>
		</tr>	
		<tr>
			<td class="form-label" style="width:80px;"><span>Codice pacchetto</span></td>
			<td class="form-values" colspan="2">
				<select id="codPacchetto" style="width:98%" name="codPacchetto" class="form-input" onblur="elementOnBlur();"></select>
			</td>
		</tr>			
		<tr>
			<td class="form-label" style="width:80px;"><span>Motivi variazione</span></td>
			<td class="form-values" colspan="2">&nbsp;</td>
		</tr>	
		<tr>
			<td class="form-values" colspan="3">
				<select id="motVar" style="width:98%" name="motVar" size="5" multiple="multiple" class="form-input" onblur="elementOnBlur();"></select>
			</td>
		</tr>					
	</tr>
</table>