<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<?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 rab_tb (akun, perkiraan, kode, nominal, keterangan, bln_terapan, januari, februari, maret, april, mei, juni, juli, agustus, september, oktober, november, desember, thn_ajuan, jenis) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['akun'], "text"),
                       GetSQLValueString($_POST['perkiraan'], "text"),
                       GetSQLValueString($_POST['kode'], "text"),
                       GetSQLValueString($_POST['nominal'], "text"),
                       GetSQLValueString($_POST['keterangan'], "text"),
                       GetSQLValueString($_POST['bln_terapan'], "text"),
                       GetSQLValueString(isset($_POST['januari']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['februari']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['maret']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['april']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['mei']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['juni']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['juli']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['agustus']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['september']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['oktober']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['november']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['desember']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString($_POST['thn_ajuan'], "text"),
                       GetSQLValueString($_POST['jenis'], "text"));

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

mysql_select_db($database_sistem, $sistem);
$query_rab = "SELECT * FROM rab_tb where kode='$_SESSION[kode]' and thn_ajuan='$_SESSION[tahun]' and jenis='Pendapatan'";
$rab = mysql_query($query_rab, $sistem) or die(mysql_error());
$row_rab = mysql_fetch_assoc($rab);
$totalRows_rab = mysql_num_rows($rab);

mysql_select_db($database_sistem, $sistem);
$query_rab2 = "SELECT * FROM rab_tb where kode='$_SESSION[kode]' and thn_ajuan='$_SESSION[tahun]' and jenis='Pengeluaran'";
$rab2 = mysql_query($query_rab2, $sistem) or die(mysql_error());
$row_rab2 = mysql_fetch_assoc($rab2);
$totalRows_rab2 = mysql_num_rows($rab2);

mysql_select_db($database_sistem, $sistem);
$query_perkir = "SELECT * FROM akun_tb where perkiraan='$_GET[perkir_number]'";
$perkir = mysql_query($query_perkir, $sistem) or die(mysql_error());
$row_perkir = mysql_fetch_assoc($perkir);
$totalRows_perkir = mysql_num_rows($perkir);
?>
<table width="100%">
  <tr>
    <td colspan="2" valign="top"><table width="100%">
      <tr valign="middle">
        <td width="335"><h3><span style="color:#033">Form Ajuan Rancangan Anggaran Pendapatan</span> dan Belanja</h3></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td width="30%" valign="top"><form method="post" name="form1" action="<?php echo $editFormAction; ?>">
      <table align="center" cellpadding="4" cellspacing="4" id="myTable3">
        <tr valign="baseline">
          <td nowrap align="left">Perkiraan</td>
          <td nowrap align="left">:</td>
          <td colspan="3"><input name="perkiraan" type="text" id="perkiraan" value="<?php echo $row_perkir['perkiraan'];?>" size="5" required="required" readonly="readonly" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="left">Akun</td>
          <td nowrap align="left">:</td>
          <td colspan="3"><input name="akun" type="text" id="akun" size="5" readonly="readonly" required="required" value="<?php echo $row_perkir['akun'];?>" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="left">&nbsp;</td>
          <td align="left" valign="top" nowrap>:</td>
          <td colspan="3"><textarea name="perkir" type="text" id="perkir" cols="30" rows="2"   placeholder="Nama Perkiraan" readonly="readonly" required="required"><?php echo $row_perkir['keterangan'];?></textarea></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="left">Kode</td>
          <td nowrap align="left">:</td>
          <td colspan="3"><input type="text" name="kode" value="<?php echo $_SESSION['kode'];?>" size="7"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="left">Nominal</td>
          <td nowrap align="left">:</td>
          <td colspan="3"><input type="text" name="nominal" id="rupiah" value="" size="20" required="required"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="left">&nbsp;</td>
          <td nowrap align="left">&nbsp;</td>
          <td colspan="3"><input name="show" type="text" id="rupiah2" style="opacity:10" size="20" readonly="readonly" /></td>
        </tr>
        <tr valign="baseline">
          <td align="left" valign="top" nowrap>Keterangan</td>
          <td align="left" valign="top" nowrap>:</td>
          <td colspan="3"><textarea name="keterangan" cols="30" required="required"></textarea></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="left">Bulan Terapan</td>
          <td nowrap align="left">:</td>
          <td colspan="3"><input type="text" name="bln_terapan" value="" size="4" required="required"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="left">Januari</td>
          <td nowrap align="left">&nbsp;</td>
          <td><input type="checkbox" name="januari" value="" ></td>
          <td align="left" nowrap>Juli</td>
          <td><input type="checkbox" name="juli" value="" ></td>
          </tr>
        <tr valign="baseline">
          <td nowrap align="left">Februari</td>
          <td nowrap align="left">&nbsp;</td>
          <td><input type="checkbox" name="februari" value="" ></td>
          <td align="left" nowrap>Agustus</td>
          <td><input type="checkbox" name="agustus" value="" ></td>
          </tr>
        <tr valign="baseline">
          <td nowrap align="left">Maret</td>
          <td nowrap align="left">&nbsp;</td>
          <td><input type="checkbox" name="maret" value="" ></td>
          <td align="left" nowrap>September</td>
          <td><input type="checkbox" name="september" value="" ></td>
          </tr>
        <tr valign="baseline">
          <td nowrap align="left">April</td>
          <td nowrap align="left">&nbsp;</td>
          <td><input type="checkbox" name="april" value="" ></td>
          <td align="left" nowrap>Oktober</td>
          <td><input type="checkbox" name="oktober" value="" ></td>
          </tr>
        <tr valign="baseline">
          <td nowrap align="left">Mei</td>
          <td nowrap align="left">&nbsp;</td>
          <td><input type="checkbox" name="mei" value="" ></td>
          <td align="left" nowrap>November</td>
          <td><input type="checkbox" name="november" value="" ></td>
          </tr>
        <tr valign="baseline">
          <td nowrap align="left">Juni</td>
          <td nowrap align="left">&nbsp;</td>
          <td><input type="checkbox" name="juni" value="" ></td>
          <td align="left" nowrap>Desember</td>
          <td><input type="checkbox" name="desember" value="" ></td>
          </tr>
        <tr valign="baseline">
          <td nowrap align="left">Tahun Ajuan</td>
          <td nowrap align="left">:</td>
          <td colspan="3"><input type="text" name="thn_ajuan" value="<?php echo $_SESSION['tahun'];?>" size="9">
            <input type="hidden" name="jenis" id="jenis"  value="<?php echo $row_perkir['kelompok'];?>"/></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="left">&nbsp;</td>
          <td nowrap align="left">&nbsp;</td>
          <td colspan="3"><input type="submit" value="Input Data" class="button">
            <input type="reset" name="Reset" id="Reset" value="Reset" class="button" /></td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1">
    </form>
      <script type="text/javascript">
$(document).ready(function(){
	$('#perkiraan').change(function(){
		var perkiraanfromfield=$('#perkiraan').val();
		$.ajax({
			method:"POST",
			url:"ajaxrespon.php",
			data:{perkiraan: perkiraanfromfield}
		})
		.done(function(hasilajax){
			$('#akun').val(hasilajax);
		});
	})
});
</script>
  <script type="text/javascript">
$(document).ready(function(){
	$('#perkiraan').change(function(){
		var perkiraanfromfield=$('#perkiraan').val();
		$.ajax({
			method:"POST",
			url:"ajaxrespon2.php",
			data:{perkiraan: perkiraanfromfield}
		})
		.done(function(hasilajax){
			$('#perkir').val(hasilajax);
		});
	})
});
</script>
    </td>
    <td valign="top">
   <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css">

		<script src="media/js/jquery.dataTables.js"></script>

    <script type="text/javascript" charset="utf-8">
          $(document).ready(function(){
            $('#dataakun').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>

      <table  id="dataakun" class="display" width="80%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
        <thead>
          <tr height="40" class="form_body">
            <th width="7%" height="30" align="center">No</th>
            <th width="10%" align="center">Akun</th>
            <th width="10%" align="center">Perkiraan</th>
            <th width="30%" height="30" align="center">Keterangan</th>
            <th width="17%" align="center">Proses</th>
          </tr>
        </thead>
        <tbody>
          <?php        mysql_select_db("akurat_db");
					          $sql = mysql_query("SELECT * FROM akun_tb WHERE kelompok='Pendapatan' or kelompok='Pengeluaran'  order by akun, perkiraan asc");
					        $no = 1;
                    while ($r = mysql_fetch_array($sql))
					 {
						                       echo "
		  <tr height='30' class='isi_tabel'> 									   
          <td align='center'>$no</td>
          <td align='center'>$r[akun]</td>
          <td align='center'>$r[perkiraan]</td>
          <td align='left'>$r[keterangan]</td>
		  <td align='center'>";?>
        <a href="?section=Setting&amp;module=rab_pick&amp;perkir_number=<?php echo $r['perkiraan'];?>"><img src="images/tambah.png" height="20" width="20" /></a><?php echo "</td>
          </tr>";
                     $no++;
                    }
                    ?>
        </tbody>
      </table>
   </td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><hr /></td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><h3><span style="color:#033"><a href="?section=Setting&module=print&amp;bb=rab"><img src="images/cetak1.png" width="41" height="32" /></a> Rancangan Anggaran Pendapatan</span> dan Belanja</h3> </td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><p>
        <style>
* {
  box-sizing: border-box;
}

#myInput {
  background-image: url('/css/searchicon.png');
  background-position: 10px 10px;
  background-repeat: no-repeat;
  width: 100%;
  font-size: 16px;
  padding: 12px 20px 12px 40px;
  border: 1px solid #ddd;
  margin-bottom: 5px;
}

#myTable {
  border-collapse: collapse;
  width: 100%;
  border: 0px solid #ddd;
  font-size: 12px;
}

#myTable th, #myTable td {
  text-align: left;
  padding: 4px;
}

#myTable tr {
  border-bottom: 0px solid #ddd;
}

#myTable tr.header, #myTable tr:hover {
  background-color: #f1f1f1;
}
      </style>
        <style>
* {
  box-sizing: border-box;
}

#myInput3 {
  background-image: url('/css/searchicon.png');
  background-position: 10px 10px;
  background-repeat: no-repeat;
  width: 100%;
  font-size: 16px;
  padding: 12px 20px 12px 40px;
  border: 1px solid #ddd;
  margin-bottom: 5px;
}

#myTable3 {
  border-collapse: collapse;
  width: 100%;
  border: 0px solid #ddd;
  font-size: 12px;
}

#myTable3 th, #myTable3 td {
  text-align: left;
  padding: 4px;
}

#myTable3 tr {
  border-bottom: 0px solid #ddd;
}

#myTable3 tr.header, #myTable3 tr:hover {
  background-color: #f1f1f1;
}
      </style>
        <input type="text" id="myInput" onkeyup="myFunction()" placeholder="mencari berdasarkan akun..." title="Type in akun" />
      </p>
      <table id="myTable" border="0" cellpadding="2" cellspacing="2">
        <tr class="">
          <td width="5" rowspan="2">No</td>
          <td width="10" rowspan="2">Perkiraan</td>
          <td width="15" rowspan="2">Nominal</td>
          <td width="20" rowspan="2">Keterangan</td>
          <td width="5" rowspan="2">Terapan</td>
          <td colspan="13">Bulan</td>
          <td width="10" rowspan="2">Thn. Ajuan</td>
          <td width="5" rowspan="2">Jenis</td>
          <td rowspan="2">Proses</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
          <td>11</td>
          <td>12</td>
          <td>Total</td>
        </tr>
        <?php
		$total_1=0;
		$total_2=0;
		$total_3=0;
		$total_4=0;
		$total_5=0;
		$total_6=0;
		$total_7=0;
		$total_8=0;
		$total_9=0;
		$total_10=0;
		$total_11=0;
		$total_12=0;
		 do { 
		 $jan=$row_rab['januari']*$row_rab['nominal'];
		 $feb=$row_rab['februari']*$row_rab['nominal'];
		 $mar=$row_rab['maret']*$row_rab['nominal'];
		 $april=$row_rab['april']*$row_rab['nominal'];
		 $mei=$row_rab['mei']*$row_rab['nominal'];
		 $jun=$row_rab['juni']*$row_rab['nominal'];
		 $jul=$row_rab['juli']*$row_rab['nominal'];
		 $ags=$row_rab['agustus']*$row_rab['nominal'];
		 $sep=$row_rab['september']*$row_rab['nominal'];
		 $okt=$row_rab['oktober']*$row_rab['nominal'];
		 $nov=$row_rab['november']*$row_rab['nominal'];
		 $des=$row_rab['desember']*$row_rab['nominal'];
		 $total_1=$total_1+$jan;
		 $total_2=$total_2+$feb;
		 $total_3=$total_3+$mar;
		 $total_4=$total_4+$april;
		 $total_5=$total_5+$mei;
		 $total_6=$total_6+$jun;
		 $total_7=$total_7+$jul;
		 $total_8=$total_8+$ags;
		 $total_9=$total_9+$sep;
		 $total_10=$total_10+$okt;
		 $total_11=$total_11+$nov;
		 $total_12=$total_12+$des;
		 ?>
        <tr>
          <td><?php echo $row_rab['id_rab']; ?></td>
          <td><?php include 'cek_perkir.php'; ?></td>
          <td><?php echo $row_rab['nominal']; ?></td>
          <td><?php echo $row_rab['keterangan']; ?></td>
          <td><?php echo $row_rab['bln_terapan']; ?></td>
          <td><?php 
				$ttl_jan=$row_rab['januari']*$row_rab['nominal'];			
			echo formatRupiah($ttl_jan); ?></td>
          <td><?php 
				$ttl_feb=$row_rab['februari']*$row_rab['nominal'];			
			echo formatRupiah($ttl_feb); ?></td>
          <td><?php 
				$ttl_mar=$row_rab['maret']*$row_rab['nominal'];			
			echo formatRupiah($ttl_mar); ?></td>
          <td><?php 
				$ttl_april=$row_rab['april']*$row_rab['nominal'];			
			echo formatRupiah($ttl_april); ?></td>
          <td><?php 
				$ttl_mei=$row_rab['mei']*$row_rab['nominal'];			
			echo formatRupiah($ttl_mei); ?></td>
          <td><?php 
				$ttl_jun=$row_rab['juni']*$row_rab['nominal'];			
			echo formatRupiah($ttl_jun); ?></td>
          <td><?php 
				$ttl_jul=$row_rab['juli']*$row_rab['nominal'];			
			echo formatRupiah($ttl_jul); ?></td>
          <td><?php 
				$ttl_ags=$row_rab['agustus']*$row_rab['nominal'];			
			echo formatRupiah($ttl_ags); ?></td>
          <td><?php 
				$ttl_sep=$row_rab['september']*$row_rab['nominal'];			
			echo formatRupiah($ttl_sep); ?></td>
          <td><?php 
				$ttl_okt=$row_rab['oktober']*$row_rab['nominal'];			
			echo formatRupiah($ttl_okt); ?></td>
          <td><?php 
				$ttl_nov=$row_rab['november']*$row_rab['nominal'];			
			echo formatRupiah($ttl_nov); ?></td>
          <td><?php 
				$ttl_des=$row_rab['desember']*$row_rab['nominal'];			
			echo formatRupiah($ttl_des); ?></td>
          <td><?php
            $ttl=$row_rab['bln_terapan']*$row_rab['nominal'];;
			echo formatRupiah($ttl);?></td>
          <td><?php echo $row_rab['thn_ajuan']; ?></td>
          <td><?php echo $row_rab['jenis']; ?></td>
          <td><a href="?module=hapus_rab&amp;reg=<?php echo $row_rab['id_rab'];?>"><img src="images/cross.png" width="16" height="16" /></a></td>
        </tr>
        <?php } while ($row_rab = mysql_fetch_assoc($rab)); ?>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><?php echo formatRupiah($total_1);?></td>
          <td><?php echo formatRupiah($total_2);?></td>
          <td><?php echo formatRupiah($total_3);?></td>
          <td><?php echo formatRupiah($total_4);?></td>
          <td><?php echo formatRupiah($total_5);?></td>
          <td><?php echo formatRupiah($total_6);?></td>
          <td><?php echo formatRupiah($total_7);?></td>
          <td><?php echo formatRupiah($total_8);?></td>
          <td><?php echo formatRupiah($total_9);?></td>
          <td><?php echo formatRupiah($total_10);?></td>
          <td><?php echo formatRupiah($total_11);?></td>
          <td><?php echo formatRupiah($total_12);?></td>
          <td><?php
            $ttl_pdp=$total_1+$total_2+$total_3+$total_4+$total_5+$total_6+$total_7+$total_8+$total_9+$total_10+$total_11+$total_12;
			echo formatRupiah($ttl_pdp);?></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </table>
      <p>
        <script>
function myFunction() {
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("myInput");
  filter = input.value.toUpperCase();
  table = document.getElementById("myTable");
  tr = table.getElementsByTagName("tr");
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[1];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }       
  }
}
        </script>
      </p>
      <p>
        <style>
* {
  box-sizing: border-box;
}

#myInput2 {
  background-image: url('/css/searchicon.png');
  background-position: 10px 10px;
  background-repeat: no-repeat;
  width: 100%;
  font-size: 16px;
  padding: 12px 20px 12px 40px;
  border: 1px solid #ddd;
  margin-bottom: 5px;
}

#myTable2 {
  border-collapse: collapse;
  width: 100%;
  border: 0px solid #ddd;
  font-size: 12px;
}

#myTable2 th, #myTable2 td {
  text-align: left;
  padding: 4px;
}

#myTable2 tr {
  border-bottom: 0px solid #ddd;
}

#myTable2 tr.header, #myTable2 tr:hover {
  background-color: #f1f1f1;
}
        </style>
        <input type="text" id="myInput2" onkeyup="myFunction2()" placeholder="mencari berdasarkan akun..." title="Type in akun" />
      </p>
      </p>
      <table id="myTable2" border="0" cellpadding="2" cellspacing="2">
        <tr class="">
          <td width="5" rowspan="2">No</td>
          <td width="10" rowspan="2">Perkiraan</td>
          <td width="15" rowspan="2">Nominal</td>
          <td width="20" rowspan="2">Keterangan</td>
          <td width="5" rowspan="2">Terapan</td>
          <td colspan="13">Bulan</td>
          <td width="10" rowspan="2">Thn. Ajuan</td>
          <td width="5" rowspan="2">Jenis</td>
          <td rowspan="2">Proses</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
          <td>11</td>
          <td>12</td>
          <td>Total</td>
        </tr>
        <?php
		$total_1=0;
		$total_2=0;
		$total_3=0;
		$total_4=0;
		$total_5=0;
		$total_6=0;
		$total_7=0;
		$total_8=0;
		$total_9=0;
		$total_10=0;
		$total_11=0;
		$total_12=0;
		 do { 
		 $jan=$row_rab2['januari']*$row_rab2['nominal'];
		 $feb=$row_rab2['februari']*$row_rab2['nominal'];
		 $mar=$row_rab2['maret']*$row_rab2['nominal'];
		 $april=$row_rab2['april']*$row_rab2['nominal'];
		 $mei=$row_rab2['mei']*$row_rab2['nominal'];
		 $jun=$row_rab2['juni']*$row_rab2['nominal'];
		 $jul=$row_rab2['juli']*$row_rab2['nominal'];
		 $ags=$row_rab2['agustus']*$row_rab2['nominal'];
		 $sep=$row_rab2['september']*$row_rab2['nominal'];
		 $okt=$row_rab2['oktober']*$row_rab2['nominal'];
		 $nov=$row_rab2['november']*$row_rab2['nominal'];
		 $des=$row_rab2['desember']*$row_rab2['nominal'];
		 $total_1=$total_1+$jan;
		 $total_2=$total_2+$feb;
		 $total_3=$total_3+$mar;
		 $total_4=$total_4+$april;
		 $total_5=$total_5+$mei;
		 $total_6=$total_6+$jun;
		 $total_7=$total_7+$jul;
		 $total_8=$total_8+$ags;
		 $total_9=$total_9+$sep;
		 $total_10=$total_10+$okt;
		 $total_11=$total_11+$nov;
		 $total_12=$total_12+$des;
		 ?>
        <tr>
          <td><?php echo $row_rab2['id_rab']; ?></td>
          <td><?php include 'cek_perkir2.php'; ?></td>
          <td><?php echo $row_rab2['nominal']; ?></td>
          <td><?php echo $row_rab2['keterangan']; ?></td>
          <td><?php echo $row_rab2['bln_terapan']; ?></td>
          <td><?php 
				$ttl_jan=$row_rab2['januari']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_jan); ?></td>
          <td><?php 
				$ttl_feb=$row_rab2['februari']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_feb); ?></td>
          <td><?php 
				$ttl_mar=$row_rab2['maret']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_mar); ?></td>
          <td><?php 
				$ttl_april=$row_rab2['april']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_april); ?></td>
          <td><?php 
				$ttl_mei=$row_rab2['mei']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_mei); ?></td>
          <td><?php 
				$ttl_jun=$row_rab2['juni']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_jun); ?></td>
          <td><?php 
				$ttl_jul=$row_rab2['juli']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_jul); ?></td>
          <td><?php 
				$ttl_ags=$row_rab2['agustus']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_ags); ?></td>
          <td><?php 
				$ttl_sep=$row_rab2['september']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_sep); ?></td>
          <td><?php 
				$ttl_okt=$row_rab2['oktober']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_okt); ?></td>
          <td><?php 
				$ttl_nov=$row_rab2['november']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_nov); ?></td>
          <td><?php 
				$ttl_des=$row_rab2['desember']*$row_rab2['nominal'];			
			echo formatRupiah($ttl_des); ?></td>
          <td><?php
            $ttl=$row_rab2['bln_terapan']*$row_rab2['nominal'];;
			echo formatRupiah($ttl);?></td>
          <td><?php echo $row_rab2['thn_ajuan']; ?></td>
          <td><?php echo $row_rab2['jenis']; ?></td>
          <td><a href="?module=hapus_rab&amp;reg=<?php echo $row_rab2['id_rab'];?>"><img src="images/cross.png" width="16" height="16" /></a></td>
        </tr>
        <?php } while ($row_rab2 = mysql_fetch_assoc($rab2)); ?>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><?php echo formatRupiah($total_1);?></td>
          <td><?php echo formatRupiah($total_2);?></td>
          <td><?php echo formatRupiah($total_3);?></td>
          <td><?php echo formatRupiah($total_4);?></td>
          <td><?php echo formatRupiah($total_5);?></td>
          <td><?php echo formatRupiah($total_6);?></td>
          <td><?php echo formatRupiah($total_7);?></td>
          <td><?php echo formatRupiah($total_8);?></td>
          <td><?php echo formatRupiah($total_9);?></td>
          <td><?php echo formatRupiah($total_10);?></td>
          <td><?php echo formatRupiah($total_11);?></td>
          <td><?php echo formatRupiah($total_12);?></td>
          <td><?php
            $ttl_pnl=$total_1+$total_2+$total_3+$total_4+$total_5+$total_6+$total_7+$total_8+$total_9+$total_10+$total_11+$total_12;
			echo formatRupiah($ttl_pnl);?></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td><?php echo formatRupiah($ttl_pdp-$ttl_pnl);?></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
    </table></td>
  </tr>
</table>
<p>&nbsp;</p>
<?php
mysql_free_result($rab);
mysql_free_result($rab2);
?>
        <script type="text/javascript">
		
		var rupiah = document.getElementById('rupiah');
		rupiah.addEventListener('keyup', function(e){
			// tambahkan 'Rp.' pada saat form di ketik
			// gunakan fungsi formatRupiah() untuk mengubah angka yang di ketik menjadi format angka
			rupiah.value = formatRupiah(this.value, 'Rp. ');
		});
			var rupiah = document.getElementById('rupiah2');
		rupiah.addEventListener('keyup', function(e){
			// tambahkan 'Rp.' pada saat form di ketik
			// gunakan fungsi formatRupiah() untuk mengubah angka yang di ketik menjadi format angka
			rupiah.value = formatRupiah(this.value, 'Rp. ');
		});
 
		/* Fungsi formatRupiah */
		function formatRupiah(angka, prefix){
			var number_string = angka.replace(/[^,\d]/g, '').toString(),
			split   		= number_string.split(','),
			sisa     		= split[0].length % 3,
			rupiah     		= split[0].substr(0, sisa),
			ribuan     		= split[0].substr(sisa).match(/\d{3}/gi);
 
			// tambahkan titik jika yang di input sudah menjadi angka ribuan
			if(ribuan){
				separator = sisa ? '.' : '';
				rupiah += separator + ribuan.join('.');
			}
 
			rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
			return prefix == undefined ? rupiah : (rupiah ? 'Rp. ' + rupiah : '');
		}
	</script>