177 lines
6.5 KiB
PHP
177 lines
6.5 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class ModelBeli 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 getDataBeli($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,b.NAMA_SUPPLIER,c.KODE_BARANG');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
|
|
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
|
|
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
|
|
}else{
|
|
$this->db->select('*,b.NAMA_SUPPLIER,c.KODE_BARANG');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_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(['ID_BELI' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataBeliSn($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,b.NAMA_SUPPLIER,c.KODE_BARANG');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID');
|
|
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
|
|
$this->db->join('jenis d','d.ID_JENIS=c.JENIS_ID');
|
|
}else{
|
|
$this->db->select('*,b.NAMA_SUPPLIER,c.KODE_BARANG');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_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(['ID_BELI' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataBeliID($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,a.ID_BELI');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_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('HARGA_BELI is NULL',NULL,FALSE);
|
|
}else{
|
|
$this->db->select('*,a.ID_BELI');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_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('HARGA_BELI is NULL',NULL,FALSE);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataBeliSKU($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('ID_BELI');
|
|
$this->db->from('beli');
|
|
$this->db->where('SKU_ID is NULL',NULL,FALSE);
|
|
}else{
|
|
$this->db->select('ID_BELI');
|
|
$this->db->from('beli');
|
|
$this->db->where('SKU_ID is NULL',NULL,FALSE);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataBeliPWA($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,b.NAMA_SUPPLIER,c.KODE_BARANG');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_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('c.JENIS_ID<=3');
|
|
$this->db->where('a.SKU_ID is NULL',NULL,FALSE);
|
|
}else{
|
|
$this->db->select('*,b.NAMA_SUPPLIER,c.KODE_BARANG');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_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('c.JENIS_ID<=3');
|
|
$this->db->where('a.SKU_ID is NULL',NULL,FALSE);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataBeliNB($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,b.NAMA_SUPPLIER,c.KODE_BARANG');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_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('c.JENIS_ID=4');
|
|
$this->db->where('a.SKU_ID is NULL',NULL,FALSE);
|
|
}else{
|
|
$this->db->select('*,b.NAMA_SUPPLIER,c.KODE_BARANG');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_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('c.JENIS_ID=4');
|
|
$this->db->where('a.SKU_ID is NULL',NULL,FALSE);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataBeliServer($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,b.NAMA_SUPPLIER,c.KODE_BARANG');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_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('c.JENIS_ID=5');
|
|
$this->db->where('a.SKU_ID is NULL',NULL,FALSE);
|
|
}else{
|
|
$this->db->select('*,b.NAMA_SUPPLIER,c.KODE_BARANG');
|
|
$this->db->from('beli a');
|
|
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_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('c.JENIS_ID=5');
|
|
$this->db->where('a.SKU_ID is NULL',NULL,FALSE);
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
?>
|