<!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" />
<?php
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
$KOD=vbval(V($_GET['ID']));//84921;
if($KOD==0){
	echo "Cero parametros recibidos";
	return;
}
$GIA_ID=$KOD;
//
$CX=gn("count(*)","guias","id_guia=$GIA_ID");
if($CX==0){
	echo "Error : Guia no registrada";
	return;
}
$r=gr("guias","id_guia=".$GIA_ID);
$CE_GEN=trim($r['xx_ce_gen']);
if($CE_GEN!="S"){
	echo "*** La guia electronica aun no ha sido generada ***";
	return;
}
//3=FACT. ELEC.
//4=BOL. ELEC.
if($r['id_comr']==3 || $r['id_comr']==4 || $r['id_comr']==-2){
	//TODO OK
}else{
	echo "*** Error : Proceso solo valido para comprobantes electronicos ***";
	return;
}
//
$XX_LINK=trim(gs("xx_link","guias","id_guia=$GIA_ID"));
if(strlen($XX_LINK)==0){
	echo "*** Error : link no generado ***";
	return;
}
//
include("sunat_guia_remision_datos.php");
//
?>
<style type="text/css">
.t_basic{
	padding:0 0 0 0; border:0 0 0 0; border-collapse:collapse;border-spacing: 0px;
}
td{
	vertical-align:top;
}
tr{
	padding:0 0 0 0; border:0 0 0 0;
}
.td_det{
	border: 1px solid; padding-left:0.3rem;
}
.td_det_n{
	border: 1px solid; padding-left:0.3rem; padding-right:0.3rem; text-align:right
}
</style>
<title>GUIA DE REMISION ELECTRONICA</title>
</head>
<body style="font-family:Tahoma, Geneva, sans-serif; font-size:12px">
<center>
<div  style="height:100%; width:850px">
<table width="100%" border="0">
  <tr>
    <td width="1%">&nbsp;</td>
    <td width="98%"><table width="100%" border="0">
      <tr>
        <td width="12%" rowspan="2">
        <img src="https://qrcode.tec-it.com/API/QRCode?data=<?php echo $LINK;?>&size=Small&dpi=150" style="width:150px; height:150px" />
        </td>
        <td width="1%" style="font-size:18px; font-weight:bold">&nbsp;</td>
        <td width="55%" height="110" style="font-size:20px; font-weight:bold"><?php echo $EMP_NOM;?></td>
        <td colspan="3" style="border: 1px solid black" >
        	
            <table width="100%" border="0" style="font-weight:bold; font-size:14px; text-align:center">
            <tr>
            <td align="center">RUC <?php echo $EMP_RUC;?></td>
            </tr>
            <tr>
            <td>GUIA DE REMISION ELECTRONICA</td>
            </tr>
            <tr>
            <td>REMITENTE</td>
            </tr>
            <tr>
            <td>Nro <?php echo $SER_NUM;?></td>
            </tr>
            </table>
        
        </td>
        </tr>
      <tr>
        <td>&nbsp;</td>
        <td height="16">Fecha de emision : <?php echo $FEC_EMI;?></td>
        <td width="18%">&nbsp;</td>
        <td width="2%">&nbsp;</td>
        <td width="12%">&nbsp;</td>
      </tr>
    </table></td>
    <td width="1%">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
    
        <table width="100%" border="0" style="font-size:12px;" cellpadding="0" cellspacing="0">
        <tr>
        <td width="20%">&nbsp;</td>
        <td width="1%">&nbsp;</td>
        <td width="14%">&nbsp;</td>
        <td width="1%">&nbsp;</td>
        <td width="14%">&nbsp;</td>
        <td width="1%">&nbsp;</td>
        <td width="49%">&nbsp;</td>
        </tr>
        <tr>
        <td valign="top" style="font-weight:bold">Fecha de entrega de Bienes al transportista</td>
        <td valign="top" >:</td>
        <td valign="top" ><?php echo $FEC_TRA;?></td>
        <td>&nbsp;</td>
        <td valign="top" style="font-weight:bold">Punto de partida</td>
        <td>:</td>
        <td valign="top"><?php echo $DIR_PAR;?></td>
        </tr>
        <tr>
          <td valign="top" style="font-weight:bold">&nbsp;</td>
          <td valign="top" >&nbsp;</td>
          <td valign="top" >&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td valign="top" style="font-weight:bold">Motivo de Traslado</td>
          <td valign="top" >:</td>
          <td valign="top" ><?php echo $MOTIVO;?></td>
          <td>&nbsp;</td>
          <td valign="top" style="font-weight:bold">Punto de llegada</td>
          <td valign="top">:</td>
          <td valign="top"><?php echo $DIR_LLE;?></td>
        </tr>
        </table>
        
    </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
        <table width="100%" border="0" style="font-size:12px; " cellpadding="0" cellspacing="0">
        <tr>
        <td width="19%" valign="top" style="font-weight:bold">Datos del destintario</td>
        <td width="2%" valign="top" >:</td>
        <td width="79%" valign="top" ><?php echo $DES_NOM;?></td>
        </tr>
        
        <tr>
        <td width="19%" valign="top" style="font-weight:bold"><?php echo $VAR_TDI;?></td>
        <td width="2%" valign="top" >:</td>
        <td width="79%" valign="top" ><?php echo $VAR_NDI;?></td>
        </tr>
        
        
        <tr>
        <td valign="top" style="font-weight:bold">Documentos Relacionados</td>
        <td valign="top" >:</td>
        <td valign="top" ></td>
        </tr>
        <tr>
        <td colspan="3" ><?php echo $REF_DOC." ".$REF_NUM;?></td>
        </tr>
        <tr>
        <td colspan="3" >&nbsp;</td>
        </tr>
        <tr>
        <td colspan="3" style="font-weight:bold">Bienes por transportar:</td>
        </tr>
        </table>
        
    </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
        <table width="100%" border="1" style="border-collapse:collapse">
        <tr>
        <td width="3%" style="background-color:#CCC;padding-left:0.5rem"><b>Nro</b></td>
        <td width="11%" style="background-color:#CCC;padding-left:0.5rem"><b>Codigo de bien</b></td>
        <td width="72%" style="background-color:#CCC;padding-left:0.5rem"><b>Descripcion detallada</b></td>
        <td width="8%" style="background-color:#CCC;padding-left:0.5rem"><b>Unidad de medida</b></td>
        <td width="6%" style="background-color:#CCC;padding-left:0.5rem"><b>Cantidad</b></td>
        </tr>
        <?php
		$CX=0;
		$s="SELECT * FROM pri_gia_det WHERE ID=$KOD ORDER BY CX";
		$rs=grs($s);			
		while($r=$rs->fetch_assoc()){
			$CX++;
		?>
            <tr>
            <td style="padding-left:0.5rem"><?php echo $CX;?></td>
            <td style="padding-left:0.5rem"><?php echo $r['COD']."x".$r['PIE'];?></td>
            <td style="padding-left:0.5rem"><?php echo $r['DES'];?></td>
            <td style="padding-left:0.5rem">CAJA</td>
            <td align="right" style="padding-right:0.5rem"><?php echo $r['CAN'];?></td>
            </tr>
        <?php
		}
		?>
        </table>
    
    </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="23%">Unidad de Medida del Peso Bruto</td>
        <td width="1%">:</td>
        <td width="20%">KGM</td>
        <td width="14%">&nbsp;</td>
        <td width="18%">Peso Bruto total de la carga</td>
        <td width="1%">:</td>
        <td width="23%"><?php echo $PESO;?> kg</td>
      </tr>
    </table></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td style="font-weight:bold">Datos del trasalado</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td >
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="36%" valign="top">Modalidad de Traslado</td>
        <td width="1%" valign="top">:</td>
        <td width="11%" valign="top" style="padding-left:0.5rem"><?php echo $MODA_TRA;?></td>
        <td width="1%" valign="top">&nbsp;</td>
        <td width="42%" valign="top">Indicador de retorno de vehiculo con envases o embalajes vacios</td>
        <td width="0%" valign="top">:</td>
        <td width="9%" valign="top" style="padding-left:0.5rem">NO</td>
      </tr>
      <tr>
        <td>Indicador de transbordo programado</td>
        <td>:</td>
        <td style="padding-left:0.5rem"><?php echo $TRAS_PRO;?></td>
        <td>&nbsp;</td>
        <td>Indicador para registrar vehأ­culos y conductores del transportista</td>
        <td>:</td>
        <td style="padding-left:0.5rem">NO</td>
      </tr>
      <tr>
        <td>Indicador de traslado en vehiculo de categoria M1 o L</td>
        <td>:</td>
        <td style="padding-left:0.5rem"><?php echo $TRAS_M1L;?></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table></td>
    <td>&nbsp;</td>
  </tr>
   <tr>
    <td>&nbsp;</td>
    <td style="font-weight:bold">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td style="font-weight:bold">Datos del transportista</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td ><?php echo $TRANSPORTISTA;?></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td style="font-weight:bold">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</div>
</center>
</body>
</html>