<?php






session_start();
//include "./conexionII.php";

    $server="localhost";
	$username="quimico4_mc_admi";
	$password="CO2316255129238111";
	$db='quimico4_mauricio_correa';
	$con=mysql_connect($server,$username,$password)or die("No se ha podido establecer la conexion");
	$sdb=mysql_select_db($db,$con)or die("La base de datos no existe");

if(isset($_SESSION['Usuario'])){
    //Valido si es Admin para dejarlo en Registro
    if($_SESSION['Admin'] == 'S') {

    //Si es admin lo dejo
    }else{



   header("Location: /MauricioCorrea/Noadmin.html");
    }


}else{

    //Si no le muestro otra página, puede ser la de Login
    header("Location: /MauricioCorrea/incorrecto.html");
}

if(isset($_SESSION['Variable'])){
if($_SESSION['Variable'] > 5){
$_SESSION['Variable'] = 1;
}else{
$_SESSION['Variable'] = $_SESSION['Variable'] + 1;
}
}else{
$_SESSION['Variable'] = 1;
}
//echo $_SESSION['Variable'];
?>

<!DOCTYPE html>





<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head><meta http-equiv="Content-Type" content="text/html; charset=gb18030">
        <title>Modificar producto</title>
                         <link rel="icon" type="image/png" href="imagenes/compra.png" />
          
 <script type="text/javascript" src="Js/jquery.min.js" ></script>
        <link rel="stylesheet" type="text/css" href="estilos.css">
        <link rel="stylesheet" type="text/css" href="fonts.css">
        
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
        <script src="Js/jquery-1.11.3.min.js"></script>
        <script src="Js/jquery-ui.js"></script>
<script src="menu.js"></script>
<style>
#ui-id-1{
    background-color: white;
    opacity: 0.7;
}
</style>
<script>
function Reset() {
    document.getElementById("Form").reset();
}
</script>
<script>
            $(function(){

var Nume = '<?php echo $_SESSION['Variable']; ?>';
//document.write('Nume = ' + Nume);
if (Nume == 1){
//alert("Se vino por el 1.");
                $("#buscador").autocomplete({


                    source: 'buscadorproductosI.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del producto: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" id="Form">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Codigo*</div></span><input type="text" value="'+ ui.item.codigoProducto +'" name="codigo" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Descripcion*</div></span><input type="text" value="'+ ui.item.value +'" name="descripcion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Precio*</div></span><input type="number" min="0" value="'+ ui.item.precioProducto +'" name="precio" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Costo*</div></span><input type="number" min="0"  value="'+ ui.item.costoProducto +'" name="costo" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>IVA*</div></span><input type="number" min="0" value="'+ ui.item.ivaProducto +'" name="iva" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Saldo*</div></span><input type="number" min="0" value="'+ ui.item.saldoProducto +'" name="saldo" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td colspan="2"><span class="required"><div><font size ="3", color ="#F1F1F1"> A </font></div></span><input type="submit" name="mod" Value="Registrar" style="width:790px; height:33px; " ></td></tr></table>'

                        );
                    }
                });
}else if (Nume == 2){
//alert("Se vino por el 2.");
                $("#buscador").autocomplete({

                    source: 'buscadorproductosII.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del producto: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" id="Form">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Codigo*</div></span><input type="text" value="'+ ui.item.codigoProducto +'" name="codigo" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Descripcion*</div></span><input type="text" value="'+ ui.item.value +'" name="descripcion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Precio*</div></span><input type="number" min="0" value="'+ ui.item.precioProducto +'" name="precio" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Costo*</div></span><input type="number" min="0"  value="'+ ui.item.costoProducto +'" name="costo" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>IVA*</div></span><input type="number" min="0" value="'+ ui.item.ivaProducto +'" name="iva" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Saldo*</div></span><input type="number" min="0" value="'+ ui.item.saldoProducto +'" name="saldo" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td colspan="2"><span class="required"><div><font size ="3", color ="#F1F1F1"> A </font></div></span><input type="submit" name="mod" Value="Registrar" style="width:790px; height:33px; " ></td></tr></table>'

                        );
                    }
                });
}else if (Nume == 3){
//alert("Se vino por el 3.");
                $("#buscador").autocomplete({

                    source: 'buscadorproductosIII.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del producto: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" id="Form">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Codigo*</div></span><input type="text" value="'+ ui.item.codigoProducto +'" name="codigo" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Descripcion*</div></span><input type="text" value="'+ ui.item.value +'" name="descripcion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Precio*</div></span><input type="number" min="0" value="'+ ui.item.precioProducto +'" name="precio" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Costo*</div></span><input type="number" min="0"  value="'+ ui.item.costoProducto +'" name="costo" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>IVA*</div></span><input type="number" min="0" value="'+ ui.item.ivaProducto +'" name="iva" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Saldo*</div></span><input type="number" min="0" value="'+ ui.item.saldoProducto +'" name="saldo" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td colspan="2"><span class="required"><div><font size ="3", color ="#F1F1F1"> A </font></div></span><input type="submit" name="mod" Value="Registrar" style="width:790px; height:33px; " ></td></tr></table>'

                        );
                    }
                });
}else if (Nume == 4){
//alert("Se vino por el 4.");
                $("#buscador").autocomplete({

                    source: 'buscadorproductosIV.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del producto: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" id="Form">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Codigo*</div></span><input type="text" value="'+ ui.item.codigoProducto +'" name="codigo" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Descripcion*</div></span><input type="text" value="'+ ui.item.value +'" name="descripcion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Precio*</div></span><input type="number" min="0" value="'+ ui.item.precioProducto +'" name="precio" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Costo*</div></span><input type="number" min="0"  value="'+ ui.item.costoProducto +'" name="costo" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>IVA*</div></span><input type="number" min="0" value="'+ ui.item.ivaProducto +'" name="iva" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Saldo*</div></span><input type="number" min="0" value="'+ ui.item.saldoProducto +'" name="saldo" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td colspan="2"><span class="required"><div><font size ="3", color ="#F1F1F1"> A </font></div></span><input type="submit" name="mod" Value="Registrar" style="width:790px; height:33px; " ></td></tr></table>'

                        );
                    }
                });
}else{
//alert("Se vino por el 5.");
                $("#buscador").autocomplete({
                    source: 'buscadorproductosV.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del producto: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" id="Form">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Codigo*</div></span><input type="text" value="'+ ui.item.codigoProducto +'" name="codigo" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Descripcion*</div></span><input type="text" value="'+ ui.item.value +'" name="descripcion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Precio*</div></span><input type="number" min="0" value="'+ ui.item.precioProducto +'" name="precio" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Costo*</div></span><input type="number" min="0"  value="'+ ui.item.costoProducto +'" name="costo" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>IVA*</div></span><input type="number" min="0" value="'+ ui.item.ivaProducto +'" name="iva" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Saldo*</div></span><input type="number" min="0" value="'+ ui.item.saldoProducto +'" name="saldo" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td colspan="2"><span class="required"><div><font size ="3", color ="#F1F1F1"> A </font></div></span><input type="submit" name="mod" Value="Registrar" style="width:790px; height:33px; " ></td></tr></table>'

                        );
                    }
                });
}

            });
        </script>
                
    </head>
    <body>
        
        <header>
<?php
if(isset($_SESSION['Usuario'])){

echo '<a class="datosusuario icon-exit" href="/MauricioCorrea/Cerrar.php"> - Salir</a>';
echo '<span class="datosusuario icon-users"> - Bienvenido '.$_SESSION['Nombre'].'</span>';


}else{
    header("Location: /MauricioCorrea/incorrecto.html");
}


?>


       <div class="menu_bar">
        <a href="#" class="bt-menu"><span class="icon-newspaper"></span>Menu</a>
        </div>
            <nav>
                <ul>
                    <li><a href="inicio.php"><span class="icon-home"> </span>Inicio</a></li>  
                    <li class="submenu">
                    <a href="#"><span class="icon-user-tie"></span>Admin<span class="caret icon-circle-down"></span></a>    
                    <ul class="children">
                        <li><a href="Registro.php" ><span class="icon-user-plus"></span>Crea Vendedor</a></li>
                        <li><a href="ModificaVendedor.php" ><span class="icon-pencil"></span>Modifica Vendedor</a></li>
                        <li><a href="RegistroCliente.php" ><span class="icon-user-plus"></span>Crea Cliente <span class="user-plus"></a></li>
                        <li><a href="RegistroProveedor.php" ><span class="icon-user-plus"></span>Crea Proveedor <span class="user-plus"></a></li>
                       

                    </ul>
                    </li>


                    <li class="submenu">
                     <a href="#"><span class="icon-cart"> </span>Vend<span class="caret icon-circle-down"></span></a>
                      <ul class="children">
                        <li><a href="RegistroCliente.php" ><span class="icon-user-plus"></span>Crea Cliente <span class=""></a></li>
                        <li><a href="RegistroVenta.php" ><span class="icon-cart"></span>Crea Factura <span class=""></a></li>
                        <li><a href="RegistroRemision.php" ><span class="icon-file-text2"></span>Crea Remision <span class=""></a></li>
                        <li><a href="RegistroNota.php" ><span class="icon-files-empty"></span>Crea Nota <span class=""></a></li>
                    </ul>
                    </li>    





                     <li class="submenu">
                    <a href="#.php"><span class="icon-users"> </span>Clientes<span class="caret icon-circle-down"></span></a>    
                   <ul class="children">  
                    
                    <li><a href="RegistraCongelador.php"><span class="icon-credit-card"> </span>Registra Congelador</a></li>  
                    <li><a href="ModificaCliente.php"><span class="icon-user-check"> </span>Modificar Cliente</a></li>  
                    <li><a href="InformesClientes.php"><span class="icon-profile"> </span>Informe Clientes</a></li> 
                    <li><a href="InformesVentas.php"><span class="icon-calculator"> </span>Informe Ventas</a></li> 
                    </ul> 
                     </li>        

                       <li class="submenu">
                    <a href="#"><span class="icon-user-tie"></span>Proveedores<span class="caret icon-circle-down"></span></a>    
                    <ul class="children">
                    <li><a href="RegistroCompra.php" ><span class="icon-plus"></span>Carga Compra <span class="plus"></a></li>
                        <li><a href="ModificaProveedor.php" ><span class="icon-user-plus"></span>Modificar Proveedor</a></li>
                        
                        <li><a href="InformesCompras.php" ><span class="icon-stats-bars2"></span>Informe Compras <span class="plus"></a></li>

                    </ul>
                    </li>



                                        
                    <li class="submenu">
                    <a href="#.php"><span class="icon-droplet"> </span>Prod<span class="caret icon-circle-down"></span></a>    
                   <ul class="children">
                        <li><a href="CrearProducto.php" ><span class="icon-barcode"></span>Crea Producto <span class=""></a></li>
                        <li><a href="ModificarProducto.php" ><span class="icon-qrcode"></span>Modifica Producto <span class=""></a></li>
                        <li><a href="InformesInventarios.php" ><span class="icon-files-empty"></span>Informe Inventario <span class=""></a></li>
                    </ul> 
                     </li>    
                    <li><a href="Cerrar.php"><span class="icon-exit"> </span>Salir</a></li>                    
                </ul>
            </nav>
        </header>
        
              <section id="TablaLog1">
            <div><p id="Titulo"> Modificar producto</p></div>
                                <div>Ingrese la descripcion del producto: </div><br>
<div id="buscar">
            <input type="text" name="buscador" id="buscador" style="width:370px; height:30px;" />
        </div>
        <div id="resultado"></div>



                <?php
      if (isset($_GET['mod'])) {
$codigo= $_GET['codigo'];

                mysql_query("update productos set descripcion ='".$_GET['descripcion']."' where codigo =".$codigo);
                mysql_query("update productos set precio1 ='".$_GET['precio']."' where codigo =".$codigo);
                mysql_query("update productos set iva ='".$_GET['iva']."' where codigo =".$codigo);
                mysql_query("update productos  set costo ='".$_GET['costo']."' where  codigo =".$codigo);
                mysql_query("update productos  set saldo ='".$_GET['saldo']."' where  codigo =".$codigo);

//echo 'Variable '.$_SESSION['Variable'];  

               echo '<script language="javascript">alert("El producto se ha actualizado correctamente en la base de datos.");</script><br>'; 
              // echo"<script language='javascript'>window.location='inicio.php'</script>;";


                }

                

                
                
                ?>

                
              


 
       

        </section> 
          </section> 

    </body>
</html>