<?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");
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;
}
$TI=0;
//++++
$POL_USU_PER_ELI=USU_PER_GET_EX("ELI_DEV");
//++++
$DOC_DESC="";
//	
$StrGT="";
$VP_RegXPag=10;
$LStrMsg="";
$LStrFoc="";
$LStrMM="";
$LStrPag=V($_POST['TxtPag']);	
include("devolucion_fun.php");
$StrHWND_G=$_SESSION['SYS_HW']."_DEVO";
?>
<!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>Devolucion</title>
<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/devolucion4.js"></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");   
   //
   var pol_usu_per_eli=gv("POL_USU_PER_ELI");
   if(jVal(pol_usu_per_eli)==0){
	   document.getElementById("CmdE").disabled=true;
   }    
});
</script>
<script>
var myVar=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>


<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<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:1000px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-500px";?>;
}
#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;
}
.s22 { 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}
.Estilo5 {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;
}

-->
</style>

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

<form id="Frm" name="Frm" method="post" action="devolucion.php" autocomplete="off">
<input type="hidden" id="DR_NOM" value="<?php echo $DR_NOM;?>" name="DR_NOM"  />
<center> 
<div Id="DivFRM"  class="centrarFrm"  >
<div class="s1" style="position:absolute; left: 26px; top: 296px; width: 946px; height: 424px;">

<table width="947" height="57" border="1" cellpadding="0" cellspacing="0">
<tr class="Estilo5">
<td width="34" bgcolor="#999999">Nº</td>
<td width="112" bgcolor="#999999">CODIGO</td>
<td width="450" bgcolor="#999999">DESCRIPCION</td>
<td width="119" bgcolor="#999999">LINEA</td>
<td width="36" bgcolor="#999999" align="right">CANT</td>
<td width="41" bgcolor="#999999" align="right">PIEZAS</td>
<td width="46" bgcolor="#999999" align="right">PRECIO</td>
<td width="53" bgcolor="#999999" align="right">IMPORTE</td>
<td width="15" bgcolor="#999999" align="center">&nbsp;</td>
<td width="19" bgcolor="#999999" align="center">&nbsp;</td>
</tr>
<?php
$TOT_CA=0;
$SEPARADOR=gs("aux_des","auxiliares","aux_tip='SIM'");
if(strlen($SEPARADOR)==0){$SEPARADOR="-";}
//
$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;
$_IT=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("LINEA","vproductos","ID=$X_ID"));
$X_CA=$row[2];	
$TOT_CA=$TOT_CA+$X_CA;
$X_PR=$row[3];	
$X_CAU=$row[8];	
$X_IM=round($row[4],2);	
$X_IMPORTE=$X_IMPORTE+$X_IM;
$_IT++;
echo "<tr class=\"Estilo5\">";
echo "<td width=\"85\" bgcolor=\"#FFFFFF\">".$_IT."</td>";
echo "<td width=\"85\" bgcolor=\"#FFFFFF\">".$X_CO.$SEPARADOR.$X_CAU."</td>";
echo "<td width=\"549\" bgcolor=\"#FFFFFF\">$X_DE</td>";
echo "<td width=\"143\" bgcolor=\"#FFFFFF\">$X_MA</td>";
echo "<td width=\"38\" bgcolor=\"#FFFFFF\" align=\"right\">$X_CA</td>";
echo "<td width=\"38\" bgcolor=\"#FFFFFF\" align=\"right\">$X_CAU</td>";
echo "<td width=\"38\" bgcolor=\"#FFFFFF\" align=\"right\">$X_PR</td>";
echo "<td width=\"38\" bgcolor=\"#FFFFFF\" align=\"right\">".NF2($X_IM,2)."</td>";
echo "<td width=\"19\" bgcolor=\"#FFFFFF\" align=\"center\">";
echo "<a href=\"javascript:void(0)\" onclick=\"fKiller('$row[5]');\" >";
echo "<img src=\"img/eliminar.png\" width=\"16\" height=\"16\" />";
echo "</a>";
echo "</td>";
echo "<td width=\"15\" bgcolor=\"#FFFFFF\" align=\"center\">";
echo "<a href=\"javascript:void(0)\" onclick=\"fEditar('$row[5]');\" >";
echo "<img src=\"img/b_edit.png\"  border=\"0\"/>";
echo "</a>";
echo "</td>";
echo "</tr>";	
}		
?>

<tr class="Estilo5">
<td colspan="7" bgcolor="#999999" align="right" >
<table width="100%" border="0">
  <tr>
    <td width="75%" align="right">TOT. CAJAS : <?php echo $TOT_CA ;?></td>
    <td width="9%">&nbsp;</td>
    <td width="16%" align="right">TOTAL</td>
  </tr>
</table>
</td>
<td bgcolor="#999999" align="right"><?php echo NF2($X_IMPORTE,2);?></td>
<td bgcolor="#999999">&nbsp;</td>
<td bgcolor="#999999">&nbsp;</td>
</tr>
<tr>
  <td colspan="10" bgcolor="#999999">&nbsp;</td>
</tr>
</table>
</div>

<div id="DivP" class="s1" style="visibility:hidden; position:absolute; left: 349px; top: 115px; width: 90px;
background-color: #FFCC00; layer-background-color: #FFCC00; font-weight:bold; text-align:center;">Descarga</div>

<div id="layer" style="position:absolute; left: 116px; top: 21px; width: 412px; height: 45px; z-index: 100;">
<div align="left" class="Estilo1">
<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_G;?>"/>

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

<input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
<input name="TxtAc" type="hidden" id="TxtAc" 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; ?>"   />   

<strong>DEVOLUCION </strong></div>

<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 $Pro_Des;?>"/>
<input name="Pro_TxtPre" type="hidden" id="Pro_TxtPre" value="<?php echo $Pro_Pre;?>"/>
<input name="Pro_TxtCod" type="hidden" id="Pro_TxtCod" value="<?php echo $Pro_Cod;?>"/>
<input name="Pro_TxtMarca" type="hidden" id="Pro_TxtMarca" value="<?php echo $Pro_Marca;?>"/>
<input name="FEC_SERVER" type="hidden" id="FEC_SERVER" value="<?php echo date("d-m-y");?>"/>  
</div>
    </div>

    <div id="LblTit" style="position:absolute; left: 52px; top: 15px; width: 64px; z-index: 100;">
      <div align="left" class="Estilo1">
      <img src="img/guias.png" width="64" height="53" / onclick="fGetProdDatos_Id('2');"></div>
</div>
    <div id="layer8" style="position:absolute; left: 0px; top: 0px; width: 1000px; height: 79px; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000; z-index: 0;">
      <div align="left" class="Estilo1">        
      </div>
</div>


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

<div class="s1" style="left: 158px; top: 146px; width: 111px;">
PUNTO DE RECEPCION</div>
<select name="CboAlm" id="CboAlm" 
style="left: 158px; top: 181px; width: 111px;" 
onkeydown="return SoloTextoEx(event,'TxtNum');" tabindex="<?php echo ++$TI;?>">
<?php 
	echo LA_ALMACEN($StrEmp,$StrAlm,"N","N");
?>
</select>

<div class="s1" style="position:absolute; left: 280px; top: 126px; width: 162px; height: 25px;">
<input name="ChN_AUTO" type="checkbox" 
id="ChN_AUTO" tabindex="<?php echo ++$TI;?>"   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: 280px; top: 163px; width: 80px;">
NUMERO</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="left: 280px; top: 181px; width: 73px;" 
value="<?php echo $StrNum;?>"  
onkeydown="return SoloEnterosEx(this,event,'TxtFec');" 
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 364px; top: 148px; width: 91px;">
FECHA
</div>
<div class="EV" style="left: 364px; top: 165px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtFec')">(dd-mm-yy) +</a></u></div>
<input name="TxtFec" type="text" id="TxtFec" 
style="left: 363px; top: 181px; width: 64px;" 
value="<?php echo $StrFec;?>"  
onkeydown="return SoloFec(this,event,'CboCom');" 
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 439px; top: 163px; width: 108px;">
COMPROBANTE
</div>
<select name="CboCom" id="CboCom" 
style="left: 438px; top: 181px; width: 111px;" 
onkeydown="return SoloTextoEx(event,'TxtSerR');"
tabindex="<?php echo ++$TI;?>">
<?php
if(strlen($DR_NOM)==0){
echo FCBO_("com_nombre","comprobantes",
		  "com_nombre IN ('FACTURA','BOLETA','PROFORMA','FACT. ELEC.','BOL. ELEC.')",$StrCom,"N","N");
}else{
echo FCBO_("com_nombre","comprobantes",
		  "com_nombre IN ('$DR_NOM')",$StrCom,"N","N");
	
}
?>
</select>

<div class="s1" style="left: 557px; top: 163px; width: 45px;">
SERIE</div>
<input name="TxtSerR" type="text" id="TxtSerR"
tabindex="<?php echo ++$TI;?>" 
style="left: 556px; top: 181px; width: 45px;"
onfocus="selecciona_value(this);" onblur="_S(this);"
onkeydown="return SoloEnterosEx(this,event,'TxtNumR');" 
value="<?php echo $StrSerR;?>" size="6" maxlength="4"  
<?php
if(strlen($DR_NOM)>0){
	echo " readonly=\"readonly\" ";
}
?>          
/>

<div class="s1" style="left: 613px; top:163px; width: 66px;">
NUMERO</div>
<input name="TxtNumR" type="text" id="TxtNumR"
tabindex="<?php echo ++$TI;?>"    onblur="_N(this);"
style="left: 611px; top: 181px; width: 74px;"
onkeydown="return SoloEnterosEx(this,event,'CmdLoad');" 
value="<?php echo $StrNumR;?>" size="10" maxlength="6"
<?php
if(strlen($DR_NOM)>0){
	echo " readonly=\"readonly\" ";
}
?>
/>
<input type="button" name="CmdLoad" id="CmdLoad"  class="ps"
<?php
	if(strlen($DR_NOM)==0){
		echo " value=\"Cargar referencia\" ";		
	}else{
		echo " value=\"Deshacer referencia\" ";		
	}
?>
onClick="LoadRef();" 
style="left: 696px; top: 181px; width: 162px; height:23px" 
tabindex="<?php echo ++$TI;?>"
/>

<div class="s1" style="left: 866px; top: 163px; width: 83px;">
CLIENTE
</div>
<input name="TxtCli" type="text" id="TxtCli" 
style="left: 866px; top: 181px; width: 98px; background-color:#CCC" 
value="<?php echo $StrCli;?>"   readonly="readonly"
onkeydown="return SoloTextoEx(event,'TxtSerR');"  
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="position:absolute; left: 27px; top: 210px; width: 346px; height: 25px;">
<input name="Ch_DINERO" type="checkbox" 
id="Ch_DINERO" tabindex="<?php echo ++$TI;?>"  value="1"
<?php
if($Str_DINERO=="1"){
	echo "checked=\"checked\"";
}
?>
/>
INCLUYE DEVOLUCION DE DINERO EN EFECTIVO</div>

<div class="s1" style="left: 370px; top: 216px; width: 139px;">
NUMERO DE RECIBO</div>

<input name="TxtRec" type="text" id="TxtRec" 
style="left: 509px; top: 214px; width: 130px" 
value="<?php echo $StrRec;?>" 
onkeydown="return SoloTextoEx(event,'CmdG');"  
tabindex="<?php echo ++$TI;?>" />

<div class="EL" style="left: 26px; top: 244px; width: 84px;">
<u><a onclick="fLimDet()">CODIGO +</a></u></div>

<input name="TxtCod" type="text" id="TxtCod" 
style="left: 26px; top: 262px; width: 118px;" 
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="<?php echo ++$TI;?>"  />
<div class="s1" style="left: 162px; top: 244px; width: 303px">
DESCRIPCION</div>
<input name="TxtDes" type="text" id="TxtDes" 
style="left: 161px; top: 262px; width: 409px;" 
value="<?php echo $StrDes;?>"  
onkeydown="return SoloTextoEx(event,'TxtMarcas');"
onkeyup="document.getElementById('TxtHora').value=GetHora();"
<?php  if (strlen($DR_NOM)>0){ echo "readonly=\"readonly\" "; } ?>
tabindex="<?php echo ++$TI;?>"  />

<div class="s1" style="left: 583px; top: 244px; width: 100px;">
LINEA</div>
<input name="TxtMarcas" type="text" id="TxtMarcas" 
style="left: 582px; top: 262px; width: 151px;" 
value="<?php echo $StrMARCA;?>"  
onkeydown="return SoloTextoEx(event,'TxtCant');"
onkeyup="document.getElementById('TxtHora').value=GetHora();"
<?php  if (strlen($DR_NOM)>0){ echo "readonly=\"readonly\" "; } ?>
tabindex="<?php echo ++$TI;?>"  />

<div class="s1" style="left: 746px; top: 244px; width: 39px;">
CANT</div>
<input name="TxtCant" type="text" id="TxtCant" 
style="left: 745px; top: 262px; width: 36px; text-align:right" 
value="<?php echo $StrCant;?>"  
onkeydown="return SoloNum(this,event,'TxtCUni');"          
onfocus="selecciona_value(this);"         
<?php  if (strlen($DR_NOM)>0){ echo "readonly=\"readonly\" "; } ?> 
tabindex="<?php echo ++$TI;?>"  />

<div class="s1" style="left: 788px; top: 244px; width: 39px;">
PIEZAS</div>
<input name="TxtCUni" type="text" id="TxtCUni" 
style="left: 793px; top: 262px; width: 49px; text-align:right" 
value="<?php echo $StrCUni;?>"  
onkeydown="return SoloNum(this,event,'CmdAdd');"          
onfocus="selecciona_value(this);"    
<?php  if (strlen($DR_NOM)>0){ echo "readonly=\"readonly\" "; } ?>      
tabindex="<?php echo ++$TI;?>"  />

<input type="button" name="CmdAdd" 
id="CmdAdd" value="+" onclick="fAgregar();" 
tabindex="<?php echo ++$TI;?>" 
<?php  if (strlen($DR_NOM)>0){ echo " disabled=\"disabled\" "; } ?>

style="position:absolute; left: 852px; top: 261px; width: 30px;" />

<div id="TAB_AJAX" 
    style="visibility: hidden; height:200px; width:859px; overflow-x:hidden; position:absolute; left: 27px; top: 314px; 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:845px; position:absolute; left:27px; top: 297px; color: #0FF; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000;" align="left">
<table width="760" height="20" border="1" cellpadding="0" cellspacing="0" bgcolor="#d4e3e5" class="estilo888">   
<tr  height="10 px">
<td width="134" bgcolor="#CCCCCC">CODIGO</td>
<td width="364" bgcolor="#CCCCCC">DESCRIPCION</td>
<td width="124" bgcolor="#CCCCCC">MARCA</td>
<td width="60" align="right" bgcolor="#CCCCCC">PC SOL</td>
<td width="66" align="right" bgcolor="#CCCCCC">PC DOL</td>
</tr>  
</table>
<div style="position:absolute; top:0px; left:758px">
<input name="CmdClose" type="button" value="Cerrar" onclick="CerrarDIV();" style="background-color:#F90" />
</div>
</div>

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

<input name="CmdB" type="button" id="CmdG" value="Guardar" 
<?php
if(strlen($StrId)>0){
	echo " disabled=\"disabled\" ";
}
?>
onclick="fGuardar();" style="width:80px" tabindex="<?php echo ++$TI;?>"/>
<input name="CmdB" type="button" id="CmdC" value="Nuevo" 
onclick="fCancelarPHP();"  tabindex="<?php echo ++$TI;?>"/>
<input name="CmdB" type="button" id="CmdA" value="Anular" onclick="flAnular();"
<?php
if(strlen($StrId)==0){
	echo "disabled=\"disabled\"";
}else{
	$StrAnu=gs("gi_anu","ginterna","id_gi=$StrId");
	if($StrAnu=="S"){
		echo "disabled=\"disabled\"";
	}
}
?>
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdB" type="button" id="CmdE" value="Eliminar" 
onclick="flEliminar();"
<?php
if(strlen($StrId)==0){
	echo "disabled=\"disabled\"";
}else{
	$StrAnu=gs("gi_anu","ginterna","id_gi=$StrId");
	if($StrAnu=="S"){
		echo "disabled=\"disabled\"";
	}
}
?>
tabindex="<?php echo ++$TI;?>"/>

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

<input name="CmdIMP" type="button" id="CmdIMP" 
style="width:90px;"  tabindex="<?php echo ++$TI;?>"
<?php
if(strlen($StrId)==0){
	echo "disabled=\"disabled\"";
}
?>
value="Generar PDF" onclick="AjImprimir();"/>

<input name="CmdB" type="button" id="CmdZ" 
value="Menu" onclick="fBuscar('menu.php');"  
tabindex="<?php echo ++$TI;?>"/>
</div>


<div id="layer9" style="position:absolute; left: 801px; top: 84px; width: 85px; height: 22px;">
<div align="left" class="s22">
<input name="TxtTC" type="text" id="TxtTC" 
style="width:5px; text-align:right; background-color:#CCC; visibility:hidden" 
/>
</div>
</div>




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