Advertisement
Guest User

aksi.php

a guest
Jul 30th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.03 KB | None | 0 0
  1. <?php
  2. session_start();
  3.     include '../../config/connect.php';
  4.     include '../../config/function.php';
  5.     include '../../config/config.php';
  6. if (NULL !== cekAkses("$modul","$_SESSION[ylevel]","$act")) {
  7.     @$sup = anti($_POST['sup']);
  8.     @$tgl = anti($_POST['tgl']);
  9.     @$nota = anti($_POST['nota']);
  10.     @$kdbeli = anti($_POST['kode']);
  11.     @$b = explode(' - ',$_POST['brg']);
  12.     @$brg = $b[0];
  13.     @$qty = abs((int)($_POST['qty']));
  14.     @$harga = abs((int)($_POST['total_harga']));
  15.     @$h_pcs = $harga/$qty; //harga satuan
  16.    
  17.     switch($_POST['tipe']) {
  18.     case 'save':
  19.     $q = $mysqli->query("CALL ypos_trxPembelianDtl('$kdbeli','$nota',$sup,'$_SESSION[yuser]','$tgl','$brg', $qty, $h_pcs, $harga, @error)")->fetch_object();
  20.     //echo $kdbeli.' - '.$nota. '-'.$sup.' - '.$_SESSION['yuser'].'-'.$tgl.'-'.$brg.'-'. $qty.'-'. $h_pcs.'-'. $harga;
  21.     $errno = $q->error;
  22.     if (!empty($errno)) {
  23.         header("location:../../$set->folder_modul=$modul&act=new&id=$kdbeli&msg=error&errno=$errno");
  24.     } else {
  25.         header("location:../../$set->folder_modul=$modul&act=new&id=$kdbeli");
  26.     }
  27.     break;
  28.     case 'edProd':
  29.     $idp = abs((int)($_GET['idp'])); //untuk get id penjualan produk
  30.     $ttl = abs((int)($_GET['ttl'])); //untuk get ttl produk
  31.     $getNota = anti($_GET['nota']);
  32.    
  33.         yposSQL('EDIT','ypos_pembeliandtl',"kd_barang='$brg', qty_beli=$qty, harga_beli=$harga/$qty, total=$harga","idDtlPembelian=$idp && kdPembelian='$kode'");
  34.    $t = yposSQL('SHOW','ypos_pembeliandtl','DISTINCT SUM(total) AS t_harga',"kdPembelian='$kode'")->fetch_array();
  35.         yposSQL('EDIT','ypos_pembelian',"total_pembelian=$t[t_harga]","kdPembelian='$kode'");
  36.        
  37.         //update harga barang terbaru
  38.         $h_brg = yposSQL('SHOW','ypos_barang','harga_beli',"kdbarang='$brg'")->fetch_array();
  39.         if ($h_brg != ($harga/$qty)) {
  40.             yposSQL('EDIT','ypos_barang',"harga_beli=$harga/$qty","kdbarang='$brg'");
  41.         }
  42.        
  43.         header("location:../../$set->folder_modul=$modul&act=new&id=$kode&ttl=$t[t_harga]&nota=$getNota&msg=sucessfully");
  44.     break;
  45.     }
  46. } else {
  47.     header("location:../../$set->folder_modul=$modul&msg=error&errno=1045");
  48. }
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement