copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
<?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 ManageKBHpa extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelCorp', 'Corp');
|
||||
$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->Corp->getDataHutangPajak();
|
||||
$datCorp = $this->Corp->getDataCorpHpa();
|
||||
$data = [
|
||||
'sidebar' => "set data",
|
||||
'navChild' => "",
|
||||
'hutang' => $datHutang,
|
||||
'corp' => $datCorp
|
||||
];
|
||||
|
||||
$this->load->view('proses/SetKBHpa', $data);
|
||||
}
|
||||
|
||||
public function kodeHutangCorp() {
|
||||
$kk = $this->Corp->getKodeHPA();
|
||||
if (is_array($kk) || is_object($kk)) {
|
||||
foreach ($kk as $row) {
|
||||
if ($row['KODE'] == NULL) {
|
||||
return "HPA/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 = "HPA/000000";
|
||||
$data = substr($data, 0, $panjang) . $str;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function save() {
|
||||
$method = $this->input->post('method');
|
||||
$id = $this->input->post('id_hpa');
|
||||
$id_corp = $this->input->post('id_corp');
|
||||
$nominal_hpa = $this->input->post('nominal_hpa');
|
||||
$kode_hpa = $this->kodeHutangCorp();
|
||||
$input = [
|
||||
'KODE_HPA' => $kode_hpa,
|
||||
'CORP_ID' => $id_corp,
|
||||
'NOMINAL_HPA' => $nominal_hpa,
|
||||
'BLOCKCON' => '0'
|
||||
];
|
||||
$action = $this->Corp->create('hutang_pajak', $input);
|
||||
$hutang_pajak = $this->Corp->getDataCorp($id_corp);
|
||||
$hutang_pajak = $hutang_pajak[0]['HUTANG_PAJAK'];
|
||||
$hutang_pajak = $hutang_pajak+$nominal_hpa;
|
||||
$update = [
|
||||
'HUTANG_PAJAK' => $hutang_pajak
|
||||
];
|
||||
$action = $this->Corp->update('corp', $update, 'ID_CORP',$id_corp);
|
||||
$nilai = $this->Neraca->getDataNeraca(16);
|
||||
$nilai = $nilai[0]['NILAI_NERACA'];
|
||||
$nilai_neraca = $nilai+$nominal_hpa;
|
||||
$id_neraca = 16;
|
||||
$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_hpa = $this->input->post('id_hpa');
|
||||
$nominal_hpa = $this->input->post('nominal_hpaed');
|
||||
|
||||
$hpa = $this->Corp->getDataHpa($id_hpa);
|
||||
$nominal = $hpa[0]['NOMINAL_HPA'];
|
||||
$id_corp = $hpa[0]['CORP_ID'];
|
||||
$nilai = $this->Neraca->getDataNeraca(16);
|
||||
$nilai = $nilai[0]['NILAI_NERACA'];
|
||||
$nilai_neraca = $nilai-$nominal;
|
||||
$id_neraca = 16;
|
||||
$update = [
|
||||
'NILAI_NERACA' => $nilai_neraca
|
||||
];
|
||||
$action = $this->Neraca->update('neraca', $update, 'ID_NERACA',$id_neraca);
|
||||
|
||||
$corp = $this->Corp->getDataCorp($id_corp);
|
||||
$hutang_pajak = $corp[0]['HUTANG_PAJAK'];
|
||||
$hutang_pajak = $hutang_pajak-$nominal;
|
||||
$update = [
|
||||
'HUTANG_PAJAK' => $hutang_pajak
|
||||
];
|
||||
$action = $this->Corp->update('corp', $update, 'ID_CORP',$id_corp);
|
||||
|
||||
$update = [
|
||||
'NOMINAL_HPA' => $nominal_hpa
|
||||
];
|
||||
$action = $this->Corp->update('hutang_pajak', $update,'ID_HPA',$id_hpa);
|
||||
|
||||
$nilai = $this->Neraca->getDataNeraca(16);
|
||||
$nilai = $nilai[0]['NILAI_NERACA'];
|
||||
$nilai_neraca = $nilai+$nominal_hpa;
|
||||
$id_neraca = 16;
|
||||
$update = [
|
||||
'NILAI_NERACA' => $nilai_neraca
|
||||
];
|
||||
$action = $this->Neraca->update('neraca', $update, 'ID_NERACA',$id_neraca);
|
||||
|
||||
$corp = $this->Corp->getDataCorp($id_corp);
|
||||
$hutang_pajak = $corp[0]['HUTANG_PAJAK'];
|
||||
$hutang_pajak = $hutang_pajak+$nominal_hpa;
|
||||
$update = [
|
||||
'HUTANG_PAJAK' => $hutang_pajak
|
||||
];
|
||||
$action = $this->Corp->update('corp', $update, 'ID_CORP',$id_corp);
|
||||
|
||||
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
|
||||
$hpa = $this->Corp->getDataHpa($id);
|
||||
$id_corp = $hpa[0]['CORP_ID'];
|
||||
$nominal_hpa = $hpa[0]['NOMINAL_HPA'];
|
||||
|
||||
$corp = $this->Corp->getDataCorp($id_corp);
|
||||
$hutang_pajak = $corp[0]['HUTANG_PAJAK'];
|
||||
$hutang_pajak = $hutang_pajak-$nominal_hpa;
|
||||
$update = [
|
||||
'HUTANG_PAJAK' => $hutang_pajak
|
||||
];
|
||||
$action = $this->Corp->update('corp', $update, 'ID_CORP', $id_corp);
|
||||
|
||||
$nilai = $this->Neraca->getDataNeraca(16);
|
||||
$nilai = $nilai[0]['NILAI_NERACA'];
|
||||
$nilai_neraca = $nilai-$nominal_hpa;
|
||||
$id_neraca = 16;
|
||||
$update = [
|
||||
'NILAI_NERACA' => $nilai_neraca
|
||||
];
|
||||
$action = $this->Neraca->update('neraca', $update, 'ID_NERACA',$id_neraca);
|
||||
|
||||
//Step Hapus Data
|
||||
$action = $this->Corp->delete('hutang_pajak',$id,'ID_HPA');
|
||||
|
||||
$this->session->set_flashdata('flash', 'dihapus');
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user