<?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 print_1(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 background="../imagenes/fondo.jpg">
<table width="680" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="25"><img src="../estilo_tabla/parte_sup_izq.gif" width="25" height="25"></td>
    <td width="680" background="../estilo_tabla/parte_sup_cen.gif" valign="bottom">
      <div align="left" class="lblTitulo" >Kardex Combustibles </div></td>
    <td width="25"><img src="../estilo_tabla/parte_sup_der.gif" width="25" height="25" border="0" usemap="#MapMap"></td>
  </tr>
  <tr>
    <td width="25" background="../estilo_tabla/parte_med_izq.gif">&nbsp;</td>
    <td width="680" height="86" background="../estilo_tabla/parte_med_cen.gif"><div align="center">
        <table width="620" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="15" colspan="5"><div align="center"></div></td>
          </tr>
          <tr>
            <form action="cvp_kardex_combus.php?fecha1=<? echo $fecha1?>&fecha2=<? echo $fecha2?>" method="post" name="form1" >
              <td width="106" height="15">
                <div align="left" class="lblForm">Buscar Por Fechas: </div></td>
              <td width="254" height="15" class="lblCampo">
                <div align="left">
                  <table width="209" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="108"><div align="left">
                          <table width="87" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="67"><div align="left">
                                  <input name="fecha1" type="text" class="lblCampo" id="fecha1" value="<? echo $fecha1?>" size="12" maxlength="10" title="FORMATO dd/mm/AA">
                              </div></td>
                              <td width="10">&nbsp;</td>
                              <td width="109"><div align="left"> <a onMouseOver="window.status='Calendario';return true;" onMouseOut="window.status='';return true;"  href="javascript:show_calendar('form1.fecha1');"> <img src="../imagenes/calendar.jpg" alt="Calendario" width="16" height="15" border="0"> </a> </div></td>
                            </tr>
                          </table>
                      </div></td>
                      <td width="144"><div align="left">
                          <table width="87" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="67"><div align="left">
                                  <input name="fecha2" type="text" class="lblCampo" id="fecha2" value="<? echo $fecha2?>" size="12" maxlength="10" title="FORMATO dd/mm/AA">
                              </div></td>
                              <td width="10">&nbsp;</td>
                              <td width="109"><div align="left"> <a onMouseOver="window.status='Calendario';return true;" onMouseOut="window.status='';return true;"  href="javascript:show_calendar('form1.fecha2');"> <img src="../imagenes/calendar.jpg" alt="Calendario" width="16" height="15" border="0"> </a> </div></td>
                            </tr>
                          </table>
                      </div></td>
                    </tr>
                  </table>
              </div></td>
              <td width="91" height="15">
                <div align="left"><span class="lblForm">
                  <input type="submit" name="Submit" value="Buscar" style="<?=$stylo['st2']?>" class="botira">
              </span></div></td>
              <td width="56"><div align="left"><span class="lblForm"> </span> </div></td>
              <td width="58"><div align="left"><span class="lblForm"> </span></div></td>
            </form>
          </tr>
          <tr>
            <td colspan="5"><div align="left">
                <table width="625" border="1" cellpadding="0" cellspacing="0" style="<?=$stylo['tabla']?>" bgcolor="<?=$c_fondo['fondo tabla']?>" bordercolor="<?=$bordetabla?>">
                  <tr valign="top" class="lblCampoBlanco" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                    <td width="101"><div align="center">Tipo Combustible </div></td>
                    <td width="88"><div align="center">Saldo Anterior </div></td>
                    <td width="90"><div align="center">Ingreso</div></td>
                    <td width="96">
                      <div align="center">Consumo</div></td>
                    <td><div align="center">Saldo Actual </div></td>
                    <td><div align="center">Detalle de Uso</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;
				   
				   $resultados=$objPer->getCombusAlmaSaldos($filas['id_combus']);
				   $fila=$objPer->NextRow1($resultados);
				   
				   
				   /*$ultimo=$fila['id_alma'];
				   if($ultimo!=""){				   
				   $resultadoU=$objPer->getCombusAlmaSaldosUlt($ultimo);
				   $filaU=$objPer->NextRow2($resultadoU);
				   }*/
				   ?>
                  <tr valign="top" class="lblForm" >
                    <td class="lblForm">
                      <div align="center">
                        <? 
						  echo $filas['tipo'];
						  //echo $id=$filas['id_combus']; 
						  ?>
                    </div></td>
                    <td class="lblForm" bgcolor="<?=$c_fondo_tr["fondo tr"]?>"><div align="right">
                        <?php 
						if($fila['saldoant_alma']==0){
						echo "0";
						}else{
						echo number_format($fila['saldoant_alma'], 2, ',', ' ');
						}
						?>
                    </div></td>
                    <td class="lblForm" bgcolor="<?=$c_fondo_tr["fondo tr"]?>"><div align="right">
                        <?php 
						if($fila['ingreso_alma']==0){
						echo "0";
						}else{
						echo number_format($fila['ingreso_alma'], 2, ',', ' ');
						}
						?>
                    </div></td>
                    <td class="lblForm" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                      <div align="right">
                        <?php 
						if($fila['consumo_alma']==0){
						echo "0";
						}else{
						echo number_format($fila['consumo_alma'], 2, ',', ' ');
						}
						?>
                    </div></td>
                    <td width="83" bgcolor="<?=$c_fondo_tr["fondo tr"]?>">
                      <div align="right">
                        <?php 
						if($fila['saldoact_alma']==0){
						echo "0";
						}else{
						echo number_format($fila['saldoact_alma'], 2, ',', ' ');
						}
						?>
                    </div></td>
                    <td width="153" bgcolor="<?=$c_fondo_tr["fondo tr"]?>"><div align="left"></div></td>
                  </tr>
                  <tr valign="top" class="lblForm" >
                    <td colspan="6" class="lblForm"><div align="left">
                        <table width="620" 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="101"><div align="center"><? echo $filap['fecha_alma']; ?></div></td>
                            <td width="89"><div align="right"><? echo number_format($filap['saldoant_alma'], 2, ',', ' '); ?></div></td>
                            <td width="94"><div align="right"><? echo number_format($filap['ingreso_alma'], 2, ',', ' '); ?></div></td>
                            <td width="97"><div align="right">
							<? 
							echo number_format($filap['consumo_alma'], 2, ',', ' ');
							$totconsumo=$totconsumo+$filap['consumo_alma'];
							?>
							</div></td>
                            <td width="86"><div align="right"><? echo number_format($filap['saldoact_alma'], 2, ',', ' '); ?></div></td>
                            <td width="153"><div align="center"><? echo $filap['obser']; ?></div></td>
                          </tr>
                          
                          <? 
						 
			}
			$objPer->Liberar1($resultadop); 
			 
			?>
			<tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td><div align="right"><? echo number_format($totconsumo, 2, ',', ' ');?></div></td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                          </tr>
                        </table>
                    </div></td>
                  </tr>
                  <? 
				   
			}
			$objPer->Liberar($resultado); 
			 
			?>
                </table>
            </div></td>
          </tr>
          <tr>
            <td colspan="5"><div align="left"><span class="lblForm"></span></div></td>
          </tr>
          <tr>
            <form name="form2" method="post" action="cvp_kardex_combus_print.php">
              <td colspan="5">
                <div align="center">
                  <table width="450" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="104"><div align="right">
                          <input type="button" name="Submit22" value=".:Imprimir:." style="<?=$stylo['st2']?>" class="botira" onClick="javascript:print_1('cvp_kardex_combus_print.php?fecha1=<? echo $fecha1?>&fecha2=<? echo $fecha2?>',800,600)">
                      </div></td>
                      <td width="93">
                        <input name="fecha12" type="hidden" id="fecha12" value="<? echo $fecha1?>">
                        <input name="fecha2" type="hidden" id="fecha22" value="<? echo $fecha2?>">
                      </td>
                      <td width="104"><div align="left">
                          <input type="button" name="Submit2" value=".:Regresar:." style="<?=$stylo['st2']?>" class="botira" onClick="volver(this.form);">
                      </div></td>
                    </tr>
                  </table>
              </div></td>
            </form>
          </tr>
        </table>
    </div></td>
    <td background="../estilo_tabla/parte_med_der.gif">&nbsp;</td>
  </tr>
  <tr>
    <td><img src="../estilo_tabla/parte_inf_izq.gif" width="25" height="20"></td>
    <td background="../estilo_tabla/parte_inf_cen.gif">&nbsp;</td>
    <td><img src="../estilo_tabla/parte_inf_der.gif" width="25" height="20"></td>
  </tr>
</table>
<map name="MapMap">
  <area shape="rect" coords="2,5,22,21" href="fondo.php">
</map>
<map name="Map">
  <area shape="rect" coords="2,5,22,21" href="fondo.php">
</map>
</body>

</html>

