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_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_TransaksiStock_AllJenis_byGUDANG_Null($id) { //Persediaan = [1, 6] $this->db->select('*,FORMAT(a.HARGA_IO,2) as HARGA'); $this->db->from('transaksi_stock 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('karyawan d','d.ID_KARYAWAN=a.GUDANG_ID'); $this->db->where('a.STATUS_IO is NULL'); $this->db->where('a.SO_ID is NULL'); $this->db->where(['a.GUDANG_ID' => $id]); return $this->db->get()->result_array(); } public function getBarang_TransaksiStock0($level) { //Persediaan = [1, 26, 53, 84, 98, 114] if ($level == 0) { $this->db->select('*,c.PCM_KUANTITI as QTY'); } else if ($level == 1) { $this->db->select('*,c.ITP_KUANTITI as QTY'); } $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->where('c.PCM_KUANTITI!=0'); $this->db->order_by('c.PCM_KUANTITI DESC,b.NAMA_JENIS ASC,a.KODE_BARANG ASC'); } else if ($level == 1) { $this->db->where('c.ITP_KUANTITI!=0'); $this->db->order_by('c.ITP_KUANTITI DESC,b.NAMA_JENIS ASC,a.KODE_BARANG ASC'); } return $this->db->get()->result_array(); } public function getBarang_TransaksiStock1() { //Persediaan = [1] $this->db->select('*'); $this->db->from('barang a'); $this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID','left'); $this->db->order_by('b.NAMA_JENIS ASC,a.KODE_BARANG ASC'); $this->db->where('b.TYPE_JENIS!=2'); return $this->db->get()->result_array(); } public function getData_HargaPart_byPART() { //Persediaan = [1] $this->db->select('*'); $this->db->from('harga_part a'); $this->db->join('part b','b.ID_PART=a.PART_ID'); $this->db->order_by('b.NAMA_PART ASC, a.ID_HPAR DESC'); return $this->db->get()->result_array(); } public function getData_SalesOrder_byID($id=null) { //Persediaan = [1, 6, 97] if ($id==null) { $this->db->select('*,DATE_FORMAT(a.TGL_SO,"%d/%m/%Y") as TANGGAL'); $this->db->from('sales_order a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.SALES_ID'); $this->db->where('a.STATUS_SO=1'); } else { $this->db->select('*'); $this->db->from('sales_order'); $this->db->where(['ID_SO' => $id]); } return $this->db->get()->result_array(); } public function getData_Karyawan_byID($id=null) { //Persediaan = [1, 26, 30, 68, 77] if ($id==null) { $this->db->select('*'); $this->db->from('karyawan'); } else { $this->db->select('*'); $this->db->from('karyawan'); $this->db->where(['ID_KARYAWAN' => $id]); } return $this->db->get()->result_array(); } public function getQtyReal_TransaksiStock0($id) { //Persediaan = [1, 6, 7, 10, 11] $this->db->select('a.ID_SNIO'); $this->db->from('sn_io a'); $this->db->join('transaksi_stock b','b.ID_IO=a.IO_ID'); $this->db->group_by('a.ID_SNIO'); $this->db->where(['a.IO_ID' => $id]); $this->db->where('a.JENIS_SNIO=0'); return $this->db->count_all_results(); } public function getQtyReal_TransaksiStock1($id) { //Persediaan = [1, 6, 12, 14, 15] $this->db->select('a.ID_SNIO'); $this->db->from('sn_io a'); $this->db->join('transaksi_stock b','b.ID_IO=a.IO_ID'); $this->db->group_by('a.ID_SNIO'); $this->db->where(['a.IO_ID' => $id]); $this->db->where('a.JENIS_SNIO=1'); return $this->db->count_all_results(); } public function getData_Karyawan_forLogin($username, $password) { //Persediaan = [2, 20] $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 getData_Kuantiti_byID($id=null) { //Persediaan = [3, 4, 6, 27, 29, 46, 47, 54, 56, 67, 74, 76, 78, 86, 87, 94, 95, 96, 97, 100, 116, 118, 125, 133] if ($id==null) { $this->db->select('*'); $this->db->from('kuantiti'); } else { $this->db->select('*'); $this->db->from('kuantiti'); $this->db->where(['ID_KUANTITI' => $id]); } return $this->db->get()->result_array(); } public function getData_HargaPart_byID($id) { //Persediaan = [3] $this->db->select('*'); $this->db->from('harga_part'); $this->db->where(['ID_HPAR' => $id]); return $this->db->get()->result_array(); } public function getData_TransaksiStock_Null($id) { //Persediaan = [4, 11, 14, 15] $this->db->select('*'); $this->db->from('transaksi_stock'); $this->db->where(['ID_IO' => $id]); $this->db->where('STATUS_IO is NULL'); return $this->db->get()->result_array(); } public function getData_SnIo_byIO($id) { //Persediaan = [4] $this->db->select('*'); $this->db->from('sn_io a'); $this->db->join('transaksi_stock b','b.ID_IO=a.IO_ID'); $this->db->where(['a.IO_ID' => $id]); return $this->db->get()->result_array(); } public function getKode_TransaksiStock() { //Persediaan = [5] $this->db->select('MAX(KODE_BUKTI) AS KODE'); $this->db->from('transaksi_stock'); $this->db->like('KODE_BUKTI','KM', 'after'); return $this->db->get()->result_array(); } public function getData_SnIo_byIO_0($id) { //Persediaan = [6, 8, 9] $this->db->select('*'); $this->db->from('sn_io a'); $this->db->join('transaksi_stock b','b.ID_IO=a.IO_ID'); $this->db->join('barang c','c.ID_BARANG=b.BARANG_ID'); $this->db->where(['a.IO_ID' => $id]); $this->db->where('a.JENIS_SNIO=0'); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_AllStatus($id) { //Persediaan = [6, 11, 15, 29, 31, 36, 43, 56, 61, 67, 76, 78, 83, 108, 113, 123] $this->db->select('*'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); return $this->db->get()->result_array(); } public function getData_SnIo_byIO_1($id) { //Persediaan = [6, 12, 13] $this->db->select('*'); $this->db->from('sn_io a'); $this->db->join('transaksi_stock b','b.ID_IO=a.IO_ID'); $this->db->join('barang c','c.ID_BARANG=b.BARANG_ID'); $this->db->where(['a.IO_ID' => $id]); $this->db->where('a.JENIS_SNIO=1'); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_13($id) { //Persediaan = [6] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=13'); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_Null($id) { //Persediaan = [6] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK is NULL'); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_0($id) { //Persediaan = [6] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=0'); return $this->db->get()->result_array(); } public function getData_TransaksiStock_byID($id) { //Persediaan = [7, 10, 12] $this->db->select('*'); $this->db->from('transaksi_stock 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->where(['a.ID_IO' => $id]); return $this->db->get()->result_array(); } public function getData_SnStock_byBARANG_Null($id, $level) { //Persediaan = [7, 12, 32, 57, 79, 109, 119] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('barang b','b.ID_BARANG=a.BARANG_ID'); $this->db->where(['a.BARANG_ID' => $id]); $this->db->where('a.STATUS_SNSTOCK is NULL'); if ($level == 0) { $this->db->where('a.GUDANG_SNSTOCK=1'); } else if ($level == 1) { $this->db->where('a.GUDANG_SNSTOCK=2'); } return $this->db->get()->result_array(); } public function getData_SnStock_byBARANG_0($id, $level) { //Persediaan = [7, 12, 32, 57, 79, 109, 119] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('barang b','b.ID_BARANG=a.BARANG_ID'); $this->db->where(['a.BARANG_ID' => $id]); $this->db->where('a.STATUS_SNSTOCK=0'); if ($level == 0) { $this->db->where('a.GUDANG_SNSTOCK=1'); } else if ($level == 1) { $this->db->where('a.GUDANG_SNSTOCK=2'); } return $this->db->get()->result_array(); } public function getData_SnStock_SnIo_byNAMA_AllStatus($id) { //Persediaan = [10, 14] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('sn_io b','b.NAMA_SNIO=a.NAMA_SNSTOCK','left'); $this->db->where(['a.NAMA_SNSTOCK' => $id]); return $this->db->get()->result_array(); } public function getData_SnIo_SnStock_byNAMA_0_13($id) { //Persediaan = [10] $this->db->select('*'); $this->db->from('sn_io a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNIO','left'); $this->db->where(['a.NAMA_SNIO' => $id]); $this->db->where('a.JENIS_SNIO=0'); $this->db->where('b.STATUS_SNSTOCK=13'); return $this->db->get()->result_array(); } public function getData_SnIo_byID($id) { //Persediaan = [11, 15] $this->db->select('*'); $this->db->from('sn_io'); $this->db->where(['ID_SNIO' => $id]); return $this->db->get()->result_array(); } public function getData_SnBeli_byNAMA_AllStatus($id) { //Persediaan = [14] $this->db->select('*'); $this->db->from('sn_beli'); $this->db->where(['NAMA_SNB' => $id]); return $this->db->get()->result_array(); } public function getData_TransaksiStock_1($id=null) { //Persediaan = [16, 17] if ($id==null) { $tgl_now = date('Y-m-01'); $this->db->select('*,FORMAT(a.HARGA_IO,2) as HARGA,DATE_FORMAT(a.TGL_IO,"%d/%m/%Y") as TANGGAL'); $this->db->from('transaksi_stock a'); $this->db->join('barang b','b.ID_BARANG=a.BARANG_ID'); $this->db->where('a.HARGA_IO=0'); $this->db->where('a.STATUS_IO=1'); $this->db->where('a.JENIS_IO=1'); $this->db->where('a.SETDATA_ID IS NULL'); $this->db->where('a.HPAR_ID IS NULL'); $this->db->where('a.TGL_IO>=', $tgl_now); $this->db->order_by('a.TGL_IO ASC, b.KODE_BARANG ASC, a.KODE_BUKTI ASC'); } else { $this->db->select('*,FORMAT(a.HARGA_IO,2) as HARGA,DATE_FORMAT(a.TGL_IO,"%d/%m/%Y") as TANGGAL'); $this->db->from('transaksi_stock a'); $this->db->join('barang b','b.ID_BARANG=a.BARANG_ID'); $this->db->join('karyawan c','c.ID_KARYAWAN=a.GUDANG_ID'); $this->db->where('a.STATUS_IO=1'); $this->db->where('a.JENIS_IO=1'); $this->db->where('a.SETDATA_ID IS NULL'); $this->db->where('a.ID_IO=', $id); $this->db->order_by('a.TGL_IO ASC, b.KODE_BARANG ASC'); } return $this->db->get()->result_array(); } public function getData_HistoriKuantiti_byIO($id) { //Persediaan = [18] $this->db->select('*'); $this->db->from('histori_kuantiti a'); $this->db->join('transaksi_stock b','b.ID_IO=a.IO_ID'); $this->db->where('a.IO_ID=', $id); return $this->db->get()->result_array(); } public function getData_Operasional_Null($id=null) { //Persediaan = [19, 24, 27, 29] if ($id==null) { $this->db->select('*,DATE_FORMAT(a.TGL_OPERASIONAL,"%d/%m/%Y") as TANGGAL'); $this->db->from('operasional a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID'); $this->db->where('a.STATUS_OPERASIONAL is NULL'); } else { $this->db->select('*'); $this->db->from('operasional a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID'); $this->db->where('a.STATUS_OPERASIONAL is NULL'); $this->db->where(['a.ID_OPERASIONAL' => $id]); } return $this->db->get()->result_array(); } public function getData_Karyawan_Operasional() { //Persediaan = [19] $this->db->select('*'); $this->db->from('karyawan a'); $this->db->join('jabatan b','b.ID_JABATAN=a.JABATAN_ID'); $this->db->where('a.ID_KARYAWAN!=1'); $this->db->order_by('a.NAMA_KARYAWAN ASC'); return $this->db->get()->result_array(); } public function getKode_Operasional() { //Persediaan = [21] $this->db->select('MAX(KODE_OPERASIONAL) AS KODE'); $this->db->from('operasional'); return $this->db->get()->result_array(); } public function getData_DaftarOperasional_byOPERASIONAL($id) { //Persediaan = [24, 25, 26, 27, 29, 30, 31] $this->db->select('*'); $this->db->from('daftar_operasional a'); $this->db->join('operasional b','b.ID_OPERASIONAL=a.OPERASIONAL_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->where(['a.OPERASIONAL_ID' => $id]); return $this->db->get()->result_array(); } public function getData_Operasional_0($id=null) { //Persediaan = [25, 31] if ($id==null) { $this->db->select('*,DATE_FORMAT(a.TGL_OPERASIONAL,"%d/%m/%Y") as TANGGAL'); $this->db->from('operasional a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID'); $this->db->where('a.STATUS_OPERASIONAL=0'); $this->db->order_by('a.ID_OPERASIONAL DESC'); } else { $this->db->select('*'); $this->db->from('operasional a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.KARYAWAN_ID'); $this->db->where('a.STATUS_OPERASIONAL=0'); $this->db->where(['a.ID_OPERASIONAL' => $id]); } return $this->db->get()->result_array(); } public function getData_Operasional_byID($id) { //Persediaan = [26, 30] $this->db->select('*'); $this->db->from('operasional'); $this->db->where(['ID_OPERASIONAL' => $id]); return $this->db->get()->result_array(); } public function getData_DaftarOperasional_byID($id) { //Persediaan = [28, 32, 35, 36] $this->db->select('*'); $this->db->from('daftar_operasional a'); $this->db->join('operasional b','b.ID_OPERASIONAL=a.OPERASIONAL_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->where(['a.ID_DFO' => $id]); return $this->db->get()->result_array(); } public function getData_SnOperasional_byDFO($id) { //Persediaan = [28, 29, 30, 31, 33, 34] $this->db->select('*'); $this->db->from('sn_operasional a'); $this->db->join('daftar_operasional b','b.ID_DFO=a.DFO_ID'); $this->db->where(['a.DFO_ID' => $id]); return $this->db->get()->result_array(); } public function getQtyReal_DaftarOperasional($id) { //Persediaan = [29, 32, 35, 36] $this->db->select('a.ID_SNO'); $this->db->from('sn_operasional a'); $this->db->join('daftar_operasional b','b.ID_DFO=a.DFO_ID'); $this->db->group_by('a.ID_SNO'); $this->db->where(['a.DFO_ID' => $id]); return $this->db->count_all_results(); } public function getData_SnStock_byNAMA_14($id) { //Persediaan = [29] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=14'); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_15($id) { //Persediaan = [29] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=15'); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_4($id) { //Persediaan = [31] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=4'); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_16($id) { //Persediaan = [31] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=16'); return $this->db->get()->result_array(); } public function getData_SnStock_SnOperasional_byNAMA_AllStatus($id) { //Persediaan = [35] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('sn_operasional b','b.NAMA_SNO=a.NAMA_SNSTOCK','left'); $this->db->where(['a.NAMA_SNSTOCK' => $id]); return $this->db->get()->result_array(); } public function getData_SnOperasional_SnStock_byNAMA_14($id) { //Persediaan = [35] $this->db->select('*'); $this->db->from('sn_operasional a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNO','left'); $this->db->where(['a.NAMA_SNO' => $id]); $this->db->where('b.STATUS_SNSTOCK=14'); return $this->db->get()->result_array(); } public function getData_SnOperasional_byID($id) { //Persediaan = [36] $this->db->select('*'); $this->db->from('sn_operasional a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNO'); $this->db->where(['a.ID_SNO' => $id]); return $this->db->get()->result_array(); } public function getData_Penjualan_forPenggantian($level) { //Persediaan = [37] $tgl_now = date('Y-m-01'); $tgl_now = $this->subTempoMonth($tgl_now, 1); $this->db->select('*,DATE_FORMAT(a.TGL_PENJUALAN,"%d/%m/%Y") as TANGGAL'); $this->db->from('penjualan a'); $this->db->join('sales_order b','b.ID_SO=a.SO_ID'); $this->db->join('karyawan c','c.ID_KARYAWAN=b.SALES_ID'); $this->db->join('pelanggan d','d.ID_PELANGGAN=b.PELANGGAN_ID'); $this->db->join('kota e','e.ID_KOTA=d.KOTA_ID'); if ($level == 0) { $this->db->where('b.CORP_ID<=3'); } else if ($level == 1) { $this->db->where('b.CORP_ID>=4'); } $this->db->where('a.STATUS_PENJUALAN=1'); $this->db->where('a.TGL_PENJUALAN>="'.$tgl_now.'"'); return $this->db->get()->result_array(); } public function subTempoMonth($date,$month) { //Persediaan = [] $sum = strtotime(date("Y-m-d", strtotime("$date")) . " -$month month"); $dateTo=date('Y-m-d',$sum); return $dateTo; } public function getData_SnJual_forPenggantian($id) { //Persediaan = [38, 43] $this->db->select('*,b.BARANG_ID as BID'); $this->db->from('sn_jual a'); $this->db->join('daftar_order b','b.ID_DO=a.DO_ID'); $this->db->join('sales_order c','c.ID_SO=b.SO_ID'); $this->db->join('penjualan d','d.SO_ID=c.ID_SO'); $this->db->join('barang e','e.ID_BARANG=b.BARANG_ID'); $this->db->join('jenis f','f.ID_JENIS=e.JENIS_ID'); $this->db->join('sn_stock g','g.ID_SNSTOCK=a.SNSTOCK_GANTI','left'); $this->db->where(['d.ID_PENJUALAN' => $id]); $this->db->where('a.STATUS_SNJ=1'); return $this->db->get()->result_array(); } public function getData_SnJual_byPENJUALAN($id) { //Persediaan = [38] $this->db->select('*'); $this->db->from('sn_jual a'); $this->db->join('daftar_order b','b.ID_DO=a.DO_ID'); $this->db->join('sales_order c','c.ID_SO=b.SO_ID'); $this->db->join('penjualan d','d.SO_ID=c.ID_SO'); $this->db->join('barang e','e.ID_BARANG=b.BARANG_ID'); $this->db->join('jenis f','f.ID_JENIS=e.JENIS_ID'); $this->db->join('sn_stock g','g.NAMA_SNSTOCK=a.NAMA_SNJ'); $this->db->where(['d.ID_PENJUALAN' => $id]); $this->db->where('a.STATUS_SNJ is NULL'); $this->db->where('g.STATUS_SNSTOCK=1'); return $this->db->get()->result_array(); } public function getData_SnStock_Null($level, $id_barang=null) { //Persediaan = [38, 44] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('barang b','b.ID_BARANG=a.BARANG_ID'); $this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID'); if ($level == 0) { $this->db->where('a.GUDANG_SNSTOCK=1'); } else if ($level == 1) { $this->db->where('a.GUDANG_SNSTOCK=2'); } if ($id_barang != null) { $this->db->where('a.BARANG_ID=', $id_barang); } $this->db->where('a.STATUS_SNSTOCK is NULL'); $this->db->order_by('c.NAMA_JENIS ASC,b.KODE_BARANG ASC,a.NAMA_SNSTOCK ASC'); return $this->db->get()->result_array(); } public function getData_SnStock_0($level, $id_barang=null) { //Persediaan = [38, 44] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('barang b','b.ID_BARANG=a.BARANG_ID'); $this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID'); if ($level == 0) { $this->db->where('a.GUDANG_SNSTOCK=1'); } else if ($level == 1) { $this->db->where('a.GUDANG_SNSTOCK=2'); } if ($id_barang != null) { $this->db->where('a.BARANG_ID=', $id_barang); } $this->db->where('a.STATUS_SNSTOCK=0'); $this->db->order_by('c.NAMA_JENIS ASC,b.KODE_BARANG ASC,a.NAMA_SNSTOCK ASC'); return $this->db->get()->result_array(); } public function getData_SalesOrder_byPENJUALAN($id) { //Persediaan = [38] $this->db->select('*,DATE_FORMAT(a.TGL_SO,"%d/%m/%Y") as TANGGAL'); $this->db->from('sales_order a'); $this->db->join('penjualan b','b.SO_ID=a.ID_SO'); $this->db->join('pelanggan c','c.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->where('b.ID_PENJUALAN=', $id); return $this->db->get()->result_array(); } public function getData_SnIo_byNAMA_1($id) { //Persediaan = [38] $this->db->select('*'); $this->db->from('sn_io a'); $this->db->join('transaksi_stock b','b.ID_IO=a.IO_ID'); $this->db->join('barang c','c.ID_BARANG=b.BARANG_ID'); $this->db->where(['a.NAMA_SNIO' => $id]); $this->db->where('a.JENIS_SNIO=1'); $this->db->where('b.JENIS_IO=1'); $this->db->where('b.STATUS_IO is NULL'); return $this->db->get()->result_array(); } public function getData_Penjualan_byID_forPengantian($id) { //Persediaan = [39, 40, 41, 42, 43] $tgl_now = date('Y-m-01'); $tgl_now = $this->subTempoMonth($tgl_now, 1); $this->db->select(''); $this->db->from('penjualan a'); $this->db->join('sales_order b','b.ID_SO=a.SO_ID'); $this->db->join('karyawan c','c.ID_KARYAWAN=b.SALES_ID'); $this->db->join('pelanggan d','d.ID_PELANGGAN=b.PELANGGAN_ID'); $this->db->join('kota e','e.ID_KOTA=d.KOTA_ID'); $this->db->where('a.STATUS_PENJUALAN=1'); $this->db->where('a.TGL_PENJUALAN>="'.$tgl_now.'"'); $this->db->where(['a.ID_PENJUALAN' => $id]); return $this->db->get()->result_array(); } public function getData_SnJual_byID($id) { //Persediaan = [39, 40, 41, 42] $this->db->select('*'); $this->db->from('sn_jual a'); $this->db->join('daftar_order b','b.ID_DO=a.DO_ID'); $this->db->where(['a.ID_SNJ' => $id]); return $this->db->get()->result_array(); } public function getData_SnJual_bySNSTOCK($id) { //Persediaan = [41] $this->db->select('*'); $this->db->from('sn_jual'); $this->db->where(['SNSTOCK_GANTI' => $id]); return $this->db->get()->result_array(); } public function getData_SnStock_byID($id) { //Persediaan = [41, 43, 47] $this->db->select('*'); $this->db->from('sn_stock'); $this->db->where(['ID_SNSTOCK' => $id]); return $this->db->get()->result_array(); } public function getData_HistoriSn_byKODEBUKTI_bySNSTOCK($id1, $id2) { //Persediaan = [43] $this->db->select('*'); $this->db->from('histori_sn'); $this->db->where(['KODE_BUKTI' => $id1]); $this->db->where(['SNSTOCK_ID' => $id2]); return $this->db->get()->result_array(); } public function getData_CetakDokumen_byPENJUALAN_forSJ($id) { //Persediaan = [43] $this->db->select('*'); $this->db->from('cetak_dokumen'); $this->db->where(['PENJUALAN_ID' => $id]); $this->db->where('SJ_INV=0'); return $this->db->get()->result_array(); } public function getData_Kuantiti_Antik() { //Persediaan = [44] $this->db->select('*'); $this->db->from('kuantiti a'); $this->db->join('barang b','b.ID_BARANG=a.ID_KUANTITI'); $this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID'); $this->db->where('a.ANTIK_KUANTITI!=0'); $this->db->order_by('c.NAMA_JENIS ASC, b.KODE_BARANG ASC'); return $this->db->get()->result_array(); } public function getData_Kuantiti_Pcm_Non() { //Persediaan = [44] $this->db->select('*'); $this->db->from('kuantiti a'); $this->db->join('barang b','b.ID_BARANG=a.ID_KUANTITI'); $this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID'); $this->db->where('a.PCM_KUANTITI!=0'); $this->db->where('c.TYPE_JENIS=0'); $this->db->order_by('c.NAMA_JENIS ASC, a.PCM_KUANTITI DESC'); return $this->db->get()->result_array(); } public function getData_Kuantiti_Antik_Non() { //Persediaan = [44] $this->db->select('*'); $this->db->from('kuantiti a'); $this->db->join('barang b','b.ID_BARANG=a.ID_KUANTITI'); $this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID'); $this->db->where('a.ANTIK_KUANTITI!=0'); $this->db->where('c.TYPE_JENIS=0'); $this->db->order_by('c.NAMA_JENIS ASC, a.ANTIK_KUANTITI DESC'); return $this->db->get()->result_array(); } public function getData_SnStock_5() { //Persediaan = [44] $this->db->select('*'); $this->db->from('sn_stock 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->where('a.STATUS_SNSTOCK=5'); $this->db->order_by('c.NAMA_JENIS ASC,b.KODE_BARANG ASC,a.NAMA_SNSTOCK ASC'); return $this->db->get()->result_array(); } public function getData_SnAntik_byBARANG($id) { //Persediaan = [44] $this->db->select('a.NAMA_SNA'); $this->db->from('sn_antik a'); $this->db->join('stok_antik b','b.ID_SA=a.SA_ID'); $this->db->join('barang c','c.ID_BARANG=b.BARANG_ID'); $this->db->where('b.BARANG_ID=', $id); return $this->db->get()->result_array(); } public function getKode_StokAntik() { //Persediaan = [45] $this->db->select('MAX(KODE_SA) AS KODE'); $this->db->from('stok_antik'); $this->db->like('KODE_SA','SA', 'after'); return $this->db->get()->result_array(); } public function getID_SAMax() { //Persediaan = [47] $this->db->select_max('ID_SA'); $this->db->from('stok_antik'); return $this->db->get()->result_array(); } public function getData_Konsinyasi_Null($id = null, $level = null) { //Persediaan = [48, 52, 54, 56] if ($id==null) { $this->db->select('*,DATE_FORMAT(a.TGL_KONSINYASI,"%d/%m/%Y") as TANGGAL'); $this->db->from('konsinyasi a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.SALES_ID'); $this->db->join('pelanggan c','c.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->join('kota d','d.ID_KOTA=c.KOTA_ID'); $this->db->where('a.STATUS_KONSINYASI is NULL'); $this->db->where('a.JENIS_KONSINYASI=', $level); } else { $this->db->select('*'); $this->db->from('konsinyasi'); $this->db->where(['ID_KONSINYASI' => $id]); $this->db->where('STATUS_KONSINYASI is NULL'); } return $this->db->get()->result_array(); } public function getData_SalesAll($id = null) { //Persediaan = [48, 84, 88] if ($id === null) { $this->db->select('*, b.NAMA_JABATAN'); $this->db->from('karyawan a'); $this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID'); $this->db->where('a.ID_KARYAWAN!=1'); $this->db->where('b.NAMA_JABATAN!="GUDANG"'); $this->db->where('b.NAMA_JABATAN!="KEUANGAN"'); $this->db->where('b.NAMA_JABATAN!="UMUM"'); $this->db->where('b.NAMA_JABATAN!="SERVICE"'); $this->db->where('b.NAMA_JABATAN!="SUPPORT"'); $this->db->where('b.NAMA_JABATAN!="ADMIN GUDANG"'); $this->db->where('b.NAMA_JABATAN!="ADMIN KEUANGAN"'); $this->db->where('b.NAMA_JABATAN!="ADMIN UMUM"'); $this->db->order_by('a.NAMA_PANGGILAN_KARYAWAN'); } else { $this->db->select('*, b.NAMA_JABATAN'); $this->db->from('karyawan a'); $this->db->join('jabatan b', 'b.ID_JABATAN=a.JABATAN_ID'); $this->db->where(['ID_KARYAWAN' => $id]); } return $this->db->get()->result_array(); } public function getData_Pelanggan_byID($id = null) { //Persediaan = [48, 53, 63, 68, 84, 88] if ($id == null) { $this->db->select('*'); $this->db->from('pelanggan a'); $this->db->join('kota b','b.ID_KOTA=a.KOTA_ID'); } else { $this->db->select('*'); $this->db->from('pelanggan a'); $this->db->join('kota b','b.ID_KOTA=a.KOTA_ID'); $this->db->where(['a.ID_PELANGGAN' => $id]); } return $this->db->get()->result_array(); } public function getKode_Konsinyasi() { //Persediaan = [49] $this->db->select('MAX(KODE_KONSINYASI) AS KODE'); $this->db->from('konsinyasi'); return $this->db->get()->result_array(); } public function getData_Konsinyasi_byID($id) { //Persediaan = [51, 53] $this->db->select('*,DATE_FORMAT(a.TGL_KONSINYASI,"%d/%m/%Y") as TANGGAL'); $this->db->from('konsinyasi a'); $this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->join('kota c','c.ID_KOTA=b.KOTA_ID'); $this->db->where(['a.ID_KONSINYASI' => $id]); return $this->db->get()->result_array(); } public function getData_DaftarKonsi_byKONSINYASI($id) { //Persediaan = [52, 53, 54, 56] $this->db->select('*'); $this->db->from('daftar_konsi a'); $this->db->join('konsinyasi b','b.ID_KONSINYASI=a.KONSINYASI_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.KONSINYASI_ID' => $id]); return $this->db->get()->result_array(); } public function getQtyReal_DaftarKonsi($id) { //Persediaan = [53, 56, 57, 60, 61] $this->db->select('a.ID_SNK'); $this->db->from('sn_konsi a'); $this->db->join('daftar_konsi b','b.ID_DFK=a.DFK_ID'); $this->db->group_by('a.ID_SNK'); $this->db->where(['a.DFK_ID' => $id]); return $this->db->count_all_results(); } public function getData_DaftarKonsi_byID($id) { //Persediaan = [55, 57, 60, 61] $this->db->select('*'); $this->db->from('daftar_konsi a'); $this->db->join('konsinyasi b','b.ID_KONSINYASI=a.KONSINYASI_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->where(['a.ID_DFK' => $id]); return $this->db->get()->result_array(); } public function getData_SnKonsi_byDFK($id) { //Persediaan = [55, 56, 58, 59] $this->db->select('*'); $this->db->from('sn_konsi a'); $this->db->join('daftar_konsi b','b.ID_DFK=a.DFK_ID'); $this->db->where(['a.DFK_ID' => $id]); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_10($id) { //Persediaan = [56] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=10'); return $this->db->get()->result_array(); } public function getData_SnStock_SnKonsi_byNAMA_AllStatus($id) { //Persediaan = [60] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('sn_konsi b','b.NAMA_SNK=a.NAMA_SNSTOCK','left'); $this->db->where(['a.NAMA_SNSTOCK' => $id]); return $this->db->get()->result_array(); } public function getData_SnKonsi_SnStock_byNAMA_16($id) { //Persediaan = [60] $this->db->select('*'); $this->db->from('sn_konsi a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNK','left'); $this->db->where(['a.NAMA_SNK' => $id]); $this->db->where('b.STATUS_SNSTOCK=16'); return $this->db->get()->result_array(); } public function getData_SnKonsi_byID($id) { //Persediaan = [61, 65] $this->db->select('*'); $this->db->from('sn_konsi a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNK'); $this->db->where(['a.ID_SNK' => $id]); return $this->db->get()->result_array(); } public function getData_Konsinyasi_groupPELANGGAN($level) { //Persediaan = [62] $this->db->select('*'); $this->db->from('konsinyasi a'); $this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->join('kota c','c.ID_KOTA=b.KOTA_ID'); $this->db->where('a.JENIS_KONSINYASI=', $level); $this->db->where('a.STATUS_KONSINYASI=1'); $this->db->order_by('b.NAMA_PELANGGAN ASC'); $this->db->group_by('a.PELANGGAN_ID'); return $this->db->get()->result_array(); } public function getData_Konsinyasi_byPELANGGAN_status0($id) { //Persediaan = [62] $this->db->select('*,SUM(a.QTY_DFK) as QTYDFK'); $this->db->from('daftar_konsi 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('konsinyasi d','d.ID_KONSINYASI=a.KONSINYASI_ID'); $this->db->join('kuantiti e','e.ID_KUANTITI=a.BARANG_ID'); $this->db->where('d.STATUS_KONSINYASI=0'); $this->db->where('d.PELANGGAN_ID=', $id); $this->db->order_by('c.NAMA_JENIS ASC, b.NAMA_BARANG ASC'); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_Konsinyasi_byPELANGGAN_status1($id) { //Persediaan = [62] $this->db->select('*,SUM(a.QTY_DFK) as QTYDFK'); $this->db->from('daftar_konsi 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('konsinyasi d','d.ID_KONSINYASI=a.KONSINYASI_ID'); $this->db->join('kuantiti e','e.ID_KUANTITI=a.BARANG_ID'); $this->db->where('d.STATUS_KONSINYASI=1'); $this->db->where('d.PELANGGAN_ID=', $id); $this->db->order_by('c.NAMA_JENIS ASC, b.NAMA_BARANG ASC'); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_Konsinyasi_byPELANGGAN_allStatus($id) { //Persediaan = [62] $this->db->select('*,SUM(a.QTY_DFK) as QTYDFK'); $this->db->from('daftar_konsi 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('konsinyasi d','d.ID_KONSINYASI=a.KONSINYASI_ID'); $this->db->join('kuantiti e','e.ID_KUANTITI=a.BARANG_ID'); $this->db->where('d.PELANGGAN_ID=', $id); $this->db->order_by('c.NAMA_JENIS ASC, b.NAMA_BARANG ASC'); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanKonsi_byBARANG_byPELANGGAN_status0($id1, $id2) { //Persediaan = [62, 65] $this->db->select('*,SUM(a.QTY_DPK) as QTYDPK'); $this->db->from('daftar_penarikankonsi a'); $this->db->join('penarikan_konsi b','b.ID_PK=a.PK_ID'); $this->db->where(['a.BARANG_ID' => $id1]); $this->db->where(['b.PELANGGAN_ID' => $id2]); $this->db->where('b.STATUS_PK=0'); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanKonsi_byBARANG_byPELANGGAN_status1($id1, $id2) { //Persediaan = [62, 65] $this->db->select('*,SUM(a.QTY_DPK) as QTYDPK'); $this->db->from('daftar_penarikankonsi a'); $this->db->join('penarikan_konsi b','b.ID_PK=a.PK_ID'); $this->db->where(['a.BARANG_ID' => $id1]); $this->db->where(['b.PELANGGAN_ID' => $id2]); $this->db->where('b.STATUS_PK=1'); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanLaku_byBARANG_byPELANGGAN_status0($id1, $id2) { //Persediaan = [62, 65] $this->db->select('*,SUM(a.QTY_DPL) as QTYDPL'); $this->db->from('daftar_penarikanlaku a'); $this->db->join('penarikan_laku b','b.ID_PL=a.PL_ID'); $this->db->where(['a.BARANG_ID' => $id1]); $this->db->where(['b.PELANGGAN_ID' => $id2]); $this->db->where('b.STATUS_PL=0'); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanLaku_byBARANG_byPELANGGAN_status1($id1, $id2) { //Persediaan = [62, 65] $this->db->select('*,SUM(a.QTY_DPL) as QTYDPL'); $this->db->from('daftar_penarikanlaku a'); $this->db->join('penarikan_laku b','b.ID_PL=a.PL_ID'); $this->db->where(['a.BARANG_ID' => $id1]); $this->db->where(['b.PELANGGAN_ID' => $id2]); $this->db->where('b.STATUS_PL=1'); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_SnKonsi_byPELANGGAN_AllNull($id) { //Persediaan = [63] $this->db->select('*'); $this->db->from('sn_konsi a'); $this->db->join('daftar_konsi b','b.ID_DFK=a.DFK_ID'); $this->db->join('konsinyasi c','c.ID_KONSINYASI=b.KONSINYASI_ID'); $this->db->join('barang d','d.ID_BARANG=b.BARANG_ID'); $this->db->where(['c.PELANGGAN_ID' => $id]); $this->db->where('a.PK_ID is NULL'); $this->db->where('a.PL_ID is NULL'); $this->db->where('a.STATUS_SNK is NULL'); return $this->db->get()->result_array(); } public function getData_PenarikanKonsi_byPELANGGAN($id) { //Persediaan = [63] $this->db->select('*,SUM(a.QTY_DPK) as QTYDPK,DATE_FORMAT(d.TGL_PK,"%d/%m/%Y") as TANGGAL'); $this->db->from('daftar_penarikankonsi 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('penarikan_konsi d','d.ID_PK=a.PK_ID'); $this->db->join('kuantiti e','e.ID_KUANTITI=a.BARANG_ID'); $this->db->where('d.STATUS_PK is NULL'); $this->db->where('d.PELANGGAN_ID=', $id); $this->db->order_by('a.ID_DPK ASC'); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_SnKonsi_byBARANG_byPELANGGAN_forPenarikan($id1, $id2) { //Persediaan = [63] $this->db->select('*'); $this->db->from('sn_konsi a'); $this->db->join('daftar_konsi b','b.ID_DFK=a.DFK_ID'); $this->db->join('konsinyasi c','c.ID_KONSINYASI=b.KONSINYASI_ID'); $this->db->where(['b.BARANG_ID' => $id1]); $this->db->where(['c.PELANGGAN_ID' => $id2]); $this->db->where('a.PL_ID is NULL'); $this->db->where('c.STATUS_KONSINYASI=0'); $this->db->where('a.STATUS_SNK=0'); $this->db->where('a.PK_ID is NOT NULL'); return $this->db->get()->result_array(); } public function getData_SnKonsi_byBARANG_byPELANGGAN_forKonsinyasi($id1, $id2) { //Persediaan = [63] $this->db->select('*'); $this->db->from('sn_konsi a'); $this->db->join('daftar_konsi b','b.ID_DFK=a.DFK_ID'); $this->db->join('konsinyasi c','c.ID_KONSINYASI=b.KONSINYASI_ID'); $this->db->where(['b.BARANG_ID' => $id1]); $this->db->where(['c.PELANGGAN_ID' => $id2]); $this->db->where('c.STATUS_KONSINYASI=0'); $this->db->where('a.STATUS_SNK is NULL'); $this->db->where('a.PL_ID is NULL'); $this->db->where('a.PK_ID is NULL'); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanKonsi_byBARANG_byPELANGGAN_allStatus($id1, $id2) { //Persediaan = [63] $this->db->select('*,SUM(a.QTY_DPK) as QTYDPK'); $this->db->from('daftar_penarikankonsi a'); $this->db->join('penarikan_konsi b','b.ID_PK=a.PK_ID'); $this->db->where(['a.BARANG_ID' => $id1]); $this->db->where(['b.PELANGGAN_ID' => $id2]); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanLaku_byBARANG_byPELANGGAN_allStatus($id1, $id2) { //Persediaan = [63] $this->db->select('*,SUM(a.QTY_DPL) as QTYDPL'); $this->db->from('daftar_penarikanlaku a'); $this->db->join('penarikan_laku b','b.ID_PL=a.PL_ID'); $this->db->where(['a.BARANG_ID' => $id1]); $this->db->where(['b.PELANGGAN_ID' => $id2]); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getKode_PenarikanKonsi() { //Persediaan = [64] $this->db->select('MAX(KODE_PK) AS KODE'); $this->db->from('penarikan_konsi'); return $this->db->get()->result_array(); } public function getData_PenarikanKonsi_byPELANGGAN_orderDESC($id) { //Persediaan = [65, 67] $this->db->select('*'); $this->db->from('penarikan_konsi'); $this->db->where(['PELANGGAN_ID' => $id]); $this->db->order_by('ID_PK DESC'); $this->db->limit('1'); return $this->db->get()->result_array(); } public function getData_PenarikanKonsi_byPELANGGAN_Null($id, $level) { //Persediaan = [65] $this->db->select('*'); $this->db->from('penarikan_konsi'); $this->db->where(['PELANGGAN_ID' => $id]); $this->db->where(['JENIS_PK' => $level]); $this->db->where('STATUS_PK is NULL'); return $this->db->get()->result_array(); } public function getID_PKMax() { //Persediaan = [65] $this->db->select_max('ID_PK'); $this->db->from('penarikan_konsi'); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanKonsi_byPK($id) { //Persediaan = [65, 67] $this->db->select('*'); $this->db->from('daftar_penarikankonsi 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('penarikan_konsi d','d.ID_PK=a.PK_ID'); $this->db->where(['a.PK_ID' => $id]); return $this->db->get()->result_array(); } public function getData_SnKonsi_byID_Null($id) { //Persediaan = [65] $this->db->select('*'); $this->db->from('sn_konsi a'); $this->db->join('daftar_konsi b','b.ID_DFK=a.DFK_ID'); $this->db->where(['a.ID_SNK' => $id]); $this->db->where('a.STATUS_SNK is NULL'); return $this->db->get()->result_array(); } public function getData_DaftarKonsi_byPELANGGAN_jenis1_groupBARANG($id) { //Persediaan = [65] $this->db->select('*,SUM(a.QTY_DFK) as QTY'); $this->db->from('daftar_konsi a'); $this->db->join('konsinyasi b','b.ID_KONSINYASI=a.KONSINYASI_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->where(['b.PELANGGAN_ID' => $id]); $this->db->where('d.TYPE_JENIS=1'); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_SnKonsi_byPK_0($id) { //Persediaan = [65] $this->db->select('*'); $this->db->from('sn_konsi a'); $this->db->join('daftar_konsi b','b.ID_DFK=a.DFK_ID'); $this->db->where(['a.PK_ID' => $id]); $this->db->where('a.STATUS_SNK=0'); return $this->db->get()->result_array(); } public function getData_Konsinyasi_byBARANG_byPELANGGAN($id1, $id2) { //Persediaan = [65] $this->db->select('SUM(a.QTY_DFK) as QTYDFK'); $this->db->from('daftar_konsi 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('konsinyasi d','d.ID_KONSINYASI=a.KONSINYASI_ID'); $this->db->join('kuantiti e','e.ID_KUANTITI=a.BARANG_ID'); $this->db->where('d.STATUS_KONSINYASI=0'); $this->db->where('a.BARANG_ID=', $id1); $this->db->where('d.PELANGGAN_ID=', $id2); $this->db->group_by('a.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanKonsi_byPK_byBARANG($id1, $id2) { //Persediaan = [65] $this->db->select('*'); $this->db->from('daftar_penarikankonsi 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('penarikan_konsi d','d.ID_PK=a.PK_ID'); $this->db->where(['a.PK_ID' => $id1]); $this->db->where(['a.BARANG_ID' => $id2]); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanKonsi_byPK_byBARANG_Null($id1, $id2) { //Persediaan = [65] $this->db->select('*'); $this->db->from('daftar_penarikankonsi 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('penarikan_konsi d','d.ID_PK=a.PK_ID'); $this->db->where(['a.PK_ID' => $id1]); $this->db->where(['a.BARANG_ID' => $id2]); $this->db->where('d.STATUS_PK is NULL'); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanKonsi_byID($id) { //Persediaan = [66] $this->db->select('*'); $this->db->from('daftar_penarikankonsi 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('penarikan_konsi d','d.ID_PK=a.PK_ID'); $this->db->where(['a.ID_DPK' => $id]); return $this->db->get()->result_array(); } public function getData_SnKonsi_byPK_byBARANG($id1, $id2) { //Persediaan = [66, 67] $this->db->select('*'); $this->db->from('sn_konsi a'); $this->db->join('daftar_konsi b','b.ID_DFK=a.DFK_ID'); $this->db->where(['a.PK_ID' => $id1]); $this->db->where(['b.BARANG_ID' => $id2]); $this->db->where('a.STATUS_SNK=0'); return $this->db->get()->result_array(); } public function getData_Peminjaman_Null_0($level) { //Persediaan = [68] $this->db->select('*,b.NAMA_PANGGILAN_KARYAWAN as PEMBERI,c.NAMA_PANGGILAN_KARYAWAN as PEMINJAM, DATE_FORMAT(a.TGL_PEMINJAMAN,"%d/%m/%Y") as TANGGAL'); $this->db->from('peminjaman a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.PEMBERI_ID'); $this->db->join('karyawan c','c.ID_KARYAWAN=a.PEMINJAM_ID','left'); $this->db->join('pelanggan d','d.ID_PELANGGAN=a.PELANGGAN_ID','left'); $this->db->join('kota e','e.ID_KOTA=d.KOTA_ID','left'); $this->db->where('a.STATUS_PEMINJAMAN is NULL AND a.JENIS_PEMINJAMAN=', $level); $this->db->or_where('a.STATUS_PEMINJAMAN=0 AND a.JENIS_PEMINJAMAN=', $level); return $this->db->get()->result_array(); } public function getKode_Peminjaman($level) { //Persediaan = [69] $this->db->select('MAX(KODE_PEMINJAMAN) AS KODE'); $this->db->from('peminjaman'); if ($level == 0) { $this->db->like('KODE_PEMINJAMAN','PIN/PCM', 'after'); } else if ($level == 1) { $this->db->like('KODE_PEMINJAMAN','PIN/ITP', 'after'); } return $this->db->get()->result_array(); } public function getData_Peminjaman_Null($id) { //Persediaan = [72, 74, 76] $this->db->select('*'); $this->db->from('peminjaman'); $this->db->where(['ID_PEMINJAMAN' => $id]); $this->db->where('STATUS_PEMINJAMAN is NULL'); return $this->db->get()->result_array(); } public function getData_DaftarPinjam_byPEMINJAMAN($id) { //Persediaan = [72, 73, 74, 76, 77, 78] $this->db->select('*'); $this->db->from('daftar_pinjam a'); $this->db->join('peminjaman b','b.ID_PEMINJAMAN=a.PEMINJAMAN_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->where(['a.PEMINJAMAN_ID' => $id]); return $this->db->get()->result_array(); } public function getData_Peminjaman_byID($id) { //Persediaan = [73, 77] $this->db->select('*'); $this->db->from('peminjaman a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.PEMINJAM_ID','left'); $this->db->join('pelanggan c','c.ID_PELANGGAN=a.PELANGGAN_ID','left'); $this->db->where(['a.ID_PEMINJAMAN' => $id]); return $this->db->get()->result_array(); } public function getQtyReal_DaftarPinjam($id) { //Persediaan = [73, 76, 79, 82, 83] $this->db->select('a.ID_SNP'); $this->db->from('sn_pinjam a'); $this->db->join('daftar_pinjam b','b.ID_DFP=a.DFP_ID'); $this->db->group_by('a.ID_SNP'); $this->db->where(['a.DFP_ID' => $id]); return $this->db->count_all_results(); } public function getData_DaftarPinjam_byID($id) { //Persediaan = [75, 79, 82, 83] $this->db->select('*'); $this->db->from('daftar_pinjam a'); $this->db->join('peminjaman b','b.ID_PEMINJAMAN=a.PEMINJAMAN_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->where(['a.ID_DFP' => $id]); return $this->db->get()->result_array(); } public function getData_SnPinjam_byDFP($id) { //Persediaan = [75, 76, 77, 78, 80, 81] $this->db->select('*'); $this->db->from('sn_pinjam a'); $this->db->join('daftar_pinjam b','b.ID_DFP=a.DFP_ID'); $this->db->where(['a.DFP_ID' => $id]); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_6($id) { //Persediaan = [76] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=6'); return $this->db->get()->result_array(); } public function getData_Peminjaman_0($id) { //Persediaan = [78] $this->db->select('*'); $this->db->from('peminjaman'); $this->db->where(['ID_PEMINJAMAN' => $id]); $this->db->where('STATUS_PEMINJAMAN=0'); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_5($id) { //Persediaan = [78] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=5'); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_7($id) { //Persediaan = [78] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=7'); return $this->db->get()->result_array(); } public function getData_SnStock_SnPinjam_byNAMA_AllStatus($id) { //Persediaan = [82] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('sn_pinjam b','b.NAMA_SNP=a.NAMA_SNSTOCK','left'); $this->db->where(['a.NAMA_SNSTOCK' => $id]); return $this->db->get()->result_array(); } public function getData_SnPinjam_SnStock_byNAMA_15($id) { //Persediaan = [82] $this->db->select('*'); $this->db->from('sn_pinjam a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNP','left'); $this->db->where(['a.NAMA_SNP' => $id]); $this->db->where('b.STATUS_SNSTOCK=15'); return $this->db->get()->result_array(); } public function getData_SnPinjam_byID($id) { //Persediaan = [83] $this->db->select('*'); $this->db->from('sn_pinjam a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNP'); $this->db->where(['a.ID_SNP' => $id]); return $this->db->get()->result_array(); } public function getData_Pending_Null($id = null, $level = null) { //Persediaan = [84, 87] if ($id === null) { $this->db->select('*,DATE_FORMAT(a.TGL_PENDING,"%d/%m/%Y") as TANGGAL'); $this->db->from('pending a'); $this->db->join('barang b','b.ID_BARANG=a.BARANG_ID','left'); $this->db->join('kuantiti c','c.ID_KUANTITI=b.ID_BARANG','left'); $this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID','left'); $this->db->join('pelanggan e','e.ID_PELANGGAN=a.PELANGGAN_ID','left'); $this->db->join('kota f','f.ID_KOTA=e.KOTA_ID','left'); $this->db->join('jenis g','g.ID_JENIS=b.JENIS_ID','left'); $this->db->where('a.STATUS_PENDING is NULL'); $this->db->where('a.JENIS_PENDING=', $level); }else{ $this->db->select('*'); $this->db->from('pending'); $this->db->where(['ID_PENDING' => $id]); $this->db->where('STATUS_PENDING is NULL'); } return $this->db->get()->result_array(); } public function getData_Pending_0($id = null, $level = null) { //Persediaan = [84, 87] if ($id === null) { $this->db->select('*,DATE_FORMAT(a.TGL_PENDING,"%d/%m/%Y") as TANGGAL'); $this->db->from('pending a'); $this->db->join('barang b','b.ID_BARANG=a.BARANG_ID','left'); $this->db->join('kuantiti c','c.ID_KUANTITI=b.ID_BARANG','left'); $this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID','left'); $this->db->join('pelanggan e','e.ID_PELANGGAN=a.PELANGGAN_ID','left'); $this->db->join('kota f','f.ID_KOTA=e.KOTA_ID','left'); $this->db->join('jenis g','g.ID_JENIS=b.JENIS_ID','left'); $this->db->where('a.STATUS_PENDING=0'); $this->db->where('a.JENIS_PENDING=', $level); }else{ $this->db->select('*'); $this->db->from('pending'); $this->db->where(['ID_PENDING' => $id]); $this->db->where('STATUS_PENDING=0'); } return $this->db->get()->result_array(); } public function getKode_Pending() { //Persediaan = [85] $this->db->select('MAX(KODE_PENDING) AS KODE'); $this->db->from('pending'); return $this->db->get()->result_array(); } public function addTempoDay($date,$day) { //Persediaan = [86] $sum = strtotime(date("Y-m-d", strtotime("$date")) . " +$day days"); $dateTo=date('Y-m-d',$sum); return $dateTo; } public function getData_Proyek_forSales_Null($id) { //Persediaan = [88] $this->db->select('*,DATE_FORMAT(a.TGL_PROYEK,"%d/%m/%Y") as TANGGAL'); $this->db->from('proyek a'); $this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->join('kota c','c.ID_KOTA=b.KOTA_ID'); $this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID'); $this->db->where('a.STATUS_PROYEK is NULL'); $this->db->where(['a.SALES_ID' => $id]); return $this->db->get()->result_array(); } public function getData_Proyek_Null($id=null) { //Persediaan = [88, 94, 95, 96, 97] if ($id==null) { $this->db->select('*,DATE_FORMAT(a.TGL_PROYEK,"%d/%m/%Y") as TANGGAL'); $this->db->from('proyek a'); $this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->join('kota c','c.ID_KOTA=b.KOTA_ID'); $this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID'); $this->db->where('a.STATUS_PROYEK is NULL'); } else { $this->db->select('*'); $this->db->from('proyek a'); $this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->join('kota c','c.ID_KOTA=b.KOTA_ID'); $this->db->join('karyawan d','d.ID_KARYAWAN=a.SALES_ID'); $this->db->where('a.STATUS_PROYEK is NULL'); $this->db->where(['a.ID_PROYEK' => $id]); } return $this->db->get()->result_array(); } public function getKode_Proyek() { //Persediaan = [89] $this->db->select('MAX(KODE_PROYEK) AS KODE'); $this->db->from('proyek'); return $this->db->get()->result_array(); } public function getData_Proyek_byPO($id) { //Persediaan = [90, 91] $this->db->select('*'); $this->db->from('proyek'); $this->db->where('PO_PROYEK=', $id); return $this->db->get()->result_array(); } public function getData_Proyek_byID($id) { //Persediaan = [91, 92, 93] $this->db->select('*'); $this->db->from('proyek a'); $this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->where(['a.ID_PROYEK' => $id]); return $this->db->get()->result_array(); } public function getData_DaftarProyek_byPROYEK($id) { //Persediaan = [92, 93, 97] $this->db->select('*'); $this->db->from('daftar_proyek a'); $this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_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->where(['a.PROYEK_ID' => $id]); return $this->db->get()->result_array(); } public function getData_SlipManual_byProyek_forCheck($id) { //Persediaan = [92] $this->db->select('*'); $this->db->from('slip_manual'); $this->db->where(['PROYEK_ID' => $id]); return $this->db->get()->result_array(); } public function getData_TransaksiStock_byPROYEK($id) { //Persediaan = [92] $this->db->select('*'); $this->db->from('transaksi_stock'); $this->db->where(['PROYEK_ID' => $id]); return $this->db->get()->result_array(); } public function getData_HppProyek_byPROYEK($id) { //Persediaan = [93] $this->db->select('*,FORMAT(a.HARGA_HPR,2) as HARGA,DATE_FORMAT(a.TGL_HPR,"%d/%m/%Y") as TANGGAL'); $this->db->from('hpp_proyek a'); $this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID'); $this->db->join('daftar_kasbank c','c.ID_DKB=a.DKB_ID'); $this->db->where(['a.PROYEK_ID' => $id]); $this->db->order_by('a.ID_HPR DESC'); return $this->db->get()->result_array(); } public function getSum_HppProyek_byPROYEK($id) { //Persediaan = [93] $this->db->select('SUM(a.HARGA_HPR) as TOTAL'); $this->db->from('hpp_proyek a'); $this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_ID'); $this->db->where(['a.PROYEK_ID' => $id]); return $this->db->get()->result_array(); } public function getData_Kuantiti_Pcm_All() { //Persediaan = [93] $this->db->select('*'); $this->db->from('kuantiti a'); $this->db->join('barang b','b.ID_BARANG=a.ID_KUANTITI'); $this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID'); $this->db->where('a.PCM_KUANTITI!=0'); $this->db->where('c.TYPE_JENIS!=2'); $this->db->order_by('c.NAMA_JENIS ASC, a.PCM_KUANTITI DESC'); return $this->db->get()->result_array(); } public function getData_SalesOrder_forProyek() { //Persediaan = [93] $this->db->select('*,DATE_FORMAT(a.TGL_SO,"%d/%m/%Y") as TANGGAL'); $this->db->from('sales_order a'); $this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID'); $this->db->join('kota c','c.ID_KOTA=b.KOTA_ID'); $this->db->where('a.STATUS_SO=0'); $this->db->order_by('a.ID_SO DESC'); return $this->db->get()->result_array(); } public function getData_HistoriKuantiti_byBARANG_MasukLebih0($id) { //Persediaan = [93] $this->db->select('*,DATE_FORMAT(a.TGL_HQ,"%d/%m/%Y") as TANGGAL'); $this->db->from('histori_kuantiti 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->order_by('a.ID_HQ ASC'); $this->db->where(['a.BARANG_ID' => $id]); $this->db->where('a.MASUK_HQ>0'); return $this->db->get()->result_array(); } public function getSum_HistoriKuantiti_byBARANG_byHQ($id_barang, $id_hq) { //Persediaan = [93] $this->db->select('SUM(a.MASUK_HQ-a.KELUAR_HQ) as TOTAL, SUM(a.KELUAR_HQ) as KELUAR'); $this->db->from('histori_kuantiti 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->where(['a.BARANG_ID' => $id_barang]); $this->db->where('a.ID_HQ<=', $id_hq); return $this->db->get()->result_array(); } public function getData_HistoriKuantiti_limitHQ($id_barang, $id_hq) { //Persediaan = [93] $this->db->select('*,DATE_FORMAT(a.TGL_HQ,"%d/%m/%Y") as TANGGAL'); $this->db->from('histori_kuantiti 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->where(['a.BARANG_ID' => $id_barang]); $this->db->where('a.ID_HQ<', $id_hq); $this->db->where('a.MASUK_HQ>0'); $this->db->order_by('a.ID_HQ DESC'); $this->db->limit('1'); return $this->db->get()->result_array(); } public function getSum_HistoriKuantiti_byBARANG_byHQ1_byHQ2($id_barang, $id_hq1, $id_hq2) { //Persediaan = [93] $this->db->select('SUM(a.KELUAR_HQ) as KELUAR'); $this->db->from('histori_kuantiti 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->where(['a.BARANG_ID' => $id_barang]); $this->db->where('a.ID_HQ<=', $id_hq1); $this->db->where('a.ID_HQ>=', $id_hq2); return $this->db->get()->result_array(); } public function getCount_SnProyek_byDPR($id){ //Persediaan = [98] $this->db->select('ID_SNPR'); $this->db->from('sn_proyek'); $this->db->where('DPR_ID=', $id); return $this->db->count_all_results(); } public function getData_DaftarProyek_byBARANG($id1, $id2) { //Persediaan = [94] $this->db->select('*'); $this->db->from('daftar_proyek a'); $this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_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->where(['a.BARANG_ID' => $id1]); $this->db->where(['a.PROYEK_ID' => $id2]); return $this->db->get()->result_array(); } public function getData_DaftarProyek_byID($id) { //Persediaan = [95, 96] $this->db->select('*'); $this->db->from('daftar_proyek a'); $this->db->join('proyek b','b.ID_PROYEK=a.PROYEK_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->where(['a.ID_DPR' => $id]); return $this->db->get()->result_array(); } public function getData_DaftarService_byKARYAWAN_Null($id) { //Persediaan = [98] $this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL'); $this->db->from('daftar_service a'); $this->db->join('service b','b.ID_SERVICE=a.SERVICE_ID'); $this->db->join('karyawan c','c.ID_KARYAWAN=b.PEMBUAT_ID'); $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('b.STATUS_SERVICE is NULL'); $this->db->where('b.PEMBUAT_ID=', $id); return $this->db->get()->result_array(); } public function getCount_Service_byKARYAWAN_0($id){ //Persediaan = [98] $this->db->select('ID_SERVICE'); $this->db->from('service'); $this->db->where('STATUS_SERVICE=0'); $this->db->where('PEMBUAT_ID=', $id); return $this->db->count_all_results(); } public function getData_Service_byKARYAWAN_Null($id) { //Persediaan = [100] $this->db->select('*'); $this->db->from('service'); $this->db->where('STATUS_SERVICE is NULL'); $this->db->where('PEMBUAT_ID=', $id); return $this->db->get()->result_array(); } public function getID_ServiceMax() { //Persediaan = [100] $this->db->select_max('ID_SERVICE'); $this->db->from('service'); return $this->db->get()->result_array(); } public function getKode_Service() { //Persediaan = [99] $this->db->select('MAX(KODE_SERVICE) AS KODE'); $this->db->from('service'); $this->db->like('KODE_SERVICE','SRV', 'after'); return $this->db->get()->result_array(); } public function getData_Service_Null($id=null) { //Persediaan = [103, 108] if ($id==null) { $this->db->select('*,b.NAMA_KARYAWAN as GUDANG,c.NAMA_KARYAWAN as PENERIMA'); $this->db->from('service a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.GUDANG_ID_1'); $this->db->join('karyawan c','c.ID_KARYAWAN=a.PENERIMA_ID'); $this->db->where('a.STATUS_SERVICE is NULL'); } else { $this->db->select('*'); $this->db->from('service'); $this->db->where(['ID_SERVICE' => $id]); $this->db->where('STATUS_SERVICE is NULL'); } return $this->db->get()->result_array(); } public function getData_DaftarService_bySERVICE($id) { //Persediaan = [100, 101, 108] $this->db->select('*'); $this->db->from('daftar_service a'); $this->db->join('service b','b.ID_SERVICE=a.SERVICE_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->where(['a.SERVICE_ID' => $id]); return $this->db->get()->result_array(); } public function getData_Barang_byID($id) { //Persediaan = [100, 135] $this->db->select('*'); $this->db->from('barang a'); $this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID'); $this->db->where(['a.ID_BARANG' => $id]); return $this->db->get()->result_array(); } public function getData_SnService_bySERVICE($id) { //Persediaan = [98] $this->db->select('*,DATE_FORMAT(a.TGL_SNS,"%d/%m/%Y") as TANGGAL'); $this->db->from('sn_service a'); $this->db->join('daftar_service b','b.ID_DFS=a.DFS_ID'); $this->db->join('barang c','c.ID_BARANG=b.BARANG_ID'); $this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID'); $this->db->join('service e','e.ID_SERVICE=a.SERVICE_ID'); $this->db->where(['b.SERVICE_ID' => $id]); return $this->db->get()->result_array(); } public function getQtyReal_DaftarService($id) { //Persediaan = [108, 109, 112, 113] $this->db->select('a.ID_SNS'); $this->db->from('sn_service a'); $this->db->join('daftar_service b','b.ID_DFS=a.DFS_ID'); $this->db->group_by('a.ID_SNS'); $this->db->where(['a.DFS_ID' => $id]); return $this->db->count_all_results(); } public function getData_DaftarService_byID($id) { //Persediaan = [101, 109, 112, 113] $this->db->select('*'); $this->db->from('daftar_service a'); $this->db->join('service b','b.ID_SERVICE=a.SERVICE_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->where(['a.ID_DFS' => $id]); return $this->db->get()->result_array(); } public function getData_SnService_byDFS($id) { //Persediaan = [101, 108, 110, 111] $this->db->select('*'); $this->db->from('sn_service a'); $this->db->join('daftar_service b','b.ID_DFS=a.DFS_ID'); $this->db->where(['a.DFS_ID' => $id]); return $this->db->get()->result_array(); } public function getData_SnService_byID($id) { //Persediaan = [102, 103, 113, 129] $this->db->select('*'); $this->db->from('sn_service a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNS'); $this->db->where(['a.ID_SNS' => $id]); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_17($id) { //Persediaan = [103] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=17'); return $this->db->get()->result_array(); } public function getData_SnStock_SnService_byNAMA_AllStatus($id) { //Persediaan = [112] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('sn_service b','b.NAMA_SNS=a.NAMA_SNSTOCK','left'); $this->db->where(['a.NAMA_SNSTOCK' => $id]); return $this->db->get()->result_array(); } public function getData_SnService_SnStock_byNAMA_17($id) { //Persediaan = [112] $this->db->select('*'); $this->db->from('sn_service a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNS','left'); $this->db->where(['a.NAMA_SNS' => $id]); $this->db->where('b.STATUS_SNSTOCK=17'); return $this->db->get()->result_array(); } public function getData_DaftarMutasiBarang_byKARYAWAN_Null($id) { //Persediaan = [114] $this->db->select('*,DATE_FORMAT(b.TGL_MB,"%d/%m/%Y") as TANGGAL'); $this->db->from('daftar_mutasibarang a'); $this->db->join('mutasi_barang b','b.ID_MB=a.MB_ID'); $this->db->join('karyawan c','c.ID_KARYAWAN=b.ADMIN_ID'); $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('b.STATUS_MB is NULL'); $this->db->where('b.ADMIN_ID=', $id); return $this->db->get()->result_array(); } public function getData_MutasiBarang_0_byJENIS($id) { //Persediaan = [114] $this->db->select('*,DATE_FORMAT(a.TGL_MB,"%d/%m/%Y") as TANGGAL'); $this->db->from('mutasi_barang a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.ADMIN_ID'); $this->db->where(['a.JENIS_MB' => $id]); $this->db->where('a.STATUS_MB=0'); return $this->db->get()->result_array(); } public function getQtyReal_DaftarMutasiBarang($id) { //Persediaan = [114, 118, 119, 122, 123] $this->db->select('a.ID_SNMB'); $this->db->from('sn_mutasibarang a'); $this->db->join('daftar_mutasibarang b','b.ID_DMB=a.DMB_ID'); $this->db->group_by('a.ID_SNMB'); $this->db->where(['a.DMB_ID' => $id]); return $this->db->count_all_results(); } public function getKode_MutasiBarang($level) { //Persediaan = [115] $this->db->select('MAX(KODE_MB) AS KODE'); $this->db->from('mutasi_barang'); if ($level == 0) { $this->db->like('KODE_MB','MB/PCM', 'after'); } else if ($level == 1) { $this->db->like('KODE_MB','MB/ITP', 'after'); } return $this->db->get()->result_array(); } public function getData_MutasiBarang_byKARYAWAN_Null($id) { //Persediaan = [116] $this->db->select('*'); $this->db->from('mutasi_barang'); $this->db->where('STATUS_MB is NULL'); $this->db->where('ADMIN_ID=', $id); return $this->db->get()->result_array(); } public function getID_MutasiBarangMax() { //Persediaan = [116] $this->db->select_max('ID_MB'); $this->db->from('mutasi_barang'); return $this->db->get()->result_array(); } public function getData_DaftarMutasiBarang_byMB($id) { //Persediaan = [116, 117, 118, 124, 125, 126] $this->db->select('*'); $this->db->from('daftar_mutasibarang a'); $this->db->join('mutasi_barang b','b.ID_MB=a.MB_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->where(['a.MB_ID' => $id]); return $this->db->get()->result_array(); } public function getData_DaftarMutasiBarang_byID($id) { //Persediaan = [117, 119, 122, 123] $this->db->select('*'); $this->db->from('daftar_mutasibarang a'); $this->db->join('mutasi_barang b','b.ID_MB=a.MB_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->where(['a.ID_DMB' => $id]); return $this->db->get()->result_array(); } public function getData_SnMutasiBarang_byDMB($id) { //Persediaan = [117, 118, 120, 121, 124, 125, 126] $this->db->select('*'); $this->db->from('sn_mutasibarang a'); $this->db->join('daftar_mutasibarang b','b.ID_DMB=a.DMB_ID'); $this->db->where(['a.DMB_ID' => $id]); return $this->db->get()->result_array(); } public function getData_MutasiBarang_Null($id) { //Persediaan = [118] $this->db->select('*'); $this->db->from('mutasi_barang'); $this->db->where(['ID_MB' => $id]); $this->db->where('STATUS_MB is NULL'); return $this->db->get()->result_array(); } public function getData_SnMutasiBarang_SnStock_byNAMA_17($id) { //Persediaan = [118, 122] $this->db->select('*'); $this->db->from('sn_mutasibarang a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNMB','left'); $this->db->where(['a.NAMA_SNMB' => $id]); $this->db->where('b.STATUS_SNSTOCK=17'); return $this->db->get()->result_array(); } public function getData_SnStock_SnMutasiBarang_byNAMA_AllStatus($id) { //Persediaan = [122, 125] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('sn_mutasibarang b','b.NAMA_SNMB=a.NAMA_SNSTOCK','left'); $this->db->where(['a.NAMA_SNSTOCK' => $id]); return $this->db->get()->result_array(); } public function getData_SnMutasiBarang_byID($id) { //Persediaan = [123] $this->db->select('*'); $this->db->from('sn_mutasibarang a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNMB'); $this->db->where(['a.ID_SNMB' => $id]); return $this->db->get()->result_array(); } public function getData_MutasiBarang_byID($id) { //Persediaan = [124, 125, 126] $this->db->select('*,DATE_FORMAT(a.TGL_MB,"%d/%m/%Y") as TANGGAL'); $this->db->from('mutasi_barang a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.ADMIN_ID'); $this->db->where(['a.ID_MB' => $id]); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_18($id) { //Persediaan = [125] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=18'); return $this->db->get()->result_array(); } public function getID_TransaksiStockMax() { //Persediaan = [Terbaru] $this->db->select_max('ID_IO'); $this->db->from('transaksi_stock'); return $this->db->get()->result_array(); } public function getData_SnProyek_byDPR($id) { //Persediaan = [93] $this->db->select('*'); $this->db->from('sn_proyek a'); $this->db->join('daftar_proyek b','b.ID_DPR=a.DPR_ID'); $this->db->join('barang c','c.ID_BARANG=b.BARANG_ID'); $this->db->where(['a.DPR_ID' => $id]); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_19($id) { //RekapGp = [12] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=19'); return $this->db->get()->result_array(); } public function getData_SnStock_SnProyek_byNAMA_AllStatus($id) { //Persediaan = [] $this->db->select('*'); $this->db->from('sn_stock a'); $this->db->join('sn_proyek b','b.NAMA_SNPR=a.NAMA_SNSTOCK','left'); $this->db->where(['a.NAMA_SNSTOCK' => $id]); return $this->db->get()->result_array(); } public function getData_SnProyek_SnStock_byNAMA_19($id) { //Persediaan = [] $this->db->select('*'); $this->db->from('sn_proyek a'); $this->db->join('sn_stock b','b.NAMA_SNSTOCK=a.NAMA_SNPR','left'); $this->db->where(['a.NAMA_SNPR' => $id]); $this->db->where('b.STATUS_SNSTOCK=19'); return $this->db->get()->result_array(); } public function getData_SnProyek_byID($id) { //Persediaan = [] $this->db->select('*'); $this->db->from('sn_proyek'); $this->db->where(['ID_SNPR' => $id]); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanService_statusNull_byKARYAWAN($id) { // Persediaan [127] $this->db->select('*,DATE_FORMAT(b.TGL_PSV,"%d/%m/%Y") as TANGGAL'); $this->db->from('daftar_penarikanservice a'); $this->db->join('penarikan_service b', 'b.ID_PSV=a.PSV_ID'); $this->db->join('karyawan c', 'c.ID_KARYAWAN=b.PENGAMBIL_ID'); $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('b.STATUS_PSV is NULL'); $this->db->where('b.PENGAMBIL_ID=', $id); return $this->db->get()->result_array(); } public function getData_SnService_SnsStatus2_SnstockStatus7_psvNull($level) { // Persediaan [127] $this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL'); $this->db->from('sn_service a'); $this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID'); $this->db->join('daftar_service c', 'c.ID_DFS=a.DFS_ID'); $this->db->join('barang d', 'd.ID_BARANG=c.BARANG_ID'); $this->db->join('sn_stock e', 'e.NAMA_SNSTOCK=a.NAMA_SNS'); $this->db->where('a.STATUS_SNS=2'); $this->db->where('a.PSV_ID is NULL'); $this->db->where('e.STATUS_SNSTOCK=7'); if ($level==0) { $this->db->where('e.GUDANG_SNSTOCK=1'); } else if ($level==1) { $this->db->where('e.GUDANG_SNSTOCK=2'); } $this->db->order_by('d.KODE_BARANG ASC, a.NAMA_SNS ASC'); return $this->db->get()->result_array(); } public function getData_NonSnService_groupBARANG() { // Persediaan [127, 134] $this->db->select('*,SUM(a.MASUK_NONSNS-a.KELUAR_NONSNS) as TOTAL'); $this->db->from('nonsn_service a'); $this->db->join('barang b','b.ID_BARANG=a.BARANG_ID'); $this->db->group_by('a.BARANG_ID'); $this->db->order_by('TOTAL DESC,b.KODE_BARANG ASC'); return $this->db->get()->result_array(); } public function getData_SnService_byPSV_byBARANG($id1, $id2) { // Persediaan [127, 129, 132, 133] $this->db->select('*'); $this->db->from('sn_service a'); $this->db->join('daftar_service b','b.ID_DFS=a.DFS_ID'); $this->db->where('a.PSV_ID=', $id1); $this->db->where('b.BARANG_ID=', $id2); return $this->db->get()->result_array(); } public function getKode_PenarikanService() { //Persediaan = [128] $this->db->select('MAX(KODE_PSV) AS KODE'); $this->db->from('penarikan_service'); $this->db->like('KODE_PSV','PSV', 'after'); return $this->db->get()->result_array(); } public function getData_PenarikanService_byKARYAWAN_statusNull($id) { // Persediaan [129, 130, 133] $this->db->select('*'); $this->db->from('penarikan_service'); $this->db->where('PENGAMBIL_ID=', $id); $this->db->where('STATUS_PSV is NULL'); return $this->db->get()->result_array(); } public function getID_PenarikanServiceMax() { // Persediaan [129, 130] $this->db->select_max('ID_PSV'); $this->db->from('penarikan_service'); return $this->db->get()->result_array(); } public function getData_SnService_byPSV_groupBARANG($id) { // Persediaan [129] $this->db->select('*'); $this->db->from('sn_service a'); $this->db->join('daftar_service b','b.ID_DFS=a.DFS_ID'); $this->db->where('a.PSV_ID=', $id); $this->db->group_by('b.BARANG_ID'); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanService_byPSV_byBARANG($id1, $id2) { // Persediaan [129, 130] $this->db->select('*'); $this->db->from('daftar_penarikanservice'); $this->db->where('PSV_ID=', $id1); $this->db->where('BARANG_ID=', $id2); return $this->db->get()->result_array(); } public function getSum_NonSnService_byBARANG($id) { // Persediaan [130, 131, 133] $this->db->select('SUM(MASUK_NONSNS-KELUAR_NONSNS) as TOTAL'); $this->db->from('nonsn_service'); $this->db->where('BARANG_ID=', $id); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanService_byID($id) { // Persediaan [131, 132] $this->db->select('*'); $this->db->from('daftar_penarikanservice a'); $this->db->join('penarikan_service b','b.ID_PSV=a.PSV_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->where('a.ID_DPSV=', $id); return $this->db->get()->result_array(); } public function getData_DaftarPenarikanService_byPSV($id) { // Persediaan [133] $this->db->select('*'); $this->db->from('daftar_penarikanservice a'); $this->db->join('penarikan_service b','b.ID_PSV=a.PSV_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->where('a.PSV_ID=', $id); return $this->db->get()->result_array(); } public function getData_SnStock_byNAMA_9($id) { //Persediaan = [133] $this->db->select('ID_SNSTOCK'); $this->db->from('sn_stock'); $this->db->where(['NAMA_SNSTOCK' => $id]); $this->db->where('STATUS_SNSTOCK=9'); return $this->db->get()->result_array(); } public function getData_SnService_allStatus_InternalOnly() { // Persediaan [134] $this->db->select('*,DATE_FORMAT(b.TGL_SERVICE,"%d/%m/%Y") as TANGGAL,DATE_FORMAT(a.TGL_SNS,"%d/%m/%Y") as TANGGALAMBIL, f.NAMA_PANGGILAN_KARYAWAN as PEMBUAT,j.NAMA_PANGGILAN_KARYAWAN as PENGAMBIL'); $this->db->from('sn_service a'); $this->db->join('service b', 'b.ID_SERVICE=a.SERVICE_ID'); $this->db->join('pelanggan c', 'c.ID_PELANGGAN=b.PELANGGAN_ID','left'); $this->db->join('kota d', 'd.ID_KOTA=c.KOTA_ID','left'); $this->db->join('unitservice e', 'e.ID_UNITSERVICE=a.UNITSERVICE_ID','left'); $this->db->join('karyawan f', 'f.ID_KARYAWAN=b.PEMBUAT_ID','left'); $this->db->join('daftar_service g', 'g.ID_DFS=a.DFS_ID','left'); $this->db->join('barang h', 'h.ID_BARANG=g.BARANG_ID','left'); $this->db->join('penarikan_service i', 'i.ID_PSV=a.PSV_ID','left'); $this->db->join('karyawan j', 'j.ID_KARYAWAN=i.PENGAMBIL_ID','left'); $this->db->where('b.PELANGGAN_ID is NULL'); return $this->db->get()->result_array(); } public function getData_NonSnService_byBARANG($id) { // Persediaan [135] $this->db->select('*,DATE_FORMAT(a.TGL_NONSNS,"%d/%m/%Y") as TANGGAL'); $this->db->from('nonsn_service a'); $this->db->join('karyawan b','b.ID_KARYAWAN=a.PENERIMA_ID'); $this->db->where('a.BARANG_ID=', $id); return $this->db->get()->result_array(); } public function getData_Jenis_Not2($id = null) { // Persediaan = [136] if ($id === null) { $this->db->select('*'); $this->db->from('jenis'); $this->db->where('TYPE_JENIS!=2'); $this->db->order_by('NAMA_JENIS ASC'); }else{ $this->db->select('*'); $this->db->from('jenis'); $this->db->where(['ID_JENIS' => $id]); } return $this->db->get()->result_array(); } public function getData_StokKuantiti($all, $jenis_gudang = null, $id_jenis = null){ // Persediaan = [136] if ($jenis_gudang == null AND $all == "0") { $this->db->select('*'); $this->db->from('kuantiti a'); $this->db->join('barang b','b.ID_BARANG=a.ID_KUANTITI'); $this->db->order_by('b.KODE_BARANG ASC'); $this->db->where('a.ID_KUANTITI is NULL'); $this->db->where('a.GLOBAL_KUANTITI>0'); } else if ($all == 1) { $this->db->select('*'); $this->db->from('kuantiti a'); $this->db->join('barang b','b.ID_BARANG=a.ID_KUANTITI'); $this->db->order_by('b.KODE_BARANG ASC'); $this->db->where('a.GLOBAL_KUANTITI>0'); } else { if ($jenis_gudang=="1") { $this->db->select('a.GLOBAL_KUANTITI as QTY,CONCAT("Rp ",FORMAT(a.HARGA_AVG,2)) as AVG,b.*,c.NAMA_JENIS'); $this->db->where('a.GLOBAL_KUANTITI>0'); } else if ($jenis_gudang=="2") { $this->db->select('a.PCM_KUANTITI as QTY,CONCAT("Rp ",FORMAT(a.HARGA_AVG,2)) as AVG,b.*,c.NAMA_JENIS'); $this->db->where('a.PCM_KUANTITI>0'); } else if ($jenis_gudang=="3") { $this->db->select('a.KONSINYASI_KUANTITI as QTY,CONCAT("Rp ",FORMAT(a.HARGA_AVG,2)) as AVG,b.*,c.NAMA_JENIS'); $this->db->where('a.KONSINYASI_KUANTITI>0'); } else if ($jenis_gudang=="4") { $this->db->select('a.PEMINJAMAN_KUANTITI as QTY,CONCAT("Rp ",FORMAT(a.HARGA_AVG,2)) as AVG,b.*,c.NAMA_JENIS'); $this->db->where('a.PEMINJAMAN_KUANTITI>0'); } else if ($jenis_gudang=="5") { $this->db->select('a.PENDING_KUANTITI as QTY,CONCAT("Rp ",FORMAT(a.HARGA_AVG,2)) as AVG,b.*,c.NAMA_JENIS'); $this->db->where('a.PENDING_KUANTITI>0'); } else if ($jenis_gudang=="6") { $this->db->select('a.ANTIK_KUANTITI as QTY,CONCAT("Rp ",FORMAT(a.HARGA_AVG,2)) as AVG,b.*,c.NAMA_JENIS'); $this->db->where('a.ANTIK_KUANTITI>0'); } else if ($jenis_gudang=="7") { $this->db->select('a.PROYEK_KUANTITI as QTY,CONCAT("Rp ",FORMAT(a.HARGA_AVG,2)) as AVG,b.*,c.NAMA_JENIS'); $this->db->where('a.PROYEK_KUANTITI>0'); } else if ($jenis_gudang=="8") { $this->db->select('a.SERVICE_KUANTITI as QTY,CONCAT("Rp ",FORMAT(a.HARGA_AVG,2)) as AVG,b.*,c.NAMA_JENIS'); $this->db->where('a.SERVICE_KUANTITI>0'); } else if ($jenis_gudang=="9") { $this->db->select('a.ITP_KUANTITI as QTY,CONCAT("Rp ",FORMAT(a.HARGA_AVG,2)) as AVG,b.*,c.NAMA_JENIS'); $this->db->where('a.ITP_KUANTITI>0'); } $this->db->from('kuantiti a'); $this->db->join('barang b','b.ID_BARANG=a.ID_KUANTITI'); $this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID'); $this->db->order_by('c.NAMA_JENIS ASC, b.KODE_BARANG ASC'); if ($id_jenis!=NULL) { $this->db->where('b.JENIS_ID=', $id_jenis); } } return $this->db->get()->result_array(); } } ?>