140 lines
4.7 KiB
PHP
140 lines
4.7 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class ModelNeraca 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 getDataNeraca($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,CONCAT("Rp ",FORMAT(NILAI_NERACA,2)) as NILAI');
|
|
$this->db->from('neraca');
|
|
$this->db->group_by('ID_NERACA');
|
|
}else{
|
|
$this->db->select('*,CONCAT("Rp ",FORMAT(NILAI_NERACA,2)) as NILAI');
|
|
$this->db->from('neraca');
|
|
$this->db->group_by('ID_NERACA');
|
|
$this->db->where(['ID_NERACA' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataNilaiNeraca($setdata,$perkiraan){
|
|
$this->db->select('*,CONCAT("Rp ",FORMAT(NILAI_NERACA,2)) as NILAI');
|
|
$this->db->from('neraca');
|
|
$this->db->where(['SETDATA_ID' => $setdata]);
|
|
$this->db->where(['PERKIRAAN_ID' => $perkiraan]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getSetdata_ID() {
|
|
$this->db->select_max('SETDATA_ID');
|
|
$this->db->from('neraca');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Neraca Spesifik, tergantung dari jenis transaksinya.
|
|
public function getDataNeracaBiaya($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*');
|
|
$this->db->from('neraca');
|
|
$this->db->group_by('ID_NERACA');
|
|
$this->db->order_by('KODE_NERACA');
|
|
$this->db->where('TYPE_NERACA="BIAYA PENJUALAN"');
|
|
$this->db->or_where('TYPE_NERACA="BIAYA UMUM DAN ADMINISTRASI"');
|
|
}else{
|
|
$this->db->select('*');
|
|
$this->db->from('neraca');
|
|
$this->db->group_by('ID_NERACA');
|
|
$this->db->order_by('KODE_NERACA');
|
|
$this->db->where('TYPE_NERACA="BIAYA PENJUALAN"');
|
|
$this->db->or_where('TYPE_NERACA="BIAYA UMUM DAN ADMINISTRASI"');
|
|
$this->db->where(['ID_NERACA' => $id]);
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataNeracaHutang($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*');
|
|
$this->db->from('neraca');
|
|
$this->db->group_by('ID_NERACA');
|
|
$this->db->order_by('KODE_NERACA');
|
|
$this->db->where('TYPE_NERACA="KEWAJIBAN LANCAR"');
|
|
}else{
|
|
$this->db->select('*');
|
|
$this->db->from('neraca');
|
|
$this->db->group_by('ID_NERACA');
|
|
$this->db->order_by('KODE_NERACA');
|
|
$this->db->where('TYPE_NERACA="KEWAJIBAN LANCAR"');
|
|
$this->db->where(['ID_NERACA' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getDataNeracaPiutang($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*');
|
|
$this->db->from('neraca');
|
|
$this->db->group_by('ID_NERACA');
|
|
$this->db->order_by('KODE_NERACA');
|
|
$this->db->where('TYPE_NERACA="AKTIVA LANCAR" AND KODE_NERACA!="1140"');
|
|
}else{
|
|
$this->db->select('*');
|
|
$this->db->from('neraca');
|
|
$this->db->group_by('ID_NERACA');
|
|
$this->db->order_by('KODE_NERACA');
|
|
$this->db->where('TYPE_NERACA="AKTIVA LANCAR" AND KODE_NERACA!="1140"');
|
|
$this->db->where(['ID_NERACA' => $id]);
|
|
}
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Hutang Lain
|
|
public function getDataHutangLain($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(TGL_HLA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(NOMINAL_HLA,2)) as HLA');
|
|
$this->db->from('hutang_lain');
|
|
$this->db->group_by('ID_HLA');
|
|
}else{
|
|
$this->db->select('*,CONCAT(DATE_FORMAT(TGL_HLA,"%d/%m/%Y")) AS WAKTU,CONCAT("Rp ",FORMAT(NOMINAL_HLA,2)) as HLA');
|
|
$this->db->from('hutang_lain');
|
|
$this->db->group_by('ID_HLA');
|
|
$this->db->where(['ID_HLA' => $id]);
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getKodeHLA() {
|
|
$this->db->select('MAX(KODE_HLA) AS KODE');
|
|
$this->db->from('hutang_lain');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
}
|
|
?>
|