<?php
ini_set("session.cookie_lifetime",60*60*10);
ini_set("session.gc_maxlifetime", 60*60*10);
session_start();	
//++++++++++++
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
$FE_SUNAT_ZIP="";
$FE_SUNAT_RUC="";
//+++++++
$EMAIL_INTERNO="shengxiangling@outlook.com";
//+++++++
$USER_EMP=V($_SESSION['SYS_USER_EMP']);	
$USER_PDV=V($_SESSION['SYS_USER_PDV']);	
//-------------------------
$VEN_AUTO_SON="NO";
$VEN_AUTO_FEC="1900-01-01";
$VEN_AUTO_HOR="";
$VEN_AUTO_TIM=0;
$VEN_AUTO_ID_VL=0;
//-------------------------++
$ES_GIA_REFERENCIA=0;
//-------------------------++
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
//++++
if(vbval($_SESSION['SYS_USER_GI'])!=USU_GET_GI($_SESSION['SYS_USER_ID'])){
	JsDir("cerrar.php");	
	return;
}
//
$IdU=vbval($_SESSION['SYS_USER_ID']);
$PRO_ID_ALM=gn("pro_id_alm","usuarios","id_usuario=$IdU");
//++++++++++
$DOC_PRI="";
$DOC_DES="";
//++++++++++	
$StrGT="";
$VP_RegXPag=10;
$LStrMsg="";
$LStrFoc="";
$LStrMM="";
$LStrPag=V($_POST['TxtPag']);	
$StrHWND_V=V($_SESSION['SYS_HW']."_V");
$ERROR_MSG="";
//
include("ventas_fun.php");
include("ventas_b_fun.php");
//++++
if(strlen($StrId)>0 && $StrCmd=="AR_PLUS"){
	$Id=$StrId;
	//++++++++
	$UbiPai=gs("ven_ubi_pai","ventas","id_venta=$Id");
	$UbiDep=gs("ven_ubi_dep","ventas","id_venta=$Id");
	$UbiPro=gs("ven_ubi_pro","ventas","id_venta=$Id");
	$UbiDis=gs("ven_ubi_dis","ventas","id_venta=$Id");
	$StrDIR=gs("ven_cli_dir","ventas","id_venta=$Id");
	//+++++
	$StrEmp=gs("EMPC","vventas","ID=$Id");
	$StrAlm=gs("ALM","vventas","ID=$Id");
	$StrFec=gs("DATE_FORMAT(FEC,'%d-%m-%y')","vventas","ID=$Id");
	$StrCom=gs("COM","vventas","ID=$Id");
	$StrSer=gs("SER","vventas","ID=$Id");
	$StrNum=gs("NUM","vventas","ID=$Id");
	$StrMon=gs("MON","vventas","ID=$Id");
	if($StrMon=="S") $StrMon="SOLES";
	if($StrMon=="D") $StrMon="DOLARES";
	$StrIdCliente=gn("id_cliente","ventas","id_venta=$Id");
	$StrCliente=gs("CLI","vventas","ID=$Id");
	//++
	if(strlen($StrDIR)==0){
		$StrDIR=gs("cli_dir","clientes","id_cliente=$StrIdCliente");
	}
	$StrEma=gs("cli_email","clientes","id_cliente=$StrIdCliente");
	$SUN_TIP_DOC=gs("SUN_DOC_TIP","vclientes","ID=$StrIdCliente");
	$StrRuc=gs("RUC","vventas","ID=$Id");
	$StrDni=gs("DNI","vventas","ID=$Id");
	$StrFven=gs("fec_ven","ventas","id_venta=$Id");
	$StrTdp=gs("TDP","vventas","ID=$Id");		
	$StrTdp=gs("tipp_nombre","tipos_pagos","id_tip_pag='$StrTdp'");
	$StrTar=gs("TAR","vventas","ID=$Id");
	$StrBan=gs("BAN","vventas","ID=$Id");
	$StrAde=gn("ADE","vventas","ID=$Id");
	$StrPagarCon=gn("P_CON","vventas","ID=$Id");
	$StrVuelto=gn("VUE","vventas","ID=$Id");
	$StrN_INC=gs("INI","vventas","ID=$Id");
	$StrTempA=gs("VEN_COM_REF","vventas","ID=$Id");
	$Str_PRI=gn("ven_prin","ventas","id_venta=$Id");
	$Str_DES=gn("ven_desc","ventas","id_venta=$Id");
	$ID_TEMP=gn("VEN_ID_VEN","vventas","ID=$Id");
	$StrPD=gn("P_DES","vventas","ID=$Id");
	$StrMod=gs("MODAL","vventas","ID=$Id");
	$StrGIA=gs("ven_gia","ventas","id_venta=$Id");
	if(strlen($StrGIA)>0){
		$ES_GIA_REFERENCIA=1;
	}
	$VEN_AUTO_ID_VL=gn("ven_id_vl","ventas","id_venta=$Id");
	//
	$StrEmpR="";
	if($StrTempA=="PROFORMA"){
		$StrTempB=gs("CONCAT(ser,'-',num)","cotizaciones","id_cotizacion=$ID_TEMP");
		$StrEmpR=gs("EMPC","vcotizaciones","ID=$ID_TEMP");
	}
	if($StrTempA=="CONTENEDOR"){
		$StrTempB=gs("CONCAT(ser,'-',numero)","compras","id_compra=$ID_TEMP");
		$StrEmpR=gs("EMPC","vcompras","ID=$ID_TEMP");
	}
	//		
	ejt("DELETE FROM temp_compras WHERE cod_temc='$StrHWND_V'");
	$s="SELECT * FROM ventas_det WHERE id_venta=$Id ORDER BY cx";
	$cx=0;
	$result = grs($s);			
	while ($row = $result->fetch_row()){
		$cx++;
		$AR_ID=$row[2];
		$AR_CA=$row[3];
		$AR_PR=$row[4];
		$AR_IM=$row[5];
		$AR_CO=$row[7];
		$AR_DE=$row[8];
		$AR_CU=$row[9];
		$s="INSERT INTO temp_compras VALUES ('$StrHWND_V',
		   $AR_ID,$AR_CA,$AR_PR,$AR_IM,$cx,'$AR_CO','$AR_DE',$AR_CU)";
		ejt($s);			
	}
	//
	$DR_NOM=$StrTempA;
	if($DR_NOM=="PROFORMA"){			
		$DR_PRI=vbval(gs("cot_pri","cotizaciones","id_cotizacion=$ID_TEMP"));
		$DR_DES=vbval(gs("cot_des","cotizaciones","id_cotizacion=$ID_TEMP"));
	}
	$_ID=gn("count(*)","guias","anu='N' AND id_comr>0 AND id_ref=$Id");
	if($_ID>0){
		$DR=$_ID;
	}
	//
	ejt("DELETE FROM ventas_cuotas_t WHERE hw='$StrHWND_V'");
	$s="SELECT * FROM ventas_cuotas WHERE id_venta=$Id ORDER BY cx";
	$cx=0;
	$rs=grs($s);			
	while($r=$rs->fetch_assoc()){
		$cx=GenId("cx","ventas_cuotas_t");
		$cx_tot=$r['tot'];
		$cx_fec=$r['fec'];
		$s="INSERT INTO ventas_cuotas_t VALUES ($cx,'$StrHWND_V',$cx_tot,'$cx_fec')";
		ejt($s);
	}		
}
//++++
$POL_USU_EV=gs("ev","usuarios","id_usuario=$IdU");
$POL_USU_MV=gs("mv","usuarios","id_usuario=$IdU");
$POL_USU_AV=gs("av","usuarios","id_usuario=$IdU");

$BOL_NL=gn("nl","doc_nl","doc='B'");
$FAC_NL=gn("nl","doc_nl","doc='F'");
//
$FE_ID=0;
$FE_ND=0;
$VEN_ANU="N";
/*
$FE_ID=gn("id_fe","facturas_electronicas","fe_id_venta=".vbval($StrId));
$FE_ND=gn("fe_nd","facturas_electronicas","fe_id_venta=".vbval($StrId));
*/
if(gs("ven_fe_ge","ventas","(id_com=3 OR id_com=4) AND id_venta=".vbval($StrId))=="S"){
	$FE_ID=1;
	$FE_ND=0;
}
if(vbval($StrId)>0){
	$VEN_ANU=gs("anu","ventas","id_venta=".$StrId);
}
//++++++
$TI=0;
//++++++
?>
<!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=utf-8">

<title>Ventas</title>
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<script type="text/javascript" src="fe/ventas_fe_guias_jun24.js"></script>
<script language="javascript">
var myVar=window.setInterval(function(){myTimer()},500);
function myTimer(){
	var DR=gv("DR_NOM");
	if(jLen(DR)==0){	
		t=GetHora();
		tt=document.getElementById("TxtHora").value;	
		if(tt>0){
			if(t-tt>=1){
				document.getElementById("TxtHora").value=0;
				fGetTabla();			
			}
		}
	}
}
function myStopFunction(){
	clearInterval(myVar);
}

</script>
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="jquery.maskedinput.min.js" type="text/javascript"></script>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script type="text/javascript" src="fe/leo.js"></script>
<script>
$(document).ready(function(){
   $("#TxtFec").mask("99-99-99");
   $("#TxtFven").mask("99-99-99"); 
   $("#CuoFec").mask("99-99-99"); 
   CalcularVuelto();  
   var fe_id=gv("TXT_FE_ID");
   if(jVal(fe_id)>0){
	   document.getElementById("CmdFE").disabled=true;
   }
});
//
function Verificar(){
	var DATA="";
	document.getElementById("TxtDAT").value="";
	frm = document.getElementById("Frm");
	if (!frm) return;
	for(i=0; i<frm.elements.length; i++)
	{
		if (frm.elements[i].type == "checkbox")	{
			if(frm.elements[i].name.substring(0,1)=="Z"){
				if(frm.elements[i].checked==true){
					var ok=frm.elements[i].name;
					ok=ok.substring(2,7);
					DATA=DATA+ok+",";
				}
			}
		}
	}	
	if(jLen(DATA)==0){
		alert("Ningun registro seleccionado, seleccione un registro marcando el check correspondiente");
		return 0;
	}else{		
		document.getElementById("TxtDAT").value=DATA;
		return 1;
	}
}
function ChK(){
	if(jVal(gv("ES_GIA_REFERENCIA"))==1){
		alert("Funcion no valida para guias de remision y proformas de referencia");
	}else{
		if(Verificar()==1){		
			document.getElementById("TxtAc").value="KCH";
			document.getElementById("Frm").submit();	
		}
	}
}
//
</script>
<style type="text/css">
<!--
.estilo888 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #003366;
font-weight: bold;
}
#TAB_CAPTION .estilo888 {
color: #000;
}
-->
</style>
<style type="text/css">
<!--
.estilo777 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #003366;
}
-->
</style>
<style type="text/css">
<!--
body {
background-color: #CCC;
background-image: url();
}
#Layer1 {
position:absolute;
left:345px;
top:115px;
width:123px;
height:35px;
z-index:1;
}
.centrarFrm{
	width:1040px;
	height:1100px;
	position:relative;
	top:0px;
	background-color:#006699;
}
#Layer2 {
position:absolute;
left:409px;
top:205px;
width:82px;
height:24px;
z-index:1;
}
.Estilo1 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FFFFFF;
}
.s2 { text-align:left; font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FFFFFF; font-size: 12px; }
.Estilo3 {color: #FFFFFF; font-size: 12px; font-family: Arial, Helvetica, sans-serif;}
.s4 {color: #000099}
.w5 {color: #000000}
#Frm center #DivFRM #layer .Estilo1 strong {
color: #900;
}
#Frm center #DivFRM #layer3 .s2 table tr td {
color: #000;
}
#Frm center #DivFRM #layer3 .s2 table tr td table tr td {
color: #FFF;
}
.sFA {	font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FF3;
font-size: 12px;
}

-->
</style>

</head>
<body  <?php echo $LStrMsg;?> onunload="myStopFunction();">
<center> 

<?php
$DIV_CSS="";
if(strlen($ERROR_MSG)>0){
	$DIV_CSS=' style="background-color:#F90" ';
}
?>
<div Id="DivFRM"  class="centrarFrm" <?php echo $DIV_CSS;?> >

<form id="Frm" name="Frm" method="post" action="ventas.php" autocomplete="off" >

<input name="FE_SUNAT_ZIP" type="hidden" id="FE_SUNAT_ZIP" value="<?php echo $FE_SUNAT_ZIP;?>" />
<input name="FE_SUNAT_RUC" type="hidden" id="FE_SUNAT_RUC" value="<?php echo $FE_SUNAT_RUC;?>" />

<input name="TXT_FE_USU_ID" type="hidden" id="TXT_FE_USU_ID" value="<?php echo $IdU;?>" />
<input name="TXT_FE_ID" type="hidden" id="TXT_FE_ID" value="<?php echo $FE_ID;?>" />
<input name="VEN_ANU" type="hidden" id="VEN_ANU" value="<?php echo $VEN_ANU;?>" />
<input name="TXT_FE_ND" type="hidden" id="TXT_FE_ND" value="<?php echo $FE_ND;?>" />


<input type="hidden" id="VEN_AUTO_ID_VL" value="<?php echo $VEN_AUTO_ID_VL;?>" name="VEN_AUTO_ID_VL"  />

<input type="hidden" id="TxtDR" value="<?php echo $DR;?>" name="TxtDR"  />
<input type="hidden" id="DR_NOM" value="<?php echo $DR_NOM;?>" name="DR_NOM"  />
<input type="hidden" id="DR_PRI" value="<?php echo $DR_PRI;?>" name="DR_PRI"  />
<input type="hidden" id="DR_DES" value="<?php echo $DR_DES;?>" name="DR_DES"  />


<div class="s1" style="position:absolute; left: 16px; top: 85px; width:1050px; height: 26px;">

<input name="CmdB" type="button" id="CmdG"
<?php
if(strlen($StrId)==0){
	echo "value=\"Guardar\"";
}else{
	echo " value=\"Modificar\" ";
	$_YA="";
	$StrAnu=gs("anu","ventas","id_venta=$StrId");
	if($StrAnu=="S"){
		echo " disabled=\"disabled\"";
		$_YA="S";
	}
	if($POL_USU_AV=="0" && strlen($_YA)==0){
		echo " disabled=\"disabled\"";
	}
}
?>
onclick="fGuardar();" style="width:80px" tabindex="35"/>
<input name="CmdB" type="button" id="CmdC" value="Nuevo" 
onclick="fCancelarPHP();"  tabindex="36"/>

<input name="CmdB" type="button" id="CmdFE" 
value="Generar Doc. Electronico" 
onclick="GenFacEle()"
<?php
	if(strlen($StrId)==0){
		echo "disabled=\"disabled\"";
	}else{
		$StrAnu=gs("anu","ventas","id_venta=$StrId");
		if($StrAnu=="S"){
			echo " disabled=\"disabled\" ";
		}
	}
?>
tabindex="37"/>

<input name="CmdB" type="button" id="CmdA" 
value="Imprimir" 
onclick="GEN_PDF_ELE();"
<?php
if(strlen($StrId)==0){
	echo "disabled=\"disabled\"";
}else{
	$StrAnu=gs("anu","ventas","id_venta=$StrId");
	if($StrAnu=="S"){
		echo "disabled=\"disabled\"";
	}
}
?>
tabindex="37"/>

<input name="CmdB" type="button" id="CmdA" 
value="Anular" onclick="flAnularEx();"
<?php
if(strlen($StrId)==0){
	echo " disabled=\"disabled\"";
}else{
	$_YA="";
	$StrAnu=gs("anu","ventas","id_venta=$StrId");
	if($StrAnu=="S"){
		echo " disabled=\"disabled\"";
		$_YA="S";
	}
	if($POL_USU_AV=="0" && strlen($_YA)==0){
		echo " disabled=\"disabled\"";
	}

}
?>
tabindex="38"/>

<input name="CmdB" type="button" id="CmdE" value="Eliminar" 
onclick="fEliVenta();"
<?php
if(strlen($StrId)==0){
	echo " disabled=\"disabled\"";
}else{
	$_YA="";
	$StrAnu=gs("anu","ventas","id_venta=$StrId");
	if($StrAnu=="S"){
		echo " disabled=\"disabled\"";
		$_YA="S";
	}
	if($POL_USU_EV=="0" && strlen($_YA)==0){
		echo " disabled=\"disabled\"";
	}
}
?>
tabindex="39"/>
<input name="CmdB" type="button" id="CmdB" 
value="Buscar" onclick="fBuscar('ventas_buscar.php');"  tabindex="40"/>
<input name="CmdB" type="button" id="CmdB" style="background-color:#FF9"
value="Buscar X" onclick="fBuscar('ventas_buscar_express.php');"  tabindex="40"/>
<input name="CmdB" type="button" id="CmdB" 
value="Buscar detallado" onclick="fBuscar('ventas_det.php');"  tabindex="41"/>
<input name="CmdPDF" type="button" id="CmdPDF" 
value="Gen. PDF" onclick="fGenPDF();" tabindex="19"
<?php
	if(strlen($StrId)==0){
		echo " disabled=\"disabled\" ";
	}else{
		$StrAnu=gs("anu","ventas","id_venta=$StrId");
		if($StrAnu=="S"){
			echo "disabled=\"disabled\"";
		}
	}
?>
/>
<input name="CmdB" type="button" id="CmdZ" 
value="Menu" onclick="fBuscar('menu.php');"  tabindex="42"/>

<input name="CmdB" type="button" id="CmdDex" value="Deshacer" 
onclick="fDeshacer();"  />
<input name="CmdFree" type="button" id="CmdFree" value="Liberar" 
onclick="fLiberar();"  />
</div>


<div class="s1" style="position:absolute; left: 17px; top: 380px; width: 1011px; height: 697px; overflow:auto">
<table width="1000" height="198" border="1" cellpadding="0" cellspacing="0">

<tr class="w5">
<td width="23" bgcolor="#999999">Nro</td>
<td width="112" bgcolor="#999999">CODIGO</td>
<td width="492" bgcolor="#999999">DESCRIPCION</td>
<td width="100" bgcolor="#999999">LINEA</span></td>
<td width="42" bgcolor="#999999" align="right">CANT</td>
<td width="50" bgcolor="#999999" align="right">PIEZAS</td>
<td width="63" bgcolor="#999999" align="right">PRECIO</td>
<td width="65" bgcolor="#999999" align="right">IMPORTE</td>
<td width="20" bgcolor="#999999" align="center">&nbsp;</td>
<td width="16" bgcolor="#999999" align="center">&nbsp;</td>
<td width="20" bgcolor="#999999" align="center">
<a href="javascript:void(0)" onclick="ChK();" >
<img src="img/eliminar.png" width="16" height="16" >
</a>
</td>
</tr>

<?php
$TOT_CA=0;
$TOT_NL=0;
$s="SELECT * FROM temp_compras WHERE cod_temc='$StrHWND_V' ORDER BY temc_index";
$result = grs($s);
$SEPARADOR=gs("aux_des","auxiliares","aux_tip='SIM'");
if(strlen($SEPARADOR)==0){$SEPARADOR="x";}
//
$X_IMPORTE=0;
$X_ST=0;
$X_IG=0;
$X_TO=0;
$_IT=0;
while ($row = $result->fetch_row()){
	$TOT_NL++;
	$X_ID=$row[1];
	$X_CO=gs("COD","vproductos","ID=$X_ID");
	if(strlen($X_CO)==0)$X_CO=$row[6];
	$X_DE=gs("DESCRIPCION","vproductos","ID=$X_ID");
	if(strlen($X_DE)==0)$X_DE=$row[7];
	$X_MA=VV(gs("LINEA","vproductos","ID=$X_ID"));
	$X_CA=$row[2];	
	$X_PR=$row[3];	
	$X_IM=$row[4];	
	$X_CAU=$row[8];
	$X_IMPORTE=$X_IMPORTE+$X_IM;
	$X_IM=number_format($X_IM,3,'.','');
	$CH="ZH".vbr("00000".$row[5],5);
	$TOT_CA=$TOT_CA+$X_CA;
	$_IT++;
	if($X_PR<=0){
		$BC="#CCCC66";
	}else{
		$BC="#FFFFFF";
	}
?>
	<tr class="w5" >
    <td bgcolor="<?php echo $BC;?>"><?php echo $_IT;?></td>
	<td bgcolor="<?php echo $BC;?>"><?php echo VV($X_CO).$SEPARADOR.VV($X_CAU);?></td>
	<td bgcolor="<?php echo $BC;?>"><?php echo VV($X_DE);?></td>
	<td bgcolor="<?php echo $BC;?>"><?php echo VV($X_MA);?></td>
	<td bgcolor="<?php echo $BC;?>" align="right"><?php echo VV($X_CA);?></td>
	<td bgcolor="<?php echo $BC;?>" align="right"><?php echo VV($X_CAU);?></td>
	<td bgcolor="<?php echo $BC;?>" align="right"><?php echo VV($X_PR);?></td>
	<td bgcolor="<?php echo $BC;?>" align="right"><?php echo VV($X_IM);?></td>
	<td bgcolor="<?php echo $BC;?>" align="center">
	<a href="javascript:void(0)" onclick="fKiller('<?php echo $row[5];?>');" >
	<img src="img/eliminar.png" width="16" height="16" >
	</a>
	</td>
	<td width="16" bgcolor="#FFFFFF" align="center">
	<a href="javascript:void(0)" onclick="fEditar('<?php echo $row[5];?>');" >
	<img src="img/b_edit.png"  border="0">
	</a>
	</td>
    <td width="20" bgcolor="#FFFFFF" align="center">
	<input name="<?php echo $CH;?>" id="<?php echo $CH;?>" type="checkbox" value="" />
	</td>
	</tr>
<?php
}	
if($StrN_INC=="1"){
	$X_ST=$X_IMPORTE;
	$X_IG=round($X_ST * 0.18,2);
	$X_TO=$X_ST + $X_IG;		
}else{
	$X_UNO=$X_IMPORTE / 118;
	$X_IG=round($X_UNO * 18,2);
	$X_ST=$X_IMPORTE - $X_IG;
	$X_TO=$X_ST + $X_IG;	
}

?>
<tr class="w5">
<td colspan="7"  bgcolor="#CCCCCC">
<table width="100%" border="0">
  <tr>
    <td width="75%" align="right"><?php echo "TOT. CAJAS:".$TOT_CA ;?></td>
    <td width="9%">&nbsp;</td>
    <td width="16%" align="right">TOT. IMPORTE</td>
  </tr>
</table>

<td bgcolor="#CCCCCC"
align="right"
>
<input type="text" name="T_Importe" 
id="T_Importe"  
value="<?php echo number_format($X_IMPORTE,2,'.','');?>"
style="width:65px; border:none; text-align:right;position:inherit"
readonly="readonly"
/>
</td>

<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">

</td>
</tr>

<tr>
<td colspan="11" bgcolor="#006699">&nbsp;</td>
</tr>

<tr class="w5">
<td colspan="7" align="right" bgcolor="#CCCCCC"><?php 
$a=GetIGV();
echo "(".$a."%)";
?>  SUB. TOTAL</td>
<td align="center" bgcolor="#CCCCCC"><input type="text" name="T_ST" 
id="T_ST"  
value="<?php echo number_format($X_ST,2,'.','');?>"
style="width:65px; border:none; text-align:right;position:inherit"
readonly="readonly"
/></td>

<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
</tr>
<tr class="w5">
<td colspan="7" align="right" bgcolor="#CCCCCC">IGV </td>
<td align="center" bgcolor="#CCCCCC"><input type="text" name="T_IG" 
id="T_IG"  
value="<?php echo number_format($X_IG,2,'.','');?>"
style="width:65px; border:none; text-align:right;position:inherit"
readonly="readonly"
/></td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
</tr>
<tr class="w5">
<td colspan="7" align="right" bgcolor="#CCCCCC"><input name="T_TOH" type="hidden" value="<?php echo $X_TO;?>"  id="T_TOH"/>
TOTAL</td>
<td align="center" bgcolor="#CCCCCC"><input type="text" name="T_TO" 
id="T_TO"  
value="<?php echo number_format($X_TO,2,'.','');?>"
style="width:65px; border:none; text-align:right;position:inherit"
readonly="readonly"
/></td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
</tr>
<tr>
<td colspan="10" bgcolor="#006699"></td>
</tr>
<tr>
<td colspan="11" bgcolor="#006699">
<table width="1000" border="0">
<tr>
<td width="110" height="17" >TIPO DE PAGO</td>
<td width="80">A CUENTA</td>
<td width="110">MONEDA</td>
<td width="110">MODALIDAD</td>
<td width="80">VUELTO (S/.)</td>
<td width="80">SALDO (S/.)</td>
<td width="273">&nbsp;</td>   
<td width="119">FEC. VCTO</td> 

</tr>
<tr>
<td height="24">
<select name="CboTdp" id="CboTdp" 
style="width:110px;position:inherit" 
onkeydown="return SoloTextoEx(event,'TxtACuenta');" 
tabindex="29" 
onchange="CalcularVuelto();"
>
<?php
echo FCBO_("tipp_nombre","tipos_pagos",
	       "tipp_nombre IN ('CONTADO','CREDITO')",$StrTdp,"N","N");
?>
</select>
</td>
<td>
<input type="text" name="TxtACuenta" 
id="TxtACuenta"   tabindex="30"
style="width:80px; text-align:right;position:inherit"
onkeydown="return SoloNum(this,event,'CboMon');"
onfocus="selecciona_value(this);"
onkeyup="CalcularVuelto();"
value="<?php echo $StrAcu;?>" 
/>
</td>
<td>
<select name="CboMon" id="CboMon" 
style="width:110px;position:inherit" 
onkeydown="return SoloTextoEx(event,'CboMod');"  
tabindex="31" onchange="CalcularVuelto();">
<?php
echo FCBOOD_("mon_nombre","monedas","",$StrMon,"N","S","mon_nombre");
?>
</select>
</td>
<td>
<select name="CboMod" id="CboMod" 
style="width:110px;position:inherit" 
onkeydown="return SoloTextoEx(event,'CmdG');"  
tabindex="32" onchange="CalcularVuelto();">
<?php
echo FCBOO_("au_item","auxiliar","au_tab='MODA'",$StrMod,"N","N","au_orden");
?>
</select>
</td>
<td><input type="text" name="TxtVuelto" 
id="TxtVuelto"  style="width:80px; text-align:right;position:inherit"
onkeydown="return SoloNum(this,event,'CboMon');"
onfocus="selecciona_value(this);" tabindex="33"
onkeyup="VUELTO();"
readonly="readonly"
value="<?php echo $StrVue;?>" 
/></td>
<td><input type="text" name="TxtSal" 
id="TxtSal"  style="width:80px; text-align:right;position:inherit"
readonly="readonly" tabindex="34"
value="<?php echo $StrSal;?>" 
/></td>
<td>&nbsp;</td>
<td width="119">
<input name="TxtFven" type="text" id="TxtFven"  readonly="readonly" style=" position:inherit; left: 318px; top: 158px; width: 100%; background-color:#CCC " 
value="<?php echo $StrFven;?>"  
onkeydown="return SoloFec(this,event,'CmdG');" 
/>
</td>   
</tr>
</table></td>
</tr>
<tr  height="30px">
<td colspan="11" bgcolor="#CCCCCC">&nbsp;</td>
</tr>
<tr  height="30px">
  <td colspan="11" bgcolor="#CCCCCC">
    <table width="100%" border="0" style="color:#000">
    <tr>
    <td width="43%"><b>CUOTAS</b> (Solo valido para facturas electronicas)</td>
    <td width="57%">&nbsp;</td>
    </tr>
    <tr>
    <td>
            <table width="100%" border="0">
            <tr>
              <td width="10%">&nbsp;</td>
            <td width="29%">MONTO CUOTA</td>
            <td width="29%">&nbsp;</td>
            <td width="29%">FECHA.VCTO</td>
            <td width="2%">&nbsp;</td>
            <td width="30%">&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            <td>
            <input type="text" name="CuoTot" id="CuoTot" 
            onkeydown="return SoloNum(this,event,'CuoFec');" 
            style="position:inherit; width:120px" />
            </td>
            <td>&nbsp;</td>
            <td>
            <input type="text" name="CuoFec" id="CuoFec" 
            style="position:inherit; width:120px" />
            </td>
            <td>&nbsp;</td>
            <td>
            <input type="button" name="CmdCuo" 
            id="CmdCuo" value="Agregar"  onclick="fCuoAdd()" style="width:100px" />
            </td>
            </tr>
            <script>
			function fCuoAdd(){		
				var ven=gv("T_TO");
				var sum=gv("CuoSUM");
				var tot=gv("CuoTot");
				var fec=gv("CuoFec");
				//
				var tdp=gv("CboTdp");
				var anu=gv("VEN_ANU");
				var ven_gen=gv("TXT_FE_ID");
				if(tdp!="CREDITO"){
					return AF("El tipo de pago debe ser credito","CuoTot");
				}
				if(anu=="S"){
					return AF("La venta ha sido anulada, no se puede proceder","CuoTot");
				}
				if(jVal(ven_gen)>0){
					return AF("La venta ha sido generada, no se puede proceder","CuoTot");
				}
				//
				if(jVal(tot)<=0){
					return AF("Ingrese el monto de la cuota","CuoTot");
				}
				var acu=jVal(sum)+jVal(tot);
				if(acu>jVal(ven)){
					return AF("La suma del total de cuotas no puede ser mayor al total de venta","CuoTot");
				}
				if(jL(fec)==0){
					return AF("Ingrese la fecha de vencimiento de cuota","CuoFec");
				}
				if(!EsFecha(fec)){
					return AF("Fecha no valida, ingrese segun el formato dd-mm-yy","CuoFec");
				}
				document.getElementById("CmdCuo").disabled=true;
				SM("CUO_ADD");
			}
			function fCuoKil(cx){
				//
				var anu=gv("VEN_ANU");
				var ven_gen=gv("TXT_FE_ID");
				if(anu=="S"){
					return AF("La venta ha sido anulada, no se puede proceder","CuoTot");
				}
				if(jVal(ven_gen)>0){
					return AF("La venta ha sido generada, no se puede proceder","CuoTot");
				}
				//
				sv("CuoKOD",cx);
				SM("CUO_KIL");
			}
			</script>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td><b>#</b></td>
              <td><b>MONTO CUOTA</b></td>
              <td>&nbsp;</td>
              <td><b>FECHA.VCTO</b></td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <?php
			$CX=0;
			$CuoSUM=0;
			$s="SELECT * FROM vis_ventas_cuotas_t WHERE HW='$StrHWND_V' ORDER BY CX";			
			$rs = grs($s);
			while($r=$rs->fetch_assoc()){
				$CX++;
				$CuoSUM=$CuoSUM + $r['TOT'];
			?>
                <tr>
                <td><?php echo $CX;?></td>
                <td align="right"><?php echo NF2($r['TOT'],2);?></td>
                <td >&nbsp;</td>
                <td ><?php echo $r['FEC_'];?></td>
                <td>&nbsp;</td>
                <td>
                <input type="button" name="CmdCuo" tabindex="-1"
                onclick="fCuoKil('<?php echo $r['CX'];?>')"
                id="CmdCuo" value="Quitar" style="width:100px" /></td>
                </tr>
            <?php
			}
			?>
            <tr>           
            <td align="right"><b>TOTAL</b></td>
            <td  align="right"><b><?php echo NF2($CuoSUM,2);?></b></td>
            <td>&nbsp;</td>            
            <td>&nbsp;</td>
             <td>&nbsp;</td>
            <td>
            <input name="CuoSUM" id="CuoSUM" type="hidden" value="<?php echo $CuoSUM;?>" />
            <input name="CuoKOD" id="CuoKOD" type="hidden" value="" />
            <input name="CuoCX" id="CuoCX" type="hidden" value="<?php echo $CX;?>" />
            </table>
    </td>
    <td>&nbsp;</td>
    </tr>
    </table>
  </td>
</tr>

</table>
</div>

<div id="layer" style="position:absolute; left: 116px; top: 21px; width: 386px; height: 33px; z-index: 100;">
<div align="left" class="Estilo1" style="color:#003">
<strong>VENTAS</strong>
</div>
</div>
<input type="button" name="CmdUP" id="CmdUP" value="UP" 
onclick="fLoad();" 
style="position:absolute; left: 83px; top: -282px; width: 49px; visibility:hidden"
/>

<input name="TxtHW" type="hidden" id="TxtHW" value="<?php echo $StrHWND_V;?>"/>
<input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
<?php
$CLAVE=gs("valor","valores","dato='CLAVE_PRECIO'");
?>
<input name="TxtPAS" type="hidden" id="TxtPAS" value="<?php echo $CLAVE;?>"/>
<input name="TxtAc" type="hidden" id="TxtAc" value="" />

<input name="TxtBOL_NL" type="hidden" id="TxtBOL_NL" value="<?php echo $BOL_NL;?>" />
<input name="TxtFAC_NL" type="hidden" id="TxtFAC_NL" value="<?php echo $FAC_NL;?>" />
<input name="TxtTOT_NL" type="hidden" id="TxtTOT_NL" value="<?php echo $TOT_NL;?>" />

<input name="TxtDAT" type="hidden" id="TxtDAT" value="" />
<input name="TxtHora" type="hidden" id="TxtHora" value="0" />
<input name="TxtPag" type="hidden" id="TxtPag" value="<?php echo $LStrPag; ?>" />
<input name="TxtRuc_" type="hidden" id="TxtRuc_"  />        
<input name="TxtIdCliente" type="hidden" id="TxtIdCliente" 
value="<?php echo $StrIdCliente; ?>"   />  
<input name="FEC_SERVER" type="hidden" id="FEC_SERVER" value="<?php echo date("d-m-y");?>"/>  		     

<div id="DivDatosProd">
<input name="Pro_TxtId" type="hidden" id="Pro_TxtId" value="<?php echo $StrPro_ID;?>"/>
<input name="Pro_TxtDes" type="hidden" id="Pro_TxtDes" value="<?php echo $StrPro_Des;?>"/>
<input name="Pro_TxtPre" type="hidden" id="Pro_TxtPre" value="<?php echo $StrPro_Pre;?>"/>
<input name="Pro_TxtPreM" type="hidden" id="Pro_TxtPreM" value="<?php echo $StrPro_PreM;?>"/>
<input name="Pro_TxtCod" type="hidden" id="Pro_TxtCod" value="<?php echo $StrPro_Cod;?>"/>
<input name="Pro_TxtCod" type="hidden" id="Pro_TxtMarca" value="<?php echo $StrPro_Mar;?>"/>
</div>

<div id="LblTit" style="position:absolute; left: 52px; top: 15px; width: 64px; z-index: 100;">
<div align="left" class="Estilo1">
<img src="img/ventas.png" width="64" height="53" / onclick="fGetProdDatos_Id('2');"></div>
</div>
<div 
style="position:absolute; left: 0px; top: 0px; width: 1040px; height: 79px; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000; z-index: 0;">
<div style="position:absolute; left:119px; top:58px; width: 918px; text-align:left; font-family:Verdana, Geneva, sans-serif; font-size:11px">
<b><span style=" color:#F00">Importante :</span></b> Desde el 06-10-21 al anular un comprobante electronico, se anulara directamente del registro de comprobantes emitidos
</div>
</div>

<div class="s1" style="left:16px; top: 139px; width: 141px;">
EMPRESA
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:16px; top:158px; width: 127px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 	
	echo LE($StrEmp,"N","N");	
?>
</select>


<div class="s1" style="left: 157px; top: 139px; width: 141px;">
PUNTO DE EMISION
</div>
<select name="CboAlm" id="CboAlm" 
style="left: 153px; top: 158px; width: 157px;" 
onkeydown="return SoloTextoEx(event,'TxtFec');" tabindex="2">
<?php 
	echo LA($StrEmp,$StrAlm,"N","N"); 	
?>
</select>

<div class="s1" style="left: 318px; top: 125px; width: 69px;">
FECHA
</div>
<input name="TxtFec" type="text" id="TxtFec" 
style="left: 318px; top: 158px; width: 75px;" 
value="<?php echo $StrFec;?>"  
onkeydown="return SoloFec(this,event,'CboCom');" 
tabindex="3" />

<div class="s1" style="left: 410px; top: 139px; width: 109px;">
COMPROBANTE
</div>
<select name="CboCom" id="CboCom" 
style="left: 408px; top:158px; width: 117px;" 
onkeydown="return SoloTextoEx2(event,'TxtSer','CmdSel');" tabindex="4">
<?php
echo FCBO_("com_nombre","comprobantes",
		  "id_comprobante>0 AND com_nombre IN ('FACTURA','BOLETA','FACT. ELEC.','BOL. ELEC.')",$StrCom,"N","N");
?>
</select>

<div class="s1" style="position:absolute; left: 527px; top: 117px; width: 147px;">
<input name="ChN_AUTO" type="checkbox" 
id="ChN_AUTO" tabindex="5"   onclick="AutoNumeracion(document.getElementById('ChN_AUTO').checked);" value="1"
<?php
if($StrN_AUTO=="1"){
echo "checked=\"checked\"";
}
?>
/>
NUM. AUTOMATICA</div>

<div class="s1" style="left: 532px; top: 139px; width: 47px;">
SERIE</div>
<input name="TxtSer" type="text" id="TxtSer" 
style="left: 532px; top: 158px; width: 55px;" 
tabindex="6"  onblur="_S(this);"
onkeydown="return SoloEnterosEx(this,event,'TxtNum');" 
value="<?php echo $StrSer;?>" maxlength="4" />

<div class="s1" style="left: 599px; top: 140px; width: 74px;">
NUMERO</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="left: 600px; top:158px; width: 68px;" 
tabindex="7"   onblur="_N(this);"
onkeydown="return SoloEnterosEx(this,event,'CmdSel');" 
value="<?php echo $StrNum;?>" maxlength="6" />

<div class="s1" style="left: 681px; top: 125px; width: 66px;">
TIPO DE CAMBIO</div>
<input name="TxtTC" type="text" id="TxtTC" 
style="left: 681px; top:158px; width: 62px; background-color:#CCC; text-align:right" 
value="<?php echo $StrTC;?>"  
onkeydown="return SoloEnterosEx(this,event,'TxtCliente');" 
tabindex="8" readonly="readonly" />

<div align="left" class="s1" style="position:absolute; left: 755px; top:134px; width: 249px; height: 25px;">
<input name="Ch_DES" type="checkbox" 
id="Ch_DES"  onchange="fChDesc();"
value="1"
<?php
if($Str_DES==1){
echo "checked=\"checked\"";
}
?>
/> 
DESCONTAR STOCK EN (<i>OPCIONAL</i>) :</div>
<select name="CboZto" id="CboZto" 
style="position:absolute; left: 758px; top:158px; width: 257px;" 
onkeydown="return SoloTextoEx(event,'CboAlm');" >
<?php echo FCBOO_("CONCAT(EMP_NC,' - ',ALM_NC)",
				  "z_vis_emp_alm","",$StrZto,"N","S","CONCAT(EMP_NC,' - ',ALM_NC)");  ?>
</select>

<div class="s1" style="left: 16px; top: 190px; width: 93px;">
CLIENTE</div>
<input type="text" name="TxtCliente" id="TxtCliente" 
value="<?php echo $StrCliente;?>" 
style="left: 16px; top: 208px; width: 287px; background-color:#CCC" 
readonly="readonly"  tabindex="9"
onkeydown="return SoloTextoEx(event,'TxtRuc');" 
/>

<div class="s1" style="left: 318px; top: 190px; width: 67px;">
RUC</div>
<input name="TxtRuc" type="text" id="TxtRuc" 
style="left: 318px; top: 208px; width: 100px; background-color:#CCC" 
value="<?php echo $StrRuc;?>"  
onkeydown="return SoloEnterosEx(this,event,'CmdSel');"
tabindex="10" readonly="readonly" />

<div class="s1" style="left: 429px; top: 190px; width: 101px;"> Nro DOC IDENTI..
</div>
<input name="TxtDni" type="text" id="TxtDni" 
style="left: 427px; top: 208px; width: 94px; background-color:#CCC" 
value="<?php echo $StrDni;?>"  
onkeydown="return SoloEnterosEx(this,event,'CmdSel');"
tabindex="10" readonly="readonly" />
<input name="SUN_TIP_DOC" id="SUN_TIP_DOC" 
type="hidden" value="<?php echo $SUN_TIP_DOC;?>" />


<div class="s1" style="position:absolute; left: 532px; top: 208px; width: 64px; height: 25px;">
<input type="button" name="CmdSel" id="CmdSel" value="..." 
onClick="Ow('ventas_clientes_buscar.php?W=V',800*ZO(),600*ZO())" 
style="width:30px" tabindex="11"
/>


<input type="button" name="CmdCls" id="CmdCls"  style="width:30px"
value="X" onclick="fCls();" tabindex="12"
/>
</div>

<div class="s1" style="left: 600px; top: 190px; width: 81px;">
DIRECCION</div>
<input name="TxtDIR" type="text" id="TxtDIR" 
style="left: 600px; top: 208px; width: 415px" 
value="<?php echo $StrDIR;?>"  
onkeydown="return SoloTextoEx(event,'TxtEma');"
tabindex="13" />
<script>
function ClsUbi(){
	sv("UbiDep","");
	sv("UbiPro","");
	sv("UbiDis","");
}
</script>

<?php if(strlen($UbiPai)==0)$UbiPai="PERU";?>
<div class="s1" style="left:16px; top: 232px; width: 36px;">PAIS</div>
<select name="UbiPai" id="UbiPai" 
style="position:absolute; left:16px; top:251px; width: 140px;" 
onkeydown="return SoloTextoEx(event,'CmdG');" onchange="ClsUbi();" tabindex="11">
<?php
echo FCBO("pai_nom","lista_paises","id_pais>0",$UbiPai,"N","S");
?>
</select>

<div class="s1" style="left:166px; top: 234px; width: 45px;">DEPARTAMENTO</div>
<input name="UbiDep" type="text" id="UbiDep" 
class="ps" style="position:absolute; left:164px; top: 250px; width: 139px; background-color:#CCC" 
value="<?php echo $UbiDep;?>"   readonly="readonly"/>

<div class="s1" style="left:318px; top: 234px; width: 68px;">PROVINCIA</div>
<input name="UbiPro" type="text" id="UbiPro" 
class="ps" style="position:absolute; left:318px; top: 250px; width: 100px; background-color:#CCC" 
value="<?php echo $UbiPro;?>"   readonly="readonly"/>

<div class="s1" style="left:429px; top: 234px; width: 61px;">DISTRITO</div>
<input name="UbiDis" type="text" id="UbiDis" 
class="ps" style="position:absolute; left:429px; top: 250px; width: 92px; background-color:#CCC" 
value="<?php echo $UbiDis;?>"   readonly="readonly"/>

<script>
function SelUbi(){
	var pai=gv("UbiPai");
	if(pai!="PERU"){
		alert("Solo valido para el pais PERU");
		return;
	}
	Ow('departamento_seleccionar.php?W=CLI',810*ZO(),510*ZO());
}
function setLima(){
	sv("UbiPai","PERU");
	sv("UbiDep","LIMA");
	sv("UbiPro","LIMA");
	sv("UbiDis","LIMA");
}
</script>

<input type="button" name="CmdUbi" id="CmdUbi" 
value="..." 
onClick="SelUbi();" tabindex="15"
style="position:absolute; left: 532px; top: 250px; width:30px;"
/>

<input type="button" name="CmdUbiX" id="CmdUbiX" 
value="X" 
onClick="ClsUbi();" tabindex="15"
style="position:absolute; left: 566px; top: 250px; width: 30px;"
/>

<input type="button" name="CmdLim" id="CmdLim" 
value="<< Lima" 
onClick="setLima();" tabindex="15"
style="position:absolute; left: 600px; top: 250px; width: 70px;"
/>

<div class="s1" style="left:678px; top: 234px; width: 108px;">EMAIL</div>
<input name="TxtEma" type="text" id="TxtEma" 
style="left:676px; top: 250px; width: 242px" 
value="<?php echo $StrEma;?>"  
onkeydown="return SoloTextoEx(event,'TxtGIA');"
tabindex="13" />

<input type="button" name="CmdEma" id="CmdEma" value="Email interno" 
onClick="SetEMA();" tabindex="15"
style="position:absolute; left: 928px; top: 250px; width: 94px;"
/>


<div class="s1" style="left: 16px; top: 282px; width: 403px;">
GUIA DE REMISION (Serie - Numero) ejemplo :1-1 o 0001-00000001</div>
<input name="TxtGIA" type="text" id="TxtGIA" 
style="left: 16px; top: 300px; width: 222px" 
value="<?php echo $StrGIA;?>"   maxlength="20"
onkeydown="return SoloTextoEx(event,'CboTemp');"
<?php
	if($ES_GIA_REFERENCIA==1){
		echo " readonly=\"readonly\"  ";
	}else{
		if(strlen($DOC_LOAD)==0){
			echo " ";		
		}else{
			echo " readonly=\"readonly\"  ";		
		}
	}
?>
tabindex="14" />

<input type="button" name="CmdGIAX" id="CmdGIAX" 
style="position:absolute; left: 246px; top: 300px; width: 169px;" 
onclick="fGiaReferencia();"  value="Obtener proforma >>"
tabindex="20"/>


<div align="left" class="s1" style="position:absolute; left: 12px; top: 111px; width: 214px;">
<input name="Ch_PRI" type="checkbox" 
id="Ch_PRI" tabindex="1"    onchange="fChPrin();"
value="1"
<?php
$CH_OK=0;
if($Str_PRI==1){
	echo " checked=\"checked\" ";
	$CH_OK=1;
}
if($CH_OK==0){
	if($DR_NOM=="CONTENEDOR"){
		echo " checked=\"checked\" ";
		$CH_OK=1;
	}
}
?>
/> 
DOC. PRINCIPAL

(<i>OPCIONAL</i>)</div>

<?php
if(strlen($ERROR_MSG)>0){
	echo '<div class="s1" style="position:absolute; left: 224px; top: 116px; width:290px; background-color:#F30; padding:0.2rem 0.2rem 0.2rem 0.2rem">'.$ERROR_MSG.'</div>';
}
?>
<div class="EV" style="left: 318px; top: 139px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtFec')">(dd-mm-yy) +</a></u></div>



<div class="s1" style="left: 682px; top: 282px; width: 100px;">
SERIE - NUMERO
</div>


<div style="visibility:hidden;position:absolute; left: 12px; top: 255px; width: 306px; height: 25px;">

<div align="left" class="s2">
<input name="ChN_INC" tabindex="14" type="checkbox" 
id="ChN_INC" value="1"  onclick="CalcularIMPORTE();" 
<?php
if($StrN_INC=="1"){
echo "checked=\"checked\"";
}
?>
/>
EL PRECIO NO INCLUYE IGV (<i>OPCIONAL</i>)</div>
</div>

<div class="EL" style="left: 16px; top: 330px; width: 84px;"><u><a onclick="fLimDet()">CODIGO +</a></u></div>
<input name="TxtCod" 
type="text" id="TxtCod" 
style="left: 16px; top: 350px; width: 89px;" 
value="<?php echo $StrCod;?>"  
onkeydown="return SoloTextoEx(event,'TxtDes');"
onkeyup="document.getElementById('TxtHora').value=GetHora();" 
<?php if(strlen($DR_NOM)>0){echo " readonly=\"readonly\" ";	} ?>
tabindex="21" />
<div class="s1" style="left: 122px; top: 330px; width: 132px;">
DESCRIPCION
</div>

<input name="TxtDes" type="text" id="TxtDes" 
style="left: 122px; top: 350px; width: 355px;" 
value="<?php echo $StrDes;?>"  
onkeydown="return SoloTextoEx(event,'TxtMarca');"
onkeyup="document.getElementById('TxtHora').value=GetHora();" 
<?php if(strlen($DR_NOM)>0){echo " readonly=\"readonly\" ";	} ?>
tabindex="22" />
<div class="s1" style="left: 602px; top: 330px; width: 56px;">
PRECIO
</div>
<input name="TxtPre" type="text" id="TxtPre" 
style="left: 599px; top: 350px; width: 56px; text-align:right" 
value="<?php echo $StrPre;?>"  
onkeydown="return SoloNum(this,event,'TxtCant');" 
tabindex="24" 
onkeyup="fImporte();"
<?php if(strlen($DR_NOM)>0){echo " readonly=\"readonly\" ";	} ?>
onfocus="selecciona_value(this);"/>

<div class="s1" style="left: 673px; top: 330px; width: 43px;">
CANT
</div>
<input name="TxtCant" type="text" id="TxtCant" 
style="left: 670px; top: 350px; width: 44px;" 
value="<?php echo $StrCant;?>"  
onkeydown="return SoloNum(this,event,'TxtCUni');" 
onkeyup="fImporte();"
onfocus="selecciona_value(this);"   
<?php if(strlen($DR_NOM)>0){echo " readonly=\"readonly\" ";	} ?>       
tabindex="25" />
<div class="s1" style="left: 729px; top: 330px; width: 43px;">
PIEZAS
</div>

<input name="TxtCUni" type="text" id="TxtCUni" 
style="left: 729px; top: 350px; width: 46px;" 
value="<?php echo $StrCUni;?>"  
onkeydown="return SoloNum(this,event,'CmdAdd');" 
onkeyup="fImporte();"
onfocus="selecciona_value(this);"
<?php if(strlen($DR_NOM)>0){echo " readonly=\"readonly\" ";	} ?>
tabindex="26" />
<div class="s1" style="left: 797px; top: 330px; width: 54px;">
IMPORTE
</div>
<input name="TxtImp" type="text" id="TxtImp" 
style="left: 792px; top: 350px; width: 67px; background-color:#CCC; text-align:right" 
value="<?php echo $StrImp;?>"  
onkeydown="return SoloNum(this,event,'CmdAdd');" 
tabindex="27" readonly="readonly" />


<div class="s1" style="left:941px; top: 333px; width: 81px;">AUTORIZAR</div>
<input name="TxtAut" type="password" id="TxtAut" 
style="position:absolute; left: 941px; top: 350px; width: 72px;"
tabindex="19" onkeydown="return SoloTextoEx(event,'CmdAdd');" 
value="" maxlength="15"
<?php echo _D($R_O);?> />



<input type="button" name="CmdAdd" 
style="position:absolute; left: 871px; top: 350px; width: 64px;"
<?php if(strlen($DR_NOM)>0){echo " disabled=\"disabled\" ";	} ?>
id="CmdAdd" value="Agregar" onclick="fAgregar();" tabindex="28"/>



<div id="TAB_AJAX" 
style="visibility: hidden; height:276px; width:1400px; overflow-x:hidden; position:absolute; left: 14px; top: 400px; overflow-y:scroll; color: #0FF; background-color: #FFFFFF; layer-background-color: #CCCCCC; border: 1px none #000000;" align="left"></div>
<div id="TAB_CAPTION" 
style="visibility: hidden; height:20px; width:1000px; position:absolute; left: 13px; top: 380px; color: #0FF; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000;" align="left">
<?php
$T=110+300+80+180+(gn("count(*)","almacenes","id_almacen>0")*60)+120;
?>
<table style="width:<?php echo $T;?>px" border="1" cellpadding="0" cellspacing="0" bgcolor="#d4e3e5" 
class="estilo888">
<tbody>
<tr  height="10 px">
<td style="width:110px" bgcolor="#CCCCCC">CODIGO</td>
<td style="width:300px" bgcolor="#CCCCCC">DESCRIPCION</td>
<td style="width:80px" bgcolor="#CCCCCC">LINEA</td>
<td style="width:60px" align="right" bgcolor="#CCCCCC">PV MIN</td>
<td style="width:60px" align="right" bgcolor="#CCCCCC">PV MAX</td>
<td style="width:60px" align="right" bgcolor="#CCCCCC">STOCK</td>

<?php
$s="";
$z="SELECT alm_obs FROM almacenes ".
   "WHERE id_almacen>0 ORDER BY alm_obs";
$result = grs($z);
while ($roww = $result->fetch_row()){		 
	$s=$s."<td  align=\"right\" style=\"width:60px\" bgcolor=\"#CCCCCC\">$roww[0]</td>";
}
echo $s;
?>
<td style="width:60px" align="right" bgcolor="#CCCCCC">SEP.</td>
<td style="width:60px" align="right" bgcolor="#CCCCCC">E.T.</td>
</tr>
</tbody>
</table>
<div style="position:absolute; top:0px; left:60px">
<input name="CmdClose" type="button" value="Cerrar" onclick="CerrarDIV();" style="background-color:#F90" /></div>
</div>





<input type="button" name="CmdSel" id="CmdSel" value="Trasformaciones" 
onClick="Ow('transformaciones_2.php',905*ZO(),390*ZO())" tabindex="15"
style="position:absolute; left: 338px; top: 298px; width: 127px; display:none"
/>




<div class="s1" style="left: 429px; top: 282px; width: 139px;">
DOC. DE REFERENCIA
</div>
<select name="CboTemp" id="CboTemp" 
style="left: 429px; top: 300px; width: 134px;" 
onkeydown="return SoloTextoEx(event,'CboEmpR');" tabindex="16">
<?php
if(strlen($DR_NOM)==0){
	echo FCBO_("au_item","auxiliar",
			   "au_tab='VEN_REF'",$StrTempA,"N","S");
}else{
	echo FCBO_("au_item","auxiliar",
			   "au_tab='VEN_REF' AND au_item='$StrTempA'",$StrTempA,"N","N");
}
?>
</select>

<div class="s1" style="left:578px; top: 282px; width: 100px;">
EMPRESA
</div>

<select name="CboEmpR" id="CboEmpR" 
style="position:absolute; left:578px; top:300px; width: 89px;" 
onkeydown="return SoloTextoEx(event,'TxtTemp');" tabindex="1">  
<?php 
	if(strlen($DOC_LOAD)>0){
		echo "<option value=\"$StrEmpR\">$StrEmpR</option> ";
	}else{
		echo FCBO_("emp_nomc","empresas","id_emp>0",$StrEmpR,"N","S");
	}
?>
</select>


<input name="TxtTemp" type="text" id="TxtTemp" 
style="left: 679px; top: 300px; width: 136px;" 
value="<?php echo $StrTempB;?>"  
<?php
	if($ES_GIA_REFERENCIA==1){
		echo " readonly=\"readonly\"  ";
	}else{
		if(strlen($DOC_LOAD)==0){
			echo " ";		
		}else{
			echo " readonly=\"readonly\"  ";		
		}
	}
?>
onkeydown="return SoloTextoEx(event,'Ch_APP');" 
tabindex="17" />

<div class="s1" style="position:absolute; left: 821px; top: 276px; width: 125px; height: 23px;">

<input name="Ch_APP" type="checkbox" 
id="Ch_APP" tabindex="18"  onchange="fVerificar()"  
onkeydown="return SoloTextoEx(event,'CmdLoad');"
value="1"
<?php
if($Str_APP==1){
	echo "checked=\"checked\"";
}
?>
/> 
APLI. DSCTO. %
</div>


<input name="TxtPD" type="text" id="TxtPD" 
style="left: 947px; top: 276px; width: 68px; text-align:right" 
value="<?php echo $StrPD;?>"  
onkeydown="return SoloNum(this,event,'CmdLoad');" 
tabindex="19" 
<?php if(strlen($DR_NOM)>0){echo " readonly=\"readonly\" ";	} ?>
onfocus="selecciona_value(this);"/>


<input type="button" name="CmdLoad" id="CmdLoad" 
style="position:absolute; left: 825px; top: 300px; width: 199px;" 
<?php
	if(strlen($DR_NOM)==0){
		echo " value=\"Cargar\"  ";		
	}else{
		echo " value=\"Deshacer referencia\"  ";		
	}
?>
onclick="fCargar();" 
tabindex="20"/>

<div id="layer44" style="position:absolute; left: 352px; top: 330px; width: 68px;">
<div align="left" class="sFA">PRE. MIN :</div>
</div>
<div id="layer45" style="position:absolute; left: 410px; top: 330px; width: 69px;">
<div id="TxtPreM" align="right" class="sFA">0.00</div>
</div>

<script>
function fSelEditX(){
	var IdCli=document.getElementById("TxtIdCliente").value;
	//OpenWin("clientes.php?Id="+IdCli,900,600);	
	window.open("sis_clientes.php?Id="+IdCli);  
}
</script>

<div class="s1" style="position:absolute; left: 87px; top: 189px; width: 76px; background-color: #FFCC00; layer-background-color: #FFCC00; border: 1px none #000000; height: 17px;">
<div align="center"> <a target="_blank" class="w5" onclick="fSelEditX()"><u>EDITAR </u></a> </div>
</div>

<div class="s1" style="position:absolute; left: 174px; top: 189px; width: 77px; background-color: #FFCC00; layer-background-color: #FFCC00; border: 1px none #000000; height: 17px;">
<div align="center"> <a target="_blank" href="sis_clientes.php">NUEVO</a> </div>
</div>

<div class="s1" style="left: 492px; top: 330px; width: 60px;">
LINEA
</div>
<input name="TxtMarca" type="text" id="TxtMarca" 
style="left: 492px; top: 350px; width: 94px;" 
value="<?php echo $StrMARCA;?>"
onkeydown="return SoloTextoEx(event,'TxtPre');"
onkeyup="document.getElementById('TxtHora').value=GetHora();"
<?php if(strlen($DR_NOM)>0){echo " readonly=\"readonly\" ";	} ?>
tabindex="23" />


<div  class="s1" style="position:absolute; left: 218px; top: 330px; width: 125px; background-color: #FFCC00; layer-background-color: #FFCC00; border: 1px none #000000; height: 17px;">
<div align="center" > <a target="_blank" href="productos.php">NUEVO PRODUCTO</a></div>
</div>

<?php

if(strlen($StrDESCARGAR)>0){
echo "<div id=\"layer51\" 
	  style=\"position:absolute; left: 496px; top: 114px; 
	  width: 90px; background-color: #FFCC00; layer-background-color: #FFCC00; 
	  border: 1px none #000000; height: 17px;\">";
echo "<div align=\"center\" class=\"f2\"> ";
echo " <a href=\"$StrDESCARGAR\" download>Descarga.PDF</a> ";
echo "</div>";
echo "</div>";
}
?>

<input name="GIA_REF_KOD" id="GIA_REF_KOD" type="hidden" value="" />
<input name="ES_GIA_REFERENCIA" id="ES_GIA_REFERENCIA" type="hidden" value="<?php echo $ES_GIA_REFERENCIA;?>" />
</form>
</div>
</center>	
</body>
</html>
