50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
class ModelSkuHarga 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 getDataSkuHarga($id = null)
|
|
{
|
|
if ($id === null) {
|
|
$this->db->select('*, b.HPP,c.NO_PO');
|
|
$this->db->from('skuharga a');
|
|
$this->db->join('harga b', 'b.ID_HARGA=a.ID_HARGA');
|
|
$this->db->join('sku c', 'c.ID_SKU=a.ID_SKU');
|
|
} else {
|
|
$this->db->select('*, b.HPP,c.NO_PO');
|
|
$this->db->from('skuharga a');
|
|
$this->db->join('harga b', 'b.ID_HARGA=a.ID_HARGA');
|
|
$this->db->join('sku c', 'c.ID_SKU=a.ID_SKU');
|
|
$this->db->where(['ID_SKUHARGA' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
}
|