<?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;
}
//++++++++++
$IdU=vbval($_SESSION['SYS_USER_ID']);
$PRO_ID_ALM=gn("pro_id_alm","usuarios","id_usuario=$IdU");
//
$DOC_DESC="";
//
$CE_GEN="N";
$CE_TIP_GIA="";
$CE_COM_REF="";
$CE_USU_KOD=$IdU;
//	
$StrGT="";
$VP_RegXPag=10;
$LStrMsg="";
$LStrFoc="";
$LStrMM="";
$LStrPag=V($_POST['TxtPag']);	
include("guias_fun.php");
include("guias_pdf.php");
///+++++
$StrHWND_G=$_SESSION['SYS_HW']."_G";
$GIA_NL=gn("nl","doc_nl","doc='G'");
$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>Guias</title>
<!--CSS_NEW------------------------------------->
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<!--CSS_NEW------------------------------------->
<?php AddJs();?>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script type="text/javascript" src="fe/guias_domingoxc.js"></script>
<script type="text/javascript" src="fe/leo.js"></script>
<script>
$(document).ready(function(){
   $("#TxtFec").mask("99-99-99");   
   $("#TxtFecT").mask("99-99-99");      
   var StrX=window.location.search;   
   if(jVal(gv("TxtId"))==0){
	   //EM_OC();
	   //EM_OC_Z();
   }
   if(StrX.indexOf("TxtAc=X")>0 || jL(StrX)==0){
	   fPartida();
   }
   var ce_gen=gv("CE_GEN");
   if(ce_gen=="S"){
	   document.getElementById("CmdG").disabled=true;
	   document.getElementById("CmdFE").disabled=true;
	   //document.getElementById("CmdA").disabled=true;
	   document.getElementById("CmdE").disabled=true;	   
   }
});

function O_Z2(){	
	var hw=gv("TxtHW");
	Ow('ventas_clientes_buscar.php?W=G&Z=2&HW='+hw,800*ZO(),600*ZO());
}
</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);
}
//
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(fValEE()){
		if(Verificar()==1){		
			document.getElementById("TxtAc").value="KCH";
			document.getElementById("Frm").submit();	
		}
	}
}
//
</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:900px;
	height:900px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-450px";?> 0 0 <?php echo "-450px";?>;
}
#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}
.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();">
  <div Id="DivFRM"  class="centrarFrm"  >

<form id="Frm" name="Frm" method="post" action="guias.php" autocomplete="off">
<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: 13px; top: 85px; width: 1100px; height: 30px;">

<input name="CmdB" type="button" id="CmdG"
<?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="25"/>
<input name="CmdB" type="button" id="CmdC" 
value="Nuevo" onclick="fCancelarPHP();"  tabindex="26"/>

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

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

<input name="CmdB" type="button" id="CmdIC" 
value="Imprimir" 
onclick="flIMPRIMIR_AHORA();"
<?php
if(strlen($StrId)==0){
	echo "disabled=\"disabled\"";
}else{
	$StrAnu=gs("anu","guias","id_guia=$StrId");
	if($StrAnu=="S"){
		echo "disabled=\"disabled\"";
	}
}
?>

tabindex="37"/>


<input name="CmdSticker" type="button" id="CmdSticker" 
value="Sticker" 
onclick="flIMPRIMIR_STICKER();"
<?php
if(strlen($StrId)==0){
	echo "disabled=\"disabled\"";
}else{
	$StrAnu=gs("anu","guias","id_guia=$StrId");
	if($StrAnu=="S"){
		echo "disabled=\"disabled\"";
	}
}
?>

tabindex="37"/>

<script>

function flIMPRIMIR_STICKER(){
	var id=gv("TxtId");
	var gen=gv("CE_GEN");
	if(jVal(id)==0){
		alert("No se puede determinar el id del registro activo");
		return ;
	}
	if(gen=="N"){
		alert("El presente comprobante aun no ha sido generado");
		return ;
	}
	//
	var d=FE_AX("GIA_IMPRIMIR_VALIDAR",id);
	var r=d.split("|");
	if(r[1]=="OK"){
		document.getElementById("LNK_PRINTERX").click();
	}else{
		if(r[1]=="MS"){
			alert(r[2]);
		}else{
			alert("Error de conexion");
		}
	}
	//
	
}


function flIMPRIMIR_AHORA(){
	var id=gv("TxtId");
	var gen=gv("CE_GEN");
	if(jVal(id)==0){
		alert("No se puede determinar el id del registro activo");
		return ;
	}
	if(gen=="N"){
		alert("El presente comprobante aun no ha sido generado");
		return ;
	}
	//
	var d=FE_AX("GIA_IMPRIMIR_VALIDAR",id);
	var r=d.split("|");
	if(r[1]=="OK"){
		document.getElementById("LNK_PRINTER").click();
	}else{
		if(r[1]=="MS"){
			alert(r[2]);
		}else{
			alert("Error de conexion");
		}
	}
	//
	
}
function FE_AX(CMD,P01,P02,P03,P04,P05,P06,P07,P08,P09,P10){
	var s="?CMD="+CMD;
	if(P01!=undefined)s=s+"&P01="+P01;
	if(P02!=undefined)s=s+"&P02="+P02;
	if(P03!=undefined)s=s+"&P03="+P03;
	if(P04!=undefined)s=s+"&P04="+P04;
	if(P05!=undefined)s=s+"&P05="+P05;
	if(P06!=undefined)s=s+"&P06="+P06;
	if(P07!=undefined)s=s+"&P07="+P07;
	if(P08!=undefined)s=s+"&P08="+P08;
	if(P09!=undefined)s=s+"&P09="+P09;
	if(P10!=undefined)s=s+"&P10="+P10;	
	//
	var php="fe_funciones.php"+s;
	//var u="http://localhost/donato/"+php;
	//prompt(u,u);
	ajax=CreateAJAX();
	ajax.open("GET",php,false);	
	ajax.send(null);
	var StrHtml=ajax.responseText;
	return StrHtml.trim();
}
</script>
<a id="LNK_PRINTER" style="display:none"  href="LQGRE://GRE-<?php echo vbval($StrId);?>">PLEASE RUN MS Access exe file</a>
<a id="LNK_PRINTERX" style="display:none"  href="LQGREX://GRE-<?php echo vbval($StrId);?>">PLEASE RUN MS Access exe file</a>
<input name="CmdB" type="button" id="CmdA" value="Anular" onclick="flAnular();"
<?php
	if(strlen($StrId)==0){
		echo "disabled=\"disabled\"";
	}else{
		$StrAnu=gs("anu","guias","id_guia=$StrId");
		if($StrAnu=="S"){
			echo "disabled=\"disabled\"";
		}
	}
?>
		tabindex="28"/>
        
<input name="CmdB" type="button" id="CmdE" 
value="Eliminar" onclick="flEliminar();"
<?php
if(strlen($StrId)==0){
	echo "disabled=\"disabled\"";
}else{
	$StrAnu=gs("anu","guias","id_guia=$StrId");
	if($StrAnu=="S"){
		echo "disabled=\"disabled\"";
	}
}
?>
tabindex="29"/>

<input name="CmdB" type="button" id="CmdB" 
value="Buscar" onclick="fBuscar('guias_buscar.php');"  tabindex="30"/>
<input name="CmdB" type="button" id="CmdB" 
value="Buscar det" onclick="fBuscar('guias_buscar_det.php');"  tabindex="30"/>

<input name="CmdPDF" type="button" id="CmdPDF" 
value="Generar PDF" onclick="fGenPDF();" style="display:none"
		<?php
		if(strlen($StrId)==0){
			echo "disabled=\"disabled\"";
		}else{
			$StrAnu=gs("anu","transferencias","id_trans=$StrId");
			if($StrAnu=="S"){
				echo "disabled=\"disabled\"";
			}
		}
		?>
 />

        <input name="CmdB" type="button" id="CmdZ" 
        value="Menu" onclick="fBuscar('menu.php');"  tabindex="31"/>
        
        <input name="CmdXX" type="button" id="CmdXX"  style="background-color:#FC9"
        value="Re-Generar" onclick="fRegenerar()"  tabindex="21"/>
</div>
<script>
function fRegenerar(){
	var kod=gv("TxtId");
	var gen=gv("CE_GEN");
	if(jVal(kod)==0){
		alert("No se puede determinar el id del registro activo, seleccione o active un registro");
		return;
	}
	if(gen=="S"){
		var ar=FE_AX("GIA_PARSE",kod);
		ar=ar.split("|");
		if(ar[1]=="MS"){
			alert(ar[2]);
		}else{
			alert("Error de conexion");
		}
	}else{
		alert("La guia aun no ha sido generada");
		return;
	}
}
</script>
<div class="s1" style="position:absolute; left: 29px; top: 648px; width: 847px; height: 198px; overflow:auto">

<table width="846" height="19" border="1" cellpadding="0" cellspacing="0">
<tr class="Estilo5">
<td width="30" bgcolor="#999999" >Nro</td>
<td width="100" bgcolor="#999999" >CODIGO</td>
<td width="334" bgcolor="#999999">DESCRIPCION</td>
<td width="185" bgcolor="#999999">LINEA</td>
<td width="60" bgcolor="#999999" align="right">CANT</td>
<td width="41" bgcolor="#999999" align="right">PIEZAS</td>
<td width="33" bgcolor="#999999" align="center">&nbsp;</td>
<td width="19" bgcolor="#999999" align="center">&nbsp;</td>
<td width="24" 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;
	$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;
	$TOT_NL=0;
	$_IT=0;
	while ($row = $result->fetch_row()){
		$TOT_NL++;
		$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_IM=$row[4];	
		$X_CAU=$row[8];	
		$X_IMPORTE=$X_IMPORTE+$X_IM;
		$CH="ZH".vbr("00000".$row[5],5);		
		$_IT++;
?>
    <tr class="Estilo5">
    <td width="30" bgcolor="#FFFFFF"><?php echo $_IT;?></td>
    <td width="100" bgcolor="#FFFFFF"><?php echo $X_CO.$SEPARADOR.$X_CAU;?></td>
    <td width="334" bgcolor="#FFFFFF"><?php echo $X_DE;?></td>
    <td width="185" bgcolor="#FFFFFF"><?php echo $X_MA;?></td>
    <td width="60" bgcolor="#FFFFFF" align="right"><?php echo $X_CA;?></td>
    <td width="41" bgcolor="#FFFFFF" align="right"><?php echo $X_CAU;?></td>
    <td width="33" 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>
    <td width="19" 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="24" bgcolor="#FFFFFF" align="center">
	<input name="<?php echo $CH;?>" id="<?php echo $CH;?>" type="checkbox" value="" />
	</td>
    </tr>	
<?php
	}		
?>
<tr class="Estilo5">
	<td width="30" bgcolor="#FFFFFF"></td>
    <td width="100" bgcolor="#FFFFFF"></td>
    <td width="334" bgcolor="#FFFFFF"></td>
    <td width="185" bgcolor="#FFFFFF">TOT. CAJAS</td>
    <td width="60" bgcolor="#FFFFFF" align="right"><?php echo $TOT_CA;?></td>
    <td width="41" bgcolor="#FFFFFF" align="right"></td>
    <td width="33" bgcolor="#FFFFFF" align="center">&nbsp;</td>
    <td width="19" bgcolor="#FFFFFF" align="center">&nbsp;</td>
     <td width="24" bgcolor="#FFFFFF" align="center">&nbsp;</td>
    </tr>	
<tr>
<td colspan="9" bgcolor="#999999">&nbsp;</td>
</tr>
</table>
</div>



<div class="s1" style="left: 29px; top:848px; width: 133px;">
OBSERVACION
</div>
<input name="Obs" type="text" id="Obs"
tabindex="22"  
style="left: 29px; top: 871px; width: 630px;"
value="<?php echo $Obs;?>" maxlength="255"
/>


<div class="s1" style="left: 671px; top:848px; width: 133px;">
PESO BRUTO TOTAL
</div>
<input name="Peso" type="text" id="Peso"
tabindex="22"  
style="left: 671px; top: 871px; width: 96px;"
value="<?php echo $Peso;?>" maxlength="6"
/>


<div class="s1" style="left: 779px; top: 872px; width: 99px;">
KILOGRAMOS
</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="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
<input name="TxtAc" type="hidden" id="TxtAc" value="" />

<input name="TxtGIA_NL" type="hidden" id="TxtGIA_NL" value="<?php echo $GIA_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");?>"/>        
<strong style="color:#000">GUIAS</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;?>"/>
</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: 900px; 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:29px; top: 180px; width: 116px;">TIPO DE GUIA
</div>
<select name="TipGia" id="TipGia" 
style="position:absolute; left:29px; top:202px; width: 205px;" 
onkeydown="return SoloTextoEx(event,'CboEmp');"
tabindex="1">
<?php 
	echo FCBO("com_nombre","comprobantes","id_comprobante IN (7,8)",$TipGia,"N","S");
?>
</select>



<div class="s1" style="left:242px; top: 180px; width: 116px;">EMPRESA
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:245px; top:202px; width: 117px;" 
onchange="EM_OC();fPartida();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="2">
<?php 
	if($PRO_ID_ALM==0){
		echo LE($StrEmp,"N","N");
	}else{
		echo "<option value=\"$StrEmp\" selected>$StrEmp</option>";
	}
?>
</select>

<div class="s1" style="left: 371px; top: 180px; width: 79px;"> ALMACEN
</div>
<select name="CboAlm" id="CboAlm" 
style="left: 370px; top: 202px; width: 127px;"  onchange="fPartida();"
onkeydown="return SoloTextoEx(event,'TxtSer');" tabindex="3">
<?php 	
	//if($PRO_ID_ALM==0){
		echo LA($StrEmp,$StrAlm,"N","N"); 
	//}else{
	//	echo "<option value=\"$StrAlm\" selected>$StrAlm</option>";
	//}	
?>
</select>

<div class="s1" style="left: 508px; top: 180px; width: 60px;">
SERIE
</div>
<input name="TxtSer" type="text" id="TxtSer" 
style="left: 508px; top: 202px; width: 58px;" 
tabindex="4"  onblur="_S(this);"
onkeydown="return SoloEnterosEx(this,event,'TxtNum');" 
value="<?php echo $StrSer;?>" maxlength="4" />

<div class="s1" style="left: 577px; top: 180px; width: 68px;">
NUMERO
</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="left: 577px; top: 202px; width: 77px;" 
tabindex="5"   onblur="_N(this);"
onkeydown="return SoloEnterosEx(this,event,'TxtFec');" 
value="<?php echo $StrNum;?>" maxlength="5" />

<div class="s1" style="left: 666px; top: 162px; width: 91px;">
FEC. EMISION
</div>
<div class="EV" style="left: 666px; top: 181px; width: 102px; color:#FF0">
<u><a onclick="fFecServer('TxtFec')">(dd-mm-yy) +</a></u></div>
<input name="TxtFec" type="text" id="TxtFec" 
style="left: 666px; top: 202px; width:95px;" 
value="<?php echo $StrFec;?>"  
onkeydown="return SoloFec(this,event,'TxtFecT');" 
tabindex="6" />

<div class="s1" style="left: 773px; top: 163px; width: 98px;">
FEC. TRASLADO
</div>
<div class="EV" style="left: 773px; top: 181px; width: 90px; color:#FF0">
<u><a onclick="fFecServer('TxtFecT')">(dd-mm-yy) +</a></u></div>
<input name="TxtFecT" type="text" id="TxtFecT" 
style="left: 772px; top: 201px; width: 95px;" 
value="<?php echo $StrFecT;?>"  
onkeydown="return SoloFec(this,event,'TxtPar');" 
tabindex="7" />

<div class="s1" style="left: 29px; top: 231px; width: 160px; height: 19px;">
PUNTO DE PARTIDA
</div>
<input name="TxtPar" type="text" id="TxtPar" 
style="left: 29px; top: 249px; width: 845px;" 
value="<?php echo $StrPar;?>"   maxlength="100"
onkeydown="return SoloTextoEx(event,'Mot');"  
tabindex="8" />



<div class="s1" style="left:29px; top: 281px; width: 148px;">
MOTIVO DE TRASLADO
</div>

<select name="Mot" id="Mot" 
style="left: 29px; top: 301px; width: 136px;" 
onkeydown="return SoloTextoEx(event,'TxtDesRs');" 
tabindex="9" >
<?php
	echo FCBOO("mot_des","gdr_motivos","id_mot>0 AND mot_lis=1 AND mot_des IN ('VENTA','OTROS','CONSIGNACION')",$Mot,"N","S","id_mot");

?>
</select>

<div class="s1" style="left: 172px; top: 281px; width: 199px;">
RAZON SOCIAL DESTINATARIO
</div>
<input name="TxtDesRs" type="text" id="TxtDesRs" 
style="left: 172px; top: 301px; width: 391px;" 
value="<?php echo $StrDesRs;?>"  
onkeydown="return SoloTextoEx(event,'TxtDesRuc');"  
tabindex="10" />

<input type="button" name="CmdSelCli" 
id="CmdSelCli" value="..." onclick="O_Z2();" 
style="position:absolute; left: 574px; top: 301px; width: 33px;" />

<div class="s1" style="left: 614px; top: 281px; width: 121px;">
RUC DESTINARIO
</div>
<input name="TxtDesRuc" type="text" id="TxtDesRuc" 
style="position:absolute; left: 614px; top: 301px; width: 125px;" 
value="<?php echo $StrDesRuc;?>"  
onkeydown="return SoloNum(this,event,'TxtDesDNI');" 
tabindex="8" maxlength="11"/>

<div class="s1" style="left: 753px; top: 281px; width: 123px;">
DNI DESTINATARIO
</div>
<input name="TxtDesDNI" type="text" id="TxtDesDNI" 
style="position:absolute; left: 750px; top: 301px; width: 126px;" 
value="<?php echo $StrDesDNI;?>"  
onkeydown="return SoloNum(this,event,'TxtDesDir');" 
tabindex="9" maxlength="20"/>

<div class="s1" style="left: 29px; top: 337px; width: 188px; height: 16px;">
PUNTO DE LLEGADA
</div>
<input name="TxtDesDir" type="text" id="TxtDesDir" 
style="left: 29px; top: 355px; width: 259px;" 
value="<?php echo $StrDesDir;?>"  
onkeydown="return SoloTextoEx(event,'UbiPai');"  
tabindex="13" />

<input type="button" name="CmdSelSuc" 
id="CmdSelSuc" value="..." onclick="fSelSuc();" 
style="position:absolute; left: 297px; top: 355px; width: 32px;" />

<?php
if(strlen($UbiPai)==0)$UbiPai="PERU";
?>
<div class="s1" style="left: 342px; top: 337px; width: 65px;">
PAIS</div>
<select name="UbiPai" id="UbiPai" 
class="lt" style="left: 339px; top: 355px; width: 87px;" 
onkeydown="return SoloTextoEx(event,'TipTra');" 
onChange="ClsUbi();"  tabindex="14">
<?php
echo FCBO("pai_nom","lista_paises","id_pais>0",$UbiPai,"N","S");
?>
</select>

<div class="s1" style="left: 438px; top: 337px;">
DEPARTAMENTO</div>
<input name="UbiDep" type="text" id="UbiDep" 
style="left: 438px; top: 355px; width: 106px; background-color:#CCC"  
readonly="readonly"
value="<?php echo $UbiDep;?>"/>

<div class="s1" style="left: 554px; top: 337px;">
PROVINCIA</div>
<input name="UbiPro" type="text" id="UbiPro" 
class="roi" style="left: 554px; top: 355px; width: 74px; background-color:#CCC"  
readonly="readonly"
value="<?php echo $UbiPro;?>"/>

<div class="s1" style="left: 643px; top: 337px;">
DISTRITO</div>
<input name="UbiDis" type="text" id="UbiDis" 
class="roi" style="left: 641px; top: 355px; width: 83px; background-color:#CCC" 
readonly="readonly"
value="<?php echo $UbiDis;?>"/>

<input type="button" name="CmdUbi" id="CmdUbi" 
value="..." 
onClick="SelUbi();" 
style="position: absolute; left: 732px; top: 355px; width: 34px;"
/>

<input type="button" name="CmdLim" id="CmdLim" 
value="<< Lima" 
onClick="SetLima();" 
style="position: absolute; left: 771px; top: 355px; width: 72px;"
/>

<input type="button" name="CmdUbiX" id="CmdUbiX" 
value="X" 
onClick="ClsUbi();" 
style="position: absolute; left: 850px; top: 355px; width: 29px;"
/>


<div class="s1" style="left:29px; top: 386px; width: 113px;">
TIPO TRANSPORTISTA
</div>
<select name="TipTra" id="TipTra" 
style="left: 29px; top: 423px; width: 133px;" 
onkeydown="return SoloTextoEx(event,'TxtETRs');" 
tabindex="15" >
<?php
	echo FCBOO("au_item","auxiliar","au_tab='GIA_TIP_TRANSPORTE' ",$TipTra,"N","S","au_orden");
?>
</select>

<div class="s1" style="left: 177px; top: 402px; width: 398px;">
EMPRESA DE TRANSPORTE
</div>
<input name="TxtETRs" type="text" id="TxtETRs" 
style="position:absolute; left: 177px; top: 423px; width: 502px;" 
value="<?php echo $StrETRs;?>"  
onkeydown="return SoloTextoEx(event,'TxtETRuc');"  
tabindex="16" />

<div class="s1" style="left: 695px; top: 402px; width: 150px;">
EMP. TRANS. RUC.
</div>
<input name="TxtETRuc" type="text" id="TxtETRuc" 
style="position:absolute; left: 698px; top: 423px; width: 125px;" 
value="<?php echo $StrETRuc;?>"  
onkeydown="return SoloTextoEx(event,'TipDoc');"  
tabindex="17" maxlength="11"/>

<input type="button" name="CmdRuc" id="CmdRuc" 
value="<<<" 
onClick="fxRuc64();" 
style="position: absolute; left: 836px; top: 423px; width: 41px;"
/>

<script>
function fGetRuc24(){
	var ruc=gv("TxtETRuc");
	if(jL(ruc)==0){
		return AF("Ingrese un numero de ruc","TxtETRuc");
	}
	if(jL(ruc)!=11){
		return AF("Ingrese un numero de ruc debe tener 11 digitos","TxtETRuc");
	}
	sv("TxtETRs","");
	var r=AX("GET_RUC",ruc);
	var d=r.split("|");
	if(d[0]=="OK"){
		sv("TxtETRs",d[1]);
	}else{
		if(d[0]=="MS"){
			alert(d[1]);
		}else{
			alert("Error de conexion");
		}
	}
}
function AX64(C,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,
			  P11,P12,P13,P14,P15,P16,P17,P18,P19,
			  P20,P21,P22,P23,P24,P25,P26,P27,P28,P29,P30){
	var s="?CM="+C;
	if(P1!=undefined)s=s+"&P1="+P1;
	if(P2!=undefined)s=s+"&P2="+P2;
	if(P3!=undefined)s=s+"&P3="+P3;
	if(P4!=undefined)s=s+"&P4="+P4;
	if(P5!=undefined)s=s+"&P5="+P5;
	if(P6!=undefined)s=s+"&P6="+P6;
	if(P7!=undefined)s=s+"&P7="+P7;
	if(P8!=undefined)s=s+"&P8="+P8;
	if(P9!=undefined)s=s+"&P9="+P9;	
	//
	var php="sis_ajax.php"+s;
	//prompt(php,php);
	ajax=CreateAJAX();
	ajax.open("GET",php,false);	
	ajax.send(null);	
	var StrHtml=ajax.responseText;
	return StrHtml.trim();
}

function fxRuc64(){
	var r=gv("TxtETRuc");
	if(jL(r)!=11){
		alert("El numero de ruc debe tener 11 digitos");
		return;
	}
	var dat=AX64("GET_RUC",r);
	var bat=dat.split("|");
	if(bat[1]=="OK"){
		sv("TxtETRs",bat[3]);	
	}else{
		if(bat[1]=="MS"){
			alert(bat[2]);
		}else{
			alert("Error de conexion");
		}
	}
	
}

</script>

<div class="s1" style="left: 29px; top: 455px; width: 116px">
TIPO DE DOC. DE IDENTIDAD</div>
<select name="TipDoc" id="TipDoc" tabindex="18"
class="lt" 
onkeydown="return SoloTextoEx(event,'ChoDni');"
style="left: 29px; top: 488px; width: 137px;" >
<?php
echo FCBO("des","sunat_catalogos","cat='TIP_DOC'",$TipDoc,"N","S");
?>
</select>

<div class="s1" style="position:absolute; left: 180px; top: 454px; width: 113px;"> Nro DOC. DE IDENTIDAD
</div>
<input name="ChoDni" type="text" id="ChoDni" 
style="position:absolute; left: 180px; top: 488px; width: 97px;" 
value="<?php echo $ChoDni;?>"  
onkeydown="return SoloTextoEx(event,'ChoNom');"           
tabindex="19" />

<div class="s1" style="position:absolute; left: 290px; top: 468px; width: 82px;"> NOMBRES
</div>
<input name="ChoNom" type="text" id="ChoNom" 
style="position:absolute; left: 290px; top: 488px; width: 90px;" 
value="<?php echo $ChoNom;?>"  
onkeydown="return SoloTextoEx(event,'ChoApe');"           
tabindex="20" />

<div class="s1" style="position:absolute; left: 392px; top: 468px; width: 86px;"> APELLIDOS
</div>
<input name="ChoApe" type="text" id="ChoApe" 
style="position:absolute; left: 392px; top: 488px; width: 104px;" 
value="<?php echo $ChoApe;?>"  
onkeydown="return SoloTextoEx(event,'TxtLic');"           
tabindex="21" />


<div class="s1" style="position:absolute; left: 507px; top: 456px; width: 110px;"> Nro DE LICENCIA DE CONDUCIR
</div>
<input name="TxtLic" type="text" id="TxtLic" 
style="position:absolute; left: 506px; top: 489px; width: 110px;" 
value="<?php echo $StrLic;?>"   maxlength="10"
onkeydown="return SoloTextoEx(event,'TxtMarca');"           
tabindex="22" />


<div class="s1" style="left: 627px; top: 470px; width: 90px;">
MARCA
</div>
<input name="TxtMarca" type="text" id="TxtMarca" 
style="position:absolute; left: 627px; top: 489px; width: 61px;" 
value="<?php echo $StrMarca;?>"  
onkeydown="return SoloTextoEx(event,'TxtPlaca');"            
tabindex="23" />


<div class="s1" style="left: 698px; top: 470px; width: 57px;">
PLACA
</div>
<input name="TxtPlaca" type="text" id="TxtPlaca" 
style="position:absolute; left: 698px; top: 489px; width: 59px;" 
value="<?php echo $StrPlaca;?>"  
onkeydown="return SoloTextoEx(event,'TxtCons');"  
tabindex="24" />

<div class="s1" style="position:absolute; left: 767px; top: 455px; width: 120px;">
CERTIFICADO. DE INSCRIPCION N&ordm;</div>
<input name="TxtCons" type="text" id="TxtCons" 
style="position:absolute; left: 767px; top: 489px; width: 111px;" 
value="<?php echo $StrCons;?>"  
onkeydown="return SoloTextoEx(event,'CboTraPro');"  
tabindex="25" />

<input type="button" name="CmdSel" id="CmdSel" value="Trasformaciones" 
onClick="Ow('transformaciones_2.php',905*ZO(),390*ZO());" style="display:none;position:absolute; left: 155px; top: 545px; width: 126px;"/>
<?php
if(strlen($TraPro)==0)$TraPro="NO";
?>

<div class="s1" style="left: 29px; top: 520px; width: 204px;">
<b>TRANSBORDO PROGRAMADO</b>
</div>
<select name="TraPro" id="TraPro" tabindex="<?php echo ++$TI;?>"
style="position:absolute; left: 29px; top: 545px; width: 181px;" 
onkeydown="return SoloTextoEx(event,'CboComR');">
<?php
	echo FCBO("au_item","auxiliar","au_tab='SI_NO'",$TraPro,"N","N");
?>
</select>


<div class="s1" style="left: 293px; top: 526px; width: 109px;">
REFERENCIA
</div>

<select name="CboComR" id="CboComR" 
style="left: 292px; top: 545px; width: 126px;" 
onkeydown="return SoloTextoEx(event,'CboEmpR');" 
tabindex="26"  onclick="CboRef();"
>
<?php
if(strlen($DR_NOM)==0){	
	echo FCBO_("com_nombre","comprobantes","",$StrComR,"N","N");
}else{
	echo FCBO_("com_nombre","comprobantes","com_nombre='$DR_NOM'",$DR_NOM,"N","N");
}
?>
</select>

<div class="s1" style="left:426px; top: 526px; width: 100px;">
EMPRESA
</div>
<select name="CboEmpR" id="CboEmpR" 
style="position:absolute; left:426px; top:545px; width: 104px;" 
onkeydown="return SoloTextoEx(event,'TxtSerR');" tabindex="27">

<?php 
	echo FCBO_("emp_nomc","empresas","id_emp>0",$StrEmpR,"N","S");
?>
</select>

<div class="s1" style="left: 540px; top: 526px; width: 48px;">
SERIE
</div>
<input name="TxtSerR" type="text" id="TxtSerR"
tabindex="28" 
style="left: 538px; top: 545px; width: 50px;"
onfocus="selecciona_value(this);"   onblur="_S(this);"
onkeydown="return SoloEnterosEx(this,event,'TxtNumR');" 
<?php if(strlen($DR_NOM)>0){ echo " readonly=\"readonly\" ";}?>
value="<?php echo $StrSerR;?>" size="6" maxlength="4"          
/>


<div class="s1" style="left: 597px; top:526px; width: 64px;">
NUMERO
</div>
<input name="TxtNumR" type="text" id="TxtNumR"
tabindex="29"   onblur="_N(this);"
style="left: 597px; top: 545px; width: 79px;"
onkeydown="return SoloEnterosEx(this,event,'CmdLoad');" 
<?php if(strlen($DR_NOM)>0){ echo " readonly=\"readonly\" ";}?>
value="<?php echo $StrNumR;?>" size="10" maxlength="6"
/>


<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: 688px; top: 545px; width: 183px; height:23px" tabindex="30"
/>


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

<input name="TxtCod" type="text" id="TxtCod" 
style="left: 29px; top: 618px; width: 112px;" 
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="16" />

<div class="s1" style="left: 156px; top: 599px; width: 303px">
DESCRIPCION
</div>
<input name="TxtDes" type="text" id="TxtDes" 
style="left: 155px; top: 618px; 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="17" />

<div class="s1" style="left: 577px; top: 599px; width: 100px;">
LINEA
</div>
<input name="TxtMarcas" type="text" id="TxtMarcas" 
style="left: 576px; top: 618px; 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="17" />



<div class="s1" style="left: 740px; top: 599px; width: 39px;">
CANT
</div>
<input name="TxtCant" type="text" id="TxtCant" 
style="left: 739px; top: 618px; width: 36px; text-align:right" 
value="<?php echo $StrCant;?>"  
onkeydown="return SoloNum(this,event,'TxtCUni');" 
<?php if(strlen($DR_NOM)>0){echo " readonly=\"readonly\" ";	} ?>      
onfocus="selecciona_value(this);"          
tabindex="18" />
<div class="s1" style="left: 782px; top: 599px; width: 39px;">
PIEZAS
</div>
<input name="TxtCUni" type="text" id="TxtCUni" 
style="left: 787px; top: 618px; 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="19" />

<input type="button" name="CmdAdd" 
id="CmdAdd" value="+" onclick="fAgregar();" 
tabindex="19" 
<?php if(strlen($DR_NOM)>0){echo " disabled=\"disabled\" ";	} ?>
style="position:absolute; left: 846px; top: 617px; width: 30px;" />



    <div id="TAB_AJAX" style="visibility: hidden; height:200px; width:859px; overflow-x:hidden; position:absolute; left: 27px; top: 668px; 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: 648px; 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">LINEA</td>
<td width="60" align="right" bgcolor="#CCCCCC">PC DOL</td>
<td width="66" align="right" bgcolor="#CCCCCC">PC SOL</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 align="left" class="s2"
style="position:absolute; left: 643px; top: 110px; width: 178px; height: 25px;">
<input name="Ch_DES" type="checkbox" 
id="Ch_DES" tabindex="10" onchange="fChDesc();"
value="1"
<?php if($Str_DES==1) echo "checked=\"checked\""; ?>
/> 
DESCONTAR STOCK EN :
</div>
<select name="CboEmpZ" id="CboEmpZ" 
style="position:absolute; left:646px; top:131px; width: 108px;" 
onchange="EM_OCD();"
onkeydown="return SoloTextoEx(event,'CboZto');" tabindex="1">
<?php 
	echo FCBO_("emp_nomc","empresas","id_emp>0",$StrEmpZ,"N","S");
?>
</select>

<select name="CboZto" id="CboZto" 
style="position:absolute; left: 759px; top:131px; width: 109px;" 
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="0">
<?php 
	echo FCBO_("ANC","vis_almacenes","IDA>0 AND ENC='$StrEmpZ'",$StrZto,"N","N");
?>
</select>

<div class="s1" style="position:absolute; left: 505px; top: 155px; width: 162px; height: 25px;">

    <input name="ChN_AUTO" type="checkbox" 
        id="ChN_AUTO" tabindex="10"   
        onclick="AutoNumeracion(document.getElementById('ChN_AUTO').checked);" value="1"
        <?php
			if($StrN_AUTO=="1"){
				echo "checked=\"checked\"";
			}
		?>
        />
    NUM. AUTOMATICA
</div>

<div class="s1" style="position:absolute; left: 837px; top: 84px; width: 49px; height: 22px;display:none">
<input name="TxtTC" type="text" id="TxtTC" 
style="width:5px; text-align:right; background-color:#CCC; display:none" />
</div>

<?php
	if(strlen($StrDESCARGAR)>0){
		echo "<div id=\"layer51\" 
			  style=\"position:absolute; left: 545px; top: 113px; 
			  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="CE_GEN" id="CE_GEN" type="hidden" value="<?php echo $CE_GEN;?>" />
<input name="CE_TIP_GIA" id="CE_TIP_GIA" type="hidden" value="<?php echo $CE_TIP_GIA;?>" />
<input name="CE_COM_REF" id="CE_COM_REF" type="hidden" value="<?php echo $CE_COM_REF;?>" />
<input name="CE_USU_KOD" id="CE_USU_KOD" type="hidden" value="<?php echo $CE_USU_KOD;?>" />
<a style="display:none" href="" download id="LnkPDF"></a>
</form>

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