155 lines
4.3 KiB
PHP
155 lines
4.3 KiB
PHP
<?php
|
|
|
|
use Restserver\Libraries\REST_Controller;
|
|
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
require APPPATH . 'libraries/REST_Controller.php';
|
|
require APPPATH . 'libraries/Format.php';
|
|
|
|
class ManageKBHla extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelNeraca', 'Neraca');
|
|
$this->load->library(['datatables', 'form_validation']);
|
|
$this->form_validation->set_error_delimiters('', '');
|
|
}
|
|
public function output_json($data, $encode = true)
|
|
{
|
|
if ($encode) $data = json_encode($data);
|
|
$this->output->set_content_type('application/json')->set_output($data);
|
|
}
|
|
|
|
public function index() {
|
|
|
|
$datHutang = $this->Neraca->getDataHutangLain();
|
|
$data = [
|
|
'sidebar' => "set data",
|
|
'navChild' => "",
|
|
'hutang' => $datHutang
|
|
];
|
|
|
|
$this->load->view('proses/SetKBHla', $data);
|
|
}
|
|
|
|
public function kodeHutangLain() {
|
|
$kk = $this->Neraca->getKodeHLA();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == NULL) {
|
|
return "HLA/000001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$panjang = 6;
|
|
$data = substr($str, 4, $panjang);
|
|
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
|
|
$panjang = 10 - strlen($str);
|
|
$data = "HLA/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function save() {
|
|
$method = $this->input->post('method');
|
|
$id = $this->input->post('id_hla');
|
|
$nominal_hla = $this->input->post('nominal_hla');
|
|
$ket_hla = $this->input->post('ket_hla');
|
|
$kode_hla = $this->kodeHutangLain();
|
|
$input = [
|
|
'KODE_HLA' => $kode_hla,
|
|
'KODE_BUKTI' => "SETDATA",
|
|
'NOMINAL_HLA' => $nominal_hla,
|
|
'KET_HLA' => $ket_hla,
|
|
'BLOCKCON' => '0'
|
|
];
|
|
$action = $this->Neraca->create('hutang_lain', $input);
|
|
$nilai = $this->Neraca->getDataNeraca(18);
|
|
$nilai = $nilai[0]['NILAI_NERACA'];
|
|
$nilai_neraca = $nilai+$nominal_hla;
|
|
$id_neraca = 18;
|
|
$update = [
|
|
'NILAI_NERACA' => $nilai_neraca
|
|
];
|
|
$action = $this->Neraca->update('neraca', $update, 'ID_NERACA',$id_neraca);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'dilakukan');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'dilakukan');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function edit() {
|
|
$method = $this->input->post('method');
|
|
$id_hla = $this->input->post('id_hla');
|
|
$nominal_hla = $this->input->post('nominal_hlaed');
|
|
$ket_hla = $this->input->post('ket_hlaed');
|
|
|
|
$nominallama = $this->Neraca->getDataHutangLain($id_hla);
|
|
$nominallama = $nominallama[0]['NOMINAL_HLA'];
|
|
$nilai = $this->Neraca->getDataNeraca(18);
|
|
$nilai = $nilai[0]['NILAI_NERACA'];
|
|
$nilai_neraca = $nilai-$nominallama;
|
|
$id_neraca = 18;
|
|
$update = [
|
|
'NILAI_NERACA' => $nilai_neraca
|
|
];
|
|
$action = $this->Neraca->update('neraca', $update, 'ID_NERACA',$id_neraca);
|
|
$update = [
|
|
'NOMINAL_HLA' => $nominal_hla,
|
|
'KET_HLA' => $ket_hla
|
|
];
|
|
$action = $this->Neraca->update('hutang_lain', $update,'ID_HLA',$id_hla);
|
|
$nilai = $this->Neraca->getDataNeraca(18);
|
|
$nilai = $nilai[0]['NILAI_NERACA'];
|
|
$nilai_neraca = $nilai+$nominal_hla;
|
|
$id_neraca = 18;
|
|
$update = [
|
|
'NILAI_NERACA' => $nilai_neraca
|
|
];
|
|
$action = $this->Neraca->update('neraca', $update, 'ID_NERACA',$id_neraca);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diubah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Ambil Data Lama
|
|
$datahutang = $this->Neraca->getDataHutangLain($id);
|
|
$nominal_hla = $datahutang[0]['NOMINAL_HLA'];
|
|
$nilai = $this->Neraca->getDataNeraca(18);
|
|
$nilai = $nilai[0]['NILAI_NERACA'];
|
|
$nilai_neraca = $nilai-$nominal_hla;
|
|
$id_neraca = 18;
|
|
$update = [
|
|
'NILAI_NERACA' => $nilai_neraca
|
|
];
|
|
$action = $this->Neraca->update('neraca', $update, 'ID_NERACA',$id_neraca);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->Neraca->delete('hutang_lain',$id,'ID_HLA');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|