copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class ModelDpPembelian 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 getDataDpPembelian($id=null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,a.KODE_BUKTI AS KB,CONCAT(DATE_FORMAT(a.TGL_DPB,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_DPB,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT,CONCAT("Rp ",FORMAT(b.SALDO_SUPPLIER,2)) as SALDO,CONCAT("Rp ",FORMAT(b.PIUTANG_SUPPLIER,2)) as PIUTANG');
|
||||
$this->db->from('dp_pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID','left');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID','left');
|
||||
$this->db->join('detail_dpb d','d.DPB_ID=a.ID_DPB','left');
|
||||
$this->db->where('a.STATUS_DPB is NULL');
|
||||
$this->db->group_by('a.ID_DPB');
|
||||
}else{
|
||||
$this->db->select('*,a.KODE_BUKTI AS KB,CONCAT(DATE_FORMAT(a.TGL_DPB,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_DPB,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT,CONCAT("Rp ",FORMAT(b.SALDO_SUPPLIER,2)) as SALDO,CONCAT("Rp ",FORMAT(b.PIUTANG_SUPPLIER,2)) as PIUTANG');
|
||||
$this->db->from('dp_pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID','left');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID','left');
|
||||
$this->db->join('detail_dpb d','d.DPB_ID=a.ID_DPB','left');
|
||||
$this->db->where('a.STATUS_DPB is NULL');
|
||||
$this->db->where(['a.ID_DPB' => $id]);
|
||||
$this->db->group_by('a.ID_DPB');
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataDpPembelianDetail($id=null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT(a.NOMINAL_DPB,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT');
|
||||
$this->db->from('dp_pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID','left');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID','left');
|
||||
$this->db->join('detail_dpb d','d.DPB_ID=a.ID_DPB','left');
|
||||
$this->db->where('a.NOMINAL_DPB!=a.BLOCKCON');
|
||||
$this->db->group_by('a.ID_DPB');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT(a.NOMINAL_DPB,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT');
|
||||
$this->db->from('dp_pembelian a');
|
||||
$this->db->join('supplier b','b.ID_SUPPLIER=a.SUPPLIER_ID','left');
|
||||
$this->db->join('kota c','c.ID_KOTA=b.KOTA_ID','left');
|
||||
$this->db->join('detail_dpb d','d.DPB_ID=a.ID_DPB','left');
|
||||
$this->db->where('a.NOMINAL_DPB!=a.BLOCKCON');
|
||||
$this->db->where(['a.ID_DPB' => $id]);
|
||||
$this->db->group_by('a.ID_DPB');
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
//Step Two, Input Transaksi
|
||||
public function getDataDetailDpPembelian($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_DPB,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_DPB,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT');
|
||||
$this->db->from('dp_pembelian a');
|
||||
$this->db->join('detail_dpb b','b.DPB_ID=a.ID_DPB');
|
||||
$this->db->join('hutang_dagang c','c.ID_HDA=b.HDA_ID','left');
|
||||
$this->db->join('pembelian d','d.ID_PEMBELIAN=c.PEMBELIAN_ID','left');
|
||||
$this->db->join('supplier e','e.ID_SUPPLIER=d.SUPPLIER_ID','left');
|
||||
$this->db->join('kota f','f.ID_KOTA=e.KOTA_ID','left');
|
||||
$this->db->group_by('b.ID_DDPB');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_DPB,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_DPB,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT');
|
||||
$this->db->from('dp_pembelian a');
|
||||
$this->db->join('detail_dpb b','b.DPB_ID=a.ID_DPB');
|
||||
$this->db->join('hutang_dagang c','c.ID_HDA=b.HDA_ID','left');
|
||||
$this->db->join('pembelian d','d.ID_PEMBELIAN=c.PEMBELIAN_ID','left');
|
||||
$this->db->join('supplier e','e.ID_SUPPLIER=d.SUPPLIER_ID','left');
|
||||
$this->db->join('kota f','f.ID_KOTA=e.KOTA_ID','left');
|
||||
$this->db->where(['a.ID_DPB' => $id]);
|
||||
$this->db->group_by('b.ID_DDPB');
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getTitleDPB($id) {
|
||||
$this->db->select('KODE_DPB,CONCAT("Rp ",FORMAT(NOMINAL_DPB,2)) as KREDIT,CONCAT("Rp ",FORMAT(BLOCKCON,2)) as DEBIT');
|
||||
$this->db->from('dp_pembelian');
|
||||
$this->db->where(['ID_DPB' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataHutangDagang($id) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('hutang_dagang');
|
||||
$this->db->where(['ID_HDA' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDpPembelian($id) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('dp_pembelian');
|
||||
$this->db->where(['ID_DPB' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataDDPB($id) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('detail_dpb');
|
||||
$this->db->where(['ID_DDPB' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getIDDDPB() {
|
||||
$this->db->select_max('ID_DDPB');
|
||||
$this->db->from('detail_dpb');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getIDDHDA() {
|
||||
$this->db->select_max('ID_DHDA');
|
||||
$this->db->from('detail_hda');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataDPB($id) {
|
||||
$this->db->select('b.NOMINAL_DPB,b.BLOCKCON');
|
||||
$this->db->from('detail_dpb a');
|
||||
$this->db->join('dp_pembelian b','b.ID_DPB=a.DPB_ID','left');
|
||||
$this->db->where(['ID_DDPB' => $id]);
|
||||
$this->db->group_by('ID_DDPB');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataHDA($id) {
|
||||
$this->db->select('b.NOMINAL_HDA,b.BLOCKCON');
|
||||
$this->db->from('detail_hda a');
|
||||
$this->db->join('hutang_dagang b','b.ID_HDA=a.HDA_ID','left');
|
||||
$this->db->where(['ID_DHDA' => $id]);
|
||||
$this->db->group_by('ID_DHDA');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataSupplier($id) {
|
||||
$this->db->select('PIUTANG_SUPPLIER,SALDO_SUPPLIER');
|
||||
$this->db->from('supplier');
|
||||
$this->db->where(['ID_SUPPLIER' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKodeDetailDPB() {
|
||||
$this->db->select('MAX(KODE_DDPB) AS KODE');
|
||||
$this->db->from('detail_dpb');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKodeDetailHDA() {
|
||||
$this->db->select('MAX(KODE_DHDA) AS KODE');
|
||||
$this->db->from('detail_hda');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function hapusDetailHda($id){
|
||||
$this->db->where(['KODE_BUKTI' => $id]);
|
||||
$this->db->delete('detail_hda');
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user