<?php
session_start();
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
//
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
//
include("deos_productos_precios_bx.php");


if($StrCmd=="G"){
	$z="SELECT ID FROM vproductos WHERE $FF ORDER BY DESCRIPCION,MARCA";
	$z=PagSql($z,$LStrPag,$VP_RegXPag,$LStrTR);						
	$rs = grs($z);
	while ($r = $rs->fetch_assoc()){
		$_PXU=vbval(V($_POST["PXU_".$r['ID']]));
		$_PXC=vbval(V($_POST["PXC_".$r['ID']]));
		$_PXM=vbval(V($_POST["PXM_".$r['ID']]));
		$_OFE=V($_POST["OFE_".$r['ID']]);		
		//
		$s="UPDATE productos SET 
			pro_pxu=$_PXU,
			pro_pxc=$_PXC,
			pro_pxm=$_PXM,
			pro_ofe='$_OFE' 
			WHERE id_producto=".$r['ID'];
		ejt($s);
	}
	$StrMsg="onload=\"alert('Datos actualizados')\";";
}

$IdUsu=$_SESSION['SYS_USER_ID'];
$AT=gs("at","usuarios","id_usuario=$IdUsu");
?>



<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Actualizar - precios</title>
<!----------------------------------------->
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.js"></script>

<script>
function fGuardar(){
	if(pre("Esta seguro que desea guardar")){
		SM("G");
	}
}

$(document).keydown(function(e){
	var AT=gv("TxtAT");

	if(e.which==66 && e.altKey){
		if(AT=="1"){	
		document.getElementById("CmdB").click();
		return;
		}
	}

	if(e.which==86 && e.altKey){
		if(AT=="1"){
		document.getElementById("CmdZ").click();
		return;
		}
	}
	
	if(e.which==71 && e.altKey){		
		if(AT=="1"){	
		document.getElementById("CmdG").click();
		return;
		}
	}
  
});
</script>
<!----------------------------------------->
<link rel="stylesheet" type="text/css" href="css/estiloss.css"  />
<link rel="stylesheet" type="text/css" href="css/basic.css"  />
<link rel="stylesheet" type="text/css" href="css/mnu.css"  />

<!----------------------------------------->
<style type="text/css">
.cF {height:600px;width:1250px;position:relative;top:0px}
.mM {height:34px;width:1250px;position:relative;top:0px;background-color:#09C; z-index:500;}

</style>

<!----------------------------------------->
<script>
$(document).ready(function(){  
   Inicializar();
   jF("TxtCod");
});
</script>
<!----------------------------------------->

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

<div class="mM" align="left" style="font-size:12px">
<?php
$HTM=file_get_contents("http://inversionessounduniversal.com/ventas/phpmnu.php?USER_ID=$IdUsu");
echo $HTM;
?>
</div>

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;" >
<form id="Frm" name="Frm" method="post" action="pre_productos_precios.php" style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">

<!----------------------------------------->
<div id="DivT" class="dT"  style="width:1250px;">
<img src="b.png" class="iT" />
<div class="tT">ACTUALIZAR - PRECIOS</div>
</div>
<!----------------------------------------->
 
<div class="s1" style="left: 35px; top: 117px; width: 52px;">
CODIGO</div>
<input name="TxtCod" type="text" id="TxtCod" 
class="lt"  style="left: 35px; top: 134px; width: 95px"
tabindex="<?php echo ++$TI;?>"
value="<?php echo $StrCod;?>" />

<div class="s1" style="left: 142px; top: 117px; width: 136px;">
-LINEA DE PRODUCTO</div>
<select name="CboLin" id="CboLin" 
class="lt" style="left: 139px; top: 134px; width: 144px"
tabindex="<?php echo ++$TI;?>">
<?php echo FCBO_("lin_nombre","lineas","id_linea>0",$StrLin,"S","");?>
</select>

<div class="s1" style="left: 298px; top: 117px; width: 94px;">
FABRICANTE</div>
<select name="Fab" id="Fab" 
class="lt" style="left: 295px; top: 134px; width: 159px" 
tabindex="<?php echo ++$TI;?>">
<?php echo FCBO_("fab_nom","fabricantes","id_fab>0",$Fab,"S","N");?>
</select>

<div class="s1" style="left: 466px; top: 117px; width: 120px;">
MODELO</div>
<select name="Mod" id="Mod" 
class="lt" style="left: 463px; top: 134px; width: 177px" 
tabindex="<?php echo ++$TI;?>">
<?php echo FCBO_("mod_nom","modelos","id_mod>0",$Mod,"S","N");?>
</select>

<div class="s1" style="left: 649px; top: 117px; width: 143px;">
DESCRIPCION</div>
<input name="TxtDes" type="text" id="TxtDes" 
class="lt" style="left: 646px; top: 134px; width: 170px" 
value="<?php echo $StrDes;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 825px; top: 117px; width: 125px;"
>MARCA</div>
<select name="CboMar" id="CboMar" 
class="lt" style="left: 823px; top: 134px; width: 126px" 
tabindex="<?php echo ++$TI;?>">
<?php echo FCBO_("mar_nombre","marcas","id_marca>0",$StrMar,"S","");?>
</select>






<!----------------------------------------->
<?php //$VOLVER="menu.php";?>
<?php //include("botones_b.php");?>;

<div id="DivBtn" align="left" style="position:absolute; left: 33px; top: 71px; width: 551px; height: 26px;">
<input name="CmdB" type="button" id="CmdB" class="btm"
value="Buscar" onClick="fFiltrar();"  
tabindex="<?php echo ++$TI;?>" />

<input name="CmdG" type="button" id="CmdG"  
tabindex="<?php echo ++$TI;?>"
class="btm" style="left: 221px; top: 71px;" 
value="Guardar" onClick="fGuardar();" />
</div>
<!-----------------------------------------> 

<div class="datagrid" style="position: absolute; left: 35px; top: 165px; width: 1180px; height: 416px; overflow: auto">
<table id="Exportar_a_Excel" width="100%">
<thead>
<tr>
<td colspan="13" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
</tr>

<tr>
<th width="9%">CODIGO</th>
<th width="11%">LINEA</th>
<th width="11%">FABRICANTE</th>
<th width="10%">MODELO</th>
<th width="23%">DESCRIPCION</th>
<th width="6%">PV.MIN</th>
<th width="6%">PV.MAX</th>
<th width="6%">PxU</th>
<th width="6%">PxC</th>
<th width="6%">PxM</th>
<th width="6%">OFERTA</th>
</tr>
</thead>
<tbody>
<?php		  		
$s="SELECT ID,COD,SUBSTRING(LINEA,1,16)as LIN,
	SUBSTRING(DESCRIPCION,1,35) as DEZ,
	FORMAT(PV_MIN,1) as PM,FORMAT(PV_MAX,1) as PW,
	SUBSTRING(FAB,1,19) as FAK,SUBSTRING(MODELO,1,15) as MOK,
	PXU,PXC,PXM,OFE
	FROM vproductos 
	WHERE $FF ORDER BY DESCRIPCION,MARCA ";
	$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);						
	$result = grs($s);
	while ($row = $result->fetch_assoc()){
		$PXU="PXU_".$row['ID'];
		$PXC="PXC_".$row['ID'];
		$PXM="PXM_".$row['ID'];
		$OFE="OFE_".$row['ID'];
		?>
		<tr>
		<td bgcolor="#FFFFFF">'<?php echo $row['COD'];?></td>
		<td bgcolor="#FFFFFF"><?php echo $row['LIN'];?></td>
		<td bgcolor="#FFFFFF"><?php echo $row['FAK'];?></td>
		<td bgcolor="#FFFFFF"><?php echo $row['MOK'];?></td>
		<td bgcolor="#FFFFFF"><?php echo $row['DEZ'];?></td>
		<td bgcolor="#FFFFFF" align=\"right\"><?php echo $row['PM'];?></td>
		<td bgcolor="#FFFFFF" align=\"right\"><?php echo $row['PW'];?></td>
        <td bgcolor="#FFFFFF" align=\"right\">
        <input name="<?php echo $PXU;?>" type="text" id="<?php echo $PXU;?>" 
        tabindex="<?php echo ++$TI;?>"
        value="<?php echo $row['PXU'];?>"
        style="position:inherit; width:60px"  class="ndd" onFocus="selecciona_value(this);"/>
        </td>
        <td bgcolor="#FFFFFF" align=\"right\">
        <input name="<?php echo $PXC;?>" type="text" id="<?php echo $PXC;?>" 
        tabindex="<?php echo ++$TI;?>"
        value="<?php echo $row['PXC'];?>"
        style="position:inherit; width:60px"  class="ndd" onFocus="selecciona_value(this);"/>
        </td>
        <td bgcolor="#FFFFFF" align=\"right\">
        <input name="<?php echo $PXM;?>" type="text" id="<?php echo $PXM;?>" 
        tabindex="<?php echo ++$TI;?>"
        value="<?php echo $row['PXM'];?>"
        style="position:inherit; width:60px"  class="ndd" onFocus="selecciona_value(this);"/>
        </td>
        <td bgcolor="#FFFFFF">
        <select name="<?php echo $OFE;?>" id="<?php echo $OFE;?>" 
        tabindex="<?php echo ++$TI;?>"
        style="position:inherit; width:60px" class="lt">
        <?php
        echo FCBO("aux_nom","auxiliar","aux_des='SN'",$row['OFE'],"N","N");
		?>
        </select>
        </td>
		</tr>
		<?php
	}
?>		  
</tbody>
</table>
</div>

<!----------------------------------------->    
<?php include("ocultos.php");?>

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