copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class ModelBank 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 getData_Bank($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('bank');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('bank');
|
||||
$this->db->where(['ID_BANK' => $id]);
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SaldoBank_byBANK_byTGL($id1,$id2){
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT((SUM(a.DEBET_SB)),2)) as DEBET,CONCAT("Rp ",FORMAT((SUM(a.KREDIT_SB)),2)) as KREDIT,CONCAT("Rp ",FORMAT((SUM(a.DEBET_SB-a.KREDIT_SB)),2)) as TOTAL');
|
||||
$this->db->from('saldo_bank a');
|
||||
$this->db->join('bank b','b.ID_BANK=a.BANK_ID');
|
||||
$this->db->where(['a.BANK_ID' => $id1]);
|
||||
$this->db->where('a.TGL_SB="'.$id2.'"');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Bank_forDkb($id){
|
||||
$this->db->select('*');
|
||||
$this->db->from('bank');
|
||||
$this->db->where('ID_BANK !=', $id);
|
||||
$this->db->order_by('KODE_BANK ASC');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_SaldoBank_byBANK($id){
|
||||
$this->db->select('*');
|
||||
$this->db->from('saldo_bank');
|
||||
$this->db->where(['BANK_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Kasbank_byBANK($id){
|
||||
$this->db->select('*');
|
||||
$this->db->from('kasbank');
|
||||
$this->db->where(['BANK_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataBankDbank(){
|
||||
$this->db->select('*');
|
||||
$this->db->from('bank a');
|
||||
$this->db->join('detail_bank b','b.BANK_ID=a.ID_BANK','left');
|
||||
$this->db->where('b.BANK_ID is NULL');
|
||||
$this->db->order_by('a.NAMA_BANK','ASC');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataBankDetail($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT(SALDO_BANK,2)) as SALDO,CONCAT("Rp ",FORMAT(HUTANG_BANK,2)) as HUTANG');
|
||||
$this->db->from('bank');
|
||||
$this->db->order_by('NAMA_BANK','ASC');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT(SALDO_BANK,2)) as SALDO,CONCAT("Rp ",FORMAT(HUTANG_BANK,2)) as HUTANG');
|
||||
$this->db->from('bank');
|
||||
$this->db->where(['ID_BANK' => $id]);
|
||||
$this->db->order_by('NAMA_BANK','ASC');
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKodeDBANK() {
|
||||
$this->db->select('MAX(KODE_DBANK) AS KODE');
|
||||
$this->db->from('detail_bank');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataDetailBank($id=null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT(b.SALDO_BANK,2)) as SALDO,CONCAT("Rp ",FORMAT(a.DEBIT_DBANK,2)) as DEBIT');
|
||||
$this->db->from('detail_bank a');
|
||||
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
||||
$this->db->group_by('a.ID_DBANK');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT("Rp ",FORMAT(b.SALDO_BANK,2)) as SALDO,CONCAT("Rp ",FORMAT(a.DEBIT_DBANK,2)) as DEBIT');
|
||||
$this->db->from('detail_bank a');
|
||||
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
||||
$this->db->group_by('a.ID_DBANK');
|
||||
$this->db->where(['a.BANK_ID' => $id]);
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getDataDetailDbank($id){
|
||||
$this->db->select('*');
|
||||
$this->db->from('detail_bank');
|
||||
$this->db->where(['ID_DBANK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
//Hutang Bank
|
||||
public function getDataHutangBank($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_HBA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(b.HUTANG_BANK,2)) as HUTANG,CONCAT("Rp ",FORMAT(a.NOMINAL_HBA,2)) as HBA');
|
||||
$this->db->from('hutang_bank a');
|
||||
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
||||
$this->db->group_by('a.ID_HBA');
|
||||
}else{
|
||||
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_HBA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(b.HUTANG_BANK,2)) as HUTANG,CONCAT("Rp ",FORMAT(a.NOMINAL_HBA,2)) as HBA');
|
||||
$this->db->from('hutang_bank a');
|
||||
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
|
||||
$this->db->group_by('a.ID_HBA');
|
||||
$this->db->where(['a.ID_HBA' => $id]);
|
||||
}
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKodeHBA() {
|
||||
$this->db->select('MAX(KODE_HBA) AS KODE');
|
||||
$this->db->from('hutang_bank');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user