<?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();
?>