Showing posts with label PHP MYSQL. Show all posts
Showing posts with label PHP MYSQL. Show all posts

Tuesday, November 12, 2019

(Part 6) Membangun Aplikasi Kasir atau Point of Sales (POS) Dengan PHP dan MYSQL (Menu User KASIR)


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(); ?>
Kode diatas untuk menampilkan Form transaksi yang digunakan kasir nantinya.
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 :

<!--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.

NB : Source code dalam artikel yang berkelanjutan ini akan kami dokumentasikan, dan kami share link downloadnya di akhir project.

Monday, November 11, 2019

(Part 5) Membangun Aplikasi Kasir atau Point of Sales (POS) Dengan PHP dan MYSQL (Menu User Gudang)

Pada Postingan kali ini kita akan membahas mengenai pembuatan untuk Menu User Gudang. Dimana pada Menu User Gudang ini terdapat Sub Menu Penerimaan Barang, dimana ketika User degnan login Hash nya sebagai GUDANG akan diarahkan pada menu ini.
Langka2 yang harus kita lakukan terlebih dahulu yaitu membuat folder Gudang di dalam folder Pages seperti pada postingan sebelumnya Menus User Admin. Selanjutnya Ketikan kode berikut :

<?php ob_start(); ?> <script src="js/jquery-ui.js"></script> <h2>PENERIMAAN BARANG</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=GUDANG&page=PENERIMAAN"> <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 BRG_PLU, BRG_DESK, BRG_FRAC, BRG_UNIT, BRG_BARCODE, ST_QTY_AWAL, ST_QTY_AKHIR, ST_ACOST,ST_ACOST_LAMA FROM TABEL_BARANG LEFT JOIN TABEL_STOCK ON BRG_PLU=ST_PLU WHERE BRG_PLU ='".$cari."' OR BRG_BARCODE like '%".$cari."%' ")) or die(mysql_error()); } else{ } $no = 1; $d1 = mysql_query(" SELECT DISTINCT(TP_NODOC) FROM POS.TABEL_PENERIMAAN WHERE TP_TGL='".date('Y-m-d')."' ") or die(mysql_error()); $j1=mysql_num_rows($d1); $urut = $j1 + 1; if( $j1 >= 9) { $urut_doc = ''.date('ymd').'0'.$urut.''; //191110010 -191110099 } elseif( $j1 >= 99) { $urut_doc = ''.date('ymd').''.$urut.''; //191110100 - .... } else { $urut_doc = ''.date('ymd').'00'.$urut.''; //191110001 -191110009 } error_reporting(0); while($d = mysql_fetch_array($data)){ ?> <form name="form" method="post" action="?cat=gudang&page=penerimaan"> <tr> <td>DOC</td> <td>PLU</td> <td>DESK</td> <td>STOCK</td> <td>LACOST</td> <td>HARAG</td> <td>QTY TERIMA</td> </tr> <tr> <td><input style="width:65px;" type="textAREA" name="doc" id="doc" value="<?php echo $urut_doc ?>"disabled="disabled" ></td> <td><input style="width:55px;" type="textAREA" name="BRG_PLU" value="<?php echo $d['BRG_PLU']; ?>"disabled="disabled" ></td> <td><input style="width:350px;" type="textAREA" name="BRG_DESK" id="BRG_DESK" value="<?php echo $d['BRG_DESK']; ?>"disabled="disabled" ></td> <td><input style="width:50px;" type="textAREA" name="ST_QTY_AKHIR" id="ST_QTY_AKHIR" value="<?php echo $d['ST_QTY_AKHIR']; ?>"disabled="disabled" ></td> <td><input style="width:50px;" type="textAREA" name="ST_ACOST_LAMA" id="ST_ACOST_LAMA" value="<?php echo $d['ST_ACOST_LAMA']; ?>"disabled="disabled" ></td> <td><input style="width:60px;" type="text" name="harga" id="harga"></td> <td><input style="width:20px;" type="text" name="TAMBAH" id="TAMBAH"></td> <td> <input type="hidden" name="BRG_PLU" 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>DOC</td> <td>PLU</td> <td>DESK</td> <td>STOCK</td> <td>HARGA</td> <td>QTY TERIMA</td> </tr> <?php $data = mysql_query("SELECT TEMP_NODOC, TEMP_PLU,brg_desk, TEMP_QTY, TEMP_HARGA_BELI,ST_QTY_AKHIR FROM TEMP_PENERIMAAN LEFT JOIN tabel_barang ON TEMP_PLU=brg_plu LEFT JOIN tabel_stock ON TEMP_PLU=ST_PLU"); $no = 1; while($d = mysql_fetch_array($data)){ ?> <tr> <td><?php echo $no++; ?></td> <td><?php echo $d['TEMP_NODOC']; ?></td> <td><?php echo $d['TEMP_PLU']; ?></td> <td><?php echo $d['brg_desk']; ?></td> <td><?php echo $d['ST_QTY_AKHIR'];?></td> <td><?php echo $d['TEMP_HARGA_BELI']; ?></td> <td><?php echo $d['TEMP_QTY'];?></td> </tr> <?php } ?> <!------- PROSES INSERT KE TABEL TEMP_PENERIMAAN KETIKA DI KLIK BUTTON TAMABAH------> <?php if(isset($_POST['button'])) { $d1 = mysql_query(" SELECT DISTINCT(TP_NODOC) FROM POS.TABEL_PENERIMAAN WHERE TP_TGL='".date('Y-m-d')."' ") or die(mysql_error()); $j1=mysql_num_rows($d1); $urut = $j1 + 1; if( $j1 >= 9) { $urut_doc = ''.date('ymd').'0'.$urut.''; //191110010 -191110099 } elseif( $j1 >= 99) { $urut_doc = ''.date('ymd').''.$urut.''; //191110100 - .... } else { $urut_doc = ''.date('ymd').'00'.$urut.''; //191110001 -191110009 } $TEMP_PLU = $_POST['BRG_PLU']; $harga = $_POST['harga']; $ST_QTY_AKHIR = $_POST['ST_QTY_AKHIR']; $newDate = date("Y-m-d H:i:s"); $USER = $_SESSION['login_user']; $TAMBAH = $_POST['TAMBAH']; if (($TAMBAH ==0) OR ($harga ==0)) { echo "<STRONG><h2><font color='#FF0000'>QTY ATAU HARGA TIDAK BOLEH KOSONG </font></h2></STRONG>"; } else { $q=mysql_query(" INSERT INTO `pos`.`TEMP_PENERIMAAN` (`TEMP_NODOC`,`TEMP_PLU` ,`TEMP_QTY`,`TEMP_HARGA_BELI`,`TEMP_TGL`,`TEMP_CREATE_BY`) VALUES ('".$urut_doc."','".$TEMP_PLU."','".$TAMBAH."','".$harga."','".$newDate."','".$USER."') ") or die(mysql_error()); if($q) { echo "<script>window.location='?cat=GUDANG&page=PENERIMAAN'</script>"; } } } ?> <!-------PROSES INSERT KE TABEL TEMP_PENERIMAAN KETIKA DI KLIK BUTTON SIMPAN----------> <form name="form" method="post" action="?cat=GUDANG&page=PENERIMAAN"> <tr> <td colspan='8'><input type="submit" class="btn btn-primary" name="SIMPAN" id="SIMPAN" value="SIMPAN"> </td> <?php if (isset($_POST['SIMPAN'])) //TEMP_NODOC, TEMP_PLU, TEMP_QTY, TEMP_HARGA_BELI, TEMP_TGL, TEMP_CREATE_BY { $rU=mysql_query("SELECT TEMP_NODOC, TEMP_PLU, TEMP_QTY, TEMP_HARGA_BELI, TEMP_TGL, TEMP_CREATE_BY, ST_QTY_AKHIR,ST_ACOST,ST_ACOST_LAMA, (ST_QTY_AWAL+TEMP_QTY) SET_QTYAWAL, (ST_QTY_AKHIR+TEMP_QTY) SET_QTYAKHIR FROM TEMP_PENERIMAAN LEFT JOIN TABEL_STOCK ON TEMP_PLU=ST_PLU"); while ($rR=mysql_fetch_array($rU)){ // Ubah format harga dengan fungsi number_format $TEMP_NODOC=$rR['TEMP_NODOC']; $TEMP_PLU=$rR['TEMP_PLU']; $SET_QTYAWAL=$rR['SET_QTYAWAL']; $SET_QTYAKHIR=$rR['SET_QTYAKHIR']; $TEMP_HARGA_BELI=$rR['TEMP_HARGA_BELI']; $ST_ACOST=$rR['ST_ACOST']; $newDate = date("Y-m-d H:i:s"); $USER = $_SESSION['login_user']; //ST_QTY_AWAL ST_QTY_AKHIR ST_ACOST ST_ACOST_LAMA ST_CREATE_BY ST_CREATE_DT ST_MODIFY_BY ST_MODIFY_DT $Z=mysql_query("UPDATE TABEL_STOCK SET ST_QTY_AWAL ='".$SET_QTYAWAL."', ST_QTY_AKHIR ='".$SET_QTYAKHIR."',ST_MODIFY_BY='".$USER."', ST_MODIFY_DT='".$newDate."', ST_ACOST='".$TEMP_HARGA_BELI."', ST_ACOST_LAMA='".$ST_ACOST."' WHERE ST_PLU='".$TEMP_PLU."' ") or die(mysql_error()); } if($Z) { $X=mysql_query("INSERT INTO tabel_penerimaan (SELECT * FROM temp_penerimaan)") or die(mysql_error()); if($X) { $ZX=mysql_query("TRUNCATE TABLE temp_penerimaan") or die(mysql_error()); if($ZX) { echo "<script>window.location='cetakBPB'</script>"; } } } } ?> </tr> </form> </table> <?php ob_end_flush(); ?>

Simpan dengan nama penerimaan.php pada folder gudang.
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 //TP_NODOC TP_PLU TP_QTY TP_HARGA_BELI TP_TGL TP_CREATE_BY $d1 = mysql_query("SELECT SUM(TP_QTY*TP_HARGA_BELI) TTL, COUNT(TP_PLU) TITEM, MAX(TP_TGL) TGL, TP_CREATE_BY, TP_NODOC FROM tabel_penerimaan WHERE TP_NODOC IN (SELECT MAX(TP_NODOC) X FROM tabel_penerimaan) GROUP BY TP_CREATE_BY, TP_NODOC ") or die(mysql_error()); while($data = mysql_fetch_array($d1)){ $TP_TOTAL_HARGA=$data['TTL']; $hasilRP=number_format($TP_TOTAL_HARGA,0,",","."); $TITEM=$data['TITEM']; $TP_TGL=$data['TGL']; $TP_CREATE_BY=$data['TP_CREATE_BY']; $TP_NODOC=$data['TP_NODOC']; } echo" </tbody> </table> "; echo" <table border='0'> <thead> <tr> <td colspan=5> <strong><center><font size='2'>BUKTI PENERIMAAN BARANG<br> ".$TP_TGL." &nbsp NOBPB : ".$TP_NODOC." &nbsp ".$TP_CREATE_BY." </br> </font></center></strong> </td> </tr> <tr> <td colspan=5>---------------------------------------------------------------------------------------------------------------------------------------</td> </tr> </thead> </table> "; echo " <table border='0'> <thead> <tr> <td><font size='2'>ITEM</font></td> <td><font size='2'>DESKRIPSI</font></td> <td><font size='2'>QTY</font></td> <td><font size='2'>PRICE</font></td> <td><font size='2'>GROSS</font></td> </tr> <tr> <td colspan=5>---------------------------------------------------------------------------------------------------------------------------------------</td> </tr> </thead> <tbody> "; ////TP_NODOC TP_PLU TP_QTY TP_HARGA_BELI TP_TGL TP_CREATE_BY $data = mysql_query("SELECT TP_PLU,BRG_DESKP, TP_QTY,TP_HARGA_BELI, (TP_QTY*TP_HARGA_BELI) TTL, TP_TGL,TP_CREATE_BY,TP_NODOC FROM tabel_penerimaan LEFT JOIN tabel_barang ON TP_PLU=BRG_PLU WHERE TP_NODOC IN (SELECT MAX(TP_NODOC) X FROM tabel_penerimaan)"); $no = 1; while($d = mysql_fetch_array($data)){ $TP_HARGA_BELI=$d['TP_HARGA_BELI']; $TP_QTY=$d['TP_QTY']; $TP_HARGA_BELIRP=number_format($TP_HARGA_BELI,0,",","."); $TP_TOTAL_HARGA=$d['TTL']; $TP_TOTAL_HARGARP=number_format($TP_TOTAL_HARGA,0,",","."); ?> <tr> <td><font size="2"><?php echo $d['TP_PLU']; ?></font></br></td> <td><font size="2"><?php echo $d['BRG_DESKP']; ?> </font></br></td> <td><font size="2"><?php echo $d['TP_QTY'];?> </font></td> <td><font size="2"><?php echo "$TP_HARGA_BELIRP"?> </br></font></td> <td><font size="2"><br><?php echo "$TP_TOTAL_HARGARP" ?> </br></font></td> </tr> <?php } echo" <tr> <td colspan=5>---------------------------------------------------------------------------------------------------------------------------------------</td> </tr> <tr> <td colspan=2><center><strong><font size='2'>TOAL :</font></center></strong></td> <td colspan=2><strong><font size='2'><div style=’text-align:right;’> ".$TITEM." &nbsp Item</div> <td><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=5>---------------------------------------------------------------------------------------------------------------------------------------</td> </tr> </thead> </table> "; ?> <button onclick="goBack()"> KEMBALI </button> <script> function goBack() { window.history.back(); } </script> </script> </body> </html>

Kode diatas untuk mencetak dokumen penerimaan. 
Simpan dengan nama cetakBPB.php pada folder POS.

Selanjutnya kita tambahkan pada sub menu untuk gudang dengan cara buka file _main-nav.php 

Ketik kode berikut tepat dibawah tanda " </li>  " pda baris 23:

<!--MENU GUDANG--> <?php }elseif($_SESSION['login_hash']=="gudang") { ?> <li class="dropdown"><a href="#"><span class="icon-th-list"></span>Master</a> <ul> <li><a href="?cat=gudang&page=penerimaan"><span class="icon-pencil"></span>Penerimaan Barang</a></li> </ul> </li>

Kemudian simpan.

Hasilnya seperti berikut :
Ketika di inputkan item nya :

Ketika di klik button "SIMPAN" data akan otomatis mengupdate stock akhir pada tabel Tabel_stock.
dan mencetak dokumen :
Sekian dulu postingan kali ini. Simak terus Postingan2 selanjutnya, terima kasih.

NB : Source code dalam artikel yang berkelanjutan ini akan kami dokumentasikan, dan kami share link downloadnya di akhir project.

follow

Follow My Blog

baner ak

Click the Flag to translate this blog into English =>> English








Twitter Delicious Facebook Digg Stumbleupon Favorites More