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

<script type="text/javascript">
	function downloadTemplate() {
		var idIntervento = cpGetMasterColumnValueOfCurrentRow('id');	
		juiceDownload('it.cedaf.icare.interventi.etc.TemplateXCalcoloQuoteUtenteFileContentProvider', 'idIntervento=' + idIntervento);
	}
	
	function caricaFile() {				
		shellFileUploadDialog(
			'it.cedaf.icare.interventi.control.action.ImportaExcelXCalcoloTariffeUtenteExecutor', 
			'Scegliere il file...', 
			"Seleziona l'Excel che si intende importare:");	
	}
	
	/*function onUploadFile(fileName) { */
	/*	document.getElementById('idNomeAllegato').value = fileName; */
	/*} */
    
    function eseguiCalcoloTariffeUtenteDaExcel() {
    	if (document.getElementById('idNomeAllegato').value == '') {
    		alert('Selezionare un file excel da caricare');
    		return false;
    	}
    	var selRow = cpGetMasterCurrentRow();
    	var idIntervento = cpGetMasterColumnValueOfCurrentRow('id');
    	hideModal('divCalcoloTariffeUtenteTramiteExcel');
    	var params =  'idIntervento=' + idIntervento + '&dmKey=' + bui_datamanagement.getKey() + '&selectedRow=' + selRow;
		jsLoadString('it.cedaf.icare.interventi.control.action.CalcoloTariffeUtenteTramiteExcelExecutor',params);
		cpReload();
	}
    	
</script>
<div id="divCalcoloTariffeUtenteTramiteExcel" class="modalElement">
	<table style="padding: 20px 4px 4px 4px;">
		<tr style="vertical-align: top;">
			<td>
				<div id="divZComparData" class="generic-label">
					<table border="0" cellpadding="0" cellspacing="3">
					<tr>
						<td class="form-label">
							<shell:label prop="nomeFileExcel" />
						</td>
						<td class="form-values">
							<input type="text" class="form-normal-text" id="idNomeAllegato" readonly="true"/>
							<shell:button img="documentiallegati.browse" text="Seleziona..." title="Seleziona il file a partire dal computer locale" href="javascript:caricaFile();" />
						</td>
			 		</tr>
			 		<tr>
			 			<td>&nbsp;</td>
			 			<td><shell:button img="commons.docnew" text="Scarica modello excel precompilato" title="Scarica il modello excel configurato compilato con i dati dell\'intervento" href="javascript:downloadTemplate();" /></td>
			 		</tr>	
					<tr>
						<td>
							&nbsp;
						</td>
						<td class="form-values">
							<br /><br /><button class="generic-button ui-state-default ui-corner-all" onclick="javascript:eseguiCalcoloTariffeUtenteDaExcel();"><img src="${j:getResourceUrlOfModule('shell', 'img/toolbar/excel.gif')}" width="24" height="24" border="0" align="absmiddle">&nbsp;<span class="generic-label">Calcola tariffe utente</span></button>
						</td>
					</tr>			 							
					</table>
				</div>				
			</td>			
		</tr>
	</table>	
</div>