72 lines
2.4 KiB
PHP
72 lines
2.4 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
class ModelSku 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 getDataSku($id = null)
|
|
{
|
|
if ($id === null) {
|
|
$this->db->select('*');
|
|
$this->db->from('sku a');
|
|
$this->db->join('distributor b', 'b.ID_DISTRIBUTOR=a.ID_DISTRIBUTOR');
|
|
$this->db->join('processor c', 'c.ID_PROCESSOR=a.ID_PROCESSOR');
|
|
$this->db->join('ram d', 'd.ID_RAM=a.ID_RAM');
|
|
$this->db->join('hdd e', 'e.ID_HDD=a.ID_HDD');
|
|
$this->db->join('ssd f', 'f.ID_SSD=a.ID_SSD');
|
|
$this->db->join('os g', 'g.ID_OS=a.ID_OS');
|
|
$this->db->join('vga h', 'h.ID_VGA=a.ID_VGA');
|
|
$this->db->join('monitor i', 'i.ID_MONITOR=a.ID_MONITOR');
|
|
$this->db->join('warna j', 'j.ID_WARNA=a.ID_WARNA');
|
|
} else {
|
|
$this->db->select('*');
|
|
$this->db->from('sku a');
|
|
$this->db->join('distributor b', 'b.ID_DISTRIBUTOR=a.ID_DISTRIBUTOR');
|
|
$this->db->join('processor c', 'c.ID_PROCESSOR=a.ID_PROCESSOR');
|
|
$this->db->join('ram d', 'd.ID_RAM=a.ID_RAM');
|
|
$this->db->join('hdd e', 'e.ID_HDD=a.ID_HDD');
|
|
$this->db->join('ssd f', 'f.ID_SSD=a.ID_SSD');
|
|
$this->db->join('os g', 'g.ID_OS=a.ID_OS');
|
|
$this->db->join('vga h', 'h.ID_VGA=a.ID_VGA');
|
|
$this->db->join('monitor i', 'i.ID_MONITOR=a.ID_MONITOR');
|
|
$this->db->join('warna j', 'j.ID_WARNA=a.ID_WARNA');
|
|
$this->db->where(['ID_SKU' => $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();
|
|
}
|
|
}
|