copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,736 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class ModelPembelian extends CI_Model {
|
||||
public function create($table, $data, $batch = false) {
|
||||
if($batch === false){
|
||||
$insert = $this->db->insert($table, $data);
|
||||
}else{
|
||||
$insert = $this->db->insert_batch($table, $data);
|
||||
}
|
||||
return $insert;
|
||||
}
|
||||
|
||||
public function update($table, $data, $pk, $id = null, $batch = false) {
|
||||
if($batch === false){
|
||||
$insert = $this->db->update($table, $data, array($pk => $id));
|
||||
}else{
|
||||
$insert = $this->db->update_batch($table, $data, $pk);
|
||||
}
|
||||
return $insert;
|
||||
}
|
||||
|
||||
public function delete($table, $data, $pk) {
|
||||
$this->db->where_in($pk, $data);
|
||||
return $this->db->delete($table);
|
||||
}
|
||||
|
||||
public function getData_Pembelian_Null($id = null, $level = null){ //Pembelian = [1, 5, 11]
|
||||
if ($id === null) {
|
||||
$this->db->select('a.CORP_ID,a.ID_PEMBELIAN,a.KODE_PEMBELIAN,a.TGL_PEMBELIAN,a.SJ_PEMBELIAN,a.SUPPLIER_ID,a.TGL_SJBELI,
|
||||
DATE_FORMAT(a.TGL_SJBELI,"%d/%m/%Y") as TANGGAL,b.NAMA_SUPPLIER,c.NAMA_KOTA');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
|
||||
$this->db->join('corp d','d.ID_CORP=a.CORP_ID');
|
||||
$this->db->where('a.STATUS_PEMBELIAN is NULL');
|
||||
if ($level == 0) {
|
||||
$this->db->where('a.CORP_ID<=4');
|
||||
} else if ($level == 1) {
|
||||
$this->db->where('a.CORP_ID=5');
|
||||
}
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('pembelian');
|
||||
$this->db->where('STATUS_PEMBELIAN is NULL');
|
||||
$this->db->where(['ID_PEMBELIAN' => $id]);
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_HistoriKuantiti_byBARANG_orderDESC_limit1($id) { //RekapGp = [6, 12]
|
||||
$this->db->select('*');
|
||||
$this->db->from('histori_kuantiti');
|
||||
$this->db->where('BARANG_ID=', $id);
|
||||
$this->db->order_by('ID_HQ DESC');
|
||||
$this->db->limit('1');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_HistoriKuantiti_byBARANG_orderDESC_limit1_beforeID($id1, $id2) { //RekapGp = [6, 12]
|
||||
$this->db->select('*');
|
||||
$this->db->from('histori_kuantiti');
|
||||
$this->db->where('BARANG_ID=', $id1);
|
||||
$this->db->where('ID_HQ<', $id2);
|
||||
$this->db->order_by('ID_HQ DESC');
|
||||
$this->db->limit('1');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_ReturPenjualan_byKODE($id) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('retur_penjualan a');
|
||||
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID');
|
||||
$this->db->where('a.KODE_RJ=', $id);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_HistoriKuantiti_byBARANG_byKODEBUKTI_beforeID($barang, $kodebukti, $idhq) { //Penjualan = [47, 54]
|
||||
$this->db->select('*');
|
||||
$this->db->from('histori_kuantiti');
|
||||
$this->db->where('BARANG_ID=', $barang);
|
||||
$this->db->where('KODE_BUKTI=', $kodebukti);
|
||||
$this->db->where('ID_HQ<', $idhq);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_HistoriKuantiti_byBARANG_afterID($id1, $id2) { //RekapGp = [6, 12]
|
||||
$this->db->select('*');
|
||||
$this->db->from('histori_kuantiti');
|
||||
$this->db->where('BARANG_ID=', $id1);
|
||||
$this->db->where('ID_HQ>', $id2);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Corp_forPembelian($level){ //Pembelian = [1]
|
||||
if ($level == 0) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('corp');
|
||||
$this->db->where('ID_CORP<=4');
|
||||
} else if ($level == 1) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('corp');
|
||||
$this->db->where('ID_CORP=5');
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Supplier_byID($id=null) { //Pembelian = [1, 19, 23, 24]
|
||||
if ($id==null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('supplier a');
|
||||
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
|
||||
$this->db->order_by('a.NAMA_SUPPLIER ASC');
|
||||
} else {
|
||||
$this->db->select('*');
|
||||
$this->db->from('supplier a');
|
||||
$this->db->join('kota b','b.ID_KOTA=a.KOTA_ID');
|
||||
$this->db->where(['a.ID_SUPPLIER' => $id]);
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Karyawan_forLogin($username, $password) { //Pembelian = [2, 18, 25]
|
||||
$this->db->select('*');
|
||||
$this->db->from('karyawan a');
|
||||
$this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID');
|
||||
$this->db->where('a.USERNAME=', $username);
|
||||
$this->db->where('a.PASSWORD=', $password);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKode_Pembelian() { //Pembelian = [3]
|
||||
$this->db->select('MAX(KODE_PEMBELIAN) AS KODE');
|
||||
$this->db->from('pembelian');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Pembelian_byID($id=null) { //Pembelian = [4, 6, 7, 19, 23, 26, 37, 40, 43, 46, 49]
|
||||
if ($id==null) {
|
||||
$this->db->select('a.*,b.NAMA_CORP,c.NAMA_SUPPLIER,d.NAMA_KOTA');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('corp b','b.ID_CORP=a.CORP_ID','left');
|
||||
$this->db->join('supplier c','c.ID_SUPPLIER=a.SUPPLIER_ID','left');
|
||||
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID','left');
|
||||
} else {
|
||||
$this->db->select('*');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
|
||||
$this->db->where(['a.ID_PEMBELIAN' => $id]);
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Pembelian_forSJ($id, $sj) { //Pembelian = [5, 41]
|
||||
$this->db->select('*');
|
||||
$this->db->from('pembelian');
|
||||
$this->db->where('ID_PEMBELIAN!=', $id);
|
||||
$this->db->where('SJ_PEMBELIAN=', $sj);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_DaftarBeli_byPEMBELIAN($id = null){ //Pembelian = [6, 7, 11, 19, 23, 27, 43, 44, 46, 47, 49]
|
||||
if ($id === null) {
|
||||
$this->db->select('*,FORMAT(a.HARGA_DB,2) as HARGA');
|
||||
$this->db->from('daftar_beli a');
|
||||
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
|
||||
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
|
||||
$this->db->join('kuantiti e','e.ID_KUANTITI=c.ID_BARANG');
|
||||
}else{
|
||||
$this->db->select('*,FORMAT(a.HARGA_DB,2) as HARGA');
|
||||
$this->db->from('daftar_beli a');
|
||||
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
|
||||
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
|
||||
$this->db->join('kuantiti e','e.ID_KUANTITI=c.ID_BARANG');
|
||||
$this->db->where(['a.PEMBELIAN_ID' => $id]);
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_HutangDagang_byPEMBELIAN($id) { //Pembelian = [6, 33, 47, 50, 51]
|
||||
$this->db->select('*');
|
||||
$this->db->from('hutang_dagang');
|
||||
$this->db->where(['PEMBELIAN_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Barang_NonJasa($level){ //Pembelian = [7]
|
||||
if ($level == 0) {
|
||||
$this->db->select('a.ID_BARANG,c.PCM_KUANTITI,a.KODE_BARANG,a.NAMA_BARANG,b.NAMA_JENIS');
|
||||
} else if ($level == 1) {
|
||||
$this->db->select('a.ID_BARANG,c.ITP_KUANTITI,a.KODE_BARANG,a.NAMA_BARANG,b.NAMA_JENIS');
|
||||
}
|
||||
$this->db->from('barang a');
|
||||
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID');
|
||||
$this->db->join('kuantiti c','c.ID_KUANTITI=a.ID_BARANG');
|
||||
$this->db->where('b.TYPE_JENIS!=2');
|
||||
if ($level == 0) {
|
||||
$this->db->order_by('c.PCM_KUANTITI DESC,b.NAMA_JENIS ASC,a.KODE_BARANG ASC');
|
||||
} else if ($level == 1) {
|
||||
$this->db->order_by('c.ITP_KUANTITI DESC,b.NAMA_JENIS ASC,a.KODE_BARANG ASC');
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Barang_status1_NonJasa($level){ //Pembelian = [7]
|
||||
if ($level == 0) {
|
||||
$this->db->select('a.ID_BARANG,c.PCM_KUANTITI,a.KODE_BARANG,a.NAMA_BARANG,b.NAMA_JENIS');
|
||||
} else if ($level == 1) {
|
||||
$this->db->select('a.ID_BARANG,c.ITP_KUANTITI,a.KODE_BARANG,a.NAMA_BARANG,b.NAMA_JENIS');
|
||||
}
|
||||
$this->db->from('barang a');
|
||||
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID');
|
||||
$this->db->join('kuantiti c','c.ID_KUANTITI=a.ID_BARANG');
|
||||
$this->db->where('b.TYPE_JENIS!=2');
|
||||
$this->db->where('a.STATUS_BARANG=1');
|
||||
if ($level == 0) {
|
||||
$this->db->order_by('c.PCM_KUANTITI DESC,b.NAMA_JENIS ASC,a.KODE_BARANG ASC');
|
||||
} else if ($level == 1) {
|
||||
$this->db->order_by('c.ITP_KUANTITI DESC,b.NAMA_JENIS ASC,a.KODE_BARANG ASC');
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getQtyReal_SnBeli_byDB($id) { //Pembelian = [7, 9, 11, 12, 15, 16]
|
||||
$this->db->select('a.ID_SNB');
|
||||
$this->db->from('sn_beli a');
|
||||
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID');
|
||||
$this->db->group_by('a.ID_SNB');
|
||||
$this->db->where(['a.DB_ID' => $id]);
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
public function getData_DaftarBeli_byID_byBARANG($id1, $id2){ //Pembelian = [8]
|
||||
$this->db->select('*');
|
||||
$this->db->from('daftar_beli');
|
||||
$this->db->where(['PEMBELIAN_ID' => $id1]);
|
||||
$this->db->where(['BARANG_ID' => $id2]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_DaftarBeli_byID($id) { //Pembelian = [10, 12, 15, 16, 20, 21, 50]
|
||||
$this->db->select('*');
|
||||
$this->db->from('daftar_beli a');
|
||||
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID');
|
||||
$this->db->join('pembelian d','d.ID_PEMBELIAN=a.PEMBELIAN_ID');
|
||||
$this->db->where(['a.ID_DB' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnBeli_byDB($id) { //Pembelian = [10, 13, 14, 23, 43, 47]
|
||||
$this->db->select('*');
|
||||
$this->db->from('sn_beli a');
|
||||
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID');
|
||||
$this->db->where(['a.DB_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnBeli_byBARANG($id) { //Pembelian = [12]
|
||||
$this->db->select('*');
|
||||
$this->db->from('sn_beli a');
|
||||
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID');
|
||||
$this->db->join('sn_stock c','c.NAMA_SNSTOCK=a.NAMA_SNB','left');
|
||||
$this->db->where(['b.BARANG_ID' => $id]);
|
||||
$this->db->where('c.STATUS_SNSTOCK is NULL');
|
||||
$this->db->order_by('a.ID_SNB DESC');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnStock_SnBeli_byNAMA_AllStatus($id) { //Pembelian = [15]
|
||||
$this->db->select('*');
|
||||
$this->db->from('sn_stock a');
|
||||
$this->db->join('sn_beli b','b.NAMA_SNB=a.NAMA_SNSTOCK','left');
|
||||
$this->db->where(['a.NAMA_SNSTOCK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnIo_byNAMA_AllStatus($id) { //Pembelian = [15]
|
||||
$this->db->select('*');
|
||||
$this->db->from('sn_io');
|
||||
$this->db->where(['NAMA_SNIO' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnBeli_byID($id) { //Pembelian = [16, 27]
|
||||
$this->db->select('*');
|
||||
$this->db->from('sn_beli a');
|
||||
$this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNB','left');
|
||||
$this->db->where(['a.ID_SNB' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Pembelian_0($id = null, $level = null){ //Pembelian = [17, 23, 42, 44]
|
||||
if ($id == null) {
|
||||
$this->db->select('*,DATE_FORMAT(a.TGL_PEMBELIAN,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(a.TGL_SJBELI,"%d/%m/%Y") as TGLSJ');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
|
||||
$this->db->join('karyawan d','d.ID_KARYAWAN=a.KAR_GUDANG_PEMBELIAN');
|
||||
$this->db->where('a.STATUS_PEMBELIAN=0');
|
||||
if ($level == 0) {
|
||||
$this->db->where('a.CORP_ID<=4');
|
||||
} else if ($level == 1) {
|
||||
$this->db->where('a.CORP_ID=5');
|
||||
}
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('pembelian');
|
||||
$this->db->where('STATUS_PEMBELIAN=0');
|
||||
$this->db->where(['ID_PEMBELIAN' => $id]);
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function addTempoDay($date,$day) { //Pembelian = [23, 41]
|
||||
$sum = strtotime(date("Y-m-d", strtotime("$date")) . " +$day days");
|
||||
$dateTo=date('Y-m-d',$sum);
|
||||
return $dateTo;
|
||||
}
|
||||
|
||||
public function getID_SNSTOCKMax() { //Pembelian = [23]
|
||||
$this->db->select_max('ID_SNSTOCK');
|
||||
$this->db->from('sn_stock');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Kuantiti_byID($id) { //Pembelian = [23, 27, 28, 31, 38, 47]
|
||||
$this->db->select('*');
|
||||
$this->db->from('kuantiti');
|
||||
$this->db->where(['ID_KUANTITI' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Pembelian_1($id = null, $level = null, $tanggal_awal = null, $tanggal_akhir = null, $id_supplier = null){ //Pembelian = [24, 45]
|
||||
if ($id == null) {
|
||||
$this->db->select('*,DATE_FORMAT(a.TGL_INVBELI,"%d/%m/%Y") as TGLINV');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
|
||||
$this->db->where('a.STATUS_PEMBELIAN=1');
|
||||
$this->db->where('a.TGL_INVBELI>=', $tanggal_awal);
|
||||
$this->db->where('a.TGL_INVBELI<=', $tanggal_akhir);
|
||||
if ($id_supplier!=null) {
|
||||
$this->db->where('a.SUPPLIER_ID=', $id_supplier);
|
||||
}
|
||||
if ($level == 0) {
|
||||
$this->db->where('a.CORP_ID<=4');
|
||||
} else if ($level == 1) {
|
||||
$this->db->where('a.CORP_ID=5');
|
||||
}
|
||||
$this->db->order_by('a.KODE_PEMBELIAN ASC');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('pembelian');
|
||||
$this->db->where('STATUS_PEMBELIAN=1');
|
||||
$this->db->where(['ID_PEMBELIAN' => $id]);
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_ReturPembelian_byPEMBELIAN_byKARYAWAN_Null($id_pembelian, $id_karyawan){ //Pembelian = [24]
|
||||
$this->db->select('*');
|
||||
$this->db->from('retur_pembelian');
|
||||
$this->db->where(['PEMBELIAN_ID' => $id_pembelian, 'ADMIN_ID' => $id_karyawan]);
|
||||
$this->db->where('STATUS_RB is NULL');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_DaftarReturBeli_byPEMBELIAN_byKARYAWAN_byLEVEL_KODENull($id_pembelian, $id_karyawan, $level) { //Pembelian = [26, 30]
|
||||
$this->db->select('*');
|
||||
$this->db->from('daftar_returbeli a');
|
||||
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->join('retur_pembelian c','c.ID_RB=a.RB_ID');
|
||||
$this->db->join('pembelian d','d.ID_PEMBELIAN=c.PEMBELIAN_ID');
|
||||
$this->db->join('corp e','e.ID_CORP=d.CORP_ID');
|
||||
$this->db->join('karyawan f','f.ID_KARYAWAN=c.ADMIN_ID');
|
||||
$this->db->join('jabatan g','g.ID_JABATAN=f.JABATAN_ID');
|
||||
$this->db->where(['c.PEMBELIAN_ID' => $id_pembelian]);
|
||||
$this->db->where(['c.ADMIN_ID' => $id_karyawan]);
|
||||
$this->db->where(['g.LEVEL_JABATAN' => $level]);
|
||||
$this->db->where('c.KODE_RB is NULL');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_DaftarBeli_byPEMBELIAN_JENIS0($id, $level) { //Pembelian = [26]
|
||||
if ($level == 0) {
|
||||
$this->db->select('a.QTY_DB,c.*,d.NAMA_JENIS,e.PCM_KUANTITI as REAL');
|
||||
} else if ($level == 1) {
|
||||
$this->db->select('a.QTY_DB,c.*,d.NAMA_JENIS,e.ITP_KUANTITI as REAL');
|
||||
}
|
||||
$this->db->from('daftar_beli a');
|
||||
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
|
||||
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
|
||||
$this->db->join('kuantiti e','e.ID_KUANTITI=c.ID_BARANG');
|
||||
$this->db->where(['b.ID_PEMBELIAN' => $id]);
|
||||
$this->db->where('d.TYPE_JENIS="0"');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnBeli_byPEMBELIAN($id) { //Pembelian = [26]
|
||||
$this->db->select('*');
|
||||
$this->db->from('sn_beli a');
|
||||
$this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNB','left');
|
||||
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID','left');
|
||||
$this->db->join('daftar_beli d','d.ID_DB=a.DB_ID','left');
|
||||
$this->db->where(['d.PEMBELIAN_ID' => $id]);
|
||||
$this->db->order_by('a.NAMA_SNB ASC');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnReturBeli_byDRB_RBNull($id_drb) { //Pembelian = [26, 28]
|
||||
$this->db->select('*');
|
||||
$this->db->from('sn_returbeli a');
|
||||
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
|
||||
$this->db->join('pembelian c','c.ID_PEMBELIAN=b.PEMBELIAN_ID');
|
||||
$this->db->where(['a.DRB_ID' => $id_drb]);
|
||||
$this->db->where('b.STATUS_RB is NULL');
|
||||
$this->db->where('c.STATUS_PEMBELIAN=1');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getSum_DaftarReturBeli_byPEMBELIAN_byBARANG($id1,$id2) { //Pembelian = [27]
|
||||
$this->db->select('*,SUM(a.QTY_DRB) as TOTAL_DRB');
|
||||
$this->db->from('daftar_returbeli a');
|
||||
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID','left');
|
||||
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID','left');
|
||||
$this->db->where(['b.PEMBELIAN_ID' => $id1]);
|
||||
$this->db->where(['a.BARANG_ID' => $id2]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_ReturPembelian_byPEMBELIAN_byADMIN_Null($id1, $id2) { //Pembelian = [27]
|
||||
$this->db->select('*');
|
||||
$this->db->from('retur_pembelian');
|
||||
$this->db->where(['PEMBELIAN_ID' => $id1]);
|
||||
$this->db->where(['ADMIN_ID' => $id2]);
|
||||
$this->db->where('STATUS_RB is NULL');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getID_RBMax() { //Pembelian = [27]
|
||||
$this->db->select_max('ID_RB');
|
||||
$this->db->from('retur_pembelian');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnReturBeli_byRB_groupBARANG($id) { //Pembelian = [27]
|
||||
$this->db->select('c.BARANG_ID,a.NAMA_SNRB');
|
||||
$this->db->from('sn_returbeli a');
|
||||
$this->db->join('sn_beli b','b.DB_ID=a.DB_ID','left');
|
||||
$this->db->join('daftar_beli c','c.ID_DB=b.DB_ID','left');
|
||||
$this->db->where(['a.RB_ID' => $id]);
|
||||
$this->db->group_by('c.BARANG_ID');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_DaftarReturBeli_byRB_byBARANG_byADMIN_Null($id_rb, $id_barang, $id_admin){ //Pembelian = [27]
|
||||
$this->db->select('*');
|
||||
$this->db->from('daftar_returbeli a');
|
||||
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
|
||||
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->where(['a.RB_ID' => $id_rb]);
|
||||
$this->db->where(['a.BARANG_ID' => $id_barang]);
|
||||
$this->db->where(['b.ADMIN_ID' => $id_admin]);
|
||||
$this->db->where('b.KODE_RB is NULL');
|
||||
$this->db->where('b.STATUS_RB is NULL');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnStock_bySNB_2($id) { //Pembelian = [27]
|
||||
$this->db->select('a.BARANG_ID');
|
||||
$this->db->from('sn_stock a');
|
||||
$this->db->join('sn_beli b','b.NAMA_SNB=a.NAMA_SNSTOCK');
|
||||
$this->db->where(['b.ID_SNB' => $id]);
|
||||
$this->db->where('a.STATUS_SNSTOCK=2');
|
||||
$this->db->group_by('a.ID_SNSTOCK');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_DaftarReturBeli_byRB_groupID($id){ //Pembelian = [27]
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT(a.HARGA_DRB,2)) as HARGA,a.BARANG_ID as BID');
|
||||
$this->db->from('daftar_returbeli a');
|
||||
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID','left');
|
||||
$this->db->join('daftar_beli c','c.PEMBELIAN_ID=b.PEMBELIAN_ID','left');
|
||||
$this->db->join('barang d','d.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->join('jenis e','e.ID_JENIS=d.JENIS_ID');
|
||||
$this->db->where(['a.RB_ID' => $id]);
|
||||
$this->db->group_by('a.ID_DRB');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnReturBeli_byRB_groupID($id) { //Pembelian = [27, 31, 36]
|
||||
$this->db->select('*');
|
||||
$this->db->from('sn_returbeli a');
|
||||
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID','left');
|
||||
$this->db->where(['a.RB_ID' => $id]);
|
||||
$this->db->group_by('a.ID_SNRB');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_DaftarReturBeli_byID($id) { //Pembelian = [28, 34, 35]
|
||||
$this->db->select('*');
|
||||
$this->db->from('daftar_returbeli a');
|
||||
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
|
||||
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->where(['a.ID_DRB' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnStock_byNAMA_2($id) { //Pembelian = [28, 31, 36, 38]
|
||||
$this->db->select('ID_SNSTOCK');
|
||||
$this->db->from('sn_stock');
|
||||
$this->db->where(['NAMA_SNSTOCK' => $id]);
|
||||
$this->db->where('STATUS_SNSTOCK=2');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_DaftarReturBeli_byRB_Null($id){ //Pembelian = [28, 31]
|
||||
$this->db->select('*');
|
||||
$this->db->from('daftar_returbeli a');
|
||||
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
|
||||
$this->db->where('b.STATUS_RB is NULL');
|
||||
$this->db->where(['a.RB_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKode_ReturPembelian() { //Pembelian = [29]
|
||||
$this->db->select('MAX(KODE_RB) AS KODE');
|
||||
$this->db->from('retur_pembelian');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_ReturPembelian_Null($id){ //Pembelian = [30, 31]
|
||||
$this->db->select('*');
|
||||
$this->db->from('retur_pembelian');
|
||||
$this->db->where('STATUS_RB is NULL');
|
||||
$this->db->where(['ID_RB' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_ReturPembelian_0($id = null){ //Pembelian = [32,33, 36, 38]
|
||||
if ($id === null) {
|
||||
$this->db->select('a.ID_RB,a.KET_RB,a.KODE_RB,b.CORP_ID,b.INV_PEMBELIAN,c.NAMA_SUPPLIER,d.NAMA_KOTA,
|
||||
DATE_FORMAT(a.TGL_RB,"%d/%m/%Y") as TANGGAL');
|
||||
$this->db->from('retur_pembelian a');
|
||||
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
|
||||
$this->db->join('supplier c','c.ID_SUPPLIER=b.SUPPLIER_ID');
|
||||
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID');
|
||||
$this->db->group_by('a.ID_RB');
|
||||
$this->db->where('a.STATUS_RB=0');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('retur_pembelian a');
|
||||
$this->db->join('pembelian b','b.ID_PEMBELIAN=a.PEMBELIAN_ID');
|
||||
$this->db->join('supplier c','c.ID_SUPPLIER=b.SUPPLIER_ID');
|
||||
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID');
|
||||
$this->db->join('daftar_returbeli e','e.RB_ID=a.ID_RB','left');
|
||||
$this->db->join('barang f','f.ID_BARANG=e.BARANG_ID','left');
|
||||
$this->db->join('jenis g','g.ID_JENIS=f.JENIS_ID','left');
|
||||
$this->db->where('a.STATUS_RB=0');
|
||||
$this->db->where(['a.ID_RB' => $id]);
|
||||
$this->db->group_by('a.ID_RB');
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_DaftarReturBeli_byRB_byBARANG_0($id){ //Pembelian = [33]
|
||||
$this->db->select('*,FORMAT(a.HARGA_DRB,2) as HARGA,a.BARANG_ID as BID');
|
||||
$this->db->from('daftar_returbeli a');
|
||||
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
|
||||
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
|
||||
$this->db->join('daftar_beli e','e.PEMBELIAN_ID=b.PEMBELIAN_ID','left');
|
||||
$this->db->where('b.STATUS_RB=0');
|
||||
$this->db->where('a.BARANG_ID=e.BARANG_ID');
|
||||
$this->db->where(['a.RB_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_ReturPembelian_byID($id) { //Pembelian = [37]
|
||||
$this->db->select('*');
|
||||
$this->db->from('retur_pembelian');
|
||||
$this->db->where(['ID_RB' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKode_INVReturBeliTMP() { //Pembelian = [37]
|
||||
$this->db->select('MAX(INV_RB) AS KODE');
|
||||
$this->db->from('retur_pembelian');
|
||||
$this->db->like('INV_RB','RT/TMP', 'after');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKode_INVReturBeliDMT() { //Pembelian = [37]
|
||||
$this->db->select('MAX(INV_RB) AS KODE');
|
||||
$this->db->from('retur_pembelian');
|
||||
$this->db->like('INV_RB','RT/DMT', 'after');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKode_INVReturBeliPCM() { //Pembelian = [37]
|
||||
$this->db->select('MAX(INV_RB) AS KODE');
|
||||
$this->db->from('retur_pembelian');
|
||||
$this->db->like('INV_RB','RT/PCM', 'after');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKode_INVReturBeliSFTR() { //Pembelian = [37]
|
||||
$this->db->select('MAX(INV_RB) AS KODE');
|
||||
$this->db->from('retur_pembelian');
|
||||
$this->db->like('INV_RB','RT/SFT', 'after');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKode_INVReturBeliITP() { //Pembelian = [37]
|
||||
$this->db->select('MAX(INV_RB) AS KODE');
|
||||
$this->db->from('retur_pembelian');
|
||||
$this->db->like('INV_RB','RT/ITP', 'after');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_DaftarReturBeli_byRB_0($id){ //Pembelian = [36, 38]
|
||||
$this->db->select('*');
|
||||
$this->db->from('daftar_returbeli a');
|
||||
$this->db->join('retur_pembelian b','b.ID_RB=a.RB_ID');
|
||||
$this->db->where('b.STATUS_RB=0');
|
||||
$this->db->where(['a.RB_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnReturBeli_byRB_byBARANG($id1,$id2) { //Pembelian = [38]
|
||||
$this->db->select('a.NAMA_SNRB');
|
||||
$this->db->from('sn_returbeli a');
|
||||
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID','left');
|
||||
$this->db->where(['a.RB_ID' => $id1]);
|
||||
$this->db->where(['b.BARANG_ID' => $id2]);
|
||||
$this->db->group_by('a.ID_SNRB');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function subTempoMonth($date,$month) { //Pembelian = [39]
|
||||
$sum = strtotime(date("Y-m-d", strtotime("$date")) . " -$month months");
|
||||
$dateTo=date('Y-m-d',$sum);
|
||||
return $dateTo;
|
||||
}
|
||||
|
||||
public function getData_Pembelian_forUbah($id=null, $level=null, $tanggal_awal=null, $tanggal_akhir=null) { //Pembelian = [39, 40, 48, 50, 51]
|
||||
if ($id==NULL) {
|
||||
$this->db->select('*,DATE_FORMAT(a.TGL_INVBELI,"%d/%m/%Y") as TGL_INV,DATE_FORMAT(a.TEMPO_INVBELI,"%d/%m/%Y") as TEMPO_INV,
|
||||
,DATE_FORMAT(a.TT_PEMBELIAN,"%d/%m/%Y") as TT_INV');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('corp b','b.ID_CORP=a.CORP_ID');
|
||||
$this->db->join('supplier c','c.ID_SUPPLIER=a.SUPPLIER_ID');
|
||||
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID');
|
||||
$this->db->where('a.TGL_INVBELI>=', $tanggal_awal);
|
||||
$this->db->where('a.TGL_INVBELI<=', $tanggal_akhir);
|
||||
$this->db->where('a.STATUS_PEMBELIAN=1');
|
||||
if ($level == 0) {
|
||||
$this->db->where('a.CORP_ID<=4');
|
||||
} else if ($level == 1) {
|
||||
$this->db->where('a.CORP_ID=5');
|
||||
}
|
||||
$this->db->group_by('a.KODE_PEMBELIAN');
|
||||
$this->db->order_by('a.KODE_PEMBELIAN ASC,a.TGL_INVBELI ASC');
|
||||
} else {
|
||||
$this->db->select('*,DATE_FORMAT(a.TGL_INVBELI,"%d/%m/%Y") as TGL_INV,DATE_FORMAT(a.TEMPO_INVBELI,"%d/%m/%Y") as TEMPO_INV,
|
||||
,DATE_FORMAT(a.TT_PEMBELIAN,"%d/%m/%Y") as TT_INV');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID');
|
||||
$this->db->join('hutang_dagang d','d.PEMBELIAN_ID=a.ID_PEMBELIAN');
|
||||
$this->db->where('a.STATUS_PEMBELIAN=1');
|
||||
$this->db->where(['a.ID_PEMBELIAN' => $id]);
|
||||
$this->db->group_by('a.ID_PEMBELIAN');
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Pembelian_forINV($id, $inv) { //Pembelian = [41]
|
||||
$this->db->select('*');
|
||||
$this->db->from('pembelian');
|
||||
$this->db->where('ID_PEMBELIAN!=', $id);
|
||||
$this->db->where('INV_PEMBELIAN=', $inv);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnStock_byNAMA_AllStatus($id) { //Pembelian = [47]
|
||||
$this->db->select('ID_SNSTOCK,STATUS_SNSTOCK');
|
||||
$this->db->from('sn_stock');
|
||||
$this->db->where(['NAMA_SNSTOCK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SnReturJual_byNAMA($nama) { //Pembelian = [47]
|
||||
$this->db->select('*');
|
||||
$this->db->from('sn_returjual');
|
||||
$this->db->where(['NAMA_SNRJ' => $nama]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Pembelian_1_checkRevisi($id, $tgl) { //Pembelian = [47]
|
||||
$this->db->select('*');
|
||||
$this->db->from('pembelian');
|
||||
$this->db->where(['ID_PEMBELIAN' => $id]);
|
||||
$this->db->where('TGL_INVBELI>=', $tgl);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_HistoriKuantiti_byBARANG_byKODE($id, $kode) { //Pembelian = [50]
|
||||
$this->db->select('*');
|
||||
$this->db->from('histori_kuantiti');
|
||||
$this->db->where(['BARANG_ID' => $id]);
|
||||
$this->db->where(['KODE_BUKTI' => $kode]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_HistoriKuantiti_byKODE($kode) { //Pembelian = [50]
|
||||
$this->db->select('*');
|
||||
$this->db->from('histori_kuantiti');
|
||||
$this->db->where(['KODE_BUKTI' => $kode]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getSum_DaftarBeli_byPEMBELIAN($id) { //Pembelian = [50, 51]
|
||||
$this->db->select('sum(HARGA_DB*QTY_DB) as TOTAL');
|
||||
$this->db->from('daftar_beli');
|
||||
$this->db->where(['PEMBELIAN_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user