<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];
$laba	= 0;

echo "<hr>
		<div align='left'>
			<li><b>Pendapatan Usaha</b></li>			
		</div>";
				
		$query1 = "SELECT * FROM akun_bb WHERE nogol='41' AND level='2' ORDER BY noakun";		
		$sql1	= mysql_query($query1);
		$subtot	= 0;
		while($r1=mysql_fetch_array($sql1)){
			$noakun=$r1[noakun];
			
			$query	= "SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal)='$bulan' AND year(tanggal)='$tahun' AND batal='' ";
			$sql = mysql_query($query);
				
			$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-top:double 1px'></td>
				<td width='20%' style='border-top: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>Rp</td>
				<td align='right'>".number_format($subtot,2)."</td>
				<td></td>
			</tr>
			</table>
			<br>";
			$laba=$laba+$subtot;
		
echo "<div align='left'>
			<li><b>Pengurang Pendapatan</b></li>
		</div>";
				
		$query1 = "SELECT * FROM akun_bb WHERE nogol='42' AND level='2' ORDER BY noakun";		
		$sql1	= mysql_query($query1);
		$subtot	= 0;
		while($r1=mysql_fetch_array($sql1)){
			$noakun=$r1[noakun];
			
			$query	= "SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal)='$bulan' AND year(tanggal)='$tahun' AND batal='' ";
			$sql = mysql_query($query);
				
			$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-top:double 1px'></td>
				<td width='20%' style='border-top: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>Rp</td>
				<td align='right'>".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%'></td>
				<td width='2%' style='border-top:double 1px'></td>
				<td width='20%' style='border-top:double 1px'></td>
				<td width='18%'></td>
			</tr>
			
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td alidn='right'>Pendapatan Bersih</td>				
				<td>Rp</td>
				<td align='right'>".number_format($laba,2)."</td>
				<td></td>
			</tr>
			
			</table>
			<br>";
			
echo "<div align='left'>
			<li><b>Harga Pokok Penjualan</b></li>
		</div>";
				
		$query1 = "SELECT * FROM akun_bb WHERE nogol='51' AND level='2' ORDER BY noakun";		
		$sql1	= mysql_query($query1);
		$subtot	= 0;
		while($r1=mysql_fetch_array($sql1)){
			$noakun=$r1[noakun];
			
			$query	= "SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal)='$bulan' AND year(tanggal)='$tahun' AND batal='' ";
			$sql = mysql_query($query);
				
			$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-top:double 1px'></td>
				<td width='20%' style='border-top: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>Rp</td>
				<td align='right'>".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%'></td>
				<td width='2%' style='border-top:double 1px'></td>
				<td width='20%' style='border-top:double 1px'></td>
				<td width='18%'></td>
			</tr>
			
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td alidn='right'>Laba Kotor</td>				
				<td>Rp</td>
				<td align='right'>".number_format($laba,2)."</td>
				<td></td>
			</tr>			
			</table>
			<br>";

echo "<div align='left'>
			<li><b>Biaya Pemasaran</b></li>
		</div>";
				
		$query1 = "SELECT * FROM akun_bb WHERE nogol='52' AND level='2' ORDER BY noakun";		
		$sql1	= mysql_query($query1);
		$subtot	= 0;
		while($r1=mysql_fetch_array($sql1)){
			$noakun=$r1[noakun];
			
			$query	= "SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal)='$bulan' AND year(tanggal)='$tahun' AND batal='' ";
			$sql = mysql_query($query);
				
			$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-top:double 1px'></td>
				<td width='20%' style='border-top: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>Rp</td>
				<td align='right'>".number_format($subtot,2)."</td>
				<td></td>
			</tr>
			</table>";
			$laba=$laba-$subtot;
			
echo "<div align='left'>
			<li><b>Biaya Administrasi dan Umum</b></li>
		</div>";
				
		$query1 = "SELECT * FROM akun_bb WHERE nogol='53' AND level='2' ORDER BY noakun";		
		$sql1	= mysql_query($query1);
		$subtot	= 0;
		while($r1=mysql_fetch_array($sql1)){
			$noakun=$r1[noakun];
			
			$query	= "SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal)='$bulan' AND year(tanggal)='$tahun' AND batal='' ";
			$sql = mysql_query($query);
				
			$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-top:double 1px'></td>
				<td width='20%' style='border-top: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>Rp</td>
				<td align='right'>".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%'></td>
				<td width='2%' style='border-top:double 1px'></td>
				<td width='20%' style='border-top:double 1px'></td>
				<td width='18%'></td>
			</tr>
			
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td alidn='right'>Laba Usaha</td>
				<td>Rp</td>
				<td align='right'>".number_format($laba,2)."</td>
				<td></td>
			</tr>			
			</table>
			<br>";
			
echo "<div align='left'>
			<li><b>Pendapatan dan Biaya Non Usaha</b></li>
			<li><b>Pendapatan dan Non Usaha</b></li>
		</div>";
		$labanon=0;
		
		$query1 = "SELECT * FROM akun_bb WHERE nogol='61' AND level='2' ORDER BY noakun";		
		$sql1	= mysql_query($query1);
		$subtot	= 0;
		while($r1=mysql_fetch_array($sql1)){
			$noakun=$r1[noakun];
			
			$query	= "SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal)='$bulan' AND year(tanggal)='$tahun' AND batal='' ";
			$sql = mysql_query($query);
				
			$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-top:double 1px'></td>
				<td width='20%' style='border-top: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>Rp</td>
				<td align='right'>".number_format($subtot,2)."</td>
				<td></td>
			</tr>
			</table>
			<br>";
			$labanon=$labanon+$subtot;
			$laba=$laba+$subtot;
			
echo "<div align='left'>
			<li><b>Biaya dan Non Usaha</b></li>
		</div>";
		
		$query1 = "SELECT * FROM akun_bb WHERE nogol='62' AND level='2' ORDER BY noakun";		
		$sql1	= mysql_query($query1);
		$subtot	= 0;
		while($r1=mysql_fetch_array($sql1)){
			$noakun=$r1[noakun];
			
			$query	= "SELECT tanggal,noakun,debet,kredit FROM rekapjur WHERE noakun='$noakun' AND month(tanggal)='$bulan' AND year(tanggal)='$tahun' AND batal='' ";
			$sql = mysql_query($query);
				
			$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-top:double 1px'></td>
				<td width='20%' style='border-top: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>Rp</td>
				<td align='right'>".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%'></td>
				<td width='2%' style='border-top:double 1px'></td>
				<td width='20%' style='border-top:double 1px'></td>
				<td width='18%'></td>
			</tr>
			
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td alidn='right'>Laba Non Usaha</td>
				<td>Rp</td>
				<td align='right'>".number_format($labanon,2)."</td>
				<td></td>
			</tr>
			
			<tr>
				<td></td>
				<td></td>
				<td></td>								
				<td></td>
				<td width='2%' style='border-top:double 1px'></td>
				<td width='20%' style='border-top:double 1px'></td>
				<td></td>
			</tr>
			
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td alidn='right'>Laba Bersih</td>
				<td>Rp</td>
				<td align='right'>".number_format($laba,2)."</td>
				<td></td>
			</tr>
			</table>
			<hr>";
?>
