You are on page 1of 50

PHP & MySQL

Tugas UTS ( Sales Toko Cat )


    

Di susun oleh  :

Aris Putra Buana ( 2016804090  )

YAYASAN PENDIDIKAN INSAN PEMBANGUNAN(YPIP)

STMIK INSAN PEMBANGUNAN

JL. RAYA SERANG KM 10 BITUNG,TANGERANG-BANTEN


FILE KONEKSI ( Di dalam Folder config )
<?php

$dbhost='localhost';

$dbuser='root';

$dbpassword='';

$dbname='sales';

mysql_connect($dbhost,$dbuser,$dbpassword);

mysql_select_db($dbname);

?>

FILE USER FORM


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

<body>

<form action="usersimpan.php" method="post" enctype="multipart/form-data" name="user"


id="user">

<table width="25%" height="176" border="0" align="center">

<tr>

<td colspan="3" bgcolor="#FF0000"><div align="center">FORM USER </div></td>

</tr>

<tr>

<td width="33%">USERID</td>
<td width="4%">:</td>

<td width="63%"><label>

<input name="txtuserid" type="text" id="txtuserid" size="10" maxlength="10" />

</label></td>

</tr>

<tr>

<td>USERNAME</td>

<td>:</td>

<td><label>

<input name="txtusername" type="text" id="txtusername" size="25" maxlength="25" />

</label></td>

</tr>

<tr>

<td>PASSWORD</td>

<td>:</td>

<td><label>

<input name="txtpassword" type="password" id="txtpassword" size="8" maxlength="8" />

</label></td>

</tr>

<tr>

<td>LEVEL</td>

<td>:</td>

<td><label>

<select name="cblevel" id="cblevel">

<option value="admin">admin</option>

<option value="kasir">kasir</option>

</select>

</label></td>

</tr>

<tr>

<td height="45" colspan="3" bgcolor="#FF0000"><label>


<div align="center">

<input type="submit" name="Submit" value="SIMPAN" />

<input type="reset" name="Submit2" value="BATAL" />

</div>

</label></td>

</tr>

</table>

</form>

<form id="form1" name="form1" method="post" action="userview.php">

<label>

<div align="center">

<input type="submit" name="Submit" value="VIEW DATA" />

</div>

</label>

</body>

</html>

FILE USER SIMPAN


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

$userid=$_POST['txtuserid'];

$username=$_POST['txtusername'];

$password=$_POST['txtpassword'];

$level=$_POST['cblevel'];

$strsql="insert into user (userid,username,password,level) values


('$userid','$username','$password','$level')";

$query=mysql_query($strsql) or die("query salah");

if($query=1){

echo"<script>alert('sukses')</script>";

echo"<script>window.location='userview.php'</script>";

}else{

echo"<script>alert('gagal')</script>";

echo"<script>window.location='userform.php'</script>";

?>

FILE USER UPDATE


<?php

include"config/koneksi.php";

$update=mysql_query("update user set userid='$_POST[txtuserid]',


username='$_POST[txtusername]', password='$_POST[txtpassword]', level='$_POST[txtlevel]' where
userid='$_POST[txtuserid]'");

if ($update==1)

echo "<script>alert('sukses di ubah')</script>";

echo"<script>window.location='userview.php'</script>";

?>
FILE USER VIEW
<?php

include'config/koneksi.php';

$query=mysql_query("select * from user");

$jml=mysql_num_rows($query);

?>

<center>

<table width="52%" height="67" border="0">

<tr bgcolor="#FF0000">

<td width="9%"><div align="center">USERID</div></td>

<td width="26%"><div align="center">USERNAME</div></td>

<td width="33%"><div align="center">PASSWORD</div></td>

<td width="15%"><div align="center">LEVEL</div></td>

<td width="17%"><div align="center">AKSI</div></td>

</tr>

<?php

while($row=mysql_fetch_array($query)) {

?>

<tr>

<td><?php echo $row['userid']; ?></td>

<td><?php echo $row['username']; ?></td>

<td><?php echo $row['password']; ?></td>

<td><?php echo $row['level']; ?></td>

<td>

<div align="center"><a href="useredit.php?userid=<?php echo $row['userid']; ?>"


onclick="return confirm('Apakah Anda Yakin?')"><img src="images/edit.png" width="20"
height="20"></a>
<a href="userdelete.php?userid=<?php echo $row['userid']; ?>" onclick="return
confirm('Apakah Anda Yakin?')" ><img src="images/hapus.png" width="20" height="20"></a>

</div></td>

</tr>

<?php

?>

</table>

<form id="form1" name="form1" method="post" action="userform.php">

<label>

<input type="submit" name="Submit" value="TAMBAH DATA" />

</label>

</form>

</center>

FILE USER EDIT


<html>

<head>

<title></title>

</head>

<body>

<?php

include "config/koneksi.php";

$kd=$_GET['userid'];

$ok=mysql_query("select * from user where userid='$_GET[userid]'");

?>
<form action="userupdate.php" method="post" id="form1" name="form1">

<?php

while($row=mysql_fetch_array($ok)){

?>

<table width="24%" height="176" border="0" align="center">

<tr>

<td height="21" colspan="3" bgcolor="#FF0000"><div align="center">UPDATE USER </div></td>

</tr>

<tr>

<td width="35%">USERID </td>

<td width="4%">:</td>

<td width="61%"><label>

<input name="txtuserid" type="text" id="txtuserid" size="10" maxlength="10" value="<?php


echo $kd; ?>" />

</label></td>

</tr>

<tr>

<td>USERNAME </td>

<td>:</td>

<td><label>

<input name="txtusername" type="text" id="txtusername" size="25" maxlength="25" value="<?


php echo $row['username']; ?>" />

</label></td>

</tr>

<tr>

<td>PASSWORD</td>

<td>:</td>

<td><label>

<input name="txtpassword" type="text" id="txtpassword" size="15" maxlength="15" value="<?


php echo $row['password']; ?>" />

</label></td>
</tr>

<tr>

<td height="21">LEVEL</td>

<td height="21">:</td>

<td height="21"><label>

<input name="txtlevel" type="text" id="txtlevel" size="5" value="<?php echo $row['level']; ?>" />

</label></td>

</tr>

<tr>

<td height="45" colspan="3" bgcolor="#FF0000"><label>

<div align="center">

<input type="submit" name="Submit" value="UPDATE" />

<input type="reset" name="Submit2" value="BATAL" />

</div>

</label></td>

</tr>

<?php

?>

</table>

</form>

</body>

</html>

FILE USER DELETE


<?php

include 'config/koneksi.php';

$query=mysql_query("delete from user where userid='$_GET[userid]'");

if($query){

?>

<script language="javascript"> document.location.href="userview.php";</script>

<?php

else {

echo "gagal hapus data";

?>

FILE PELANGGAN FORM

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


<title>Untitled Document</title>

</head>

<body>

<form action="pelanggansimpan.php" method="post" enctype="multipart/form-data"


name="pelanggan" id="pelanggan">

<table width="28%" height="189" border="0" align="center">

<tr>

<td colspan="3" bgcolor="#FF0000"><div align="center">FORM PELANGGAN </div></td>

</tr>

<tr>

<td width="44%">KODE PELANGGAN </td>

<td width="5%">:</td>

<td width="51%"><label>

<input name="txtkodepelanggan" type="text" id="txtkodepelanggan" size="10" maxlength="10" />

</label></td>

</tr>

<tr>

<td>NAMA PELANGGAN </td>

<td>:</td>

<td><label>

<input name="txtnamapelanggan" type="text" id="txtnamapelanggan" size="25"


maxlength="25" />

</label></td>

</tr>

<tr>

<td>ALAMAT</td>

<td>:</td>

<td><label>

<textarea name="txtalamat" id="txtalamat"></textarea>

</label></td>
</tr>

<tr>

<td>TELEPON</td>

<td>:</td>

<td><label>

<input name="txttelepon" type="text" id="txttelepon" size="12" maxlength="12" />

</label></td>

</tr>

<tr>

<td height="45" colspan="3" bgcolor="#FF0000"><label>

<div align="center">

<input type="submit" name="Submit" value="SIMPAN" />

<input type="reset" name="Submit2" value="BATAL" />

</div>

</label></td>

</tr>

</table>

</form>

<form id="form1" name="form1" method="post" action="pelangganview.php">

<label>

<div align="center">

<input type="submit" name="Submit" value="VIEW DATA" />

</div>

</label>

</body>

</html>

FILE PELANGGAN SIMPAN


<?php

include 'config/koneksi.php';

$kd=$_POST['txtkodepelanggan'];

$nama=$_POST['txtnamapelanggan'];

$alamat=$_POST['txtalamat'];

$tlp=$_POST['txttelepon'];

$strsql="insert into pelanggan(kodepelanggan,namapelanggan,alamat,telepon) values


('$kd','$nama','$alamat','$tlp')";

$query=mysql_query($strsql) or die("query salah");

if($query=1){

echo"<script>alert('sukses')</script>";

echo"<script>window.location='pelangganview.php'</script>";

}else{

echo"<script>alert('gagal')</script>";

echo"<script>window.location='pelangganform.php'</script>";

?>

FILE PELANGGAN UPDATE

<?php

include"config/koneksi.php";

$update=mysql_query("update pelanggan set kodepelanggan='$_POST[txtkodepelanggan]',


namapelanggan='$_POST[txtnamapelanggan]', alamat='$_POST[txtalamat]',
telepon='$_POST[txttelepon]' where kodepelanggan='$_POST[txtkodepelanggan]'");

if ($update==1)

echo "<script>alert('sukses di ubah')</script>";

echo"<script>window.location='pelangganview.php'</script>";

}
?>

FILE PELANGGAN VIEW

<?php

include'config/koneksi.php';

$query=mysql_query("select * from pelanggan");

$jml=mysql_num_rows($query);

?>

<center>

<table width="58%" height="67" border="0">

<tr bgcolor="#FF0000">

<td width="20%"><div align="center">KODE PELAGGAN </div></td>

<td width="20%"><div align="center">NAMA PELANGGAN </div></td>

<td width="38%"><div align="center">ALAMAT</div></td>

<td width="13%"><div align="center">TELEPON</div></td>

<td width="9%"><div align="center">AKSI</div></td>

</tr>

<?php

while($row=mysql_fetch_array($query)) {

?>

<tr>

<td><?php echo $row['kodepelanggan']; ?></td>

<td><?php echo $row['namapelanggan']; ?></td>

<td><?php echo $row['alamat']; ?></td>

<td><?php echo $row['telepon']; ?></td>

<td>
<div align="center"><a href="pelangganedit.php?kodepelanggan=<?php echo
$row['kodepelanggan']; ?>" onclick="return confirm('Apakah Anda Yakin?')"><img
src="images/edit.png" width="20" height="20"></a>

<a href="pelanggandelete.php?kodepelanggan=<?php echo $row['kodepelanggan']; ?>"


onclick="return confirm('Apakah Anda Yakin?')" ><img src="images/hapus.png" width="20"
height="20"></a>

</div></td>

</tr>

<?php

?>

</table>

<form id="form1" name="form1" method="post" action="pelangganform.php">

<label>

<input type="submit" name="Submit" value="TAMBAH DATA" />

</label>

</form>

</center>

FILE PELANGGAN EDIT

<html>

<head>

<title></title>

</head>

<body>
<?php

include "config/koneksi.php";

$kd=$_GET['kodepelanggan'];

$ok=mysql_query("select * from pelanggan where kodepelanggan='$_GET[kodepelanggan]'");

?>

<form action="pelangganupdate.php" method="post" id="form1" name="form1">

<?php

while($row=mysql_fetch_array($ok)){

?>

<table width="35%" height="189" border="0" align="center">

<tr>

<td colspan="3" bgcolor="#FF0000"><div align="center">UPDATE PELANGGAN </div></td>

</tr>

<tr>

<td width="35%">KODE PELANGGAN </td>

<td width="4%">:</td>

<td width="61%"><label>

<input name="txtkodepelanggan" type="text" id="txtkodepelanggan" size="10" maxlength="10"


value="<?php echo $kd; ?>" />

</label></td>

</tr>

<tr>

<td>NAMA PELANGGAN </td>

<td>:</td>

<td><label>

<input name="txtnamapelanggan" type="text" id="txtnamapelanggan" size="25"


maxlength="25" value="<?php echo $row['namapelanggan']; ?>" />

</label></td>

</tr>

<tr>

<td>ALAMAT</td>

<td>:</td>
<td><label>

<textarea name="txtalamat" id="txtalamat"><?php echo $row['alamat']; ?></textarea>

</label></td>

</tr>

<tr>

<td height="21">TELEPON</td>

<td height="21">:</td>

<td height="21"><label>

<input name="txttelepon" type="text" id="txttelepon" value="<?php echo $row['telepon']; ?>"


size="12" maxlength="12" />

</label></td>

</tr>

<tr>

<td height="45" colspan="3" bgcolor="#FF0000"><label>

<div align="center">

<input type="submit" name="Submit" value="UPDATE" />

<input type="reset" name="Submit2" value="BATAL" />

</div>

</label></td>

</tr>

<?php

?>

</table>

</form>

</body>
</html>

FILE PELANGGAN DELETE

<?php

include 'config/koneksi.php';

$query=mysql_query("delete from pelanggan where kodepelanggan='$_GET[kodepelanggan]'");

if($query){

?>

<script language="javascript"> document.location.href="pelangganview.php";</script>

<?php

else {

echo "gagal hapus data";

?>

FILE BARANG FORM


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>
</head>

<body>

<form action="barangsimpan.php" method="post" enctype="multipart/form-data" name="user"


id="user">

<table width="27%" height="204" border="0" align="center">

<tr>

<td colspan="3" bgcolor="#FF0000"><div align="center">FORM BARANG </div></td>

</tr>

<tr>

<td width="37%">KODE BARANG </td>

<td width="2%">:</td>

<td width="61%"><label>

<input name="txtkodebarang" type="text" id="txtkodebarang" size="10" maxlength="10" />

</label></td>

</tr>

<tr>

<td>NAMA BARANG </td>

<td>:</td>

<td><label>

<input name="txtnamabarang" type="text" id="txtnamabarang" size="25" maxlength="25" />

</label></td>

</tr>

<tr>

<td>WARNA</td>

<td>:</td>

<td><label>

<select name="cbwarna" id="cbwarna">

<option value="merah">merah</option>

<option value="biru">biru</option>

<option value="kuning">kuning</option>
<option value="ungu">ungu</option>

<option value="hijau">hijau</option>

<option value="putih">putih</option>

</select>

</label></td>

</tr>

<tr>

<td>BERAT</td>

<td>:</td>

<td><label>

<select name="cbberat" id="cbberat">

<option value="1 kg">1 kg</option>

<option value="5 kg">5 kg</option>

<option value="10 kg">10 kg</option>

<option value="25 kg">25 kg</option>

</select>

</label></td>

</tr>

<tr>

<td>HARGA</td>

<td>:</td>

<td><label>

<input name="txtharga" type="text" id="txtharga" size="10" maxlength="10" />

</label></td>

</tr>

<tr>

<td height="45" colspan="3" bgcolor="#FF0000"><label>

<div align="center">

<input type="submit" name="Submit" value="SIMPAN" />

<input type="reset" name="Submit2" value="BATAL" />

</div>
</label></td>

</tr>

</table>

</form>

<form id="form1" name="form1" method="post" action="barangview.php">

<label>

<div align="center">

<input type="submit" name="Submit" value="VIEW DATA" />

</div>

</label>

</form>

</body>

</html>

FILE BARANG SIMPAN

<?php

include 'config/koneksi.php';

$kdbrg=$_POST['txtkodebarang'];

$nmbrg=$_POST['txtnamabarang'];

$wrn=$_POST['cbwarna'];

$brt=$_POST['cbberat'];

$hrg=$_POST['txtharga'];

$strsql="insert into barang (kodebarang,namabarang,warna,berat,harga) values


('$kdbrg','$nmbrg','$wrn','$brt','$hrg')";

$query=mysql_query($strsql) or die("query salah");

if($query=1){

echo"<script>alert('sukses')</script>";

echo"<script>window.location='barangview.php'</script>";
}else{

echo"<script>alert('gagal')</script>";

echo"<script>window.location='barangform.php'</script>";

?>

FILE BARANG UPDATE

<?php

include"config/koneksi.php";

$update=mysql_query("update barang set kodebarang='$_POST[txtkodebarang]',


namabarang='$_POST[txtnamabarang]', warna='$_POST[txtwarna]', berat='$_POST[txtberat]',
harga='$_POST[txtharga]' where kodebarang='$_POST[txtkodebarang]'");

if ($update==1)

echo "<script>alert('sukses di ubah')</script>";

echo"<script>window.location='barangview.php'</script>";

?>

FILE BARANG VIEW


<?php

include'config/koneksi.php';

$query=mysql_query("select * from barang");

$jml=mysql_num_rows($query);

?>

<center>

<table width="61%" height="67" border="0">

<tr bgcolor="#FF0000">

<td width="16%"><div align="center">KODE BARANG </div></td>

<td width="25%"><div align="center">NAMA BARANG </div></td>

<td width="13%"><div align="center">WARNA</div></td>

<td width="11%"><div align="center">BERAT</div></td>

<td width="12%"><div align="center">HARGA</div></td>

<td width="13%"><div align="center">AKSI</div></td>

</tr>

<?php

while($row=mysql_fetch_array($query)) {

?>

<tr>

<td><?php echo $row['kodebarang']; ?></td>

<td><?php echo $row['namabarang']; ?></td>

<td><?php echo $row['warna']; ?></td>

<td><?php echo $row['berat']; ?></td>

<td><?php echo $row['harga']; ?></td>

<td>

<div align="center"><a href="barangedit.php?kodebarang=<?php echo


$row['kodebarang']; ?>" onclick="return confirm('Apakah Anda Yakin?')"><img
src="images/edit.png" width="20" height="20"></a>

<a href="barangdelete.php?kodebarang=<?php echo $row['kodebarang']; ?>"


onclick="return confirm('Apakah Anda Yakin?')" ><img src="images/hapus.png" width="20"
height="20"></a>
</div></td>

</tr>

<?php

?>

</table>

<form id="form1" name="form1" method="post" action="barangform.php">

<label>

<input type="submit" name="Submit" value="TAMBAH DATA" />

</label>

</form>

</center>

FILE BARANG EDIT

<html>

<head>

<title></title>

</head>

<body>

<?php

include "config/koneksi.php";

$kd=$_GET['kodebarang'];

$ok=mysql_query("select * from barang where kodebarang='$_GET[kodebarang]'");

?>

<form action="barangupdate.php" method="post" id="form1" name="form1">


<?php

while($row=mysql_fetch_array($ok)){

?>

<table width="27%" height="202" border="0" align="center">

<tr>

<td colspan="3" bgcolor="#FF0000"><div align="center">FORM BARANG </div></td>

</tr>

<tr>

<td width="37%">KODE BARANG </td>

<td width="2%">:</td>

<td width="61%"><label>

<input name="txtkodebarang" type="text" id="txtkodebarang" size="10" maxlength="10"


value="<?php echo $kd; ?>" />

</label></td>

</tr>

<tr>

<td>NAMA BARANG </td>

<td>:</td>

<td><label>

<input name="txtnamabarang" type="text" id="txtnamabarang" size="25" maxlength="25"


value="<?php echo $row['namabarang']; ?>" />

</label></td>

</tr>

<tr>

<td>WARNA</td>

<td>:</td>

<td><label>

<input name="txtwarna" type="text" id="txtwarna" size="15" maxlength="15" value="<?php


echo $row['warna']; ?>"/>
</label></td>

</tr>

<tr>

<td>BERAT</td>

<td>:</td>

<td><label>

<input name="txtberat" type="text" id="txtberat" size="5" maxlength="5" value="<?php echo


$row['berat']; ?>"/>

</label></td>

</tr>

<tr>

<td>HARGA</td>

<td>:</td>

<td><label>

<input name="txtharga" type="text" id="txtharga" size="10" maxlength="10" value="<?php


echo $row['harga']; ?>" />

</label></td>

</tr>

<tr>

<td height="45" colspan="3" bgcolor="#FF0000"><label>

<div align="center">

<input type="submit" name="Submit" value="UPDATE" />

<input type="reset" name="Submit2" value="BATAL" />

</div>

</label></td>

</tr>

<?php

}
?>

</table>

</form>

</body>

</html>

FILE BARANG DELETE

<?php

include 'config/koneksi.php';

$query=mysql_query("delete from barang where kodebarang='$_GET[kodebarang]'");

if($query){

?>

<script language="javascript"> document.location.href="barangview.php";</script>

<?php

else {

echo "gagal hapus data";

?>
FILE GUDANG FORM

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

<body>

<form action="gudangsimpan.php" method="post" enctype="multipart/form-data" name="gudang"


id="gudang">

<table width="23%" height="176" border="0" align="center">

<tr>

<td colspan="2" bgcolor="#FF0000"><div align="center">FORM GUDANG </div></td>

</tr>

<tr>

<td width="42%">KODE GUDANG </td>

<td width="58%"><label>

<input name="txtkodegudang" type="text" id="txtkodegudang" size="10" maxlength="10" />

</label></td>

</tr>

<tr>
<td>KODE BARANG </td>

<td><label>

<select name="cbkodebarang" id="cbkodebarang">

<?php

include "config/koneksi.php";

$tampil=mysql_query("select kodebarang, namabarang from barang");

echo "<option>::Silahkan Pilih::</option>";

while ($tampilkan=mysql_fetch_array($tampil))

echo "<option value='$tampilkan[0]'>$tampilkan[0]|


$tampilkan[1]</option>";

?>

</select>

</label></td>

</tr>

<tr>

<td>LOKASI</td>

<td><label>

<input name="txtlokasi" type="text" id="txtlokasi" size="5" maxlength="5" />

</label></td>

</tr>

<tr>

<td>STOK</td>

<td><label>

<input name="txtstok" type="text" id="txtstok" size="10" maxlength="10" />

</label></td>

</tr>
<tr>

<td height="45" colspan="2" bgcolor="#FF0000"><label>

<div align="center">

<input type="submit" name="Submit" value="SIMPAN" />

<input type="reset" name="Submit2" value="BATAL" />

</div>

</label></td>

</tr>

</table>

</form>

<form id="form1" name="form1" method="post" action="gudangview.php">

<label>

<div align="center">

<input type="submit" name="Submit" value="VIEW DATA" />

</div>

</label>

</body>

</html>

FILE GUDANG SIMPAN

<?php

include 'config/koneksi.php';

$kodeg=$_POST['txtkodegudang'];

$kodeb=$_POST['cbkodebarang'];

$lokasi=$_POST['txtlokasi'];

$stok=$_POST['txtstok'];
$strsql="insert into gudang(kodegudang,kodebarang,lokasi,stok) values
('$kodeg','$kodeb','$lokasi','$stok')";

$query=mysql_query($strsql) or die("query salah");

if($query=1){

echo"<script>alert('sukses')</script>";

echo"<script>window.location='gudangview.php'</script>";

}else{

echo"<script>alert('gagal')</script>";

echo"<script>window.location='gudangform.php'</script>";

?>

FILE GUDANG VIEW

<?php

include'config/koneksi.php';

$query=mysql_query("select * from gudang");

$jml=mysql_num_rows($query);

?>

<center>

<table width="33%" height="67" border="0">

<tr bgcolor="#FF0000">

<td width="34%"><div align="center">KODE GUDANG </div></td>

<td width="34%"><div align="center">KODE BARANG </div></td>

<td width="18%"><div align="center">LOKASI</div></td>

<td width="14%"><div align="center">STOK</div></td>

</tr>
<?php

while($row=mysql_fetch_array($query)) {

?>

<tr>

<td><?php echo $row['kodegudang']; ?></td>

<td><?php echo $row['kodebarang']; ?></td>

<td><?php echo $row['lokasi']; ?></td>

<td><?php echo $row['stok']; ?></td>

</tr>

<?php

?>

</table>

<form id="form1" name="form1" method="post" action="gudangform.php">

<label>

<input type="submit" name="Submit" value="TAMBAH DATA" />

</label>

</form>

</center>
FILE HITUNG
<?php

include 'config/koneksi.php';

$data=mysql_query("select SUM(subtotal) as total from penjualansementara");

$baris=mysql_fetch_array($data);

$total=$baris['total'];

if($total>=1500000){

$diskon=$total*15/100;

$grandtotal=$total-$diskon;

elseif($total>=1000000){

$diskon=$total*10/100;

$grandtotal=$total-$diskon;

elseif($total>=500000){

$diskon=$total*5/100;

$grandtotal=$total-$diskon;

else{

$diskon=$total*0/100;

$grandtotal=$total-$diskon;

}
?>

FILE LIST VIEW

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

<body>

<?php

include 'config/koneksi.php';

$barang=mysql_query( "SELECT * FROM barang");

?>

<?php

$query=mysql_query("select * from penjualansementara");

$jml=mysql_num_rows($query);

?>
<form id="form1" name="form1" method="post" action="simpanlist.php">

<table width="80%" border="0" align="center">

<tr>

<td width="14%" height="26"><select name="kodebarang" size="1" id="kodebarang"


onchange="changeValue(this.value)" >

<option>- Pilih -</option>

<?php if(mysql_num_rows($barang)) {?>

<?php while($row_brg= mysql_fetch_array($barang)) {?>

<option value="<?php echo $row_brg["kodebarang"]?>"> <?php echo


$row_brg["kodebarang"]?> </option>

<?php $jsArray .= "namabarang['" . $row_brg['kodebarang'] . "'] = {namabarang:'" .


addslashes($row_brg['namabarang']) . "'};\n";

$jsArray .= "berat['" . $row_brg['kodebarang'] . "'] =


{berat:'" . addslashes($row_brg['berat']) . "'};\n";

$jsArray .= "warna['" . $row_brg['kodebarang'] . "'] =


{warna:'" . addslashes($row_brg['warna']) . "'};\n";

$jsArray .= "harga['" . $row_brg['kodebarang'] . "'] =


{harga:'" . addslashes($row_brg['harga']) . "'};\n"; } ?>

<?php } ?>

</select>

<label></label></td>

<td width="14%"><label></label>

<label>

<input name="namabarang" type="text" id="namabarang" placeholder="NAMA BARANG" />

</label></td>

<td width="14%"><label>

<input name="warna" type="text" id="warna" placeholder="WARNA" readonly="" />

</label></td>

<td width="14%"><label>

<input name="berat" type="text" id="berat" placeholder="BERAT" readonly="" />

</label></td>
<td width="14%"><label>

<input name="harga" type="text" id="harga" placeholder="HARGA" readonly="" />

</label></td>

<td width="14%"><label>

<input name="jumlah" type="text" id="jumlah" placeholder="JUMLAH" />

</label></td>

<td><label>

<input type="submit" name="Submit" value="TAMBAH" />

</label></td>

</tr>

</table>

<table width="83%" border="0" align="center">

<tr>

<td width="16%" height="21" bordercolor="#F0F0F0" bgcolor="#FF0000"><div


align="center">KODE BARANG </div></td>

<td width="12%" height="21" bordercolor="#F0F0F0" bgcolor="#FF0000"><div


align="center">HARGA</div></td>

<td width="16%" height="21" bordercolor="#F0F0F0" bgcolor="#FF0000"><div


align="center">JUMLAH</div></td>

<td width="13%" bordercolor="#F0F0F0" bgcolor="#FF0000"><div


align="center">SUBTOTAL</div></td>

</tr>

<?php

while($row=mysql_fetch_array($query)) {

?>

<tr>

<td><?php echo $row['kodebarang']; ?></td>

<td><?php echo $row['harga']; ?></td>

<td><?php echo $row['jumlah']; ?></td>


<td><?php echo $row['subtotal']; ?></td>

</tr>

<?php

?>

</table>

</form>

<script type="text/javascript">

<?php echo $jsArray; ?>

function changeValue(kodebarang) {

document.getElementById("namabarang").value = namabarang[kodebarang].namabarang;

document.getElementById("warna").value = warna[kodebarang].warna;

document.getElementById("berat").value = berat[kodebarang].berat;

document.getElementById("harga").value = harga[kodebarang].harga;

};

</script>

</body>

</html>

FILE SIMPAN LIST


<?php

include 'config/koneksi.php';

$kdbrg=$_POST['kodebarang'];

$hrg=$_POST['harga'];

$jumlah=$_POST['jumlah'];
$subtotal=$hrg*$jumlah;

$strsql="insert into penjualansementara (kodebarang,jumlah,harga,subtotal)


values('$kdbrg','$jumlah','$hrg','$subtotal')";

$query=mysql_query($strsql);

if($query=1){

echo"<script>alert('sukses')</script>";

echo"<script>window.location='listview.php'</script>";

}else{

echo"<script>alert('gagal')</script>";

echo"<script>window.location='listview.php'</script>";

?>

FILE PROSES AJAX

<?php

include 'config/koneksi.php';

$barang=mysql_query( "SELECT * FROM barang");

$jsArray = "var warna = new Array();\n";

?>

<!DOCTYPE html>

<html lang="en">

<head>

<title><strong>Menampilkan Field Otomatis Setelah Field Pertama Diisi</strong></title>


</head>

<body>

<div class="container">

<h1>Penjualan</h1>

<form name="autosumform" method="post" action="">

<table>

<tr>

<td width="78"><label>kode Barang</label></td>

<td width="165">

<p>

<select name="kodebarang" onchange="changeValue(this.value)" >

<option>- Pilih -</option>

<?php if(mysql_num_rows($barang)) {?>

<?php while($row_brg= mysql_fetch_array($barang)) {?>

<option value="<?php echo $row_brg["kodebarang"]?>"> <?php echo


$row_brg["kodebarang"]?> </option>

<?php $jsArray .= "namabarang['" . $row_brg['kodebarang'] . "'] =


{namabarang:'" . addslashes($row_brg['namabarang']) . "'};\n";

$jsArray .= "berat['" . $row_brg['kodebarang'] . "'] =


{berat:'" . addslashes($row_brg['berat']) . "'};\n";

$jsArray .= "warna['" . $row_brg['kodebarang'] . "'] =


{warna:'" . addslashes($row_brg['warna']) . "'};\n"; } ?>

<?php } ?>

</select>

</p>

<p>

<label></label>

<input name="kodebarang2" type="text" id="kodebarang" value="<?php echo


$row_brg["kodebarang"]?>" onChange="changeValue(this.value)">
</p></td>

</tr>

<tr>

<td>Warna</td>

<td><label>

<input name="warna" type="text" id="warna">

</label></td>

</tr>

<tr>

<td>Berat</td>

<td><label>

<input name="berat" type="text" id="berat">

</label></td>

</tr>

<tr>

<td><label>Nama</label></td>

<td><input type="text" class="form-control" name="namabarang" id="namabarang"


value="" readonly="readonly"></td>

</tr>

</table>

<p>&nbsp;</p>

</form>

</div>

<script type="text/javascript">

<?php echo $jsArray; ?>

function changeValue(kodebarang) {

document.getElementById("namabarang").value = namabarang[kodebarang].namabarang;

document.getElementById("warna").value = warna[kodebarang].warna;

document.getElementById("berat").value = berat[kodebarang].berat;

};
</script> <!-- Tampilkan Harga berdasarkan kode barang -->

</body>

</html>

FILE PENJUALAN FORM

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

<body>

<?php

include 'config/koneksi.php';

$data=mysql_query("select * from penjualan order by nonota DESC LIMIT 0,1");

if($data===false){

die(mysql_error());

$i=mysql_fetch_array($data);

$kodeawal=substr($i['nonota'],3,4)+1;

if($kodeawal<10){

$kode='P00'.$kodeawal;

elseif($kodeawal>9 && $kodeawal<=99){

$kode='P0'.$kodeawal;

}
else{

$kode='P'.$kodeawal;

?>

<form id="form1" name="form1" method="post" action="">

<table width="80%" border="0" align="center">

<tr>

<td colspan="7" bgcolor="#FF0000"><div align="center"><strong>FORM TRANSAKSI PENJUALAN


</strong></div></td>

</tr>

<tr>

<td width="14%">KODE PENJUALAN </td>

<td width="70%" colspan="6"><label>

<input name="txtkodepenjualan" type="text" id="txtkodepenjualan" size="10" maxlength="10"


disabled="disabled" value="<?php echo $kode; ?>" />

</label></td>

</tr>

<tr>

<td>PETUGAS </td>

<td colspan="6"><label>

<input name="txtusername" type="text" id="txtusername" size="10" maxlength="10" />

</label></td>

</tr>

<tr>

<td>PELANGGAN</td>

<td colspan="6"><label>

<select name="cbnamapelanggan" id="cbnamapelanggan">

<?php

include "config/koneksi.php";

$tampil=mysql_query("select namapelanggan from pelanggan");

echo "<option>::Silahkan Pilih::</option>";


while ($tampilkan=mysql_fetch_array($tampil)){

echo "<option value='$tampilkan[0]'>$tampilkan[0]</option>";

?>

</select>

</label></td>

</tr>

<tr>

<td>TANGGAL</td>

<td colspan="6"><label>

<input name="txttanggal" type="date" id="txttanggal" />

</label></td>

</tr>

<tr>

<td colspan="7" bgcolor="#FF0000"><div align="center"><strong>DATA BARANG


</strong></div></td>

</tr>

<tr>

<td colspan="7">

<iframe width="1070" height="300" src="listview.php"> </iframe> </td>

</tr>

<tr>

<td colspan="6"><div align="right">TOTAL</div></td>

<td width="16%"><label>

<?php

include'hitung.php';

?>
<input name="txttotal" type="text" id="txttotal" value="<?php echo $baris['total']; ?>" />

</label></td>

</tr>

<tr>

<td colspan="6"><div align="right">DISKON</div></td>

<td><label>

<input name="txtdiskon" type="text" id="txtdiskon" value="<?php echo $diskon; ?>" />

</label></td>

</tr>

<tr>

<td colspan="6"><div align="right">GRANDTOTAL</div></td>

<td><label>

<input name="txtgrandtotal" type="text" id="txtgrandtotal" value="<?php echo $grandtotal; ?


>" />

</label></td>

</tr>

<tr>

<td height="45" colspan="7"><label>

<div align="center">

<input type="submit" name="Submit3" value="SIMPAN" />

<input type="reset" name="Submit2" value="BATAL" />

</div>

</label>

<label>

<div align="center"></div>

</label></td>

</tr>

</table>

</form>

</body>
</html>

You might also like