133 lines
5.4 KiB
PHP
133 lines
5.4 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class ModelBiayaFee 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);
|
|
}
|
|
|
|
//Step One, View Biaya Fee
|
|
public function getDataPiutangDagang($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_PDA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_PDA,2)) as DEBIT');
|
|
$this->db->from('piutang_dagang a');
|
|
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID','left');
|
|
$this->db->join('pelanggan c','c.ID_PELANGGAN=b.PELANGGAN_ID','left');
|
|
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID','left');
|
|
$this->db->join('detail_pda e','e.PDA_ID=a.ID_PDA','left');
|
|
$this->db->group_by('a.ID_PDA');
|
|
$this->db->where('a.STATUS_PDA is NULL');
|
|
}else{
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_PDA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_PDA,2)) as DEBIT');
|
|
$this->db->from('piutang_dagang a');
|
|
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID','left');
|
|
$this->db->join('pelanggan c','c.ID_PELANGGAN=b.PELANGGAN_ID','left');
|
|
$this->db->join('kota d','d.ID_KOTA=c.KOTA_ID','left');
|
|
$this->db->join('detail_pda e','e.PDA_ID=a.ID_PDA','left');
|
|
$this->db->group_by('a.ID_PDA');
|
|
$this->db->where('a.STATUS_PDA is NULL');
|
|
$this->db->where(['a.ID_PDA' => $id]);
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataBiayaFeeDetail($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_BF,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.NOMINAL_BF,2)) as BIAYA');
|
|
$this->db->from('biaya_fee a');
|
|
$this->db->join('detail_bf b','b.BF_ID=a.ID_BF','left');
|
|
$this->db->join('penjualan c','c.ID_PENJUALAN=a.PENJUALAN_ID','left');
|
|
$this->db->join('pelanggan d','d.ID_PELANGGAN=c.PELANGGAN_ID','left');
|
|
$this->db->group_by('a.ID_BF');
|
|
$this->db->where('a.NOMINAL_BF!=a.BLOCKCON');
|
|
}else{
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_BF,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.NOMINAL_BF,2)) as BIAYA');
|
|
$this->db->from('biaya_fee a');
|
|
$this->db->join('detail_bf b','b.BF_ID=a.ID_BF','left');
|
|
$this->db->join('penjualan c','c.ID_PENJUALAN=a.PENJUALAN_ID','left');
|
|
$this->db->join('pelanggan d','d.ID_PELANGGAN=c.PELANGGAN_ID','left');
|
|
$this->db->group_by('a.ID_BF');
|
|
$this->db->where('a.NOMINAL_BF!=a.BLOCKCON');
|
|
$this->db->where(['a.ID_BF' => $id]);
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getKodePiutangDagang()
|
|
{
|
|
$this->db->select('MAX(KODE_PDA) AS KODE');
|
|
$this->db->from('piutang_dagang');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Step Two, View Deskripsi
|
|
public function getDataDeskripsiPDA($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_PDA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_PDA,2)) as DEBIT,CONCAT("Rp ",FORMAT(b.KREDIT_DPDA,2)) as DEBIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as KREDITALL');
|
|
$this->db->from('piutang_dagang a');
|
|
$this->db->join('detail_pda b','b.PDA_ID=a.ID_PDA');
|
|
$this->db->group_by('b.ID_DPDA');
|
|
}else{
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_PDA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_PDA,2)) as DEBIT,CONCAT("Rp ",FORMAT(b.KREDIT_DPDA,2)) as DEBIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as KREDITALL');
|
|
$this->db->from('piutang_dagang a');
|
|
$this->db->join('detail_pda b','b.PDA_ID=a.ID_PDA');
|
|
$this->db->group_by('b.ID_DPDA');
|
|
$this->db->where(['a.ID_PDA' => $id]);
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getTitlePDA($id)
|
|
{
|
|
$this->db->select('KODE_PDA,CONCAT("Rp ",FORMAT(NOMINAL_PDA,2)) as DEBIT,CONCAT("Rp ",FORMAT(BLOCKCON,2)) as KREDIT');
|
|
$this->db->from('piutang_dagang');
|
|
$this->db->where(['ID_PDA' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getKodeDetailPDA()
|
|
{
|
|
$this->db->select('MAX(KODE_DPDA) AS KODE');
|
|
$this->db->from('detail_pda');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getID_DPDA()
|
|
{
|
|
$this->db->select('MAX(ID_DPDA) AS KODE');
|
|
$this->db->from('detail_pda');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getBlockcon($id)
|
|
{
|
|
$this->db->select('a.BLOCKCON,a.ID_PDA,b.KREDIT_DPDA');
|
|
$this->db->from('piutang_dagang a');
|
|
$this->db->join('detail_pda b','b.PDA_ID=a.ID_PDA');
|
|
$this->db->where(['b.ID_DPDA' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
}
|
|
?>
|