<?
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = 'index.php';
		</script>
		<? 
		exit();
		}

$id_empresa =$_SESSION['ss_empresa'];
$id_user = $_SESSION['ss_user'];
$id_autoriza=1;

include("../conex.php");
include("../autoriza.php");
if ($grabar==0)  
{
?>
		<script>
		alert ("No Autorizado");
		parent.location.href = 'index.php';
		</script>
	<? 
	exit();
}			

$post_id= $_POST["id"];
$post_rut=$_POST["txtrut"];
$post_vendedor=$_POST["lstvendedor"];
$post_empresa=$_POST["lstem"];
$post_mail=$_POST["mail"];
$post_pda=$_POST["pda"];
$pass = $_POST["pass"];

if ($pass!='') $pass = md5($pass);

if ($pass!='') $esql = "UPDATE usuarios SET clave = '$pass', mail = '$post_mail', rut = '$post_rut', id_vendedor='$post_vendedor', pda='$post_pda' WHERE id = $post_id";
else $esql = "UPDATE usuarios SET mail = '$post_mail', rut = '$post_rut', id_vendedor='$post_vendedor', pda='$post_pda' WHERE id = $post_id";

	$consulta = mysql_query($esql,$enlace);
	
$esql = "UPDATE usuario_empresa SET id_usuario = '$post_id', id_empresa = '$post_empresa' WHERE id_usuario = $post_id";
	$consulta = mysql_query($esql,$enlace);	
?>
<script language="javascript" type="text/javascript">
alert ("<?=$post_nombre.'\nActualizado Con Exito!';?>");
parent.location.href = 'index.php';
</script>