soggettoDomQuartiereExt.jsp 3.65 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
<%@ include file="/project/include.jsp" %>

<%@ page import = "it.cedaf.icare.customers.zcompar.control.action.CalcoloQuartiereAction" %>

<%@ page import = "it.cedaf.icare.customers.zcompar.ZcomparModuleInfo" %>

<bui:out modes="update,create">
	
	<script type="text/javascript">
	var _quartiere;
	var idComuneParma = <%=ZcomparModuleInfo.ID_COMUNE_PARMA%>;
	
	function getQuartiere(idVia, numCivico, idComune) {
		_quartiere = null;

		var strParam = '&' + '<%=CalcoloQuartiereAction.IDVIA%>' + '=' + idVia;
		strParam = strParam + '&' + '<%=CalcoloQuartiereAction.NUMCIV%>' + '=' + numCivico;
		strParam = strParam + '&' + '<%=CalcoloQuartiereAction.IDCOMUNE%>' + '=' + idComune;

		jsLoadString('it.cedaf.icare.customers.zcompar.control.action.CalcoloQuartiereAction', strParam, '_setQuartiere', JS_SYNC);		
		return _quartiere;
	}	
	
	function _setQuartiere(quartiere) {
		_quartiere = quartiere;
	}
	
	function retrieveQuartiere() {
		var idVia = document.getElementById('id_viaDomicilio').value;
		var indirizzo = document.getElementById('descrizione_viaDomicilio').value;
		var numCivico = document.getElementById('idCivicoDomicilio').value;
		var idComune = document.getElementById('id_luogoDomicilio').value;
		
		if ((idVia == '') || idComune == '' || numCivico == '') {
			alert("Per calcolare il quartiere servono: indirizzo (da viario) e numero civico.");
			return;
		}		
		
		var quartiereInput = document.getElementById('idQuartiereDomicilio');
		var capInput = document.getElementById('defaultCAP_luogoDomicilio');
		var calcoloEnabled = quartiereInput && capInput && quartiereInput.length>1 && idComune == idComuneParma;
		
		if (calcoloEnabled) {
			
			var quartiereRet = getQuartiere(idVia, numCivico, idComune);
		
			if (quartiereRet != '') {
				var idQuartiereDom = '';
				var capDom = '';
			
				var tokens = quartiereRet.split('|');
			   	idQuartiereDom = tokens[0];
			   	if (tokens.length==2) {
			   		capDom = tokens[1];
			   	}			   
			

			if (quartiereInput) {
				if (idQuartiereDom == '') {
					quartiereInput.selectedIndex = 0;
				} else {
					selectComboElementByValue(quartiereInput, idQuartiereDom);
		    	}
			}
			if (capInput) {
				capInput.value = capDom;
			}		
			
			}	
		}	
		
		return;												
	}
	
	registerOnChangeLookup('luogoDomicilio',function() {
		enableDisableCalcoloQuartiere();
	});
	
	registerOnClearLookup('luogoDomicilio',function() {
		var divCustomControl = document.getElementById('div_calcolaQuartiere');
		if (divCustomControl) {
			divCustomControl.style.display = 'none';
		}
	});
	
	function findCapAndProvinciaDomicilio(){
		var nomeComune = document.getElementById("nome_luogoDomicilio").value;
		var nonEstero = document.getElementById("esteroDomicilioId_1").checked;
		if (nonEstero) {
			jsLoadMap('it.cedaf.icare.commons.control.action.FindCapAndProvinciaByComuneExecutor', 'nomeComune=' + nomeComune, 'settaCapAndProvinciaDomicilio', JS_SYNC);
		}
		initQuartiere('Domicilio');
		enableDisableCalcoloQuartiere();
	}	
	
	function enableDisableCalcoloQuartiere() {
		var idComune = document.getElementById('id_luogoDomicilio').value;
		var quartiereInput = document.getElementById('idQuartiereDomicilio');
		var calcoloEnabled = quartiereInput && idComune == idComuneParma;
		
		var divCustomControl = document.getElementById('div_calcolaQuartiere');

		if (divCustomControl) {
			if (calcoloEnabled) {
				divCustomControl.style.display = '';
			} else {
				divCustomControl.style.display = 'none';
			}
		}
	}
	</script>
	
	<span id="div_calcolaQuartiere" ><shell:button id="calcolaQuartiereHref" text="Reperisci il quartiere" img="zcompar.calcoloQuartiere" title="Reperisci il quartiere" href="javascript: retrieveQuartiere();"/></span>
</bui:out>