<?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;}
	$StrId=V($_POST['TxtId']);
	$StrCmd=V($_POST['TxtAc']);
	//-------------------------
	//$StrAlm=V($_POST['CboAlm']);		
	$StrCom=V($_POST['CboCom']);		
	$StrSer=V($_POST['TxtSer']);		
	$StrNum=V($_POST['TxtNum']);		
	$StrDex=V($_POST['TxtDex']);		
	$StrHax=V($_POST['TxtHax']);			
	$StrPro=V($_POST['TxtPro']);			
	//-------------------------	
	$StrAlm="%";
	if(strlen($StrCom)==0) $StrCom="TODOS";	
	//-------------------------
	if($StrCom=="TODOS"){
		$StrCom_="%";
	}else{
		$StrCom_=substr($StrCom,0,2);
	}
	$StrNum_=$StrNum."%";
	$StrSer_=$StrSer."%";
	if(strlen($StrDex)==0){
		$StrDex_="2000-01-01";
	}else{
		$StrDex_=ToDate($StrDex);
	}
	if(strlen($StrHax)==0){
		$StrHax_="2030-12-01";//
	}else{
		$StrHax_=ToDate($StrHax);
	}
	$StrPro_=$StrPro."%";
	//-------------------------
	$FF="id>0 AND tienda LIKE '$StrAlm' AND doc LIKE '$StrCom_' AND
		 num LIKE '$StrNum_' AND ser LIKE '$StrSer_' AND 
		 fec >= '$StrDex_' AND fec <= '$StrHax_' AND cliente LIKE '$StrPro_' ";
	//-------------------------
	$LStrTR=gn("count(*)","historial",$FF);	
	$LStrPag=V($_POST['TxtPag']);	
	if($StrCmd=="F"){$LStrPag="1";}
	$VP_RegXPag=10;	
	$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);

?>
<!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>Historial</title>
<script type="text/javascript" src="fe/funciones.js"></script>
<style type="text/css">
<!--
body {
	background-color: #CCC;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:1024px;
	height:600px;
	position:absolute;
	left:50%;
	top:50%;
	background-color:#006699;
	margin:-300px 0 0 -512px;
}
#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;
}
.f2 {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;}
.Estilo4 {color: #000099}
.Estilo5 {color: #000000}

-->
</style>

</head>
<body >
<form id="Frm" name="Frm" method="post" action="historial.php">
<input name="TxtAc" id="TxtAc" type="hidden" value="" />
<input name="TxtPag" id="TxtPag" type="hidden" value="<?php echo $LStrPag; ?>" />
<center> 
  <div Id="DivFRM"  class="centrarFrm" >
    <div id="layer6" style="position:absolute; left: 310px; top: 86px; width: 63px;">
      <div align="left" class="f2">NUMERO</div>
    </div>
    <div id="layer5" style="position:absolute; left: 79px; top: 50px; width: 85px; height: 28px;">
      <div align="left" class="f2">
        <input name="CmdV" type="button" id="CmdV" 
        value="Volver" onclick="fVolver('menu.php');" />
      </div>
    </div>
    <div id="layer3" style="position:absolute; left: 25px; top: 138px; width: 982px; height: 200px;">
      <div align="left" class="f2">
        <table width="978" height="19" border="1" cellpadding="0" cellspacing="0">
<tr  >
<td height="18" colspan="11" bgcolor="#666666" align="center">
<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
</td>
</tr>
<tr>
<td width="63" bgcolor="#999999"><span class="Estilo4">ALMACEN</span></td>
<td width="90" bgcolor="#999999"><span class="Estilo4">COMPROBANTE</span></td>
<td width="55" bgcolor="#999999"><span class="Estilo4">NUMERO</span></td>
<td width="43" bgcolor="#999999"><span class="Estilo4">FECHA</span></td>
<td width="164" bgcolor="#999999"><span class="Estilo4">CLIENTE</span></td>            
<td width="92" bgcolor="#999999"><span class="Estilo4">CODIGO</span></td>            
<td width="253" bgcolor="#999999"><span class="Estilo4">DESCRIPCION</span></td>            
<td width="45" bgcolor="#999999" align="right"><span class="Estilo4">CANT</span></td>
<td width="52" bgcolor="#999999" align="right"><span class="Estilo4">PRECIO</span></td>
<td width="58" bgcolor="#999999" align="right"><span class="Estilo4">IMPORTE</span></td>
<td width="39" bgcolor="#999999">&nbsp;</td>
</tr>
<?php		  		

	$s="SELECT id,tienda,doc,CONCAT(ser,'-',num),DATE_FORMAT(fec,'%d-%m-%y'),cliente,
		 prod_cod,prod_des,can,ROUND(pre,1),ROUND(importe,1)
		 FROM historial WHERE ".$FF." ORDER BY id ";
	$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
	$X1B="<td bgcolor=\"#FFFFFF\" align=\"right\"><span class=\"Estilo5\">";
	$X2="</span></td>";
	$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);	
	$result = grs($s);				
	while ($row = $result->fetch_row()){
		echo "<tr >";
		echo $X1.$row[0].$X2;
		echo $X1.$row[2].$X2;
		echo $X1.$row[3].$X2;
		echo $X1.$row[4].$X2;
		echo $X1.$row[5].$X2;
		echo $X1.$row[6].$X2;
		echo $X1.$row[7].$X2;
		echo $X1.$row[8].$X2;
		echo $X1B.$row[9].$X2;
		echo $X1B.$row[10].$X2;
		echo "<td bgcolor=\"#FFFFFF\" align=\"center\">		 
			 </td>";
		echo "</tr>";
	}

?>		  
<tr  >
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF" >&nbsp;</td>
<td bgcolor="#FFFFFF" >&nbsp;</td>
<td bgcolor="#FFFFFF" >&nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>    
<td  bgcolor="#FFFFFF" >nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>    
<td  bgcolor="#FFFFFF" >nbsp;</td>
</tr>
</table>
      </div>
    </div>
    <div id="layer" style="position:absolute; left: 79px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">HISTORIAL </div>
    </div>
          <input name="TxtNum" type="text" id="TxtNum" 
          style="position:absolute; left: 310px; top: 109px; width: 69px;" value="<?php echo $StrNum;?>"  
          onkeydown="return SoloTextoEx(event,'TxtDex');"
          tabindex="1" />

    <div id="LblTit" style="position:absolute; left: 20px; top: 25px; width: 64px;">
    <div align="left" class="Estilo1"><img src="img/buscar.png" width="57" height="60" /></div>
  </div>	
        <input name="CmdB" type="button" id="CmdB"
style="position:absolute; left: 830px; top: 109px; width: 57px;"
 value="Filtrar" onclick="fFiltrar();" />

    <div id="layer7" style="position:absolute; left: 397px; top: 86px; width: 45px;">
      <div align="left" class="f2">DESDE</div>
    </div>
        <input name="TxtDex" type="text" id="TxtDex" 
        style="position:absolute; left: 395px; top: 109px; width: 73px;" value="<?php echo $StrDex;?>"  
        onkeydown="return SoloFec(this,event,'TxtHax');"
        tabindex="1" />

        <input name="TxtPro" type="text" id="TxtPro" 
        style="position:absolute; left: 570px; top: 109px; width: 249px;" value="<?php echo $StrPro;?>"  
        onkeydown="return SoloTextoEx(event,'CmdB');" 
        tabindex="1" />

    <div id="layer10" style="position:absolute; left: 575px; top: 86px; width: 100px;">
      <div align="left" class="f2">CLIENTE</div>
    </div>
    <div id="layer11" style="position:absolute; left: 484px; top: 86px; width: 60px;">
      <div align="left" class="f2">HASTA</div>
    </div>
        <input name="TxtHax" type="text" id="TxtHax" 
        style="position:absolute; left: 483px; top: 109px; width: 73px;" 
        value="<?php echo $StrHax;?>"  
        onkeydown="return SoloFec(this,event,'TxtPro');"
        tabindex="1" />

        <select name="CboCom" id="CboCom" 
style="position:absolute; left: 24px; top: 109px; width: 204px;" 
onkeydown="return SoloTextoEx(event,'TxtSer');">
<?php
if($StrCom=="TODOS"){
echo "<option value=\"TODOS\" selected=\"selected\">TODOS</option>";	
}else{
echo "<option value=\"TODOS\" >TODOS</option>";	
}
$s="SELECT com_nombre FROM comprobantes WHERE id_comprobante> 0 ORDER BY com_nombre";
$result = grs($s);
while ($row = $result->fetch_row()){
if($StrCom==$row[0]){
echo "<option value=\"$row[0]\" selected=\"selected\">$row[0]</option>";
}else{
echo "<option value=\"$row[0]\" >$row[0]</option>";
}
}
?>
        </select>

    <div id="layer13" style="position:absolute; left: 26px; top: 86px; width: 148px;">
      <div align="left" class="f2">COMPROBANTE</div>
    </div>
    <div id="layer15" style="position:absolute; left: 247px; top: 86px; width: 46px;">
      <div align="left" class="f2">SERIE</div>
  </div>
        <input name="TxtSer" type="text" id="TxtSer" 
          style="position:absolute; left: 245px; top: 109px; width: 50px;" value="<?php echo $StrSer;?>"  
          onkeydown="return SoloTextoEx(event,'TxtNum');"
          tabindex="1" />

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