<%@ page language="java"%> 

<%@ page import="java.util.*,javax.sql.*,java.sql.*,javax.naming.*,java.text.*,m05bClasses.*" %>
<%
	// _______________________________XLNETs______________________________________
	// Evaluar variable de session que indica si esta conectado a XLNets
	if ((session.getAttribute("objetoSeguridad")) == null)  { 
		// Verificar que no ha transcurrido el tiempo de sesion (web.xml) %>
			<%@ include file="/m05bControlAcceso.inc"%> <%
	} 
%>	
<%@ include file="/m05bIdioma.inc"%>
<HTML>
<HEAD>
    <title><%= resTit.getString("titLstGasAnuales")%></title>
	<link rel="stylesheet" href="<%=m05bConstantesPaginas.PATH_ESTILOS%>/m05bestilos.css" type="text/css">
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
</HEAD>	

<!-- Hojas de Estilo -->
<%	String sGastoAnual = m05bFicheroProperties.getInstance().getParameter("PDF.GastoAnual"); %>

<BODY style="cursor: wait" onload="document.body.style.cursor='default';document.all['general'].style.visibility='visible';document.all['general'].style.cursor='default';" onunload="document.body.style.cursor='wait';document.all['general'].style.cursor='wait';">
<div  id="general" style="POSITION: absolute;visibility:hidden;cursor: wait">	
<form NAME="formSolicitud" METHOD="POST">
<%
	


    String sEjercicio= request.getParameter("Ano");
	String srcPDF = sGastoAnual+"?Ejercicio="+sEjercicio;
	java.sql.Connection conn=null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
      try
      {  //HttpSession session = request.getSession(true);
			m05bConexion miConex = new m05bConexion();
			conn = miConex.getConnection();

String sSentencia=" SELECT " +
m05bConstantes.COL_46_TARJETA+","+ 
" DECODE( LENGTH("+
m05bConstantes.COL_46_MES+"),1,'0'||"+
m05bConstantes.COL_46_MES+","+m05bConstantes.COL_46_MES+"),"+
" SUM("+ m05bConstantes.COL_46_IMPORTE+")"+   
" FROM " + 
m05bConstantes.TAB_HIST_OPEBANCOS+
" WHERE " + 
m05bConstantes.COL_46_EJER+"="+ sEjercicio  +
" GROUP BY " + 
m05bConstantes.COL_46_TARJETA+","+
m05bConstantes.COL_46_MES+
" UNION " +
" SELECT " +
 m05bConstantes.COL_18_TARJETA+","+ 
 "TO_CHAR("+m05bConstantes.COL_18_FECHA+",'mm'), SUM("+m05bConstantes.COL_18_IMPORTE+")"+ 
" FROM "+ m05bConstantes.TAB_OPEBANCOS+
" WHERE TO_CHAR("+m05bConstantes.COL_18_FECHA+",'YYYY')="+ sEjercicio+
" GROUP BY "+
m05bConstantes.COL_18_TARJETA+", TO_CHAR("+m05bConstantes.COL_18_FECHA+",'mm')";	
		   pstmt = conn.prepareStatement(sSentencia);
		   rs = pstmt.executeQuery();
%>
	
<TABLE class="general">
  <tr>
       <td width="90%" align="right">
       	<input type="button" class="boton" name="<%= res.getString("etBOT_RETORNAR")%>" value="<%= res.getString("etBOT_RETORNAR")%>" ONCLICK="JavaScript:fncRetornar();" onMouseOver="top.status='<%= res.getString("etBOT_STATUSRETORNAR")%>'; return false" onMouseOut="top.status=''; return false" />
       </td>
    
  </tr>
  <tr>
    <td colspan="2">
    <% if (rs.next() == true){ %>
		<embed name='pdfGastoAnual' src='<%=srcPDF%>' type="application/pdf" width='736' height='500'></embed>
    <%} else {%>
		<embed name='pdfGastoAnual' src='/parquemovil/SinDatos.pdf' type="application/pdf" width='736' height='500'></embed>
    <%}%>
	<%	} catch (Exception SQLException) {
		m05bClasses.m05bFileLog miLog = new m05bClasses.m05bFileLog();
			miLog.addTraza(SQLException);
		} 	finally{
				if (rs != null)
					rs.close();			
				if (pstmt != null)
					pstmt.close();
				if (conn != null)
					conn.close();}%>
  	</td>
  </tr>
</TABLE>
</form>
<script type="text/javascript" src="<%=m05bConstantesPaginas.PATH_SCRIPTS%>/m05bMsControl.js"></script>
 
</div>		
</body>
<SCRIPT language=JavaScript>
		function fncRetornar() {
				 document.formSolicitud.action="/m05bParqueMovilWar/m05bTarjResuAnualJsp.jsp" ;
				 document.formSolicitud.submit();
		}
</SCRIPT>
		
</html>
