<script type="text/javascript">
    $(function() {
        $("#theList tr:even").addClass("stripe1");
        $("#theList tr:odd").addClass("stripe2");

        $("#theList tr").hover(
            function() {
                $(this).toggleClass("highlight");
            },
            function() {
                $(this).toggleClass("highlight");
            }
        );
    });
</script>

<style type="text/css">
#info {
	font-size:12px;
	font-weight:bold;
	color:#F00;
}
</style>

<?php
include '../../inc/inc.koneksi.php';

$bulan	= $_GET[bulan];
$tahun	= $_GET[tahun];
$bulan1 = $bulan+1;
$laba	= 0;

echo "<hr>
	<table width='100%'>
		<tr>
			<td align='left'><b>Pendapatan Usaha</b></td>
		</tr>
	</table>";
	
	$sql1	= mysql_query("SELECT * FROM akun_bb WHERE nogol='41' AND level='2' ORDER BY noakun");
	$subtot	= 0;
	while($r1=mysql_fetch_array($sql1)){
		$noakun=$r1[noakun];
		
		$sql = mysql_query("SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal)<'$bulan1' AND year(tanggal)='$tahun' AND batal='' ");
			
		$rdebet=0;
		$rkredit=0;
		while($r=mysql_fetch_array($sql)){
			$rdebet=$rdebet+$r[debet];
			$rkredit=$rkredit+$r[kredit];
		}
			
		$saldo=$rkredit-$rdebet;
		$subtot=$subtot+$saldo;
				
		echo "<table width='100%' align='left'>
			<tr>
				<td width='3%'></td>
				<td width='35%'>$r1[naakun]</td>					
				<td width='2%'>Rp</td>
				<td width='20%' align='right'>".number_format($saldo,2)."</td>
				<td width='40%'></td>
			</tr>
		</table>";
	}
		
	echo "<table width='100%' align='left'>
		</tr>
			<td width='3%'></td>
			<td width='35%'></td>
			<td width='2%' style='border-bottom:double 1px'></td>
			<td width='20%' style='border-bottom:double 1px'></td>
			<td width='2%'></td>
			<td width='20%'></td>
			<td width='18%'></td>
		</tr>
			
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td alidn='right'>Jumlah</td>				
			<td style='border-bottom:double 1px'>Rp</td>
			<td align='right' style='border-bottom:double 1px'>".number_format($subtot,2)."</td>
			<td></td>
		</tr>
	</table>
	<br>";
	$laba=$laba+$subtot;
	
echo "<table width='100%' align='left'>
		<tr>
			<td><b>Biaya Operasional</b></td>
		</tr>
	</table>";

	$sql1	= mysql_query("SELECT * FROM akun_bb WHERE nogol='51' AND level='2' ORDER BY noakun");
	$subtot	= 0;
	while($r1=mysql_fetch_array($sql1)){
		$noakun=$r1[noakun];

		$sql = mysql_query("SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal) <'$bulan1' AND year(tanggal)='$tahun' AND batal='' ");
			
		$rdebet=0;
		$rkredit=0;
		while($r=mysql_fetch_array($sql)){
			$rdebet=$rdebet+$r[debet];
			$rkredit=$rkredit+$r[kredit];
		}
			
		$saldo =$rdebet-$rkredit;
		$subtot=$subtot+$saldo;
			
		echo "<table width='100%' align='left'>
			<tr>
				<td width='3%'></td>
				<td width='35%'>$r1[naakun]</td>					
				<td width='2%'>Rp</td>
				<td width='20%' align='right'>".number_format($saldo,2)."</td>
				<td width='40%'></td>
			</tr>
		</table>";
	}
		
	echo "<table width='100%' align='left'>
		<tr>
			<td width='3%'></td>
			<td width='35%'></td>
			<td width='2%' style='border-bottom:double 1px'></td>
			<td width='20%' align='right' style='border-bottom:double 1px'></td>
			<td width='2%'></td>
			<td width='20%'></td>
			<td width='18%'></td>
		</tr>
			
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Jumlah</td>
			<td style='border-bottom:double 1px'>Rp</td>
			<td align='right' style='border-bottom:double 1px'>".number_format($subtot,2)."</td>
			<td></td>
		</tr>
	</table>";
	$laba=$laba-$subtot;
			
echo "<table width='100%' align='left'>
		<tr>
			<td align='left'><b>Biaya Administrasi dan Umum</b></td>
		</tr>
	</table>";

	$sql1	= mysql_query("SELECT * FROM akun_bb WHERE nogol='52' AND level='2' ORDER BY noakun");
	$subtot	= 0;
	while($r1=mysql_fetch_array($sql1)){
		$noakun=$r1[noakun];

		$sql = mysql_query("SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal) <'$bulan1' AND year(tanggal)='$tahun' AND batal='' ");
			
		$rdebet=0;
		$rkredit=0;
		while($r=mysql_fetch_array($sql)){
			$rdebet=$rdebet+$r[debet];
			$rkredit=$rkredit+$r[kredit];
		}
			
		$saldo =$rdebet-$rkredit;
		$subtot=$subtot+$saldo;
			
		echo "<table width='100%' align='left'>
			<tr>
				<td width='3%'></td>
				<td width='35%'>$r1[naakun]</td>					
				<td width='2%'>Rp</td>
				<td width='20%' align='right'>".number_format($saldo,2)."</td>
				<td width='40%'></td>
			</tr>
		</table>";
	}
		
	echo "<table width='100%' align='left'>
		<tr>
			<td width='3%'></td>
			<td width='35%'></td>
			<td width='2%' style='border-bottom:double 1px'></td>
			<td width='20%' align='right' style='border-bottom:double 1px'></td>
			<td width='2%'></td>
			<td width='20%'></td>
			<td width='18%'></td>
		</tr>
			
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Jumlah</td>
			<td style='border-bottom:double 1px'>Rp</td>
			<td align='right' style='border-bottom:double 1px'>".number_format($subtot,2)."</td>
			<td></td>
		</tr>
	</table>";
	$laba=$laba-$subtot;
			
	echo "<table width='100%' align='left'>
		<tr>
			<td width='3%'></td>
			<td width='35%'></td>
			<td width='2%'></td>
			<td width='20%' align='right'>Laba Usaha</td>
			<td width='2%' style='border-bottom:double 1px'>Rp</td>
			<td width='20%' align='right' style='border-bottom:double 1px'>".number_format($laba,2)."</td>
			<td width='18%'></td>
		</tr>
		</table>
		<br>";
			
echo "<table width='100%' align='left'>
		<tr>
			<td><b>Pendapatan dan Biaya Non Usaha</b></td>
		</tr>
		<tr>
			<td><b>Pendapatan Non Usaha</b></td>
		</tr>
	</table>";
	$labanon=0;
	
	$sql1	= mysql_query("SELECT * FROM akun_bb WHERE nogol='61' AND level='2' ORDER BY noakun");
	$subtot	= 0;
	while($r1=mysql_fetch_array($sql1)){
		$noakun=$r1[noakun];

		$sql = mysql_query("SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal) <'$bulan1' AND year(tanggal)='$tahun' AND batal='' ");
			
		$rdebet=0;
		$rkredit=0;
		while($r=mysql_fetch_array($sql)){
			$rdebet=$rdebet+$r[debet];
			$rkredit=$rkredit+$r[kredit];
		}
			
		$saldo =$rkredit-$rdebet;
		$subtot=$subtot+$saldo;
				
		echo "<table width='100%' align='left'>
			<tr>
				<td width='3%'></td>
				<td width='35%'>$r1[naakun]</td>					
				<td width='2%'>Rp</td>
				<td width='20%' align='right'>".number_format($saldo,2)."</td>
				<td width='40%'></td>
			</tr>
		</table>";
	}
		
	echo "<table width='100%' align='left'>
		<tr>
			<td width='3%'></td>
			<td width='35%'></td>
			<td width='2%' style='border-bottom:double 1px'></td>
			<td width='20%' align='right' style='border-bottom:double 1px'></td>
			<td width='2%'></td>
			<td width='20%'></td>
			<td width='18%'></td>
		</tr>		
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Jumlah</td>
			<td style='border-bottom:double 1px'>Rp</td>
			<td align='right' style='border-bottom:double 1px'>".number_format($subtot,2)."</td>
			<td></td>
		</tr>
	</table>
	<br>";
	$labanon=$labanon+$subtot;
	$laba=$laba+$subtot;
			
echo "<table width='100%' align='left'>
		<tr>
			<td><b>Biaya Non Usaha</b></td>
		</tr>
	</table>";

	$sql1	= mysql_query("SELECT * FROM akun_bb WHERE nogol='62' AND level='2' ORDER BY noakun");
	$subtot	= 0;
	while($r1=mysql_fetch_array($sql1)){
		$noakun=$r1[noakun];
		
		$sql = mysql_query("SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal) <'$bulan1' AND year(tanggal)='$tahun' AND batal='' ");
				
		$rdebet=0;
		$rkredit=0;
		while($r=mysql_fetch_array($sql)){
			$rdebet=$rdebet+$r[debet];
			$rkredit=$rkredit+$r[kredit];
		}			
		$saldo =$rdebet-$rkredit;
		$subtot=$subtot+$saldo;
				
		echo "<table width='100%' align='left'>
			<tr>
				<td width='3%'></td>
				<td width='35%'>$r1[naakun]</td>					
				<td width='2%'>Rp</td>
				<td width='20%' align='right'>".number_format($saldo,2)."</td>
				<td width='40%'></td>
			</tr>
		</table>";
	}
		
	echo "<table width='100%' align='left'>
		<tr>
			<td width='3%'></td>
			<td width='35%'></td>
			<td width='2%' style='border-bottom:double 1px'></td>
			<td width='20%' align='right' style='border-bottom:double 1px'></td>
			<td width='2%'></td>
			<td width='20%'></td>
			<td width='18%'></td>
		</tr>
		
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Jumlah</td>
			<td style='border-bottom:double 1px'>Rp</td>
			<td align='right' style='border-bottom:double 1px'>".number_format($subtot,2)."</td>
			<td></td>
		</tr>
	</table>";
	$labanon=$labanon-$subtot;
	$laba=$laba-$subtot;
			
	echo "<table width='100%' align='left'>
		<tr>
			<td width='3%'></td>
			<td width='35%'></td>
			<td width='2%'></td>
			<td width='20%' align='right'>Laba Non Usaha</td>
			<td width='2%' style='border-bottom:double 1px'>Rp</td>
			<td width='20%' align='right' style='border-bottom:double 1px'>".number_format($labanon,2)."</td>
			<td width='18%'></td>
		</tr>
		
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td align='right'>Laba Bersih</td>
			<td style='border-bottom:double 1px'>Rp</td>
			<td align='right' style='border-bottom:double 1px'>".number_format($laba,2)."</td>
			<td></td>
		</tr>
	</table>
	<hr>";
?>