<?
ini_set('error_reporting', 1);
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = '../index.php';
		</script>
		<? 
		exit();
		}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cuenta Corriente</title>
<script type="text/javascript" src="validarut.js"></script>
<script language="javascript" src="cal.js" type="text/javascript"></script>
<script src="http://www.bci.cl/common/include/valores.js"></script>
<?
include("../abre_conexion.php");
$id=$_GET["id"];
$proyecto=$_GET["id1"];
$cons = mysql_query("SELECT * FROM g_clientes WHERE rut='$id'", $enlace);
$cont=0;
while ( mysql_fetch_object ($cons) )
{
	$nombres = mysql_result($cons, $cont, "nombres");
    $paterno = mysql_result($cons, $cont, "ap_paterno");
	$materno = mysql_result($cons, $cont, "ap_materno");
}
?>
<style type="text/css">
<!--
.Estilo11 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
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>

</head>

<body alink="CCCCCC" link="CCCCCC" vlink="CCCCCC">
<div align="center">
  <p>Ingreso Caja <?=$nombres." ".$paterno." ".$materno;?>
  </p>
  <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>
  <form id="form1" name="form1" method="post" action="ingreso_caja.php?id=<?=$id;?>">
    <table border="1" align="center" cellpadding="1" cellspacing="0">
      <tr>
        <td><div align="left"><span class="Estilo11">Cantidad (UF) </span></div></td>
        <td><div align="left">
          <input name="cantidad" type="text" class="textboxnormal" id="cantidad" size="40" maxlength="20" onKeyUp="javascript:this.value=this.value.toUpperCase();"/>
        </div></td>
      </tr>
      <tr>
        <td><div align="left"><span class="Estilo11">Promesa</span></div></td>
        <td><div align="left">
          <select name="promesa" id="promesa">
            <option value="null" selected="selected">SELECCIONE PROMESA
              <?
			$cons_empresa = mysql_query("SELECT DISTINCT(promesa) AS promesa FROM g_movimientos WHERE rut_cliente='$id';", $enlace);
 			$cont=0;
			while ( mysql_fetch_object ($cons_empresa) ) 
 			{
 				$ides=mysql_result($cons_empresa, $cont, "promesa");
				$cont1=0;
				$prom=0;
				$cons = mysql_query("SELECT p.promesa AS promesa FROM g_promesa AS p, g_promesa_detalle AS pd, g_existencia AS e WHERE p.id=$ides AND p.id=pd.promesa AND (pd.producto=1 OR pd.producto=4) AND pd.existencia=e.id AND e.proyecto=$proyecto;", $enlace);
 				
				while ( mysql_fetch_object ($cons) ) 
 				{
					$prom=mysql_result($cons, $cont1, "promesa");
					$cont1=$cont1+1;
				}
				if ($prom!=0)
				{  				
  					echo "              <option value=\"".$ides."\">".$prom."\n";
				}
  				$cont = $cont + 1;
 			}
			?>
            </option>
          </select>
        </div></td>
      </tr>
      <tr>
        <td><div align="left"><span class="Estilo11">Concepto </span></div></td>
        <td><div align="left">
          <select name="forma" id="forma">
		  <option value="null" selected>SELECCIONE CONCEPTO
		  <?
			$cons_empresa = mysql_query("SELECT * FROM g_financiamiento WHERE id < 6 ORDER BY id ASC;", $enlace);
 			$cont=0;
			while ( mysql_fetch_object ($cons_empresa) ) 
 			{
 				$ides=mysql_result($cons_empresa, $cont, "id");
  				$nombre=mysql_result($cons_empresa, $cont, "nombre");
  				echo "              <option value=\"".$ides."\">".$nombre."\n";
  				$cont = $cont + 1;
 			}
			?>
          </select>
          </div></td>
      </tr>
      <tr>
        <td><div align="left"><span class="Estilo11">Fecha</span></div></td>
        <td valign="baseline"><input name="fecha" type="text" class="textboxnormal" id="fecha" size="35" maxlength="40" value="<?=date("d/m/Y");?>" />
          <a href="javascript:show_calendar('form1.fecha');"><img src="../Images/CALENDAR.jpg" width="24" height="22" align="absmiddle" style="cursor:pointer" title="Presione aqui y seleccione la fecha"/></a></td>
      </tr>
      <tr>
        <td><div align="left"><span class="Estilo11">Forma de Pago </span></div></td>
        <td><div align="left">
          <input name="descripcion" type="text" class="textboxnormal" id="descripcion" onKeyUp="javascript:this.value=this.value.toUpperCase();" value="" size="40" maxlength="30" />
        </div></td>
      </tr>
      <tr>
        <td><div align="left"><span class="Estilo11">Valor UF  </span></div></td>
        <td><div align="left">
          <input name="uf" type="text" class="textboxnormal" id="uf" size="40" maxlength="1" />
        </div></td>
      </tr>
    </table>
    <table width="200" border="0">
      <tr>
        <td><div align="center">
            <label></label>
        </div></td>
      </tr>
      <tr>
        <td><div align="center">
          <input type="button" name="Submit" value="Continuar" onClick="enviar(form1)"/>
        </div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
  </form>
  <p>&nbsp;</p>
</div>
</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 -->
function validal(evt){
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 65 && key <= 90) || (key >= 97 && key <= 122) || (key == 32));
}

function enviar(form)
{
	if (form.cantidad.value==0)
		{
		alert ("Ingrese Cantidad")
		form.cantidad.focus();
		return false;
		}
	else if (form.promesa.value== "null")
	{
		alert ("Ingrese Promesa");
		form.promesa.focus();
		return false;
	}
	else if (form.forma.value== "null")
	{
		alert ("Ingrese Forma");
		form.forma.focus();
		return false;
	}
	else if (form.descripcion.value==0)
	{
		alert ("Ingrese Descripcion");
		form.descripcion.focus();
		return false;
	}
	else if (form.fecha.value==0)
	{
		alert ("Ingrese UF");
		form.fecha.focus();
		return false;
	}	
	else if (form.uf.value==0)
	{
		alert ("Ingrese UF");
		form.uf.focus();
		return false;
	}	
	form.submit();
}

</script>

<script language="javascript">
if(typeof(arrValores) != "undefined")
if(typeof(arrValores[4])=="object")
document.form1.uf.value=formatear_numero(arrValores[4].valor2);
</script>

<script language="javascript" type="text/javascript">
function cerrar()
{
window.top.open('','_parent','');
window.top.close();
}
</script>