114 lines
3.7 KiB
PHP
114 lines
3.7 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class ModelKas 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_Kas($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*');
|
|
$this->db->from('kas');
|
|
}else{
|
|
$this->db->select('*');
|
|
$this->db->from('kas');
|
|
$this->db->where(['ID_KAS' => $id]);
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getData_Kas_forDkb($id){
|
|
$this->db->select('*');
|
|
$this->db->from('kas');
|
|
$this->db->where('ID_KAS !=', $id);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getData_Kasbank_byKAS($id){
|
|
$this->db->select('*');
|
|
$this->db->from('kasbank');
|
|
$this->db->where(['KAS_ID' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getData_SaldoKas_byKAS_byTGL($id1,$id2){
|
|
$this->db->select('*,CONCAT("Rp ",FORMAT((SUM(DEBET_SK)),2)) as DEBET,CONCAT("Rp ",FORMAT((SUM(KREDIT_SK)),2)) as KREDIT,CONCAT("Rp ",FORMAT((SUM(DEBET_SK-KREDIT_SK)),2)) as TOTAL');
|
|
$this->db->from('saldo_kas');
|
|
$this->db->where(['KAS_ID' => $id1]);
|
|
$this->db->where('TGL_SK="'.$id2.'"');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataKasDetail($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,CONCAT("Rp ",FORMAT(SALDO_KAS,2)) as SALDO');
|
|
$this->db->from('kas');
|
|
}else{
|
|
$this->db->select('*,CONCAT("Rp ",FORMAT(SALDO_KAS,2)) as SALDO');
|
|
$this->db->from('kas');
|
|
$this->db->where(['ID_KAS' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataKasDkas(){
|
|
$this->db->select('*');
|
|
$this->db->from('kas a');
|
|
$this->db->join('detail_kas b','b.KAS_ID=a.ID_KAS','left');
|
|
$this->db->where('b.KAS_ID is NULL');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getKodeDKAS() {
|
|
$this->db->select('MAX(KODE_DKAS) AS KODE');
|
|
$this->db->from('detail_kas');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataDetailKas($id=null){
|
|
if ($id === null) {
|
|
$this->db->select('*,CONCAT("Rp ",FORMAT(b.SALDO_KAS,2)) as SALDO,CONCAT("Rp ",FORMAT(a.DEBIT_DKAS,2)) as DEBIT');
|
|
$this->db->from('detail_kas a');
|
|
$this->db->join('kas b','b.ID_KAS=a.KAS_ID','left');
|
|
$this->db->group_by('a.ID_DKAS');
|
|
}else{
|
|
$this->db->select('*,CONCAT("Rp ",FORMAT(b.SALDO_KAS,2)) as SALDO,CONCAT("Rp ",FORMAT(a.DEBIT_DKAS,2)) as DEBIT');
|
|
$this->db->from('detail_kas a');
|
|
$this->db->join('kas b','b.ID_KAS=a.KAS_ID','left');
|
|
$this->db->group_by('a.ID_DKAS');
|
|
$this->db->where(['a.KAS_ID' => $id]);
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataDetailDkas($id){
|
|
$this->db->select('*');
|
|
$this->db->from('detail_kas');
|
|
$this->db->where(['ID_DKAS' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
}
|
|
?>
|