1131 lines
33 KiB
PHP
1131 lines
33 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 ManageKasMasuk extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelKasMasuk', 'KasMasuk');
|
|
$this->load->model('ModelBank', 'Bank');
|
|
$this->load->model('ModelKendaraan', 'Kendaraan');
|
|
$this->load->model('ModelKas', 'Kas');
|
|
$this->load->model('ModelKaryawan', 'Karyawan');
|
|
$this->load->model('ModelPerkiraan', 'Perkiraan');
|
|
$this->load->model('ModelPajak', 'Pajak');
|
|
$this->load->model('ModelPiutangKaryawan', 'Pkar');
|
|
$this->load->model('ModelPiutangPihakKe3', 'Ppi');
|
|
$this->load->model('ModelPiutangDagang', 'Pda');
|
|
$this->load->model('ModelBiayaPengiriman', 'Bp');
|
|
$this->load->model('ModelPelanggan', 'Pelanggan');
|
|
$this->load->model('ModelSupplier', 'Supplier');
|
|
$this->load->model('ModelPihakKe3', 'PihakKe3');
|
|
$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);
|
|
}
|
|
|
|
//Step One, Input Kas Masuk
|
|
public function index() {
|
|
|
|
$datKasMasuk = $this->KasMasuk->getDataKasMasuk();
|
|
$datKas = $this->Kas->getDataKasDetail();
|
|
|
|
$data = [
|
|
'sidebar' => "menu accounting",
|
|
'navChild' => "",
|
|
'kasmasuk' => $datKasMasuk,
|
|
'kas' => $datKas
|
|
];
|
|
|
|
$this->load->view('proses/KasMasuk', $data);
|
|
}
|
|
|
|
public function kodeKasMasuk() {
|
|
$kk = $this->KasMasuk->getKodeKasMasuk();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "BKM/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 = "BKM/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function save() {
|
|
$method = $this->input->post('method');
|
|
$id = $this->input->post('id_kasmasuk');
|
|
$id_kas = $this->input->post('id_kas');
|
|
$debit_kasmasuk = $this->input->post('debit_kasmasuk');
|
|
$kode_kasmasuk = $this->kodeKasMasuk();
|
|
|
|
$input = [
|
|
'KODE_KASMASUK' => $kode_kasmasuk,
|
|
'KAS_ID' => $id_kas,
|
|
'DEBIT_KASMASUK' => $debit_kasmasuk,
|
|
'KREDIT_KASMASUK' => '0'
|
|
];
|
|
|
|
$action = $this->KasMasuk->create('kasmasuk', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageKasMasuk');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageKasMasuk');
|
|
}
|
|
|
|
}
|
|
|
|
public function edit() {
|
|
$method = $this->input->post('method');
|
|
$id_kasmasuk = $this->input->post('id_kasmasuk');
|
|
$id_kas = $this->input->post('id_kased');
|
|
$debit_kasmasuk = $this->input->post('debit_kasmasuked');
|
|
|
|
$update = [
|
|
'KAS_ID' => $id_kas,
|
|
'DEBIT_KASMASUK' => $debit_kasmasuk
|
|
];
|
|
|
|
$action = $this->KasMasuk->update('kasmasuk', $update, 'ID_KASMASUK', $id_kasmasuk);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diedit');
|
|
redirect('ManageKasMasuk');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diedit');
|
|
redirect('ManageKasMasuk');
|
|
}
|
|
}
|
|
|
|
public function hapus() {
|
|
$id = $this->input->post('id');
|
|
|
|
$action = $this->KasMasuk->hapusKasbankKM($id);
|
|
$action = $this->KasMasuk->delete('kasmasuk',$id,'ID_KASMASUK');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function konfirmasi() {
|
|
$method = $this->input->post('method');
|
|
$id_kasmasuk = $this->input->post('id_kasmasuk');
|
|
|
|
//Proses Konfirmasi + Update Saldo Kas
|
|
$datakas = $this->KasMasuk->getDataKasMasuk($id_kasmasuk);
|
|
$saldo = $datakas[0]['SALDO_KAS'];
|
|
$nominal = $datakas[0]['DEBIT_KASMASUK'];
|
|
$id_kas = $datakas[0]['KAS_ID'];
|
|
$saldo_kas = $saldo+$nominal;
|
|
$update = [
|
|
'SALDO_KAS' => $saldo_kas
|
|
];
|
|
$action = $this->KasMasuk->update('kas', $update, 'ID_KAS', $id_kas);
|
|
$update = [
|
|
'STATUS_KASMASUK' => '0'
|
|
];
|
|
$action = $this->KasMasuk->update('kasmasuk', $update, 'ID_KASMASUK', $id_kasmasuk);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'dikonfirmasi');
|
|
redirect('ManageKasMasuk');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'dikonfirmasi');
|
|
redirect('ManageKasMasuk');
|
|
}
|
|
|
|
}
|
|
|
|
//Step Two, Input Transaksi
|
|
public function tambahTransaksi($id) {
|
|
$transaksi = $this->KasMasuk->getDataKasbankKM($id);
|
|
$title = $this->KasMasuk->getTitleKM($id);
|
|
$perkiraan = $this->Perkiraan->getDataPerkiraan();
|
|
$bank = $this->Bank->getDataBankDetail();
|
|
$kas = $this->Kas->getDataKasDetail();
|
|
$kendaraan = $this->Kendaraan->getDataKendaraan();
|
|
$karyawan = $this->Karyawan->getDataKaryawan();
|
|
$pihakke3 = $this->PihakKe3->getDataPihakKe3();
|
|
$pelanggan = $this->Pelanggan->getDataPelanggan();
|
|
$pajak = $this->Pajak->getDataPajak();
|
|
$pkar = $this->Pkar->getDataPiutangKaryawanDetail();
|
|
$ppi = $this->Ppi->getDataPiutangPihakKe3Detail();
|
|
$pda = $this->Pda->getDataPiutangDagangDetail();
|
|
$bp = $this->Bp->getDataBiayaPengirimanDetail();
|
|
$data = [
|
|
'sidebar' => "menu accounting",
|
|
'navChild' => "",
|
|
'transaksi' => $transaksi,
|
|
'id_kasmasuk' => $id,
|
|
'title1' => $title[0]['KODE_KASMASUK'],
|
|
'title2' => $title[0]['DEBIT'],
|
|
'title3' => $title[0]['KREDIT'],
|
|
'perkiraan' => $perkiraan,
|
|
'bank' => $bank,
|
|
'kas' => $kas,
|
|
'kendaraan' => $kendaraan,
|
|
'karyawan' => $karyawan,
|
|
'pihakke3' => $pihakke3,
|
|
'pelanggan' => $pelanggan,
|
|
'pajak' => $pajak,
|
|
'pkar' => $pkar,
|
|
'ppi' => $ppi,
|
|
'pda' => $pda,
|
|
'bp' => $bp
|
|
];
|
|
|
|
$this->load->view('proses/KasbankKM', $data);
|
|
}
|
|
|
|
public function kodeKasbankKM() {
|
|
$kk = $this->KasMasuk->getKodeKasbankKM();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "KBKM/000001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$panjang = 6;
|
|
$data = substr($str, 5, $panjang);
|
|
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
|
|
$panjang = 11 - strlen($str);
|
|
$data = "KBKM/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function savetransaksi() {
|
|
//Step Input Transaksi
|
|
$method = $this->input->post('method');
|
|
$id_kbkm = $this->input->post('id');
|
|
$id_kasmasuk = $this->input->post('id_kasmasuk');
|
|
$id_perkiraan = $this->input->post('id_perkiraan');
|
|
$nominal_kbkm = $this->input->post('nominal_kbkm');
|
|
$ket_kbkm = $this->input->post('ket_kbkm');
|
|
$kode_kbkm = $this->kodeKasbankKM();
|
|
|
|
$input = [
|
|
'KASMASUK_ID' => $id_kasmasuk,
|
|
'PERKIRAAN_ID' => $id_perkiraan,
|
|
'NOMINAL_KBKM' => $nominal_kbkm,
|
|
'KET_KBKM' => $ket_kbkm,
|
|
'KODE_KBKM' => $kode_kbkm
|
|
];
|
|
|
|
$action = $this->KasMasuk->create('kasbank_km', $input);
|
|
|
|
//Step Ambil Data Lama
|
|
$id_kbkm = $this->KasMasuk->getID_KBKM();
|
|
$datakredit = $this->KasMasuk->getKreditData($id_kbkm[0]['KODE']);
|
|
$id_kasmasuk = $datakredit[0]['ID_KASMASUK'];
|
|
$nominal = $datakredit[0]['KREDIT_KASMASUK'];
|
|
$kredit_kasmasuk = $nominal+$nominal_kbkm;
|
|
$update = [
|
|
'KREDIT_KASMASUK' => $kredit_kasmasuk
|
|
];
|
|
$action = $this->KasMasuk->update('kasmasuk', $update, 'ID_KASMASUK', $id_kasmasuk);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function edittransaksi() {
|
|
//Step Edit Transaksi
|
|
$method = $this->input->post('method');
|
|
$id_kbkm = $this->input->post('id_kbkm');
|
|
$id_kasmasuk = $this->input->post('id_kasmasuk');
|
|
$id_perkiraan = $this->input->post('id_perkiraaned');
|
|
$nominal_kbkm = $this->input->post('nominal_kbkmed');
|
|
$ket_kbkm = $this->input->post('ket_kbkmed');
|
|
|
|
//Step Ambil Data Lama
|
|
$datakredit = $this->KasMasuk->getKreditData($id_kbkm);
|
|
$nominal = $datakredit[0]['KREDIT_KASMASUK'];
|
|
$nominallama = $datakredit[0]['NOMINAL_KBKM'];
|
|
$nominalbaru = $nominal-$nominallama;
|
|
$update = [
|
|
'KREDIT_KASMASUK' => $nominalbaru
|
|
];
|
|
$action = $this->KasMasuk->update('kasmasuk', $update, 'ID_KASMASUK', $id_kasmasuk);
|
|
|
|
//Step Update Debit Kas Masuk
|
|
$update = [
|
|
'PERKIRAAN_ID' => $id_perkiraan,
|
|
'NOMINAL_KBKM' => $nominal_kbkm,
|
|
'KET_KBKM' => $ket_kbkm
|
|
];
|
|
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM',$id_kbkm);
|
|
|
|
//Step Update Kas Masuk
|
|
$datakredit = $this->KasMasuk->getKreditData($id_kbkm);
|
|
$nominal = $datakredit[0]['KREDIT_KASMASUK'];
|
|
$nominalbaru = $nominal+$nominal_kbkm;
|
|
$update = [
|
|
'KREDIT_KASMASUK' => $nominalbaru
|
|
];
|
|
$action = $this->KasMasuk->update('kasmasuk', $update, 'ID_KASMASUK', $id_kasmasuk);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diedit');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diedit');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
}
|
|
|
|
public function hapustransaksi() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Ambil Data Lama
|
|
$datakredit = $this->KasMasuk->getKreditData($id);
|
|
$id_kasmasuk = $datakredit[0]['ID_KASMASUK'];
|
|
$nominal = $datakredit[0]['KREDIT_KASMASUK'];
|
|
$kredit = $datakredit[0]['NOMINAL_KBKM'];
|
|
$nominalbaru = $nominal-$kredit;
|
|
$update = [
|
|
'KREDIT_KASMASUK' => $nominalbaru
|
|
];
|
|
$action = $this->KasMasuk->update('kasmasuk', $update, 'ID_KASMASUK', $id_kasmasuk);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->KasMasuk->delete('kasbank_km',$id,'ID_KBKM');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
//Step Three, Input Detail
|
|
|
|
//Substep Three, Transaksi Sekali Jalan
|
|
public function kodeDetailKAS() {
|
|
$kk = $this->KasMasuk->getKodeDetailKAS();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "KAS/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 = "KAS/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function detailkas() {
|
|
//Step Input Detail KAS
|
|
$method = $this->input->post('method');
|
|
$id_dkas = $this->input->post('id');
|
|
$id_kbkm = $this->input->post('id_kbkm');
|
|
$id_kas = $this->input->post('id_kas');
|
|
$kode_dkas = $this->kodeDetailKAS();
|
|
|
|
if ($id_kas==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbkm = $this->KasMasuk->getDataKBKM($id_kbkm);
|
|
$kredit_dkas = $kbkm[0]['NOMINAL_KBKM'];
|
|
$kode_bukti = $kbkm[0]['KODE_KBKM'];
|
|
$input = [
|
|
'KREDIT_DKAS' => $kredit_dkas,
|
|
'KAS_ID' => $id_kas,
|
|
'KODE_DKAS' => $kode_dkas,
|
|
'KODE_BUKTI' => $kode_bukti
|
|
];
|
|
$action = $this->KasMasuk->create('detail_kas', $input);
|
|
$kas = $this->KasMasuk->getSaldoKAS($id_kas);
|
|
$saldo = $kas[0]['SALDO_KAS'] - $kredit_dkas ;
|
|
$update = [
|
|
'SALDO_KAS' => $saldo
|
|
];
|
|
$action = $this->KasMasuk->update('kas', $update, 'ID_KAS', $id_kas);
|
|
$id_dkas = $this->KasMasuk->getIDDKAS();
|
|
$update = [
|
|
'DKAS_ID' => $id_dkas[0]['ID_DKAS']
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM',$id_kbkm);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function resetkas() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Reset Saldo KAS
|
|
$id_dkas = $this->KasMasuk->getDataKBKM($id);
|
|
$kredit_kbkm = $id_dkas[0]['NOMINAL_KBKM'];
|
|
$id_dkas = $id_dkas[0]['DKAS_ID'];
|
|
$kas = $this->KasMasuk->getDataKAS($id_dkas);
|
|
$id_kas = $kas[0]['ID_KAS'];
|
|
$saldo = $kas[0]['SALDO_KAS'];
|
|
$saldo = $saldo+$kredit_kbkm;
|
|
$update = [
|
|
'SALDO_KAS' => $saldo
|
|
];
|
|
$action = $this->KasMasuk->update('kas', $update, 'ID_KAS', $id_kas);
|
|
|
|
//Step Ambil Data Lama
|
|
$id_dkas = $this->KasMasuk->getDKASID($id);
|
|
$id_dkas = $id_dkas[0]['DKAS_ID'];
|
|
$update = [
|
|
'DKAS_ID' => NULL
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->KasMasuk->delete('detail_kas',$id_dkas,'ID_DKAS');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function kodeDetailBANK() {
|
|
$kk = $this->KasMasuk->getKodeDetailBANK();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "BANK/000001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$panjang = 6;
|
|
$data = substr($str, 5, $panjang);
|
|
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
|
|
$panjang = 11 - strlen($str);
|
|
$data = "BANK/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function detailbank() {
|
|
//Step Input Detail BANK
|
|
$method = $this->input->post('method');
|
|
$id_dbank = $this->input->post('id');
|
|
$id_kbkm = $this->input->post('id_kbkm');
|
|
$id_bank = $this->input->post('id_bank');
|
|
$kode_dbank = $this->kodeDetailBANK();
|
|
|
|
if ($id_bank==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbkm = $this->KasMasuk->getDataKBKM($id_kbkm);
|
|
$kredit_dbank = $kbkm[0]['NOMINAL_KBKM'];
|
|
$kode_bukti = $kbkm[0]['KODE_KBKM'];
|
|
$input = [
|
|
'KREDIT_DBANK' => $kredit_dbank,
|
|
'BANK_ID' => $id_bank,
|
|
'KODE_DBANK' => $kode_dbank,
|
|
'KODE_BUKTI' => $kode_bukti
|
|
];
|
|
$action = $this->KasMasuk->create('detail_bank', $input);
|
|
$bank = $this->KasMasuk->getSaldoBANK($id_bank);
|
|
$saldo = $bank[0]['SALDO_BANK'] - $kredit_dbank ;
|
|
$update = [
|
|
'SALDO_BANK' => $saldo
|
|
];
|
|
$action = $this->KasMasuk->update('bank', $update, 'ID_BANK', $id_bank);
|
|
$id_dbank = $this->KasMasuk->getIDDBANK();
|
|
$update = [
|
|
'DBANK_ID' => $id_dbank[0]['ID_DBANK']
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM',$id_kbkm);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function resetbank() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Reset Saldo BANK
|
|
$id_dbank = $this->KasMasuk->getDataKBKM($id);
|
|
$kredit_kbkm = $id_dbank[0]['NOMINAL_KBKM'];
|
|
$id_dbank = $id_dbank[0]['DBANK_ID'];
|
|
$bank = $this->KasMasuk->getDataBANK($id_dbank);
|
|
$id_bank = $bank[0]['ID_BANK'];
|
|
$saldo = $bank[0]['SALDO_BANK'];
|
|
$saldo = $saldo+$kredit_kbkm;
|
|
$update = [
|
|
'SALDO_BANK' => $saldo
|
|
];
|
|
$action = $this->KasMasuk->update('bank', $update, 'ID_BANK', $id_bank);
|
|
|
|
//Step Ambil Data Lama
|
|
$id_dbank = $this->KasMasuk->getDBANKID($id);
|
|
$id_dbank = $id_dbank[0]['DBANK_ID'];
|
|
$update = [
|
|
'DBANK_ID' => NULL
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->KasMasuk->delete('detail_bank',$id_dbank,'ID_DBANK');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function kodeDPJ() {
|
|
$kk = $this->KasMasuk->getKodeDPJ();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "DPJ/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 = "DPJ/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function detaildpj() {
|
|
//Step Input Detail DP Penjualan
|
|
$method = $this->input->post('method');
|
|
$id_dpj = $this->input->post('id');
|
|
$id_kbkm = $this->input->post('id_kbkm');
|
|
$id_pelanggan = $this->input->post('id_pelanggan');
|
|
$kode_dpj = $this->kodeDPJ();
|
|
|
|
if ($id_pelanggan==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbkm = $this->KasMasuk->getDataKBKM($id_kbkm);
|
|
$nominal_dpj = $kbkm[0]['NOMINAL_KBKM'];
|
|
$kode_bukti = $kbkm[0]['KODE_KBKM'];
|
|
$input = [
|
|
'NOMINAK_DPJ' => $nominal_dpj,
|
|
'PELANGGAN_ID' => $id_pelanggan,
|
|
'KODE_DPJ' => $kode_dpj,
|
|
'KODE_BUKTI' => $kode_bukti
|
|
];
|
|
$action = $this->KasMasuk->create('dp_penjualan', $input);
|
|
$pelanggan = $this->KasMasuk->getSaldoDPJ($id_pelanggan);
|
|
$saldo = $pelanggan[0]['SALDO_PELANGGAN'] + $nominal_dpj ;
|
|
$update = [
|
|
'SALDO_PELANGGAN' => $saldo
|
|
];
|
|
$action = $this->KasMasuk->update('pelanggan', $update, 'ID_PELANGGAN', $id_pelanggan);
|
|
$id_dpj = $this->KasMasuk->getIDDPJ();
|
|
$update = [
|
|
'DPJ_ID' => $id_dpj[0]['ID_DPJ']
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM',$id_kbkm);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function resetdpj() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Reset Saldo DP Penjualan
|
|
$id_dpj = $this->KasMasuk->getDataKBKM($id);
|
|
$kredit_kbkm = $id_dpj[0]['NOMINAL_KBKM'];
|
|
$id_dpj = $id_dpj[0]['DPJ_ID'];
|
|
$pelanggan = $this->KasMasuk->getDataPEL($id_ddpj);
|
|
$id_pelanggan = $pelanggan[0]['ID_PELANGGAN'];
|
|
$saldo = $pelanggan[0]['SALDO_PELANGGAN'];
|
|
$saldo = $saldo-$kredit_kbkm;
|
|
$update = [
|
|
'SALDO_PELANGGAN' => $saldo
|
|
];
|
|
$action = $this->KasMasuk->update('pelanggan', $update, 'ID_PELANGGAN', $id_pelanggan);
|
|
|
|
//Step Ambil Data Lama
|
|
$id_dpj = $this->KasMasuk->getDPJID($id);
|
|
$id_dpj = $id_dpj[0]['DPJ_ID'];
|
|
$update = [
|
|
'DPJ_ID' => NULL
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->KasMasuk->delete('dp_penjualan',$id_dpj,'ID_DPJ');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
//Substep Three, Create Data Hutang/Piutang
|
|
public function kodeHutangLAIN() {
|
|
$kk = $this->KasMasuk->getKodeHutangLAIN();
|
|
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 detailhla() {
|
|
//Step Input Detail Hutang LAIN
|
|
$method = $this->input->post('method');
|
|
$id_hla = $this->input->post('id');
|
|
$id_kbkm = $this->input->post('id_kbkm');
|
|
$ket_hla = $this->input->post('ket_hla');
|
|
$kode_hla = $this->kodeHutangLAIN();
|
|
|
|
if ($ket_hla==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbkm = $this->KasMasuk->getDataKBKM($id_kbkm);
|
|
$nominal_hla = $kbkm[0]['NOMINAL_KBKM'];
|
|
$kode_bukti = $kbkm[0]['KODE_KBKM'];
|
|
$input = [
|
|
'NOMINAL_HLA' => $nominal_hla,
|
|
'KET_HLA' => $ket_hla,
|
|
'KODE_HLA' => $kode_hla,
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'BLOCKCON' => '0'
|
|
];
|
|
$action = $this->KasMasuk->create('hutang_lain', $input);
|
|
$id_hla = $this->KasMasuk->getIDHLA();
|
|
$update = [
|
|
'HLA_ID' => $id_hla[0]['ID_HLA']
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM',$id_kbkm);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function resethla() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Ambil Data Lama
|
|
$id_hla = $this->KasMasuk->getHLAID($id);
|
|
$id_hla = $id_hla[0]['HLA_ID'];
|
|
$update = [
|
|
'HLA_ID' => NULL
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->KasMasuk->delete('hutang_lain',$id_hla,'ID_HLA');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
//Substep Three, Angsuran Hutang/Piutang
|
|
public function kodeDetailPKAR() {
|
|
$kk = $this->KasMasuk->getKodeDetailPKAR();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "DPKAR/000001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$panjang = 6;
|
|
$data = substr($str, 6, $panjang);
|
|
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
|
|
$panjang = 12 - strlen($str);
|
|
$data = "DPKAR/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function detailpkar() {
|
|
//Step Input Detail Piutang Karyawan
|
|
$method = $this->input->post('method');
|
|
$id_dpkar = $this->input->post('id');
|
|
$id_kbkm = $this->input->post('id_kbkm');
|
|
$id_pkar = $this->input->post('id_pkar');
|
|
$kode_dpkar = $this->kodeDetailPKAR();
|
|
|
|
if ($id_pkar==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbkm = $this->KasMasuk->getDataKBKM($id_kbkm);
|
|
$nominal_pkar = $kbkm[0]['NOMINAL_KBKM'];
|
|
$kode_bukti = $kbkm[0]['KODE_KBKM'];
|
|
$input = [
|
|
'KODE_DPKAR' => $kode_dpkar,
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'PKAR_ID' => $id_pkar,
|
|
'DEBIT_DPKAR' => $nominal_pkar,
|
|
];
|
|
$action = $this->KasMasuk->create('detail_pkar', $input);
|
|
$id_dpkar = $this->KasMasuk->getIDDPKAR();
|
|
$id_dpkar = $id_dpkar[0]['ID_DPKAR'];
|
|
$update = [
|
|
'DPKAR_ID' => $id_dpkar
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM',$id_kbkm);
|
|
$blockcon = $this->KasMasuk->getBlockconPKAR($id_pkar);
|
|
$blockcon = $blockcon[0]['BLOCKCON']+$nominal_pkar;
|
|
$update = [
|
|
'BLOCKCON' => $blockcon
|
|
];
|
|
$action = $this->KasMasuk->update('piutang_karyawan', $update, 'ID_PKAR', $id_pkar);
|
|
$hutang = $this->KasMasuk->getDataPKAR($id_dpkar);
|
|
$id_karyawan = $hutang[0]['ID_KARYAWAN'];
|
|
$hutang_karyawan = $hutang[0]['HUTANG_KARYAWAN']-$nominal_pkar;
|
|
$update = [
|
|
'HUTANG_KARYAWAN' => $hutang_karyawan
|
|
];
|
|
$action = $this->KasMasuk->update('karyawan', $update, 'ID_KARYAWAN', $id_karyawan);
|
|
|
|
if ($action) {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function resetdpkar() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Ambil Data Lama
|
|
$id_dpkar = $this->KasMasuk->getDPKARID($id);
|
|
$id_dpkar = $id_dpkar[0]['DPKAR_ID'];
|
|
$pkar = $this->KasMasuk->getDataPKAR($id_dpkar);
|
|
$id_pkar = $pkar[0]['ID_PKAR'];
|
|
$id_karyawan = $pkar[0]['ID_KARYAWAN'];
|
|
$blockcon = $pkar[0]['BLOCKCON'];
|
|
$debit_dpkar = $pkar[0]['DEBIT_DPKAR'];
|
|
$hutang_karyawan = $pkar[0]['HUTANG_KARYAWAN'];
|
|
|
|
//Step Reset Piutang Karyawan
|
|
$blockcon = $blockcon-$debit_dpkar;
|
|
$update = [
|
|
'BLOCKCON' => $blockcon
|
|
];
|
|
$action = $this->KasMasuk->update('piutang_karyawan', $update, 'ID_PKAR', $id_pkar);
|
|
$hutang = $hutang_karyawan+$debit_dpkar;
|
|
$update = [
|
|
'HUTANG_KARYAWAN' => $hutang
|
|
];
|
|
$action = $this->KasMasuk->update('karyawan', $update, 'ID_KARYAWAN', $id_karyawan);
|
|
$update = [
|
|
'DPKAR_ID' => NULL
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->KasMasuk->delete('detail_pkar',$id_dpkar,'ID_DPKAR');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function kodeDetailPPI() {
|
|
$kk = $this->KasMasuk->getKodeDetailPPI();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "DPPI/000001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$panjang = 6;
|
|
$data = substr($str, 5, $panjang);
|
|
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
|
|
$panjang = 11 - strlen($str);
|
|
$data = "DPPI/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function detailppi() {
|
|
//Step Input Detail Piutang Pihak Ke3
|
|
$method = $this->input->post('method');
|
|
$id_dppi = $this->input->post('id');
|
|
$id_kbkm = $this->input->post('id_kbkm');
|
|
$id_ppi = $this->input->post('id_ppi');
|
|
$kode_dppi = $this->kodeDetailPPI();
|
|
|
|
if ($id_ppi==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbkm = $this->KasMasuk->getDataKBKM($id_kbkm);
|
|
$nominal_ppi = $kbkm[0]['NOMINAL_KBKM'];
|
|
$kode_bukti = $kbkm[0]['KODE_KBKM'];
|
|
$input = [
|
|
'KODE_DPPI' => $kode_dppi,
|
|
'KODE_BUKTI'=> $kode_bukti,
|
|
'PPI_ID' => $id_ppi,
|
|
'DEBIT_DPPI'=> $nominal_ppi
|
|
];
|
|
$action = $this->KasMasuk->create('detail_ppi', $input);
|
|
$id_dppi = $this->KasMasuk->getIDDPPI();
|
|
$id_dppi = $id_dppi[0]['ID_DPPI'];
|
|
$update = [
|
|
'DPPI_ID' => $id_dppi
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM',$id_kbkm);
|
|
$blockcon = $this->KasMasuk->getBlockconPPI($id_ppi);
|
|
$blockcon = $blockcon[0]['BLOCKCON']+$nominal_ppi;
|
|
$update = [
|
|
'BLOCKCON' => $blockcon
|
|
];
|
|
$action = $this->KasMasuk->update('piutang_pihakke3', $update, 'ID_PPI', $id_ppi);
|
|
$hutang = $this->KasMasuk->getDataPPI($id_dppi);
|
|
$id_pihakke3 = $hutang[0]['ID_PIHAKKE3'];
|
|
$hutang_pihakke3 = $hutang[0]['HUTANG_PIHAKKE3']-$nominal_ppi;
|
|
$update = [
|
|
'HUTANG_PIHAKKE3' => $hutang_pihakke3
|
|
];
|
|
$action = $this->KasMasuk->update('pihakke3', $update, 'ID_PIHAKKE3', $id_pihakke3);
|
|
|
|
if ($action) {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function resetdppi() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Ambil Data Lama
|
|
$id_dppi = $this->KasMasuk->getDPPIID($id);
|
|
$id_dppi = $id_dppi[0]['DPPI_ID'];
|
|
$ppi = $this->KasMasuk->getDataPPI($id_dppi);
|
|
$id_ppi = $ppi[0]['ID_PPI'];
|
|
$id_pihakke3 = $ppi[0]['ID_PIHAKKE3'];
|
|
$blockcon = $ppi[0]['BLOCKCON'];
|
|
$debit_dppi = $ppi[0]['DEBIT_DPPI'];
|
|
$hutang_pihakke3 = $ppi[0]['HUTANG_PIHAKKE3'];
|
|
|
|
//Step Reset Piutang Pihak Ke3
|
|
$blockcon = $blockcon-$debit_dppi;
|
|
$update = [
|
|
'BLOCKCON' => $blockcon
|
|
];
|
|
$action = $this->KasMasuk->update('piutang_pihakke3', $update, 'ID_PPI', $id_ppi);
|
|
$hutang = $hutang_pihakke3+$debit_dppi;
|
|
$update = [
|
|
'HUTANG_PIHAKKE3' => $hutang
|
|
];
|
|
$action = $this->KasMasuk->update('pihakke3', $update, 'ID_PIHAKKE3', $id_pihakke3);
|
|
$update = [
|
|
'DPPI_ID' => NULL
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->KasMasuk->delete('detail_ppi',$id_dppi,'ID_DPPI');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function kodeDetailPDA() {
|
|
$kk = $this->KasMasuk->getKodeDetailPDA();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "DPDA/000001";
|
|
} else {
|
|
$str = (string) $row['KODE'];
|
|
$panjang = 6;
|
|
$data = substr($str, 5, $panjang);
|
|
|
|
$ko = (int) $data + 1;
|
|
$str = (string) $ko;
|
|
|
|
$panjang = 11 - strlen($str);
|
|
$data = "DPDA/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function detailpda() {
|
|
//Step Input Detail Piutang Dagang/Pelanggan
|
|
$method = $this->input->post('method');
|
|
$id_dpda = $this->input->post('id');
|
|
$id_kbkm = $this->input->post('id_kbkm');
|
|
$id_pda = $this->input->post('id_pda');
|
|
$kode_dpda = $this->kodeDetailPDA();
|
|
|
|
if ($id_pda==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbkm = $this->KasMasuk->getDataKBKM($id_kbkm);
|
|
$nominal_pda = $kbkm[0]['NOMINAL_KBKM'];
|
|
$kode_bukti = $kbkm[0]['KODE_KBKM'];
|
|
$input = [
|
|
'KODE_DPDA' => $kode_dpda,
|
|
'KODE_BUKTI'=> $kode_bukti,
|
|
'PDA_ID' => $id_pda,
|
|
'DEBIT_DPDA'=> $nominal_pda
|
|
];
|
|
$action = $this->KasMasuk->create('detail_pda', $input);
|
|
$id_dpda = $this->KasMasuk->getIDDPDA();
|
|
$id_dpda = $id_dpda[0]['ID_DPDA'];
|
|
$update = [
|
|
'DPDA_ID' => $id_dpda
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM',$id_kbkm);
|
|
$blockcon = $this->KasMasuk->getBlockconPDA($id_pda);
|
|
$blockcon = $blockcon[0]['BLOCKCON']+$nominal_pda;
|
|
$update = [
|
|
'BLOCKCON' => $blockcon
|
|
];
|
|
$action = $this->KasMasuk->update('piutang_dagang', $update, 'ID_PDA', $id_pda);
|
|
$hutang = $this->KasMasuk->getDataPDA($id_dpda);
|
|
$id_pelanggan = $hutang[0]['ID_PELANGGAN'];
|
|
$hutang_pelanggan = $hutang[0]['HUTANG_PELANGGAN']-$nominal_pda;
|
|
$update = [
|
|
'HUTANG_PELANGGAN' => $hutang_pelanggan
|
|
];
|
|
$action = $this->KasMasuk->update('pelanggan', $update, 'ID_PELANGGAN', $id_pelanggan);
|
|
|
|
if ($action) {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function resetdpda() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Ambil Data Lama
|
|
$id_dpda = $this->KasMasuk->getDPDAID($id);
|
|
$id_dpda = $id_dpda[0]['DPDA_ID'];
|
|
$pda = $this->KasMasuk->getDataPDA($id_dpda);
|
|
$id_pda = $pda[0]['ID_PDA'];
|
|
$id_pelanggan = $pda[0]['ID_PELANGGAN'];
|
|
$blockcon = $pda[0]['BLOCKCON'];
|
|
$debit_dpda = $pda[0]['DEBIT_DPDA'];
|
|
$hutang_pelanggan = $pda[0]['HUTANG_PELANGGAN'];
|
|
|
|
//Step Reset Piutang Dagang/Pelanggan
|
|
$blockcon = $blockcon-$debit_dpda;
|
|
$update = [
|
|
'BLOCKCON' => $blockcon
|
|
];
|
|
$action = $this->KasMasuk->update('piutang_dagang', $update, 'ID_PDA', $id_pda);
|
|
$hutang = $hutang_pelanggan+$debit_dpda;
|
|
$update = [
|
|
'HUTANG_PELANGGAN' => $hutang
|
|
];
|
|
$action = $this->KasMasuk->update('pelanggan', $update, 'ID_PELANGGAN', $id_pelanggan);
|
|
$update = [
|
|
'DPDA_ID' => NULL
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->KasMasuk->delete('detail_pda',$id_dpda,'ID_DPDA');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
//Substep Three, Link Biaya Pengiriman
|
|
public function kodeDetailBP() {
|
|
$kk = $this->KasMasuk->getKodeDetailBP();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "DBP/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 = "DBP/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function detailbp() {
|
|
//Step Input Detail Biaya Pengiriman
|
|
$method = $this->input->post('method');
|
|
$id_dbp = $this->input->post('id');
|
|
$id_kbkm = $this->input->post('id_kbkm');
|
|
$id_bp = $this->input->post('id_bp');
|
|
$kode_dbp = $this->kodeDetailBP();
|
|
|
|
if ($id_bp==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbkm = $this->KasMasuk->getDataKBKM($id_kbkm);
|
|
$debit_dbp = $kbkm[0]['NOMINAL_KBKM'];
|
|
$bukti_debit = $kbkm[0]['KODE_KBKM'];
|
|
$input = [
|
|
'KODE_DBP' => $kode_dbp,
|
|
'BUKTI_DEBIT' => $bukti_debit,
|
|
'BP_ID' => $id_bp,
|
|
'DEBIT_DBP' => $debit_dbp,
|
|
];
|
|
$action = $this->KasMasuk->create('detail_bp', $input);
|
|
$id_dbp = $this->KasMasuk->getIDDBP();
|
|
$id_dbp = $id_dbp[0]['ID_DBP'];
|
|
$update = [
|
|
'DBP_ID' => $id_dbp
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM',$id_kbkm);
|
|
$blockdeb = $this->KasMasuk->getBlockdebBP($id_bp);
|
|
$blockdeb = $blockdeb[0]['BLOCKDEB_BP']+$debit_dbp;
|
|
$update = [
|
|
'BLOCKDEB_BP' => $blockdeb
|
|
];
|
|
$action = $this->KasMasuk->update('biaya_pengiriman', $update, 'ID_BP', $id_bp);
|
|
|
|
if ($action) {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
public function resetdbp() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Ambil Data Lama
|
|
$id_dbp = $this->KasMasuk->getDBPID($id);
|
|
$id_dbp = $id_dbp[0]['DBP_ID'];
|
|
$bp = $this->KasMasuk->getDataBP($id_dbp);
|
|
$id_bp = $bp[0]['ID_BP'];
|
|
$blockdeb = $bp[0]['BLOCKDEB_BP'];
|
|
$debit_dbp = $bp[0]['DEBIT_DBP'];
|
|
//Step Reset Biaya Pengiriman
|
|
$blockdeb = $blockdeb-$debit_dbp;
|
|
$update = [
|
|
'BLOCKDEB_BP' => $blockdeb
|
|
];
|
|
$action = $this->KasMasuk->update('biaya_pengiriman', $update, 'ID_BP', $id_bp);
|
|
$update = [
|
|
'DBP_ID' => NULL
|
|
];
|
|
$action = $this->KasMasuk->update('kasbank_km', $update, 'ID_KBKM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->KasMasuk->delete('detail_bp',$id_dbp,'ID_DBP');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
|
|
}
|