<?
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = 'index.php';
		</script>
		<? 
		exit();
		}
$id_empresa = $_SESSION['ss_empresa'];
$id_user = $_SESSION['ss_user'];		
?>
<?
include("../conex.php");
include("../css/mascara_fecha.js");
if ( isset($_GET["cnt"]))$contprod=$_GET["cnt"];
else $contprod=1;
?>
<!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>Compra</title>
</head>
<?
/********************************** Datos Empresa *********************************************************************/
	$sql_empresa = "SELECT * FROM empresa, comunas WHERE comunas.cod_comuna = empresa.comuna AND id=$id_empresa";
	$res_empresa = mysql_query($sql_empresa,$enlace);
	$row=0;
	while (mysql_fetch_object ($res_empresa))
		{
		$empresa_rut=mysql_result($res_empresa, $row, "rut_empresa");
		$empresa_nombre=mysql_result($res_empresa, $row, "nombre");
		$empresa_direccion=mysql_result($res_empresa, $row, "direccion");
		$empresa_ciudad=mysql_result($res_empresa, $row, "ciudad");
		$empresa_comuna=mysql_result($res_empresa, $row, "comunas.comuna");
		$empresa_actividad=mysql_result($res_empresa, $row, "actividad");
		$empresa_rut_representante=mysql_result($res_empresa, $row, "rut_representante");
		$empresa_nombre_representante=mysql_result($res_empresa, $row, "nombre_representante");
		$row=$row+1;
		}
$id_ent = $_POST["txt_nv"];		
$sql_nv = "SELECT s.id AS id,s.tipo_pago AS fp, s.num_dcto AS nv, s.tipo_dcto AS tdc, s.rut_proveedor AS rc, s.fecha_emision AS fe,s. fecha_pago AS fv, s.fecha_recepcion AS fr, s.neto AS neto, s.iva AS iva, s.total AS total, s.iva_retenido AS ivar, s.bodega AS bodega, s.tipo_pago AS tipo_pago, s.correlativo, s.productos, s.vendedor
			FROM entrada AS s, tipo_dcto AS td 
			WHERE s.tipo_dcto = td.id AND (td.descripcion ='ND' OR td.descripcion ='ND ELECTRONICA') AND s.id=$id_ent AND s.empresa = $id_empresa";
$res_nv= mysql_query($sql_nv,$enlace);
$nv_cont = 0;
$sqlnv_ivar='';
while ( mysql_fetch_object($res_nv))
	{
	$txtndcto=mysql_result($res_nv, $nv_cont, "nv");
	$lstdcto=mysql_result($res_nv, $nv_cont, "tdc");
	$id_bodega=mysql_result($res_nv, $nv_cont, "bodega");
	$id_vendedor=mysql_result($res_nv, $nv_cont, "s.vendedor");
	$mercaderia=mysql_result($res_nv, $nv_cont, "s.productos");
	$txtcorrelativo=mysql_result($res_nv, $nv_cont, "s.correlativo");
	$lstpago=mysql_result($res_nv, $nv_cont, "tipo_pago");
	$sqlnv_rc=mysql_result($res_nv, $nv_cont, "rc");
	$txtrut=$sqlnv_rc;
	$fechaven=mysql_result($res_nv, $nv_cont, "fv");
	$fechaemi=mysql_result($res_nv, $nv_cont, "fe");
	$fecharec=mysql_result($res_nv, $nv_cont, "fr");
	$txtneto=mysql_result($res_nv, $nv_cont, "neto");
	$txtiva=mysql_result($res_nv, $nv_cont, "iva");
	$txttotal=mysql_result($res_nv, $nv_cont, "total");
		
	$ano = substr ($fechaven, 0, 4);
	$mes = substr ($fechaven, 5, 2);
	$dia = substr ($fechaven, 8, 2); 
	$fecha3 = "$dia/$mes/$ano";
	$ano = substr ($fechaemi, 0, 4);
	$mes = substr ($fechaemi, 5, 2);
	$dia = substr ($fechaemi, 8, 2); 
	$fecha = "$dia/$mes/$ano";	
	$ano = substr ($fecharec, 0, 4);
	$mes = substr ($fecharec, 5, 2);
	$dia = substr ($fecharec, 8, 2); 
	$fecha2 = "$dia/$mes/$ano";	
	$txtivar=mysql_result($res_nv, $nv_cont, "ivar");
	
	
	
	$sqlnv_id=mysql_result($res_nv, $nv_cont, "id");
	$id_fp=mysql_result($res_nv, $nv_cont, "fp");
	$sqlnv_fe=mysql_result($res_nv, $nv_cont, "fe");

	$nv_cont += 1;
	}
	
$sqlbp = "SELECT * FROM nombres WHERE rut = '".$txtrut."'";
$resbp = mysql_query($sqlbp,$enlace);
if(mysql_fetch_object($resbp))
	{
	$txtrut = mysql_result($resbp, 0, "rut");
	$txtrsoc = mysql_result($resbp, 0, "razon_social");
	$txtemail = mysql_result($resbp, 0, "email");
	$txtactividad = mysql_result($resbp, 0, "rubro_giro");	
	$txtfono = mysql_result($resbp, 0, "fono1");
	$txtfax = mysql_result($resbp, 0, "fax");
	$txtciudad = mysql_result($resbp, 0, "ciudad");
	$txtdireccion = mysql_result($resbp, 0, "direccion");
	$lstcom = mysql_result($resbp, 0, "comuna");
	$lstreg = mysql_result($resbp, 0, "region");
	}


	if ($nv_cont==0){
	?>
	<script language="javascript">
		alert("No existe Factura relacionada al numero ingresado");
		window.top.open('','_parent','');
		window.top.close();
	</script>
	<?
	}
			
		
		
		
		
		
/************************************************** sacar valor de iva ***********************************************/	
	$sql_par = "SELECT valor FROM parametros WHERE descripcion = 'IVA'";
	$res_par = mysql_query($sql_par,$enlace);
	$row=0;
	while (mysql_fetch_object ($res_par))
		{
		$par_iva=mysql_result($res_par, $row, "valor");
		$row=$row+1;
		}
/************************************************** fechas ***********************************************
		if ($fecha=='') $fecha=$fecha = date(d)."/".date(m)."/".date(Y);;
		if ($fecha2=='') $fecha2=$fecha2 = date(d)."/".date(m)."/".date(Y);;
		if ($fecha3=='') $fecha3=$fecha3 = date(d)."/".date(m)."/".date(Y);;
		*/

?>

<script type="text/javascript" src="../css/validarut.js"></script>
<script language="JavaScript" src="../css/cal.js" type="text/JavaScript"></script>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="640" align="center" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="60px"><div align="center"><img src="../Images/logo.gif" width="60px" height="60px"></div></td>
	<td width="220px"><div align="left"><font size="1">
		<?=$empresa_nombre?><br>
		<?=$empresa_direccion?><br>
		<?=$empresa_ciudad;?>

		</font></div>
	</td>
    <td width="360px" align="left"><div align="left"><font size="+2">&nbsp;ND Nº <?=$txtndcto;?></font></div></td>
  </tr>
</table>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr> 
		<td width="10%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif"></font></strong></div></td>
		<td width="20%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif"></font></strong></div></td>
		<td width="40%"><div align="center"></div></td>
		<td width="20%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif"></font></strong></div></td>
		<td width="10%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif"></font></strong></div></td>
    </tr>
</table>
<br>
<table width="640" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td width="100">R.U.T.</td>
		<td width="157"><input name="txtrut" id="txtrut" value="<?=$txtrut;?>" type="text" readonly="1" size="23" maxlength="12"/></td>
		<td width="23" align="left">&nbsp;</td>
		<td width="100" align="right"><div align="left">Señor: &nbsp;</div></td>
		<td width="260">
		  <input name="txtrsoc" id="txtrsoc" type="text" size="42" value="<?=$txtrsoc;?>" readonly="1"/>		</td>           
  </tr>
<tr>
		<td>E-Mail</td>
		<td>
			<input name="txtemail" id="txtemail" type="text" size="23" value="<?=$txtemail;?>" readonly="1">		</td>
		<td>&nbsp;</td>
		<td align="right">
			<div align="left">Actividad:&nbsp;	        </div></td>
		<td>
			<input name="txtactividad" id="txtactividad" type="text" size="42" value="<?=$txtactividad;?>" readonly="1">		</td>
	</tr>
<tr>
		<td>Fono: </td>
		<td><input name="txtfono" id="txtfono" type="text" size="23" value="<?=$txtfono;?>" readonly="1"/></td>
		<td>&nbsp;</td>
		<td align="right"><div align="left">Regi&oacute;n: &nbsp;</div></td>
		<td><select name="lstreg" onChange="rellenaCombo('form1');" style="width:280px;" disabled="disabled">
        <option value="null" selected>SELECCIONE REGION
          	<?
			$cons_region = mysql_query("SELECT * FROM regiones;", $enlace);
 			$cont=0;
			while ( mysql_fetch_object ($cons_region) ) 
 			{
 				$ides=mysql_result($cons_region, $cont, "Cod_Region");
  				$nombres=mysql_result($cons_region, $cont, "Region");
  				if($lstreg==$ides){$sel="selected";}
				else {$sel="";}
				echo "              <option value=\"".$ides."\"$sel>".$nombres."\n";
				
  				$cont = $cont + 1;
 			}
			?>
      </select></td>
</tr>
	<tr>
		<td>Fax:</td>
		<td><input name="txtfax" id="txtfax" type="text"  size="23" value="<?=$txtfax;?>" readonly="1"/></td>
		<td>&nbsp;</td>
		<td align="right"><div align="left">Comuna:&nbsp;		</div></td>
		<td><select name="lstcom" disabled="disabled" style="width:280px">
		<? if ($lstreg=='')$lstreg=0;?>
        <option value="null">SELECCIONE COMUNA
		<?
		
			$cons_com = mysql_query("SELECT * FROM comunas WHERE region=$lstreg;", $enlace);
 			$cont=0;
			while ( mysql_fetch_object ($cons_com) ) 
 			{
 				$ides=mysql_result($cons_com, $cont, "Cod_Comuna");
  				$nombres=mysql_result($cons_com, $cont, "Comuna");
  				if($lstcom==$ides){
					$sel="selected";
					}
				else {$sel="";}
				echo "              <option value=\"".$ides."\"$sel>".$nombres."\n";
				
  				$cont = $cont + 1;
 			}
			?>
        </select></td>
	</tr>
	<tr>
		<td>Ciudad:&nbsp; </td>
		<td><input name="txtciudad" id="txtciudad" type="text" size="23" value="<?=$txtciudad;?>" readonly="1" /></td>
		<td>&nbsp;</td>
		<td align="right"><div align="left">Direcci&oacute;n:</div></td>
		<td><input name="txtdireccion" id="txtdireccion" type="text" size="42" value="<?=$txtdireccion;?>" readonly="1"/></td>
	</tr>
		<tr>
		<td>N&ordm; Dcto. </td>
		<td><input name="txtndcto" type="text" id="txtndcto" value="<?=$txtndcto?>" size="23" readonly="1"></td>
		<td>&nbsp;</td>
		<td align="right"><div align="left">Tipo Dcto.</div></td>
		<td>
			
			<select name="lstdcto" style="width:280px" disabled="disabled">

            <?
			$cons_dcto = mysql_query("SELECT * FROM tipo_dcto WHERE empresa=$id_empresa;", $enlace);
 			$cont=0;
			while ( mysql_fetch_object ($cons_dcto) ) 
 			{
 				$ides=mysql_result($cons_dcto, $cont, "id");
  				$nombres=mysql_result($cons_dcto, $cont, "descripcion");
  				if($lstdcto==$ides){$sel="selected";}
				else {$sel="";}
				echo "              <option value=\"".$ides."\"$sel>".$nombres."\n";
				
  				$cont = $cont + 1;
 			}
			?>
          </option>
		  </select></td>
	</tr>
	<tr>
		<td>Emision:</td>
	    <td><input name="fecha" type="text" id="fecha" style="border-width:0;" value="<?=$fecha?>" size="23" readonly="1" />	  </td>
		<td>&nbsp;</td>
		<td>Pago:</td>
		<td><select name="lstpago" id="lstpago" style="width:280px" disabled="disabled">
          <?
			$cons_pago = mysql_query("SELECT * FROM tipo_pago WHERE descripcion ='CONTADO' OR descripcion = 'CREDITO'", $enlace);
 			$cont=0;
			while ( mysql_fetch_object ($cons_pago) ) 
 			{
 				$ides=mysql_result($cons_pago, $cont, "id");
  				$nombres=mysql_result($cons_pago, $cont, "descripcion");
  				if($lstpago==$ides){$sel="selected";}
				else {$sel="";}
				echo "              <option value=\"".$ides."\"$sel>".$nombres."\n";
				
  				$cont = $cont + 1;
 			}
			?>
          </option>
                </select></td>
	</tr>
	<tr>
		<td>Recepcion: </td>
	    <td><input name="fecha2" type="text" id="fecha2" style="border-width:0;" value="<?=$fecha2?>" size="23" readonly="1" /></td>
		<td>&nbsp;</td>
		<td>Iva Retenido:</td>
		<td><input name="txtivar" id="txtivar" type="text" size="42" value="<?=$txtivar;?>" readonly="1"/></td>
	</tr>
		<tr>
		<td> Vencimiento:</td>
	    <td><input name="fecha3" type="text" id="fecha3" style="border-width:0;" value="<?=$fecha3?>" size="23" readonly="1" /></td>
		<td>&nbsp;</td>
		<td>Bodega</td>
		<td><select name="id_bodega" id="id_bodega" size="1" style="width:280px" disabled="disabled">
		<? 
		$sql_buem= mysql_query("SELECT * FROM bodega WHERE empresa=$id_empresa",$enlace);
		$buem_contb = 0;
		while ( mysql_fetch_object($sql_buem))
			{
			$sqlbuem_codigo=mysql_result($sql_buem, $buem_contb, "id");
			$sqlbuem_rsoc=mysql_result($sql_buem, $buem_contb, "descripcion");
			?>
			<option value="<?=$sqlbuem_codigo?>" <? if ($sqlbuem_codigo==$id_bodega){?> selected="selected" <? }?> >
				<?=$sqlbuem_rsoc?>
			</option>
			<? 
			$buem_contb += 1;
			} 
		?>
		</select></td>
	</tr>
	<tr>
		<td>Correlativo </td>
	   <td><input name="txtcorrelativo" id="txtcorrelativo" type="text" size="10" value="<?=$txtcorrelativo;?>" /></td>
        <td></td>
		<td>Comprador</td>
		<td><select name="id_vendedor" id="id_vendedor" size="1" style="width:270px" disabled="disabled">
          <? 
		$sql_buem= mysql_query("SELECT * FROM vendedor",$enlace);
		$buem_contb = 0;
		while ( mysql_fetch_object($sql_buem))
			{
			$sqlbuem_codigo=mysql_result($sql_buem, $buem_contb, "id");
			$sqlbuem_rsoc=mysql_result($sql_buem, $buem_contb, "nombres");
			?>
          <option value="<?=$sqlbuem_codigo?>" <? if ($sqlbuem_codigo==$id_vendedor){?> selected="selected" <? }?> >
          <?=$sqlbuem_rsoc?>
          </option>
          <? 
			$buem_contb += 1;
			} 
			
			
		?>
        </select></td>
	</tr>




 <tr>
    <?
	if ($mercaderia==1) 
	{ ?>
    
	<td width="10%"><div align="right">&nbsp;</div></td>
    <td width="10%"><div align="right">Mercaderia&nbsp;</div></td>    
    <td width="5%"><input name="mercaderia" type="radio" checked = "checked"   />    </td>
     <td width="10%"><div align="right">Gastos&nbsp;</div></td>
    <td width="5%"><input name="mercaderia" type="radio"  />    </td>
    <? }
	else 
	{
    ?>
    <td width="10%"><div align="right">&nbsp;</div></td>
    <td width="10%"><div align="right">Mercaderia&nbsp;</div></td>    
    <td width="5%"><input name="mercaderia" type="radio" />    </td>
    <td width="10%"><div align="right">Gastos&nbsp;</div></td>
    <td width="5%"><input name="mercaderia" type="radio" checked = "checked"   />    </td>
    <? } ?>
    </tr>
</table>
<br>
<table width="640" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
	<tr bgcolor="#000000"> 
		<td width="12%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Cant.</font></strong></div></td>
		<td width="14%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">C&oacute;digo</font></strong></div></td>
		<td width="46%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Detalle</font></strong></div></td>
		<td width="14%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Precio</font></strong></div></td>
		<td width="14%"><div align="center"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Total $</font></strong></div></td>
    </tr>
<? 
$sql_blp = "SELECT movimiento.cantidad AS cnt, movimiento.cod_producto AS cprod, movimiento.precio_unitario AS pu, (movimiento.cantidad*movimiento.precio_unitario) AS total, productos.producto_seriado_param AS seriado, productos.descripcion AS des FROM movimiento, productos WHERE movimiento.cod_producto = productos.codigo AND movimiento.id_soe=$id_ent AND movimiento.entrada_salida_traspaso='E'";
$res_blp= mysql_query($sql_blp,$enlace);
$cant=1;
$cnt_blp = 0;
$txtst=0;
if ($mercaderia==0)  $txtst=$txttotal; 

	while (mysql_fetch_object($res_blp))
		{
		$cantidad=mysql_result($res_blp, $cnt_blp, "cnt");
		$codigo=mysql_result($res_blp, $cnt_blp, "cprod");
		$detalle=mysql_result($res_blp, $cnt_blp, "des");
		$precio=mysql_result($res_blp, $cnt_blp, "pu");
		$total=mysql_result($res_blp, $cnt_blp, "total");
		
		$txtst+=$total;
		
			
			
	?>
	<tr> 
		<td><div align="center"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
		<input name="cantidad[<?=$cant;?>]" id="cantidad[<?=$cant;?>]" type="text" style="width:100%" value="<?=$cantidad;?>">
		</font></strong></div></td>
			
		<td><div align="center"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
			<input name="codigo[<?=$cant;?>]" id="codigo[<?=$cant;?>]" type="text" style="width:100%" value="<?=$codigo;?>">
		</font></strong></div></td>
		
			
		<td><div align="center"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
			<input name="detalle[<?=$cant;?>]" id="detalle[<?=$cant;?>]" type="text" value="<?=$detalle;?>" readonly="1" border="0" style="border-width:0;font-size:14px;width:100%">
		</font></strong></div></td>
		
		  
		<td><div align="right"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
			<input name="precio[<?=$cant;?>]" id="precio[<?=$cant;?>]" type="text" value="<?=$precio;?>" style="border-width:0;text-align:right;width:100%">
		</font></strong></div></td>
		
		<td ><div align="right"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
			<input name="total[<?=$cant;?>]" id="total[<?=$cant;?>]" type="text" value="<?=$total;?>" style="border-width:0;text-align:right;width:100%">
			</font></strong></div></td>
    </tr>
	<? 
	$cant=$cant+1;
	$cnt_blp+= 1;
	}
	$txtdes=$txtst-$txttotal;
	?>

<? 
$sql_cargos = "SELECT Id, id_plan_cuenta, id_entrada, valor FROM cuentas_de_cargo WHERE id_entrada=$id_ent";
$res_cargos = mysql_query($sql_cargos,$enlace);	
	
$lstcargo0=0;
$lstcargo1=0;
$lstcargo2=0;


$cant=0;
$row=0;
	while (mysql_fetch_object($res_cargos))
		{
	
	if ($cant==0) {
		$lstcargo0=mysql_result($res_cargos, $row, "id_plan_cuenta");
		$txtcargo0=mysql_result($res_cargos, $row, "valor");
		}
	
	if ($cant==1) {
		$lstcargo1=mysql_result($res_cargos, $row, "id_plan_cuenta");
		$txtcargo1=mysql_result($res_cargos, $row, "valor");
		}
	if ($cant==2) {
		$lstcargo2=mysql_result($res_cargos, $row, "id_plan_cuenta");
		$txtcargo2=mysql_result($res_cargos, $row, "valor");
		}
	
	$cant=$cant+1;
	$row += 1;
	}

	?>

	
	
</table>
<table width="640" border="0" align="center" cellpadding="0" cellspacing="0">
	<table width="640" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td width="22%">&nbsp;</td>
	  <td width="15%">&nbsp;</td>
	  <td width="12%">&nbsp;</td>
	  <td width="20%"><div align="right">Sub Total</div></td>
    <td width="31%" align="right"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
	    <input name="txtst" id="txtst" type="text" value="<?=$txtst;?>" style="text-align:right;width:92%">
		</font></strong></td>
	</tr>
	<tr bordercolor="#000000"> 
	<td>&nbsp;</td>
	<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td><div align="right">Descuento</div></td>
		<td align="right"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
		  <input name="txtdes" id="txtdes" type="text" value="<?=$txtdes;?>" style="text-align:right;width:92%" onKeyPress="return vnum(event)" onBlur="fun_cint();">
		</font></strong></td>
    </tr>
    <tr bordercolor="#000000"> 
		<td> <div align="center"><strong>Cuenta de Cargo</strong></div></td>
	  <td><div align="center"><strong>Monto</strong></div></td>
		<td>&nbsp;</td>
		<td><div align="right">Exento</div></td>
		<td align="right"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
		  <input name="txtexento" id="txtexento" type="text" value="<?=$txtexento;?>" style="text-align:right;width:92%" onKeyPress="return vnum(event)" onBlur="fun_cint();">
		</font></strong></td>
    </tr>
		<tr bordercolor="#000000">
    
          <?
	if ($lstcargo0<>0) { ?>
     
		<td> 
      <select name="lstcargo0" style="width:200px">
      <option value="null" selected>SELECCIONE CARGO
        <?
$cons_cargo = mysql_query("SELECT * FROM plan_cuenta ORDER BY descripcion;", $enlace);   
 			$cont=0;
			while ( mysql_fetch_object ($cons_cargo) ) 
 			{
 				$ides=mysql_result($cons_cargo, $cont, "Id");
  				$nombres=mysql_result($cons_cargo, $cont, "descripcion");
  				if($lstcargo0==$ides){$sel="selected";}
				else {$sel="";}
				echo "              <option value=\"".$ides."\"$sel>".$nombres."\n";
				
  				$cont = $cont + 1;
 			}
			?>
        </option>
    </select>    </td>
     <td><input name="txtcargo0" id="txtcargo0" type="text" value="<?=$txtcargo0;?>" style="text-align:right;width:92%" ></td>
   <? }
    else { ?>	

		<td>&nbsp;</td>
		<td>&nbsp;</td>
        <? } ?>      
		<td>&nbsp;</td>
		<td><div align="right">Neto</div></td>
		<td align="right"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
		  <input name="txtneto" id="txtneto" type="text" value="<?=$txtneto;?>" style="text-align:right;width:92%" onKeyPress="return vnum(event)">
		</font></strong></td>
    </tr>
		<tr bordercolor="#000000">
          <?
	if ($lstcargo1<>0) { ?>
      
		<td> 
      <select name="lstcargo1" style="width:200px">
      <option value="null" selected>SELECCIONE CARGO
        <?
			$cons_cargo = mysql_query("SELECT * FROM plan_cuenta ORDER BY descripcion;", $enlace);   // 5=cuenta cargo familia
 			$cont=0;
			while ( mysql_fetch_object ($cons_cargo) ) 
 			{
 				$ides=mysql_result($cons_cargo, $cont, "Id");
  				$nombres=mysql_result($cons_cargo, $cont, "descripcion");
  				if($lstcargo1==$ides){$sel="selected";}
				else {$sel="";}
				echo "              <option value=\"".$ides."\"$sel>".$nombres."\n";
				
  				$cont = $cont + 1;
 			}
			?>
        </option>
    </select>    </td>
     <td><input name="txtcargo1" id="txtcargo1" type="text" value="<?=$txtcargo1;?>" style="text-align:right;width:92%" onKeyPress="return vnum(event)" onBlur="fun_cint();" /></td>
     <? }
    else { ?>	

		<td>&nbsp;</td>
		<td>&nbsp;</td>
        <? } ?>   
		<td>&nbsp;</td>
		<td><div align="right">IVA</div></td>
		<td align="right"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
		  <input name="txtiva" id="txtiva" type="text" value="<?=$txtiva;?>" style="text-align:right;width:92%" onKeyPress="return vnum(event)">
		</font></strong></td>
        
    </tr>
	<tr bordercolor="#000000">
     <?
	if ($lstcargo2<>0) { ?>
      
		<td> <select name="lstcargo2" style="width:200px">
      <option value="null" selected>SELECCIONE CARGO
        <?
			$cons_cargo = mysql_query("SELECT * FROM plan_cuenta ORDER BY descripcion;", $enlace);   // 5=cuenta cargo familia
 			$cont=0;
			while ( mysql_fetch_object ($cons_cargo) ) 
 			{
 				$ides=mysql_result($cons_cargo, $cont, "Id");
  				$nombres=mysql_result($cons_cargo, $cont, "descripcion");
  				if($lstcargo2==$ides){$sel="selected";}
				else {$sel="";}
				echo "              <option value=\"".$ides."\"$sel>".$nombres."\n";
				
  				$cont = $cont + 1;
 			}
			?>
        </option>
    </select>    </td>
    <td>
    <input name="txtcargo2" id="txtcargo2" type="text" value="<?=$txtcargo2;?>" style="text-align:right;width:92%" ></td>
    <? }
    else { ?>	

		<td>&nbsp;</td>
		<td>&nbsp;</td>
        <? } ?>   
		<td>&nbsp;</td>
		<td><div align="right">Total</div></td>
		<td align="right"><strong><font color="#333333" face="Arial, Helvetica, sans-serif">
		  <input name="txttotal" id="txttotal" type="text" value="<?=$txttotal;?>" style="text-align:right;width:92%" onKeyPress="return vnum(event)">
		</font></strong></td>
    </tr>

</table>
<table width="640" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td width="35%">&nbsp;</td>
		<td width="10%" align="center">	<input type="button" name="Submit1" value="Eliminar" onClick="fun_eliminar();" style="visibility:hidden"></td>
        <td width="10%" align="center">	</td>
        <td width="10%" align="center">	<input type="button" name="Submit1" value="Imprimir" onClick="fun_imprimir();" style="visibility:hidden"></td>
		<td width="10%" align="center">	<input type="button" name="Submit3" value="Salir" onClick="fun_salir();"></td>
		<td width="10%" align="center">	<input type="button" name="Submit2" value="Guardar" onClick="fun_guardar();" style="visibility:hidden"></td>
		<td width="35%">&nbsp;</td>
    </tr>
</table>
<input name="txtcom" type="text" id="txtcom" style="visibility:hidden" size="1" />
<input name="txtcnd" type="text" id="txtcnd" style="visibility:hidden" size="1" />
<input name="txtcs" type="text" id="txtcs" style="visibility:hidden" size="1" />
<input name="txtcs2" type="text" id="txtcs2" style="visibility:hidden" size="1" />
<input name="id_ent" type="text" id="id_ent" value="<?=$id_ent;?>"   style="visibility:hidden" size="1" />

</form>
</body>
</html>
<script language="Javascript">
function fun_imprimir()
	{
	var answer = confirm ("¿Seguro que desea imprimir?");
	if (answer)
		{
		document.getElementById('foto1').style.display = "none";
		document.getElementById('foto2').style.display = "none";
		document.getElementById('foto3').style.display = "none";
		document.getElementById('foto4').style.display = "none";
		document.getElementById('Submit').style.display = "none";
		document.getElementById('Submit1').style.display = "none";
		document.getElementById('Submit2').style.display = "none";
		document.getElementById('Submit3').style.display = "none";
		window.print();
		document.getElementById('foto1').style.display = "block";
		document.getElementById('foto2').style.display = "block";
		document.getElementById('foto3').style.display = "block";
		document.getElementById('foto4').style.display = "block";
		document.getElementById('Submit').style.display = "block";
		document.getElementById('Submit1').style.display = "block";
		document.getElementById('Submit2').style.display = "block";
		document.getElementById('Submit3').style.display = "block";
		}
	}
	
function fun_eliminar()
	{
	var answer = confirm ("¿Seguro que desea eliminar?");
	if (answer)
		{
		document.form1.action = "eliminar.php";
		document.form1.target = "_self";
		document.form1.submit();
		}
	}	
function fun_salir()
	{
	var answer = confirm ("¿Desea Salir?");
	if (answer)
		{
		window.top.open('','_parent','');window.top.close();
		}
	}

</script>