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

<script type="text/javascript">
	function tformat_cpst_emessi_valida(element, value, name) {
		var tableId = CP_SLAVE_TABLE_ID + '_emessi';
		var tkns = element.parentNode.id.split('_');
		var rowIndex = parseInt(tkns[tkns.length-1]);		
		var modificaAbilitata = cpGetColumnValueOfRow(tableId, parseInt(rowIndex), 'modificaAbilitata');
		if (modificaAbilitata == "si") {
			if (value == 'si') {		
				var txt = '<a href="javascript:zcmpAnnullaRigaPagamento(' + rowIndex + ');">';
				txt+='<img title="Annulla riga" style="border:0px;" src="' + juiceGetResource('shell', 'img/misc/check_small.gif') + '" />';
				txt+='</a>';
				element.style.paddingTop = '0px';
				element.style.paddingBottom = '0px';
				element.innerHTML = txt;
			} else if (value == 'no') {
				var txt = '<a href="javascript:zcmpRipristinaRigaPagamento(' + rowIndex + ');">';
				txt+='<img title="Ripristina riga" style="border:0px;" src="' + juiceGetResource('shell', 'img/misc/delete-small.gif') + '" />';
				txt+='</a>';
				element.style.paddingTop = '0px';
				element.style.paddingBottom = '0px';	
				element.innerHTML = txt;
			}
		}
	}
	
	function zcmpAnnullaRigaPagamento(rowIndex) {
		var tableId = CP_SLAVE_TABLE_ID + '_emessi';
		var idRigaPag = cpGetColumnValueOfRow(tableId, parseInt(rowIndex), 'idRigaPag');
		if (idRigaPag) {
		    if (confirm('Annullare la riga pagamento selezionata?')) {	
		    	var currentMasterRow = cpGetMasterCurrentRow();	
				var event = "zcompar.impostaValiditaRigaPagamento?valida=false&currentMasterRow=" + currentMasterRow + "&idRigaPagamento=" + idRigaPag;
			 	juiceChangeLocation(event);
			 }
		}
	}
	
	function zcmpRipristinaRigaPagamento(rowIndex) {
		var tableId = CP_SLAVE_TABLE_ID + '_emessi';
		var idRigaPag = cpGetColumnValueOfRow(tableId, parseInt(rowIndex), 'idRigaPag');
		if (idRigaPag) {
			var response = jsLoadString('it.cedaf.icare.pagamenti.control.action.VerificaRigaPagamentoRipristinabileExecutor', 'idRigaPagamento=' + idRigaPag);
			if (response == 'NO') {
				alert('Impossibile ripristinare la riga pagamento.\nEsiste gi� una riga pagamento valida con lo stesso numero bollettino.');
				return;
			} else if (confirm('Ripristinare la riga pagamento selezionata?')) {	
		    	var currentMasterRow = cpGetMasterCurrentRow();	
				var event = "zcompar.impostaValiditaRigaPagamento?valida=true&currentMasterRow=" + currentMasterRow + "&idRigaPagamento=" + idRigaPag;
			 	juiceChangeLocation(event);
			}
		}
	}	
</script>

<icare:grid description="descrizione,23%;dataEmissione,10%;periodoRiferimentoDa,10%;periodoRiferimentoA,10%;importo,5%,-1,right;numeroBollettino,5%;soggPagante,22%;valida,5%,-1,center;elaboratoPGE,5%,-1,center;importoPagato,5%,-1,right" slave="emessi" />