copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class ModelStock 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 getDataStock($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID','left');
|
||||
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID','left');
|
||||
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID','left');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID','left');
|
||||
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID','left');
|
||||
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID','left');
|
||||
$this->db->where(['a.ID_STOCK' => $id]);
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataSetStock($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT(b.HARGA_DB,2)) as HARGA,a.GUDANG_ID as GID1,d.NAMA_GUDANG as GNA1');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID','left');
|
||||
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID','left');
|
||||
$this->db->join('gudang d','d.ID_GUDANG=a.GUDANG_ID','left');
|
||||
$this->db->join('jenis e','e.ID_JENIS=c.JENIS_ID','left');
|
||||
$this->db->join('sn f','f.STOCK_ID=a.ID_STOCK','left');
|
||||
$this->db->join('gudang g','g.ID_GUDANG=f.GUDANG_ID','left');
|
||||
$this->db->group_by('a.ID_STOCK');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT(b.HARGA_DB,2)) as HARGA,a.GUDANG_ID as GID1,d.NAMA_GUDANG as GNA1');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID','left');
|
||||
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID','left');
|
||||
$this->db->join('gudang d','d.ID_GUDANG=a.GUDANG_ID','left');
|
||||
$this->db->join('jenis e','e.ID_JENIS=c.JENIS_ID','left');
|
||||
$this->db->join('sn f','f.STOCK_ID=a.ID_STOCK','left');
|
||||
$this->db->join('gudang g','g.ID_GUDANG=f.GUDANG_ID','left');
|
||||
$this->db->group_by('a.ID_STOCK');
|
||||
$this->db->where(['a.ID_STOCK' => $id]);
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getQtyReal($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(['a.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 getDataSnStock($id)
|
||||
{
|
||||
$this->db->select('b.GUDANG_ID,a.STOCK_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 getID_DH($id)
|
||||
{
|
||||
$this->db->select('ID_DH');
|
||||
$this->db->from('daftar_harga');
|
||||
$this->db->where(['BARANG_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getID_DB() {
|
||||
$this->db->select_max('ID_DB');
|
||||
$this->db->from('daftar_beli');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getID_SN() {
|
||||
$this->db->select_max('ID_SN');
|
||||
$this->db->from('sn');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getID_STOCK() {
|
||||
$this->db->select_max('ID_STOCK');
|
||||
$this->db->from('stock');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function delKuantiti($id){
|
||||
$this->db->where(['BARANG_ID' => $id]);
|
||||
$this->db->delete('kuantiti');
|
||||
}
|
||||
|
||||
public function delSn($id){
|
||||
$this->db->where(['STOCK_ID' => $id]);
|
||||
$this->db->delete('sn');
|
||||
}
|
||||
|
||||
public function getKuantitiData($id) {
|
||||
$this->db->select('e.ID_KUANTITI,e.READY_KUANTITI');
|
||||
$this->db->from('sn a');
|
||||
$this->db->join('stock b','b.ID_STOCK=a.STOCK_ID');
|
||||
$this->db->join('daftar_beli c','c.ID_DB=b.DB_ID');
|
||||
$this->db->join('barang d','d.ID_BARANG=c.BARANG_ID');
|
||||
$this->db->join('kuantiti e','e.BARANG_ID=d.ID_BARANG','left');
|
||||
$this->db->where(['b.ID_STOCK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataKuantiti($id) {
|
||||
$this->db->select('d.ID_KUANTITI,d.READY_KUANTITI');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('daftar_beli b','b.ID_DB=a.DB_ID');
|
||||
$this->db->join('barang c','c.ID_BARANG=b.BARANG_ID');
|
||||
$this->db->join('kuantiti d','d.BARANG_ID=c.ID_BARANG','left');
|
||||
$this->db->where(['a.ID_STOCK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataJenis($id) {
|
||||
$this->db->select('b.TYPE_JENIS');
|
||||
$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 getDataStockPesanan($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID','left');
|
||||
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID','left');
|
||||
$this->db->group_by('a.BARANG_ID');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('stock a');
|
||||
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID','left');
|
||||
$this->db->join('jenis c','c.ID_JENIS=b.JENIS_ID','left');
|
||||
$this->db->group_by('a.BARANG_ID');
|
||||
$this->db->where(['a.ID_STOCK' => $id]);
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataBarangPembelian($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('barang a');
|
||||
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID','left');
|
||||
$this->db->order_by('KODE_BARANG','ASC');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('barang a');
|
||||
$this->db->join('jenis b','b.ID_JENIS=a.JENIS_ID','left');
|
||||
$this->db->where(['a.ID_BARANG' => $id]);
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKodeBarangPWA($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('barang');
|
||||
$this->db->where('JENIS_ID<=3');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('barang');
|
||||
$this->db->where('JENIS_ID<=3');
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKodeBarangNB($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('barang');
|
||||
$this->db->where('JENIS_ID=4');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('barang');
|
||||
$this->db->where('JENIS_ID=4');
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKodeBarangServer($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('barang');
|
||||
$this->db->where('JENIS_ID=5');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('barang');
|
||||
$this->db->where('JENIS_ID=5');
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function cekPass($id, $pass)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('karyawan');
|
||||
$this->db->where(['ID_KARYAWAN' => $id]);
|
||||
$this->db->where(['PASSWORD' => $pass]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user