39
LAMPIRAN
1. Lampiran Utama
40
41
42
d.
Coding List
index.php
<html> <head>
<title>-TIMATEX-</title>
</head>
<body>
<div class="container"> <div class="row">
<h4 class="page-head-line">Please Login To Enter </h4>
<div class="col-md-6"> <div class="alert alert-login">
<form action="login.php" method="post"> <table align="center">
<tr>
<h4> User ID : </h4>
<input type="text" name="username" required="required" class="form-control" placeholder="Username" /></br>
</tr> <tr>
<h4>Password : </h4>
<input type="password" name="password" required="required" class="form-control"placeholder="Password" />
</br> </tr> <tr>
<div><button id="submit" name="login" class="btn btn-info"> <span class="glyphicon glyphicon-user"></span> Log In </button></div>
</tr>
</table> </form>
</div> </div> </div> </div>
</body> </html>
login.php
<?php
include('db/koneksi.php'); if(isset($_POST['login'])){
$user = mysql_real_escape_string(htmlentities($_POST['username'])); $pass = mysql_real_escape_string(htmlentities($_POST['password']));
$sql = mysql_query("SELECT * FROM user WHERE username='$user' AND password='$pass'") or die(mysql_error());
43
echo '<script language="javascript">alert("User tidak ditemukan!") document.location="index.php";</script>';
}else{
$row = mysql_fetch_assoc($sql); if($row['level'] == 1){
$_SESSION['personalia']=$user;
echo '<script language="javascript">alert("Anda berhasil Login Admin!"); document.location="home_personalia.php";</script>';
}else{
$_SESSION['logistik']=$user;
echo '<script language="javascript">alert("Anda berhasil Login Guest!"); document.location="home_logistik.php";</script>';
} }
} ?>
home_logistik.php
<html> <head>
<title>-TIMATEX-</title>
</head>
<body bgcolor="red"> <header>
<div class="container">
<div class="pull-right" > <div class="dropdown">
<button class="btn btn-success" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
<span class="glyphicon glyphicon-cog"></span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Refresh</a></li> <li role="presentation">
<arole="menuitem" tabindex="-1" href="logout.php">Logout</a></li> </ul>
</div> </section>
</body> </html>
home_personalia.php
<html> <head>
<title>-TIMATEX-</title>
</head>
<body bgcolor="red"> <header>
44
<div class="pull-right" >
<section class="menu-section .dropdown-menu "> <div class="container">
<nav>
<ul class="nav navbar-nav navbar-right"> <li><a href="home_logistik.php">Master</a> <ul>
<li><a href="?page=bagian">Bagian</a></li>
<li><a href="?page=barang">Barang</a></li> </ul>
<li><a href="#">Laporan</a> <ul>
<li><a href=”laporant.php">Pembelian</a></li> <li><a href transaksi-not.php ">Laporan</a></li> </ul>
</li> </ul> </nav>
</div> </section>
</body> </html>
Bagian.php
<html>
<head> </head>
<body> <center>
<div class="container">
<div class="panel panel-default-bagian">
<h4 class="page-head">Daftar Departemen</h4> <div class="col-md-8">
<?php
$p=isset($_GET['act'])?$_GET['act']:null; switch($p){
default:
$dfbagian=mysql_query("select * from bagian"); echo "
<div class='table-responsive'>
<table class='table table-bordered table-hover'> <thead>
<tr>
<td>ID Bagian</td> <td>Nama Bagian</td>
</tr> </thead>
</div> </div>";
45
<td>$d[0]</td> <td>$d[1]</td>
</tr>"; } break; }
?>
</div> </div> </div> </center>
</body> </html>
Barang.php
<html> <head>
<title> TIMATEX </title>
//mengidentifikasikan variabel yang kita gunakan var kode;
var nama; var jumlah; $(function(){
$("#kode").load("proses.php","op=kode"); $("#barang").load("proses.php","op=barang");
//jika ada perubahan di kode barang $("#kode").change(function(){ kode=$("#kode").val();
//tampilkan status loading dan animasinya $("#status").html("loading. . .");
$("#loading").show();
//lakukan pengiriman data $.ajax({
url:"proses.php",
data:"op=ambildata&kode="+kode, cache:false,
success:function(msg){ data=msg.split("|");
//masukan isi data ke masing - masing field $("#nama").val(data[0]);
//hilangkan status animasi dan loading $("#status").html("");
$("#loading").hide(); }
}); });
46
48
<?php
$p=isset($_GET['act'])?$_GET['act']:null; switch($p){
default:
echo'<div class="panel panel-default"> <div class="panel-heading">
<h3>DAFTAR BAGIAN / DEPARTEMEN</h3> </div>
<div class="panel-body">
<div class="table-responsive table-bordered">
<table id="barang" class="table striped bordered table-hover">
<legend>Data Barang</legend> <label>Kode Barang</label>
<select id="kode" class="btn dropdown-toggle"></select>
<input type="text" id="nama" placeholder="Nama Barang" class="span2"> <button id="update" class="btn btn-info"><i class=" fa fa-refresh "></i> Update</button>
<button id="hapus" class="btn btn-danger"><i class=" fa fa-trash "></i> Hapus</button> </br>
<input type="text" id="carinama" placeholder="Cari Barang" class="span2"> br>
<div id="status"></div> <div id="barang"></div>'; break;
case "tambah":
echo'<div class="col-md-6">
<h3> Tambah Data Barang </h3>
<label>Kode Barang</label>
<input type="text" id="kode2"> <span id="pesan"></span> </br>
<label>Nama Barang</label> <input type="text" id="nama" > </br>
<button id="simpan" class="btn btn-primary"><i class=" fa fa-save "></i> Simpan</button>
<a href="?page=barang" class="btn btn-info">Kembali</a> <div id="status">
</div> </div>
</div>'; break;
case "cari":
//untuk menampilkan data yang dicari
$nama=$_POST['carinama']; $cari=mysql_query("select * from barang where nama=$nama");
echo '<table class=table table-hover> <thead>
<tr>
49
</tr> </thead>';
while($r=mysql_fetch_row($cari)){ echo "<tr>
<td>$r[kode]</td>
<td>$r[nama]</td> </tr>";
} break;
} ?> </body> </html>
Proses.php
<?php
include "db/koneksi.php";
$op=isset($_GET['op'])?$_GET['op']:null;
$carinama=isset($_GET['carinama'])?$_GET['carinama']:null; if($carinama==null)
$data=mysql_query("select * from barang"); else
$data=mysql_query("select * from barang WHERE nama LIKE '%$carinama%'");
if($op=='kode'){
echo"<option> Kode Barang </option>"; while($r=mysql_fetch_array($data)){
echo "<option value='$r[kode]'>$r[kode]</option>"; }
}elseif($op=='cari'){
echo'<table id="carinama" class="table table-hover"> <thead>
<tr>
<Td colspan="5"><a href="?page=barang&act=cari" class="btn btn-primary">Cari Barang</a></td>
</tr> <tr>
<td>Kode Barang</td> <td>Nama Barang</td> </tr>
</thead>';
while ($r=mysql_fetch_array($cari)){ echo"<tr>
<td>$r[kode]</td> <td>$r[nama]</td> </tr>";
}
echo "</table>"; }
elseif($op=='barang'){
50
<div class="panel-body">
<div class="table-responsive table-bordered">
<table id="barang" class="table striped bordered table-hover">
<thead> <tr>
<Td colspan="5"><a href="?page=barang&act=tambah" class="btn btn-primary"><i class=" fa fa-plus "> Tambah Barang</a></td>
</tr>
$dt=mysql_query("SELECT * FROM barang where kode='$kode'"); $d=mysql_fetch_array($dt);
echo $d['nama'];
}elseif($op=='ambildata2'){ $nama=$_GET['nama'];
$dt=mysql_query("SELECT * FROM barang where nama LIKE '%$nama%'"); $d=mysql_fetch_array($dt);
echo $d['nama']; }elseif($op=='cek'){ $kd=$_GET['kd'];
$sql=mysql_query("SELECT * FROM barang where kode='$kd'"); $cek=mysql_num_rows($sql);
echo $cek;
}elseif($op=='update'){ $kode=$_GET['kode'];
$nama=htmlspecialchars($_GET['nama']);
51
$nama=htmlspecialchars($_GET['nama']);
$tambah=mysql_query("INSERT INTO barang (kode,nama) VALUES ('$kode','$nama')");
if($tambah){ echo "sukses"; }else{
echo "error"; }
}
elseif($op=='cari'){
echo'<table id="caribarang" class="table table-hover"> <thead>
<tr>
<Td colspan="5"><a href="?page=barang&act=cari" class="btn btn-primary">Cari Barang</a></td>
</tr> <tr>
<td>Kode Barang</td> <td>Nama Barang</td> </tr>
</thead>';
while ($c=mysql_fetch_array($cari)){ echo"<tr>
<td>$c[kode]</td> <td>$c[nama]</td> </tr>";
}
echo "</table>"; }
?>
Transaksi.php
<html> <head>
<title>TIMATEX</title>
<script>
//mendeksripsikan variabel yang akan digunakan var nota;
var tanggal; var id; var nbagian; var kode; var nama; var jumlah;
$(function(){
//meload file pk dengan operator ambil barang dimana nantinya //isinya akan masuk di combo box
$("#kode").load("pk.php","op=ambilbarang");
//meload file pk dengan operator ambil bagian dimana nantinya //isinya akan masuk di combo box
52
//meload isi tabel
$("#barang").load("pk.php","op=barang"); $("#bagian").load("pk.php","op=bagian");
//mengkosongkan input text dengan masing2 id berikut $("#id").val("");
$("#nama").val(""); $("#jumlah").val("");
//jika ada perubahan di kode barang $("#kode").change(function(){ kode=$("#kode").val();
//tampilkan status loading dan animasinya $("#status").html("loading. . .");
$("#loading").show();
//lakukan pengiriman data $.ajax({
url:"proses.php",
data:"op=ambildata&id="+id+"&kode="+kode, cache:false,
success:function(msg){ data=msg.split("|");
//masukan isi data ke masing - masing field $("#id").val(data[1]);
$("#nama").val(data $("#jumlah").val(data[3]
//hilangkan status animasi dan loadin $("#status").html("");
$("#loading").hide();
}); });
//jika tombol tambah di klik $("#tambah").click(function(){ id=$("#id").val();
kode=$("#kode").val(); jumlah=$("#jumlah").val();
if(id=="Id Bagian"){ alert("Id Bagian tidak diisi" exit();
}
else if(kode=="Kode Barang"){ alert("Kode Barang Harus diisi"); exit();
}
else if(jumlah < 1){
alert("Jumlah beli tidak boleh 0"); $("#jumlah").focus();
exit(); }
53
$("#status").html("sedang diproses. . ."); $("#loading").show();
$.ajax({ url:"pk.php",
data:"op=tambah&id="+id+"&kode="+kode+"&nama="+nama+"&jumlah="+jumlah, cache:false,
success:function(msg){ if(msg=="sukses"){
$("#status").html("Berhasil disimpan. . ."); }else{
$("#status").html("ERROR. . ."); }
$("#loading").hide(); $("#nbagian").val(""); $("#nama").val("" $("#jumlah").val("");
$("#id").load("pk.php","op=ambilbagian"); $("#kode").load("pk.php","op=ambilbarang"); $("#barang").load("pk.php","op=barang"); $("#bagian").load("pk.php","op=bagian"); }
}); });
//jika tombol proses diklik $("#proses").click(function(){ nota=$("#nota").val(); tanggal=$("#tanggal").val();
$.ajax({ url:"pk.php",
data:"op=proses¬a="+nota+"&tanggal="+tanggal, cache:false,
success:function(msg){ if(msg=='sukses'){
$("#status").html('Transaksi Pembelian berhasil'); alert('Transaksi Berhasil');
// window.open("notapembelian.php?nonota="+nota, "_blank"); window.location = "home.php?page=pembelian";
exit(); }else{
$("#status").html('Transaksi Gagal'); alert('Transaksi Gagal');
exit(); }
$("#id").load("pk.php","op=ambilbagian"); $("#kode").load("pk.php","op=ambilbarang"); $("#barang").load("pk.php","op=barang"); $("#bagian").load("pk.php","op=bagian"); $("#loading").hide();
$("#nama").val(""); $("#nbagian").val(""); $("#jumlah").val(""); }
54
//ketika kolom cari barang diisi $("#cariid").keyup(function(){ var cariid=$("#cariid").val();
$("#bagian").load("pk.php","op=barang&cariid="+cariid); });
}); </script> </head>
<body>
<div class="container"> <?php
include "db/koneksi.php";
$p=isset($_GET['act'])?$_GET['act']:null; switch($p){
default:
echo "<div class='col-md-6'> <div class='panel panel-default'> <div class='panel-heading NOTA PERMINTAAN </div>
<div class='panel-body'> <div class='table-responsive'> <table class='table'>
<tr>
<td colspan='3'><a href='?page=pembelian&act=tambah' class='btn btn-info'> <i class=' fa fa-pencil '></i> Input Transaksi</a></td>
</tr> <tr>
<td>No.Nota</td> <td>Tanggal</td> <td>Tools</td> </tr>";
$query=mysql_query("select * from permintaan"); while($r=mysql_fetch_array($query)){
echo "<tr> <td><a
href='home_personalia?page=pembelian&act=detail¬a=$r[nonota]'>$r[nonota]</a></td> <td>$r[tanggal]</td>
<td><href='?page=pembelian&act=detail¬a=$r[nonota]'>Cetak Nota</a></td> </tr>";
}
echo"</table>"; break;
case "tambah":
//untuk menambahkan tanggal otomatis $tgl=date('Y-m-d');
//untuk autonumber di nota
$auto=mysql_query("select * from permintaan order by nonota desc limit 1"); $no=mysql_fetch_array($auto);
$angka=$no['nonota']+1;
echo "<div class='navbar-form pull-right'>
55
</div>";
echo'<h4 class="page-head-line">TRANSAKSI</h4> <div class="col-md-6">
<div class="panel panel-default"> <div class="panel-heading"> NOTA PERMINTAAN </div>
<div class="panel-body"> <div class="table-responsive"> <table class="table">
<tr>
<td><label>Kode Barang</label></td>
<td><select id="kode" class=btn btn-default dropdown-toggle></select>  </td> <td><input type="text" id="nama" placeholder="Nama Barang" readonly></td>
</tr>
<tr>
<td><label>Id Bagian </label></td>
<td><select id="id" class=btn btn-default dropdown-toggle></select></td> </tr>
<tr>
<td><input type="text" id="jumlah" placeholder="Jumlah Beli" class="span1">  </td>
<td><button id="tambah" class="btn btn-primary"><i class=" fa fa-plus "></i> Tambah</button></td>
</tr>
<span id="status"></span>
<table id="barang" class="table table-bordered">
</table>
<div class="form-actions">
<button id="proses" class="btn btn-primary"><i class=" fa fa-process "></i>Proses</button> </div>';
break;
case "detail":
echo '<h4 class="page-head-line">TRANSAKSI</h4> ';
$nota=$_GET['nota'];
$query=mysql_query("SELECT
permintaan.nonota,notapermintaan.id,notapermintaan.kode,barang.nama, notapermintaan.jumlah
FROM notapermintaan,permintaan,barang
WHERE permintaan.nonota=notapermintaan.nonota and barang.kode=notapermintaan.kode AND notapermintaan.nonota='$nota'");
$nomor=mysql_fetch_array(mysql_query("select * from permintaan where nonota='$nota'"));
echo "<div class='navbar-form pull-right'>
Nota : <input type='text' value='$nomor[nonota]' disabled> <input type='text' value='$nomor[tanggal]' disabled> </div>";
echo "<a href='?page=pembelian&act=rekap&nonota=".$nota."' class='btn btn-primary'><i class=' fa fa-edit '></i> Rekap Nota</a>
56
echo "<div class='col-md-6'> <div class='panel panel-default'> <div class='panel-heading'> NOTA PERMINTAAN </div>
<div class='panel-body'> <div class='table-responsive'> <table class='table'>
<thead> <tr>
<td>Id Bagian </td> <td>Kode Barang</td> <td>Nama</td> <td>Jumlah</td> </tr>
</thead>";
while($r=mysql_fetch_row($query)){ echo "<tr>
<td>$r[1]</td> <td>$r[2]</td> <td>$r[3]</td> <td>$r[4]</td> </tr>";
}
break ;
case "filter":
echo "<h4 class='page-head-line'>TRANSAKSI</h4> ";
$auto=mysql_query("select * from permintaan order by nonota "); $no=mysql_fetch_array($auto);
$nota=$no['nonota']+1;
$nomrekap=mysql_fetch_array(mysql_query("select * from permintaan where nonota='$nota'"));
$filter=mysql_query("SELECT
permintaan.nonota,notapermintaan.id,notapermintaan.kode,barang.nama, notapermintaan.jumlah
FROM notapermintaan,permintaan,barang
WHERE permintaan.nonota=notapermintaan.nonota and barang.kode=notapermintaan.kode AND notapermintaan.nonota='$nota'");
echo "<div class='navbar-form pull-right'>
Nota : <input type='text' value='$nota[nonota]' disabled> <input type='text' value='$nomrekap[tanggal]' disabled> </div>";
echo "<div class='col-md-6'> <div class='panel panel-default'> <div class='panel-heading'> NOTA PERMINTAAN </div>
<div class='panel-body'> <div class='table-responsive'> <table class='table'>
57
<tr>
<td> Id </td>
<td>Kode Barang</td> <td>Nama</td> <td>Total Jumlah</td> </tr>
</thead>";
while($f=mysql_fetch_row($filter)){ echo "<tr>
<td>$f[1]</td> <td>$f[2]</td> <td>$f[3]</td> <td>$f[4]</td> </tr>";
}
echo "<a href='?page=pembelian&act=detail¬a=$f[nonota]' class='btn btn-primary'>ALL</a>";
break;
case "rekap":
echo "<h4 class='page-head-line'>TRANSAKSI</h4> ";
$nota=$_GET['nonota'];
$query=mysql_query("SELECT notapermintaan.kode, barang.nama, SUM(notapermintaan.jumlah) as TotalJumlah
FROM notapermintaan,permintaan,barang
WHERE permintaan.nonota=notapermintaan.nonota AND barang.kode=notapermintaan.kode AND notapermintaan.nonota=".$nota."
GROUP BY notapermintaan.kode");
$nomrekap=mysql_fetch_array(mysql_query("select * from permintaan where nonota=".$nota));
echo "<div class='navbar-form pull-right'>
Nota : <input type='text' value='".$nomrekap['nonota']."' disabled> <input type='text' value='".$nomrekap['tanggal']."' disabled> </div>";
echo "<div class='col-md-6'> <div class='panel panel-default'> <div class='panel-heading'> NOTA PERMINTAAN </div>
<div class='panel-body'> <div class='table-responsive'> <table class='table'>
<tr>
<td>Kode Barang</td> <td>Nama</td> <td>Total Jumlah</td> </tr>
</thead>";
while($r=mysql_fetch_row($query)){ echo "<tr>
58
<td>$r[2]</td> </tr>";
}
echo "</table>";
break; }
?> </div> </body> </html>
Pk.php
<?php
include "db/koneksi.php";
$op=isset($_GET['op'])?$_GET['op']:null;
$cariid=isset($_GET['cariid'])?$_GET['cariid']:null; if($cariid==null)
$data=mysql_query("select * from notapermintaan"); else
$data=mysql_query("select * from notapermintaan WHERE id LIKE '%$cariid%'");
if($op=='ambilbagian'){
$data=mysql_query("select * from bagian"); echo "<option>Id Bagian</option>"; while($r=mysql_fetch_array($data)){
echo "<option value='$r[id]'>$r[id]</option>"; }
}elseif($op=='ambilbarang'){
$data=mysql_query("select * from barang"); echo"<option>Kode Barang</option>"; while($r=mysql_fetch_array($data)){
echo "<option value='$r[kode]'>$r[kode]</option>"; }
}elseif($op=='ambildata'){ $kode=$_GET['kode'];
$dt=mysql_query("select * from barang where kode='$kode'"); $d=mysql_fetch_array($dt);
echo $d['nama']; }elseif($op=='ambildata'){
$id=$_GET['id'];
$bt=mysql_query("select * from bagian where id='$id'"); $b=mysql_fetch_array($bt);
echo $b['nbagian']; }elseif($op=='barang'){
$brg=mysql_query("select * from nota"); echo "<thead>
<tr>
<td>Id Barang </td> <td>Kode Barang</td>
<td>Nama</td>
<td>Jumlah Beli</td>
<td>Tools</td> </tr>
59
while($r=mysql_fetch_array($brg)){ echo "<tr>
<td>$r[id]</td> <td>$r[kode]</td>
<td>$r[nama]</td>
<td><input type='text' name='jum' value='$r[jumlah]' class='span2'></td> <td><a href='pk.php?op=hapus&kode=$r[kode]' id='hapus'>Hapus</a></td> </tr>";
$tambah=mysql_query("INSERT into nota (id,kode,nama,jumlah) values ('$id','$kode','$nama','$jumlah')");
$del=mysql_query("delete from nota where kode='$kode'"); if($del){
echo
"<script>window.location='home_personalia.php?page=pembelian&act=tambah';</script>"; }else{
echo "<script>alert('Hapus Data Berhasil');
window.location='home_personalia.php?page=pembelian&act=tambah';</script>"; }
}elseif($op=='proses'){ $nota=$_GET['nota']; $tanggal=$_GET['tanggal'];
$to=mysql_fetch_array(mysql_query("select sum(jumlah) as total from nota")); $tot=$to['total'];
$simpan=mysql_query("insert into permintaan(nonota,tanggal) values ('$nota','$tanggal')");
if($simpan){
$query=mysql_query("select * from nota"); while($r=mysql_fetch_row($query)){
60
Laporan.php<html> <head>
//mendeksripsikan variabel yang akan digunakan var nota;
var tanggal; var kode; var nama; var jumlah; var tjumlah; var harga; var tharga; var total;
$(function(){
//meload file lap dengan operator ambil harga dimana nantinya //isinya akan masuk di combo box
$("#harga").load("lap.php","op=ambilharga");
//meload isi tabel
$("#harga").load("lap.php","op=harga");
//mengkosongkan input text dengan masing2 id berikut $("#kode").val("");
$("#nama").val(""); $("#jumlah").val("");
//jika ada perubahan di kode barang $("#kode").change(function(){ kode=$("#kode").val();
//tampilkan status loading dan animasinya $("#status").html("loading. . .");
$("#loading").show();
//lakukan pengiriman data $.ajax({
url:"proses.php",
data:"op=ambildata&kode="+kode+"&tjumlah="+tjumlah", cache:false,
success:function(msg){ data=msg.split("|");
//masukan isi data ke masing - masing field $("#kode").val(data[1]);
$("#nama").val(data[0]); $("#jumlah").val(data[3]);
//hilangkan status animasi dan loading $("#status").html("");
$("#loading").hide(); }
61
});
//jika tombol hitung di klik $("#hitung").click(function(){ kode=$("#kode").val(); tjumlah=$("#tjumlah").val(); harga=$("#harga").val(); tharga=$("#tharga").val(); total=$("#tharga").val();
if(harga=="Harga Beli"){ alert("Harga tidak diisi"); exit();
}
else if(harga < 100){
alert("Bukan Jumlah Minimum"); exit();
}
nama=$("#nama").val();
$("#status").html("sedang diproses. . ."); $("#loading").show();
$.ajax({ url:"lap.php",
data:"op=hitung&kode="+kode+"&nama="+nama+"&jumlah="+jumlah, cache:false,
success:function(msg){ if(msg=="sukses"){
$("#status").html("Berhasil disimpan. . ."); }else{
$("#status").html("ERROR. . ."); }
$("#loading").hide(); $("#nama").val(""); $("#jumlah").val("");
$("#kode").load("lap.php","op=ambilbarang"); $("#barang").load("lap.php","op=barang"); $("#harga").load("lap.php","op=ambilharga"); }
}); });
//jika tombol proses diklik $("#proses").click(function(){ nota=$("#nota").val(); tanggal=$("#tanggal").val();
$.ajax({ url:"lap.php",
data:"op=proses¬a="+nota+"&tanggal="+tanggal, cache:false,
success:function(msg){ if(msg=='sukses'){
$("#status").html('Transaksi Pembelian berhasil'); alert('Transaksi Berhasil');
62
echo "<div class='col-md-6'> <div class='panel panel-default'> <div class='panel-heading'>
$query=mysql_query("select * from permintaan"); while($r=mysql_fetch_array($query)){
echo "<tr>
<td>$r[nonota]</td> <td>$r[tanggal]</td>
<td><a href='?page=laporan&act=detail&n=$r[nonota]'>Cetak Nota</a>|| <a href='?page=laporan&act=hitung¬a=$r[nonota]'>Input Harga</a>|| <td><a href='?page=pembelian&act=detail¬a=$r[nonota]'>Detail</a></td> </td>
</tr>"; }
63
break; case "hapus":
include("model_barang.php"); $nnota = $_GET['nota']; $brg = new model_barang(); $hsl = $brg->deleteLaporan($nnota); if($hsl=="T"){
?>
<script language="JavaScript">alert('Berhasil Hapus Data'); document.location='index.php?page=laporan'</script> <?php
} else { ?>
<script language="JavaScript">alert('Data Gagal Dihapus!'); document.location='index.php?page=laporan'</script> <?php
} break;
case "hitung":
if(!isset($_POST['hitung'])){
//untuk menambahkan tanggal otomatis $tgl=date('Y-m-d');
//untuk autonumber di nota
$auto=mysql_query("select * from permintaan order by nonota desc limit 1"); $no=mysql_fetch_array($auto);
$angka=$no['nonota'];
/* $query=mysql_query("SELECT permintaan.nonota,notapermintaan.kode,barang.nama, SUM(notapermintaan.jumlah), no
FROM notapermintaan,permintaan,barang
WHERE permintaan.nonota=notapermintaan.nonota and barang.kode=notapermintaan.kode AND notapermintaan.nonota='$angka'
GROUP BY permintaan.nonota, notapermintaan.kode"); */
$nnota = $_GET['nota'];
$query=mysql_query("SELECT n.nonota,n.kode,b.nama,n.jumlah, n.no FROM notapermintaan n
JOIN barang b ON (n.kode = b.kode) WHERE n.nonota = '$nnota'");
echo "<div class='navbar-form pull-right'>
No. Nota : <input type='text' id='nota' value='$angka' readonly > <input type='text' id='tanggal' value='$tgl' readonly>
</div>";
echo "<div class='col-md-6'> <div class='panel panel-default'> <div class='panel-heading'> BON PEMBELIAN </div>
<div class='panel-body'> <div class='table-responsive'> <table class='table'>
64
<thead> <tr>
<td colspan='3'><input type='submit' class='btn btn-primary' name='hitung' value='Hitung'/>
</td> </tr> <tr>
<td>Kode Barang</td> <td>Nama</td> <td>Total Jumlah</td> <td>Harga </td> <td>Total Harga </td> </tr>
</thead>";
while($r=mysql_fetch_row($query)){ echo "<tr>
<input type='text' name='no_nota' hidden='' value='$r[0]'> <td>$r[1]</td>
<td>$r[2]</td> <td>$r[3]</td>
<td><input type='text' name='Harga[]' id='harga' placeholder='Harga Beli' class='span1'> <input type='text' value='$r[4]' name='no[]' hidden=''>
</td> </tr>"; }
echo "<tr>
<td colspan='4'><h4 align='right'>Total</h4></td> <td>
</tr>
</table></form>"; }else{
echo "<legend>Nota Pembelian</legend>";
$auto=mysql_query("select * from permintaan order by nonota desc limit 1"); $no=mysql_fetch_array($auto);
$nota=$no['nonota'];
$no_nota = $_POST['no_nota'];
$query9=mysql_query("SELECT permintaan.nonota,notapermintaan.kode,barang.nama, SUM(notapermintaan.jumlah)
FROM notapermintaan,permintaan,barang
WHERE permintaan.nonota=notapermintaan.nonota and barang.kode=notapermintaan.kode AND notapermintaan.nonota='$no_nota'
GROUP BY permintaan.nonota, notapermintaan.kode");
$query2=mysql_query("SELECT n.nonota,n.kode,b.nama,n.jumlah, n.no FROM notapermintaan n
JOIN barang b ON (n.kode = b.kode) WHERE n.nonota = '1'");
$nomor=mysql_fetch_array(mysql_query("select * from permintaan where nonota='$nota'")); $Harga = $_POST['Harga'];
$no = $_POST['no'];
echo "<div class='navbar-form pull-right'>
65
</div>";
echo "<div> <a href='?page=laporan&act=detail&n=$no_nota' class='btn btn-primary'>Laporkan</a></div>";
echo "<div class='col-md-6'> <div class='panel panel-default'> <div class='panel-heading'> BON PEMBELIAN </div>
<div class='panel-body'> <div class='table-responsive'> <table class='table'>
<thead> <tr>
<td>Kode Barang</td> <td>Nama</td> <td>Total Jumlah</td> <td>Harga </td> <td>Total Harga </td> </tr>
</thead>"; $i=0; $total = 0;
while($r=mysql_fetch_row($query9)){ $subtotal = $r[3]*$Harga[$i];
echo "<tr> <td>$r[1]</td> <td>$r[2]</td> <td>$r[3]</td>
<td>".$Harga[$i]."</td> <td>".$subtotal."</td> </tr>";
include("db/koneksi.php");
$query6 = "update notapermintaan set harga='$Harga[$i]', total='$subtotal' WHERE no='$no[$i]'"; $hasil = mysql_query($query6);
$total+=$subtotal; $i++;
}
echo "<tr>
<td colspan='4'><h4 align='right'>Total : </h4></td> <td><h4>".$total."</h4></td>
</tr> </table>"; }
break;
case "detail":
66
//untuk autonumber di nota
echo "<legend>Nota Pembelian</legend>";
$auto=mysql_query("select * from permintaan order by nonota desc limit 1"); $no=mysql_fetch_array($auto);
$nota=$no['nonota']; $n = $_GET['n']; /*
$query=mysql_query("SELECT permintaan.nonota,notapermintaan.kode,barang.nama, notapermintaan.jumlah,barang.harga, notapermintaan.total
FROM notapermintaan,permintaan,barang
WHERE permintaan.nonota=notapermintaan.nonota and barang.kode=notapermintaan.kode AND notapermintaan.nonota='$nota'
GROUP BY permintaan.nonota, notapermintaan.kode"); */
$query=mysql_query("SELECT n.nonota, n.kode, b.nama, n.jumlah, n.harga, n.total,n.id from notapermintaan n
JOIN barang b ON (n.kode = b.kode) where nonota = '$n'");
$nomor=mysql_fetch_array(mysql_query("select * from permintaan where nonota='$n'"));
echo "<div class='navbar-form pull-right'>
Nota : <input type='text' value='$nomor[nonota]' disabled> <input type='text' value='$nomor[tanggal]' disabled> </div>";
echo "<div class='panel-body'>
<table class='table table-striped table-bordered '>
<thead>
<tr class='warning'> <td>Kode Barang</td> <td>Nama</td> <td>Total Jumlah</td> <td>Harga Satuan</td> <td>Total Harga </td> </tr>
</thead> </div> </div>"; $i=0; $total = 0;
while($r=mysql_fetch_row($query)){ echo "<tr class='info'>
<td>$r[1]</td> <td>$r[2]</td> <td>$r[3]</td> <td>$r[4]</td> <td>$r[5]</td>
</tr>";
$total = $total + $r[5]; }
echo "<tr class='warning'>
67
<td><h4>".$total."</h4></td> </tr>
</table>";
break;
} ?> </div> </body> </html>
Lap.php
<?php
include "db/koneksi.php";
$op=isset($_GET['op'])?$_GET['op']:null;
if($op=='ambilbarang'){
$data=mysql_query("select * from barang");
}elseif($op=='harga'){
$hrg=mysql_query("select * from transaksi"); echo "<thead>
<tr>
<td>Kode Barang</td> <td>Nama</td> <td>Jumlah Total</td> <td>Harga</td> <td>Harga Total</td> <td>Tools</td> </tr>
</thead>";
while($r=mysql_fetch_array($hrg)){ echo "<tr>
<td>$r[kode]</td> <td>$r[nama]</td> <td>$r[jumlah]</td>
<td><input type='text' name='har' value='$r[harga]' class='span2'></td> <td><a href='lap.php?op=hapus&kode=$r[kode]' id='hapus'>Hapus</a></td> </tr>";
}
}elseif($op=='hitung'){ $kode=$_GET['kode']; $nama=$_GET['nama']; $jumlah=$_GET['jumlah']; $harga=$_GET['harga'];
$hitung=mysql_query("INSERT into nota (kode,nama,jumlah,harga) values ('$kode','$nama','$jumlah','$harga')");
if($hitung){ echo "sukses"; }else{
echo "ERROR"; }
68
$tanggal=$_GET['tanggal'];
$to=mysql_fetch_array(mysql_query("select sum(jumlah) as total from nota")); $tot=$to['total'];
$simpan=mysql_query("insert into permintaan(nonota,tanggal) values ('$nota','$tanggal')");
if($simpan){
$query=mysql_query("select * from nota"); while($r=mysql_fetch_row($query)){
mysql_query("insert into notapermintaan(nonota,id,kode,jumlah) values('$nota','$r[0]','$r[1]','$r[3]')");
}
//hapus seluruh isi tabel nota mysql_query("truncate table nota"); echo "sukses";
}else{
echo "ERROR"; }
} ?>
Transaksi-not.php
<?php session_start(); unset($_SESSION['login']); session_destroy();
print '<script>alert("Hanya dapat diakses bagian Personalia !!!")</script>'; print '<meta http-equiv="refresh" content="0;url=home_logistik.php" />'; ?>
Laporan-not.php
<?php session_start(); unset($_SESSION['laporan']); session_destroy();
print '<script>alert("Hanya dapat diakses bagian Logistik !!!")</script>'; print '<meta http-equiv="refresh" content="0;url=home_personalia.php" />'; ?>
Logout.php
<?php session_start(); unset($_SESSION['login']); session_destroy();
print '<script>alert("Anda Telah Logout !!!")</script>';