<?php
session_start();
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
include("phpmnu_fun.php");
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
//++
$StrGT="";$LStrMsg="";$LStrFoc="";$LStrMM="";
//++
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
$LStrPag=V($_POST['TxtPag']);
//
$IdU=vbval(V($_SESSION['SYS_USER_ID']));
$StrHWND_V=V($_SESSION['SYS_USER_ID']."_V");//++++++
include("ventas_fun.php");
$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");	
$POL_USU_MP=vbval(gs("mp","usuarios","id_usuario=$IdU"));
$POL_USU_OPC=vbval(gs("opc","usuarios","id_usuario=$IdU"));
//
$VP_RegXPag=10;
$LStrTR=gn("count(*)","marcas","id_marca>0");
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);	
$TI=0;
//
$IdUsu=vbval(V($_SESSION['SYS_USER_ID']));
$AT=gs("at","usuarios","id_usuario=$IdUsu");
//
$VEN_TR=gn("count(*)","ventas","id_venta>0");
//++
?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ventas</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.js"></script>
<script type="text/javascript" src="ja/ventaz6.js"></script>
<!--FIN_SCRIPT------------------------------------->
<link rel="stylesheet" type="text/css" href="css/estiloss.css"  />
<link rel="stylesheet" type="text/css" href="css/basic.css"  />
<link rel="stylesheet" type="text/css" href="css/mnu.css"  />
<!--
<link href="css/bootstrap.css" rel="stylesheet">
--->

<style type="text/css">
.tableFixHead          { overflow-y: auto; }
.tableFixHead thead th { position: sticky; top: 0; }
table  {border-collapse:collapse;width:100%;}
th, td {padding: 3px 3px;}
th     {background:#666;}

.cF {height:600px;width:1250px;position:relative;top:0px}
.mM {height:34px;width:1250px;position:relative;top:0px;background-color:#09C; z-index:500;}
</style>
<script>
$(document).ready(function(){  
   Inicializar();
  
});


var FOCO=0;
var myVar=window.setInterval(function(){myTimer()},500);
var myVarC=window.setInterval(function(){myTimerC()},500);


function myTimer(){
	t=GetHora();
	tt=document.getElementById("TxtHora").value;	
	if(tt>0 && document.getElementById("ChN_BAR").checked==false){
		if(t-tt>=1){
			document.getElementById("TxtHora").value=0;
			fGetTabla();			
		}
	}

}

function myTimerC(){
	t=GetHora();
	tt=gv("TxtHoraC");	
	if(tt>0){
		if(t-tt>=1){
			sv("TxtHoraC","0");
			fGetTabla2();	
		}
	}
}

function myStopFunction(){
	clearInterval(myVar);
	clearInterval(myVarC);
}



$(document).keydown(function(e){
	var AT=gv("TxtAT");
	
	if(e.which==71 && e.altKey){		
		if(AT=="1"){	
		document.getElementById("CmdG").click();
		return;
		}
	}
	
	if(e.which==78 && e.altKey){
		if(AT=="1"){
		document.getElementById("CmdC").click();
		return;
		}
	}
	
	if(e.which==75 && e.altKey){
		if(AT=="1"){	
		document.getElementById("CmdE").click();
		return;
		}
	}

	if(e.which==66 && e.altKey){
		if(AT=="1"){	
		document.getElementById("CmdB").click();
		return;
		}
	}

	if(e.which==77 && e.altKey){
		if(AT=="1"){
		document.getElementById("CmdZ").click();
		return;
		}
	}
  
});

function GetCod(Cod){	
	svv("Pro_TxtId,TxtDes,TxtPre,TxtCant,TxtImp,Pro_TxtCod,Pro_TxtDes");

	R=AX("Z_VENTAS",Cod);

	S=R.split("|");
	IdP=S[0];
	Cod=S[1];
	Des=S[2];
	Pre=S[3];
	//
	if(jL(IdP)>0){
		sv("Pro_TxtId",IdP);
		sv("TxtCod",Cod);
		sv("TxtDes",Des);
		sv("TxtPre",Pre);
		sv("TxtCant","1");
		//	
		sv("Pro_TxtCod",Cod);
		sv("Pro_TxtDes",Des);
		//
		if(document.getElementById("ChN_AUT").checked==true){
			fAgregar();
		}else{
			jF("TxtPre");
		}
	}else{
		//alert("Codigo del producto no existe");
		jF("TxtDes");	
	}
}

function KeyFoco(e){	
	var k;
	k=(document.all) ? e.keyCode :e.which;

	if(k==13){
		var Tip=gv("CboTdp");
		if(Tip=="CONTADO"){			
			document.getElementById("CboTar").value="";
			document.getElementById("CboTar").disabled=true;
			document.getElementById("CboBancos").value="";
			document.getElementById("CboBancos").disabled=true;
			document.getElementById("TxtPagarCon").disabled=false;
			document.getElementById("TxtPagarCon").value=document.getElementById("T_TO").value;
			document.getElementById("CboMon").disabled=false;
			document.getElementById("CboMon").value="SOLES";
			jF("TxtPagarCon");
		}		
		if(Tip=="CREDITO"){			
			document.getElementById("CboTar").value="";
			document.getElementById("CboTar").disabled=true;
			document.getElementById("CboBancos").value="";
			document.getElementById("CboBancos").disabled=true;
			document.getElementById("TxtPagarCon").disabled=true;
			document.getElementById("TxtPagarCon").value="0.0";
			document.getElementById("CboMon").disabled=false;
			document.getElementById("CboMon").value="SOLES";
			jF("CboMon");
		}
		if(Tip=="TARJETA"){	
			document.getElementById("CboTar").value="";
			document.getElementById("CboTar").disabled=false;
			document.getElementById("CboBancos").value="";
			document.getElementById("CboBancos").disabled=false;
			document.getElementById("TxtPagarCon").disabled=true;
			document.getElementById("TxtPagarCon").value="0.0";
			document.getElementById("CboMon").disabled=true;
			document.getElementById("CboMon").value="SOLES";											
			document.getElementById("CboTar").focus();
		}
		if(Tip=="DEPOSITO"){	
			document.getElementById("CboTar").value="";
			document.getElementById("CboTar").disabled=true;
			document.getElementById("CboBancos").value="";
			document.getElementById("CboBancos").disabled=false;
			document.getElementById("TxtPagarCon").disabled=true;
			document.getElementById("TxtPagarCon").value="0.0";
			document.getElementById("CboMon").disabled=true;
			document.getElementById("CboMon").value="SOLES";											
			document.getElementById("CboBancos").focus();
		}
		event.preventDefault();
		return true;
	}
}
//
function fFOCO(e,FOC){	
	var k;
	k=(document.all) ? e.keyCode :e.which;

	if(k==13){
		if(FOC=="P"){
			jF("CboMon");
		}
	
		if(FOC=="M"){
			fGuardar();
		}
		
		if(FOC=="B"){
			var Tip=gv("CboTdp");
			if(Tip=="DEPOSITO"){
				jF("TxtOpe");
			}
			if(Tip=="TARJETA"){
				fGuardar();
			}
			
		}		
		
		if(FOC=="O"){
			fGuardar();
		}
		
		if(FOC=="T"){
			jF("CboBancos");
		}

		
		event.preventDefault();
		return true;
	}
	
}


function InsBan(){
	Ow("bancos_p.php",480*ZO(),240*ZO());
}

function fBancos(){
	R=fLista("ban_nombre","bancos","id_banco>=0");
	FCBO('CboBancos',R);
	jF("CboBancos");
}

</script>
</head>

<body  <?php echo $LStrMsg;?>>
<div align="center">

<div class="mM" align="left" style="font-size:12px">
<?php
//$HTM=file_get_contents("http://inversionessounduniversal.com/ventas/phpmnu.php?USER_ID=$IdUsu");
echo GEN_MENU(vbval(V($_SESSION['SYS_USER_ID'])));
?>
</div>

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;">
<form id="Frm" name="Frm" method="post" action="ventas.php" 
autocomplete="off" 
style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">
<!--INI_TITULO--------------------------------->
<div id="DivT" class="dT" >
<img src="img/ventas2.png" class="iT" />
<div class="tT">VENTAS</div>
</div>
<!--FIN_TITULO--------------------------------->
<div class="s1" style="left: 35px; top: 106px; width: 79px;">
ALMACEN *</div>
<select name="CboAlm" id="CboAlm" 
class="lt" style="left: 35px; top: 122px; width: 176px" 
tabindex="<?php echo ++$TI;?>">
<?php echo ListALM($StrAlm); ?>
</select>

<div class="s1" style="left: 224px; top: 106px; width: 54px;">
FECHA *</div>
<input name="TxtFec" type="text" id="TxtFec" 
class="fe" style="position: absolute; left: 224px; top: 122px; width: 116px;"
value="<?php echo $StrFec;?>"  
tabindex="<?php echo ++$TI;?>"/>


<input name="ChN_BAR" tabindex="10" 
type="checkbox" id="ChN_BAR"
class="lt" style="left: 908px; top: 118px;"
value="1"  onchange="ChN_BAR_OnChange();"
<?php if($StrN_BAR=="1"){echo "checked=\"checked\"";}?>/> 
<div class="s1" style="left: 928px; top: 122px; width: 135px; height: 18px;">
<label for="ChN_BAR">CODIGO DE BARRAS</label></div>

<input name="ChN_AUT" tabindex="10" 
type="checkbox" id="ChN_AUT"
class="lt" style="left: 1067px; top: 118px;" 
value="1"  onchange="ChN_BAR_OnChange();"
<?php if($StrN_AUT=="1"){echo "checked=\"checked\"";}?>/> 
<div class="s1" style="left: 1093px; top: 122px; width: 122px; height: 18px;">
<label for="ChN_AUT">AUTO AGREGAR</label></div>	


<div class="s1" style="left: 35px; top: 152px; width: 54px;">
CODIGO</div>
<input name="TxtCod" type="text" id="TxtCod" 
style="left: 35px; top: 169px; width: 120px" 
value="<?php echo $StrCod;?>"
onkeydown="return cCod(event);" 
onKeyUp="return cCodUP(event);" 
onFocus="FOCO=0;"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 163px; top: 152px; width: 96px;">
DESCRIPCION</div>
<input name="TxtDes" type="text" id="TxtDes" 
style="left: 162px; top: 169px; width: 702px" 
value="<?php echo $StrDes;?>"  
onkeydown="return cDes(event);" 
onKeyUp="return cDesUP(event);" onFocus="FOCO=1;"
tabindex="<?php echo ++$TI;?>"/>

<div class="sFA s1" style="left: 293px; top: 152px; width: 134px; color:#900">
PRECIO DE COMPRA : </div>
<div id="TxtPreC" class="sFA s1" style="left:426px; top: 152px; width: 66px; color:#900">
<b>0.00</b></div>


<div class="sFA s1" style="left: 503px; top: 152px; width: 134px; color:#00C">
PRECIO DE VENTA : S/</div>
<div id="TxtPreM" class="sFA s1" style="left: 639px; top: 152px; width: 68px; color:#00C">
<b>0.00</b></div>

<div class="sFA s1" style="left:718px; top: 152px; width: 52px; color:#000">
STOCK : </div>
<div id="TxtSTOCK" class="sFA s1" style="left:777px; top: 152px; width: 58px; color:#000">
0</div>

<div class="s1" style="left: 872px; top: 151px; width: 78px;">
S/ PRECIO</div>
<input name="TxtPre" type="text" id="TxtPre" 
class="ndd" style="left: 872px; top: 168px; width: 66px;" 
value="<?php echo $StrPre;?>"
onkeyup="fImporte();" onFocus="selecciona_value(this);"
<?php 
if($POL_USU_MP==0){
	echo "readonly=\"readonly\" ";
}
?>
tabindex="<?php echo ++$TI;?>"/>



<div class="s1" style="left: 947px; top: 151px; width: 62px;">
CANT</div>
<input name="TxtCant" type="text" id="TxtCant" 
class="ndd" style="left: 946px; top: 168px; width: 59px;" 
value="<?php echo $StrCant;?>"
onkeyup="fImporte();" onFocus="selecciona_value(this);"          
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 1015px; top: 151px; width: 76px;">
S/ IMPORTE</div>
<input name="TxtImp" type="text" id="TxtImp" 
class="rod" style="left: 1015px; top: 168px; width: 76px;" 
value="<?php echo $StrImp;?>"/>


<input type="button" name="CmdAdd" 
style="position: absolute; left: 1098px; top: 166px; width: 75px; height: 25px;"
id="CmdAdd" value="Agregar" onClick="fAgregar();" 
tabindex="<?php echo ++$TI;?>"/>

<input type="button" name="CmdLim" 
style="position: absolute; left: 1179px; top: 166px; width: 36px; height: 25px;"
id="CmdLim" value="X" onClick="fLimpiar();" 
tabindex="<?php echo ++$TI;?>"/>



<div id="DivBtn" align="left" style="position: absolute; left:35px; top: 71px; width: 854px; height: 26px;">
<input name="CmdB" type="button" id="CmdG" class="btm"
<?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";
}
//
$StrCan=gs("ven_cancelado","ventas","id_venta=$StrId");
if($StrCan=="S" && strlen($_YA)==0){
echo " disabled=\"disabled\"";
$_YA="S";
}
//
if($POL_USU_AV=="0" && strlen($_YA)==0){
echo " disabled=\"disabled\"";
}
}
?>
onclick="fGuardar();"  
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdC" class="btm"
value="Nuevo" onClick="fCancelarPHP();"  
tabindex="<?php echo ++$TI;?>"/>

<script>
function js_imprimir(){
	var id=gv("TxtId");
	if(jVal(id)==0){
		alert("No se puede determinar el id del registro activo");
		return;
	}
	document.getElementById("LnkPrint").href="ventas_print.php?ID="+id;
	document.getElementById("LnkPrint").click();
}
</script>
<a href="ventas_print.php" target="_blank" style="display:none" id="LnkPrint"></a>
<input name="CmdB" type="button" id="CmdPrint" class="btm"
value="Imprimir" onClick="js_imprimir()"
<?php
if(strlen($StrId)==0){
	echo " disabled=\"disabled\" ";
}else{
	$StrAnu=gs("anu","ventas","id_venta=$StrId");
	if($StrAnu=="S"){
		echo " disabled=\"disabled\" ";
	}
}
?>
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdA" class="btm"
value="Anular" onClick="flAnular();"
<?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";
}
//
$StrCan=gs("ven_cancelado","ventas","id_venta=$StrId");
if($StrCan=="S" && strlen($_YA)==0){
echo " disabled=\"disabled\"";
$_YA="S";
}
//
if($POL_USU_AV=="0" && strlen($_YA)==0){
echo " disabled=\"disabled\"";
}		
}
?>
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdE" class="btm"
value="Eliminar" onClick="flEliminar();"
<?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";
}
//
$StrCan=gs("ven_cancelado","ventas","id_venta=$StrId");
if($StrCan=="S" && strlen($_YA)==0){
echo " disabled=\"disabled\"";
$_YA="S";
}
//
if($POL_USU_EV=="0" && strlen($_YA)==0){
echo " disabled=\"disabled\"";
}

}
?>
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdE" class="btm"
value="Env.por.Email" onClick="fEnviarPDF();" style="display:none"
<?php
if(strlen($StrId)==0){
echo "disabled=\"disabled\"";
}else{
$StrAnu=gs("anu","cotizaciones","id_cotizacion=$StrId");
if($StrAnu=="S"){
    echo " disabled=\"disabled\"";
}
}
?>
tabindex="<?php echo ++$TI;?>"/>

<a href="ventas_vista_previa.php" target="_blank" style="display:none" id="LnkVP"></a>
<input name="CmdB" type="button" id="CmdVP" class="btm"
value="Vista previa" onClick="vista_previa()"
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdB" class="btm"
value="Buscar" onClick="fBuscar('ventas_buscar.php');"  
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdB" class="btm"
value="Bus. Det" onClick="fBuscar('ventas_det.php');"  
tabindex="<?php echo ++$TI;?>"/>

</div>
<div class="tableFixHead" style="position: absolute; left: 35px; top: 196px; width: 1180px; height: 197px; overflow: auto; border:solid 1px #A9A9A9">
<table width="100%" style="font-family:Arial, Helvetica, sans-serif; font-size:11px">
<thead>
<tr>
<th width="17">#</th>
<th width="133">CODIGO</th>
<th width="541">DESCRIPCION</th>
<th width="207" >MARCA</th>
<th width="54" align="right">PRECIO</th>
<th width="51" align="right">CANT</th>
<th width="91" align="right">IMPORTE</th>
<th width="24">&nbsp;</th>
<th width="20">&nbsp;</th>
</tr>
</thead>
<tbody>

<?php
$ZX=0;
$s="SELECT * FROM temp_compras WHERE cod_temc='$StrHWND_V' ORDER BY temc_index";
$result = grs($s);
$X_IMPORTE=0;
$X_ST=0;
$X_IG=0;
$X_TO=0;
while ($row = $result->fetch_row()){
	$X_ID=$row[1];
	$X_CO=$row[6];
	$X_DE=$row[7];
	$X_MA=VV(gs("MARCA","vproductos","ID=$X_ID"));
	$X_CA=$row[2];	
	$X_PR=$row[3];	
	$X_IM=$row[4];	
	$X_IMPORTE=$X_IMPORTE+$X_IM;
	$X_IM=number_format($X_IM,2,'.','');
	$ZX++;
	$CSS="";
	if($ZX%2==0)$CSS=" style=\"background-color:#CCC\" ";
?>
<tr <?php echo $CSS;?>>
<td width="17" ><?php echo $ZX;;?></td>
<td width="133" ><?php echo VV($X_CO);?></td>
<td width="541" ><?php echo VV($X_DE);?></td>
<td width="207" ><?php echo VV($X_MA);?></td>
<td width="54" align="right"><?php echo VV($X_PR);?></td>
<td width="51" align="right"><?php echo VV($X_CA);?></td>
<td width="91" align="right"><?php echo VV($X_IM);?></td>
<td width="24" 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="20" align="center"><a href="javascript:void(0)" onClick="fEditar('<?php echo $row[5];?>');"><img src="img/b_edit.png"  border="0"/></a></td>
</tr>
<?php
}
$X_IMPORTE=round($X_IMPORTE,1);
//
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;	
}
?>

</tbody>
</table>
</div>

<div class="s1" style="left: 807px; top: 402px; width: 75px;display:none">
<b>SUB TOTAL</b></div>
<input name="T_ST" type="text" id="T_ST" 
class="rod" style="left: 886px; top: 398px; width:75px; height:25px; border:none; padding-right:5px; display:none"
value="<?php echo number_format($X_ST,2,'.','');?>" />

<div class="s1" style="left: 974px; top: 402px; width: 28px;display:none">
<b>IGV</b></div>
<input name="T_IG" type="text" id="T_IG" 
class="rod" style="left: 1004px; top: 398px; width:70px; height:25px;border:none; padding-right:5px;display:none"
value="<?php echo number_format($X_IG,2,'.','');?>" />

<div class="s1" style="left: 1088px; top: 402px; width: 48px;">
<b>TOTAL</b></div>
<input name="T_TO" type="text" id="T_TO" 
class="rod" style="left: 1135px; top: 398px; width: 80px; height:25px;border:none; padding-right:5px"
value="<?php echo number_format($X_TO,2,'.','');?>" />


<!--INI_OCULTOS-------------------------------->
<?php include("ocultos.php");?>
<div class="s1" style="left: 116px; top: 21px; width: 412px; height: 45px; z-index: 100;">
<input name="TxtHora" type="hidden" id="TxtHora" value="0" />
<input name="VEN_TR" type="hidden" id="VEN_TR" value="<?php echo $VEN_TR;?>" />
<input name="TxtHoraC" type="hidden" id="TxtHoraC" value="0" />
<input name="TxtRuc_" type="hidden" id="TxtRuc_"  />        
<input name="TxtIdCliente" type="hidden" id="TxtIdCliente" value="<?php echo $StrIdCliente; ?>"   />        
<input name="TxtHW" type="hidden" id="TxtHW" value="<?php echo $StrHWND_V;?>"/>

<input name="FBan" type="hidden" id="FBan" onClick="fBancos();" />
</div>

<div id="DivDatosProd">
<input name="Pro_TxtId" type="hidden" id="Pro_TxtId" value=""/>
<input name="Pro_TxtDes" type="hidden" id="Pro_TxtDes" value=""/>
<input name="Pro_TxtPre" type="hidden" id="Pro_TxtPre" value=""/>
<input name="Pro_TxtPreM" type="hidden" id="Pro_TxtPreM" value=""/>
<input name="Pro_TxtCod" type="hidden" id="Pro_TxtCod" value=""/>
<input name="Pro_TxtCod" type="hidden" id="Pro_TxtMarca" value=""/>
<input name="TXT_PXU" id="TXT_PXU" type="hidden" value="" />
<input name="TXT_PXC" id="TXT_PXC" type="hidden" value="" />
<input name="TXT_PXM" id="TXT_PXM" type="hidden" value="" />
</div>
<!--FIN_OCULTOS-------------------------------->

<div class="s1" style="left: 35px; top: 438px; width: 109px;">
COMPROBANTE *</div>
<select name="CboCom" id="CboCom" 
class="lt" style="left: 35px; top: 456px; width: 169px;"
tabindex="<?php echo ++$TI;?>">
<?php 
echo FCBO_("com_nombre","comprobantes",
		   "id_comprobante>0 AND com_nombre IN('NOTA DE VENTA')",$StrCom,"","");?>
</select>


<?php
if($VEN_TR>0){
	$StrN_AUTO=1;
}
?>
<input name="ChN_AUTO" type="checkbox" 
style="left: 211px; top: 411px;"
class="lt" id="ChN_AUTO"  
onClick="AutoNumeracion(document.getElementById('ChN_AUTO').checked);fVenTR();" value="1"
<?php if($StrN_AUTO=="1"){echo "checked=\"checked\"";}?>
/>

<div class="s1" style="left: 233px; top: 414px; width: 184px;">
<label for="ChN_AUTO" >NUMERACION AUTOMATICA</label></div>

<div class="s1" style="left: 214px; top: 438px; width: 47px;">
SERIE *</div>
<input name="TxtSer" type="text" id="TxtSer" 
class="lt" style="left: 214px; top: 456px; width: 92px;<?php if($VEN_TR>0) echo "background-color:#CCC"; ?>" 
value="<?php echo $StrSer;?>"  onBlur="fcSer()"
<?php if($VEN_TR>0) echo " readonly "; ?>
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 314px; top: 438px; width: 96px;">
NUMERO *</div>
<input name="TxtNum" type="text" id="TxtNum" 
class="lt" style="left: 314px; top: 456px; width: 100px;<?php if($VEN_TR>0) echo "background-color:#CCC"; ?>" 
<?php if($VEN_TR>0) echo " readonly "; ?> onBlur="fcNum()"
value="<?php echo $StrNum;?>"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 425px; top: 438px; width: 67px;">
RUC</div>
<input name="TxtRuc" type="text" id="TxtRuc" 
class="lt" style="left: 425px; top: 456px; width: 101px;"
value="<?php echo $StrRuc;?>" maxlength="11" 
onkeydown="return KeyRuc(event);"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 534px; top: 438px; width: 90px;">
DNI</div>
<input name="TxtDni" type="text" id="TxtDni" 
class="lt" style="left: 533px; top: 456px; width: 90px;" 
value="<?php echo $StrDni;?>" maxlength="15"  
onkeydown="return KeyDni(event);"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 1098px; top: 67px; width: 118px; text-align:center">
TIPO DE CAMBIO</div>
<input name="TxtTC" type="text" id="TxtTC" 
class="roi" style="left: 1098px; top: 83px; width: 121px; text-align:center" 
value="<?php echo $StrTC;?>"/>

<div class="s1" style="left: 633px; top: 456px; width: 64px; height: 25px;">
<input type="button" name="CmdSel" id="CmdSel" value="..." 
onClick="OpenWin('ventas_clientes_buscar.php',800,600)" 
style="width:30px"/>
<input type="button" name="CmdCls" id="CmdCls"  style="width:30px"
value="X" 
onclick="fCls();"/>
</div>

<style type="text/css">
.grx{
	background-color:#FFCC00; 
	layer-background-color:#FFCC00; 
	border: 1px none #000000;
	border-radius: 0.25rem;
	padding-top:2px;
}
</style>

<div class="s1" style="left:714px; top: 438px; width: 205px;">CLIENTE / RASON SOCIAL *</div>
<div class="s1 grx" style="left:1098px; top:433px; width: 117px; height: 19px;">
<div align="center" class="Est2"> <a target="_blank" href="clientes.php">NUEVO CLIENTE</a> </div>
</div>
<input type="text" name="TxtCliente" id="TxtCliente" 
class="lt" style="left:714px; top: 456px; width: 501px;"
value="<?php echo $StrCliente;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 35px; top: 488px; width: 74px; height: 18px;">
DIRECCION</div>
<input name="TxtDIR" type="text" id="TxtDIR" 
class="lt" style="left: 35px; top: 506px; width: 271px" 
value="<?php echo $StrDIR;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 314px; top: 488px; width: 35px; height: 18px;"> TELEFONO
</div>
<input name="TxtTel" type="text" id="TxtTel" 
class="lt" style="left: 314px; top: 506px; width: 100px" 
value="<?php echo $StrTel;?>"   maxlength="12"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 425px; top: 488px; width: 67px; height: 18px;">
EMAIL</div>
<input name="TxtEma" type="text" id="TxtEma" 
class="lt" style="left: 425px; top: 506px; width: 272px" 
value="<?php echo $StrEma;?>"  
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 714px; top: 488px; width: 269px;">
VENDEDOR *</div>
<select name="CboVend" id="CboVend" 
class="lt" style="position: absolute; left: 714px; top: 506px; width: 501px;"
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO_("per_nombre","personal","id_personal>0",$CboVend,"","S");
?>
</select>

<div class="s1" style="left:35px; top: 541px; width: 118px;">
COSTO DE ENVIO</div>
<input name="TxtEnv" type="text" id="TxtEnv" 
class="ndd" style="left:35px; top: 557px; width: 122px;" 
value="<?php echo $StrEnv;?>"
onkeyup="f_CAL_IMP_TOT();" 
onFocus="selecciona_value(this);"
tabindex="<?php echo ++$TI;?>"/>

<?php
$StrTOT_IMP=round(vbval($StrEnv)+$X_TO,2);
?>
<div class="s1" style="left:169px; top: 541px; width: 129px;">
<b>IMPORTE TOTAL</b></div>
<input name="TXT_TOT_IMP" type="text" 
id="TXT_TOT_IMP" 
class="ndd" 
style="left:167px; top: 557px; width: 138px; background-color:#CCC" 
value="<?php echo $StrTOT_IMP;?>" readonly />



<div class="s1" style="left: 314px; top: 541px; width: 98px;">
TIPO DE PAGO *</div>
<select name="CboTdp" id="CboTdp" 
style="position: absolute; left: 314px; top: 557px; width: 100px;" 
tabindex="<?php echo ++$TI;?>" onkeydown="return KeyFoco(event);"
onchange="TDP();">
<?php
echo FCBO("tipp_nombre","tipos_pagos","",$StrTdp,"N","N");
?>
</select>

<div class="s1" style="left: 425px; top: 541px; width: 83px;">
TARJETA</div>
<select name="CboTar" id="CboTar" 
style="position: absolute; left: 425px; top: 557px; width: 109px;" 
onkeydown="return fFOCO(event,'T'); ">
<?php
if($StrTdp=="CONTADO" || $StrTdp=="DEPOSITO"  || $StrTdp=="CREDITO"){
echo "disabled=\"disabled\"";
}
?>
>
<?php
$s="SELECT tar_nombre FROM tarjetas ORDER BY id_tarjeta";
$result = grs($s);
while ($row = $result->fetch_row()){
if($StrTar==$row[0]){
echo "<option value=\"$row[0]\" selected=\"selected\">$row[0]</option>";
}else{
echo "<option value=\"$row[0]\" >$row[0]</option>";
}
}
?>
</select>

<div class="s1" style="left: 542px; top: 541px; width: 92px; cursor:pointer; color:#00F" onClick="InsBan()">BANCO</div>
<select name="CboBancos" id="CboBancos" 
style="position: absolute; left: 543px; top: 557px; width: 156px;" 
onkeydown="return fFOCO(event,'B'); ">
<?php
if($StrTdp=="CONTADO" || $StrTdp=="CREDITO"){
	echo "disabled=\"disabled\"";
}
?>
>
<?php
	echo FCBO("ban_nombre","bancos","ban_nombre>=0",$StrBan,"N","N");
?>
</select>

<div class="s1" style="left: 717px; top: 541px; width: 184px;">
NRO DE OPERACION</div>
<input type="text" name="TxtOpe" id="TxtOpe"  
style="left: 717px; top: 557px; width: 230px;"
onkeydown="return fFOCO(event,'O'); "
<?php
if($StrTdp=="CONTADO" || $StrTdp=="CREDITO"){
	echo " readonly=\"readonly\" ";
}
?>
onfocus="selecciona_value(this);" 
value="<?php echo $StrOpe;?>"/>

<div class="s1" style="left: 955px; top: 541px; width: 84px;">
PAGAR CON</div>
<input type="text" name="TxtPagarCon" id="TxtPagarCon"  
style="left:954px;top:557px;width:82px;text-align:right"
onkeyup="VUELTO();" onKeyDown="return fFOCO(event,'P'); "
value="<?php echo $StrPagarCon;?>" 
<?php
if($StrTdp!="CONTADO"){
	echo "readonly=\"readonly\"";
}
?>
/>



<div class="s1" style="left: 1046px; top: 541px; width: 70px;">
MONEDA</div>
<select name="CboMon" id="CboMon" 
style="left: 1044px; top: 557px; width: 90px;"
onchange="VUELTO();" onkeydown="return fFOCO(event,'M'); "
<?php
if($StrTdp!="CONTADO"){
echo "disabled=\"disabled\"";
}

?>
>

<?php
if($StrTdp!="CONTADO" ){
$StrMon="SOLES";
}
$s="SELECT mon_nombre FROM monedas WHERE id_moneda<>'X' ORDER BY mon_nombre DESC";
$result = grs($s);
while ($row = $result->fetch_row()){
if($StrMon==$row[0]){
echo "<option value=\"$row[0]\" selected=\"selected\">$row[0]</option>";
}else{
echo "<option value=\"$row[0]\" >$row[0]</option>";
}
}
?>
</select>


<div class="s1" style="left: 1141px; top: 541px; width: 71px;">
VUELTO S/.</div>
<input type="text" name="TxtVuelto" id="TxtVuelto"  
class="rod" style="left: 1141px; top: 557px; width: 72px;"
value="<?php echo $StrVuelto;?>"/>

<input type="button" name="CmdUP" id="CmdUP" value="UP" 
onclick="fLoad();" 
style="position: absolute; left: 816px; top: 121px; width: 49px; visibility: hidden"
tabindex="3" />


<div id="TAB_AJAX" class="datagrid" style="visibility:hidden; height: 155px; width: 1180px; overflow-x: hidden; position: absolute; left: 34px; top: 212px; overflow-y: scroll; color: #0FF; background-color: #FFFFFF; layer-background-color: #CCCCCC; border: 1px none #000000;" align="left"></div>
<div id="TAB_CAPTION" class="datagrid" style="visibility:hidden; height: 20px; width: 1180px; position: absolute; left: 34px; top: 196px; color: #0FF; overflow-y: scroll; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000;" align="left">
<table width="1000" border="1" cellpadding="0" cellspacing="0" bgcolor="#d4e3e5" >
<tbody>
<tr  height="10 px">
<td width="94" bgcolor="#CCCCCC">CODIGO</td>
<td width="200" bgcolor="#CCCCCC">LINEA</td>
<td width="280" bgcolor="#CCCCCC">DESCRIPCION</td>
<td width="110" bgcolor="#CCCCCC">MARCA</td>
<td width="100"  bgcolor="#CCCCCC">PRECIO DE VENTA</td>
<td width="53"  bgcolor="#CCCCCC">STOCK</td>
<td width="100"  bgcolor="#CCCCCC">PRECIO DE COMPRA</td>
<td width="47"  bgcolor="#CCCCCC">&nbsp;</td>
</tr>
</tbody>
</table>
<div style="position:absolute; top:0px; left:1120px"><input name="CmdClose" type="button" value="Cerrar" onClick="CerrarDIV();" style="background-color:#F90" /></div>
</div>
<?php
if(strlen($StrId)>0){
	$StrCan=gs("ven_cancelado","ventas","id_venta=$StrId");
	if($StrCan=="S"){
		$StrIdCob=gn("cv_id_cobro","cobros_ventas","cv_id_venta=$StrId");
$s="<div 
style=\"position:absolute; left: 16px; top: 115px; width: 410px; ".
"background-color: #FFCC00; ".
"layer-background-color: #FFCC00; border: 1px none #000000; height: 17px;\">
<div  align=\"center\" class=\"EstA\">VENTA AL CREDITO CANCELADA 
<a target=\"_blank\" href=\"clientes_edc.php?Id=".$StrIdCob."&Pag=0\">VER COBRO</a>
</div>
</div>";
		echo $s;
	}
}
?>
<input name="TXT_OPC" type="hidden" id="TXT_OPC" value="<?php echo $POL_USU_OPC;?>">
	
</form>
</div>
</div>
</body>
</html>
