<?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_sistem, $sistem);
$query_hitung_pdp_index = "SELECT sum(debet)as debet, sum(kredit)as kredit FROM transaksi_tb where bulan='$bulan' and tahun='$tahun' and kode_unit='$kode' and akun='$r[akun]'  and (transaksi='Kas' or transaksi='Bank')";
$hitung_pdp_index = mysql_query($query_hitung_pdp_index, $sistem) or die(mysql_error());
$row_hitung_pdp_index = mysql_fetch_assoc($hitung_pdp_index);
$totalRows_hitung_pdp_index = mysql_num_rows($hitung_pdp_index);


mysql_free_result($hitung_pdp_index);
?>
<?php
echo formatRupiah($row_hitung_pdp_index['debet']);
?>