<?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;
}
//
	$StrId=V($_POST['TxtId']);
	$StrCmd=V($_POST['TxtAc']);
	//-------------------------
	$StrAlm=V($_POST['CboAlm']);		
	$StrCom=V($_POST['CboCom']);		
	$StrNum=V($_POST['TxtNum']);		
	$StrDex=V($_POST['TxtDex']);		
	$StrTdp=V($_POST['CboTdp']);			
	if(strlen($StrDex)==0)$StrDex=date("d-m-y");
	if($_SESSION['SYS_USER_ALM']=="%"){
		if(strlen($StrAlm)==0)$StrAlm=GetSO("alm_obs","almacenes","","alm_obs");
	}else{
		$StrAlm=$_SESSION['SYS_USER_ALM'];
	}
	if(strlen($StrCom)==0) $StrCom="TODOS";	
	if(strlen($StrTdp)==0) $StrTdp=GetSO("tipp_nombre","tipos_pagos","","tipp_nombre");	
	//-------------------------
	if($StrCom=="TODOS"){
		$StrCom_="%";
	}else{
		$StrCom_=$StrCom;
	}
	$StrNum_=$StrNum."%";
	$StrTdp_=substr($StrTdp,0,2);
	$StrDex_=val_dex($StrDex);
	$StrHax_=$StrDex_;	
	//
	$FF="ID>0 AND ALM LIKE '$StrAlm' AND ".
	    "COM LIKE '$StrCom_' AND ".
		"NUM LIKE '$StrNum_' AND  ".
		"FEC >= '$StrDex_' AND ".
		"FEC <= '$StrHax_' AND ".
		"TDP LIKE '$StrTdp_' ";
	//
	$LStrTR=gn("count(*)","vcompras",$FF);
	$LStrPag=V($_POST['TxtPag']);	
	if($StrCmd=="F"){$LStrPag="1";}
	$VP_RegXPag=200;	
	$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>Reporte de compras del dia</title>
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="jquery.maskedinput.min.js" type="text/javascript"></script>
<script type="text/javascript" src="fe/funciones.js"></script>
<script>
$(document).ready(function(){
   $("#TxtDex").mask("99-99-99"); 
});
</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:800px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-400px";?>;
}
#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}
#Frm center #DivFRM #layer3 .f2 table tr td {
	color: #000;
	text-align: left;
}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<form id="Frm" name="Frm" method="post" action="rep_compras_xdia.php">
<center> 
  <div Id="DivFRM"  class="centrarFrm" >
    <div id="layer6" style="position:absolute; left: 288px; top: 86px; width: 66px;">
      <div align="left" class="f2">NUMERO</div>
    </div>
    <div id="layer5" style="position:absolute; left: 116px; top: 50px; width: 346px; height: 28px;">
      <div align="left" class="f2">
        <input name="CmdV" type="button" id="CmdV" 
        value="Volver" onclick="fVolver('menu.php');" />
        <input type="hidden" name="TxtAc" id="TxtAc" />
        <input name="TxtPag" id="TxtPag" type="hidden" value="<?php echo $LStrPag; ?>" />
      </div>
    </div>
    <div id="layer3" style="position:absolute; left: 22px; top: 138px; width: 760px; height: 438px;">
      <div align="left" class="f2">
        <table width="761" height="52" border="1" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="6" bgcolor="#999999" height="18px">
			<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
            </tr>
          <tr>
            <td width="87" bgcolor="#999999"><span class="Estilo4">ALMACEN</span></td>
            <td width="115" bgcolor="#999999"><span class="Estilo4">COMPROBANTE</span></td>
            <td width="81" bgcolor="#999999"><span class="Estilo4">NUMERO</span></td>
            <td width="91" bgcolor="#999999"><span class="Estilo4">FECHA</span></td>
            <td width="286" bgcolor="#999999"><span class="Estilo4">PROVEEDOR</span></td>
            <td width="67" bgcolor="#999999" 
            style="text-align:right"><span class="Estilo4">TOTAL</span></td>
          </tr>
		  <?php	
		  		$TOTAL=0;
		  		$StrTemp=$StrPag * $VP_RegXPag;
				$s="SELECT ID,ALM,COM,NUM,DATE_FORMAT(FEC,'%d-%m-%y'),PROV,TOT
				     FROM vcompras 
					 WHERE $FF ORDER BY ALM,COM,NUM,FEC,PROV ";				
				$X1="<td bgcolor=\"#FFFFFF\"><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[1].$X2;
					echo $X1.$row[2].$X2;
					echo $X1.$row[3].$X2;
					echo $X1.$row[4].$X2;
					echo $X1.$row[5].$X2;
					echo "<td bgcolor=\"#FFFFFF\" 
					style=\"text-align:right\"><span class=\"Estilo5\">".$row[6].$X2;
					echo "</tr>";
					$TOTAL=$TOTAL + $row[6];
				}

		  ?>		  
          <tr  >
            <td bgcolor="#FFFFFF">&nbsp;</td>
            <td bgcolor="#FFFFFF">

			</td>
            <td bgcolor="#FFFFFF" ></td>
            <td bgcolor="#FFFFFF" ></td>
            <td bgcolor="#FFFFFF"  style="text-align:right">TOTAL</td>
            <td  bgcolor="#FFFFFF"   style="text-align:right"><?php echo $TOTAL;?></td>
          </tr>
         
        </table>
      </div>
    </div>
    <div id="layer" style="position:absolute; left: 116px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">REPORTE DE COMPRAS DEL DIA</div>
    </div>
          <input name="TxtNum" type="text" id="TxtNum" 
          style="position:absolute; left: 286px; top: 109px; width: 78px;" value="<?php echo $StrNum;?>"  
          onkeydown="return SoloTextoEx(event,'TxtDex');"
          tabindex="1" />

    <div id="LblTit" style="position:absolute; left: 57px; 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: 692px; top: 109px; width: 57px;"
 value="Filtrar" onclick="fFiltrar();" />

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

<select name="CboCom" id="CboCom" 
style="position:absolute; left: 177px; top: 109px; width: 99px;" 
onkeydown="return SoloTextoEx(event,'TxtNum');">
<?php
echo FCBO_("com_nombre","comprobantes","id_comprobante>0",$StrCom,"S","N");
?>
        </select>

    <div id="layer13" style="position:absolute; left: 179px; top: 86px; width: 102px;">
      <div align="left" class="f2">COMPROBANTE</div>
    </div>
<select name="CboAlm" id="CboAlm" style="position:absolute; left: 59px; top: 109px; width: 109px;" 
onkeydown="return SoloTextoEx(event,'CboCom');">
<?php echo ListALM($StrAlm); ?>
</select>

    <div id="layer14" style="position:absolute; left: 61px; top: 86px; width: 102px;">
      <div align="left" class="f2">ALMACEN</div>
    </div>
        <select name="CboTdp" id="CboTdp" style="position:absolute; left: 464px; top: 109px; width: 134px;" 
onkeydown="return SoloTextoEx(event,'CmdB');" tabindex="9">
<?php
echo FCBO_("tipp_nombre","tipos_pagos","",$StrTdp,"N","N");
?>
        </select>

    <div id="layer9" style="position:absolute; left: 468px; top: 86px; width: 92px;">
      <div align="left" class="f2">TIPO DE PAGO</div>
    </div>
  </div>
</center>	
</form>
</body>
</html>
