<?php
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;
}
//
$HW=$_SESSION['SYS_HW'];
$StrGT="";$LStrMsg="";$LStrFoc="";$LStrMM="";
$LStrPag=V($_POST['TxtPag']);
//
include("rpt_notas_fun.php");
//
$LStrTR=gn("count(*)","vis_notas_rpt",$FF);
$LStrPag=V($_POST['TxtPag']);
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=350;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
$TI=0;
?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reporte de notas de credito</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="fe/funcionex.js"></script>
<!--FIN_SCRIPT------------------------------------->
<link rel="stylesheet" type="text/css" href="estilox.css"  />
<link rel="stylesheet" type="text/css" href="basix.css"  />
<style type="text/css">
.cF {height:650px;width:1300px;position:relative; <?php echo "top:0px";?>}
</style>
<script>
$(document).ready(function(){  
   Inicializar();   
});
</script>
<script language="javascript">
$(document).ready(function() {
	$(".botonExcel").click(function(event) {
		$("#datos_a_enviar").val( $("<div>").append( $("#Exportar_a_Excel").eq(0).clone()).html());
		$("#FormularioExportacion").submit();
});
});
function _S(O){
	var s=O.value;
	s=s.trim()
	if(jL(s)==1)s="000"+s;
	if(jL(s)==2)s="00"+s;
	if(jL(s)==3)s="0"+s;
	O.value=s;
}
function _N(O){
	var s=O.value;
	s=s.trim()
	if(jL(s)==1)s="00000"+s;
	if(jL(s)==2)s="0000"+s;
	if(jL(s)==3)s="000"+s;
	if(jL(s)==4)s="00"+s;
	if(jL(s)==5)s="0"+s;
	O.value=s;
}

</script>
</head>

<body >
<div align="center">

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;" >
<form id="Frm" name="Frm" method="post" action="rpt_notas.php" autocomplete="off">
<!--INI_TITULO-->
<div id="DivT" class="dT"  style="width:1300px">
<img src="img/unidades.png" class="iT" />
<div class="tT" style="width:1000px">REPORTE DE NOTAS DE CREDITO</div>
</div>
<!--FIN_TITULO-->

<div class="ad" style="left:35px; top:132px; width: 78px; height: 18px;">EMPRESA</div>
<select name="Emp" id="Emp" 
class="lty" style="left:35px; top:149px; width: 94px;"
tabindex="<?php echo ++$TI;?>"  >
<?php
	echo FCBO("emp_nomc","empresas","id_emp>0",$Emp,"S","N");
?>
</select>


<div class="s1" style="left:144px; top:112px; width: 166px; height: 18px;">
<b>NOTA DE CREDITO</b>
</div>

<div class="s1" style="left:144px; top: 132px; width: 40px; height: 18px;">
SERIE</div>
<input name="Ser"  type="text" 
class="lt"  id="Ser" 
style="left:144px; top: 149px; width: 56px;"
maxlength="4" 
tabindex="<?php echo ++$TI;?>"
value="<?php echo $Ser;?>"   />

<div class="s1" style="left:209px; top: 132px; width: 59px; height: 18px;">
NUMERO</div>
<input name="Num"  type="text" 
class="lt"  id="Num" 
style="left:209px; top: 149px; width: 65px;"
maxlength="8" 
tabindex="<?php echo ++$TI;?>"
value="<?php echo $Num;?>"   />







<div class="ad" style="left:291px; top:118px; width: 82px; height: 18px;">DESDE</div>
<div class="EV" style="left: 291px; top: 132px; width: 86px;"><u><a onClick="sh('Dex')">(dd-mm-yy)</a></u></div>
<input name="Dex" type="text" id="Dex" 
class="fe"
style="left:291px; top: 149px; width: 70px;" value="<?php echo $Dex;?>"  
tabindex="<?php echo ++$TI;?>" />

<div class="ad" style="left:373px; top:118px; width: 82px; height: 18px;">HASTA</div>
<div class="EV" style="left: 373px; top: 132px; width: 86px;"><u><a onClick="sh('Hax')">(dd-mm-yy)</a></u></div>
<input name="Hax" type="text" id="Hax" 
class="fe"
style="left:371px; top: 149px; width: 70px;" value="<?php echo $Hax;?>"  
tabindex="<?php echo ++$TI;?>" />



<div class="ad" style="left:460px; top:116px; width: 52px; height: 18px;">
  GENE- RADO</div>
<select name="Gen" id="Gen" 
class="lty" style="left:459px; top:149px; width: 55px;"
tabindex="<?php echo ++$TI;?>"  >
<?php
echo FCBO("au_item","auxiliar","au_tab='SI_NO'",$Gen,"S","N");
?>
</select>


<div class="ad" style="left:531px; top:116px; width: 52px; height: 18px;">
ANU- LADO</div>
<select name="Anu" id="Anu" 
class="lty" style="left:531px; top:149px; width: 55px;"
tabindex="<?php echo ++$TI;?>"  >
<?php
echo FCBO("au_item","auxiliar","au_tab='SI_NO'",$Anu,"S","N");
?>
</select>


<div class="s1" style="left:600px; top: 132px; width: 59px; height: 18px;">
CLIENTE</div>
<input name="Cli"  type="text" 
class="lt"  id="Cli" 
style="left:600px; top: 149px; width: 184px;"
tabindex="<?php echo ++$TI;?>"
value="<?php echo $Cli;?>"   />

<div class="s1" style="left:795px; top: 132px; width: 77px; height: 18px;"> RUC / DNI
</div>
<input name="Ndi"  type="text" 
class="lt"  id="Ndi"  maxlength="11"
style="left:794px; top: 149px; width: 115px;"
tabindex="<?php echo ++$TI;?>"
value="<?php echo $Ndi;?>"   />

<div class="ad" style="left:919px; top:117px; width: 94px; height: 18px;">
<b>REFERENCIA</b></div>

<div class="ad" style="left:919px; top:132px; width: 78px; height: 18px;">
COMPROBANTE</div>
<select name="RefCom" id="Emp" 
class="lty" style="left:919px; top:149px; width: 94px;"
tabindex="<?php echo ++$TI;?>"  >
<?php
echo FCBO_("com_nombre","comprobantes",
		  "id_comprobante>0 AND com_nombre IN ('FACTURA','BOLETA','FACT. ELEC.','BOL. ELEC.')",$RefCom,"S","N");
?>
</select>

<div class="s1" style="left:1027px; top: 132px; width: 60px; height: 18px;">
SERIE</div>
<input name="RefSer"  type="text" 
class="lt"  id="RefSer" 
style="left:1027px; top: 149px; width: 62px;"
maxlength="4" 
tabindex="<?php echo ++$TI;?>"
value="<?php echo $RefSer;?>"   />

<div class="s1" style="left:1099px; top: 132px; width: 82px; height: 18px;">
NUMERO</div>
<input name="RefNum"  type="text" 
class="lt"  id="RefNum" 
style="left:1099px; top: 149px; width: 103px;"
maxlength="8"
tabindex="<?php echo ++$TI;?>"
value="<?php echo $RefNum;?>"   />

<input name="CmdF" type="button" id="CmdF"  
style="position:absolute; top:149px; left:1212px; width: 76px;"
value="Filtrar" onClick="fFiltrar();"  
tabindex="<?php echo ++$TI;?>" />

<!--INI_TABLA----->

<div class="s1"
style="background:#ECF9FF; position:absolute; left: 35px; top: 180px; width: 1262px; height: 426px; overflow:auto;">
<div class="s1" style="left: 0px; top: 0px; width: 1257px; z-index:0;">
<table class="f4t" width="1239" border="1" style="border-collapse: collapse">
<tr>
<td  bgcolor="#CCCCCC" height="18" align="center">
<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
</td>
</tr>   
</table>
    
</div>
</div>

<div class="s1"
style="background:#ECF9FF; position:absolute; left: 35px; top: 205px; width: 1262px; height: 415px; overflow:auto;">
<div class="s1" style="left: 0px; top: 0px; width: 1257px; z-index:0;">
  <table id="Exportar_a_Excel" class="f4t" border="1" style="border-collapse: collapse">
    
    <tr>
    <td style="width:20px" bgcolor="#CCCCCC"><b>#</b></td>
    <td style="width:100px" bgcolor="#CCCCCC"><b>EMPRESA</b></td>
    <td style="width:80px"  bgcolor="#CCCCCC"><b>SERIE</b></td>
    <td style="width:100px"  bgcolor="#CCCCCC"><b>NUMERO</b></td>
    <td style="width:100px" bgcolor="#CCCCCC"><b>FECHA</b></td>
    <td style="width:300px" bgcolor="#CCCCCC"><b>CLIENTE</b></td>
    
    <td style="width:100px" bgcolor="#CCCCCC" style="white-space: nowrap;"><b>Nº DOCUMENTO</b></td>
    <td style="width:100px"" align="right" bgcolor="#CCCCCC"><b>SUBTOTAL</b></td>
    <td style="width:100px" align="right" bgcolor="#CCCCCC"><b>IGV</b></td>
    <td style="width:100px" align="right" bgcolor="#CCCCCC"><b>TOTAL</b></td>
    <td style="width:80px" bgcolor="#CCCCCC"><b>GEN</b></td>
    <td style="width:80px" bgcolor="#CCCCCC"><b>ANU</b></td>
    <td style="width:80px" bgcolor="#CCCCCC"><b>REF.DOC.</b></td>
    <td style="width:100px" bgcolor="#CCCCCC"><b>REF.SERIE</b></td>      
    <td style="width:150px" bgcolor="#CCCCCC"><b>REF.NUMERO</b></td>
    </tr>   
    <?php
		$ZX=0;
		$CSS="";
		$TOT=0;
		$s="SELECT * FROM vis_notas_rpt WHERE ".$FF." ORDER BY FEC DESC,ID DESC ";
		$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
		$rs = grs($s);
		while ($r = $rs->fetch_assoc()){
			$ZX++;
			$CSS="";
			if($ZX%2==0)$CSS=' style="background-color:#DADADA" ';			
			//if($ZX>350)break;		
			$TOT=$TOT + $r['TOT'];
	?>
        <tr <?php echo $CSS;?> >
        <td style="white-space: nowrap;" >'<?php echo $ZX;?></td>
        <td style="white-space: nowrap;"><?php echo $r['EMP'];?></td>
        <td style="white-space: nowrap;">'<?php echo $r['SER'];?></td>
        <td style="white-space: nowrap;">'<?php echo $r['NUM'];?></td>
        <td style="white-space: nowrap;"><?php echo $r['FEC_'];?></td>
        <td style="white-space: nowrap;"><?php echo $r['CLI_NOM'];?></td>           
        <td style="white-space: nowrap;">'<?php echo $r['CLI_NDI'];?></td>
        <td align="right" style="padding-right:0.2rem;white-space: nowrap;"><?php echo NF2($r['SUB_TOT'],2);?></td>
        <td align="right" style="padding-right:0.2rem;white-space: nowrap;"><?php echo NF2($r['IGV'],2);?></td> 
        <td align="right" style="padding-right:0.2rem;white-space: nowrap;"><?php echo NF2($r['TOT'],1);?></td> 
        <td style="white-space: nowrap;"><?php echo $r['GEN'];?></td>    
        <td style="white-space: nowrap;"><?php echo $r['ANU'];?></td> 
        <td style="white-space: nowrap;"><?php echo $r['REF_COM'];?></td> 
        <td style="white-space: nowrap;">'<?php echo $r['REF_SER'];?></td> 
        <td style="white-space: nowrap;">'<?php echo $r['REF_NUM'];?></td>
        </tr>			
    <?php
		}
	?>
  </table>
</div>
</div>
<div class="adn" style="left:1100px; top:627px; width: 179px; height: 18px; text-align:right">TOTAL : <?php echo NF2($TOT,2);?></div>
<!--FIN_TABLA----->
<!--INI_OCULTOS-------------------------------->
<?php include("ocultox.php");?>
<!--FIN_OCULTOS-------------------------------->
<!--INI_BOTONES----->
<div id="DivBtn"  align="left"
style="position:absolute; left: 33px; top: 71px; width: 180px; height: 26px;">
<input name="CmdB" type="button" id="CmdZ" class="btm"
value="Volver" onClick="fBuscar('menu.php');"  
tabindex="<?php echo ++$TI;?>" />
</div>
<!--FIN_BOTONES-->
</form>
<form action="ficheroExcel.php" method="post" target="_blank" id="FormularioExportacion" >
<div style="position:absolute; left: 149px; top: 72px; width: 45px; height: 15px;">  
<input name="" type="button" class="botonExcel" value="Exportar" />
<input type="hidden" id="datos_a_enviar" name="datos_a_enviar" />
</div>
</form>

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