<?php
  include("stilos/config.inc.php");
  include("../clases/BDConexion.php");
  include("../clases/clsPer.php");
  include("funcion/funciones.php");
  include("Funciones.php");
  session_start();
  $objPer=new clsPer;
  
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><MMString:LoadString id="insertbar/formsHidden" /></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">

<link href="Estilos.css" rel="stylesheet" type="text/css">

<link href="stilos/Estilos.css" rel="stylesheet" type="text/css">
<SCRIPT language=JavaScript src="js/calendario.js"></SCRIPT>
<!-- Copyright 2000,2001 Macromedia, Inc. All rights reserved. -->
<script language="JavaScript"> 
<!--
function Abrir_Ventanapopup1(sURL,x,y) {
if (!window.focus) return;
			var par;
			par = "width=" +x + ",height="+y+","
			par = par + "dependent=no,scrollbars=yes,resizable=yes"
			par = par + "menubar=no,toolbar=no,status=no"
			var ventana = window.open(sURL,"Ver",par)
			ventana.focus();
}
//--> 
</script>

</head>

<body onLoad="print();">
<table width="700" border="0" cellspacing="0" cellpadding="0">
  <tr class="lblCampo" valign="top">
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><div align="right"><img src="../imagenes/logo_perenco.gif" width="150" height="50" border="0"></div></td>
  </tr>
  <tr class="lblCampo" valign="top">
    <td width="249"><div align="left"></div></td>
    <td width="139">&nbsp;</td>
    <td width="212"><div align="right">Fecha : <? echo date("d/m/Y");?> <br>
Hora : <? echo date("H:i:s");?></div></td>
  </tr>
  <tr class="lblCampo" valign="top">
    <td colspan="3"><div align="center">KARDEX COMBUSTIBLE </div></td>
  </tr>
  <tr class="lblCampo" valign="top">
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3"><div align="left">
      <table width="698" border="0" cellspacing="0" cellpadding="0">
        
        <tr class="lblCampo">
          <td height="15">
            <div align="left">
              <table width="489" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="86">REPORTE DEL </td>
                  <td width="92"><div align="center"><? echo $fecha1?></div></td>
                  <td width="72"><div align="center">AL</div></td>
                  <td width="239"><div align="left"><? echo $fecha2?></div></td>
                  </tr>
              </table>
            </div></td>
        </tr>
        <tr>
          <td><div align="left">
              <table width="697" border="1" cellpadding="0" cellspacing="0" style="<?=$stylo['tabla']?>" bordercolor="<?=$bordetabla1?>">
                <tr valign="top" class="lblCampo">
                  <td width="111"><div align="center">Tipo Combustible </div></td>
                  <td width="92"><div align="right">Saldo Anterior </div></td>
                  <td width="115"><div align="center">Ingreso</div></td>
                  <td width="94">
                    <div align="center">Consumo</div></td>
                  <td><div align="center">Saldo Actual </div></td>
                  <td><div align="center">Destino</div></td>
                </tr>
                <? 
					  				   
				    $registros = 25;
					$pagina = $_GET["pagina"];
					
					if (!$pagina) { 
						$inicio = 0; 
						$pagina = 1; 
					}else { 
						$inicio = ($pagina - 1) * $registros; 
					} 				
					
						$resultado=$objPer->getCombusAlmaFechas();
					
					
                  while($filas=$objPer->NextRow($resultado))
                   {
				   $totconsumo=0;
				   $id=$filas['id_combus'];
				   $resultados=$objPer->getCombusAlmaSaldos($id);
				   $fila=$objPer->NextRow1($resultados);
				   
				   /*$ultimo=$fila['id_alma'];
				   if($ultimo!=""){				   
				   $resultadoU=$objPer->getCombusAlmaSaldosUlt($ultimo);
				   $filaU=$objPer->NextRow2($resultadoU);
				   }*/
				   ?>
                <tr valign="top" bgcolor="#999999" class="lblCampoBlanco" >
                  <td class="lblCampoBlanco">
                    <div align="center"> <? echo $filas['tipo']; ?> </div></td>
                  <td class="lblCampoBlanco"><div align="right">
                      <?php 
						if($fila['saldoant_alma']==0){
						echo "0";
						}else{
						echo number_format($fila['saldoant_alma'], 2, ',', ' ');
						}
						?>
                  </div></td>
                  <td class="lblCampoBlanco"><div align="right">
                      <?php 
						if($fila['ingreso_alma']==0){
						echo "0";
						}else{
						echo number_format($fila['ingreso_alma'], 2, ',', ' ');
						}
						?>
                  </div></td>
                  <td bgcolor="#999999" class="lblCampoBlanco">
                    <div align="right">
                      <?php 
						if($fila['consumo_alma']==0){
						echo "0";
						}else{
						echo number_format($fila['consumo_alma'], 2, ',', ' ');
						}
						?>
                  </div></td>
                  <td width="94">
                    <div align="right">
                      <?php 
						if($fila['saldoact_alma']==0){
						echo "0";
						}else{
						echo number_format($fila['saldoact_alma'], 2, ',', ' ');
						}
						?>
                  </div></td>
                  <td width="180">&nbsp;</td>
                </tr>
                <tr valign="top" class="lblForm" >
                  <td colspan="6" class="lblForm"><table width="696" border="0" cellpadding="0" cellspacing="0">
                    <?
						  $resultadop=$objPer->getCombusAlmaxTipo($filas['id_combus'],extraerfechamysql($fecha1),extraerfechamysql($fecha2));
				   		  //$filap=$objPer->NextRow1($resultadop); 
						  while($filap=$objPer->NextRow($resultadop))
                   			{
						  ?>
                    <tr>
                      <td width="110"><div align="center"><? echo $filap['fecha_alma']; ?></div></td>
                      <td width="100"><div align="right"><? echo number_format($filap['saldoant_alma'], 2, ',', ' '); ?></div></td>
                      <td width="117"><div align="right"><? echo number_format($filap['ingreso_alma'], 2, ',', ' '); ?></div></td>
                      <td width="96"><div align="right">
					  <? 
					  echo number_format($filap['consumo_alma'], 2, ',', ' ');
					  $totconsumo=$totconsumo+$filap['consumo_alma'];
					  ?>
					  </div></td>
                      <td width="98"><div align="right"><? echo number_format($filap['saldoact_alma'], 2, ',', ' '); ?></div></td>
                      <td width="175"><div align="center"><? echo $filap['obser']; ?></div></td>
                    </tr>
                    
                    <? 
			}
			$objPer->Liberar1($resultadop); 
			 
			?>
			<tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td bgcolor="#999999"><div align="right"><? echo number_format($totconsumo, 2, ',', ' ');?></div></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                  </table></td>
                  </tr>
                <? 
			}
			$objPer->Liberar($resultado); 
			 
			?>
              </table>
          </div></td>
        </tr>        
        <tr>          
            <td>
              <div align="center">			  </div>			</td>          
        </tr>
      </table>
    </div></td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
  </tr>
</table>
</body>

</html>

