<?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=V($_SESSION['SYS_HW']);
$StrGT="";$LStrMsg="";$LStrFoc="";$LStrMM="";
$LStrPag=V($_POST['TxtPag']);
//
include("compras_apdv_fun.php");
//
$VP_RegXPag=20;
$LStrTR=0;//gn("count(*)","vproductos",$FF);
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);	
$TI=0;
?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Actualizar precios de venta</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="fe/funcioney.js"></script>
<script type="text/javascript" src="fe/compras_apdv.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:800px;width:1100px;position:relative; <?php echo "top:0px";?>}
</style>
<script>
$(document).ready(function(){  
   Inicializar(); 
   if(jVal(gv("TOT_REP"))>0){
	   alert("Uno o mas codigos/productos repetidos");
   }
});
</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();
});
});


</script>
</head>

<body  <?php echo $LStrMsg;?>  >
<div align="center">

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;" >
<form id="Frm" name="Frm" method="post" action="compras_apdv.php">
<!--INI_TITULO-->
<div id="DivT" class="dT"  style="width:1100px">
<img src="img/unidades.png" class="iT" />
<div class="tT" style="width:500px">ACTUALIZAR PRECIOS DE VENTA</div>
</div>
<!--FIN_TITULO-->
<div class="s1" style="left:177px; top: 114px; width: 142px; height: 18px;">
  <?php
	if(strlen($_PDF)>0){
		echo "<a href=\"$_PDF\" target=\"_new\">DESCARGAR</a>";	
	}
?>
  
</div>

<div class="ad" style="left:35px; top:132px; width: 139px; height: 18px;">COMPROBANTE</div>
<select name="Com" id="Com" 
class="lty" style="left:35px; top:149px; width: 139px;"
tabindex="<?php echo ++$TI;?>"  >
<?php
	echo FCBO_("com_nombre","comprobantes","com_nombre IN ('FACTURA','BOLETA','CONTENEDOR')",$Com,"N","S");
?>
</select>

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

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

<div class="s1" style="left:365px; top: 132px; width: 89px; height: 18px;">
DAM</div>
<input name="Dam"  type="text" 
class="lt"  id="Dam" 
style="left:365px; top: 149px; width: 97px;"
maxlength="150" 
tabindex="<?php echo ++$TI;?>"
value="<?php echo $Dam;?>"   />


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

<!--INI_TABLA----->
<div class="s1"
style="background:#ECF9FF; position:absolute; left: 35px; top: 182px; width: 1040px; height: 550px; overflow:auto;">
<div class="s1" style="left: 0px; top: 0px; width: 1030px;">
  <table id="Exportar_a_Excel" class="f4t" width="1006" border="1" style="border-collapse: collapse">
   <tr>
      <td colspan="12" bgcolor="#CCCCCC" height="18" align="center">
      <?php //echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
      </td>
      </tr>   
    <tr>
      <td width="11" bgcolor="#CCCCCC">#</td>
      <td width="116" bgcolor="#CCCCCC">COMPROBANTE</td>
      <td width="53" bgcolor="#CCCCCC">SERIE</td>
      <td width="63" bgcolor="#CCCCCC">NUMERO</td>
      <td width="59" bgcolor="#CCCCCC">DAM</td>
      <td width="89" bgcolor="#CCCCCC">CODIGO</td>
      <td width="250" bgcolor="#CCCCCC">DESCRIPCION</td>
      <td width="141" bgcolor="#CCCCCC">LINEA</td>
      <td width="80" bgcolor="#CCCCCC">PV.MIN</td> 
      <td width="80" bgcolor="#CCCCCC">PV.MAX</td>      
    </tr>   
    <?php
		$LP_T=0;
		$LP[0]=0;
		$ZX=0;
		$TOT_IMP=0;
		$_COM="";
		$TOT_COM=0;
		$TOT_REP=0;
		$s="SELECT ID,COM,SER,NUM,DAM,ID_PRO,COD,DES,LINEA 
			FROM vcompras_det_ WHERE $FF 
			GROUP BY ID,COM,SER,NUM,DAM,ID_PRO,COD,DES,LINEA 
			ORDER BY COD";
		$rs = grs($s);
		while ($r = $rs->fetch_assoc()){
			$ZX++;
			$PM="PM_".$r['ID_PRO'];
			$PW="PW_".$r['ID_PRO'];
			$CSS="";
			if($ZX%2==0){
				$CSS=" style=\"background-color:#DADADA\" ";
			}
			$COM=$r['ID'];
			if($COM!=$_COM){
				$TOT_COM++;
				$_COM=$COM;
			}
			$PV_MIN=gn("pro_pv_min","productos","id_producto=".$r['ID_PRO']);
			$PV_MAX=gn("pro_pv_max","productos","id_producto=".$r['ID_PRO']);
			//
			for($i=1;$i<=$LP_T;$i++){
				if($LP[$i]==$r['ID_PRO']){
					$TOT_REP++;
					break;
				}
			}
			$LP_T=$LP_T+1;
			$LP[$LP_T]=$r['ID_PRO'];
	?>
    <tr <?php echo $CSS; ?>>
        <td ><?php echo $ZX;?></td>
        <td><?php echo $r['COM'];?></td> 
        <td><?php echo $r['SER'];?></td> 
        <td><?php echo $r['NUM'];?></td> 
        <td><?php echo $r['DAM'];?></td> 
        <td><?php echo $r['COD'];?></td>      
        <td><?php echo $r['DES'];?></td>
        <td><?php echo $r['LINEA'];?></td>       
        <td>
        <input name="<?php echo $PM;?>" id="<?php echo $PM;?>"  onFocus="this.select()"
        class="ndd" style="position:inherit; width:80px"  
        type="text" value="<?php echo $PV_MIN;?>" tabindex="<?php echo ++$TI;?>" >
        </td>
        <td>
        <input name="<?php echo $PW;?>" id="<?php echo $PW;?>"  onFocus="this.select()"
        class="ndd" style="position:inherit; width:80px"  
        type="text" value="<?php echo $PV_MAX;?>" tabindex="<?php echo ++$TI;?>" >
        </td>
    </tr>			
    <?php
		}
		$TOT_DIF=0;		
	?>
  </table>
</div>
</div>

<div class="s1" style="left:35px; top: 751px; width: 93px; height: 18px;">
<b>No COMPRAS</b> :</div>
<input name="NRO_COM"  type="text" 
class="rod"  id="NRO_COM"  readonly
style="left:132px; top: 748px; width: 64px;" 
maxlength="150" value="<?php echo $TOT_COM;?>"   />

<div class="s1" style="left:229px; top: 751px; width: 293px; height: 18px;">
<b>TOTAL CODIGOS/PRODUCTOS REPETIDOS</b> : </div>

<input name="TOT_REP"  type="text" 
class="rod"  id="TOT_REP"  readonly
style="left:482px; top: 748px; width: 60px;" 
maxlength="6" value="<?php echo $TOT_REP;?>"   />

<!--FIN_TABLA----->
<!--INI_OCULTOS-------------------------------->
<?php include("ocultox.php");?>
<input name="TXT_COM" id="TXT_COM" type="hidden" value="<?php echo $Com;?>">
<input name="TXT_SER" id="TXT_SER" type="hidden" value="<?php echo $Ser;?>">
<input name="TXT_NUM" id="TXT_NUM" type="hidden" value="<?php echo $Num;?>">
<input name="TXT_DAM" id="TXT_DAM" type="hidden" value="<?php echo $Dam;?>">
<!--FIN_OCULTOS-------------------------------->
<!--INI_BOTONES----->
<div id="DivBtn"  align="left"
style="position:absolute; left: 33px; top: 71px; width: 703px; height: 26px;">
<input name="CmdP" type="button" id="CmdP" class="btm"
value="Guardar" onClick="flGuardar();"  
tabindex="<?php echo ++$TI;?>" />
<input name="CmdB" type="button" id="CmdZ" class="btm"
value="Menu" onClick="fBuscar('menu.php');"  
tabindex="<?php echo ++$TI;?>" />
</div>
<!--FIN_BOTONES-->
</form>
<form action="ficheroExcel.php" 
method="post" target="_blank" 
id="FormularioExportacion" >
</form>

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