<?php

if($bulan=='Januari'){
	$bulannya='Desember';
	$tahunnya=$tahun-1;
}
elseif($bulan=='Februari'){
	$bulannya='Januari';
	$tahunnya=$tahun;
}
elseif($bulan=='Maret'){
	$bulannya='Februari';
	$tahunnya=$tahun;
}
elseif($bulan=='April'){
	$bulannya='Maret';
	$tahunnya=$tahun;
}
elseif($bulan=='Mei'){
	$bulannya='April';
	$tahunnya=$tahun;
}
elseif($bulan=='Juni'){
	$bulannya='Mei';
	$tahunnya=$tahun;
}
elseif($bulan=='Juli'){
	$bulannya='Juni';
	$tahunnya=$tahun;
}
elseif($bulan=='Agustus'){
	$bulannya='Juli';
	$tahunnya=$tahun;
}
elseif($bulan=='September'){
	$bulannya='Agustus';
	$tahunnya=$tahun;
}
elseif($bulan=='Oktober'){
	$bulannya='September';
	$tahunnya=$tahun;
}
elseif($bulan=='November'){
	$bulannya='Oktober';
	$tahunnya=$tahun;
}
elseif($bulan=='Desember'){
	$bulannya='November';
	$tahunnya=$tahun;
}
mysql_select_db($database_sistem, $sistem);
$query_saldo_awal = "SELECT * FROM saldo_tb where bulan='$bulannya' and tahun='$tahunnya'";
$saldo_awal = mysql_query($query_saldo_awal, $sistem) or die(mysql_error());
$row_saldo_awal = mysql_fetch_assoc($saldo_awal);
$totalRows_saldo_awal = mysql_num_rows($saldo_awal);
?>

<?php
mysql_select_db($database_sistem, $sistem);
$query_unit = "SELECT * FROM user_tb WHERE user_tb.`level`='Unit'";
$unit = mysql_query($query_unit, $sistem) or die(mysql_error());
$row_unit = mysql_fetch_assoc($unit);
$totalRows_unit = mysql_num_rows($unit);
?>

<p>&nbsp;</p>
<table width="90%" border="0" align="center" background="images/tr.png">
  <tr>
    <td><h3>Tabel Data Unit</h3></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="2" class="form_body">
      <tr align="center">
        <td background="images/bg1.png"  height="30">kode unit</td>
        <td background="images/bg1.png">nama unit</td>
        <td background="images/bg1.png">alamat</td>
        <td background="images/bg1.png">telp</td>
        <td background="images/bg1.png">email</td>
        <td background="images/bg1.png">direktur</td>
        <td background="images/bg1.png">bendahara</td>
        <td background="images/bg1.png">nama admin</td>
      </tr>
      <tr align="center">
        <td colspan="8"><hr /></td>
      </tr>
      <?php do { ?>
      <tr align="center">
        <td><a href="?section=Report&module=show_lr&amp;kodenya=<?php echo $row_unit['kode_unit'];?>"><?php echo $row_unit['kode_unit']; ?></a></td>
        <td><?php echo $row_unit['nama_unit']; ?></td>
        <td><?php echo $row_unit['alamat']; ?></td>
        <td><?php echo $row_unit['telp']; ?></td>
        <td><?php echo $row_unit['email']; ?></td>
        <td><?php echo $row_unit['direktur']; ?></td>
        <td><?php echo $row_unit['bendahara']; ?></td>
        <td><?php echo $row_unit['nama_admin']; ?></td>
      </tr>
      <tr align="center">
        <td colspan="8"><hr /></td>
      </tr>
      <?php } while ($row_unit = mysql_fetch_assoc($unit)); ?>
    </table></td>
  </tr>
  <tr>
    <td><script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css">
<table width="90%" border="0" align="center" class="form_body">
  <tr>
    <td colspan="8"><h1 style="color:#033">Laporan Laba Rugi</h1></td>
  </tr>
  <tr height="30">
    <td width="100" align="center" background="images/bg1.png">Akun</td>
    <td align="center" background="images/bg1.png">Keterangan</td>
    <td colspan="6" align="center" background="images/bg1.png">Nominal</td>
  </tr>
  <tr height="30">
    <td colspan="8" align="left">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='left'>$r[keterangan]</td>
          <td align='right'>Rp.</td>
          <td align='right'>";?>
  <?php 
			if($r['index']==''){
			include 'module/_report/hitung_pdp_lr_pus_show.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_pus_show.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"><?php include 'module/_proses/hitung_ttl_pdp_lr_pus_show.php';?></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td colspan="8"><hr /></td>
  </tr>
  <tr height="30">
    <td colspan="8">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='left'>$r[keterangan]</td>
          <td align='right'>Rp.</td>
          <td align='right'>";?>
  <?php 
			if($r['index']==''){
			include 'module/_report/hitung_pnl_lr_pus_show.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_pus_show.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"><?php include 'module/_proses/hitung_ttl_pnl_lr_pus_show.php';?></td>
    <td align="right"></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="8"><hr /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>Sisa Hasil Usaha</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="right">Rp.</td>
    <td align="right"><?php 
  $lr=$ttl_pdp-$ttl_pnl;
  echo formatRupiah($lr);
  ?></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=Report&module=rekap&amp;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</td>
          <td>:</td>
          <td><?php 
  $lr=$ttl_pdp-$ttl_pnl;
  echo formatRupiah($lr);
  ?></td>
        </tr>
        <tr>
          <td>Cetak</td>
          <td>:</td>
          <td><a href="?section=Report&module=print&amp;bb=labarug"><img src="images/cetak1.png" width="41" height="32" /></a></td>
        </tr>
      </table>
    </form></td>
  </tr>
</table></td>
  </tr>
</table>
<p>&nbsp;</p>

