Melanjutkan postingan sebelumnya (Menu User Gudang). Kali ini kami akan membahas mengenai menu kasir. dimana disini kasir dapat melakukan transaksi dengan menginput barcode atau plu dari item2 yang sudah didaftarkan oleh admin dan sudah ada stock nya (sudah pernah diproses penerimaan barang), pada proses transaksi ini bisa juga mengunakan scaner dengan cara scane barcode item2 yang sudah terdaftar tadi.
Mari kita lakukan dengan langkah dibawah ini:
Buat folder kasir didalam folder pages.
Ketik kode berikut :
<?php
ob_start();
?>
<script src="js/jquery-ui.js"></script>
<h2>TOKO ALTHAF</h2>
<!----------------------------------------------------------------------------------------------------------------------------------------->
<form name="form1" method="POST" action="" autocomplete="on">
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>PLU : <input type="text" name="cari" id="cari"><input type="hidden" class="btn btn-primary" value=""></td>
</tr>
</table>
</form>
<form name="form1" method="POST" action="?cat=kasir&page=SALES">
<span >
<table width="100%" border="1" cellspacing="1" cellpadding="1" class="table table-striped">
<?php
if(isset($_POST['cari']))
{
$cari = $_POST['cari'];
$data=mysql_query(("
select distinct A.BRG_PLU, A.BRG_DESK, A.Brg_unit, A.brg_frac, D.HRG_HARGA_BARU, B.ST_QTY_AKHIR
from TABEL_BARANG A
LEFT JOIN TABEL_STOCK B ON A.BRG_PLU=B.ST_PLU
LEFT JOIN tabel_harga D on A.brg_plu=D.HRG_plu
where CONCAT(A.BRG_BARCODE,'-',A.BRG_PLU,'-',A.BRG_DESK) like '%".$cari."%'
")) or die(mysql_error());
}
else{
$data = mysql_query("
select distinct A.BRG_PLU, A.BRG_DESK, A.Brg_unit, A.brg_frac, D.HRG_HARGA_BARU, B.ST_QTY_AKHIR
from TABEL_BARANG A
LEFT JOIN TABEL_STOCK B ON A.BRG_PLU=B.ST_PLU
LEFT JOIN tabel_harga D on A.brg_plu=D.HRG_plu
where BRG_PLU='".$cari."'");
}
$no = 1;
while($d = mysql_fetch_array($data)){
?>
<form name="form" method="post" action="?cat=kasir&page=SALES">
<tr>
<td>
<input style="width:55px;" type="textAREA" name="BRG_PLU" id="BRG_PLU" value="<?php echo $d['BRG_PLU']; ?>" disabled="disabled" >
<input style="width:370px;" type="textAREA" name="BRG_DESK" id="BRG_DESK" value="<?php echo $d['BRG_DESK']; ?>" disabled="disabled">
STOCK:<input style="width:50px;" type="textAREA" name="ST_QTY_AKHIR" id="ST_QTY_AKHIR" value="<?php echo $d['ST_QTY_AKHIR']; ?>" disabled="disabled" >
Rp.<input style="width:100px;" type="textAREA" name="HRG_HARGA_BARU" id="HRG_HARGA_BARU" value="<?php echo $d['HRG_HARGA_BARU']; ?>" disabled="disabled">
QTY: <input style="width:20px;" type="text" name="TAMBAH" id="TAMBAH">
<input type="hidden" name="ST_QTY_AKHIRh" value="<?php echo $d['ST_QTY_AKHIR']; ?>">
<input type="hidden" name="HRG_HARGA_BARUh" value="<?php echo $d['HRG_HARGA_BARU']; ?>">
<input type="hidden" name="BRG_PLUh" value="<?php echo $d['BRG_PLU']; ?>">
<input type="submit" class="btn btn-primary" name="button" id="button" value="Tambah">
</td>
</tr>
</form>
<?php
}
?>
</table>
</span>
</form>
<table width="100%" border="1" cellspacing="1" cellpadding="1" class="table table-striped">
<tr>
<td>No.</td>
<td>PLU</td>
<td>DESK</td>
<td>PRICE</td>
<td>QTY</td>
<td>GROSS</td>
</tr>
<?php
$data = mysql_query("SELECT TEMP_PLU, brg_desk, TEMP_QTY, TEMP_HARGA, TEMP_TOTAL_HARGA
FROM temp_tabel_jual LEFT JOIN tabel_barang ON TEMP_PLU=brg_plu");
$no = 1;
while($d = mysql_fetch_array($data)){
?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $d['TEMP_PLU']; ?></td>
<td><?php echo $d['brg_desk']; ?></td>
<td><?php echo $d['TEMP_HARGA'];?></td>
<td><?php echo $d['TEMP_QTY']; ?></td>
<td><?php echo $d['TEMP_TOTAL_HARGA']; ?></td>
</tr>
<?php
}
$rs=mysql_query("SELECT SUM(TEMP_TOTAL_HARGA) TTL FROM temp_tabel_jual");
while ($r=mysql_fetch_array($rs)){
// Ubah format harga dengan fungsi number_format
$TOTAL=number_format($r[TTL],0,",",".");
}
?>
<tr>
<td colspan='5'><h5>YANG HARUS DIBAYAR </h5></td> <td><h5> <?php echo "$TOTAL"; ?> </h5></td>
<form name="form" method="post" action="?cat=kasir&page=SALES">
<tr>
<td colspan='5'><h5>TUNAI </h5></td> <td><h5>
<input style="width:100px;"style="width:100px;" type="text" name="tunai" id="tunai" value="<?php $angka1=number_format($_POST['tunai'],0,",","."); echo "$angka1" ?>"></h5>
<input type="hidden" class="btn btn-primary" name="BAYAR" id="BAYAR" value="">
</td>
</tr>
<tr>
<?php
$angka=$angka1;
$angka2 = "$TOTAL";
$hasil = ($angka-$angka2)*1000;
$hasilRP=number_format($hasil,0,",",".");
?>
<td colspan='5'><h5>KEMBALI </h5></td> <td><h5>
<?php if (isset($_POST['BAYAR'])) echo "$hasilRP"; ?></h5>
</td>
</tr>
</form>
<!----------------------------------------------------------------------------------------------------------------->
<form name="form" method="post" action="?cat=kasir&page=SALES">
<tr> <td colspan='5'><input type="submit" class="btn btn-primary" name="SIMPAN" id="SIMPAN" value="SIMPAN">
</td>
<?php
if (isset($_POST['SIMPAN']))
{
$rU=mysql_query("SELECT TEMP_PLU, TEMP_QTY, ST_QTY_AKHIR, (ST_QTY_AKHIR-TEMP_QTY) X FROM
TEMP_TABEL_JUAL A LEFT JOIN TABEL_STOCK B
ON A.TEMP_PLU=B.ST_PLU");
while ($rR=mysql_fetch_array($rU)){
// Ubah format harga dengan fungsi number_format
$TEMP_PLUX=$rR['TEMP_PLU'];
$TEMP_QTYX=$rR['X'];
$Z=mysql_query("UPDATE TABEL_STOCK SET ST_QTY_AKHIR='".$TEMP_QTYX."' WHERE ST_PLU='".$TEMP_PLUX."'
") or die(mysql_error());
}
if($Z)
{
$X=mysql_query("INSERT INTO TABEL_JUAL (SELECT * FROM TEMP_TABEL_JUAL)") or die(mysql_error());
if($X)
{
$Z=mysql_query("TRUNCATE TABLE TEMP_TABEL_JUAL") or die(mysql_error());
if($Z)
{
echo "<script>window.location='cetak'</script>";
}
}
}
}
?>
</tr>
</form>
</table
<!----------------------------------------------------------------------------------------------------------------------------------------->
<?php
if(isset($_POST['button']))
{
$d1 = mysql_query(" SELECT DISTINCT TJ_NO_STRUK FROM TABEL_JUAL WHERE TJ_TGLTRANS='".date('Y-m-d')."' ")
or die(mysql_error());
$j1=mysql_num_rows($d1);
$urut = $j1 + 1;
if( $j1 >= 9)
{
$urut_STRUK = ''.date('ymd').'0'.$urut.''; //12010 -12099
}
elseif( $j1 >= 99)
{
$urut_STRUK = ''.date('ymd').''.$urut.''; //12100 - ....
}
else
{
$urut_STRUK = ''.date('ymd').'00'.$urut.''; //12001 -12009
}
$TEMP_PLU = $_POST['BRG_PLUh'];
$HRG_HARGA_BARU = $_POST['HRG_HARGA_BARUh'];
$ST_QTY_AKHIR = $_POST['ST_QTY_AKHIRh'];
$newDate = date("Y-m-d H:i:s");
$USER = $_SESSION['login_user'];
$TAMBAH = $_POST['TAMBAH'];
$TH =($HRG_HARGA_BARU*$TAMBAH);
$QTYA =($ST_QTY_AKHIR-$TAMBAH);
if (($TH<=0))
{
echo "<STRONG><h2><font color='#FF0000'>$TEMP_PLU BELUM ADA HARGANYA !!! $HRG_HARGA_BARU $ST_QTY_AKHIR</font></h2></STRONG>";
}
elseif (($TAMBAH > $ST_QTY_AKHIR))
{
echo "<STRONG><h2><font color='#FF0000'>STOCK=$ST_QTY_AKHIR TIDAK CUKUP !!! </font></h2></STRONG>";
}
else
{
$q=mysql_query("INSERT INTO `pos`.`temp_tabel_jual` (`TEMP_PLU` ,`TEMP_QTY`,`TEMP_HARGA`,`TEMP_TOTAL_HARGA`,`TEMP_TGLTRANS`,`TEMP_CREATE_BY`,`TEMP_NO_STRUK`)
VALUES ('".$TEMP_PLU."','".$TAMBAH."','".$HRG_HARGA_BARU."','".$TH."','".$newDate."','".$USER."','".$urut_STRUK."')
") or die(mysql_error());
if($q)
{
echo "<script>window.location='?cat=kasir&page=SALES'</script>";
}
}
//$newDate = date("Y-m-d", strtotime($_POST['BRG_TGL_CREATE']));
}
?>
<?php
ob_end_flush();
?>
Simpan dengan nama sales.php pada folder kasir.
Selanjutnya Ketikan kode berikut :
<html>
<head>
<style type='text/css'>
body {
font-family: calibri;
}
table {
border-collapse: collapse;
}
td {
min-width: 0px;
overflow-y: auto;
overflow-x: hidden;
}
</style>
</head>
<body>
<button onclick="myFunction()"><img src='img/Print.png'></button>
<script src="js/jquery-ui.js"></script>
<script>
function myFunction() {
window.print();
}
</script>
<!DOCTYPE HTML>
<?php
include("_db.php");
?>
<body>
<?php
$d1 = mysql_query("SELECT
SUM(TJ_TOTAL_HARGA) TTL, MAX(TJ_TGLTRANS) TGL, TJ_CREATE_BY, TJ_NO_STRUK
FROM tabel_jual
WHERE TJ_NO_STRUK IN (SELECT MAX(TJ_NO_STRUK) X FROM tabel_jual)
GROUP BY TJ_CREATE_BY, TJ_NO_STRUK ")
or die(mysql_error());
while($data = mysql_fetch_array($d1)){
$TJ_TOTAL_HARGA=$data['TTL'];
$hasilRP=number_format($TJ_TOTAL_HARGA,0,",",".");
$TJ_TGLTRANS=$data['TGL'];
$TJ_CREATE_BY=$data['TJ_CREATE_BY'];
$TJ_NO_STRUK=$data['TJ_NO_STRUK'];
}
echo"
</tbody>
</table>
";
echo"
<table border='0'>
<thead>
<tr>
<td colspan=3>
<strong><center><font size='2'>STRUK <br>
".$TJ_TGLTRANS." </br> </font></center></strong>
</td>
</tr>
<tr>
<td colspan=2><strong><font size='2'>".$TJ_NO_STRUK." </font></strong></td>
<td colspan=2><strong><font size='2'>".$TJ_CREATE_BY." </font></strong></td>
</tr>
<tr>
<td colspan=3>---------------------------------------------</td>
</tr>
</thead>
</table>
";
echo "
<table border='0'>
<thead>
<tr>
<td><font size='2'>ITEM</font></td>
<td><font size='2'> QTY<br>
PRICE</br></font></td>
<td><font size='2'> GROSS</font></td>
</tr>
<tr>
<td colspan=3>---------------------------------------------</td>
</tr>
</thead>
<tbody>
";
$data = mysql_query("SELECT
TJ_PLU,BRG_DESKP, TJ_QTY,TJ_HARGA,TJ_TOTAL_HARGA,TJ_TGLTRANS,TJ_CREATE_BY,TJ_NO_STRUK
FROM tabel_jual LEFT JOIN tabel_barang ON TJ_PLU=BRG_PLU
WHERE TJ_NO_STRUK IN (SELECT MAX(TJ_NO_STRUK) X FROM tabel_jual)");
$no = 1;
while($d = mysql_fetch_array($data)){
$TJ_HARGA=$d['TJ_HARGA'];
$TJ_HARGARP=number_format($TJ_HARGA,0,",",".");
$TJ_TOTAL_HARGA=$d['TJ_TOTAL_HARGA'];
$TJ_TOTAL_HARGARP=number_format($TJ_TOTAL_HARGA,0,",",".");
?>
<tr>
<td><font size="2"><?php echo $d['TJ_PLU']; ?><br><?php echo $d['BRG_DESKP']; ?> </font></br></td>
<td><font size="2"><?php echo $d['TJ_QTY'];?><br><?php echo "$TJ_HARGARP"?> </br></font></td>
<td><font size="2"><br><?php echo "$TJ_TOTAL_HARGARP" ?> </br></font></td>
</tr>
<?php
}
echo"
<tr>
<td colspan=3>---------------------------------------------</td>
</tr>
<tr>
<td><center><strong><font size='2'>TOAL :</font></center></strong></td>
<td colspan=><strong><font size='2'><div style=’text-align:right;’>".$hasilRP."</div>
</font></strong></td>
</tr>
</tbody>
</table>
";
echo "
<table border='0'>
<thead>
<tr>
<td colspan=3>---------------------------------------------</td>
</tr>
</thead>
</table>
";
?>
<button onclick="goBack()"> KEMBALI </button>
<script>
function goBack() {
window.history.back();
}
</script>
</script>
</body>
</html>
Kode diatas berfungsi untuk mencetak struk dari transaksi penjualan simpan dengan nama cetak.php
Selanjutnya tambahkan menu untuk akses halaman transaksi diatas, dengan cara buka file_main-nav.php pada ketikan kode berikut :
Selanjutnya tambahkan menu untuk akses halaman transaksi diatas, dengan cara buka file_main-nav.php pada ketikan kode berikut :
<!--MENU KASIR-->
<?php
}elseif($_SESSION['login_hash']=="KASIR"){
?>
<li class="dropdown"><a href="#"><span class="icon-th-list"></span>MENU A</a>
<ul>
<li><a href="#"><span class="icon-pencil"></span>SUB MENU 1A</a></li>
<li><a href="#"><span class="icon-pencil"></span>SUB MENU 2A</a></li>
</ul>
</li>
<li class="dropdown"><a href="#"><span class="icon-th-list"></span>MENU B</a>
<ul>
<li><a href="#"><span class="icon-pencil"></span>SUB MENU 1B</a></li>
<li><a href="#"><span class="icon-pencil"></span>SUB MENU 2B</a></li>
</ul>
</li>
Ganti menjadi :
<!--MENU KASIR-->
<?php
}elseif($_SESSION['login_hash']=="kasir"){
?>
<li class="dropdown"><a href="#"><span class="icon-th-list"></span>MENU A</a>
<ul>
<li><a href="?cat=KASIR&page=SALES"><span class="icon-pencil"></span>SALES</a></li>
<li><a href="#"><span class="icon-pencil"></span>SUB MENU 2A</a></li>
</ul>
</li>
<li class="dropdown"><a href="#"><span class="icon-th-list"></span>MENU B</a>
<ul>
<li><a href="#"><span class="icon-pencil"></span>SUB MENU 1B</a></li>
<li><a href="#"><span class="icon-pencil"></span>SUB MENU 2B</a></li>
</ul>
</li>
Coba masuk dengan user has kasir, maka akan tampil seperti berikut :
Tamilan ketika melakukan transaksi :
Berikut tampilan struknya :
Sekian dulu postingan kali ini. untuk selanjutnya kami akan membahas mengenai laporan untuk menu pimpinan. terima kasih.
Berikut tampilan struknya :
Sekian dulu postingan kali ini. untuk selanjutnya kami akan membahas mengenai laporan untuk menu pimpinan. terima kasih.
NB : Source code dalam artikel yang berkelanjutan ini akan kami dokumentasikan, dan kami share link downloadnya di akhir project.
0 komentar:
Post a Comment