74 lines
2.8 KiB
PHP
74 lines
2.8 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
class ModelConfig 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 getDataConfig($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,b.NO_INVOICE,c.NAMA_DISTRIBUTOR,FORMAT(b.HPP-SUM(g.POTONGAN),0) as HPP_REAL,d.NAMA_STATUSGUDANG,e.NAMA_STATUSPENJUALAN');
|
|
$this->db->from('sn a');
|
|
$this->db->join('invoice b','b.ID_INVOICE=a.ID_INVOICE');
|
|
$this->db->join('distributor c','c.ID_DISTRIBUTOR=b.ID_DISTRIBUTOR');
|
|
$this->db->join('statusgudang d','d.ID_STATUSGUDANG=a.ID_STATUSGUDANG');
|
|
$this->db->join('statuspenjualan e','e.ID_STATUSPENJUALAN=a.ID_STATUSPENJUALAN');
|
|
$this->db->join('promo g','g.ID_INVOICE=a.ID_INVOICE');
|
|
$this->db->group_by('a.ID_SN');
|
|
}else{
|
|
$this->db->select('*,b.NO_INVOICE,c.NAMA_DISTRIBUTOR,FORMAT(b.HPP-SUM(g.POTONGAN),0) as HPP_REAL,d.NAMA_STATUSGUDANG,e.NAMA_STATUSPENJUALAN');
|
|
$this->db->from('sn a');
|
|
$this->db->join('invoice b','b.ID_INVOICE=a.ID_INVOICE');
|
|
$this->db->join('distributor c','c.ID_DISTRIBUTOR=b.ID_DISTRIBUTOR');
|
|
$this->db->join('statusgudang d','d.ID_STATUSGUDANG=a.ID_STATUSGUDANG');
|
|
$this->db->join('statuspenjualan e','e.ID_STATUSPENJUALAN=a.ID_STATUSPENJUALAN');
|
|
$this->db->join('promo g','g.ID_INVOICE=a.ID_INVOICE');
|
|
$this->db->group_by('a.ID_SN');
|
|
$this->db->where(['ID_SN' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataSnBelumLaku($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*');
|
|
$this->db->from('sn a');
|
|
$this->db->join('statuspenjualan b','b.ID_STATUSPENJUALAN=a.ID_STATUSPENJUALAN');
|
|
$this->db->where('a.ID_STATUSPENJUALAN=1');
|
|
}else{
|
|
$this->db->select('*');
|
|
$this->db->from('sn a');
|
|
$this->db->join('statuspenjualan b','b.ID_STATUSPENJUALAN=a.ID_STATUSPENJUALAN');
|
|
$this->db->where('a.ID_STATUSPENJUALAN=1');
|
|
$this->db->where(['ID_SN' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
}
|