G2A Many GEOs
SHARE
TWEET

Untitled

a guest Mar 29th, 2020 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class m_pembelian extends CI_Model{
  3.  
  4.     function simpan_pembelian($nofak,$tglfak,$suplier,$beli_kode){
  5.         $idadmin=$this->session->userdata('idadmin');
  6.         $this->db->query("INSERT INTO tbl_beli (beli_nofak,beli_tanggal,beli_suplier_id,beli_user_id,beli_kode) VALUES ('$nofak','$tglfak','$suplier','$idadmin','$beli_kode')");
  7.         foreach ($this->cart->contents() as $item) {
  8.             $data=array(
  9.                 'd_beli_nofak'      =>  $nofak,
  10.                 'd_beli_barang_id'  =>  $item['id'],
  11.                 'd_beli_harga'      =>  $item['price'],
  12.                 'd_beli_jumlah'     =>  $item['qty'],
  13.                 'd_beli_total'      =>  $item['subtotal'],
  14.                 'd_beli_kode'       =>  $beli_kode
  15.             );
  16.             $this->db->insert('tbl_detail_beli',$data);
  17.             $this->db->query("update tbl_barang set barang_stok=barang_stok+'$item[qty]',barang_harpok='$item[price]',barang_harjul='$item[harga]' where barang_id='$item[id]'");
  18.         }
  19.         return true;
  20.     }
  21.     function get_kobel(){
  22.         $q = $this->db->query("SELECT MAX(RIGHT(beli_kode,6)) AS kd_max FROM tbl_beli WHERE DATE(beli_tanggal)=CURDATE()");
  23.         $kd = "";
  24.         if($q->num_rows()>0){
  25.             foreach($q->result() as $k){
  26.                 $tmp = ((int)$k->kd_max)+1;
  27.                 $kd = sprintf("%06s", $tmp);
  28.             }
  29.         }else{
  30.             $kd = "000001";
  31.         }
  32.         return "BL".date('dmy').$kd;
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top