COVER
DAFTAR ISI............................................................................................................ii
DAFTAR GAMBAR..............................................................................................iii
DAFTAR TABEL...................................................................................................vi
BAB I PENDAHULUAN
A. Latar Belakang………………………………………………………
B. Manfaat/fungsi aplikasi……………………………………………...
C. Sasaran pemasaran aplikasi………………………………………….
D. Fitur / fasilitas aplikasi………………………………………………
E. Kelebihan aplikasi…………………………………………………...
F. Kekurangan aplikasi…………………………………………………
1
DAFTAR GAMBAR
2
DAFTAR TABEL
3
BAB I
PENDAHULUAN
1. Latar Belakang
Pendataan barang merupakan faktor penting dalam suatu perusahaan
yang memiliki tingkat rutinitas yang tinggi dan pengelolaan data yang
tersusun rapih dan teratur. Sistem informasi digunakan untuk
mengumpulkan, mengolah, dan menyediakan informasi. data dan informasi
yang diperoleh suatu instansi terus-menerus bertambah banyak, sehingga
tidak mudah untuk diolah dengan cara manual. Oleh karenanya sangat
diperlukan sistem informasi berbasis komputer bagi setiap instansi
pemerintah agar dapat memudahkan proses manajemen data dengan baik.
Aplikasi sistem informasi berbasis komputer berupa software program
pendataan barang yang dapat digunakan untuk perekapan stok barang yang
masih tersedia yang diharapkan dapat lebih efisien dibandingkan dengan
cara pencatatan data secara manual. Dengan ini penulis akan mencoba
membuat aplikasi sistem informasi pendataan barang dengan menggunakan
Sublime Text 3 dan Xampp 5.6.33 sebagai server data base.
4
5. Kelebihan Aplikasi
1. Tampilan web yang minimalis dan dinamis
2. Memiliki Login multiuser
6. Kekurangan Aplikasi
1. Harus memilik koneksi internet
5
BAB II
LAPORAN KERJA PROJEK
1. Alur Navigasi / Flowchart
6
2. Alat dan bahan
A. XAMPP Version: 5.6.28
Software Requirements:
a) Windows 2008, 2012, Vista, 7, 8 (Important: XP or 2003 not
supported
Hardware Requiresments:
a) 64 MB RAM (RECOMMENDED)
b) 350 MB free fixed disk
7
B. Sublime Text 3
Software Requirements:
a) Windows 7 SP1 (x86 and x64)
b) Windows 8 (x86 and x64)
c) Windows Server 2008 R2 SP1 (x64)
d) Windows Server 2012 (x64)
Hardware Requirements:
a) 1.6 GHz or faster processor
b) 1 GB of RAM (1.5 GB if running on a virtual machine)
c) 10 GB of available hard disk space
d) 600 MB of available hard disk space (language pack)
e) 5400 RPM hard drive
f) DirectX 9-capable video card running at 1024 x 768 or higher
display resolution
A. Langkah Kerja
1. Pembuatan Database
a. Buka Xampp di Start → All Programs → Xampp→ Xampp Control
Panel
8
b. Klik Start apache & mysql lalu klik admin di mysql
9
Gambar 3.8 Buat database baru
e. Akan muncul tampilan seperti berikut isi nama “Basis Data” dengan
nama “inven2” lalu kelik buat
f. Akan muncul tampilan berikut lalu nama tabel dengan “admin” dengan
3 kolom
10
Gambar 3.10 Tampilan buat tabel
11
Gambar 3.11 Simpan Table
k. Beri nama tabel dengan barang lalu isi field seperti di bawah
Tabel 3.2 Field dari table barang
Nama Tipe
12
Idbarang Int (11) Primary key
Nama_barang Varchar (50)
Jenis_barang Varchar (50)
Stok_barang Varchar (50)
l. Jika sudah kelik simpan seperti di gambar 3.12 lalu kelik baru di dalam
database lagi seperti di gamabar 3.13 dan nama tabel nya dengan nama
history lalu isi setiap field seperti dibawah berikut
m. Jika sudah kelik selesai seperti di gambar 3.(lupa) dan biarkan dulu di
dekstop
2. Persiapan Awal Pembuatan Aplikasi
a. Buka Sublime text3 di Menu → All Programs → Sublime text3
.
13
Gambar 3.14 Buka Sublime Text 3 dari Menu
14
3. Pembuatan CSS
a. Sebelum membuat form login buatlah css untuk memperbagus
tampilan halaman web
b. Masukan script di bawah berikut kedalam sublime text3.
Tabel 3.4 script dari css
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
background: transparent;
border: 0;
margin: 0;
padding: 0;
vertical-align: baseline;
text-decoration: none;
color: black;
}
ol, ul {
list-style: none;
}
body{
line-height: 1.5;
margin: auto;
float: auto;
font-family: arial;
font-weight: lighter;
15
}
.left{
float: left;
}
.right{
float: right;
}
.text-left{
text-align: left;
}
.text-right{
text-align: right;
}
img{
max-width: 100%;
max-height: 100%;
}
.button{
padding: 10px;
border-radius: 5px;
background: transparent;
text-align: center;
border: solid 3px #1DCFAB;
transition: all 500ms;
float: left;
margin-right: 15px;
margin-bottom: 15px;
}
.button:hover{
background: #1DCFAB;
color: white;
16
}
p{
margin-bottom: 15px;
font-size: 18px;
}
table {
border-collapse: collapse;
width: 100%;
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
margin-top: 20px;
float: left;
}
th, td {
text-align: left;
padding: 8px;
border-bottom: 1px solid #ddd;
}
th {
background-color: #1DCFAB;
color: white;
}
.paging-nav {
text-align: right;
padding-top: 2px;
margin-top: 5px;
float: right;
}
.paging-nav a {
margin: auto 1px;
text-decoration: none;
17
display: inline-block;
padding: 1px 7px;
background: #1DCFAB;
color: white;
border-radius: 3px;
}
.paging-nav .selected-page {
background: #17A387;
font-weight: bold;
}
input,select{
padding: 10px;
border: solid 1px #dcdcdc;
border-radius: 5px;
border: solid 1px #dcdcdc;
transition: box-shadow 0.3s, border 0.3s;
background: white;
width: 50%;
margin-bottom: 15px;
}
input[type="submit"]{
width: 15%;
}
input[type="text"]:focus,select:focus{
border: solid 1px #dcdcdc;
box-shadow: 0 0 5px 1px #969696;
}
a.table:hover{
text-decoration: underline;
}
header{
18
width: 98%;
padding: 1%;
float: left;
background: #1DCFAB;
}
aside{
padding: 25px 0 25px 0;
background: #DEDEDE;
width: 20%;
float: left;
}
li.side{
padding: 15px;
text-align: center;
transition: background 500ms;
}
li.side:hover{
background: #1DCFAB;
}
li.active{
background: #1DCFAB;
}
section.content{
padding: 3%;
width: 74%;
float: left;
}
div.container{
float: left;
width: 100%;
}
19
div.empty{
float: left;
margin-bottom: 20px;
width: 100%;
}
div.data{
padding: 10px 30px 10px 30px;
border-radius: 5px;
float: left;
background: #1AB898;
color: white;
}
h1.content{
font-size: 36px;
font-weight: lighter;
}
form.login{
width: 30%;
padding: 30px;
background: #DEDEDE;
float: left;
position: relative;
margin-top: 10%;
left: 30%;
right: 30%;
text-align: center;
border-radius: 10px;
}
h1.login{
font-size: 32px;
font-weight: lighter;
20
}
input.login{
padding: 10px;
float: left;
width: 100%;
border-radius: 5px;
border: none;
margin-bottom: 15px;
}
.button-login{
border: solid 3px gray;
}
.button-login:hover{
background: gray;
}
@media screen and (max-width: 720px) {
form.login{
width: 70%;
padding: 5%;
left: 10%;
right: 10%;
}
aside{
width: 100%;
}
section.content{
width: 94%;
overflow: auto;
}
input,input[type="submit"],select,label{
width: 100%;
21
}
}
22
}
$MySQLi_CON->close();
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>STOK | LOGIN</title>
</head>
<body>
<form class="login" method="post">
<h1 class="login">Log In</h1>
<?php
if(isset($msg)){
echo "<p>".$msg."</p>";
}
?>
<input type="text" class="login" name="user"
placeholder="Username" required/>
<input type="password" class="login" name="pass"
placeholder="Password" required/>
<input type="submit" class="button button-login" value="Login"
name="btn-login" style="float: none;margin: 0 auto;"/>
</form></body></html>
23
session_destroy();
header('Location: login.php');
exit;
?>
24
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>STOK</title>
</head>
<body>
<header>
<div class="left">
STOK BARANG
</div>
<div class="right">
Hi , <?php echo htmlentities($username) ?> |
<a href="logout.php">Logout</a>
</div>
</header>
<aside>
<ul class="side">
<li class="side active">Home</li>
<a href="tab-barang.php"><li class="side">Nama Barang</li></a>
<a href="tab-stok-barang.php"><li class="side">Stok Barang</li></a>
<a href="tab-history.php"><li class="side">History</li></a></ul>
</aside>
<section class="content">
<h1 class="content">STOK BARANG</h1>
<p>Stok barang</p>
<div class="container">
<a href="tab-barang.php"><div class="button">Tabel
Barang</div></a>
</div>
<div class="container"><div class="data">
25
Jumlah Data Tabel Barang <br>
<p style="text-align: center;font-size: 24px;color: white;margin:
0;"><?php echo $tablebarangrow; ?></p>
</div></div>
<div class="empty"></div>
<div class="container">
<a href="tab-history.php"><div class="button">Tabel
History</div></a>
</div>
<div class="container">
<div class="data">Jumlah Data History <br>
<p style="text-align: center;font-size: 24px;color: white;margin:
0;"><?php echo $tablehistoryrow; ?></p>
</div></div>
</section>
<?php $MySQLi_CON->close(); ?></body>
</html>
26
$sql = "SELECT * FROM user WHERE
user_id=".$_SESSION['userSession'];
$userquery = $MySQLi_CON->query($sql);
$userRow = $userquery->fetch_object();
$username = $userRow->username;
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="application/javascript" src="jquery-2.1.3.js"></script>
<script type="application/javascript" src="jquery-ui.js"></script>
<script type="application/javascript" src="paging.js"></script>
<script>
$(document).ready(function() {
$('#tableData').paging({
limit:10
});
});
</script><title>STOK | NAMA BARANG</title>
</head>
<body>
<header>
<div class="left">
STOK BARANG
</div>
<div class="right">
Hi , <?php echo htmlentities($username) ?> |
<a href="logout.php">Logout</a>
</div>
</header>
27
<aside>
<ul class="side">
<a href="index.php"><li class="side">Home</li></a>
<a href="tab-barang.php"><li class="side active">Nama
Barang</li></a>
<a href="tab-stok-barang.php"><li class="side">Stok Barang</li></a>
<a href="tab-history.php"><li class="side">History</li></a>
</ul>
</aside>
<section class="content">
<h1 class="content">Tabel Barang</h1>
<p>Menampilkan data tabel barang</p>
<a href="tab-barang-tambah.php"><div class="button">Tambah
Data</div></a>
<p style="float: left;width: 100%;">Filter dalam menampiklan
data</p>
<form method="POST" style="width: 100%;float: left;">
<select name="filter" onchange="this.form.submit()">
<option disabled selected>Filter</option>
<option value="remove">Hilangkan Filter</option>
<?php
$filterbarang = "SELECT * FROM barang";
$filterresult = $MySQLi_CON->query($filterbarang);
while ($filterrow = $filterresult->fetch_object()) {
echo "<option value=\"{$filterrow->jenis_barang}\">";
echo $filterrow->jenis_barang;
echo "</option>";
}?>
</select>
</form>
<?php
28
if(isset($_POST["filter"])){
if($_POST["filter"] == "remove"){
$tablebarang = "SELECT * FROM barang";
}
else{
$tablebarang = "SELECT * FROM barang WHERE jenis_barang IN
('".$_POST["filter"]."')";
}
}
else{
$tablebarang = "SELECT * FROM barang";
}
if ($result = $MySQLi_CON->query($tablebarang))
{
if ($result->num_rows > 0)
{
echo "<table id='tableData'>";
echo "<tr><th>ID</th><th>Nama Barang</th><th>Jenis
Barang</th><th></th><th></th></tr>";while ($row = $result-
>fetch_object())
{
echo "<tr>";
echo "<td>" . $row->idbarang . "</td>";
echo "<td>" . $row->nama_barang . "</td>";
echo "<td>" . $row->jenis_barang . "</td>";
echo "<td><a class='table'href='tab-barang-edit.php?id=" . $row-
>idbarang . "'>Ubah</a></td>";
echo "<td><a class='table'onclick='return
confirmDelete(this);'href='tab-barang-del.php?id=" . $row->idbarang .
"'>Hapus</a></td>";
echo "</tr>";
29
}echo "</table>";
}
else{
echo "Tidak ada yang dapat ditampilkan !!!";
}
}
else{
echo "Error: " . $MySQLi_CON->error;}?>
</section></body><script>
function confirmDelete(link) {
if (confirm("Data ini akan dihapus ?")) {
doAjax(link.href, "POST"); // doAjax needs to send the "confirm"
field}
return false;}
</script><?php $MySQLi_CON->close(); ?>
</html>
30
$userquery = $MySQLi_CON->query($sql);
$userRow = $userquery->fetch_object();
$username = $userRow->username;
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="application/javascript" src="jquery-2.1.3.js"></script>
<script type="application/javascript" src="jquery-ui.js"></script>
<script type="application/javascript" src="paging.js"></script>
<script>
$(document).ready(function() {
$('#tableData').paging({
limit:10
});
});
</script><title>STOK | STOK BARANG</title>
</head>
<body>
<header>
<div class="left">
STOK BARANG
</div>
<div class="right">
Hi , <?php echo htmlentities($username) ?> |
<a href="logout.php">Logout</a></div>
</header>
<aside>
<ul class="side">
<a href="index.php"><li class="side">Home</li></a>
31
<a href="tab-barang.php"><li class="side">Nama Barang</li></a>
<a href="tab-stok-barang.php"><li class="side active">Stok
Barang</li></a>
<a href="tab-history.php"><li class="side">History</li></a>
</ul>
</aside>
<section class="content">
<h1 class="content">Tabel Stok Barang</h1>
<p>Menampilkan data stok barang</p>
<p style="float: left;width: 100%;">Filter dalam menampiklan
data</p>
<form method="POST" style="width: 100%;float: left;">
<select name="filter" onchange="this.form.submit()">
<option disabled selected>Filter</option>
<option value="remove">Hilangkan Filter</option>
<?php
$filterbarang = "SELECT * FROM barang";
$filterresult = $MySQLi_CON->query($filterbarang);
while ($filterrow = $filterresult->fetch_object()) {
echo "<option value=\"{$filterrow->jenis_barang}\">";
echo $filterrow->jenis_barang;
echo "</option>";
}
?>
</select>
</form>
<?php
if(isset($_POST["filter"])){
if($_POST["filter"] == "remove"){
$tablebarang = "SELECT * FROM barang";
}
32
else{
$tablebarang = "SELECT * FROM barang WHERE jenis_barang IN
('".$_POST["filter"]."')";
}
}
else{
$tablebarang = "SELECT * FROM barang";
}
if ($result = $MySQLi_CON->query($tablebarang))
{
if ($result->num_rows > 0)
{
echo "<table id='tableData'>";
echo "<tr><th>ID</th><th>Nama Barang</th><th>Jenis
Barang</th><th>Stok
Barang</th><th></th><th></th></tr></th></tr>";
while ($row = $result->fetch_object())
{
echo "<tr>";
echo "<td>" . $row->idbarang . "</td>";
echo "<td>" . $row->nama_barang . "</td>";
echo "<td>" . $row->jenis_barang . "</td>";
echo "<td>" . $row->stok_barang . "</td>";
echo "<td><a class='table'href='tab-tambah-stok.php?id=" . $row-
>idbarang . "'>Tambah Stok</a></td>";
echo "<td><a class='table'href='tab-kurangi-stok.php?id=" . $row-
>idbarang . "'>Kurangi Stok</a></td>";
echo "</tr>";
}
echo "</table>";
}
33
else
{
echo "Tidak ada yang dapat ditampilkan !!!";
}
}
else
{
echo "Error: " . $MySQLi_CON->error;
}
?>
</section>
</body><?php $MySQLi_CON->close(); ?>
</html>
34
$userquery = $MySQLi_CON->query($sql);
$userRow = $userquery->fetch_object();
$username = $userRow->username;
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="application/javascript" src="jquery-2.1.3.js"></script>
<script type="application/javascript" src="jquery-ui.js"></script>
<script type="application/javascript" src="paging.js"></script>
<script>
$(document).ready(function() {
$('#tableData').paging({
limit:10
});
});
</script><title>STOK | HISTORY</title>
</head>
<body>
<header>
<div class="left">
STOK BARANG
</div>
<div class="right">
Hi , <?php echo htmlentities($username) ?> |
<a href="logout.php">Logout</a>
</div>
</header>
<aside>
<ul class="side">
35
<a href="index.php"><li class="side">Home</li></a>
<a href="tab-barang.php"><li class="side">Nama Barang</li></a>
<a href="tab-stok-barang.php"><li class="side">Stok
Barang</li></a>
<a href="tab-history.php"><li class="side active">History</li></a>
</ul>
</aside>
<section class="content">
<h1 class="content">History</h1>
<p>Menampilkan history operasi yang dilakukan</p>
<?php
$tablehistory = "SELECT * FROM history";
if ($result = $MySQLi_CON->query($tablehistory))
{
if ($result->num_rows > 0)
{
echo "<table id='tableData'>";
echo "<tr><th>ID</th><th>Nama Barang</th><th>Jenis
Barang</th><th>Kegiatan</th><th></th>";
while ($row = $result->fetch_object())
{
echo "<tr>";
echo "<td>" . $row->idhistory . "</td>";
echo "<td>" . $row->nama_barang . "</td>";
echo "<td>" . $row->jenis_barang . "</td>";
echo "<td>" . $row->kegiatan . "</td>";
echo "<td><a class='table'onclick='return
confirmDelete(this);'href='tab-history-del.php?id=" . $row->idhistory
. "'>Hapus</a></td>";
echo "</tr>";
}
36
echo "</table>";
}
else
{
echo "Tidak ada yang dapat ditampilkan !!!";
}
}
else
{
echo "Error: " . $MySQLi_CON->error;
}
?>
</section>
</body>
<script>
function confirmDelete(link) {
if (confirm("Data ini akan dihapus ?")) {
doAjax(link.href, "POST"); // doAjax needs to send the "confirm"
field
}
return false;
}
</script><?php $MySQLi_CON->close(); ?>
</html>
l. Jika sudah simpan di dalam folder inven2 simpan dengan format tab-
history.php
m. Jika sudah selanjutnya membuat script untuk membuat action tambah
, hapus , cari , dan edit data.
6. Pembuatan action tambah , hapus , cari , dan edit data.
37
a. Setelah membuat tampilan lalu buatlah action untuk tambah data dengan
membuka jendela baru di sublime text 3 lalu masukan script berikut
untuk membuat action tambah data untuk halaman nama barang.
38
$sqlhistory = "INSERT INTO history (waktu, jenis_barang,
nama_barang, kegiatan)
VALUES
('".$waktu."','".$nama_barang."','".$jenis_barang."','".$kegiatan."')";
if ($MySQLi_CON->query($sqlhistory) == TRUE) {
header("Location: tab-barang.php");
}
else {
echo "Error: " . $sql . "<br>" . $MySQLi_CON->error;
}
} else {
echo "Error: " . $sql . "<br>" . $MySQLi_CON->error;
}
$MySQLi_CON->close();
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>STOK | NAMA BARANG | TAMBAH</title>
</head>
<body>
<header>
<div class="left">
STOK BARANG
</div>
<div class="right">
Hi , <?php echo htmlentities($username) ?> |
<a href="logout.php">Logout</a></div>
</header>
<aside>
39
<ul class="side">
<a href="index.php"><li class="side">Home</li></a>
<a href="tab-barang.php"><li class="side active">Nama
Barang</li></a>
<a href="tab-stok-barang.php"><li class="side">Stok
Barang</li></a>
<a href="tab-history.php"><li class="side">History</li></a>
</ul>
</aside>
<section class="content">
<h1 class="content">Tabel barang</h1>
<p>Menambah data barang</p>
<form method="post">
<input type="text" name="nama_barang" placeholder="Nama
Barang" required/>
<input type="text" name="jenis_barang" placeholder="Jenis
Barang" required/><br>
<input type="submit" name="tambah" value="Tambah"/>
</form></section></body>
</html>
40
$id = $_GET['id'];
if ($stmt = $MySQLi_CON->prepare("DELETE FROM barang
WHERE idbarang = ? LIMIT 1"))
{
$id = $_GET['id'];
$userquery = $MySQLi_CON->query("SELECT * FROM barang
WHERE idbarang = ".$id);
$row = $userquery->fetch_object();
date_default_timezone_set('Asia/Jakarta');
$waktu = date("d/m/Y h:i:s");
$kegiatan = "Meghapus nama barang ".$row->nama_barang."
dengan jenis barang ".$row->jenis_barang;
$sqlhistory = "INSERT INTO history (waktu, jenis_barang,
nama_barang, kegiatan)
VALUES ('".$waktu."','".$row->nama_barang."','".$row-
>jenis_barang."','".$kegiatan."')";
if ($MySQLi_CON->query($sqlhistory) == TRUE) {
}
else
{
echo "Error dalam menghapus data: " . $MySQLi_CON->error;}
$stmt->bind_param("i",$id);
$stmt->execute();
$stmt->close();
}
else
{
echo "ERROR: could not prepare SQL statement.";
}
$MySQLi_CON->close();
header("Location: tab-barang.php");
41
}
else
{
header("Location: tab-barang.php");
}
?>
42
$nama_barang = $_POST["nama_barang"];
$jenis_barang = $_POST["jenis_barang"];
$sql = "UPDATE barang SET nama_barang = '".$nama_barang."',
jenis_barang = '".$jenis_barang."' WHERE idbarang = ".$id;
if ($MySQLi_CON->query($sql) == TRUE) {
date_default_timezone_set('Asia/Jakarta');
$waktu = date("d/m/Y h:i:s");
$kegiatan = "Mengubah nama barang ".$row->nama_barang."
menjadi ".$nama_barang." dan mengubah jenis barang ".$row-
>jenis_barang." menjadi ".$jenis_barang;
$sqlhistory = "INSERT INTO history (waktu, jenis_barang,
nama_barang, kegiatan)
VALUES ('".$waktu."','".$row->nama_barang."','".$row-
>jenis_barang."','".$kegiatan."')";
if ($MySQLi_CON->query($sqlhistory) == TRUE) {
header("Location: tab-barang.php");
} else {
echo "Error dalam mengubah data: " . $MySQLi_CON->error;
}
} else {
echo "Error dalam mengubah data: " . $MySQLi_CON->error;
}
$MySQLi_CON->close();
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>STOK | NAMA BARANG | EDIT</title>
</head>
<body>
43
<header>
<div class="left">
STOK BARANG
</div>
<div class="right">
Hi , <?php echo htmlentities($username) ?> |
<a href="logout.php">Logout</a>
</div>
</header>
<aside>
<ul class="side">
<a href="index.php"><li class="side">Home</li></a>
<a href="tab-barang.php"><li class="side active">Nama
Barang</li></a>
<a href="tab-stok-barang.php"><li class="side">Stok
Barang</li></a>
<a href="tab-history.php"><li class="side">History</li></a>
</ul>
</aside>
<section class="content">
<h1 class="content">Tabel Barang</h1>
<p>Mengubah nama dan jenis barang</p>
<form method="post">
<p>ID: <?php echo $id; ?></p>
<input type="text" name="nama_barang" value="<?php echo $row-
>nama_barang; ?>" placeholder="Nama Barang"
required/><strong>*Nama Barang</strong>
<input type="text" name="jenis_barang" value="<?php echo $row-
>jenis_barang; ?>" placeholder="Jenis Barang"
required/><strong>*Jenis Barang</strong><br>
<input type="submit" name="ubah" value="Ubah"/>
44
</form></section></body></html>
45
if ($MySQLi_CON->query($sql) == TRUE) {
date_default_timezone_set('Asia/Jakarta');
$waktu = date("d/m/Y h:i:s");
$kegiatan = "Menambah stok barang ".$row->nama_barang."
berjulmah ".$row->stok_barang." sebanyak ".$jumlah." sehingga stok
barang ".$row->nama_barang." menjadi ".$hasil_stok;
$sqlhistory = "INSERT INTO history (waktu, jenis_barang,
nama_barang, kegiatan)
VALUES ('".$waktu."','".$row->nama_barang."','".$row-
>jenis_barang."','".$kegiatan."')";
if ($MySQLi_CON->query($sqlhistory) == TRUE) {
header("Location: tab-stok-barang.php");
} else {
echo "Error dalam mengubah data: " . $MySQLi_CON->error;
}
} else {
echo "Error dalam mengubah data: " . $MySQLi_CON->error;
}
$MySQLi_CON->close();
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>STOK | STOK BARANG | TAMBAH</title>
</head>
<body>
<header>
<div class="left">
STOK BARANG
</div>
46
<div class="right">
Hi , <?php echo htmlentities($username) ?> |
<a href="logout.php">Logout</a>
</div>
</header>
<aside>
<ul class="side">
<a href="index.php"><li class="side">Home</li></a>
<a href="tab-barang.php"><li class="side active">Nama
Barang</li></a>
<a href="tab-stok-barang.php"><li class="side">Stok Barang</li></a>
<a href="tab-history.php"><li class="side">History</li></a>
</ul>
</aside>
<section class="content">
<h1 class="content">Tambah Stok Barang</h1>
<p>Menambah stok barang</p>
<form method="post">
<p>ID : <?php echo $id; ?></p>
<p>Nama Barang : <?php echo $row->nama_barang;?></p>
<input type="number" name="jumlah" value="0" min="0"
placeholder="Jumlah" required/><strong>*Jumlah</strong>
</br>
<input type="submit" name="ubah" value="Ubah"/>
</form></section></body>
</html>
47
<?php
session_start();
include_once 'dbconnect.php';
if(!isset($_SESSION['userSession']))
{
header("Location: login.php");
}
else{
$sql = "SELECT * FROM user WHERE
user_id=".$_SESSION['userSession'];
$userquery = $MySQLi_CON->query($sql);
$userRow = $userquery->fetch_object();
$username = $userRow->username;
}
$id = $_GET['id'];
$userquery = $MySQLi_CON->query("SELECT * FROM barang
WHERE idbarang = ".$id);
$row = $userquery->fetch_object();
if(isset($_POST["ubah"])){
$jumlah = $_POST["jumlah"];
$hasil_stok = ($row->stok_barang - $jumlah);
$sql = "UPDATE barang SET stok_barang = '".$hasil_stok."' WHERE
idbarang = ".$id;
if ($MySQLi_CON->query($sql) == TRUE) {
date_default_timezone_set('Asia/Jakarta');
$waktu = date("d/m/Y h:i:s");
$kegiatan = "Mengurangi stok barang ".$row->nama_barang."
berjulmah ".$row->stok_barang." sebanyak ".$jumlah." sehingga stok
barang ".$row->nama_barang." menjadi ".$hasil_stok;
$sqlhistory = "INSERT INTO history (waktu, jenis_barang,
nama_barang, kegiatan)
48
VALUES ('".$waktu."','".$row->nama_barang."','".$row-
>jenis_barang."','".$kegiatan."')";
if ($MySQLi_CON->query($sqlhistory) == TRUE) {
header("Location: tab-stok-barang.php");
} else {
echo "Error dalam mengubah data: " . $MySQLi_CON->error;
}
} else {
echo "Error dalam mengubah data: " . $MySQLi_CON->error;
}
$MySQLi_CON->close();
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>STOK | STOK BARANG | KURANGI</title>
</head>
<body>
<header>
<div class="left">
STOK BARANG
</div>
<div class="right">
Hi , <?php echo htmlentities($username) ?> |
<a href="logout.php">Logout</a>
</div>
</header>
<aside>
<ul class="side">
<a href="index.php"><li class="side">Home</li></a>
49
<a href="tab-barang.php"><li class="side active">Nama
Barang</li></a>
<a href="tab-stok-barang.php"><li class="side">Stok Barang</li></a>
<a href="tab-history.php"><li class="side">History</li></a>
</ul>
</aside>
<section class="content">
<h1 class="content">Kurangi Stok Barang</h1>
<p>Mengurangi stok barang</p>
<form method="post">
<p>ID : <?php echo $id; ?></p>
<p>Nama Barang : <?php echo $row->nama_barang;?></p>
<input type="number" name="jumlah" value="0" min="0"
max="<?php echo $row->stok_barang;?>" placeholder="Jumlah"
required/><strong>*Jumlah</strong>
</br>
<input type="submit" name="ubah" value="Ubah"/>
</form></section></body></html>
50
Ini adalah hasil dari aplikasinya:
a. Dimulai dari Halaman Login.
51
dengan jika mengekelik button nama barang , jika button tabel history
di kelik maka akan muncul tampilan yang sama dengan button history.
e. Lalu jika stok barang di kelik akan muncul tampilan stok barang .
52
’’
Gambar 3.20 Form stok barang
53