<?php require_once('../../Connections/sistem.php'); 
?>
<?php
function formatRupiah($angka){
 $rupiah=number_format($angka,0,',','.');
 return $rupiah;
}
?>
<?php
$bulan=$_GET['bulan'];
$tahun=$_GET['tahun'];
$kode=$_GET['unit'];
$nama=$_GET['nama'];

mysql_select_db($database_sistem, $sistem);
$query_rab = "SELECT * FROM rab_tb where kode='$_GET[unit]' and thn_ajuan='$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='$_GET[unit]' and thn_ajuan='$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_unit = "SELECT * FROM user_tb WHERE user_tb.kode_unit='$kode'";
$unit = mysql_query($query_unit, $sistem) or die(mysql_error());
$row_unit = mysql_fetch_assoc($unit);
$totalRows_unit = mysql_num_rows($unit);

?>
<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>
<table width="100%" class="isi_tabel" id="myTable">
  <tr>
    <td width="106" rowspan="5"><img  alt="" name="img" width="100" height="100" id="img" src="../../images/wlha.jpg" /></td>
    <td width="141">Laporan</td>
    <td width="10">:</td>
    <td width="776">RAB</td>
  </tr>
  <tr>
    <td>Bulan/ Tahun Lapor</td>
    <td>:</td>
    <td><?php echo $_GET['bulan'].'/ '.$_GET['tahun'];?></td>
  </tr>
  <tr>
    <td>Tahun Ajuan</td>
    <td>&nbsp;</td>
    <td><?php echo $row_rab['thn_ajuan']; ?></td>
  </tr>
  <tr>
    <td>Unit</td>
    <td>:</td>
    <td><?php echo $_GET['nama'];?></td>
  </tr>
  <tr>
    <td>Tanggal</td>
    <td>:</td>
    <td><?php echo date('d-M-Y');?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<table width="100%">
  <tr>
    <td valign="top">

      
      </p>
      Akun Pendapatan
      <table id="myTable" border="0" cellpadding="2" cellspacing="2">
        <tr>
          <td rowspan="2">No</td>
          <td rowspan="2">Akun</td>
          <td rowspan="2">Perkiraan</td>
          <td rowspan="2">Nominal</td>
          <td rowspan="2">Keterangan</td>
          <td rowspan="2">Terapan</td>
          <td colspan="13">Bulan</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;
		$i=1;
		 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 $i; ?></td>
            <td><?php echo $row_rab['akun']; ?></td>
            <td><?php echo $row_rab['perkiraan']; ?></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>
          </tr>
           <?php 
		   $i++;
		   } while ($row_rab = mysql_fetch_assoc($rab)); ?>

          <tr>
            <td>&nbsp;</td>
            <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>&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>
        <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>
      Akun Pengeluaran
      <table id="myTable2" border="0" cellpadding="2" cellspacing="2">
        <tr class="">
          <td rowspan="2">No</td>
          <td rowspan="2">Akun</td>
          <td rowspan="2">Perkiraan</td>
          <td rowspan="2">Nominal</td>
          <td rowspan="2">Keterangan</td>
          <td rowspan="2">Terapan</td>
          <td colspan="13">Bulan</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;
		$i=1;
		 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 $i; ?></td>
            <td><?php echo $row_rab2['akun']; ?></td>
            <td><?php echo $row_rab2['perkiraan']; ?></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>
          </tr>
          <?php 
		  $i++;
		  } while ($row_rab2 = mysql_fetch_assoc($rab2)); ?>
          <tr>
            <td>&nbsp;</td>
            <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>&nbsp;</td>
          </tr>
              </table>
    <script>
function myFunction2() {
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("myInput2");
  filter = input.value.toUpperCase();
  table = document.getElementById("myTable2");
  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>

    </td>
  </tr>
  <tr>
    <td valign="top"><table width="95%" id="myTable3" border="0" align="center" cellpadding="1">
      <tr>
        <td width="30%">Mengetahui</td>
        <td width="30%">&nbsp;</td>
        <td width="30%" align="right">.....................,<?php echo date('d-M-Y');?></td>
      </tr>
      <tr>
        <td>Ketua <?php echo $nama;?></td>
        <td>&nbsp;</td>
        <td align="right">Bendahara/ Wakil Ketua <?php echo $nama;?></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td align="right">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td align="right">&nbsp;</td>
      </tr>
      <tr>
        <td><?php echo $row_unit['direktur'];?></td>
        <td>&nbsp;</td>
        <td align="right"><?php echo $row_unit['bendahara'];?></td>
      </tr>
    </table></td>
  </tr>
</table>
<p>&nbsp;</p>
<?php
mysql_free_result($rab);
mysql_free_result($rab2);
?>
<script>
		window.print();
	</script>  