<?php require_once('../Connections/cn_conexion.php'); ?>
<?php
$id=$_GET['id_cuenta'];
?>
<?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;
}
}

mysql_select_db($database_cn_conexion, $cn_conexion);
$query_rs_cuentas = "SELECT * FROM cuentas WHERE cuentas.id_cuenta='".$id."'";
$rs_cuentas = mysql_query($query_rs_cuentas, $cn_conexion) or die(mysql_error());
$row_rs_cuentas = mysql_fetch_assoc($rs_cuentas);
$totalRows_rs_cuentas = mysql_num_rows($rs_cuentas);
?>
<form id="form2" name="form2" method="POST" action="index.php">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="30" colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><p class="rot_man">&nbsp;&nbsp;&nbsp;&nbsp;Modificar  Cuenta</p></td>
          <td align="right"><p class="rot_man">&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.php" class="rot_man">Nueva  Cuenta</a>&nbsp;&nbsp;&nbsp;&nbsp;</p></td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td width="3%">&nbsp;</td>
      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td>Nombre de Cuenta
            <input name="id_cuenta" type="hidden" id="id_cuenta" value="<?php echo $row_rs_cuentas['id_cuenta']; ?>" /></td>
        </tr>
        <tr>
          <td><input name="nom_cuenta" type="text" class="fn_text" id="nom_cuenta" value="<?php echo $row_rs_cuentas['nom_cuenta']; ?>" size="60" /></td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td width="58%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td>Tipo de Cuenta</td>
        </tr>
        <tr>
          <td><input <?php if (!(strcmp($row_rs_cuentas['tipo_cuenta'],"1"))) {echo "checked=\"checked\"";} ?> name="tipo" type="radio" id="radio3" value="1"/>
            Ingreso&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;
            <input <?php if (!(strcmp($row_rs_cuentas['tipo_cuenta'],"-1"))) {echo "checked=\"checked\"";} ?> type="radio" name="tipo" id="radio4" value="-1" />
            Egreso </td>
        </tr>
      </table></td>
      <td width="39%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td>Habilitado</td>
        </tr>
        <tr>
          <td><input <?php if (!(strcmp($row_rs_cuentas['hab_cuenta'],"1"))) {echo "checked=\"checked\"";} ?> name="habilitado" type="radio" id="radio" value="1" checked="checked" />
            Si&nbsp;&nbsp;
            <input <?php if (!(strcmp($row_rs_cuentas['hab_cuenta'],"0"))) {echo "checked=\"checked\"";} ?> name="habilitado" type="radio" id="radio2" value="0" />
            No </td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td height="30">&nbsp;</td>
      <td><input type="submit" name="button2" id="button2" value="Actualizar" /></td>
    </tr>
  </table>
  <input name="MM_update" type="hidden" id="MM_update" value="form2" />
</form>
<?php
mysql_free_result($rs_cuentas);
?>
