<?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_pre_plantilla3_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()){
		$_FAB=V($_POST["F_".$r['ID']]);
		$_MOD=V($_POST["M_".$r['ID']]);
		$_FAB=gn("id_fab","fabricantes","fab_nom='$_FAB'");
		$_MOD=gn("id_mod","modelos","mod_nom='$_MOD'");
		//
		$s="UPDATE productos SET pro_id_fab=$_FAB,pro_id_mod=$_MOD 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 Productos</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="ja/funciones.js"></script>
<!--FIN_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");
});

function fGenPDF(){	
	document.getElementById("TxtAc").value="GEN_PDF";
	document.getElementById("Frm").submit();
}
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>

</head>

<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_plantilla3.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 PRODUCTOS</div>
</div>

<!----------------------------------------->
<div class="s1" style="left: 35px; top: 117px; width: 82px;">
CODIGO</div>
<input name="TxtCod" type="text" id="TxtCod" 
class="lt"  style="left: 35px; top: 135px; width:95px"
tabindex="<?php echo ++$TI;?>"
value="<?php echo $StrCod;?>" />

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

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

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

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

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


<!----------------------------------------->
<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" class="btm"
value="Guardar" onClick="fGuardar();" 
tabindex="<?php echo ++$TI;?>"/>
</div>
<!-----------------------------------------> 

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

<tr>
<th width="8%">CODIGO</th>
<th width="13%">LINEA</th>
<th width="17%">FABRICANTE</th>
<th width="18%">MODELO</th>
<th width="19%">DESCRIPCION</th>
<th width="11%">MARCA</th>
<th width="7%" style="text-align:right;">PV.MIN</th>
<th width="7%" style="text-align:right;">PV.MAX</th>
</tr>
</thead>
<tbody>

<?php		  		
$s="SELECT ID,COD,
	SUBSTRING(LINEA,1,20) AS LINEA,
	SUBSTRING(DESCRIPCION,1,29) AS DESCRIPCION,
	SUBSTRING(MARCA,1,15) AS MARCA,
	FORMAT(PV_MIN,1) AS PV_MIN,FORMAT(PV_MAX,1) AS PV_MAX,FAB,MODELO 
	FROM vproductos 
	WHERE $FF 
	ORDER BY DESCRIPCION,MARCA ";
	
	$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);						
	$result = grs($s);	
	while ($row = $result->fetch_assoc()){
		$_FAB="F_".$row[0];
		$_MOD="M_".$row[0];		
		?>	
        <tr>
        <!----------------------------------------------->
        <td>'<?php echo $row['COD'];?></td> 
		<td><?php echo $row['LINEA'];?></td>
		<td>
        <select name="<?php echo $_FAB;?>" id="<?php echo $_FAB;?>" 
        class="lt" style="position:inherit; width:100%" 
        tabindex="<?php echo ++$TI;?>">
        <?php echo FCBO("fab_nom","fabricantes","id_fab>0",$row[7],"N","S");?>
        </select>
        </td>
		<td>
        <select name="<?php echo $_MOD;?>" id="<?php echo $_MOD;?>"  
        class="lt" style="position:inherit; width:100%" 
        tabindex="<?php echo ++$TI;?>">
        <?php echo FCBO("mod_nom","modelos","id_mod>0",$row[8],"N","S");?>
        </select>
        </td>
		<td><?php echo $row['DESCRIPCION'];?></td>
		<td><?php echo $row['MARCA'];?></td>
		<td style="text-align:right;"><?php echo $row['PV_MIN'];?></td>
		<td style="text-align:right;"><?php echo $row['PV_MAX'];?></td>
        <!----------------------------------------------->
        </tr>
        <?php		
	}
?>		  
</tbody>
</table>
</div>

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

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