<?php
session_start();
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
//
$HW=$_SESSION['SYS_HW'];
$StrGT="";$LStrMsg="";$LStrFoc="";$LStrMM="";
//
$StrId=V($_POST['TxtId']);
$StrCmd=V($_POST['TxtAc']);
$LStrPag=V($_POST['TxtPag']);
//
include("transferencias_fun.php");
//
$VP_RegXPag=10;
$LStrTR=gn("count(*)","temp_compras","cod_temc='$StrHWND_T'");
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);	
$TI=0;

$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>Transferencias</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.js"></script>
<script type="text/javascript" src="ja/transferencias.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=window.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) {	
  if(e.which==65 && e.altKey){
    document.getElementById("CmdAdd").click();
	return;
  }
  if(e.which==84 && e.altKey){
    document.getElementById("CboTdp").focus();
	return;
  }
  if(e.which==71 && e.altKey){
	if(document.getElementById("CmdG").disabled==false){		
    	document.getElementById("CmdG").click();
		return;
	}
  }
});

function cCod(e,c){	
	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_TRASFERENCIAS",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("TxtMarca",Mar);
		sv("TxtCant","1");
		//	
		sv("Pro_TxtCod",Cod);
		sv("Pro_TxtDes",Des);
		//
		if(document.getElementById("ChN_AUT").checked==true){		
			fAgregar();
		}else{
			jF("TxtMarca");
		}
	}
}


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;" onunload="myStopFunction();">
<form id="Frm" name="Frm" method="post" action="transferencias.php"  autocomplete="off" 
style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">

<!--INI_TITULO--------------------------------->
<div id="DivT" class="dT" >
<img src="img/transferencia.png" class="iT" />
<div class="tT">TRASFERENCIAS</div>
</div>
<!--FIN_TITULO--------------------------------->

<div class="s1" style="left: 35px; top: 121px; width: 70px;">
FECHA *</div>
<input name="TxtFec" type="text" id="TxtFec" 
class="fe" style="left: 35px; top: 139px; width:80px" 
value="<?php echo $StrFec;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 126px; top: 121px; width: 177px;">
ALMACEN ORIGEN *</div>
<select name="CboAlm" id="CboAlm" 
class="lt" style="left: 126px; top: 139px; width: 206px" 
tabindex="<?php echo ++$TI;?>">
<?php echo ListALM($StrAlm); ?>
</select>

<div class="s1" style="left: 342px; top:121px; width: 115px;">
NUM. AUTOMATICO</div>
<input name="TxtNum" type="text" id="TxtNum" 
class="roi" style="left: 340px; top: 139px; width:113px; background:#CCC" 
value="<?php echo $StrNum;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 469px; top: 121px; width: 180px;">
ALMACEN DESTINO *</div>
<select name="CboAlmD" id="CboAlmD" 
class="lt" style="left: 465px; top: 139px; width:200px" 
tabindex="<?php echo ++$TI;?>">
<?php echo FCBO_("alm_nombre","almacenes","id_almacen>=0",$StrAlmD,"","S");?>
</select>


<input name="ChN_BAR" type="checkbox" id="ChN_BAR"
class="lt" style="left: 33px; top: 176px;"
value="1"   onchange="ChN_BAR_OnChange();"
<?php if($StrN_BAR=="1"){echo "checked=\"checked\"";}?>
/> 

<div class="s1" style="left: 57px; top: 179px; width: 135px;">
<label for="ChN_BAR">CODIGO DE BARRAS</label></div>

<input name="ChN_AUT" type="checkbox" id="ChN_AUT"
class="lt" style="left: 198px; top: 176px;"
value="1"  onchange="ChN_BAR_OnChange();"
<?php if($StrN_AUT=="1"){echo "checked=\"checked\"";}?>/> 
<div class="s1" style="left: 222px; top: 179px; width: 128px;">
<label for="ChN_AUT">AUTO AGREGAR</label></div>


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

<div class="s1" style="left: 159px; top: 207px; width: 259px;">
DESCRIPCION</div>
<input name="TxtDes" type="text" id="TxtDes" 
class="lt" style="left: 156px; top: 225px; width: 750px" 
value="<?php echo $StrDes;?>"  
onkeydown="return cDes(event);"
onkeyup="return cDesUP(event);" 
onfocus="FOCO=1;"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 915px; top: 207px; width: 100px;">
MARCA</div>
<input name="TxtMarca" type="text" id="TxtMarca" 
class="lt" style="left: 914px; top: 225px; width: 140px" 
value="<?php echo $StrMARCA;?>"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 1073px; top: 207px; width: 54px;">
CANT</div>
<input name="TxtCant" type="text" id="TxtCant" 
class="ndd" style="left: 1072px; top: 225px; width: 60px" 
value="<?php echo $StrCant;?>"
onfocus="selecciona_value(this);"          
tabindex="<?php echo ++$TI;?>"/>

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


<div class="s1" style="left: 35px; top: 85px; width: 672px; height: 26px;">
<input name="CmdB" type="button" id="CmdG" class="btm"
onclick="fGuardar();" 
<?php
if(strlen($StrId)==0){
	echo "value=\"Guardar\"";
}else{
	echo "value=\"Modificar\"";

$StrAnu=gs("anu","transferencias","id_trans=$StrId");
if($StrAnu=="S"){
    echo " disabled=\"disabled\"";
}
}
?> 
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="Anular" onClick="fAnular();"
<?php
if(strlen($StrId)==0){
    echo "disabled=\"disabled\"";
}else{
    $StrAnu=gs("anu","transferencias","id_trans=$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","transferencias","id_trans=$StrId");
    if($StrAnu=="S"){
        echo "disabled=\"disabled\"";
    }
}
?>
tabindex="<?php echo ++$TI;?>"/>

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

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

</div>

<div class="datagrid" style="position: absolute; left: 35px; top: 255px; width: 1180px; height: 306px;">
<table width="75%">
<thead>

<tr>
<th width="9%">CODIGO</th>
<th width="49%">DESCRIPCION</th>
<th width="18%">MARCA</th>
<th width="7%" style="text-align:right;">CANT</th>
<th width="3%">&nbsp;</th>
</tr>

</thead>
<tbody>

<?php
	$StrHWND_T=$_SESSION['SYS_HW']."_T";
	$s="SELECT * FROM temp_compras WHERE cod_temc='$StrHWND_T' ORDER BY temc_index";
	$result = grs($s);
	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];
		
		?>
		<tr>
		<!----------------------------------------------->
		<td ><?php echo $X_CO;?></td>
		<td ><?php echo $X_DE;?></td>
		<td ><?php echo $X_MAR;?></td>
		<td style="text-align:right"><?php echo $X_CA;?></td>
		<!----------------------------------------------->
		<td bgcolor="#FFFFFF" align="center">
		<a href="javascript:void(0)" onClick="fKiller(<?php echo $row[5];?>);">
		<img src="img/eliminar.png"  border="0"/></a></td>
		</tr>
		<?php	
	}	
?>



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

<!--INI_OCULTOS-------------------------------->
<?php include("ocultos.php");?>
<input name="TxtPre" type="hidden" id="TxtPre" value=""/>
<input name="TxtHora" type="hidden" id="TxtHora" value="0" />
<input name="TxtHoraC" type="hidden" id="TxtHoraC" value="0" />
<input name="TxtRuc_" type="hidden" id="TxtRuc_"  value=""/> 
<!--FIN_OCULTOS-------------------------------->

<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_TxtCod" type="hidden" id="Pro_TxtCod" value=""/>
<input name="Pro_TxtMarca" type="hidden" id="Pro_TxtMarca" value=""/>
<input name="Pro_TxtPre" type="hidden" id="Pro_TxtPre" value=""/>
</div>

<style type="text/css">
.gr1{
	visibility: hidden; 
	overflow-x: hidden; 
	position: absolute; 
	overflow-y: scroll; 
	color: #0FF; 
	background-color: #FFFFFF; 
	layer-background-color: #CCCCCC; 
	border: 1px none #000000;		
}
.gr2{
	visibility: hidden; 
	height: 20px; 
	width: 1180px; 
	position: absolute; 
	left: 34px; 
	top: 256px; 
	color: #0FF; 
	overflow-y: scroll; 
	background-color: #CCCCCC; 
	layer-background-color: #CCCCCC; 
	border: 1px none #000000;	
}
</style>
<div id="TAB_AJAX" class="datagrid gr1" style="height:202px;width:1180px;position:absolute;left:34px;top:275px;" align="left"></div>

<div id="TAB_CAPTION" class="datagrid gr2" style="height: 20px; width: 1180px; position: absolute; left: 34px; top: 256px;border: 1px none #000000;" align="left">
<table width="1080" border="1" cellpadding="0" cellspacing="0" bgcolor="#d4e3e5" class="estilo888">   
<tr height="10 px">
<td width="80" bgcolor="#CCCCCC">CODIGO</td>
<td width="180" bgcolor="#CCCCCC">TIPO DE PRODUCTO</td>
<td width="415" bgcolor="#CCCCCC">DESCRIPCION</td>
<td width="120" 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:absolute; top:0px; left:1120px">
<input name="CmdClose" type="button" value="Cerrar" onClick="CerrarDIV();" style="background-color:#F90" /></div>
</table>
</div>

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