r4ndi04

aksi-proses

Jan 2nd, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php
  2. include "../../config/koneksi.php";
  3.  
  4. $noFaktur   = $_POST['noFaktur'];
  5.  
  6. $subtotal   = mysql_fetch_array(mysql_query("select sum(subtotal) as total from tblsementara"));
  7. $tot        = $subtotal['total'];
  8.  
  9. $simpan     = mysql_query("insert into penjualan(no_faktur,tanggal,tot_hrg) values ('$noFaktur',now(),'$tot')");
  10.  
  11. if($simpan){
  12.     $query=mysql_query("select * from tblsementara");
  13.     while($r=mysql_fetch_row($query)){
  14.         mysql_query("insert into tbldetailjual(no_faktur,kd_brg,nm_brg,hrg_jual,hrg_terjual,potongan,qty,subtotal) values('','$r[0]','$r[1]','$r[2]','$r[3]','$r[4]','$r[5]','$r[6]','$r[7]')");
  15.         mysql_query("update tblbarang set stok=stok-'$r[6]' where kd_brg='$r[1]'");
  16.     }
  17.     //hapus seluruh isi tabel sementara
  18.     mysql_query("truncate table tblsementara");
  19.     echo "<script type='text/javascript'>
  20.             alert('Data Berhasil Disimpan...!!!');
  21.         </script>";
  22.         echo "<meta http-equiv='refresh' content='0; ../modul.php?page=tampilPenjualan'>";
  23. }
  24. else{
  25.     echo "<script type='text/javascript'>
  26.             alert('Data Gagal Disimpan...!!!');
  27.         </script>";
  28.         echo "<meta http-equiv='refresh' content='0; ../modul.php?page=tambahPenjualan'>";
  29. }
  30. ?>
Add Comment
Please, Sign In to add comment