<?
ini_set('error_reporting', 1);
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = '../index.php';
		</script>
		<? 
		exit();
		}
?>
<?
include("../conex.php");
$id=$_GET["id"];
$cliente=$_GET["id1"];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Cuentas Corrientes</title>
<style type="text/css">
<!--
.Estilo11 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
.Estilo12 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; }
body {
	background-color: #CCCCCC;
	margin-left: 0px;
	margin-top: 3px;
	margin-right: 0px;
	margin-bottom: 0px;
}
select {
	clear: right;
	float: left;
	height: auto;
	width: 267px;
}
-->
</style></head>

<body vlink="CCCCCC" alink="CCCCCC" link="CCCCCC">
<form action="" method="post" enctype="multipart/form-data" name="form1" target="_self">
<?
$esql="SELECT * FROM nombres WHERE rut='$cliente'";
$cons_empresa = mysql_query($esql,$enlace);
$cont=0;
while( mysql_fetch_object ($cons_empresa) )
{	
$nombre		= mysql_result($cons_empresa, $cont, "razon_social");
$rut		= mysql_result($cons_empresa, $cont, "rut");
}
?>
  <div align="center">Movimientos <?=$nombre?>
    <table width="30%" border="0">
      <tr>
        <th scope="col"><div align="center">
            <input name="salir" type="button" class="Estilo11" id="salir" value="Salir" onclick="cerrar()"/>
        </div></th>
      </tr>
    </table>
  </div>
  <div align="center"></div>
  <div align="center">
    <table width="90%" border="0">
      <tr>
        <th scope="col">&nbsp;</th>
      </tr>
    </table>
	<?
	$sql="SELECT num_dcto FROM entrada WHERE id=$id";
	//echo $sql;
	$cons1 = mysql_query($sql,$enlace);
	$cont2=0;
	while (mysql_fetch_object ($cons1))
	{
		$numpro=mysql_result($cons1, $cont2, "num_dcto");
		//echo $cont2;	
		?>
	<table width="90%" border="0">
      <tr>
        <th scope="col">&nbsp;</th>
      </tr>
	  <tr>
        <th scope="col"><div align="center">Factura Nš 
            <?=$numpro;?>
        </div></th>
      </tr>
	  <tr>
        <th scope="col">&nbsp;</th>
      </tr>
    </table>
    <table width="90%" border="0">
      <tr bgcolor="#FFFFFF">
        <th width="60" scope="col"><div align="center">Fecha</div></th>
        <th width="359" scope="col"><div align="center">Descripci&oacute;n</div></th>
        <th scope="col"><div align="center">Cargos (UF) </div></th>
        <th width="98" scope="col"><div align="center">Abonos (UF) </div></th>
        <th width="87" scope="col"><div align="center">Saldo (UF) </div></th>
      </tr>
      <?
	  	  $esql="SELECT * FROM ctacte_proveedor WHERE num_salida=$id ORDER BY fecha";
		  //echo $esql;
		  $cons_empresa = mysql_query($esql,$enlace);
		  $cont=0;
		  $totald=0;
		  $totalh=0;
		  while (mysql_fetch_object ($cons_empresa))
		  {
		  	$fecha=mysql_result($cons_empresa, $cont, "fecha");
			$fecha=$fecha[8].$fecha[9].$fecha[7].$fecha[5].$fecha[6].$fecha[4].$fecha[0].$fecha[1].$fecha[2].$fecha[3];
			if(mysql_result($cons_empresa, $cont, "tipo")=="D")
			{
				$totald=$totald+mysql_result($cons_empresa, $cont, "valor");
			}
			else 
			{
				$totalh=$totalh+mysql_result($cons_empresa, $cont, "valor");
			}
		  	?>
      <tr>
        <td class="Estilo12" style="border-color:#FFFFFF; border:solid; border-width:2px; border-right-width:1px; border-left-width:1px"><div align="center">
            <?=$fecha;?>
        </div></td>
        <td class="Estilo12" style="border-color:#FFFFFF; border:solid; border-width:2px; border-right-width:1px"><div align="left"><span class="Estilo11"><strong>&nbsp; 
		<? 
		if(mysql_result($cons_empresa, $cont, "descripcion")!=NULL)
		{ 
			echo mysql_result($cons_empresa, $cont, "descripcion"); 
		} 
		else 
		{ 
			echo "PROMESA Nš ".$numpro; 
		}
		?>
		</strong></span></div></td>
        <td class="Estilo12" style="border-color:#FFFFFF; border:solid; border-width:2px; border-right-width:1px; border-left-width:1px"><div align="center">
          <?
		  if(mysql_result($cons_empresa, $cont, "tipo")=="D")
			{
				echo mysql_result($cons_empresa, $cont, "valor");
			}
			?>
        </div></td>
        <td class="Estilo12" style="border-color:#FFFFFF; border:solid; border-width:2px; border-right-width:1px; border-left-width:1px"><div align="center">
		<?
		  if(mysql_result($cons_empresa, $cont, "tipo")=="H")
			{
				echo mysql_result($cons_empresa, $cont, "valor");
			}
			?>
			</div></td>
        <td class="Estilo12" style="border-color:#FFFFFF; border:solid; border-width:2px; border-left-width:1px"><div align="center"><?=number_format($totalh-$totald,2,',','.');?></div></td>
      </tr>
      
      <?
			$cont = $cont + 1;
		  }
		?>
	<tr>
        <td class="Estilo12">&nbsp;</td>
        <td class="Estilo12">&nbsp;</td>
        <td class="Estilo12">&nbsp;</td>
        <td class="Estilo12">&nbsp;</td>
        <td class="Estilo12">&nbsp;</td>
      </tr>
      <tr>
        <td class="Estilo12">&nbsp;</td>
        <td bgcolor="FFFFFF"><div align="right"><strong>TOTALES</strong></div></td>
        <td class="Estilo12" style="border-color:#FFFFFF; border:solid; border-width:2px; border-right-width:1px; border-left-width:1px"><div align="center"><strong>
            <?=$totald;?>
        </strong></div></td>
        <td class="Estilo12" style="border-color:#FFFFFF; border:solid; border-width:2px; border-right-width:1px; border-left-width:1px"><div align="center"><strong>
            <?=$totalh;?>
        </strong></div></td>
        <td class="Estilo12" style="border-color:#FFFFFF; border:solid; border-width:2px; border-left-width:1px"><div align="center"><strong>
            <?=$totalh-$totald;?>
        </strong></div></td>
      </tr>
    </table>
	<?
	//echo $cont2;
	$cont2=$cont2+1;
	}
	//echo $cont2;
	?>
  </div>
</form>
</body>
</html>
<script language="javascript">
var nav4 = window.Event ? true : false;
<!-- Ingreso solo numeros y k K - . -->
function valida(evt){
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 48 && key <= 57) || (key == 107) || (key == 75) || (key == 45) || (key == 46));
}
<!-- Ingreso solo letras y espacio -->
function validal(evt){
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 65 && key <= 90) || (key >= 97 && key <= 122) || (key == 32));
}
</script>
<script language="javascript" type="text/javascript">
function cerrar()
{
window.top.open('','_parent','');
window.top.close();
}
</script>