<?php require_once('Connections/roldanillo.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE radicacion SET radicacion=%s, instancia=%s, proceso=%s, subclase=%s, daterepar=%s, dte=%s, ccnitdte=%s, dirteldte=%s, apodte=%s, dirapodte=%s, telapodte=%s, emailapodte=%s, ddo=%s, ccnitddo=%s, dirtelddo=%s, apoddo=%s, dirapoddo=%s, telapoddo=%s, emailapoddo=%s, observacion=%s, matinm=%s, namepred=%s, classmed=%s, actuacion=%s, dateactua=%s, cuaderno=%s WHERE id=%s",
                       GetSQLValueString($_POST['radicacion'], "text"),
                       GetSQLValueString($_POST['instancia'], "text"),
                       GetSQLValueString($_POST['proceso'], "text"),
                       GetSQLValueString($_POST['subclase'], "text"),
                       GetSQLValueString($_POST['daterepar'], "date"),
                       GetSQLValueString($_POST['dte'], "text"),
                       GetSQLValueString($_POST['ccnitdte'], "text"),
                       GetSQLValueString($_POST['dirteldte'], "text"),
                       GetSQLValueString($_POST['nameapodte'], "text"),
                       GetSQLValueString($_POST['dirapodte'], "text"),
                       GetSQLValueString($_POST['telapodte'], "text"),
                       GetSQLValueString($_POST['emailapodte'], "text"),
                       GetSQLValueString($_POST['ddo'], "text"),
                       GetSQLValueString($_POST['ccnitddo'], "text"),
                       GetSQLValueString($_POST['dirtelddo'], "text"),
                       GetSQLValueString($_POST['nameapoddo'], "text"),
                       GetSQLValueString($_POST['dirapoddo'], "text"),
                       GetSQLValueString($_POST['telapoddo'], "text"),
                       GetSQLValueString($_POST['emailapoddo'], "text"),
                       GetSQLValueString($_POST['observacion'], "text"),
                       GetSQLValueString($_POST['matinm'], "int"),
                       GetSQLValueString($_POST['namepred'], "text"),
                       GetSQLValueString($_POST['classmed'], "text"),
                       GetSQLValueString($_POST['actuacion'], "text"),
                       GetSQLValueString($_POST['dateactua'], "date"),
                       GetSQLValueString($_POST['cuaderno'], "text"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_roldanillo, $roldanillo);
  $Result1 = mysql_query($updateSQL, $roldanillo) or die(mysql_error());

  $updateGoTo = "messagerad.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
$varradicacion_modificar = "-1";
if (isset($_POST['radicacion'])) {
  $varradicacion_modificar = $_POST['radicacion'];
}
mysql_select_db($database_roldanillo, $roldanillo);
$query_modificar = sprintf("SELECT * FROM radicacion WHERE radicacion = %s", GetSQLValueString($varradicacion_modificar, "text"));
$modificar = mysql_query($query_modificar, $roldanillo) or die(mysql_error());
$row_modificar = mysql_fetch_assoc($modificar);
$totalRows_modificar = mysql_num_rows($modificar);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Radicacin</title>
<link href="CSS/registro.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body,td,th {
	color: #198D19;
	font-weight: normal;
	text-align: center;
}
</style>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
</head>

<body bgcolor="#FFFFFF">

<div class="container">
  <div class="header"><!-- end .header -->
    <div class="logueoHeader">
      <p>Bienvenido Usuario <?php echo $_SESSION['MM_Username'] ?> </p>
      <p>Registro de Datos</p>
    </div>
  </div>
  <div class="content">
  <div>
  <ul id="MenuBar1" class="MenuBarHorizontal">
    <li><a href="consrad.php">Radicaci&oacute;n</a></li>
    <li><a href="registro.php">Registro</a></li>
    <li><a href="#">Reportes</a></li>
    <li><a href="<?php echo $logoutAction ?>">Finalizar</a></li>
  </ul>
  </div>
  
<h1>&nbsp;</h1>
<h1>Radicacin</h1>
<p>&nbsp;</p>
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <table align="center">
    <tr valign="baseline">
      <td width="224" align="right" nowrap="nowrap">Radicacion:</td>
      <td width="303"><input name="radicacion" type="text" value="<?php echo $row_modificar['radicacion']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Instancia:</td>
      <td><label for="instancia"></label>
        <label for="instancia3"></label>
        <select name="instancia" id="instancia3" title="<?php echo $row_modificar['instancia']; ?>">

          <option value="<?php echo $row_modificar['instancia']; ?>"><?php echo $row_modificar['instancia']; ?></option>
          <option value="Primera">Primera</option>
          <option value="Segunda">Segunda</option>
        </select>
<label for="instancia2"></label></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Proceso:</td>
      <td><label for="proceso"></label>
        <select name="proceso" id="proceso" title="<?php echo $row_modificar['proceso']; ?>">
          
          <option value="<?php echo $row_modificar['proceso']; ?>"><?php echo $row_modificar['proceso']; ?></option>
          <option value="Abreviado">Abreviado</option>
          <option value="Accin">Accin</option>
          <option value="Consulta Desacato">Consulta desacato</option>
          <option value="Deslinde y Amojonamiento">Deslinde y Amojonamiento</option>
          <option value="Despacho Comisorio">Despacho Comisorio</option>
          <option value="Divisorio">Divisorio</option>
          <option value="Ejecutivo">Ejecutivo</option>
          <option value="Expropiacin">Expropiacin</option>
          <option value="Habeas Corpus">Habeas Corpus</option>
          <option value="Liquidacin">Liquidacin</option>
          <option value="Ordinario">Ordinario</option>
          <option value="Otros">Otros</option>
          <option value="Reorganizacin">Reorganizacin</option>
          <option value="Validacin">Validacin</option>
          <option value="Verbal">Verbal</option>
        </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Subclase:</td>
      <td><label for="subclase"></label>
        <select name="subclase" id="subclase" title="<?php echo $row_modificar['subclase']; ?>">
          <option value="<?php echo $row_modificar['subclase']; ?>"><?php echo $row_modificar['subclase']; ?></option>
          <option value="Agrario">Agrario</option>
          <option value="Grupo">Grupo</option>
          <option value="Hipotecario">Hipotecario</option>
          <option value="Lesin Enorme">Lesin Enorme</option>
          <option value="Mixto">Mixto</option>
          <option value="Pertenencia">Pertenencia</option>
          <option value="Popular">Popular</option>
          <option value="RCC">RCC</option>
          <option value="RCE">RCE</option>
          <option value="Simulacin">Simulacin</option>
          <option value="Singular">Singular</option>
          <option value="Tutela">Tutela</option>
        </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Fecha de Reparto:</td>
      <td><input name="daterepar" type="text" value="<?php echo $row_modificar['daterepar']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Demandante:</td>
      <td><input name="dte" type="text" value="<?php echo $row_modificar['dte']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">CC-NIT:</td>
      <td><input name="ccnitdte" type="text" value="<?php echo $row_modificar['ccnitdte']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Direccin y Telfono:</td>
      <td><input name="dirteldte" type="text" value="<?php echo $row_modificar['dirteldte']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Apoderado Demandante:</td>
      <td><input name="apodte" type="text" value="<?php echo $row_modificar['nameapodte']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Direccin:</td>
      <td><input name="dirapodte" type="text" value="<?php echo $row_modificar['dirapodte']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Telfono:</td>
      <td><input name="telapodte" type="text" value="<?php echo $row_modificar['telapodte']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Email:</td>
      <td><input name="emailapodte" type="text" value="<?php echo $row_modificar['emailapodte']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Demandado:</td>
      <td><input name="ddo" type="text" value="<?php echo $row_modificar['ddo']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">CC-NIT:</td>
      <td><input name="ccnitddo" type="text" value="<?php echo $row_modificar['ccnitddo']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Direccin y Telfono:</td>
      <td><input name="dirtelddo" type="text" value="<?php echo $row_modificar['dirtelddo']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Apoderado Demandado:</td>
      <td><input name="apoddo" type="text" value="<?php echo $row_modificar['nameapoddo']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Direccin:</td>
      <td><input name="dirapoddo" type="text" value="<?php echo $row_modificar['dirapoddo']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Telfono:</td>
      <td><input name="telapoddo" type="text" value="<?php echo $row_modificar['telapoddo']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Email:</td>
      <td><input name="emailapoddo" type="text" value="<?php echo $row_modificar['emailapoddo']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Observacion:</td>
      <td><label for="observacion"></label>
        <textarea name="observacion" id="observacion" cols="45" rows="5"><?php echo $row_modificar['observacion']; ?></textarea></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Matricula inmobiliaria:</td>
      <td><input name="matinm" type="text" value="<?php echo $row_modificar['matinm']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Nombre del Predio:</td>
      <td><input name="namepred" type="text" value="<?php echo $row_modificar['namepred']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Clase de Medidad:</td>
      <td><input name="classmed" type="text" value="<?php echo $row_modificar['classmed']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Actuacion:</td>
      <td><input type="text" name="actuacion" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Fecha de actuacion:</td>
      <td><input type="text" name="dateactua" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Cuaderno:</td>
      <td><input type="text" name="cuaderno" size="32" /></td>
    </tr>
     <tr valign="baseline">
      <td colspan="2" align="right" nowrap="nowrap"><input type="submit" name="modificar" id="modificar" value="Actualizar Registros" /></td>
      </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1" />
  <input type="hidden" name="id" value="<?php echo $row_modificar['id']; ?>" />
</form>
<p>&nbsp;</p>
<!-- end .content --></div>
  <div class="footer">
    <p><!-- end .footer --></p>
  </div>
<!-- end .container --></div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>

<?php
mysql_free_result($modificar);
?>
