<html>
<head>
<title>EDITAR JEFATURA</title>
<script type="text/javascript"> 
function VentanaClose(){ 
   
}
function GuardarJefatura(){
var idj = document.getElementById("idj").value;
var nom = document.getElementById("nomj").value;
var abrev = document.getElementById("abrevj").value;
document.location="editarjefaturadpto.php?nom="+nom+"&abrev="+abrev+"&idj="+idj;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="../styles/Style.css">
</head>
<body>
<?php
include("../bd/sql_variables.php");
$db_conexion= mysql_connect("$sql_host", "$sql_usuario", "$sql_pass") or die(header ("No Disponible Servidor de Base de Datos"));
mysql_select_db("$sql_db");



$error=3;

if(isset($_GET['nom']) && isset($_GET['abrev']) && isset($_GET['idj']) ){
$nom=$_GET['nom'];
$abrev=$_GET['abrev'];
$idj=$_GET['idj'];
$error=0;
	if($idj!=0){	
	$sql="update tb_jefatura set j_abrev=upper('$abrev'), j_desc=upper('$nom') where j_id='$idj'";
	
	$result = mysql_query($sql);
	}else{
	$error=1;
	}
}
if(isset($_GET['id'])){
$idj = $_GET['id'];
$sql="select j_abrev as abrev, j_desc as nom from tb_jefatura where j_id='$idj'";
$result = mysql_query($sql);
	while ($row= mysql_fetch_array($result)){
		$abrev=$row['abrev'];
		$nom=$row['nom'];
	}
}
$cadena = $cadena."<br><table align='center' class='TableDiseno'>";
$cadena = $cadena."<tr><td align='center' colspan='2' width='450' height='40' class='LlenarTablaGareaTitulo'><b>EDITAR JEFATURA</b></td></tr>";
$cadena = $cadena."<tr><td class ='FacetDataTextC' colspan='2' align='center'><font color='red'><b>";
if($error==1){
$cadena = $cadena." No se modifico correctamente";
}elseif($error==0){
echo "<script type='text/javascript'>window.opener.location.reload(); window.close();</script>";
}

$cadena = $cadena."</b></font></td></tr>";
$cadena = $cadena."<tr><td class ='FacetDataTextC' align='left' width='120' >Nombre Jefatura</td><td class ='FacetDataTextC'><input type='text' name='nomj' id='nomj' value='$nom' size='50'></td></tr>";
$cadena = $cadena."<tr><td class ='FacetDataTextC' align='left' >Abreviatura</td><td class ='FacetDataTextC'><input type='text' name='abrevj' id='abrevj' value='$abrev' size='15'></td></tr>";
$cadena = $cadena."<tr><td align='center' colspan='2'><input type='hidden' id='idj' name='idj' value='".$idj."'><input type='button' value='Guardar' onClick='GuardarJefatura()'><input type='button' value='Cerrar'></td></tr>";
$cadena = $cadena."</table>";
echo $cadena;
?>
</body>
</html>
