<!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("conexion_sunat.php");
require_once('cantidad_en_letras.php');
include("sunat_ndc_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>NOTA DE CREDITO ELECTRONICA</title>
</head>
<body style="font-family:Tahoma, Geneva, sans-serif; font-size:12px">
<center>
<table width="100%" border="0" class="t_basic" style="max-width:950px">
<tr>
<td width="1%">&nbsp;</td>
<td width="98%">
    <table width="100%" border="0">
    <tr>
    <td width="50%" >
            <table width="100%" border="0" class="t_basic">
            <tr>
            <td style="font-weight:bold"><?php echo $EMP_NOM_COM;?></td>
            </tr>
            <tr>
            <td style="font-weight:bold"><?php echo $EMP_NOM;?></td>
            </tr>
            <tr>
            <td><?php echo $EMP_DIR;?></td>
            </tr>
            <tr>
            <td><?php echo $EMP_DIR_UBI;?></td>
            </tr>
            </table>
    </td>    
    <td width="50%">
    		<table width="100%" border="0" class="t_basic">
            <tr>
            <td style="font-weight:bold" align="center">NOTA DE CREDITO ELECTRONICA</td>
            </tr>
            <tr>
            <td style="font-weight:bold" align="center"><?php echo $EMP_RUC;?></td>
            </tr>
            <tr>
            <td style="font-weight:bold; font-size:16px" align="center"><?php echo $DOC_SER_NUM;?></td>
            </tr>
           
            </table>
    </td>
    </tr>
    </table>

</td>
<td width="1%">&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td></td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td><table width="100%" border="0">
    <tr>
      <td width="14%">FECHA<span style="color:#FFF">_</span>DE<span style="color:#FFF">_</span>EMISION</td>
      <td width="1%">:</td>
      <td width="85%" style="font-weight:bold"><?php echo $DOC_FEC;?></td>
    </tr>
    <tr>
      <td>SEÑOR(ES)</td>
      <td>:</td>
      <td style="font-weight:bold"><?php echo $CLI_NOM;?></td>
    </tr>
    <tr>
      <td><?php echo $CLI_TDI;?></td>
      <td>:</td>
      <td style="font-weight:bold"><?php echo $CLI_NDI;?></td>
    </tr>
    <tr>
      <td>DIRECCION</td>
      <td>:</td>
      <td style="font-weight:bold"><?php echo $CLI_DIR;?></td>
    </tr>
    <tr>
      <td>TIPO DE MONEDA</td>
      <td>:</td>
      <td style="font-weight:bold">SOLES</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td style="font-weight:bold">&nbsp;</td>
    </tr>
    <tr>
      <td><b>REFERENCIA</b></td>
      <td>&nbsp;</td>
      <td style="font-weight:bold">&nbsp;</td>
    </tr>
    <tr>
      <td>COMPROBANTE</td>
      <td>:</td>
      <td style="font-weight:bold"><?php echo $REF_COM;?></td>
    </tr>
    <tr>
      <td>SERIE - NUMERO</td>
      <td>:</td>
      <td style="font-weight:bold"><?php echo $REF_SER."-".$REF_NUM;?></td>
    </tr>
    <tr>
      <td>MOTIVO</td>
      <td>:</td>
      <td style="font-weight:bold"><?php echo $DOC_MOT;?></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td style="font-weight:bold">&nbsp;</td>
    </tr>
  </table></td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td></td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>
            <table width="100%" border="3" style="border: 1px solid;border-collapse:collapse; ">
            <tr >
            <td width="10%" class="td_det"><b>CODIGO</b></td>
            <td width="39%" class="td_det"><b>DESCRIPCION</b></td>
            <td width="13%" class="td_det_n"><b>CANT</b></td>
            <td width="13%" class="td_det"><b>UNIDAD</b></td>
            <td width="17%" class="td_det_n"><b>PRECIO</b></td>
            <td width="21%" class="td_det_n"><b>IMPORTE</b></td>
            </tr>
            <?php
			$s="SELECT * FROM fe_ventaz_det WHERE id_fe=$KOD ORDER BY cx";
			$rs=grs($s);			
			while($r=$rs->fetch_assoc()){
				$COD=$r['cod']."x".$r['pie_'];
				$DES=$r['des'];
				$CAN=$r['can_'];
				$PRE=$r['pre_'];
				$IMP=$r['imp_'];
			?>
            <tr >
            <td width="10%" class="td_det"><?php echo $COD;?></td>
            <td width="39%" class="td_det"><?php echo $DES;?></td>
            <td width="13%" class="td_det_n" align="right"><?php echo $CAN;?></td>
            <td width="13%" class="td_det" >CAJAS</td>
            <td width="17%" class="td_det_n" align="right"><?php echo NF2($PRE * $r['pie_'] ,3);?></td>
            <td width="21%" class="td_det_n" align="right"><?php echo NF2($IMP,3);?></td>
            <?php
			}
			?>
            </tr>
            </table>
  
  </td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td></td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>
  
    <table width="100%" border="3" style="border: 1px solid;border-collapse:collapse; ">
    <?php 
	if($TOTAL_DETALLADO==1){
	?>
    <tr >
    <td style="border: 1px solid;" align="right"><b>Sub total</b></td>
    <td width="21%" style="border: 1px solid;" align="right"><b>S/. <?php echo NF2($DOC_SUB,2)?></b></td>
    </tr>
    <tr >
    <td style="border: 1px solid;" align="right"><b>IGV</b></td>
    <td width="21%" style="border: 1px solid;" align="right"><b>S/. <?php echo NF2($DOC_IGV,2)?></b></td>
    </tr>
    <?php
	}
	?>
    <tr >
    <td style="border: 1px solid;" align="right"><b>Importe Total</b></td>
    <td width="21%" style="border: 1px solid;" align="right"><b>S/. <?php echo NF2($DOC_TOT,2)?></b></td>
    </tr>
    </table>


  </td>
  <td>&nbsp;</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td><b>SON: <?php echo CantidadEnLetra($DOC_TOT);?></b></td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td align="center"><img src="https://qrcode.tec-it.com/API/QRCode?data=<?php echo $CODE_QR;?>&size=Small&dpi=200" /></td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td></td>
  <td>&nbsp;</td>
</tr>

</table>
</center>
</body>
</html>