<?php
include 'verifikasi.php';?>
<?php
$tahun_shu=$tahun-1;
mysql_select_db($database_sistem, $sistem);
$query_saldo_shu = "SELECT * FROM saldo_tb where bulan='Desember' and tahun='$tahun_shu' and kode_unit='$_SESSION[kode]'";
$saldo_shu = mysql_query($query_saldo_shu, $sistem) or die(mysql_error());
$row_saldo_shu = mysql_fetch_assoc($saldo_shu);
$totalRows_saldo_shu = mysql_num_rows($saldo_shu);

mysql_select_db($database_sistem, $sistem);
$query_hitung_pnlnya = "SELECT sum(debet)as debet, sum(kredit)as kredit FROM pnl_tb where tahun='$tahun'  and bulan='$bulan' and kode_unit='$_SESSION[kode]' and akun between 5000 and 5999";
$hitung_pnlnya = mysql_query($query_hitung_pnlnya, $sistem) or die(mysql_error());
$row_hitung_pnlnya = mysql_fetch_assoc($hitung_pnlnya);
$totalRows_hitung_pnlnya = mysql_num_rows($hitung_pnlnya);

mysql_select_db($database_sistem, $sistem);
$query_hitung_pdpnya= "SELECT sum(debet)as debet, sum(kredit)as kredit FROM transaksi_tb where tahun='$tahun' and bulan='$bulan' and kode_unit='$_SESSION[kode]' and akun between 4000 and 4999 ";
$hitung_pdpnya = mysql_query($query_hitung_pdpnya, $sistem) or die(mysql_error());
$row_hitung_pdpnya = mysql_fetch_assoc($hitung_pdpnya);
$totalRows_hitung_pdpnya = mysql_num_rows($hitung_pdpnya);
?>
<p>&nbsp;</p>
<table width="100%" border="0" align="center">
  <tr>
    <td><script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css">
<div id="TabbedPanels1" class="TabbedPanels">
  <ul class="TabbedPanelsTabGroup">
    <li class="TabbedPanelsTab" tabindex="0">Aktivitas (Satu Tahun)</li>
</ul>
  <div class="TabbedPanelsContentGroup">
    <div class="TabbedPanelsContent">
      <table width="100%" border="0" align="center" cellpadding="3" cellspacing="3" class="form_body">
        <tr>
          <td colspan="8">&nbsp;</td>
          </tr>
        <tr height="30">
          <td width="100" align="center">Akun</td>
          <td align="center">Perkiraan</td>
          <td align="center">Keterangan</td>
          <td colspan="6" align="center">Nominal</td>
        </tr>
        <tr height="30">
          <td colspan="8" align="left" background="images/bg2.png">Pendapatan</td>
        </tr>
        <?php        mysql_select_db("csabrude_akurat");
					          $sql = mysql_query("SELECT * From akun_tb where kode_unit='All' and kelompok='Pendapatan' order by akun asc ");
					          $no = 1;
							
                    while ($r = mysql_fetch_array($sql)) {
                      echo "<tr>
          <td align='center'>$r[akun]</td>
		  <td align='center'>$r[perkiraan]</td>
          <td align='left'>$r[keterangan]</td>
          <td align='right'>Rp.</td>
          <td align='right'>";?>
          <?php 
			if($r['index']==''){
			include 'module/_report/hitung_pdp_lr.php';
			}else{
				echo '';
			}
			?>
			<?php echo"</td>
          <td align='right'>Rp.</td>
          <td align='right'>";?><?php 
			if($r['index']=='Ya'){
			include 'module/_report/hitung_pdp_index_lr.php';
			}else{
				echo '';
			}
			?><?php echo"</td>
          <td></td>
          <td></td>
        </tr>";
		 $no++;
                    }
                    ?>
        <tr height="30">
          <td colspan="2"></td>
          <td></td>
          <td></td>
          <td></td>
          <td align="right">Rp.</td>
          <td align="right"> <?php include 'module/_proses/hitung_ttl_pdp_lr.php';?></td>
          <td></td>
          </tr>

        <tr>
          <td colspan="8"><hr></td>
          </tr>
        <tr height="30">
          <td colspan="8" background="images/bg2.png">Pengeluaran</td>
          </tr>
                   <?php        mysql_select_db("csabrude_akurat");
					          $sql = mysql_query("SELECT * From akun_tb where kode_unit='All' and kelompok='Pengeluaran' order by akun asc ");
					          $no = 1;
							
                    while ($r = mysql_fetch_array($sql)) {
                      echo "<tr>
          <td align='center'>$r[akun]</td>
		  <td align='center'>$r[perkiraan]</td>
          <td align='left'>$r[keterangan]</td>
          <td align='right'>Rp.</td>
          <td align='right'>";?>
          <?php 
			if($r['index']==''){
			include 'module/_report/hitung_pnl_lr.php';
			}else{
				echo '';
			}
			?>
			<?php echo"</td>
          <td align='right'>Rp.</td>
          <td align='right'>";?><?php 
			if($r['index']=='Ya'){
			include 'module/_report/hitung_pnl_index_lr.php';
			}else{
				echo '';
			}
			?><?php echo"</td>
          <td></td>
          <td></td>
        </tr>";
		 $no++;
                    }
                    ?>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td align="right">Rp.</td>
  <td align="right"> <?php include 'module/_proses/hitung_ttl_pnl_lr.php';?></td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td colspan="8"><hr /></td>
  </tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td align="right">Rp.</td>
  <td align="right"><?php 
  $total=$ttl_pdp-$ttl_pnl;
  echo formatRupiah($total);
  ?>
   <?php 
  $lr=$row_hitung_pdpnya['debet']-$row_hitung_pnlnya['kredit'];;
  ?>
  </td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td align="right">&nbsp;</td>
  <td align="right">&nbsp;</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td colspan="8"><form id="form1" name="form1" method="post" action="?section=Transaksi&module=rekap&shu=<?php echo $lr;?>">
    <table class="isi_tabel" width="70%" border="0" align="center">
      <tr>
        <td width="200">&nbsp;</td>
        <td width="10">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>Tahun</td>
        <td>:</td>
        <td><?php echo $tahun;?></td>
      </tr>
      <tr>
        <td>Bulan</td>
        <td>:</td>
        <td><?php echo $bulan;?></td>
      </tr>
      <tr>
        <td>Laba diterima tahun lalu</td>
        <td>:</td>
        <td><?php 
  $lr_sisa=$row_saldo_shu['col_shu'];
  echo formatRupiah($lr_sisa);
  ?></td>
      </tr>
      <tr>
        <td>Laba bulan ini</td>
        <td>:</td>
        <td><?php 
  $lr=$row_hitung_pdpnya['debet']-$row_hitung_pnlnya['kredit'];
  echo formatRupiah($lr);
  ?></td>
      <tr>
        <td>Total SHU</td>
        <td>:</td>
        <td><?php 
  $lr_berjalan=$ttl_pdp-$ttl_pnl;
  echo formatRupiah($lr_berjalan);
  ?></td>
      </tr>
      <tr>
        <td><input type="submit" name="Simpan" id="Simpan" value="Rekap Aktivitas dan Transaksi" class="button" /></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
  </form></td>
  </tr>

      </table>
    </div>
</div>
</div>
<script type="text/javascript">
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
</script>
</td>
  </tr>
</table>
<p>&nbsp;</p>

