Title: cekLogin
Author: ella
Company: jogjakarta

Listing Program

cekLogin.php
<?
if(ereg("cekLogin.php", $PHP_SELF)){
    header("location: index.php");
    die;
} else{
	session_start();
	if (!session_is_registered(username) and !session_is_registered(password)){
		print("<script> alert('Anda harus Login terlebih dahulu!!');location.href='index.php';</script>");
		exit;
	}
}
?>

conect.php
<?
if(ereg("conect.php", $PHP_SELF)){
    header("location: index.php");
    die;
} else{
	$server = 'localhost';
	$database = 'piutang';
	$user = 'root';
	$pass = '';
	@mysql_connect("$server","$user","$pass") or die("<font color='#009900'><h2>Tidak Berhasil Koneksi Ke Database</h2></font>");
	@mysql_select_db($database) or die("<font align=center color='#009900'>Database Tidak Ketemu</font>");
}
?>

index.php
<?
include '../conect/conect.php';

$submit 	= $_REQUEST['submit'];
$nama		= $_POST['nama'];
$passwd 	= $_POST['passwd'];

if($submit){
	if (empty($nama) || empty($passwd))
		print("<script> alert('Isian Masih Ada Yang Kosong!!');self.history.back();</script>");
	else{
		if (!empty($nama) || !empty($passwd)){
			$query = "select * from admin where username='$nama'";
			$hasil=mysql_query($query);
			$jumlah=mysql_num_rows($hasil);
			if ($jumlah==0)
				print "<script>alert('Anda Tidak Berhak!');window.history.go(-1);</script>";
			else {
				if($jumlah>0){
					$baris=mysql_fetch_array($hasil);
					$username=$baris['username'];
					$password=$baris['password'];
					if ($passwd!=$password)
						print "<script>alert('Password Anda Salah, Silakan ulangi kembali!');window.history.go(-1);</script>";
					else {
						if($passwd==$password){
							session_start();
							session_register("username","password");
							header("location:index2.php?");
						}
					}
				}
			}	
		}
	}
}
?>
<html>
<head>
<title>.:: TOKO TENGAH SLEMAN</title>
</head>
<body bgcolor="#FFFFFF" background="images/background.JPG">
<br><br>
<center>
<form action="index.php" method="post" enctype="multipart/form-data" name="f">
<table cellpadding=1 cellspacing=0 border=0 bgcolor="#4f89b7" width="340" height="121">
<tr><td bgcolor="#4f89b7" width="346" height="16" align="center"><font color="#FFFFFF"><b><font face="Arial" size="2">&nbsp;</font><font face="verdana" size="2">Login Admin<br>&nbsp;<font size=1 color=silver></font></font></b></font></td></tr><tr>
  <td width="346" height="101">  
<table cellpadding=2 cellspacing=0 border=0 bgcolor="#FFFFFF" width="338" height="131"><tr>
  <td width="96" height="1">
  <tr>  	
    <td width="330" bgcolor="#FFFFFF" style="border-right-width: 1; border-bottom-width: 1" valign="top" colspan="2">
    <center><? print("<font color=red size=2><b>$msg</b></font>"); ?></center></td>
  </tr>
  <tr>  	
    <td width="96" height="31" bgcolor="#FFFFFF" style="border-right-width: 1; border-bottom-width: 1" valign="bottom">
    <b>
    <font face="Times New Roman"><big>&nbsp; </big> </font>
    </b>
    <font face="Tahoma" size="2">Username</font></td>
    <td width="234" height="31" bgcolor="#FFFFFF" valign="bottom" align="left">
    <p align="left"><font face="Times New Roman">&nbsp;: </font><input name="nama" type="text" id="q" size="20" maxlength="30"></td>
  </tr>
  <tr>
    <td width="96" height="36" bgcolor="#FFFFFF" valign="bottom">
    <b><font face="Times New Roman">&nbsp;<big> </big> </font></b>
    <font face="Tahoma" size="2">Password</font></td>
    <td width="234" height="36" align="left" bgcolor="#FFFFFF" valign="bottom">
    <font face="Times New Roman">&nbsp;: </font>
    <font face="Times New Roman" color="#FFFFFF"> 
    <input type="password" name="passwd" size="20" maxlength="30"></font></td>
  </tr>
  <tr>
    <td width="96" height="44" bgcolor="#FFFFFF" style="border-right-width: 1; border-top-width: 1">&nbsp;</td>
    <td width="234" height="44" bgcolor="#FFFFFF" valign="top">
    <font face="Times New Roman">&nbsp;
    <input type="submit" name="submit" value="Masuk"></font></td>    
</td></tr></table></td></tr></table></form>
</center>

</body>
</html>

header.html
<html>
<head>
<title>.: Toko tengah Sleman :.</title>
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
<!--
.style1 {
	font-size: 24px;
	color: #FFFFFF;
}
.style2 {
	font-family: "Comic Sans MS";
	font-size: 24px;
	color: #0057AE;
}
.style3 {color: #FFFFFF}
-->
</style>
</head>
<body>
<!--script language="JavaScript1.2">mmLoadMenus();</script-->
<table width="75%" border="0" align="center" cellpadding="1" cellspacing="1">
  <tr bgcolor="DFEEDC"> 
    <td height="100" bgcolor="#0080C0"><table width="100%" border="0" align="center">
        <tr> 
          <td width="21%" rowspan="3"><div align="left"><img src="images/logos.gif" width="150" height="100" align="right"></div></td>
          <td width="79%" height="58"><div align="right"><span class="style1">TOKO TENGAH SLEMAN</span></div></td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
        </tr>
        <tr> 
          <td class="TEXT1"><div align="right" class="style3">Jl. Letkol Subadri No.5 Desa Sleman</div></td>
        </tr>
      </table></td>
  </tr>
  <tr bgcolor="EDFDF5"> 
    <td height="100" bgcolor="#c0d0b0" valign="top"><table width="100%" border="0">
        <tr> 
          <td colspan="3"><div align="right"><font face="Verdana" size="1" color="#0057AE"><? echo date("D, d M Y, g:s A "); ?></font></div></td>
        </tr>
        <tr> 
          <td width="15%" valign="top"><table width="100%" height="248" border="0" cellpadding="1" cellspacing="1">
              <tr> 
                <td height="138"> <table width="100%" height="100%" border="1" cellpadding="1" cellspacing="1" bordercolor="#0057AE">
                    <tr> 
                      <td valign="top" width="100%" height="139"> <table width="100%" height="100%" border="0" cellpadding="1" cellspacing="1">
                          <tr>
                            <td bgcolor="#0080C0" class="TEXT1" height="20">.: Menu :.</td>
                          </tr>
                          <tr> 
                            <td bgcolor="#5BADFF" class="TEXT1"><a href="index.php">Home</a></td>
                          </tr>
                          <tr> 
                            <td bordercolor="#D4D0C8" bgcolor="#5BADFF" class="TEXT1"><a href="output_jenis.php">Laporan Jenis </a></td>
                          </tr>
                          <tr> 
                            <td bgcolor="#5BADFF" class="TEXT1"><a href="output_barang.php">Laporan Barang </a></td>
                          </tr>
                          <tr> 
                            <td bgcolor="#5BADFF" class="TEXT1"><a href="output_pelanggan.php">Laporan Pelanggan </a></td>
                          </tr>
						  <tr> 
                            <td bgcolor="#5BADFF" class="TEXT1"><a href="output_barang.php">Daftar Analisa </a></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
              </tr>
              <tr> 
                <td valign="top" height="100%">&nbsp;</td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
              </tr>
              <tr> 
                <td><table width="100%" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#0057AE">
                    <tr> 
                      <td valign="top"><table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
                          <tr> 
                            <td class="TEXT1" bgcolor="#0080C0" height="20">.: Calender :.</td>
                          </tr>
                          <tr> 
                            <td> 
                              <? include "calender.php";?>
                            </td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
              </tr>
            </table>
          </td>
          <td width="35%" valign="top"><table width="100%" align="center" cellpadding="1" cellspacing="1">
              <tr> 
                <th bgcolor="#0080C0" width="5%"></th>
                <th bgcolor="#5BADFF"><marquee behavior="alternate"><font size="3" class="style2">.: </font><span class="style2">WELCOME</span><font size="3" class="style2"> :.<br>
                </font></marquee></th>
                <th bgcolor="#0080C0" width="5%">&nbsp;</th>
              </tr>
              <tr> 
                <td colspan="3"><hr noshade color="#0057AE"></td>
              </tr>
              <tr> 
                <td colspan="3"><table width="100%" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#0080C0">
                    <tr> 
                      <td height="174" valign="top" bgcolor="#D2E9FF"><table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
                          <tr> 
                            <td bgcolor="#0080C0" class="TEXT1" height="20">Toko Tengah Sleman</td>
                          </tr>
                          <tr> 
                            <td class="NEWS">

footer.html
</td>
                          </tr>
                          <tr> 
                            <td>&nbsp;</td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
              <tr> 
                <td colspan="3"><hr noshade color="#0057AE"></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td bgcolor="#0080C0" class="TEXT">Developed By Toko Tengah Sleman <br>
      Copyright 2007</td>
  </tr>
</table>
</body>
</html>

calender.php
<?php 
//bulan sekarang 
$month=date("m"); 
//Tahun sekarang 
$year=date("Y"); 
//hari ini 
$day=date("d"); 
//cek jumlah hari tahun sekarang 
$endDate=date("t",mktime(0,0,0,$month,$day,$year));

//style untuk table 
echo ' <style> td { font-size:11; font-family:verdana; } </style> '; 
//table untuk menulis tanggal sekarang 
echo '<table align="center" border="0" width="100%" cellpadding=2 cellspacing=1 style=""><tr><td align=center>'; 
echo date(" M  ",mktime(0,0,0,$month,$day,$year)); 
echo '</td></tr></table>';
//table untuk menulis hari 
echo ' <table align="center" border="0" width="100%" cellpadding=2 cellspacing=1 style="border:1px solid #CCCCCC" bgcolor="dfefff"> 
<tr bgcolor="#EFEFEF"> <td align=center><font color=red>Su</font></td> 
<td align=center>Mo</td> <td align=center>Tu</td> 
<td align=center>We</td> <td align=center>Th</td> 
<td align=center>Fr</td> <td align=center><font color=blue>Sa</font></td>
</tr> '; 
/* mengecek tanggal 1 bulan sekarang ada pada hari ke berapa kemudian tambahkan cell td sebanyak var $s */ 
$s=date ("w", mktime (0,0,0,$month,1,$year)); 
for ($ds=1;$ds<=$s;$ds++) 
{ 
echo "<td style=\"font-family:arial;color:#B3D9FF\" width=\"15%\" align=center valign=middle bgcolor=\"#FFFFFF\"> </td>"; }
//memulai penulisan tanggal
for($d=1;$d<=$endDate;$d++) {  
//jika nilai $d (tanggal) adalah hari minggu (0) dibuat baris baru <tr>
if (date("w",mktime (0,0,0,$month,$d,$year)) == 0) 
{ echo "<tr>"; } 
//default warna huruf 
$fontColor="#000000";
//jika tanggal adalah hari minggu warna huruf merah
if (date("D",mktime (0,0,0,$month,$d,$year)) == "Sun") { $fontColor="red"; } 
// jika tanggal adalah hari sabtu warna huruf biru 
if (date("D",mktime (0,0,0,$month,$d,$year)) == "Sat") { $fontColor="blue"; } 
//menulis tanggal
echo "<td style=\"font-family:arial;color:#333333\" width=\"15%\" align=center valign=middle> <span style=\"color:$fontColor\">$d</span></td>";
//jika tanggal adalah hari sabtu (6) akhiri baris </tr>} 
if (date("w",mktime (0,0,0,$month,$d,$year)) == 6) { echo "</tr>"; }}
//akhir table 
echo '</table>'; ?>

rupiah.php
<?php
if(ereg("rupiah.php", $PHP_SELF))
{
    header("location: index.php");
    die;
}
function rupiah($rp)
{
	$rupiah = "";
	$p = strlen($rp);
	while($p > 3)
	{
		$rupiah = "." . substr($rp,-3) . $rupiah;
		$l = strlen($rp) - 3;
		$rp = substr($rp,0,$l);
		$p = strlen($rp);
	}
	$rupiah = "" . $rp . $rupiah . ",-";
	return $rupiah;
}
?>

daftar_barang.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";
include "../rupiah.php";
include "header.html";

$query 			= "SELECT b.*,j.* FROM barang b, jenis j where b.kd_jenis=j.kd_jenis ORDER BY kd_barang";
$hasil 			= mysql_query($query);
$jumlahHasil 	= mysql_num_rows($hasil);
if($jumlahHasil < 1)
	echo("<br><center><h1>Data Barang Tidak Ada Pada Database</h1></center><BR>"); 
else { 
?>
	<div align="center"><font color="#0080C0"><h2>DAFTAR DATA BARANG</h2></font></div>
	<br><br>
	<table border="0" width="99%">
		<tr bgcolor="#0080C0" style="color:#000000 " align="center">
			<td width="10%"><font color="#FFFFFF">Kode Barang</font></td>
			<td width="19%"><font color="#FFFFFF">Nama Jenis</font></td>
			<td width="27%"><font color="#FFFFFF">Nama Barang</font></td>
			<td width="15%" bgcolor="#0080C0"><font color="#FFFFFF">Harga Beli</font></td>
			<td width="16%"><font color="#FFFFFF">Stock</font></td>
			<td width="13%"><font color="#FFFFFF">Action</font></td>
	  </tr>
<?
		//Membuat Kolom
		$i=1;
		while($data=mysql_fetch_array($hasil)) {
			$a=rupiah($data[harga_barang]);
			$kd_barang=substr("000",0,3-strlen($data[kd_barang])).$data[kd_barang];
			echo "<tr bgcolor=\"#FFFFFF\">";
			echo "<td align='center'>$kd_barang</td>";
			echo "<td>$data[nama_jenis]</td>";
			echo "<td>$data[nama_barang]</td>";
			echo "<td align=right>Rp. $a</td>";
			echo "<td>$data[stock] $data[satuan] </td>";
			echo "<td align='center'> <a href=\"input_barang.php?action=ubah&id=$data[kd_barang]\">Edit</a> - <a href=\"proses_barang.php?action=hapus&id=$data[kd_barang]\">Hapus</a></td>";
			echo "</tr>";
			$i++;
		}
?>
</table>
<?
}
?>
<br><br>
<? include "../footer.html";?>

daftar_jenis.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";
include "header.html";

$query 			= "SELECT * FROM jenis ORDER BY kd_jenis";
$hasil 			= mysql_query($query);
$jumlahHasil 	= mysql_num_rows($hasil);
if($jumlahHasil < 1)
	echo("<br><center><h1>Data Jenis Barang Tidak Ada Pada Database</h1></center><BR>"); 
else { 
?>
<style type="text/css">
<!--
.style1 {color: #0080C0}
-->
    </style>
	<div align="center" class="style1"><h2>DAFTAR DATA JENIS</h2></div>
	<br><br>
	<table border="0" width="99%">
		<tr bgcolor="#0080C0" style="color:#000000 " align="center">
			<td width="32%"><font color="#FFFFFF">Kode Jenis</font></td>
			<td width="45%"><font color="#FFFFFF">Nama Jenis</font></td>
			<td width="23%"><font color="#FFFFFF">Action</font></td>
	  </tr>
<?
		//Membuat Kolom
		$i=1;
		while($data=mysql_fetch_array($hasil)) {
			$kdJenis=substr("0000",0,4-strlen($data[kd_jenis])).$data[kd_jenis];
			echo "<tr bgcolor=\"#FFFFFF\">";
			echo "<td align='center'>$kdJenis</td>";
			echo "<td>$data[nama_jenis]</td>";
			echo "<td align='center'> <a href=\"input_jenis.php?action=ubah&id=$data[kd_jenis]\">Edit</a> - <a href=\"proses_jenis.php?action=hapus&id=$data[kd_jenis]\">Hapus</a></td>";
			echo "</tr>";
			$i++;
		}
?>
</table>
<?
}
?>
<br><br>
<? include "../footer.html";?>
daftar_pelanggan.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";
include "header.html";

$query 			= "SELECT * FROM pelanggan ORDER BY kd_plg";
$hasil 			= mysql_query($query);
$jumlahHasil 	= mysql_num_rows($hasil);
if($jumlahHasil < 1)
	echo("<br><center><h1>Data Pelanggan Tidak Ada Pada Database</h1></center><BR>"); 
else { 
?>
	<div align="center"><font color="#0080C0"><h2>DAFTAR DATA PELANGGAN</h2></font></div>
	<br><br>
	<table border="0" width="99%">
		<tr bgcolor="#0080C0" style="color:#000000 " align="center">
			<td width="13%"><font color="#FFFFFF">Kode Pelanggan</font></td>
			<td width="23%"><font color="#FFFFFF">Nama Pelanggan</font></td>
			<td width="13%"><font color="#FFFFFF">Alamat</font></td>
			<td width="13%"><font color="#FFFFFF">Kota</font></td>
			<td width="13%"><font color="#FFFFFF">Telp</font></td>
			<td width="10%"><font color="#FFFFFF">Action</font></td>
	  </tr>
<?
		//Membuat Kolom
		$i=1;
		while($data=mysql_fetch_array($hasil)) {
			$kd_plg=substr("0000",0,4-strlen($data[kd_plg])).$data[kd_plg];
			echo "<tr bgcolor=\"#FFFFFF\">";
			echo "<td align='center'>$kd_plg</td>";
			echo "<td>$data[nama_plg]</td>";
			echo "<td>$data[alamat]</td>";
			echo "<td>$data[kota]</td>";
			echo "<td>$data[telp] </td>";
			echo "<td align='center'> <a href=\"input_pelanggan.php?action=ubah&id=$data[kd_plg]\">Edit</a> - <a href=\"proses_pelanggan.php?action=hapus&id=$data[kd_plg]\">Hapus</a></td>";
			echo "</tr>";
			$i++;
		}
?>
	</table>
<?
}
?>
<br><br>
<? include "../footer.html";?>

daftar_taksir.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";
include "header.html";

$query 			= "SELECT * FROM pelanggan ORDER BY kd_plg";
$hasil 			= mysql_query($query);
$jumlahHasil 	= mysql_num_rows($hasil);
if($jumlahHasil < 1)
	echo("<br><center><h1>Data Pelanggan Tidak Ada Pada Database</h1></center><BR>"); 
else { 
?>
	<div align="center"><font color="#0080C0"><h2>DAFTAR DATA PELANGGAN</h2></font></div>
	<br><br>
	<table border="0" width="99%">
		<tr bgcolor="#0080C0" style="color:#000000 " align="center">
			<td width="13%"><font color="#FFFFFF">Kode Pelanggan</font></td>
			<td width="23%"><font color="#FFFFFF">Nama Pelanggan</font></td>
			<td width="13%"><font color="#FFFFFF">Alamat</font></td>
			<td width="13%"><font color="#FFFFFF">Kota</font></td>
			<td width="13%"><font color="#FFFFFF">Telp</font></td>
			<td width="10%"><font color="#FFFFFF">Action</font></td>
	  </tr>
<?
		//Membuat Kolom
		$i=1;
		while($data=mysql_fetch_array($hasil)) {
			$kd_plg=substr("0000",0,4-strlen($data[kd_plg])).$data[kd_plg];
			echo "<tr bgcolor=\"#FFFFFF\">";
			echo "<td align='center'>$kd_plg</td>";
			echo "<td>$data[nama_plg]</td>";
			echo "<td>$data[alamat]</td>";
			echo "<td>$data[kota]</td>";
			echo "<td>$data[telp] </td>";
			echo "<td align='center'> <a href=\"input_pelanggan.php?action=ubah&id=$data[kd_plg]\">Edit</a> - <a href=\"proses_pelanggan.php?action=hapus&id=$data[kd_plg]\">Hapus</a></td>";
			echo "</tr>";
			$i++;
		}
?>
	</table>
<?
}
?>
<br><br>
<? include "../footer.html";?>

ganti_password.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";
include "header.html";

$submit 		= $_REQUEST['submit'];
$old_pass		= $_GET['old_pass'];
$new_passA 		= $_POST['new_passA'];
$new_passB 		= $_POST['new_passB'];

if($submit){
	if (empty($old_pass) || empty($new_passA) || empty($new_passB))
		$msg="<center><font color=red><strong>Semua isian harus diisi</strong></font></center>";
	else {
		session_start();
		$query="SELECT * FROM admin where username='$username'";
		$hasil=mysql_query($query);
		$data=mysql_fetch_array($hasil);
		$old_pass_dbase=$data['password'];
		if($old_pass <> $old_pass_dbase) 
			$msg="<center><font color=red><strong>Masukkan password lama dengan benar!</strong></font></center>";
		else {
			$new_pass=$new_passA;		
			$query="UPDATE admin SET password='$new_pass' where username='$username'";
			$hasil=mysql_query($query);
			$msg="<center><font color=blue><strong>Password Berhasil di Ubah</strong></font></center>";
		}
	} 
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function evKirim() {
	if (!document.formPass.old_pass.value) {
		alert('Masukan Password Lama')
		document.formPass.old_pass.focus();
		return false;		
	}
	if (!document.formPass.new_passA.value) {
		alert('Masukkan Password Baru I')
		document.formPass.new_passA.focus();
		return false;		
	}
	if (!document.formPass.new_passB.value) {
		alert('Masukkan Password Baru II')
		document.formPass.new_passB.focus();
		return false;		
	}
	if (document.formPass.new_passA.value != document.formPass.new_passB.value) {
		alert('Password baru I tidak cocok dengan Password baru II')
		document.formPass.new_passB.focus();
		return false;		
	}									
}
</script>
<style type="text/css">
<!--
body,td,th {
	color: #0080C0;
}
-->
</style></head>

<body>
<form action="ganti_password.php" method="post">
	<table width="99%">
		<tr>
		<table align="center">
			<tr><td width="100%"><h2>GANTI PASSWORD</h2></td></tr>
		</table>
		</tr>
		
		<tr><td>&nbsp;</td></tr>
		
		<tr>
		<table>
			<tr><td width="229">Password Lama</td>
      <td width="336"><input type="password" name="old_pass" size="30" maxlength="10"></td>
    </tr>
  	<tr><td>Password Baru</td><td><input type="password" name="new_passA" size="30" maxlength="10"></td></tr>
 	<tr><td>Ulangi Password Baru</td><td><input type="password" name="new_passB" size="30" maxlength="10"></td></tr>
		</table>
		</tr>
		
		<tr><td>&nbsp;</td></tr>
		
		<tr>
		<table width="99%">
			<td align="center" width="50%"><input type="submit" name="simpan" value="Kirim"></td>
			<td align="left" width="50%"><input type="reset" name="cancel" value="Kosongkan"></td>
		</table>
		</tr>
	</table>
</form>
<br><br>
<? include "../footer.html";?>
</body>
</html>

index.inc.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h2>Profil Toko Tengah Sleman </h2>
<p> Toko Tengah Sleman adalah usaha milik pribadi yang modalnya diperoleh dari pemilik. Toko Tengah Sleman bergerak dibidang pelayanan dan penjualan furniture, barang-barang yang dijual adalah barang-barang dagangan yang berkaitan dengan perlengkapan rumah tangga seperti meja, almari, kursi, busa, dan lain-lain. </p>

<h2>Lokasi</h2>
<p> Toko Tengah Sleman berdiri &plusmn; pada tahun 1979 dan terletak di Jl. Letkol Subadri No.5 Desa Sleman. Posisi dari Toko Tengah Sleman sangat strategis karena berada di pinggir jalan besar dan berada di sekitar dari Pasar Besar Sleman dan juga merupakan tempat usahanya sampai saat ini. </p>
  
<h2>Toko Tengah Sleman Hari Ini</h2>
<p>Untuk meningkatkan usahanya yaitu melayani masyarakat dengan penjualan barang dagangannya tersebut maka Toko Tengah Sleman menambah jumlah tenaga kerjanya yang tadinya 3 orang menjadi 6 orang yang terdiri dari 2 driver dan 4 tenaganya. Dengan adanya semangat kekeluargaan yang tinggi mereka melakukan pekerjaan dengan baik sehingga pekerjaan terselesaikan dengan cepat. </p>
<p>Toko Tengah Sleman melakukan kerjasama dengan koperasi yang ada di Sleman yaitu koperasi GKBI dan koperasi Primissima selain dengan para supplier atau pemasok yang berasal dari luar kota untuk mendapatkan barang dagangan yang diminta para pembelinya, sehingga prinsip mereka bagi untung. Toko Tengah Sleman juga melakukan pemasaran keluar Sleman agar usahanya lebih meningkat.</p>

<h2>Proses Pembayaran</h2>
<p> Adapun proses pembayaran dapat dilakukan dengan cara tunai maupun kredit. Para pelanggan boleh melakukan pemesanan barang kembali meskipun barang yang dibeli secara kredit belum dilunasi, jadi apabila pelanggan ingin melakukan pemesanan barang kembali tidak harus melunasi piutangnya terlebih dahulu.</p>
</body>
</html>

input_angsuran.php
<? 	include "../conect/conect.php";
   	include "../conect/cekLogin.php";
	include "header.html";
   
   	$kd_plg		= $_GET['kd_plg'];
	$nama_plg	= $_GET['nama_plg'];
?>
<style type="text/css">
<!--
.style1 {font-size: 12}
-->
</style>
<body>
<center><h2>INPUT PENERIMAAN ANGSURAN</h2></center>
<table width="99%">
	<tr><form action="input_angsuran.php" method="get">        
	<td width="501">Nama Pelanggan</td>
        <td width="397"><? 
				if($action=='tambah'){
					echo "<input type='text' readonly='true' value='$nama_plg' name='kd_plg'><input type='hidden' name='kd_plg' value='$kd_plg'>";
				}
				if(!$action=='ubah'){
					echo "<select name='kd_plg'>";
					$query = "SELECT * FROM pelanggan ORDER BY kd_plg";
					$hasil = mysql_query($query);
					echo "<option value='' selected>-- Nama Pelanggan --</option>";
					while ($data2 = mysql_fetch_array($hasil)){
						if($kd_plg==$data2[kd_plg])
							$sel = 'selected';
						else
							$sel = '';
						echo "<option value=\"$data2[kd_plg]\" $sel>$data2[kd_plg] - $data2[nama_plg] </option>";
					}
					echo "</select>";
				}
			?></td>
        <td width="99"><input name="Cari2" type="submit" id="Cari2" value="Cari"></td></form>
	</tr>
</table>
<table width="99%" border="0" align="center">
	<tr bgcolor="#0080C0" style="color:#ffffff" align="center"><td width="43"><span class="style1">No</span></td>
       	<td width="144"><span class="style1">Kode Piutang</span></td>
        <td width="350"><span class="style1">Tgl Piutang</span></td>
        <td width="174"><span class="style1">Saldo</span></td>
		<td width="174"><span class="style1">Jumlah Angsuran</span></td>
		<td width="174"><span class="style1">Action</span></td>
  </tr>
		<?
			$query = "select j.* from jual j, pelanggan p where j.kd_plg=p.kd_plg and j.saldo>0";
   			if(!$kd_plg=='')
   				$query = $query." and p.kd_plg=$kd_plg";
			$query = $query." order by j.kd_jual";
			$hasil=@mysql_query($query);
			$no=0;
			while ($baris=@mysql_fetch_array($hasil)){
				$no++;
				$tgl = explode("-",$baris[tgl_jual]);
		?>	
		<form name='formAngsuran' method='post' action='proses_angsuran.php'>
	<tr bgcolor="#FFFFFF">
		<td align='center'><? print $no; ?></td>	
		<td align='center'><? print $baris[kd_jual]; ?>&nbsp;<input name='kd_jual' type='hidden' value='<? print $baris[kd_jual]; ?>'></td>
		<td align="center"><? print "$tgl[2]-$tgl[1]-$tgl[0]"; ?>&nbsp;<input name='tgl_jual' type='hidden' value='<? print $baris[tgl_jual];?>'></td>
		<td align="right">Rp. <? print $baris[saldo]; ?>&nbsp;<input name='saldo' type='hidden' value='<? print $baris[saldo];?>'></td>
		<td align="right">Rp. <input type='text' size='10' maxlength='9' name='jumlah' value='<? print $jumlah;?>'></td>
		<td><input type="hidden" name="kd_plg" value="<? echo $kd_plg?>"><input type="submit" name='submit' value='Tambah'></td>
	</tr>
		</form>
		<? } ?>
</table>
<? include "../footer.html";?>
</body>
</html>

input_barang.php 
<? include "../conect/conect.php";
   include "../conect/cekLogin.php";
   include "header.html";
   
   $action 		= $_REQUEST['action'];
   if ($action=='ubah'){
		$id		= $_GET['id'];
		$query 	= "SELECT * FROM barang WHERE kd_barang='$id'";
		$hasil 	= @mysql_query($query);
		while($data=@mysql_fetch_array($hasil)) {
			$kd_barang 		= $data['kd_barang'];
			$kd_jenis 		= $data['kd_jenis'];
			$nama_barang 	= $data['nama_barang'];
			$harga_barang 	= $data['harga_barang'];
			$stock 			= $data['stock'];
			$satuan 		= $data['satuan'];
  		}
   }
?>
<style type="text/css">
<!--
body,td,th {
	color: #0080C0;
}
-->
</style>
<body>
<form action="proses_barang.php" method="post">
	<table width="99%">
	<tbody>
		<tr>
		<table align="center">
			<tr><td width="99%"><h2>INPUT DATA BARANG</h2></td>
			</tr>
		</table>
		</tr>
		
	  <font size="+1">
		
		<tr><td>&nbsp;</td></tr>
		
		<tr>
		<table>
			<tr>
			<td width="20%">Kode Barang</td><td width="40%"><input type="text" name="kd_barang" size="10" readonly="true" value="<?
				if (!$action=='ubah'){
					$query = "SELECT max(kd_barang) FROM barang";
					$hasil = mysql_query($query);
					$data = mysql_fetch_row($hasil);
					$ada = mysql_num_rows($hasil);
					$kodeAkhir = $data[0] + 1;
					echo substr("0000",0,4-strlen($kodeAkhir)).$kodeAkhir;
				}
				if ($action=='ubah')
					echo substr("0000",0,4-strlen($kd_barang)).$kd_barang;
			?>"></td>
			</tr>
			<tr>
			<td>Nama Jenis</td><td><select name="kd_jenis">
			<?
				$query = "SELECT * FROM jenis ORDER BY kd_jenis";
				$hasil = mysql_query($query);
				if(!$action=='ubah'){
					echo "<option value='0' selected>-- Jenis Barang --</option>";
					while ($data2 = mysql_fetch_array($hasil)){
						echo "<option value=\"$data2[kd_jenis]\">$data2[kd_jenis] - $data2[nama_jenis] </option>";
					}
				}
				if($action=='ubah'){
					while ($data = mysql_fetch_array($hasil)){
						if($kd_jenis == $data['kd_jenis'])
							$sel="selected";
						else    
							$sel = "";
						echo "<option value=\"$data[kd_jenis]\" $sel>$data[kd_jenis] - $data[nama_jenis] </option>";
					}
				}
			?></select></td>
			</tr>
			<tr><td>Nama Barang</td><td><input type="text" name="nama_barang" size="45" maxlength="35" value="<? echo $nama_barang;?>"></td>
			<tr><td>Harga Barang</td><td><input type="text" name="harga_barang" size="20" maxlength="9" value="<? echo $harga_barang;?>"></td></tr>
			<tr><td>Stock</td><td><input type="text" name="stock" size="10" maxlength="3" value="<? echo $stock;?>"></td></tr>
			<tr><td>Satuan Barang</td><td><select name="satuan">
			<?
				$jns = array("Kilogram","Bungkus", "PCS", "Unit");
				if(!$action=='ubah'){
					echo "<option value='0' selected>-- Satuan Barang --</option>";
					for ($n=0; $n<4; $n++){
						echo "<option value=\"$jns[$n]\">$jns[$n]</option>";
					}
				}
				if($action=='ubah'){
					for ($n=0; $n<4; $n++){
						if($satuan == $jns[$n])
							$sel="selected";
						else    
							$sel = "";
						echo "<option value=\"$jns[$n]\" $sel>$jns[$n]</option>";
					}
				}
			?></select></td></tr>
		</table>
		</tr>
		
		<tr><td>&nbsp;</td></tr>
		
		<tr>
		<table width="99%"><? if($action=="ubah") echo "<input type=\"hidden\" name=\"action\" value=\"ubah\">";?>
			<td align="center" width="50%"><input type="submit" name="simpan" value="Kirim"></td>
			<td align="left" width="50%"><input type="reset" name="cancel" value="Kosongkan"></td>
		</table>
		</tr>
		
	  </font>
	</tbody>
	</table>
</form>
</body>
<? include "../footer.html";?>

input_jenis.php
<? include "../conect/conect.php";
   include "../conect/cekLogin.php"; 
   include "header.html";
   
   $action 		= $_REQUEST['action'];
   if ($action=='ubah'){
		$id		= $_GET['id'];
		$query 	= "SELECT * FROM jenis WHERE kd_jenis='$id'";
		$hasil 	= @mysql_query($query);
		while($data=mysql_fetch_array($hasil)) {
			$kd_jenis 	= $data['kd_jenis'];
			$nama_jenis = $data['nama_jenis'];
  		}
   }
?>
<body text="#0080C0">
<form action="proses_jenis.php" method="post">
	<table width="99%">
	<tbody>
		<tr>
		<table align="center">
			<tr><td width="99%"><h2>INPUT DATA JENIS BARANG</h2></td></tr>
		</table>
		</tr>
		
  <font size="+1">
		
		<tr><td>&nbsp;</td></tr>
		
		<tr>
		<table>
			<tr>
			<td width="20%">Kode Jenis</td><td width="40%"><input type="text" name="kd_jenis" size="10" readonly="true" value="<?
				if (!$action=='ubah'){
					$query 		= "SELECT max(kd_jenis) FROM jenis";
					$hasil 		= mysql_query($query);
					$data 		= mysql_fetch_row($hasil);
					$ada 		= mysql_num_rows($hasil);
					$kodeAkhir 	= $data[0] + 1;
					echo substr("0000",0,4-strlen($kodeAkhir)).$kodeAkhir;
				}
				if ($action=='ubah')
					echo substr("0000",0,4-strlen($kd_jenis)).$kd_jenis;
			?>"></td>
			</tr>
			<tr>
			<td>Nama Jenis</td><td><input type="text" name="nama_jenis" size="35" maxlength="25" value="<? echo $nama_jenis?>"></td>
			</tr>
		</table>
		</tr>
		
		<tr><td>&nbsp;</td></tr>
		
		<tr>
		<table width="99%"><? if($action=="ubah") echo "<input type=\"hidden\" name=\"action\" value=\"ubah\">";?>
			<td align="center" width="50%"><input type="submit" name="simpan" value="Kirim"></td>
			<td align="left" width="50%"><input type="reset" name="cancel" value="Kosongkan"></td>
		</table>
		</tr>	
  </font>
	</tbody>
	</table>
</form>
<? include "../footer.html";?>
</body>
</html>

input_jual.php
<? 	include "../conect/conect.php";
  	include "../conect/cekLogin.php";
	include "header.html";
	include "../rupiah.php";
   
  	$action 	= $_REQUEST['action'];
	$kd_jual	= $_GET['kd_jual'];
	$kd_plg		= $_GET['kd_plg'];
	$nama_plg	= $_GET['nama_plg'];
	
	if(!action=='tambah'||!$action=='ubah'){
   		mysql_query("delete from detail_jual_temp");
   }
?>

<SCRIPT LANGUAGE = "JavaScript">
<!--
function numbersonly()
{
	if (event.keyCode<48||event.keyCode>57)
	{
	return false;
	} else
	{
	return true;
	}			
}	
//-->
</SCRIPT>
<style type="text/css">
<!--
body,td,th {
	color: #0080C0;
}
.style9 {color: #FFFFFF; font-size: 12px; }
-->
</style>
<body>
<center><h2>TRANSAKSI PENJUALAN</h2></center>
<form method="get">
<table width="70%" border="0" cellpadding="0" cellspacing="0">
  	<tr><td width="40%" height="23" align="left">Nama Pelanggan</td>
    	<td width="50%"> 
	  		<? 
			if($action=='tambah')
				echo "<input type='text' readonly='true' value='$nama_plg' name='kd_plg'><input type='hidden' name='kd_plg' value='$kd_plg'>";
			if(!$action=='ubah'){
				echo "<select name='kd_plg'>";
				$query = "SELECT * FROM pelanggan ORDER BY kd_plg";
				$hasil = mysql_query($query);
				echo "<option value='' selected>-- Nama Pelanggan --</option>";
				while ($data2 = mysql_fetch_array($hasil)){
					if($kd_plg==$data2[kd_plg])
						$sel = 'selected';
					else
						$sel = '';
					echo "<option value=\"$data2[kd_plg]\" $sel>$data2[kd_plg] - $data2[nama_plg] </option>";
				}
				echo "</select>";
			}
		?>
	  </td>
  	</tr>
	<tr><td width="50%">Masukkan Jenis Barang</td>
		<td><select name="kd_jenis">
	  			<option value="" selected>-- Jenis Barang --</option>
				<?
					$query = "SELECT * FROM jenis ORDER BY kd_jenis";
					$hasil = mysql_query($query);
					while ($data2 = mysql_fetch_array($hasil)){
						echo "<option value=\"$data2[kd_jenis]\">$data2[kd_jenis] - $data2[nama_jenis] </option>";
					}
				?>
	  		</select>
	   </td>
		<td width="10%" align="center"><input name="Cari" type="submit" id="Cari" value="Cari"></td>
	</tr>
</table>
</form>
<table width="99%" border="0" align="center">
	<tr bgcolor="#0080C0" align="center">
		<td width="40"><span class="style9">No</span></td>
       	<td width="133"><span class="style9">Kode Barang</span></td>
        <td width="384"><span class="style9">Nama Barang</span></td>
		<td width="213"><span class="style9">Harga Beli</span></td>
    	<td width="256"><span class="style9">Harga Jual</span></td>
        <td width="167"><span class="style9">Jumlah</span></td>
	</tr>
		<?
		$query = "select * from barang";
		$kd_jenis = $_GET['kd_jenis'];
   		if(!$kd_jenis=='')
   			$query = $query." where kd_jenis='$kd_jenis'";
		$query = $query." order by kd_barang";
		$hasil=mysql_query($query);
		$no=0;
		while ($baris=mysql_fetch_array($hasil)){
			$no++;
		?>	<form name='formtransaksi' method='post' action='proses_jual.php'>
<tr bgcolor="#FFFFFF">
			<td align='center'><? print $no; ?>&nbsp;<? if($action=='tambah') echo"<input name='kd_jual' type='hidden' value=$kd_jual>"; ?></td>	
			<td align='center'><? print $baris[kd_barang]; ?>&nbsp;<input name='kd_barang' type='hidden' value='<? print $baris[kd_barang]; ?>'></td>
			<td><? print $baris[nama_barang]; ?>&nbsp;<input name='nama_barang' type='hidden' value='<? print $baris[nama_barang];?>'></td>
			<td align="right"><? print rupiah($baris[harga_barang]); ?></td>
			<td align='right'>Rp. <input name='harga_jual' type='text' value='<? print $harga_jual; ?>' size="15" maxlength="9"></td>
			<td><center><input type='text' size='3' maxlength='3' name='jumlah' value='1' onKeyPress='return numbersonly()'>&nbsp;
			<input type="hidden" name="kd_plg" value="<? echo $kd_plg?>"><input type="submit" name='submit' value='Tambah'></center></td>
		</tr>
		</form>
	<? } ?>
</table>
<? include "../footer.html"; ?>
</body>
</html>

input_pelanggan.php
<? include "../conect/conect.php";
   include "../conect/cekLogin.php";
   include "header.html";
   
   $action 		= $_REQUEST['action'];
   if ($action=='ubah'){
		$id		= $_GET['id'];
		$query 	= "SELECT * FROM pelanggan WHERE kd_plg='$id'";
		$hasil 	= @mysql_query($query);
		while($data=mysql_fetch_array($hasil)) {
			$kd_plg 	= $data['kd_plg'];
			$nama_plg 	= $data['nama_plg'];
			$alamat 	= $data['alamat'];
			$kota 		= $data['kota'];
			$telp 		= $data['telp'];
  		}
   }
?>
<body text="#0080C0">
<form action="proses_pelanggan.php" method="post">
	<table width="99%">
	<tbody>
		<tr>
		<table align="center">
			<tr><td width="100%"><h2>INPUT DATA PELANGGAN</h2></td></tr>
		</table>
		</tr>
		
	  <font size="+1">
		
		<tr><td>&nbsp;</td></tr>
		
		<tr>
		<table>
			<tr>
			<td width="20%">Kode Pelanggan</td><td width="40%"><input type="text" name="kd_plg" size="10" readonly="true" value="<?
				if (!$action=='ubah'){
					$query 		= "SELECT max(kd_plg) FROM pelanggan";
					$hasil 		= mysql_query($query);
					$data 		= mysql_fetch_row($hasil);
					$ada 		= mysql_num_rows($hasil);
					$kodeAkhir 	= $data[0] + 1;
					echo substr("0000",0,4-strlen($kodeAkhir)).$kodeAkhir;
				}
				if ($action=='ubah')
					echo substr("0000",0,4-strlen($kd_plg)).$kd_plg;
			?>"></td>
			</tr>
			<tr>
			<td>Nama Pelanggan</td><td><input type="text" name="nama_plg" size="35" maxlength="25" value="<? echo $nama_plg?>"></td>
			</tr>
			<tr><td>Alamat Pelanggan</td><td><input type="text" name="alamat" size="45" maxlength="40" value="<? echo $alamat;?>"></td>
			</tr>
			<tr><td>Kota Pelanggan</td><td><input type="text" name="kota" size="20" maxlength="25" value="<? echo $kota;?>"></td></tr>
			<tr><td>No Telp.</td><td><input type="text" name="telp" size="20" maxlength="12" value="<? echo $telp;?>"></td></tr>
		</table>
		</tr>
		
		<tr><td>&nbsp;</td></tr>
		
		<tr>
		<table width="99%"><? if($action=="ubah") echo "<input type=\"hidden\" name=\"action\" value=\"ubah\">";?>
			<td align="center" width="50%"><input type="submit" name="simpan" value="Kirim"></td>
			<td align="left" width="50%"><input type="reset" name="cancel" value="Kosongkan"></td>
		</table>
		</tr>
		
	  </font>
	</tbody>
	</table>
</form>
<? include "../footer.html";?>
</body>

input_taksir.php
<? include "../conect/conect.php";
   include "../conect/cekLogin.php";
   include "header.html";
   
   $action 		= $_REQUEST['action'];
   if ($action=='ubah'){
		$id		= $_GET['id'];
		$query 	= "SELECT * FROM taksir WHERE kd_taksir='$id'";
		$hasil 	= @mysql_query($query);
		while($data=mysql_fetch_array($hasil)) {
			$kd_taksir 		= $data['kd_taksir'];
			$jangka_waktu 	= $data['jangka_waktu'];
			$persen_taksir 	= $data['persen_taksir'];
  		}
   }
?>
<body text="#0080C0">
<form action="proses_taksir.php" method="post">
	<table width="99%">
	<tbody>
		<tr>
		<table align="center">
			<tr><td width="100%"><h2>INPUT DATA TAKSIRAN</h2></td></tr>
		</table>
		</tr>
		
	  <font size="+1">
		
		<tr><td>&nbsp;</td></tr>
		
		<tr>
		<table>
			<tr>
			<td width="20%">Kode Taksir</td><td width="40%"><input type="text" name="kd_taksir" size="10" readonly="true" value="<?
				if (!$action=='ubah'){
					$query 		= "SELECT max(kd_taksir) FROM taksir";
					$hasil 		= mysql_query($query);
					$data 		= mysql_fetch_row($hasil);
					$ada 		= mysql_num_rows($hasil);
					$kodeAkhir 	= $data[0] + 1;
					echo substr("0000",0,4-strlen($kodeAkhir)).$kodeAkhir;
				}
				if ($action=='ubah')
					echo substr("0000",0,4-strlen($kd_taksir)).$kd_taksir;
			?>"></td>
			</tr>
			<tr>
			<td>Jangka Waktu</td><td><input type="text" name="jangka_waktu" size="15" maxlength="10" value="<? echo $jangka_waktu?>"></td>
			</tr>
			<tr>
			<td>Persen Taksir</td><td><input type="text" name="persen_taksir" size="5" maxlength="3" value="<? echo $persen_taksir?>"> %</td>
			</tr>
		</table>
		</tr>
		
		<tr><td>&nbsp;</td></tr>
		
		<tr>
		<table width="99%"><? if($action=="ubah") echo "<input type=\"hidden\" name=\"action\" value=\"ubah\">";?>
			<td align="center" width="50%"><input type="submit" name="simpan" value="Kirim"></td>
			<td align="left" width="50%"><input type="reset" name="cancel" value="Kosongkan"></td>
		</table>
		</tr>
		
	  </font>
	</tbody>
	</table>
</form>
</body>
<? include "../footer.html";?>

kolom_detail_jual.php
<? 	
	include "header.html";
	include "../conect/conect.php";
	include "../conect/cekLogin.php";
	include "../rupiah.php";
	
	//$kd_jual 		= $_GET['kd_jual'];
	//$tgl 			= $_GET['tgl'];
	
	$query = "SELECT d.*,b.* FROM detail_jual_temp d,barang b where d.kd_barang=b.kd_barang and d.kd_jual=$kd_jual";
	if($hasil = mysql_query($query))
		$jumlahHasil = mysql_num_rows($hasil);
	if($jumlahHasil < 1)
		echo("<br><center><h1>Data Penjualan Belum Ada</h1></center><BR>"); 
	else { 
		$queryplg 	= "SELECT * FROM pelanggan where kd_plg='$kd_plg'";
		$gatau		= mysql_query($queryplg);
		$plg		= mysql_fetch_array($gatau);
?>
		<br><h2><center>NOTA PENJUALAN</center></h2><br>
		<table><tr><td>Kode Jual</td><td> : <? echo substr("0000",0,4-strlen($kd_jual)).$kd_jual;?></td></tr>
		<tr><td>Nama Pelanggan</td><td> : <? echo $plg[nama_plg]?></td></tr>
		<tr><td>Tgl transaksi</td><td> : <? echo $tanggal=date("d-m-Y");?></td></tr></table><br>
		<table border="1" width="99%" bgcolor="#FFFFFF">
			<tr bgcolor="#E6F2FB" style="color:#000000 " align="center">
				<th width="5%">ID</th>
				<th width="25%">Nama Barang</th>
				<th width="10%">Jumlah</th>
				<th width="17%">Harga</th>
				<th width="17%">Sub Total</th>
				<th width="25%">Action</th>
			</tr>
<?
			//Membuat Kolom
			$i=1;
			while($data=mysql_fetch_array($hasil)) {
				$total+=$subTotal = $data[harga_jual] *$data[jumlah];
				$a=rupiah($data[harga_jual]);
				$b=rupiah($subTotal);
				echo "<tr style=\"color:#000000 \">";
				echo "<td align='center'>$data[id]</td>";
				echo "<td>$data[nama_barang]</td>";
				echo "<td align=centr>$data[jumlah]</td>";
				echo "<td align=right>Rp. $a</td>";
				echo "<td align=right>Rp. $b</td>";
				echo "<td><form action='proses_jual.php?action=ubah'>
					  <input type=hidden name=id value=$data[id]><input type=hidden name=kd_jual value=$data[kd_jual]>
					  <input type='text' size='2' maxlength='3' name='jml' value='$data[jumlah]'><input type=hidden name=action value=ubah>
					  <input type=submit name=ubah value=Ubah></form><a href=\"proses_jual.php?action=hapus&id=$data[id]&kd_jual=$data[kd_jual]\">Hapus</a></td>";
				echo "</tr>";
				$i++;
			}
			$c=rupiah($total);
			echo "<tr bgColor='ffffcc'>";
			echo "<td align='left' colspan='4'>Total Harga</td>";
			echo "<td align=right>$c</td>";
			echo "<td> </td>";
			echo "</tr>";

		print("</table></font>");
		print("<table>");
		print("<tr><td align='center'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='input_jual.php?action=tambah&kd_jual=$kd_jual&tgl=$tgl&kd_plg=$plg[kd_plg]&nama_plg=$plg[nama_plg]'>[ Tambah ]</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='proses_jual.php?action=simpan&kd_jual=$kd_jual'>[ Simpan ]</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='proses_jual.php?action=batal&kd_jual=$kd_jual'>[ Batal ]</a></td><tr>");
		print("</table>");
	}
?>
<br><br>
<? include "../footer.html";?>

logout.php
<?
	session_start();
	session_unregister("username");
	session_unregister("password");
	session_destroy();
	header("location:../");
?>

output_analisa.php
<? 	include "../conect/conect.php";
   	include "../conect/cekLogin.php";
	include "../rupiah.php";
	include "header.html";
	
	$tahun 		= date("Y");
	$bulan 		= date("n");
	$tanggal	= date("j");
	$sekarang	= "$tahun-$bulan-$tanggal";
	$jumlahhari	= array("0","31","28","31","30","31","30","31","31","30","31","30","31");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>.:: TOKO TENGAH SLEMAN</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
</head>
<body>
<center><H2>ANALISA UMUR PIUTANG</H2>
<H3>(dalam rupiah)</H3></center>
<table width="99%" border="0">
			<tr bgcolor="#0080C0" align="center" style="color:#FFFFFF "><td width="5%" rowspan="2">No</td>
       			<td width="20%" rowspan="2">Nama Debitur</td>
        		<td width="15%" rowspan="2">Jumlah piutang</td>
				<td width="45%" colspan="4">Jumlah hari Lewat Waktu</td>
        	</tr>
			<tr style="color:#FFFFFF ">
			<?
				$sql = "select * from taksir order by kd_taksir";
				$taksir=@mysql_query($sql);
				while ($baristaksir=@mysql_fetch_array($taksir)){
			?>
				<td width="15%" align="center" bgcolor="#0080C0"><? echo $baristaksir[jangka_waktu]?></td>
			<? }?>
       	  </tr>
			<?
				$hasil=@mysql_query("select * from pelanggan order by kd_plg");
				$no=1;$totalpiutang=0;$totalbelumjt=0;$totalhari30=0;$totalhari60=0;$totallebih60=0;
				while ($baris=@mysql_fetch_array($hasil)){
					$tahun 		= date("Y");
					$bulan 		= date("n");
					$tanggal	= date("j");
					$baris1=@mysql_fetch_array(@mysql_query("select sum(saldo) as saldo from jual where kd_plg='$baris[kd_plg]'"));
					$tanggal 	= $tanggal - 30;
					if($tanggal < 1){
						while($tanggal <1){
							$bulan 		= intval($bulan) - 1;
							$tanggal	= $tanggal + intval($jumlahhari[$bulan]);
							$tahun		= $tahun;
							while($bulan < 1){
								$tahun = $tahun - 1;
								$bulan = 12;
							} // end o while
						} //end of while
					} else{
						$tanggal 	= $tanggal - $nilai;
						$bulan		= $bulan;
						$tahun		= $tahun;
					}
					//MELIHAT TOTAL PIUTANG BELUM JATUH TEMPO
					$keluaran = "$tahun-$bulan-$tanggal";
					$query2 = "select sum(saldo) as total from jual where tgl_jual>='$keluaran' and tgl_jual <='$sekarang' and kd_plg='$baris[kd_plg]'";
					$keluaransebelumnya =$keluaran;
					$hasil2 = @mysql_query($query2);
					if ($baris2=@mysql_fetch_array($hasil2)){
						if($baris2[total]>0)
							$total30	= $baris2[total];
						else
							$total30	= 0;
					}
					$tahun 		= date("Y");
					$bulan 		= date("n");
					$tanggal	= date("j");
					$tanggal 	= $tanggal - 60;
					if($tanggal < 1){
						while($tanggal <1){
							$bulan 		= intval($bulan) - 1;
							$tanggal	= $tanggal + intval($jumlahhari[$bulan]);
							$tahun		= $tahun;
							while($bulan < 1){
								$tahun = $tahun - 1;
								$bulan = 12;
							} // end o while
						} //end of while
					} else{
						$tanggal 	= $tanggal - $nilai;
						$bulan		= $bulan;
						$tahun		= $tahun;
					}
					//MELIHAT TOTAL PIUTANG JATUH TEMPO 1 - 30
					$keluaran = "$tahun-$bulan-$tanggal";
					$query3 = "select sum(saldo) as total from jual where tgl_jual>='$keluaran' and tgl_jual <='$keluaransebelumnya' and kd_plg='$baris[kd_plg]'";
					$keluaransebelumnya =$keluaran;//echo $query3;
					$hasil3 = @mysql_query($query3);
					if ($baris3=@mysql_fetch_array($hasil3)){
						if($baris3[total]>0)
							$total60	= $baris3[total];
						else
							$total60	= 0;
					}
					$tahun 		= date("Y");
					$bulan 		= date("n");
					$tanggal	= date("j");
					$tanggal 	= $tanggal - 90;
					if($tanggal < 1){
						while($tanggal <1){
							$bulan 		= intval($bulan) - 1;
							$tanggal	= $tanggal + intval($jumlahhari[$bulan]);
							$tahun		= $tahun;
							while($bulan < 1){
								$tahun = $tahun - 1;
								$bulan = 12;
							} // end o while
						} //end of while
					} else{
						$tanggal 	= $tanggal - $nilai;
						$bulan		= $bulan;
						$tahun		= $tahun;
					}
					//MELIHAT TOTAL PIUTANG JATUH TEMPO 31 - 60
					$keluaran = "$tahun-$bulan-$tanggal";
					$query4 = "select sum(saldo) as total from jual where tgl_jual>='$keluaran' and tgl_jual <='$keluaransebelumnya' and kd_plg='$baris[kd_plg]'";
					$hasil4 = @mysql_query($query4);//echo $query4;
					if ($baris4=@mysql_fetch_array($hasil4)){
						if($baris4[total]>0)
							$total90	= $baris4[total];
						else
							$total90	= 0;
					}
					if($baris1[saldo]>0)
						$piutang = $baris1[saldo];
					else
						$piutang = 0;
					$totallebih90 = $piutang-($total30+$total60+$total90);
					$totalpiutang 	+= $piutang ;
					$totalbelumjt 	+= $total30;
					$totalhari30 	+= $total60;
					$totalhari60 	+= $total90;
					//MELIHAT TOTAL PIUTANG JATUH TEMPO > 60
					$totallebih60 	+= $totallebih90;
					if($totallebih60<=0)
						$totallebih60=0;
					$biaya = array("$totalbelumjt","$totalhari30","$totalhari60","$totallebih60");
			?>	
			<tr bgcolor="#FFFFFF">
			<td align='center'><? print "$no"; ?></td>
			<td align='center'><? print "$baris[nama_plg]"; ?></td>	
			<td align='right'><? print rupiah($piutang ); ?></td>
			<td align="right"><? print rupiah($total30); ?></td>
			<td align="right"><? print rupiah($total60); ?></td>
			<td align="right"><? print rupiah($total90); ?></td>
			<td align="right"><? print rupiah($totallebih90); ?></td>
			</tr><? $no++; }?>
			<tr bgcolor="#FFFFFF">
			<td colspan="2">Jumlah Piutang</td>
			<td align='right'><? print rupiah($totalpiutang); ?></td>
			<td align='right'><? print rupiah($totalbelumjt); ?></td>
			<td align='right'><? print rupiah($totalhari30); ?></td>
			<td align='right'><? print rupiah($totalhari60); ?></td>
			<td align='right'><? print rupiah($totallebih60); ?></td>
			</tr>
			<tr bgcolor="#FFFFFF">
			<td colspan="3">% Kerugian Piutang</td>
			<? 
				$taksir=@mysql_query($sql);
				while ($baristaksir=@mysql_fetch_array($taksir)){
			?>
			<td align='center'><? echo $baristaksir[persen_taksir]?> %</td>
			<? }?>
			</tr>
			<tr bgcolor="#FFFFFF">
			<td colspan="3">Taks kerugian Piutang</td>
			<? 
				$taksir=@mysql_query($sql);
				$i=0;
				while ($baristaksir=@mysql_fetch_array($taksir)){
					$taks =(($baristaksir[persen_taksir])/100) * ($biaya[$i]);
					$tottaks += $taks;
					$total += $tottaks;
			?>
			<td align='right'>Rp. <? print rupiah(intval($taks)); ?></td>
			<? $i++; }?>
			</tr>
			<tr  bgcolor="#FFFFFF"><td align='right' colspan="3">Rp. <? print rupiah(intval($tottaks)); ?></td><td colspan="4">&nbsp;</td></tr>
		</table>
<? include "../footer.html";?>
</body>
</html>

output_angsuran.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";
include "../rupiah.php";
include "header.html";

$kd_plg		= $_GET['kd_plg'];
?>
<form action="output_angsuran.php" method="get">
<table width="70%" border="0" cellpadding="0" cellspacing="0">
	<tr><td width="50%">Nama Pelanggan</td>
		<td>
		<? 
			if($action=='tambah')
				echo "<input type='text' readonly='true' value='$nama_plg' name='kd_plg'><input type='hidden' name='kd_plg' value='$kd_plg'>";
			if(!$action=='ubah'){
				echo "<select name='kd_plg'>";
				$query = "SELECT * FROM pelanggan ORDER BY kd_plg";
				$hasil = mysql_query($query);
				echo "<option value='' selected>-- Nama Pelanggan --</option>";
				while ($data2 = mysql_fetch_array($hasil)){
					if($kd_plg==$data2[kd_plg])
						$sel = 'selected';
					else
						$sel = '';
					echo "<option value=\"$data2[kd_plg]\" $sel>$data2[kd_plg] - $data2[nama_plg] </option>";
				}
				echo "</select>";
			}
		?>
		<td width="10%" align="center"><input name="Cari" type="submit" id="Cari" value="Cari"></td>
	</tr>
</table>
</form>
<?
	$query 			= "SELECT p.*,j.*,a.* FROM pelanggan p, jual j, angsuran a where p.kd_plg=j.kd_plg and j.kd_jual=a.kd_jual";
	if(!$kd_plg=="")
		$query 		= $query." and j.kd_plg=$kd_plg";
	$query 			= $query." ORDER BY a.kd_angsuran";
	$hasil 			= mysql_query($query);
	$jumlahHasil 	= mysql_num_rows($hasil);
	if($jumlahHasil < 1)
		echo("<br><center><h1>Data Angsuran Tidak Ada Pada Database</h1></center><BR>"); 
	else { 
?>
	<div align="center">
	  <H2>DAFTAR ANGSURAN </H2>
	</div>
	<br><br>
	<table border="0" width="99%">
		<tr bgcolor="#0080C0" style="color:#000000 " align="center">
			<td width="12%"><font color="#FFFFFF">Tgl Angsuran</font></td>
			<td width="20%"><font color="#FFFFFF">Nama Pelanggan</font></td>
			<td width="15%"><font color="#FFFFFF">Jumlah Angsuran</font></td>
	  	</tr>
<?
		//Membuat Kolom
		$i=1;
		while($data=mysql_fetch_array($hasil)) {
			if($i % 2==0)
				$bg="#999999";
			else
				$bg="#009900";
			$a=rupiah($data[jumlah_angsuran]);
			$tgl = explode("-",$data[tgl_angsuran]);
			echo "<tr bgcolor=\"#FFFFFF\">";
			echo "<td align='center'>$tgl[2]-$tgl[1]-$tgl[0]</td>";
			echo "<td>$data[nama_plg]</td>";
			echo "<td align=right>Rp. $a</td>";
			echo "</tr>";
			$total += $data[jumlah_angsuran];
			$i++;
		}
?>
		<tr bgcolor="#FFFFFF"><td colspan="2">Total Angsuran</td><td align="right">Rp. <? echo rupiah($total);?></td></tr>
	</table>
<?
}
include "../footer.html";?>

output_barang.inc.php
<?
$query 			= "SELECT b.*,j.* FROM barang b, jenis j where b.kd_jenis=j.kd_jenis ORDER BY kd_barang";
$hasil 			= mysql_query($query);
$jumlahHasil 	= mysql_num_rows($hasil);
if($jumlahHasil < 1)
	echo("<br><center><h1>Data Barang Tidak Ada Pada Database</h1></center><BR>"); 
else { 
?>
<link href="../style.css" rel="stylesheet" type="text/css">

	<style type="text/css">
<!--
.style1 {color: #0080C0}
-->
    </style>
<div align="center" class="style1"><h2>LAPORAN DATA BARANG</h2></div><br>
	<table border="0" width="99%">
		<tr bgcolor="#0080C0" style="color:#000000 " align="center">
			<td width="12%"><font color="#FFFFFF">Kode Barang</font></td>
			<td width="20%"><font color="#FFFFFF">Nama Jenis</font></td>
			<td width="35%"><font color="#FFFFFF">Nama Barang</font></td>
			<td width="15%"><font color="#FFFFFF">Harga Beli</font></td>
			<td width="18%"><font color="#FFFFFF">Stock</font></td>
		</tr>
<?
		//Membuat Kolom
		$i=1;
		while($data=mysql_fetch_array($hasil)) {
			$a=rupiah($data[harga_barang]);
			$kd_barang=substr("000",0,3-strlen($data[kd_barang])).$data[kd_barang];
			echo "<tr bgcolor=\"#FFFFFF\">";
			echo "<td align='center'>$kd_barang</td>";
			echo "<td>$data[nama_jenis]</td>";
			echo "<td>$data[nama_barang]</td>";
			echo "<td align=right>Rp. $a</td>";
			echo "<td>$data[stock] $data[satuan] </td>";
			echo "</tr>";
			$i++;
		}
?>
	</table>
<?
}
?>
<br><br>

output_buku_besar.php
<? 	include "../conect/conect.php";
   	include "../conect/cekLogin.php";
	include "../rupiah.php";
	include "header.html";
	
	$bln = array("0","Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
	$thn = date("Y");
	$jml = $thn - 10;
   
   	$tampil		= $_GET['tampil'];
   	$bulan		= $_GET['bulan'];
	$tahun		= $_GET['tahun'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
<title>.:: TOKO TENGAH SLEMAN</title>
</head>
<body>
<center><h2>BUKU BESAR PIUTANG DAGANG</h2></center>
		<form action="output_buku_besar.php" method="get">
		<table width="99%">
			<!--td width="159" align="center"><select name="bulan"><option value='' selected>-- Bulan --</option>
			</?
				for ($n=1; $n<=12; $n++)
					echo "<option value=\"$n\">$bln[$n]</option>";
			?>
					</select></td--><td width="139" align="center">
				<select name="tahun"><option value='' selected>-- Tahun --</option>
			<?
				for ($a=$thn; $a>=$jml; $a--)
					echo "<option value=$a>$a</option>";
			?>
				</select>
			</td><td></td><td align="center"><input type="submit" name="tampil" value="Tampilkan"></td></tr>
  		</table>
		</form>
		<table width="99%" border="0">
			<tr bgcolor="#0080C0" style="color:#FFFFFF " align="center"><td width="25%" colspan="2">Tanggal</td>
        		<td width="25%">Debet</td>
          		<td width="25%">Kredit</td>
				<td width="25%">Saldo</td>
        	</tr>
			<?
			$query = "select * from jual";
			if($tampil){
				/*if(!empty($bulan)||!empty($tahun)){
					$query = $query." where";
					if(!empty($bulan))
						$query = $query." tgl_jual>='$tahun-$bulan-1'";
					if(!empty($tahun))
						$query = $query." tgl_jual<='$tahun-$bulan-31'";
					if(!empty($bulan)&&!empty($tahun))
						$query = $query."tgl_jual>='$tahun-$bulan-1' and tgl_jual<='$tahun-$bulan-31'";
				}*/
				if(!empty($tahun)){
					$query = $query." where  tgl_jual>='$tahun-1-1' and  tgl_jual<='$tahun-12-31'";
				}
			}
				$query = $query." order by tgl_jual";
				$hasil=@mysql_query($query);
				$bln = array("","Jan", "Feb", "Mar", "Apr", "Mei", "Juni", "Juli", "Agt", "Sep", "Okt", "Nov", "Des");
				while ($baris=@mysql_fetch_array($hasil)){
					$kredit=0;$debet=0;
					$tanggal 	= explode("-", $baris[tgl_jual]);
					$hasil3 	= @mysql_fetch_array(@mysql_query("select sum(jumlah_angsuran) as nilai_angsuran from angsuran where kd_jual='$baris[kd_jual]'"));
					$hasil4 	= @mysql_fetch_array(@mysql_query("select sum(harga_jual*jumlah) as total from detail_jual where kd_jual='$baris[kd_jual]'"));
						
					$kredit		+= $hasil3[nilai_angsuran];
					$debet		+= $hasil4[total];
					$saldo		+= $debet-$kredit;
					for($i=1;$i<13;$i++)
						$tgl = $bln[intval($tanggal[1])];
			?>	
			<tr bgcolor="#FFFFFF">
			<td align='center'><? print "$tanggal[0] $tgl"; ?></td>
			<td align='center'><? print "$tanggal[2]"; ?></td>	
			<td align='right'>Rp. <? print rupiah($debet); ?></td>
			<td align="right">Rp. <? print rupiah($kredit); ?></td>
			<td align="right">Rp. <? print rupiah($saldo); ?></td>
			</tr>
			<? } ?>
		</table>
<? include "../footer.html";?>
</body>
</html>

output_buku_pembantu.php
<? 	include "../conect/conect.php";
   	include "../conect/cekLogin.php";
	include "../rupiah.php";
	include "header.html";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>.:: TOKO TENGAH SLEMAN</title>
<link rel="stylesheet" href="../style.css" type="text/css" media="screen" />
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<body>
<center><h2>BUKU PEMBANTU PIUTANG</h2></center>
			<?
				$hasil=@mysql_query("select * from pelanggan order by kd_plg");
				while ($baris=@mysql_fetch_array($hasil)){
					$query2 	= "select * from jual where kd_plg='$baris[kd_plg]' order by kd_jual";
					$hasil2 	= @mysql_query($query2);
					$bln 		= array("","Jan", "Feb", "Mar", "Apr", "Mei", "Juni", "Juli", "Agt", "Sep", "Okt", "Nov", "Des");
					if(mysql_num_rows($hasil2)>0){
						print("<center><font size='+2'>$baris[nama_plg]</font></center>");
						
					while ($baris2=@mysql_fetch_array($hasil2)){
						$kredit		= 0;$debet		= 0;$saldo		= 0;
						$tanggal 	= explode("-", $baris2[tgl_jual]);
						$hasil3 	= @mysql_fetch_array(@mysql_query("select sum(jumlah_angsuran) as nilai_angsuran from angsuran where kd_jual='$baris2[kd_jual]'"));
						$hasil4 	= @mysql_fetch_array(@mysql_query("select sum(harga_jual*jumlah) as total from detail_jual where kd_jual='$baris2[kd_jual]'"));
						
						$kredit		+= $hasil3[nilai_angsuran];
						$debet		+= $hasil4[total];
						$saldo		+= $debet-$kredit;
						if($angsuran < 1)
							$angsuran=0;
						for($i=1;$i<13;$i++)
							$tgl = $bln[intval($tanggal[1])];
			?>
			<table width="99%" border="0">
			<tr bgcolor="#0080C0" style="color:#FFFFFF " align="center">
				<td width="25%" colspan="2">Tanggal</td>
        		<td width="25%">Debet</td>
				<td width="25%">Kredit</td>
          		<td width="25%">Saldo</td>
        	</tr>
			<tr bgcolor="#FFFFFF">
				<td align='center'><? print "$tanggal[0]<br>$tgl"; ?></td>
				<td align='center'><? print "$tanggal[2]"; ?></td>	
				<td align='right'>Rp. <? print rupiah($debet); ?></td>
				<td align="right">Rp. <? print rupiah($kredit); ?></td>
				<td align="right">Rp. <? print rupiah($saldo); ?></td>
			</tr></table><br>
			<? }}}?>
<? include "../footer.html"; ?>
</body>
</html>

output_ckp.php
<? 	include "../conect/conect.php";
   	include "../conect/cekLogin.php";
	include "../rupiah.php";
	include "header.html";
	
	$tahun 		= date("Y");
	$bulan 		= date("n");
	$tanggal	= date("j");
	$sekarang	= "$tahun-$bulan-$tanggal";
	$jumlahhari	= array("0","31","28","31","30","31","30","31","31","30","31","30","31");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
<title>.:: TOKO TENGAH SLEMAN</title>
</head>
<body>
<center><H2>BUKU BESAR CKP</H2></center>
		<table width="99%" border="0" align="center">
			<tr bgcolor="#0080C0" style="color:#FFFFFF " align="center"><td width="25%" colspan="2">Tanggal</td>
			<td width="25%">Keterangan</td>
				<td width="25%">Saldo</td>
        	</tr>
			<?
				$hasil=@mysql_query("select * from pelanggan order by kd_plg");
				$no=1;$totalpiutang=0;$totalbelumjt=0;$totalhari30=0;$totalhari60=0;$totallebih60=0;
				while ($baris=@mysql_fetch_array($hasil)){
					$tahun 		= date("Y");
					$bulan 		= date("n");
					$tanggal	= date("j");
					$baris1=@mysql_fetch_array(@mysql_query("select sum(saldo) as saldo from jual where kd_plg='$baris[kd_plg]'"));
					$tanggal 	= $tanggal - 30;
					if($tanggal < 1){
						while($tanggal <1){
							$bulan 		= intval($bulan) - 1;
							$tanggal	= $tanggal + intval($jumlahhari[$bulan]);
							$tahun		= $tahun;
							while($bulan < 1){
								$tahun = $tahun - 1;
								$bulan = 12;
							} // end o while
						} //end of while
					} else{
						$tanggal 	= $tanggal - $nilai;
						$bulan		= $bulan;
						$tahun		= $tahun;
					}
					//MELIHAT TOTAL PIUTANG BELUM JATUH TEMPO
					$keluaran = "$tahun-$bulan-$tanggal";
					$query2 = "select sum(saldo) as total from jual where tgl_jual>='$keluaran' and tgl_jual <='$sekarang' and kd_plg='$baris[kd_plg]'";
					$keluaransebelumnya =$keluaran;
					$hasil2 = @mysql_query($query2);
					if ($baris2=@mysql_fetch_array($hasil2)){
						if($baris2[total]>0)
							$total30	= $baris2[total];
						else
							$total30	= 0;
					}
					$tahun 		= date("Y");
					$bulan 		= date("n");
					$tanggal	= date("j");
					$tanggal 	= $tanggal - 60;
					if($tanggal < 1){
						while($tanggal <1){
							$bulan 		= intval($bulan) - 1;
							$tanggal	= $tanggal + intval($jumlahhari[$bulan]);
							$tahun		= $tahun;
							while($bulan < 1){
								$tahun = $tahun - 1;
								$bulan = 12;
							} // end o while
						} //end of while
					} else{
						$tanggal 	= $tanggal - $nilai;
						$bulan		= $bulan;
						$tahun		= $tahun;
					}
					//MELIHAT TOTAL PIUTANG JATUH TEMPO 1 - 30
					$keluaran = "$tahun-$bulan-$tanggal";
					$query3 = "select sum(saldo) as total from jual where tgl_jual>='$keluaran' and tgl_jual <='$keluaransebelumnya' and kd_plg='$baris[kd_plg]'";
					$keluaransebelumnya =$keluaran;//echo $query3;
					$hasil3 = @mysql_query($query3);
					if ($baris3=@mysql_fetch_array($hasil3)){
						if($baris3[total]>0)
							$total60	= $baris3[total];
						else
							$total60	= 0;
					}
					$tahun 		= date("Y");
					$bulan 		= date("n");
					$tanggal	= date("j");
					$tanggal 	= $tanggal - 90;
					if($tanggal < 1){
						while($tanggal <1){
							$bulan 		= intval($bulan) - 1;
							$tanggal	= $tanggal + intval($jumlahhari[$bulan]);
							$tahun		= $tahun;
							while($bulan < 1){
								$tahun = $tahun - 1;
								$bulan = 12;
							} // end o while
						} //end of while
					} else{
						$tanggal 	= $tanggal - $nilai;
						$bulan		= $bulan;
						$tahun		= $tahun;
					}
					//MELIHAT TOTAL PIUTANG JATUH TEMPO 31 - 60
					$keluaran = "$tahun-$bulan-$tanggal";
					$query4 = "select sum(saldo) as total from jual where tgl_jual>='$keluaran' and tgl_jual <='$keluaransebelumnya' and kd_plg='$baris[kd_plg]'";
					$hasil4 = @mysql_query($query4);//echo $query4;
					if ($baris4=@mysql_fetch_array($hasil4)){
						if($baris4[total]>0)
							$total90	= $baris4[total];
						else
							$total90	= 0;
					}
					if($baris1[saldo]>0)
						$piutang = $baris1[saldo];
					else
						$piutang = 0;
					$totallebih90 = $piutang-($total30+$total60+$total90);
					$totalpiutang 	+= $piutang ;
					$totalbelumjt 	+= $total30;
					$totalhari30 	+= $total60;
					$totalhari60 	+= $total90;
					//MELIHAT TOTAL PIUTANG JATUH TEMPO > 60
					$totallebih60 	+= $totallebih90;
					if($totallebih60<=0)
						$totallebih60=0;
					$biaya = array("$totalbelumjt","$totalhari30","$totalhari60","$totallebih60");
				}
			?>	
			<tr bgcolor="#FFFFFF">
			<td align="center"><? echo date("Y M");?></td>
			<td align="center"><? echo date("j");?></td>
			<td><? print "Cadangan kerugian Piutang"; ?></td>
			<? 
				$sql = "select * from taksir order by kd_taksir";
				$taksir=@mysql_query($sql);
				$i=0;
				while ($baristaksir=@mysql_fetch_array($taksir)){
					$taks =(($baristaksir[persen_taksir])/100) * ($biaya[$i]);
					$tottaks += $taks;
					$i++;
				}
			?>
			<td align='right'>Rp. <? print rupiah(intval($tottaks)); ?></td>
			</tr>
		</table>
<? include "../footer.html";?>
</body>
</html>

output_daftar_piutang.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";
include "../rupiah.php";
include "header.html";
?>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>

<div id="maincontent_container">
<div id="maincontent">
<?
$query 			= "SELECT * FROM pelanggan ORDER BY kd_plg";
$hasil 			= mysql_query($query);
$jumlahHasil 	= mysql_num_rows($hasil);
if($jumlahHasil < 1)
	echo("<br><center><h1>Data Piutang Tidak Ada Pada Database</h1></center><BR>"); 
else { 
?>
<link href="style.css" rel="stylesheet" type="text/css">

	<div align="center"><h2>DAFTAR PIUTANG</h2></div><br><br>
	<table border="0" width="99%">
		<tr bgcolor="#0080C0" style="color:#000000 " align="center">
			<td width="10%"><font color="#FFFFFF">Kode Pelanggan</font></td>
			<td width="35%"><font color="#FFFFFF">Nama Pelanggan</font></td>
			<td width="25%"><font color="#FFFFFF">Alamat</font></td>
			<td width="15%"><font color="#FFFFFF">Kota</font></td>
			<td width="15%" colspan="2"><font color="#FFFFFF">Saldo</font></td>
	  </tr>
<?
		//Membuat Kolom
		$i=1;
		while($data=mysql_fetch_array($hasil)) {
			if($hasil2 = mysql_query("select * from jual where kd_plg='$data[kd_plg]'")){
				if($data2=mysql_fetch_array($hasil2)) {
					$saldo += $data2[saldo];
				} else
					$saldo = 0;
			}
			$kd_plg=substr("0000",0,4-strlen($data[kd_plg])).$data[kd_plg];
			echo "<tr bgcolor=\"FFFFFF\">";
			echo "<td align='center'>$kd_plg</td>";
			echo "<td>$data[nama_plg]</td>";
			echo "<td>$data[alamat]</td>";
			echo "<td>$data[kota]</td>";
			echo "<td  width=\"1%\">Rp.</td>";
			echo "<td align=right>".rupiah($saldo)."</td>";
			echo "</tr>";
			$i++;
			$totalPiutang += $saldo;
		}
?>
		<tr bgcolor="#FFFFFF"><td colspan="4">Total Piutang</td><td>Rp. </td><td align="right"><? echo rupiah($totalPiutang);?></td></tr>
	</table>
<?
}
?>
<br><br>
</div>
</div>
<? include "../footer.html";?>

output_detail_jual.php
<?
include "../conect/conect.php";
include "../rupiah.php";
include "../conect/cekLogin.php";
include "header.html";

$id			= $_GET['id'];
$tanggal	= $_GET['tanggal'];

$bln = array("","Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
$tgl = explode("-", $tanggal);
$nBln= intval($tgl[1]);
$kdJual=substr("0000",0,4-strlen($id)).$id;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>.:: TOKO TENGAH SLEMAN</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
	$query = "SELECT d.*,b.*,j.*,d.jumlah*d.harga_jual as hJual FROM barang b, detail_jual d, jenis j where b.kd_barang=d.kd_barang and j.kd_jenis=b.kd_jenis and d.kd_jual=$id ORDER BY d.kd_jual";
	if($hasil = mysql_query($query))
		$jumlahHasil = mysql_num_rows($hasil);
	if($jumlahHasil < 1)
		echo("<br><center><h1>Data Penjualan Tidak Ada Pada Database</h1></center><BR>"); 
	else { 
?>
	<br><div align="center"><font color="#FFFFFF"><h2>LAPORAN DETAIL PENJUALAN</h2><BR>
			    <font size="+3"><? echo date("D d M Y")?></font></font></div><br><br>
		<table width="319">
			<tr><td width="165">Kode Jual</td><td width="142"><? echo $kdJual?></td></tr>
			<tr><td>Tanggal Jual</td><td><? echo "$tgl[2] $bln[$nBln] $tgl[0]"?></td></tr>
		</table><br>
		<table border="0" width="99%">
			<tr bgcolor="#E6F2FB" style="color:#000000 " align="center">
				<th>Nama Barang</th>
				<th>Jenis Barang</th>
				<th>Jumlah</th>
				<th>Harga Jual</th>
				<th>Sub Total</th>
			</tr>
<?
			//Membuat Kolom
			$i=1;
			while($data=mysql_fetch_array($hasil)) {
				if($i % 2==0)
					$bg="#cccccc";
				else
					$bg="#ffffff";
				$a=rupiah($data[harga_jual]);
				$b=rupiah($data[hJual]);
				$total+=$data[hJual];
				$c=rupiah($total);
				echo "<tr bgcolor=\"$bg\">";
				echo "<td>$data[nama_barang]</td>";
				echo "<td>$data[nama_jenis]</td>";
				echo "<td align='center'>$data[jumlah] $data[sat_barang]</td>";
				echo "<td align='right'>Rp. $a</td>";
				echo "<td align='right'>Rp. $b</td>";
				echo "</tr>";
				$i++;
			}
?>
			<tr bgcolor="#FFFF99"><td colspan="4">Total Penjualan</td><td align="right">Rp. <? echo $c?></td></tr>
		</table>
		<br><a href="javascript:history.go(-1)">[ kembali ]</a>
<?
		}
?> 
<br><br>
</div>
</div>
<? include "../footer.html";?>
</body>
</html>

output_jenis.inc.php
<?
$query 			= "SELECT * FROM jenis ORDER BY kd_jenis";
$hasil 			= mysql_query($query);
$jumlahHasil 	= mysql_num_rows($hasil);
if($jumlahHasil < 1)
	echo("<br><center><h1>Data Jenis Barang Tidak Ada Pada Database</h1></center><BR>"); 
else { 
?>
<link href="../style.css" rel="stylesheet" type="text/css">

	<style type="text/css">
<!--
.style1 {color: #0080C0}
-->
    </style>
<div align="center" class="style1"><h2>LAPORAN DATA JENIS</h2></div>
<br><br>
	<table border="0" width="99%">
		<tr bgcolor="#0080C0" style="color:#000000 " align="center">
			<td bgcolor="#0080C0"><font color="#FFFFFF">Kode Jenis</font></td>
			<td><font color="#FFFFFF">Nama Jenis</font></td>
		</tr>
<?
		//Membuat Kolom
		$i=1;
		while($data=mysql_fetch_array($hasil)) {
			$kdJenis=substr("00",0,2-strlen($data[kd_jenis])).$data[kd_jenis];
			echo "<tr bgcolor=\"#FFFFFF\">";
			echo "<td align='center'>$kdJenis</td>";
			echo "<td>$data[nama_jenis]</td>";
			echo "</tr>";
			$i++;
		}
?>
	</table>
<?
}
?>
<br><br>

output_jual.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";
include "header.html";
include "../rupiah.php";

$tampil		= $_GET['tampil'];
$bulan		= $_GET['bulan'];
$tahun		= $_GET['tahun'];

$tgl = explode("-", $tanggal);
$bln = array("","Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
$thn = date("Y");
$jml = $thn - 10;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>.:: TOKO TENGAH SLEMAN</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<br>
<form action="output_jual.php" method="get">
	<table width="381">
	<tr><td width="67" height="35">Dari</td>
	<td width="159"><select name="bulan"><option value='' selected>-- Bulan --</option>
<?
							for ($n=1; $n<=12; $n++)
								echo "<option value=\"$n\">$bln[$n]</option>";
?>
						</select></td><td width="139">
						<select name="tahun"><option value='' selected>-- Tahun --</option>
<?
							for ($a=$thn; $a>=$jml; $a--)
								echo "<option value=$a>$a</option>";
?>
						</select>
		</td>
		<td align="center" colspan="3"><input type="submit" name="tampil" value="Tampilkan"></td></tr>
  </table>
</form>
<?
if($tampil){
	if(!empty($bulan)&&!empty($tahun)){
		$tahunAwal 	= "$tahun-$bulan-1";
		$tahunAkhir = "$tahun-$bulan-31";
	}
}
else{
	$tahunAwal 	= date("Y")."-".date("m")."-1";
	$tahunAkhir = date("Y")."-".date("m")."-31";
}
	$query = "SELECT * FROM jual where tgl_jual>='$tahunAwal' and tgl_jual<='$tahunAkhir' ORDER BY kd_jual";
	if($hasil = mysql_query($query))
		$jumlahHasil = mysql_num_rows($hasil);
	if($jumlahHasil < 1)
		echo("<br><center><h1>Data Penjualan Tidak Ada Pada Database</h1></center><BR>"); 
	else { 
?>
	<div align="center"><h2>LAPORAN PENJUALAN
	  <h2>Bulan <? echo "$bln[$bulan] $tahun";?></h2>
	<h2><? echo date("D d M Y")?></h2></div>
		<table border="0" width="99%">
			<tr bgcolor="#0080C0" style="color:#FFFFFF " align="center">
				<td>Kode Jual</td>
				<td>Tanggal Jual</td>
				<td>Total</td>
				<td>Detail</td>
			</tr>
<?
			//Membuat Kolom
			$i=1;
			while($data=mysql_fetch_array($hasil)) {
				$jual = "SELECT jumlah*harga_jual as totalJual FROM detail_jual where kd_jual=$data[kd_jual]";
				$hasilJual = mysql_query($jual);
				$totalJual =0;
				while($dataJual=mysql_fetch_array($hasilJual)) {
					$totalJual+=$dataJual[totalJual];
				}
				$tgl = explode("-",$data[tgl_jual]);
				if($i % 2==0)
					$bg="#cccccc";
				else
					$bg="#ffffff";
				$kdJual=substr("0000",0,4-strlen($data[kd_jual])).$data[kd_jual];
				$a=rupiah($totalJual);
				$total+=$totalJual;
				$c=rupiah($total);
				echo "<tr bgcolor=\"$bg\">";
				echo "<td align='center'>$kdJual</td>";
				echo "<td align='center'>$tgl[2]-$tgl[1]-$tgl[0]</td>";
				echo "<td align='right'>Rp. $a</td>";
				echo "<td align=center><a href='output_detail_jual.php?action=detail&id=$data[kd_jual]&tanggal=$data[tgl_jual]'>Detail</a></td>";
				echo "</tr>";
				$i++;
			}
?>
			<tr bgcolor="#FFFFFF"><td colspan="2">Total Penjualan</td><td align="right">Rp. <? echo $c?></td><td>&nbsp;</td></tr>
		</table>
<?
		}
?> 
<br><br>
<? include "../footer.html";?>
</body>
</html>

output_jurnal.php
<? 	include "../conect/conect.php";
   	include "../conect/cekLogin.php";
	include "../rupiah.php";
	include "header.html";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
<title>.:: TOKO TENGAH SLEMAN</title>
</head>
<body>
<center><h2>JURNAL UMUM</h2></center>
		<table width="99%" border="0" align="center">
		  <tr bgcolor="#0080C0" style="color:#FFFFFF " align="center">
				<td width="25%" colspan="2">Tanggal</td>
        		<td width="25%">Debet</td>
				<td width="25%">Kredit</td>
          		<td width="25%">Saldo</td>
        	</tr>
			<?
				$query = "select p.*,j.*,d.*,b.* from pelanggan p, jual j, detail_jual d,barang b where p.kd_plg=j.kd_plg and j.kd_jual=d.kd_jual and d.kd_barang=b.kd_barang order by j.tgl_jual";
				$hasil=@mysql_query($query);
				$bln = array("","Jan", "Feb", "Mar", "Apr", "Mei", "Juni", "Juli", "Agt", "Sep", "Okt", "Nov", "Des");
				while ($baris=@mysql_fetch_array($hasil)){
					$tanggal 	= explode("-", $baris[tgl_jual]);
					$total		= rupiah($baris[harga_jual] * $baris[jumlah]);
					for($i=1;$i<13;$i++)
						$tgl = $bln[intval($tanggal[1])];
					//<br>(untuk mencatat penjualan <? echo $baris[nama_barang]> secara kredit ke <? echo $baris[nama_plg]>)
			?>	
			<tr bgcolor="#FFFFFF">
			<td align='center'><? print "$tanggal[0]<br>$tgl"; ?></td>
			<td align='center'><? print "$tanggal[2]"; ?></td>	
			<td align='left'>Piutang Dagang <? print $baris[nama_plg]; ?><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Penjualan
			</td>
			<td align="right">Rp. <? print $total; ?><br><center>-</center></td>
			<td align="right"><center>-</center><br>Rp. <? print $total; ?></td>
		</tr>
			
			<? } ?>
		</table>
<? include "../footer.html"; ?>
</body>
</html>

output_pelanggan.inc.php
<?
$query 			= "SELECT * FROM pelanggan ORDER BY kd_plg";
$hasil 			= mysql_query($query);
$jumlahHasil 	= mysql_num_rows($hasil);
if($jumlahHasil < 1)
	echo("<br><center><h1>Data Pelanggan Tidak Ada Pada Database</h1></center><BR>"); 
else { 
?>
<link href="../style.css" rel="stylesheet" type="text/css">

	<style type="text/css">
<!--
.style1 {color: #0080C0}
-->
    </style>
<div align="center" class="style1"><h2>LAPORAN DATA PELANGGAN</h2></div>
	<br><br>
	<table border="0" width="99%">
		<tr bgcolor="#0080C0" style="color:#000000 " align="center">
			<td width="12%"><font color="#FFFFFF">Kode Pelanggan</font></td>
			<td width="30%"><font color="#FFFFFF">Nama Pelanggan</font></td>
			<td width="23%"><font color="#FFFFFF">Alamat</font></td>
			<td width="19%"><font color="#FFFFFF">Kota</font></td>
			<td width="16%"><font color="#FFFFFF">Telp</font></td>
		</tr>
<?
		//Membuat Kolom
		$i=1;
		while($data=mysql_fetch_array($hasil)) {
			$kd_plg=substr("0000",0,4-strlen($data[kd_plg])).$data[kd_plg];
			echo "<tr bgcolor=\"#FFFFFF\">";
			echo "<td align='center'>$kd_plg</td>";
			echo "<td>$data[nama_plg]</td>";
			echo "<td>$data[alamat]</td>";
			echo "<td>$data[kota]</td>";
			echo "<td>$data[telp] </td>";
			echo "</tr>";
			$i++;
		}
?>
	</table>
<?
}
?>
<br><br>

proses_angsuran.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";

$kd_jual		= $_POST['kd_jual'];
$jumlah 		= $_POST['jumlah'];

if (trim($kd_jual)=="" || trim($jumlah)=="")
	print("<script> alert('Masih Ada Isian Yang Kosong!!');location.href='javascript:history.back()';</script>");
else {
	if (!trim($kd_jual)=="" || !trim($jumlah)==""){
		$check 		= mysql_fetch_array(mysql_query("SELECT * FROM jual where kd_jual=$kd_jual"));
		if($check[saldo] < $jumlah)
			print("<script> alert('Saldo Piutang Adalah Rp. $check[saldo] !!');location.href='javascript:history.back()';</script>");
		else{
			$tanggal	= date("Y-m-d");
			
			$data 		= mysql_fetch_row(mysql_query("SELECT max(kd_angsuran) FROM angsuran"));
			$kodeAkhir	= $data[0] + 1;
			
			$sql		= "insert into angsuran values('$kodeAkhir','$kd_jual','$tanggal','$jumlah')";
			$sql2		= "update jual set saldo=saldo-$jumlah where kd_jual=$kd_jual";
				
			$hasil1		= mysql_query($sql);
			$hasil2		= mysql_query($sql2);
			
			if ($hasil1 && $hasil2)
				print("<script> alert('Data Angsuran Telah Disimpan');location.href='input_angsuran.php?';</script>");
			else
				print("<script> alert('Data Angsuran Gagal Disimpan!!');location.href='javascript:history.back()';</script>");
		}
	}
} 
?>

proses_barang.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";

$action 		= $_REQUEST['action'];
$id				= $_GET['id'];
$kd_barang 		= $_POST['kd_barang'];
$kd_jenis 		= $_POST['kd_jenis'];
$nama_barang 	= $_POST['nama_barang'];
$harga_barang 	= $_POST['harga_barang'];
$stock 			= $_POST['stock'];
$satuan 		= $_POST['satuan'];

if (!$action=="ubah"||!$action=="hapus"){
	if (trim($kd_barang)=="" || trim($kd_jenis)=="" || trim($nama_barang)=="" || trim($harga_barang)=="" || trim($stock)=="" || trim($satuan)=="")
		print("<script> alert('Masih Ada Isian Yang Kosong !!');location.href='javascript:history.back()';</script>");
	else {
		if (!trim($kd_barang)=="" || !trim($kd_jenis)=="" || !trim($nama_barang)=="" || !trim($harga_barang)=="" || !trim($stock)=="" || !trim($satuan)==""){
			$query_check = mysql_query("SELECT * FROM barang WHERE nama_barang = '$nama_barang'");
			if(mysql_num_rows($query_check) > 0)
        		print("<script> alert('Data Barang $nama_barang Sudah Ada Pada Database!!');location.href='javascript:history.back()';</script>");
			else {
				$sql="insert into barang values('$kd_barang','$kd_jenis','$nama_barang','$harga_barang','$stock','$satuan')";
				if (mysql_query($sql))
					print("<script> alert('Data Barang $nama_barang Telah Disimpan');location.href='input_barang.php?';</script>");
				else
					print("<script> alert('Data Barang $nama_barang Gagal Disimpan!!');location.href='javascript:history.back()';</script>");
			}
		}
	}
} elseif ($action=='ubah'){
	if (trim($kd_barang)=="" || trim($kd_jenis)=="" || trim($nama_barang)=="" || trim($harga_barang)=="" || trim($stock)=="" || trim($satuan)=="")
		print("<script> alert('Masih Ada Isian Yang Kosong !!');location.href='javascript:history.back()';</script>");
	else {
		if (!trim($kd_barang)=="" || !trim($kd_jenis)=="" || !trim($nama_barang)=="" || !trim($harga_barang)=="" || !trim($stock)=="" || !trim($satuan)==""){
			$sql = "UPDATE barang SET kd_jenis='$kd_jenis', nama_barang='$nama_barang', harga_barang='$harga_barang', stock='$stock', satuan='$satuan' WHERE kd_barang='$kd_barang'";
			if (mysql_query($sql))
				print("<script> alert('Data Barang $nama_barang Telah Diupdate');location.href='daftar_barang.php?';</script>");
			else
				print("<script> alert('Data Barang $nama_barang Gagal Diupdate');location.href='javascript:history.back()';</script>");
		}
	}
} elseif($action=="hapus"){
	$sql = "DELETE FROM barang WHERE kd_barang = '$id'";
	if (mysql_query($sql))
		print("<script> alert('Data Barang $nama_barang Telah Dihapus');location.href='daftar_barang.php?';</script>");
	else
		print("<script> alert('Data Barang $nama_barang Gagal Dihapus');location.href='daftar_barang.php?';</script>");
}
?>

proses_jenis.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";

$action 		= $_REQUEST['action'];
$kd_plg			= $_POST['kd_plg'];
$kd_barang		= $_POST['kd_barang'];
$harga_jual 	= $_POST['harga_jual'];
$jumlah 		= $_POST['jumlah'];
$id 			= $_GET['id'];
$kd_jual 		= $_GET['kd_jual'];
$jml 			= $_GET['jml'];
	
if (!$action=='ubah'||!$action=='hapus'||!$action=='simpan'||!$action=='batal'){
	if (trim($kd_barang)==""||trim($harga_jual)==""||trim($jumlah)==""||trim($kd_plg)=="")
		print("<script>alert('Isian Masih Ada Yang Kosong!!');location.href='javascript:history.back()';</script>");
	else {
		if (!trim($kd_barang)==""||!trim($harga_jual)==""||!trim($jumlah)==""||!trim($kd_plg)==""){
			$hasil = mysql_query("SELECT * FROM barang where kd_barang='$kd_barang'");
			$jum = mysql_fetch_array($hasil);
			if(intval($jum[harga_barang]) >= $harga_jual)
				print("<script>alert('Harga Jual Barang Dibawah Harga Beli !!');location.href='javascript:history.back()';</script>");
			elseif(intval($jum[stock]) < $jumlah)
				print("<script>alert('Jumlah Barang Tidak Mencukupi $jum[stock]!!');location.href='javascript:history.back()';</script>");
			else{
			
				$tanggal		= date("Y-m-d");
				
				$data 			= mysql_fetch_row(mysql_query("SELECT max(id) FROM detail_jual_temp"));
				$kodeAkhirId 	= $data[0] + 1;
			
				$data 			= mysql_fetch_row(mysql_query("SELECT max(kd_jual) FROM jual"));
				$kd_jual		 	= $data[0] + 1;
			
				$hasil 			= mysql_query("SELECT * FROM detail_jual_temp where kd_barang='$kd_barang'");
				$data 			= mysql_fetch_array($hasil);
				$ada 			= mysql_num_rows($hasil);
				if($ada>0)
					$sql 		= "update detail_jual_temp set jumlah=jumlah+$jumlah where id='$data[id]'";
				else
					$sql 		= "insert into detail_jual_temp values ('$kodeAkhirId','$tanggal','$kd_jual','$kd_plg','$kd_barang','$jumlah','$harga_jual')";
				
				mysql_query($sql);
					include "kolom_detail_jual.php";
			}
		}
	}
	
} elseif($action=='ubah'){
	if (trim($id)==""||trim($kd_jual)==""||trim($jml)=="")
		print("<script>alert('Isian Masih Ada Yang Kosong !!');location.href='javascript:history.go(-1)';</script>");
	else {
		if (!trim($id)==""||!trim($kd_jual)==""||!trim($jml)==""){
			$sql = "update detail_jual_temp set jumlah='$jml' where id='$id'";
			mysql_query($sql);
		}
	}
	include "kolom_detail_jual.php";
	//header("location:kolom_detail_jual.php?kd_jual=$kd_jual");
	
} elseif($action=='hapus'){
	$sql = "delete from detail_jual_temp where id='$id'";
	mysql_query($sql);
	$query=mysql_query("select distinct * from detail_jual_temp where kd_jual=$kd_jual");
	$data=mysql_fetch_array($query);
	if(($ada=mysql_num_rows($query))>0)
		header("location:kolom_detail_jual.php?kd_jual=$data[kd_jual]&tgl=$data[tgl_jual]");
	else
		header('location:input_jual.php');
		
} elseif($action=='simpan'){
	$query 		= "SELECT * FROM detail_jual_temp where kd_jual=$kd_jual";
	$hasil		= mysql_query($query);
	while($data	= mysql_fetch_array($hasil)) {
		$sql1 		= "insert into detail_jual values ('$data[kd_jual]','$data[kd_barang]','$data[harga_jual]','$data[jumlah]')";
		$sql2 		= "update barang set stock=stock-$data[jumlah] where kd_barang='$data[kd_barang]'";
		
		$hasil1		= mysql_query($sql1);
		$hasil2		= mysql_query($sql2);
		$total 		+= ($data[jumlah] * $data[harga_jual]);
		$kd_jual	= $data[kd_jual];
		$tgl_jual	= $data[tgl_jual];
		$kd_plg		= $data[kd_plg];
	}
	$sql 	= "insert into jual values ('$kd_jual','$kd_plg','$tgl_jual','$total')";
	$hasil3	= mysql_query($sql);
	if($hasil1 && $hasil2 && $hasil3){
		print("<script>alert('Data Penjualan Sudah Disimpan!!');location.href='input_jual.php'</script>");
		mysql_query("delete from detail_jual_temp");
	}
	
} elseif($action=='batal'){
	$sql = "delete from detail_jual_temp where kd_jual='$kd_jual'";
	mysql_query($sql);
	header('location:input_jual.php');
}
?>

proses_jual.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";

$action 		= $_REQUEST['action'];
$kd_plg			= $_POST['kd_plg'];
$kd_barang		= $_POST['kd_barang'];
$harga_jual 	= $_POST['harga_jual'];
$jumlah 		= $_POST['jumlah'];
$id 			= $_GET['id'];
$kd_jual 		= $_GET['kd_jual'];
$jml 			= $_GET['jml'];
	
if (!$action=='ubah'||!$action=='hapus'||!$action=='simpan'||!$action=='batal'){
	if (trim($kd_barang)==""||trim($harga_jual)==""||trim($jumlah)==""||trim($kd_plg)=="")
		print("<script>alert('Isian Masih Ada Yang Kosong!!');location.href='javascript:history.back()';</script>");
	else {
		if (!trim($kd_barang)==""||!trim($harga_jual)==""||!trim($jumlah)==""||!trim($kd_plg)==""){
			$hasil = mysql_query("SELECT * FROM barang where kd_barang='$kd_barang'");
			$jum = mysql_fetch_array($hasil);
			if(intval($jum[harga_barang]) >= $harga_jual)
				print("<script>alert('Harga Jual Barang Dibawah Harga Beli !!');location.href='javascript:history.back()';</script>");
			elseif(intval($jum[stock]) < $jumlah)
				print("<script>alert('Jumlah Barang Tidak Mencukupi $jum[stock]!!');location.href='javascript:history.back()';</script>");
			else{
			
				$tanggal		= date("Y-m-d");
				
				$data 			= mysql_fetch_row(mysql_query("SELECT max(id) FROM detail_jual_temp"));
				$kodeAkhirId 	= $data[0] + 1;
			
				$data 			= mysql_fetch_row(mysql_query("SELECT max(kd_jual) FROM jual"));
				$kd_jual		 	= $data[0] + 1;
			
				$hasil 			= mysql_query("SELECT * FROM detail_jual_temp where kd_barang='$kd_barang'");
				$data 			= mysql_fetch_array($hasil);
				$ada 			= mysql_num_rows($hasil);
				if($ada>0)
					$sql 		= "update detail_jual_temp set jumlah=jumlah+$jumlah where id='$data[id]'";
				else
					$sql 		= "insert into detail_jual_temp values ('$kodeAkhirId','$tanggal','$kd_jual','$kd_plg','$kd_barang','$jumlah','$harga_jual')";
				
				mysql_query($sql);
					include "kolom_detail_jual.php";
			}
		}
	}
	
} elseif($action=='ubah'){
	if (trim($id)==""||trim($kd_jual)==""||trim($jml)=="")
		print("<script>alert('Isian Masih Ada Yang Kosong !!');location.href='javascript:history.go(-1)';</script>");
	else {
		if (!trim($id)==""||!trim($kd_jual)==""||!trim($jml)==""){
			$sql = "update detail_jual_temp set jumlah='$jml' where id='$id'";
			mysql_query($sql);
		}
	}
	include "kolom_detail_jual.php";
	//header("location:kolom_detail_jual.php?kd_jual=$kd_jual");
	
} elseif($action=='hapus'){
	$sql = "delete from detail_jual_temp where id='$id'";
	mysql_query($sql);
	$query=mysql_query("select distinct * from detail_jual_temp where kd_jual=$kd_jual");
	$data=mysql_fetch_array($query);
	if(($ada=mysql_num_rows($query))>0)
		header("location:kolom_detail_jual.php?kd_jual=$data[kd_jual]&tgl=$data[tgl_jual]");
	else
		header('location:input_jual.php');
		
} elseif($action=='simpan'){
	$query 		= "SELECT * FROM detail_jual_temp where kd_jual=$kd_jual";
	$hasil		= mysql_query($query);
	while($data	= mysql_fetch_array($hasil)) {
		$sql1 		= "insert into detail_jual values ('$data[kd_jual]','$data[kd_barang]','$data[harga_jual]','$data[jumlah]')";
		$sql2 		= "update barang set stock=stock-$data[jumlah] where kd_barang='$data[kd_barang]'";
		
		$hasil1		= mysql_query($sql1);
		$hasil2		= mysql_query($sql2);
		$total 		+= ($data[jumlah] * $data[harga_jual]);
		$kd_jual	= $data[kd_jual];
		$tgl_jual	= $data[tgl_jual];
		$kd_plg		= $data[kd_plg];
	}
	$sql 	= "insert into jual values ('$kd_jual','$kd_plg','$tgl_jual','$total')";
	$hasil3	= mysql_query($sql);
	if($hasil1 && $hasil2 && $hasil3){
		print("<script>alert('Data Penjualan Sudah Disimpan!!');location.href='input_jual.php'</script>");
		mysql_query("delete from detail_jual_temp");
	}
	
} elseif($action=='batal'){
	$sql = "delete from detail_jual_temp where kd_jual='$kd_jual'";
	mysql_query($sql);
	header('location:input_jual.php');
}
?>

proses_pelanggan.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";

$action 	= $_REQUEST['action'];
$id			= $_GET['id'];
$kd_plg 	= $_POST['kd_plg'];
$nama_plg 	= $_POST['nama_plg'];
$alamat 	= $_POST['alamat'];
$kota 		= $_POST['kota'];
$telp 		= $_POST['telp'];

if (!$action=="ubah"||!$action=="hapus"){
	if (trim($kd_plg)=="" || trim($nama_plg)=="" || trim($alamat)=="" || trim($kota)=="" || trim($telp)=="")
		print("<script> alert('Masih Ada Isian Yang Kosong !!');location.href='javascript:history.back()';</script>");
	else {
		if (!trim($kd_plg)=="" || !trim($nama_plg)=="" || !trim($alamat)=="" || !trim($kota)=="" || !trim($telp)==""){
			$query_check = mysql_query("SELECT * FROM pelanggan WHERE nama_plg = '$nama_plg'");
			if(mysql_num_rows($query_check) > 0)
        		print("<script> alert('Data Pelanggan $nama_plg Sudah Ada Pada Database!!');location.href='javascript:history.back()';</script>");
			else {
				$sql="insert into pelanggan values('$kd_plg','$nama_plg','$alamat','$kota','$telp')";
				if (mysql_query($sql))
					print("<script> alert('Data Pelanggan $nama_plg Telah Disimpan');location.href='input_pelanggan.php?';</script>");
				else
					print("<script> alert('Data Pelanggan $nama_plg Gagal Disimpan!!');location.href='javascript:history.back()';</script>");
			}
		}
	}
} elseif ($action=='ubah'){
	if (trim($kd_plg)=="" || trim($nama_plg)=="" || trim($alamat)=="" || trim($kota)=="" || trim($telp)=="")
		print("<script> alert('Masih Ada Isian Yang Kosong !!');location.href='javascript:history.back()';</script>");
	else {
		if (!trim($kd_plg)=="" || trim($nama_plg)=="" || trim($alamat)=="" || trim($kota)=="" || trim($telp)==""){
			$sql = "UPDATE pelanggan SET nama_plg='$nama_plg', alamat='$alamat', kota='$kota', telp='$telp' WHERE kd_plg='$kd_plg'";
			if (mysql_query($sql))
				print("<script> alert('Data Pelanggan $nama_plg Telah Diupdate');location.href='daftar_pelanggan.php?';</script>");
			else
				print("<script> alert('Data Pelanggan $nama_plg Gagal Diupdate');location.href='javascript:history.back()';</script>");
		}
	}
} elseif($action=="hapus"){
	$sql = "DELETE FROM pelanggan WHERE kd_plg = '$id'";
	if (mysql_query($sql))
		print("<script> alert('Data Pelanggan $nama_plg Telah Dihapus');location.href='daftar_pelanggan.php?';</script>");
	else
		print("<script> alert('Data Pelanggan $nama_plg Gagal Dihapus');location.href='daftar_pelanggan.php?';</script>");
}
?>

proses_taksir.php
<?
include "../conect/conect.php";
include "../conect/cekLogin.php";

$action 		= $_REQUEST['action'];
$id				= $_GET['id'];
$kd_taksir 		= $_POST['kd_taksir'];
$jangka_waktu 	= $_POST['jangka_waktu'];
$persen_taksir 	= $_POST['persen_taksir'];

if (!$action=="ubah"||!$action=="hapus"){
	if (trim($kd_taksir)=="" || trim($jangka_waktu)=="" || trim($persen_taksir)=="")
		print("<script> alert('Masih Ada Isian Yang Kosong!!');location.href='javascript:history.back()';</script>");
	else {
		if (!trim($kd_taksir)=="" || !trim($jangka_waktu)=="" || !trim($persen_taksir)==""){
			$query_check = mysql_query("SELECT * FROM taksir WHERE jangka_waktu = '$jangka_waktu'");
			if(mysql_num_rows($query_check) > 0)
        		print("<script> alert('Data  Jenis $nama_jenis Sudah Ada Pada Database!!');location.href='javascript:history.back()';</script>");
			else {
				$sql="insert into taksir values('$kd_taksir','$jangka_waktu','$persen_taksir')";
				if (mysql_query($sql))
					print("<script> alert('Data Prosentase Taksiran Telah Disimpan');location.href='input_taksir.php?';</script>");
				else
					print("<script> alert('Data Prosentase Taksiran Gagal Disimpan!!');location.href='javascript:history.back()';</script>");
			}
		}
	}
} elseif ($action=='ubah'){
	if (trim($kd_taksir)=="" || trim($nama_jenis)=="" || trim($persen_taksir)=="")
		print("<script> alert('Masih Ada Isian Yang Kosong !!');location.href='javascript:history.back()';</script>");
	else {
		if (!trim($kd_taksir)=="" || !trim($nama_jenis)=="" || !trim($persen_taksir)==""){
			$sql = "UPDATE taksir SET jangka_waktu='$jangka_waktu',persen_taksir=$persen_taksir WHERE kd_taksir=$kd_taksir";
			if (mysql_query($sql))
				print("<script> alert('Data Prosentase Taksiran Telah Diupdate');location.href='daftar_taksir.php?';</script>");
			else
				print("<script> alert('Data Prosentase Taksiran Gagal Diupdate');location.href='javascript:history.back()';</script>");
		}
	}
} elseif($action=="hapus"){
	$sql = "DELETE FROM taksir WHERE kd_taksir = '$id'";
	if (mysql_query($sql))
		print("<script> alert('Data Prosentase Taksiran Telah Dihapus');location.href='daftar_taksir.php?';</script>");
	else
		print("<script> alert('Data Prosentase Taksiran Gagal Dihapus');location.href='daftar_taksir.php?';</script>");
}
?>