<?php
mysql_select_db($database_sistem, $sistem);
$query_unit = "SELECT * FROM user_tb WHERE user_tb.`level`='Unit'";
$unit = mysql_query($query_unit, $sistem) or die(mysql_error());
$row_unit = mysql_fetch_assoc($unit);
$totalRows_unit = mysql_num_rows($unit);
?>
<?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"] == "form2")) {
  $insertSQL = sprintf("INSERT INTO aktiva_tb (akun, keterangan, nominal, kode_unit, bulan, tahun, reg) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['akun'], "text"),
                       GetSQLValueString($_POST['keterangan'], "text"),
                       GetSQLValueString($_POST['nominal'], "text"),
                       GetSQLValueString($_POST['kode_unit'], "text"),
                       GetSQLValueString($_POST['bulan'], "text"),
                       GetSQLValueString($_POST['tahun'], "text"),
                       GetSQLValueString($_POST['reg'], "text"));

  mysql_select_db($database_sistem, $sistem);
  $Result1 = mysql_query($insertSQL, $sistem) or die(mysql_error());
}
?>
<script type="text/javascript" charset="utf-8">
          $(document).ready(function(){
            $('#bbkas').dataTable({
					     "oLanguage": {
						      "sLengthMenu": "Tampilkan _MENU_ data per halaman",
						      "sSearch": "Pencarian: ", 
						      "sZeroRecords": "Maaf, tidak ada data yang ditemukan",
						      "sInfo": "Menampilkan _START_ s/d _END_ dari _TOTAL_ data",
						      "sInfoEmpty": "Menampilkan 0 s/d 0 dari 0 data",
						      "sInfoFiltered": "(di filter dari _MAX_ total data)",
						      "oPaginate": {
						          "sFirst": "<<",
						          "sLast": ">>", 
						          "sPrevious": "<", 
						          "sNext": ">"
					       }
				      },
              "sPaginationType":"full_numbers",
              "bJQueryUI":true
            });
          })    
        </script>

<p>&nbsp;</p>
<table width="75%" border="0" align="center" cellpadding="5" cellspacing="5" background="images/tr2.png">
  <tr>
    <td><h3>Tabel Data Aktiva Awal</h3></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="2" class="form_body">
      <tr align="center">
        <td background="images/bg1.png"  height="30">kode unit</td>
        <td background="images/bg1.png">nama unit</td>
        <td background="images/bg1.png">alamat</td>
        <td background="images/bg1.png">telp</td>
        <td background="images/bg1.png">email</td>
        <td background="images/bg1.png">direktur</td>
        <td background="images/bg1.png">bendahara</td>
        <td background="images/bg1.png">nama admin</td>
      </tr>
      <tr align="center">
        <td colspan="8"><hr /></td>
      </tr>
      <?php do { ?>
      <tr align="center">
        <td><a href="?module=show_aktiva&amp;kodenya=<?php echo $row_unit['kode_unit'];?>"><?php echo $row_unit['kode_unit']; ?></a></td>
        <td><?php echo $row_unit['nama_unit']; ?></td>
        <td><?php echo $row_unit['alamat']; ?></td>
        <td><?php echo $row_unit['telp']; ?></td>
        <td><?php echo $row_unit['email']; ?></td>
        <td><?php echo $row_unit['direktur']; ?></td>
        <td><?php echo $row_unit['bendahara']; ?></td>
        <td><?php echo $row_unit['nama_admin']; ?></td>
      </tr>
      <tr align="center">
        <td colspan="8"><hr /></td>
      </tr>
      <?php } while ($row_unit = mysql_fetch_assoc($unit)); ?>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" align="center"  bgcolor="#FFFFFF" class="display" id="bbkas">
      <thead>
        <tr height="40" class="form_body">
          <th align="center" width="100">No</th>
          <th align="center">Kode Aktiva</th>
          <th align="center">Keterangan</th>
          <th align="center">Nominal</th>
          <th align="center">Bulan</th>
          <th align="center">Tahun</th>
        </tr>
        </thead>
      <tbody>
      
        <?php        mysql_select_db("csabrude_akurat");
					          $sql = mysql_query("SELECT * From aktiva_tb where kode_unit='-' order by akun asc");
					          $no = 1;
							
                    while ($r = mysql_fetch_array($sql)) {
                      echo "<tr height='25'>
          <td align='center'>$no</td>
		  <td align='center'>$r[akun]</td>
            <td align='left'>$r[keterangan]</td>
			<td align='right'>";?><?php echo formatRupiah($r['nominal']);?><?php echo"</td>
			<td align='center'>$r[bulan]</td>
			<td align='center'>$r[tahun]</td>
          </tr>";
                      $no++;
                    }
                    ?>
      </tbody>
      <tfoot>
        </tfoot>
    </table></td>
  </tr>
  <tr>
    <td><hr /></td>
  </tr>
</table>
<p>&nbsp;</p>
        