<?php

	mysql_select_db($database_sistem, $sistem);
$query_saldo_awal_konsol = "SELECT  sum(col_1110)as kas, sum(col_1120a)as bank1, sum(col_1120b)as bank2, sum(col_1120c)as bank3, sum(col_1120d)as bank4, sum(col_1120e)as bank5, sum(col_1120f)as bank6, sum(col_1120g)as bank7, sum(col_1120h)as bank8, sum(col_1120i)as bank9, sum(col_1120j)as bank10, sum(col_1120k)as bank11, sum(col_1120l)as bank12, sum(col_1120m)as bank13, sum(col_1120n)as bank14, sum(col_1120o)as bank15, sum(col_1120p)as bank16, sum(col_1120q)as bank17, sum(col_1120r)as bank18, sum(col_1120s)as bank19, sum(col_1120t)as bank20, sum(col_1130a)as depo1, sum(col_1130b)as depo2, sum(col_1130c)as depo3, sum(col_1130d)as depo4, sum(col_1130e)as depo5, sum(col_1130f)as depo6, sum(col_1130g)as depo7, sum(col_1130h)as depo8, sum(col_1130i)as depo9, sum(col_1130j)as depo10, sum(col_1130k)as depo11, sum(col_1130l)as depo12, sum(col_1130m)as depo13, sum(col_1130n)as depo14, sum(col_1130o)as depo15, sum(col_1130p)as depo16, sum(col_1130q)as depo17, sum(col_1130r)as depo18, sum(col_1130s)as depo19, sum(col_1130t)as depo20, sum(col_1140)as piutang, sum(col_1150)as persediaan, sum(col_1160)as bdd, sum(col_1170)as inves, sum(col_1210)as tanah, sum(col_1220)as gedung, sum(col_1230)as kendaraan, sum(col_1240)as inventaris, sum(col_1250)as atl, sum(col_1300)as susut, sum(col_2110)as hutang_usaha, sum(col_2120)as hutang_bank, sum(col_2130)as hutang_pajak, sum(col_2140)as hutang_pdd, sum(col_2150)as hutang_bmh, sum(col_3000)as modal, sum(col_shu)as shu from saldo_tb where bulan='$bulannya' and tahun='$tahunnya'";
$saldo_awal_konsol = mysql_query($query_saldo_awal_konsol, $sistem) or die(mysql_error());
$row_saldo_awal_konsol = mysql_fetch_assoc($saldo_awal_konsol);
$totalRows_saldo_awal_konsol = mysql_num_rows($saldo_awal_konsol);

?>
<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>

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="400" class="isi_tabel">
        <tr>
          <td colspan="3"><h1 style="color:#033">Buku Besar Kas</h1></td>
        </tr>
        <tr>
          <td>Bulan/ Tahun Lapor</td>
          <td>:</td>
          <td><?php echo $bulan.'/ '.$tahun;?></td>
        </tr>
        <tr>
          <td>Unit</td>
          <td>:</td>
          <td>Konsolidasi</td>
        </tr>
        <tr>
          <td>Tanggal</td>
          <td>:</td>
          <td><?php echo date('d-M-Y');?></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="90%" align="center"  bgcolor="#FFFFFF" class="display" id="bbkas">
      <thead>
        <tr height="30" class="form_body">
          <th colspan="2" align="left">Saldo Awal</th>
          <th align="center">&nbsp;</th>
          <th align="center">&nbsp;</th>
          <th align="right"><?php
		  $saldo=$row_saldo_awal_konsol['kas'];
		   echo formatRupiah($saldo);?></th>
        </tr>
        <tr class="form_body" height="30">
          <th align="center" width="100">Perkiraan</th>
          <th align="center">Keterangan</th>
          <th align="center">Debet</th>
          <th align="center">Kredit</th>
          <th align="center">Saldo</th>
        </tr>
        </thead>
      <tbody>
      
        <?php        mysql_select_db("csabrude_akurat");
					          $sql = mysql_query("SELECT no_perkiraan, sum(transaksi_tb.debet)as debet, sum(transaksi_tb.kredit)as kredit From transaksi_tb where bulan='$bulan' and tahun='$tahun' and transaksi='Kas' group by no_perkiraan order by no_perkiraan asc");
					          $no = 1;
							$totdebet = 0;
	   						$totkredit = 0;
	   						$subtotal = 0;
                    while ($r = mysql_fetch_array($sql)) {
		$debet=$r['debet'];
	   $kredit=$r['kredit'];
	    $totdebet = $totdebet + $debet;
    	$totkredit = $totkredit + $kredit;
    	$subtotal =($subtotal + $debet) - $kredit;
                      echo "<tr>
          <td align='center'>$r[no_perkiraan]</td>
            <td align='left'>";?><?php include 'nama_perkiraan.php';?><?php echo"</td>
			<td align='right'>";?><?php echo formatRupiah($r['debet']);?><?php echo"</td>
			<td align='right'>";?><?php echo formatRupiah($r['kredit']);?><?php echo"</td>
			<td align='right'>";?><?php echo formatRupiah($saldo+$subtotal);?><?php echo"</td>
          </tr>";
                      $no++;
                    }
                    ?>
      </tbody>
      <tfoot>
        <tr>
       <th colspan="2" align="center">Saldo</th>
          <th align="right"><?php echo formatRupiah($totdebet);?></th>
          <th align="right"><?php echo formatRupiah($totkredit);?></th>
          <th align="right"><?php echo formatRupiah($saldo+$subtotal);?></th>
        </tr>
      </tfoot>
    </table></td>
  </tr>
  </table>
        