<?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='$_SESSION[kode]' and akun='$r[akun]'";
$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_select_db($database_sistem, $sistem);
$query_hitung_ttlpdp_index = "SELECT sum(debet)as debet, sum(kredit)as kredit FROM transaksi_tb where bulan='$bulan' and tahun='$tahun' and kode_unit='$_SESSION[kode]' and akun between 4000 and 4599";
$hitung_ttlpdp_index = mysql_query($query_hitung_ttlpdp_index, $sistem) or die(mysql_error());
$row_hitung_ttlpdp_index = mysql_fetch_assoc($hitung_ttlpdp_index);
$totalRows_hitung_ttlpdp_index = mysql_num_rows($hitung_ttlpdp_index);

mysql_free_result($hitung_pdp_index);
mysql_free_result($hitung_ttlpdp_index);
?>
<a href="?section=Report&module=bb_akun&akun_index=<?php echo $r['akun'];?>">
<?php
echo formatRupiah($row_hitung_pdp_index['debet']);
?></a>