<?php
	session_start();	
	//-------------------------	
	include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
	if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}	
	$StrGT="";
	$VP_RegXPag=20;
	$LStrMsg="";
	$LStrFoc="";
	$LStrMM="";
	$LStrPag=V($_POST['TxtPag']);	
	include("guias_fun.php");
	$StrHWND_G=$_SESSION['SYS_HW']."_G";
	
$IdUsu=$_SESSION['SYS_USER_ID'];
$AT=gs("at","usuarios","id_usuario=$IdUsu");
?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Guias</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.js"></script>
<script type="text/javascript" src="ja/guias.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"  />

<style type="text/css">
.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=setInterval(function(){myTimer()},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 myStopFunction(){
	clearInterval(myVar);
}

$(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 cCod(e){	
	var k;
	k=(document.all) ? e.keyCode :e.which;
	DivDatos = document.getElementById("TAB_AJAX");
	DivCaption = document.getElementById("TAB_CAPTION");
	if(k==40){
		if(DivDatos.style.visibility!="hidden"){
			document.getElementById("z1").focus();
			event.preventDefault();
			
		}
		return true;
	}

	if(k==13){
		var Cod=gv("TxtCod");
		//
		if(Cod=="")return;		
		//
		if(k==13){
			GetCod(Cod);
		}
	}
	
	
}

function GetCod(Cod){	
	svv("Pro_TxtId,TxtDes,TxtMarca,TxtCant");
	svv("Pro_TxtCod,Pro_TxtDes");
	
	R=AX("Z_GUIA",Cod);

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

function cCodUP(e){	
	var k;
	k=(document.all) ? e.keyCode :e.which;	
	if(k==40 || k==27 || k==13){
		
	}else{
		sv('TxtHora',GetHora());
	}
}
</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 $HTM;
?>
</div>

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;">
<form id="Frm" name="Frm" method="post" action="guias.php" autocomplete="off" 
style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">

<!--INI_TITULO--------------------------------->
<div id="DivT" class="dT" >
<img src="img/guia.png" class="iT" />
<div class="tT">GUIAS</div>
</div>


<!--FIN_TITULO--------------------------------->

<div class="s1" style="left: 35px; top: 137px; width: 79px;">
ALMACEN *</div>
<select name="CboAlm" id="CboAlm" 
class="lt" style="left: 35px; top: 154px; width: 130px" 
onchange="fPartida();"
tabindex="<?php echo ++$TI;?>">
<?php echo ListALM($StrAlm); ?>
</select>

<input name="ChN_AUTO" type="checkbox" id="ChN_AUTO" 
class="lt" style="left: 168px; top: 115px;"
value="1" onClick="AutoNumeracion(document.getElementById('ChN_AUTO').checked);" 
<?php if($StrN_AUTO=="1"){echo "checked=\"checked\"";}?>/>
<div class="s1" style="left: 189px; top: 118px; width: 195px;">
<label for="ChN_AUTO">NUMERACION AUTOMATICA</label></div>


<div class="s1" style="left: 170px; top: 137px; width: 58px;">
SERIE *</div>
<input name="TxtSer" type="text" id="TxtSer" 
class="lt" style="left: 172px; top: 154px; width: 54px" 
value="<?php echo $StrSer;?>"  maxlength="4" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 240px; top: 137px; width: 70px;">
NUMERO *</div>
<input name="TxtNum" type="text" id="TxtNum" 
class="lt" style="left: 240px; top: 154px; width: 60px" 
value="<?php echo $StrNum;?>" maxlength="6" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 312px; top: 137px; width: 91px;">
FEC. EMISIO *</div>
<input name="TxtFec" type="text" id="TxtFec" 
class="fe" style="left: 311px; top: 154px; width: 75px" 
value="<?php echo $StrFec;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 398px; top: 122px; width: 73px; height: 33px;">
FEC. TRASLADO</div>
<input name="TxtFecT" type="text" id="TxtFecT" 
class="fe" style="left: 397px; top: 154px; width: 77px" 
value="<?php echo $StrFecT;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 487px; top: 137px; width: 157px; height: 19px;">
PUNTO DE PARTIDA *</div>
<input name="TxtPar" type="text" id="TxtPar" 
class="lt" style="left: 485px; top: 154px; width: 293px" 
value="<?php echo $StrPar;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 791px; top: 137px; width: 81px;">
COSTO MIN.</div>
<input name="TxtCosto" type="text" id="TxtCosto" 
class="lt" style="left: 789px; top: 154px; width: 70px; text-align: right" 
value="<?php echo $StrCosto;?>"  
onfocus="selecciona_value(this);" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 869px; top: 137px; width: 195px;">
RAZON SOCIAL DESTINATARIO *</div>
<input name="TxtDesRs" type="text" id="TxtDesRs" 
class="lt" style="left: 869px; top: 154px; width: 227px" 
value="<?php echo $StrDesRs;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 1106px; top: 123px; width: 98px;">
RUC DESTINARIO</div>
<input name="TxtDesRuc" type="text" id="TxtDesRuc" 
class="lt" style="left: 1106px; top: 154px; width: 105px;" 
value="<?php echo $StrDesRuc;?>"  
tabindex="<?php echo ++$TI;?>" maxlength="11"/>


<div class="s1" style="left: 35px; top: 204px; width: 165px; height: 16px;">
PUNTO DE LLEGADA *</div>
<input name="TxtDesDir" type="text" id="TxtDesDir" 
class="lt" style="left: 35px; top: 221px; width: 268px" 
value="<?php echo $StrDesDir;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 313px; top: 204px; width: 169px;">
EMPRESA DE TRANSPORTE</div>
<input name="TxtETRs" type="text" id="TxtETRs" 
class="lt" style="left: 313px; top: 221px; width: 164px" 
value="<?php echo $StrETRs;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 489px; top: 204px; width: 111px;">
EMP. TRANS. RUC</div>
<input name="TxtETRuc" type="text" id="TxtETRuc" 
class="lt" style="left: 486px; top: 221px; width: 112px;" 
value="<?php echo $StrETRuc;?>"  
tabindex="<?php echo ++$TI;?>"  maxlength="11"/>

<div class="s1" style="left: 611px; top: 204px; width: 123px;">
MARCA</div>
<input name="TxtMarca" type="text" id="TxtMarca" 
class="lt" style="left: 611px; top: 221px; width: 168px" 
value="<?php echo $StrMarca;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 792px; top: 204px; width: 90px;">
PLACA</div>
<input name="TxtPlaca" type="text" id="TxtPlaca" 
class="lt" style="left: 790px; top: 221px; width: 100px" 
value="<?php echo $StrPlaca;?>"   maxlength="7"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 904px; top: 189px; width: 89px;">
CONST. DE INSCRIPCION</div>
<input name="TxtCons" type="text" id="TxtCons" 
class="lt" style="left: 902px; top: 221px; width: 132px" 
value="<?php echo $StrCons;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 1044px; top: 204px; width: 107px;">
NRO. LICENCIA</div>
<input name="TxtLic" type="text" id="TxtLic" 
class="lt" style="left: 1044px; top: 221px; width: 167px" 
value="<?php echo $StrLic;?>"  maxlength="15"
tabindex="<?php echo ++$TI;?>"/>


<input name="ChN_BAR" type="checkbox" id="ChN_BAR" 
value="1" style="left: 32px; top: 313px;"   
onchange="ChN_BAR_OnChange();"
<?php if($StrN_BAR=="1"){echo "checked=\"checked\"";}?>/> 
<div class="s1" style="left: 52px; top: 316px; width: 125px;">
<label for="ChN_BAR">CODIGO DE BARRAS</label></div>


<input name="ChN_AUT" type="checkbox" id="ChN_AUT" 
value="1" style="left: 187px; top: 313px;"
onchange="ChN_BAR_OnChange();"
<?php if($StrN_AUT=="1"){echo "checked=\"checked\"";}?>/> 
<div class="s1" style="left: 210px; top: 316px; width: 122px;">
<label for="ChN_AUT">AUTO AGREGAR</label></div>






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

<div class="s1" style="left: 190px; top: 340px; width: 138px;">
DESCRIPCION</div>
<input name="TxtDes" type="text" id="TxtDes" 
style="left: 190px; top: 357px; width: 690px" 
value="<?php echo $StrDes;?>"  
onkeydown="return cDes(event);"
onkeyup="return cDesUP(event);" 
onfocus="FOCO=1;" tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 892px; top: 340px; width: 100px;">
MARCA</div>
<input name="TxtMarcas" type="text" id="TxtMarcas" 
class="lt" style="left: 891px; top: 357px; width: 165px" 
value="<?php echo $StrMARCA;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 1065px; top: 340px; width: 39px;">
CANT</div>
<input name="TxtCant" type="text" id="TxtCant" 
class="lt" style="left: 1063px; top: 357px; width: 74px; text-align: right" 
value="<?php echo $StrCant;?>"      
onfocus="selecciona_value(this);"          
tabindex="<?php echo ++$TI;?>"/>

<input type="button" name="CmdAdd" id="CmdAdd" 
class="lt" style="position: absolute; left: 1144px; top: 356px; height: 23px; width: 68px;"
value="Agregar" onClick="fAgregar();" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" id="LblTit2" style="left: 729px; top: 267px; width: 33px; z-index: 100;">
<img src="img/categorias.png" width="32" height="32" / onclick="fGetProdDatos_Id('2');" /></div>
<div class="s1" style="left: 766px; top: 262px; width: 109px;">
REFERENCIA</div>
<select name="CboComR" id="CboComR" 
class="lt" style="left: 765px; top: 278px; width: 180px" 
onclick="CboRef();" onChange="CboRef();" tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO_("com_nombre",
			   "comprobantes",
			   "id_comprobante>0 AND com_nombre IN('FACTURA','BOLETA','NOTA DE VENTA')",$StrComR,"","S");
?>  
</select>

<div class="s1" style="left: 957px; top: 262px; width: 47px;">
SERIE</div>
<input name="TxtSerR" type="text" id="TxtSerR" 
class="lt" style="left: 957px; top: 278px; width: 78px"                     
onfocus="selecciona_value(this);"
value="<?php echo $StrSerR;?>" maxlength="6"  
<?php
if(strlen($StrComR)==0 || $StrComR=="TRANSFERENCIA"){
	echo "style=\"width:40px; background-color:#CCC\" ";
	echo " readonly=\"readonly\" ";
}else{
	echo "style=\"width:40px;\" ";
	echo " readonly=\"readonly\" ";
}
?>          
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 1043px; top: 262px; width: 64px;">
NUMERO</div>
<input name="TxtNumR" type="text" id="TxtNumR" 
class="lt" style="left: 1043px; top: 278px; width: 73px"
value="<?php echo $StrNumR;?>" maxlength="10"
<?php
if(strlen($StrComR)==0){
	echo "style=\"width:60px; background-color:#CCC\" ";
	echo " readonly=\"readonly\" ";
}else{
	echo "style=\"width:60px;\" ";
	echo " readonly=\"readonly\" ";
}
?>
tabindex="<?php echo ++$TI;?>"/>

<input type="button" name="CmdLoad" id="CmdLoad" 
style="position: absolute; left: 1122px; top: 275px; width: 90px; height: 25px;"
value="Cargar datos" onClick="LoadRef();"
tabindex="<?php echo ++$TI;?>"/>


<div id="DivBtn" align="left" style="position:absolute; left: 35px; top: 71px; width:1000px; height: 26px;">
<input name="CmdB" type="button" id="CmdG" class="btm"
<?php
if(strlen($StrId)==0){
	echo "value=\"Guardar\"";
}else{
	echo "value=\"Modificar\"";
$StrAnu=gs("anu","guias","id_guia=$StrId");
if($StrAnu=="S"){
	echo " disabled=\"disabled\"";
}
}
?>
onclick="fGuardar();" style="width:80px" 
tabindex="<?php echo ++$TI;?>"/>
        
<input name="CmdB" type="button" id="CmdC" class="btm"
value="Nuevo" onClick="fCancelarPHP();"  
tabindex="<?php echo ++$TI;?>"/>

        
<input name="CmdB" type="button" id="CmdA" class="btm"
value="Imprimir" onClick="OpenWin('guias_imprimir.php?TxtId=<?php echo $StrId;?>',800,600);"
<?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="fAnular();"
<?php
if(strlen($StrId)==0){
echo "disabled=\"disabled\"";
}else{
$StrAnu=gs("anu","guias","id_guia=$StrId");
if($StrAnu=="S"){
	echo "disabled=\"disabled\"";
}
}
?>
tabindex="<?php echo ++$TI;?>"/>
        
<input name="CmdB" type="button" id="CmdE" class="btm"
value="Eliminar" onClick="fEliminar();"
<?php
if(strlen($StrId)==0){
	echo "disabled=\"disabled\"";
}else{
	$StrAnu=gs("anu","guias","id_guia=$StrId");
	if($StrAnu=="S"){
		echo "disabled=\"disabled\"";
	}
}
?>
tabindex="<?php echo ++$TI;?>"/>

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

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


<div class="datagrid" style="position: absolute; left: 35px; top: 390px; width: 1180px; height: 176px; overflow: auto">
<table width="75%">
<thead>
<tr>
<th width="9%">CODIGO</th>
<th width="49%">DESCRIPCION</th>
<th width="18%">MARCA</th>
<th width="7%">CANT</th>
<th width="3%">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php
	$s="SELECT * FROM temp_compras WHERE cod_temc='$StrHWND_G' 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=VV(gs("COD","vproductos","ID=$X_ID"));
		$X_DE=VV(gs("DESCRIPCION","vproductos","ID=$X_ID"));
		$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;
?>
    <tr>
    <td width="85" bgcolor="#FFFFFF"><?php echo $X_CO;?></td>
    <td width="549" bgcolor="#FFFFFF"><?php echo $X_DE;?></td>
    <td width="143" bgcolor="#FFFFFF"><?php echo $X_MA;?></td>
    <td width="38" bgcolor="#FFFFFF" align="right"><?php echo $X_CA;?></td>
    <td width="19" bgcolor="#FFFFFF" align="center">
    <a href="javascript:void(0)" onClick="fKiller('<?php echo $row[5];?>');" >
    <img src="img/eliminar.png" width="16" height="16" />
    </a>
    </td>
    </tr>
<?php
	}		
?>


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


<!--INI_OCULTOS-------------------------------->
<?php include("ocultos.php");?>

<div class="s1" id="layer">
<input name="TxtHora" type="hidden" id="TxtHora" value="0" />
<input name="TxtRuc_" type="hidden" id="TxtRuc_"  />        
<input name="TxtIdCliente" type="hidden" id="TxtIdCliente" value="<?php echo $StrIdCliente; ?>"   />        
<input name="TxtTC" type="hidden" id="TxtTC" value=""/>
</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_TxtCod" type="hidden" id="Pro_TxtCod" value=""/>
<input name="Pro_TxtMarca" type="hidden" id="Pro_TxtMarca" value=""/>
</div>
<!--FIN_OCULTOS-------------------------------->  
<style type="text/css">
.gr1{
	visibility:hidden; 
	overflow-x: hidden; 
	overflow-y: scroll; 
	color: #0FF; 
	background-color: #FFFFFF; 
	layer-background-color: #CCCCCC; 
	border: 1px none #000000;
}
.gr2{
	visibility:hidden; 
	height: 20px; 
	width: 1125px; 
	position: absolute; 
	left: 35px; 
	top: 389px; 
	color: #0FF; 
	background-color: #CCCCCC; 
	layer-background-color: #CCCCCC; 
	border: 1px none #000000;	
}
</style>
<div id="TAB_AJAX" class="datagrid gr1" 
style="height: 155px; width: 1126px; position: absolute; left: 35px; top: 408px;" align="left">
</div>
<div id="TAB_CAPTION" class="datagrid gr2" 
style="height: 20px; width: 1125px; position: absolute; left: 35px; top: 389px;" align="left">
<table width="1080" border="1" cellpadding="0" cellspacing="0" bgcolor="#d4e3e5" >   
<tr height="10 px">
<td width="128" bgcolor="#CCCCCC">CODIGO</td>
<td width="155" bgcolor="#CCCCCC">TIPO DE PRODUCTO</td>
<td width="400" bgcolor="#CCCCCC">DESCRIPCION</td>
<td width="142" bgcolor="#CCCCCC">MARCA</td>
<td width="56" bgcolor="#CCCCCC">STOCK</td>
<td width="56" align="right" bgcolor="#CCCCCC">PC.SOL</td>
<td width="56" align="right" bgcolor="#CCCCCC">PC.DOL</td>
<td width="56" align="right" bgcolor="#CCCCCC">&nbsp;</td>
</tr> 
<div style=" position:inherit; top:0px; left:1074px"><input name="CmdClose" type="button" value="Cerrar" onClick="CerrarDIV();" style="background-color:#F90" /></div>  
</table>
</div>

</form>
</div>
</div>
</body>
</html>
