460 lines
16 KiB
PHP
460 lines
16 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class ModelBankMasuk 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, Input Bank Masuk
|
|
public function getDataBankMasuk($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_BANKMASUK,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.DEBIT_BANKMASUK,2)) as DEBIT');
|
|
$this->db->from('bankmasuk a');
|
|
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
|
$this->db->join('kasbank_bm c','c.BANKMASUK_ID=a.ID_BANKMASUK','left');
|
|
$this->db->group_by('a.ID_BANKMASUK');
|
|
$this->db->where('a.STATUS_BANKMASUK is NULL');
|
|
}else{
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_BANKMASUK,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.DEBIT_BANKMASUK,2)) as DEBIT');
|
|
$this->db->from('bankmasuk a');
|
|
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
|
$this->db->join('kasbank_bm c','c.BANKMASUK_ID=a.ID_BANKMASUK','left');
|
|
$this->db->group_by('a.ID_BANKMASUK');
|
|
$this->db->where('a.STATUS_BANKMASUK is NULL');
|
|
$this->db->where(['a.ID_BANKMASUK' => $id]);
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataBankMasukRev($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_BANKMASUK,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.DEBIT_BANKMASUK,2)) as DEBIT,CONCAT("Rp ",FORMAT(a.KREDIT_BANKMASUK,2)) as KREDIT');
|
|
$this->db->from('bankmasuk a');
|
|
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
|
$this->db->join('kasbank_bm c','c.BANKMASUK_ID=a.ID_BANKMASUK','left');
|
|
$this->db->group_by('a.ID_BANKMASUK');
|
|
$this->db->where('a.STATUS_BANKMASUK="0"');
|
|
}else{
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_BANKMASUK,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.DEBIT_BANKMASUK,2)) as DEBIT,CONCAT("Rp ",FORMAT(a.KREDIT_BANKMASUK,2)) as KREDIT');
|
|
$this->db->from('bankmasuk a');
|
|
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
|
$this->db->join('kasbank_bm c','c.BANKMASUK_ID=a.ID_BANKMASUK','left');
|
|
$this->db->group_by('a.ID_BANKMASUK');
|
|
$this->db->where('a.STATUS_BANKMASUK="0"');
|
|
$this->db->where(['a.ID_BANKMASUK' => $id]);
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getKodeBankMasuk() {
|
|
$this->db->select('MAX(KODE_BANKMASUK) AS KODE');
|
|
$this->db->from('bankmasuk');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function hapusKasbankBM($id){
|
|
$this->db->where(['BANKMASUK_ID' => $id]);
|
|
$this->db->delete('kasbank_bm');
|
|
}
|
|
|
|
//Step Two, Input Transaksi
|
|
public function getDataKasbankBM($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_BANKMASUK,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.DEBIT_BANKMASUK,2)) as DEBIT,CONCAT("Rp ",FORMAT(c.NOMINAL_KBBM,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.KREDIT_BANKMASUK,2)) as KREDITALL');
|
|
$this->db->from('bankmasuk a');
|
|
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
|
$this->db->join('kasbank_bm c','c.BANKMASUK_ID=a.ID_BANKMASUK');
|
|
$this->db->join('perkiraan d','d.ID_PERKIRAAN=c.PERKIRAAN_ID','left');
|
|
$this->db->group_by('c.ID_KBBM');
|
|
}else{
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_BANKMASUK,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.DEBIT_BANKMASUK,2)) as DEBIT,CONCAT("Rp ",FORMAT(c.NOMINAL_KBBM,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.KREDIT_BANKMASUK,2)) as KREDITALL');
|
|
$this->db->from('bankmasuk a');
|
|
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
|
$this->db->join('kasbank_bm c','c.BANKMASUK_ID=a.ID_BANKMASUK');
|
|
$this->db->join('perkiraan d','d.ID_PERKIRAAN=c.PERKIRAAN_ID','left');
|
|
$this->db->where(['a.ID_BANKMASUK' => $id]);
|
|
$this->db->group_by('c.ID_KBBM');
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getTitleBM($id) {
|
|
$this->db->select('KODE_BANKMASUK,CONCAT("Rp ",FORMAT(DEBIT_BANKMASUK,2)) as DEBIT,CONCAT("Rp ",FORMAT(KREDIT_BANKMASUK,2)) as KREDIT');
|
|
$this->db->from('bankmasuk');
|
|
$this->db->where(['ID_BANKMASUK' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getKodeKasbankBM() {
|
|
$this->db->select('MAX(KODE_KBBM) AS KODE');
|
|
$this->db->from('kasbank_bm');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getID_KBBM() {
|
|
$this->db->select('MAX(ID_KBBM) AS KODE');
|
|
$this->db->from('kasbank_bm');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getKreditData($id) {
|
|
$this->db->select('a.KREDIT_BANKMASUK,a.ID_BANKMASUK,b.NOMINAL_KBBM');
|
|
$this->db->from('bankmasuk a');
|
|
$this->db->join('kasbank_bm b','b.BANKMASUK_ID=a.ID_BANKMASUK');
|
|
$this->db->where(['b.ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Step Three, Input Detail
|
|
public function getTitleKBBM($id) {
|
|
$this->db->select('KODE_KBBM,BANKMASUK_ID,CONCAT("Rp ",FORMAT(NOMINAL_KBBM,2)) as KREDIT');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataKBBM($id) {
|
|
$this->db->select('*');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Submenu Three, KAS
|
|
public function getSaldoKAS($id) {
|
|
$this->db->select('SALDO_KAS');
|
|
$this->db->from('kas');
|
|
$this->db->where(['ID_KAS' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataKAS($id) {
|
|
$this->db->select('b.SALDO_KAS,b.ID_KAS');
|
|
$this->db->from('detail_kas a');
|
|
$this->db->join('kas b','b.ID_KAS=a.KAS_ID','left');
|
|
$this->db->where(['ID_DKAS' => $id]);
|
|
$this->db->group_by('ID_DKAS');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getKodeDetailKAS() {
|
|
$this->db->select('MAX(KODE_DKAS) AS KODE');
|
|
$this->db->from('detail_kas');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getIDDKAS() {
|
|
$this->db->select_max('ID_DKAS');
|
|
$this->db->from('detail_kas');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDKASID($id) {
|
|
$this->db->select('DKAS_ID');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Submenu Three, BANK
|
|
public function getSaldoBANK($id) {
|
|
$this->db->select('SALDO_BANK');
|
|
$this->db->from('bank');
|
|
$this->db->where(['ID_BANK' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataBANK($id) {
|
|
$this->db->select('b.SALDO_BANK,b.ID_BANK');
|
|
$this->db->from('detail_bank a');
|
|
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
|
$this->db->where(['ID_DBANK' => $id]);
|
|
$this->db->group_by('ID_DBANK');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getKodeDetailBANK() {
|
|
$this->db->select('MAX(KODE_DBANK) AS KODE');
|
|
$this->db->from('detail_bank');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getIDDBANK() {
|
|
$this->db->select_max('ID_DBANK');
|
|
$this->db->from('detail_bank');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDBANKID($id) {
|
|
$this->db->select('DBANK_ID');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Submenu Three, DP Penjualan
|
|
public function getSaldoDPJ($id) {
|
|
$this->db->select('SALDO_PELANGGAN');
|
|
$this->db->from('pelanggan');
|
|
$this->db->where(['ID_PELANGGAN' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataPEL($id) {
|
|
$this->db->select('b.SALDO_PELANGGAN,b.ID_PELANGGAN');
|
|
$this->db->from('dp_penjualan a');
|
|
$this->db->join('pelanggan b','b.ID_PELANGGAN=a.PELANGGAN_ID','left');
|
|
$this->db->where(['ID_DPJ' => $id]);
|
|
$this->db->group_by('ID_DPJ');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getKodeDPJ() {
|
|
$this->db->select('MAX(KODE_DPJ) AS KODE');
|
|
$this->db->from('dp_penjualan');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getIDDPJ() {
|
|
$this->db->select_max('ID_DPJ');
|
|
$this->db->from('dp_penjualan');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDPJID($id) {
|
|
$this->db->select('DPJ_ID');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Submenu Three, Hutang BANK
|
|
public function getKodeHutangBANK() {
|
|
$this->db->select('MAX(KODE_HBA) AS KODE');
|
|
$this->db->from('hutang_bank');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getHutangSaldoBANK($id) {
|
|
$this->db->select('HUTANG_BANK,SALDO_BANK');
|
|
$this->db->from('bank');
|
|
$this->db->where(['ID_BANK' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getIDHBA() {
|
|
$this->db->select_max('ID_HBA');
|
|
$this->db->from('hutang_bank');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataHBA($id) {
|
|
$this->db->select('b.HUTANG_BANK,b.SALDO_BANK,b.ID_BANK');
|
|
$this->db->from('hutang_bank a');
|
|
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
|
$this->db->where(['ID_HBA' => $id]);
|
|
$this->db->group_by('ID_HBA');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getHBAID($id) {
|
|
$this->db->select('HBA_ID');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Submenu Three, Hutang LAIN
|
|
public function getKodeHutangLAIN() {
|
|
$this->db->select('MAX(KODE_HLA) AS KODE');
|
|
$this->db->from('hutang_lain');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getIDHLA() {
|
|
$this->db->select_max('ID_HLA');
|
|
$this->db->from('hutang_lain');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getHLAID($id) {
|
|
$this->db->select('HLA_ID');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Submenu Three, Detail Piutang Karyawan
|
|
public function getKodeDetailPKAR() {
|
|
$this->db->select('MAX(KODE_DPKAR) AS KODE');
|
|
$this->db->from('detail_pkar');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getIDDPKAR() {
|
|
$this->db->select_max('ID_DPKAR');
|
|
$this->db->from('detail_pkar');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getBlockconPKAR($id) {
|
|
$this->db->select('BLOCKCON');
|
|
$this->db->from('piutang_karyawan');
|
|
$this->db->where(['ID_PKAR' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDPKARID($id) {
|
|
$this->db->select('DPKAR_ID');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataPKAR($id) {
|
|
$this->db->select('b.BLOCKCON,b.ID_PKAR,a.DEBIT_DPKAR,c.HUTANG_KARYAWAN,c.ID_KARYAWAN');
|
|
$this->db->from('detail_pkar a');
|
|
$this->db->join('piutang_karyawan b','b.ID_PKAR=a.PKAR_ID','left');
|
|
$this->db->join('karyawan c','c.ID_KARYAWAN=b.KARYAWAN_ID','left');
|
|
$this->db->where(['a.ID_DPKAR' => $id]);
|
|
$this->db->group_by('a.ID_DPKAR');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Submenu Three, Detail Piutang Pihak Ke3
|
|
public function getKodeDetailPPI() {
|
|
$this->db->select('MAX(KODE_DPPI) AS KODE');
|
|
$this->db->from('detail_ppi');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getIDDPPI() {
|
|
$this->db->select_max('ID_DPPI');
|
|
$this->db->from('detail_ppi');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getBlockconPPI($id) {
|
|
$this->db->select('BLOCKCON');
|
|
$this->db->from('piutang_pihakke3');
|
|
$this->db->where(['ID_PPI' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDPPIID($id) {
|
|
$this->db->select('DPPI_ID');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataPPI($id) {
|
|
$this->db->select('b.BLOCKCON,b.ID_PPI,a.DEBIT_DPPI,c.ID_PIHAKKE3,c.HUTANG_PIHAKKE3');
|
|
$this->db->from('detail_ppi a');
|
|
$this->db->join('piutang_pihakke3 b','b.ID_PPI=a.PPI_ID','left');
|
|
$this->db->join('pihakke3 c','c.ID_PIHAKKE3=b.PIHAKKE3_ID','left');
|
|
$this->db->where(['a.ID_DPPI' => $id]);
|
|
$this->db->group_by('a.ID_DPPI');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Submenu Three, Detail Piutang Dagang
|
|
public function getKodeDetailPDA() {
|
|
$this->db->select('MAX(KODE_DPDA) AS KODE');
|
|
$this->db->from('detail_pda');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getIDDPDA() {
|
|
$this->db->select_max('ID_DPDA');
|
|
$this->db->from('detail_pda');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getBlockconPDA($id) {
|
|
$this->db->select('BLOCKCON');
|
|
$this->db->from('piutang_dagang');
|
|
$this->db->where(['ID_PDA' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDPDAID($id) {
|
|
$this->db->select('DPDA_ID');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataPDA($id) {
|
|
$this->db->select('b.BLOCKCON,b.ID_PDA,a.DEBIT_DPDA,c.ID_PENJUALAN,d.ID_PELANGGAN,d.HUTANG_PELANGGAN');
|
|
$this->db->from('detail_pda a');
|
|
$this->db->join('piutang_dagang b','b.ID_PDA=a.PDA_ID','left');
|
|
$this->db->join('penjualan c','c.ID_PENJUALAN=b.PENJUALAN_ID','left');
|
|
$this->db->join('pelanggan d','d.ID_PELANGGAN=c.PELANGGAN_ID','left');
|
|
$this->db->where(['a.ID_DPDA' => $id]);
|
|
$this->db->group_by('a.ID_DPDA');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Submenu Three, Biaya Pengiriman
|
|
public function getKodeDetailBP() {
|
|
$this->db->select('MAX(KODE_DBP) AS KODE');
|
|
$this->db->from('detail_bp');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getIDDBP() {
|
|
$this->db->select_max('ID_DBP');
|
|
$this->db->from('detail_bp');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getBlockdebBP($id) {
|
|
$this->db->select('BLOCKDEB_BP');
|
|
$this->db->from('biaya_pengiriman');
|
|
$this->db->where(['ID_BP' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDBPID($id) {
|
|
$this->db->select('DBP_ID');
|
|
$this->db->from('kasbank_bm');
|
|
$this->db->where(['ID_KBBM' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataBP($id) {
|
|
$this->db->select('a.KODE_BP,a.ID_BP,b.ID_PENJUALAN,a.NOMINAL_BP,a.BLOCKDEB_BP,a.BLOCKKRE_BP,c.DEBIT_DBP');
|
|
$this->db->from('biaya_pengiriman a');
|
|
$this->db->join('penjualan b','b.ID_PENJUALAN=a.PENJUALAN_ID','left');
|
|
$this->db->join('detail_bp c','c.BP_ID=a.ID_BP','left');
|
|
$this->db->where(['c.ID_DBP' => $id]);
|
|
$this->db->group_by('a.ID_BP');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
|
|
}
|
|
?>
|