<?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;
}


?>

<!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>
        <title>Modificar cliente</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 charset="UTF-8">
        <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(){

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

                $("#buscador").autocomplete({
                    source: 'buscadormod.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del cliente: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" name="">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Cliente*</div></span><input type="text" value="'+ ui.item.value +'" name="nombre" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ced*</div></span><input type="text" value="'+ ui.item.idUsuario +'" name="nit" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Establecimiento*</div></span><input type="text" value="'+ ui.item.establecimientoUsuario +'" name="apellido" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ciudad*</div></span><input type="text" value="'+ ui.item.ciudadUsuario +'" name="ciudad"  autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Direccion*</div></span><input type="text" value="'+ ui.item.direccionUsuario +'" name="direccion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Teléfono*</div></span><input type="number" value="'+ ui.item.telefonoUsuario +'" name="telefono" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Celular*</div></span><input type="number" value="'+ ui.item.celularUsuario +'" name="celular" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Correo*</div></span><input type="text" value="'+ ui.item.correoUsuario +'" name="correo"  autofocus="autofocus" 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: 'buscadorI.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del cliente: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" name="">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Cliente*</div></span><input type="text" value="'+ ui.item.value +'" name="nombre" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ced*</div></span><input type="text" value="'+ ui.item.idUsuario +'" name="nit" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Establecimiento*</div></span><input type="text" value="'+ ui.item.establecimientoUsuario +'" name="apellido" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ciudad*</div></span><input type="text" value="'+ ui.item.ciudadUsuario +'" name="ciudad"  autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Direccion*</div></span><input type="text" value="'+ ui.item.direccionUsuario +'" name="direccion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Teléfono*</div></span><input type="number" value="'+ ui.item.telefonoUsuario +'" name="telefono" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Celular*</div></span><input type="number" value="'+ ui.item.celularUsuario +'" name="celular" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Correo*</div></span><input type="text" value="'+ ui.item.correoUsuario +'" name="correo"  autofocus="autofocus" 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){
                $("#buscador").autocomplete({
                    source: 'buscadorII.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del cliente: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" name="">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Cliente*</div></span><input type="text" value="'+ ui.item.value +'" name="nombre" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ced*</div></span><input type="text" value="'+ ui.item.idUsuario +'" name="nit" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Establecimiento*</div></span><input type="text" value="'+ ui.item.establecimientoUsuario +'" name="apellido" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ciudad*</div></span><input type="text" value="'+ ui.item.ciudadUsuario +'" name="ciudad"  autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Direccion*</div></span><input type="text" value="'+ ui.item.direccionUsuario +'" name="direccion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Teléfono*</div></span><input type="number" value="'+ ui.item.telefonoUsuario +'" name="telefono" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Celular*</div></span><input type="number" value="'+ ui.item.celularUsuario +'" name="celular" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Correo*</div></span><input type="text" value="'+ ui.item.correoUsuario +'" name="correo"  autofocus="autofocus" 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){
                $("#buscador").autocomplete({
                    source: 'buscadorIII.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del cliente: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" name="">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Cliente*</div></span><input type="text" value="'+ ui.item.value +'" name="nombre" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ced*</div></span><input type="text" value="'+ ui.item.idUsuario +'" name="nit" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Establecimiento*</div></span><input type="text" value="'+ ui.item.establecimientoUsuario +'" name="apellido" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ciudad*</div></span><input type="text" value="'+ ui.item.ciudadUsuario +'" name="ciudad"  autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Direccion*</div></span><input type="text" value="'+ ui.item.direccionUsuario +'" name="direccion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Teléfono*</div></span><input type="number" value="'+ ui.item.telefonoUsuario +'" name="telefono" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Celular*</div></span><input type="number" value="'+ ui.item.celularUsuario +'" name="celular" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Correo*</div></span><input type="text" value="'+ ui.item.correoUsuario +'" name="correo"  autofocus="autofocus" 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 == 5){
                $("#buscador").autocomplete({
                    source: 'buscadorIV.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del cliente: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" name="">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Cliente*</div></span><input type="text" value="'+ ui.item.value +'" name="nombre" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ced*</div></span><input type="text" value="'+ ui.item.idUsuario +'" name="nit" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Establecimiento*</div></span><input type="text" value="'+ ui.item.establecimientoUsuario +'" name="apellido" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ciudad*</div></span><input type="text" value="'+ ui.item.ciudadUsuario +'" name="ciudad"  autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Direccion*</div></span><input type="text" value="'+ ui.item.direccionUsuario +'" name="direccion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Teléfono*</div></span><input type="number" value="'+ ui.item.telefonoUsuario +'" name="telefono" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Celular*</div></span><input type="number" value="'+ ui.item.celularUsuario +'" name="celular" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Correo*</div></span><input type="text" value="'+ ui.item.correoUsuario +'" name="correo"  autofocus="autofocus" 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{
                $("#buscador").autocomplete({
                    source: 'buscadorV.php',
                    select: function(event, ui){
                        $("#resultado").html(
'<br>'+
'Se dispone a modificar los datos del cliente: '+
ui.item.value + '<br>' + 
//'id de usuario: ' + 
//ui.item.idUsuario + '<br>' + 
' <form method="get" name="">' + 
' <table    cellspacing="35"  style="margin: 0 auto;" >'+
'<tr><td><span class="required"><div>Cliente*</div></span><input type="text" value="'+ ui.item.value +'" name="nombre" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ced*</div></span><input type="text" value="'+ ui.item.idUsuario +'" name="nit" readonly autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Establecimiento*</div></span><input type="text" value="'+ ui.item.establecimientoUsuario +'" name="apellido" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Ciudad*</div></span><input type="text" value="'+ ui.item.ciudadUsuario +'" name="ciudad"  autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Direccion*</div></span><input type="text" value="'+ ui.item.direccionUsuario +'" name="direccion" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Teléfono*</div></span><input type="number" value="'+ ui.item.telefonoUsuario +'" name="telefono" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td></tr>'+
'<tr><td><span class="required"><div>Celular*</div></span><input type="number" value="'+ ui.item.celularUsuario +'" name="celular" min="0" max="9999999999" autofocus="autofocus" required="required" class="required" style="width:370px; height:30px;"></td>'+
'<td><span class="required"><div>Correo*</div></span><input type="text" value="'+ ui.item.correoUsuario +'" name="correo"  autofocus="autofocus" 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 cliente</p></div>
                                <div>Ingrese el nombre del cliente: </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'])) {
$nit = $_GET['nit'];

                     
			
                mysql_query("update clientes set nombre ='".$_GET['nombre']."' where numerodocumento  =".$nit);
                mysql_query("update clientes set apellido ='".$_GET['apellido']."' where numerodocumento  =".$nit);
                mysql_query("update clientes set ciudad ='".$_GET['ciudad']."' where numerodocumento  =".$nit);
                mysql_query("update clientes set direccion ='".$_GET['direccion']."' where  numerodocumento  =".$nit);
                mysql_query("update clientes set telefono ='".$_GET['telefono']."' where  numerodocumento  =".$nit);
                mysql_query("update clientes set celular ='".$_GET['celular']."' where  numerodocumento  =".$nit);

                mysql_query("update clientes set correo ='".$_GET['correo']."' where numerodocumento =".$nit);   
          	

                	
		unset($_SESSION['datos']);
        
        
                echo '<script language="javascript">alert("El cliente se ha actualizado correctamente en la base de datos.");</script><br>'; 
                //echo"<script language='javascript'>window.location='ModificarCliente.php'</script>;";
                }
                
                

                
                
                ?>

                
              


 
       

        </section> 
          </section> 

    </body>
</html>