<?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_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO akun_tb (akun, perkiraan, keterangan, kelompok, jenis, akb, kode_unit, konten) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['akun'], "text"),
                       GetSQLValueString($_POST['perkiraan'], "text"),
                       GetSQLValueString($_POST['keterangan'], "text"),
                       GetSQLValueString($_POST['kelompok'], "text"),
                       GetSQLValueString($_POST['jenis'], "text"),
                       GetSQLValueString($_POST['akb'], "text"),
                       GetSQLValueString($_POST['kode_unit'], "text"),
                       GetSQLValueString($_POST['konten'], "text"));

  mysql_select_db($database_sistem, $sistem);
  $Result1 = mysql_query($insertSQL, $sistem) or die(mysql_error());
}
?>

<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table class="isi_tabel" align="left" cellpadding="4" cellspacing="4">
    <tr valign="baseline">
      <td colspan="2" align="left" nowrap><h2><span style="color:#033">Tambahkan Akun</span> Pendapatan &amp; Pengeluaran</h2></td>
    </tr>
    <tr valign="baseline">
      <td align="left" valign="top" nowrap>Akun</td>
      <td><input name="akun" type="text" value="" size="4" maxlength="4"></td>
    </tr>
    <tr valign="baseline">
      <td align="left" valign="top" nowrap>Perkiraan</td>
      <td><input name="perkiraan" type="text" value="" size="4" maxlength="4"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="left" valign="top">Jenis Akun</td>
      <td><input type="radio" name="kelompok" id="radio" value="Pendapatan">
      Pendapatan</td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="left" valign="top">&nbsp;</td>
      <td valign="top"><input type="radio" name="kelompok" id="radio2" value="Pengeluaran" />
Pengeluaran </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="left" valign="top">Keterangan</td>
      <td valign="top"><textarea name="keterangan" cols="40" rows="2"></textarea></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="left" valign="top">Konten</td>
      <td valign="top"><textarea name="konten" cols="40" rows="3"></textarea></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="left">&nbsp;</td>
      <td><?php 
	  if($_SESSION['level']=='Unit'){
	  ?>
	  <input class="button" name="Submit" type="submit" value="Tambahkan Data Akun" disabled>
      <input class="button" name="Submit2" type="reset" value="Reset">
      <?php }
	  elseif($_SESSION['level']=='Pusat'){
	  ?>
      <input class="button" name="Submit" type="submit" value="Tambahkan Data Akun">
      <input class="button" name="Submit2" type="reset" value="Reset">
      <?php
	  }
	  ?>
      </td>
    </tr>
  </table>
  <input type="hidden" name="jenis" value="Kas">
  <input type="hidden" name="kode_unit" value="All" size="32">
<input type="hidden" name="akb" value="Ya">
  <input type="hidden" name="index" value="">
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
