Files
2026-06-13 16:02:07 +10:00

179 lines
7.0 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelDpPajak 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 getDataDpPajak($id=null){
if ($id === null) {
$this->db->select('*,a.KODE_BUKTI AS KB,CONCAT(DATE_FORMAT(a.TGL_DPP,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_DPP,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT,CONCAT("Rp ",FORMAT(b.SALDO_PAJAK,2)) as SALDO,CONCAT("Rp ",FORMAT(b.HUTANG_PAJAK,2)) as HUTANG');
$this->db->from('dp_pajak a');
$this->db->join('pajak b','b.ID_PAJAK=a.PAJAK_ID','left');
$this->db->join('detail_dpp c','c.DPP_ID=a.ID_DPP','left');
$this->db->where('a.STATUS_DPP is NULL');
$this->db->group_by('a.ID_DPP');
}else{
$this->db->select('*,a.KODE_BUKTI AS KB,CONCAT(DATE_FORMAT(a.TGL_DPP,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_DPP,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT,CONCAT("Rp ",FORMAT(b.SALDO_PAJAK,2)) as SALDO,CONCAT("Rp ",FORMAT(b.HUTANG_PAJAK,2)) as HUTANG');
$this->db->from('dp_pajak a');
$this->db->join('pajak b','b.ID_PAJAK=a.PAJAK_ID','left');
$this->db->join('detail_dpp c','c.DPP_ID=a.ID_DPP','left');
$this->db->where('a.STATUS_DPP is NULL');
$this->db->group_by('a.ID_DPP');
$this->db->where(['a.ID_DPP' => $id]);
}
return $this->db->get()->result_array();
}
public function getDataDpPajakDetail($id=null){
if ($id === null) {
$this->db->select('*,CONCAT("Rp ",FORMAT(a.NOMINAL_DPP,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT');
$this->db->from('dp_pajak 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.DPP_ID=a.ID_DPP','left');
$this->db->where('a.NOMINAL_DPP!=a.BLOCKCON');
$this->db->group_by('a.ID_DPP');
}else{
$this->db->select('*,CONCAT("Rp ",FORMAT(a.NOMINAL_DPP,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT');
$this->db->from('dp_pajak 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.DPP_ID=a.ID_DPP','left');
$this->db->where('a.NOMINAL_DPP!=a.BLOCKCON');
$this->db->where(['a.ID_DPP' => $id]);
$this->db->group_by('a.ID_DPP');
}
return $this->db->get()->result_array();
}
//Step Two, Input Transaksi
public function getDataDetailDpPajak($id = null){
if ($id === null) {
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_DPP,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_DPP,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT');
$this->db->from('dp_pajak a');
$this->db->join('detail_dpb b','b.DPP_ID=a.ID_DPP');
$this->db->join('hutang_dagang c','c.ID_HDA=b.HDA_ID','left');
$this->db->join('pajak 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_DDPP');
}else{
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_DPP,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_DPP,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as DEBIT');
$this->db->from('dp_pajak a');
$this->db->join('detail_dpb b','b.DPP_ID=a.ID_DPP');
$this->db->join('hutang_dagang c','c.ID_HDA=b.HDA_ID','left');
$this->db->join('pajak 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_DPP' => $id]);
$this->db->group_by('b.ID_DDPP');
}
return $this->db->get()->result_array();
}
public function getTitleDPP($id) {
$this->db->select('KODE_DPP,CONCAT("Rp ",FORMAT(NOMINAL_DPP,2)) as KREDIT,CONCAT("Rp ",FORMAT(BLOCKCON,2)) as DEBIT');
$this->db->from('dp_pajak');
$this->db->where(['ID_DPP' => $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 getDpPajak($id) {
$this->db->select('*');
$this->db->from('dp_pajak');
$this->db->where(['ID_DPP' => $id]);
return $this->db->get()->result_array();
}
public function getDataDDPP($id) {
$this->db->select('*');
$this->db->from('detail_dpb');
$this->db->where(['ID_DDPP' => $id]);
return $this->db->get()->result_array();
}
public function getIDDDPP() {
$this->db->select_max('ID_DDPP');
$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 getDataDPP($id) {
$this->db->select('b.NOMINAL_DPP,b.BLOCKCON');
$this->db->from('detail_dpb a');
$this->db->join('dp_pajak b','b.ID_DPP=a.DPP_ID','left');
$this->db->where(['ID_DDPP' => $id]);
$this->db->group_by('ID_DDPP');
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 getKodeDetailDPP() {
$this->db->select('MAX(KODE_DDPP) 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');
}
}
?>