copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class ModelBiayaPengiriman 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 Pengiriman
|
||||
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 getDataBiayaPengirimanDetail($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_BP,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.BLOCKKRE_BP,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKDEB_BP,2)) as DEBIT,CONCAT("Rp ",FORMAT(a.NOMINAL_BP,2)) as BIAYA');
|
||||
$this->db->from('biaya_pengiriman a');
|
||||
$this->db->join('detail_bp b','b.BP_ID=a.ID_BP','left');
|
||||
$this->db->join('penjualan c','c.ID_PENJUALAN=a.PENJUALAN_ID','left');
|
||||
$this->db->group_by('a.ID_BP');
|
||||
$this->db->where('a.NOMINAL_BP!=a.BLOCKDEB_BP');
|
||||
$this->db->or_where('a.NOMINAL_BP!=a.BLOCKKRE_BP');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_BP,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.BLOCKKRE_BP,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKDEB_BP,2)) as DEBIT,CONCAT("Rp ",FORMAT(a.NOMINAL_BP,2)) as BIAYA');
|
||||
$this->db->from('biaya_pengiriman a');
|
||||
$this->db->join('detail_bp b','b.BP_ID=a.ID_BP','left');
|
||||
$this->db->join('penjualan c','c.ID_PENJUALAN=a.PENJUALAN_ID','left');
|
||||
$this->db->group_by('a.ID_BP');
|
||||
$this->db->where('a.NOMINAL_BP!=a.BLOCKDEB_BP');
|
||||
$this->db->or_where('a.NOMINAL_BP!=a.BLOCKKRE_BP');
|
||||
$this->db->where(['a.ID_BP' => $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();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user