copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class ModelTransaksi 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 getDataTransaksiHutang($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_TRANSAKSI,"%d %M %Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NILAI_TRANSAKSI,2)) as JUMLAH');
|
||||
$this->db->from('transaksi a');
|
||||
$this->db->join('relasi b','b.TRANSAKSI_ID=a.ID_TRANSAKSI','left');
|
||||
$this->db->where('a.JENIS_TRANSAKSI="Hutang"');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_TRANSAKSI,"%d %M %Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NILAI_TRANSAKSI,2)) as JUMLAH');
|
||||
$this->db->from('transaksi a');
|
||||
$this->db->join('relasi b','b.TRANSAKSI_ID=a.ID_TRANSAKSI','left');
|
||||
$this->db->where(['a.ID_TRANSAKSI' => $id]);
|
||||
$this->db->where('a.JENIS_TRANSAKSI="Hutang"');
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataTransaksi($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_TRANSAKSI,"%d %M %Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NILAI_TRANSAKSI,2)) as JUMLAH');
|
||||
$this->db->from('transaksi a');
|
||||
$this->db->join('relasi b','b.TRANSAKSI_ID=a.ID_TRANSAKSI','left');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_TRANSAKSI,"%d %M %Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NILAI_TRANSAKSI,2)) as JUMLAH');
|
||||
$this->db->from('transaksi a');
|
||||
$this->db->join('relasi b','b.TRANSAKSI_ID=a.ID_TRANSAKSI','left');
|
||||
$this->db->where(['a.ID_TRANSAKSI' => $id]);
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataPembelianHarga($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_SJBELI,"%d %M %Y")) AS WAKTU');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID','left');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID','left');
|
||||
$this->db->where('a.STATUS_PEMBELIAN="SJ SUDAH PROSES"');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_SJBELI,"%d %M %Y")) AS WAKTU');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID','left');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID','left');
|
||||
$this->db->where(['a.ID_PEMBELIAN' => $id]);
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataPembelianStock($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_SJBELI,"%d %M %Y")) AS WAKTU');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID','left');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID','left');
|
||||
$this->db->join('stock d','d.PEMBELIAN_ID=a.ID_PEMBELIAN','left');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_SJBELI,"%d %M %Y")) AS WAKTU');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID','left');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID','left');
|
||||
$this->db->join('stock d','d.PEMBELIAN_ID=a.ID_PEMBELIAN','left');
|
||||
$this->db->where(['a.ID_PEMBELIAN' => $id]);
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getStock($id = null) {
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('barang b', 'b.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->where(['a.ID_STOCK' => $id]);
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('barang b', 'b.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->where(['a.ID_STOCK' => $id]);
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataTambahStock($id)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('stock b', 'b.PEMBELIAN_ID=a.ID_PEMBELIAN');
|
||||
$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('gudang e', 'e.ID_GUDANG=b.GUDANG_ID');
|
||||
$this->db->join('sn f', 'f.STOCK_ID=b.ID_STOCK','left');
|
||||
$this->db->where(['a.ID_PEMBELIAN' => $id]);
|
||||
$this->db->group_by('b.ID_STOCK');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getPembelianHarga($id)
|
||||
{
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT(f.DPP_BELI_SATUAN,0)) as SATUAN,CONCAT("Rp ",FORMAT(f.DPP_BELI_TOTAL,0)) as JUMLAH');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('stock b', 'b.PEMBELIAN_ID=a.ID_PEMBELIAN');
|
||||
$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('gudang e', 'e.ID_GUDANG=b.GUDANG_ID');
|
||||
$this->db->join('harga f', 'f.STOCK_ID=b.ID_STOCK','left');
|
||||
$this->db->where(['a.ID_PEMBELIAN' => $id]);
|
||||
$this->db->group_by('b.ID_STOCK');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getStockID($id)
|
||||
{
|
||||
$this->db->select('a.*, b.KODE_BARANG, b.NAMA_BARANG,b.QTY_REAL,c.TYPE_JENIS');
|
||||
$this->db->from('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_STOCK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getStockTitle($id)
|
||||
{
|
||||
$this->db->select('b.NAMA_BARANG');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('barang b', 'b.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->where(['a.ID_STOCK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getStockHarga($id)
|
||||
{
|
||||
$this->db->select('a.*, b.KODE_BARANG, b.NAMA_BARANG');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('barang b', 'b.ID_BARANG=a.BARANG_ID');
|
||||
$this->db->join('harga c', 'c.STOCK_ID=a.ID_STOCK');
|
||||
$this->db->where(['a.ID_STOCK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getQtyPembelian($id)
|
||||
{
|
||||
$this->db->select('QTY,BLOCKADDSN');
|
||||
$this->db->from('stock');
|
||||
$this->db->where(['ID_STOCK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getQtyPembelianSn($id)
|
||||
{
|
||||
$this->db->select('b.ID_SN');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('sn b','b.STOCK_ID=a.ID_STOCK');
|
||||
$this->db->where(['ID_STOCK' => $id]);
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
public function getStockSn($id)
|
||||
{
|
||||
$this->db->select('b.ID_STOCK');
|
||||
$this->db->from('pembelian a');
|
||||
$this->db->join('stock b','b.PEMBELIAN_ID=a.ID_PEMBELIAN');
|
||||
$this->db->join('sn c','c.STOCK_ID=b.ID_STOCK');
|
||||
$this->db->where(['a.ID_PEMBELIAN' => $id]);
|
||||
$this->db->group_by('b.ID_STOCK');
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getBlockAddSn($id)
|
||||
{
|
||||
$this->db->select('a.ID_SN');
|
||||
$this->db->from('sn a');
|
||||
$this->db->join('stock b','b.ID_STOCK=a.STOCK_ID');
|
||||
$this->db->where(['b.ID_STOCK' => $id]);
|
||||
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
public function getQtyStockSn($id)
|
||||
{
|
||||
$this->db->select('a.ID_SN');
|
||||
$this->db->from('sn a');
|
||||
$this->db->join('stock b','b.ID_STOCK=a.STOCK_ID');
|
||||
$this->db->join('pembelian c','c.ID_PEMBELIAN=b.PEMBELIAN_ID');
|
||||
$this->db->where(['b.ID_STOCK' => $id]);
|
||||
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
public function getDataSn($id)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('sn');
|
||||
$this->db->where(['STOCK_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDetailPembelianID($id)
|
||||
{
|
||||
$this->db->select('STOCK_ID');
|
||||
$this->db->from('sn');
|
||||
$this->db->where(['ID_SN' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getSJPembelian($id)
|
||||
{
|
||||
$this->db->select('SJ_PEMBELIAN');
|
||||
$this->db->from('pembelian');
|
||||
$this->db->where(['ID_PEMBELIAN' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getGudangSN()
|
||||
{
|
||||
$this->db->select_max('ID_SN');
|
||||
$this->db->from('sn');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getStockHargaID()
|
||||
{
|
||||
$this->db->select_max('ID_HARGA');
|
||||
$this->db->from('harga');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getGudangStock($id)
|
||||
{
|
||||
$this->db->select('b.GUDANG_ID');
|
||||
$this->db->from('sn a');
|
||||
$this->db->join('stock b','b.ID_STOCK=a.STOCK_ID');
|
||||
$this->db->where(['a.ID_SN' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getBarangStock($id)
|
||||
{
|
||||
$this->db->select('b.BARANG_ID,b.BLOCKADDSN,c.QTY_REAL');
|
||||
$this->db->from('sn a');
|
||||
$this->db->join('stock b','b.ID_STOCK=a.STOCK_ID');
|
||||
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID');
|
||||
$this->db->where(['b.ID_STOCK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user