142 lines
5.2 KiB
PHP
142 lines
5.2 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class ModelSnSku 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 getDataSnSku($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,b.PO_BELI,c.KODE_BARANG');
|
|
$this->db->from('snsku a');
|
|
$this->db->join('beli b','b.ID_BELI=a.BELI_ID');
|
|
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
|
|
}else{
|
|
$this->db->select('*,b.PO_BELI,c.KODE_BARANG');
|
|
$this->db->from('snsku a');
|
|
$this->db->join('beli b','b.ID_BELI=a.BELI_ID');
|
|
$this->db->join('barang c','c.ID_BARANG=a.BARANG_ID');
|
|
$this->db->where(['ID_SNSKU' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataIDX($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,c.ID_TYPE,d.ID_PROCESSOR,e.ID_RAM,f.ID_HDD,g.ID_SSD,h.ID_VGA,i.ID_OS,j.ID_DVD,k.ID_WARNA,l.ID_KEYMOU,m.ID_SP,n.ID_RAID');
|
|
$this->db->from('sn a');
|
|
$this->db->join('sku b','b.ID_SKU=a.ID_SKU');
|
|
$this->db->join('type c','c.ID_TYPE=b.ID_TYPE');
|
|
$this->db->join('processor d','d.ID_PROCESSOR=b.ID_PROCESSOR');
|
|
$this->db->join('ram e','e.ID_RAM=b.ID_RAM');
|
|
$this->db->join('hdd f','f.ID_HDD=b.ID_HDD');
|
|
$this->db->join('ssd g','g.ID_SSD=b.ID_SSD');
|
|
$this->db->join('vga h','h.ID_VGA=b.ID_VGA');
|
|
$this->db->join('os i','i.ID_OS=b.ID_OS');
|
|
$this->db->join('dvd j','j.ID_DVD=b.ID_DVD');
|
|
$this->db->join('warna k','k.ID_WARNA=b.ID_WARNA');
|
|
$this->db->join('keymou l','l.ID_KEYMOU=b.ID_KEYMOU');
|
|
$this->db->join('sp m','m.ID_SP=b.ID_SP');
|
|
$this->db->join('raid n','n.ID_RAID=b.ID_RAID');
|
|
}else{
|
|
$this->db->select('*,c.ID_TYPE,d.ID_PROCESSOR,e.ID_RAM,f.ID_HDD,g.ID_SSD,h.ID_VGA,i.ID_OS,j.ID_DVD,k.ID_WARNA,l.ID_KEYMOU,m.ID_SP,n.ID_RAID');
|
|
$this->db->from('sn a');
|
|
$this->db->join('sku b','b.ID_SKU=a.ID_SKU');
|
|
$this->db->join('type c','c.ID_TYPE=b.ID_TYPE');
|
|
$this->db->join('processor d','d.ID_PROCESSOR=b.ID_PROCESSOR');
|
|
$this->db->join('ram e','e.ID_RAM=b.ID_RAM');
|
|
$this->db->join('hdd f','f.ID_HDD=b.ID_HDD');
|
|
$this->db->join('ssd g','g.ID_SSD=b.ID_SSD');
|
|
$this->db->join('vga h','h.ID_VGA=b.ID_VGA');
|
|
$this->db->join('os i','i.ID_OS=b.ID_OS');
|
|
$this->db->join('dvd j','j.ID_DVD=b.ID_DVD');
|
|
$this->db->join('warna k','k.ID_WARNA=b.ID_WARNA');
|
|
$this->db->join('keymou l','l.ID_KEYMOU=b.ID_KEYMOU');
|
|
$this->db->join('sp m','m.ID_SP=b.ID_SP');
|
|
$this->db->join('raid n','n.ID_RAID=b.ID_RAID');
|
|
$this->db->where(['ID_SKU' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataID($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('b.ID_TYPE,b.ID_PROCESSOR,b.ID_RAM,b.ID_HDD,b.ID_SSD,b.ID_VGA,b.ID_OS,b.ID_DVD,b.ID_WARNA,b.ID_KEYMOU,b.ID_SP,b.ID_RAID');
|
|
$this->db->from('sn a');
|
|
$this->db->join('sku b','b.ID_SKU=a.ID_SKU');
|
|
}else{
|
|
$this->db->select('b.ID_TYPE,b.ID_PROCESSOR,b.ID_RAM,b.ID_HDD,b.ID_SSD,b.ID_VGA,b.ID_OS,b.ID_DVD,b.ID_WARNA,b.ID_KEYMOU,b.ID_SP,b.ID_RAID');
|
|
$this->db->from('sn a');
|
|
$this->db->join('sku b','b.ID_SKU=a.ID_SKU');
|
|
$this->db->where(['b.ID_SKU' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getIDBarang($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('a.BARANG_ID');
|
|
$this->db->from('beli a');
|
|
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
|
|
}else{
|
|
$this->db->select('a.BARANG_ID');
|
|
$this->db->from('beli a');
|
|
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
|
|
$this->db->where(['a.ID_BELI' => $id]);
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
public function getBeli()
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('beli a');
|
|
$this->db->join('barang b','b.ID_BARANG=a.BARANG_ID');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getSnn($id)
|
|
{
|
|
$this->db->select('ID_SNSKU, NAMA_SNSKU');
|
|
$this->db->from('snsku');
|
|
$this->db->where(['BELI_ID' => $id]);
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
}
|
|
?>
|