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

97 lines
4.3 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ModelHutangBank 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 getDataHutangBank($id = null){
if ($id === null) {
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_HBA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_HBA,2)) as DEBIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as KREDIT');
$this->db->from('hutang_bank a');
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
$this->db->join('detail_hba c','c.HBA_ID=a.ID_HBA','left');
$this->db->group_by('a.ID_HBA');
$this->db->where('a.STATUS_HBA is NULL');
}else{
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_HBA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_HBA,2)) as DEBIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as KREDIT');
$this->db->from('hutang_bank a');
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
$this->db->join('detail_hba c','c.HBA_ID=a.ID_HBA','left');
$this->db->group_by('a.ID_HBA');
$this->db->where('a.STATUS_HBA is NULL');
$this->db->where(['a.ID_HBA' => $id]);
}
return $this->db->get()->result_array();
}
public function getDataHutangBankDetail($id = null){
if ($id === null) {
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_HBA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_HBA,2)) as DEBIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as KREDIT');
$this->db->from('hutang_bank a');
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
$this->db->join('detail_hba c','c.HBA_ID=a.ID_HBA','left');
$this->db->group_by('a.ID_HBA');
$this->db->where('a.NOMINAL_HBA!=a.BLOCKCON');
}else{
$this->db->select('*,CONCAT(DATE_FORMAT(a.TGL_HBA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_HBA,2)) as DEBIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as KREDIT');
$this->db->from('hutang_bank a');
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
$this->db->join('detail_hba c','c.HBA_ID=a.ID_HBA','left');
$this->db->group_by('a.ID_HBA');
$this->db->where('a.NOMINAL_HBA!=a.BLOCKCON');
$this->db->where(['a.ID_HBA' => $id]);
}
return $this->db->get()->result_array();
}
public function getDataDeskripsiHBA($id = null){
if ($id === null) {
$this->db->select('*,CONCAT(DATE_FORMAT(c.TGL_DHBA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_HBA,2)) as DEBIT,CONCAT("Rp ",FORMAT(c.KREDIT_DHBA,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as KREDITALL');
$this->db->from('hutang_bank a');
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
$this->db->join('detail_hba c','c.HBA_ID=a.ID_HBA');
$this->db->group_by('c.ID_DHBA');
}else{
$this->db->select('*,CONCAT(DATE_FORMAT(c.TGL_DHBA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(a.NOMINAL_HBA,2)) as DEBIT,CONCAT("Rp ",FORMAT(c.KREDIT_DHBA,2)) as KREDIT,CONCAT("Rp ",FORMAT(a.BLOCKCON,2)) as KREDITALL');
$this->db->from('hutang_bank a');
$this->db->join('bank b','b.ID_BANK=a.BANK_ID','left');
$this->db->join('detail_hba c','c.HBA_ID=a.ID_HBA');
$this->db->group_by('c.ID_DHBA');
$this->db->where(['a.ID_HBA' => $id]);
}
return $this->db->get()->result_array();
}
public function getTitleHBA($id)
{
$this->db->select('KODE_HBA,CONCAT("Rp ",FORMAT(NOMINAL_HBA,2)) as KREDIT,CONCAT("Rp ",FORMAT(BLOCKCON,2)) as DEBIT');
$this->db->from('hutang_bank');
$this->db->where(['ID_HBA' => $id]);
return $this->db->get()->result_array();
}
}
?>