1242 lines
36 KiB
PHP
1242 lines
36 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 ManageBankMasuk extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelBankMasuk', 'BankMasuk');
|
|
$this->load->model('ModelBank', 'Bank');
|
|
$this->load->model('ModelDpPembelian', 'Dpb');
|
|
$this->load->model('ModelHutangDagang', 'Hda');
|
|
$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 Bank Masuk
|
|
public function index() {
|
|
|
|
$datBankMasuk = $this->BankMasuk->getDataBankMasuk();
|
|
$datBank = $this->Bank->getDataBankDetail();
|
|
|
|
$data = [
|
|
'sidebar' => "menu accounting",
|
|
'navChild' => "",
|
|
'bankmasuk' => $datBankMasuk,
|
|
'bank' => $datBank
|
|
];
|
|
|
|
$this->load->view('proses/BankMasuk', $data);
|
|
}
|
|
|
|
public function kodeBankMasuk() {
|
|
$kk = $this->BankMasuk->getKodeBankMasuk();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "BBM/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 = "BBM/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function save() {
|
|
$method = $this->input->post('method');
|
|
$id = $this->input->post('id_bankmasuk');
|
|
$id_bank = $this->input->post('id_bank');
|
|
$debit_bankmasuk = $this->input->post('debit_bankmasuk');
|
|
$kode_bankmasuk = $this->kodeBankMasuk();
|
|
|
|
$input = [
|
|
'KODE_BANKMASUK' => $kode_bankmasuk,
|
|
'BANK_ID' => $id_bank,
|
|
'DEBIT_BANKMASUK' => $debit_bankmasuk,
|
|
'KREDIT_BANKMASUK' => '0'
|
|
];
|
|
|
|
$action = $this->BankMasuk->create('bankmasuk', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageBankMasuk');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageBankMasuk');
|
|
}
|
|
|
|
}
|
|
|
|
public function edit() {
|
|
$method = $this->input->post('method');
|
|
$id_bankmasuk = $this->input->post('id_bankmasuk');
|
|
$id_bank = $this->input->post('id_banked');
|
|
$debit_bankmasuk = $this->input->post('debit_bankmasuked');
|
|
|
|
$update = [
|
|
'BANK_ID' => $id_bank,
|
|
'DEBIT_BANKMASUK' => $debit_bankmasuk
|
|
];
|
|
|
|
$action = $this->BankMasuk->update('bankmasuk', $update, 'ID_BANKMASUK', $id_bankmasuk);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diedit');
|
|
redirect('ManageBankMasuk');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diedit');
|
|
redirect('ManageBankMasuk');
|
|
}
|
|
}
|
|
|
|
public function hapus() {
|
|
$id = $this->input->post('id');
|
|
|
|
$action = $this->BankMasuk->hapusKasbankBM($id);
|
|
$action = $this->BankMasuk->delete('bankmasuk',$id,'ID_BANKMASUK');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function konfirmasi() {
|
|
$method = $this->input->post('method');
|
|
$id_bankmasuk = $this->input->post('id_bankmasuk');
|
|
|
|
//Proses Konfirmasi + Update Saldo Bank
|
|
$databank = $this->BankMasuk->getDataBankMasuk($id_bankmasuk);
|
|
$saldo = $databank[0]['SALDO_BANK'];
|
|
$nominal = $databank[0]['DEBIT_BANKMASUK'];
|
|
$id_bank = $databank[0]['BANK_ID'];
|
|
$saldo_bank = $saldo+$nominal;
|
|
$update = [
|
|
'SALDO_BANK' => $saldo_bank
|
|
];
|
|
$action = $this->BankMasuk->update('bank', $update, 'ID_BANK', $id_bank);
|
|
$update = [
|
|
'STATUS_BANKMASUK' => '0'
|
|
];
|
|
$action = $this->BankMasuk->update('bankmasuk', $update, 'ID_BANKMASUK', $id_bankmasuk);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'dikonfirmasi');
|
|
redirect('ManageBankMasuk');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'dikonfirmasi');
|
|
redirect('ManageBankMasuk');
|
|
}
|
|
|
|
}
|
|
|
|
//Step Two, Input Transaksi
|
|
public function tambahTransaksi($id) {
|
|
$transaksi = $this->BankMasuk->getDataKasbankBM($id);
|
|
$title = $this->BankMasuk->getTitleBM($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();
|
|
$hda = $this->Hda->getDataHutangDagangDetail();
|
|
$dpb = $this->Dpb->getDataDpPembelianDetail();
|
|
$data = [
|
|
'sidebar' => "menu accounting",
|
|
'navChild' => "",
|
|
'transaksi' => $transaksi,
|
|
'id_bankmasuk' => $id,
|
|
'title1' => $title[0]['KODE_BANKMASUK'],
|
|
'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,
|
|
'hda' => $hda,
|
|
'dpb' => $dpb
|
|
];
|
|
|
|
$this->load->view('proses/KasbankBM', $data);
|
|
}
|
|
|
|
public function kodeKasbankBM() {
|
|
$kk = $this->BankMasuk->getKodeKasbankBM();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "KBBM/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 = "KBBM/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function savetransaksi() {
|
|
//Step Input Transaksi
|
|
$method = $this->input->post('method');
|
|
$id_kbbm = $this->input->post('id');
|
|
$id_bankmasuk = $this->input->post('id_bankmasuk');
|
|
$id_perkiraan = $this->input->post('id_perkiraan');
|
|
$nominal_kbbm = $this->input->post('nominal_kbbm');
|
|
$ket_kbbm = $this->input->post('ket_kbbm');
|
|
$kode_kbbm = $this->kodeKasbankBM();
|
|
|
|
$input = [
|
|
'BANKMASUK_ID' => $id_bankmasuk,
|
|
'PERKIRAAN_ID' => $id_perkiraan,
|
|
'NOMINAL_KBBM' => $nominal_kbbm,
|
|
'KET_KBBM' => $ket_kbbm,
|
|
'KODE_KBBM' => $kode_kbbm
|
|
];
|
|
|
|
$action = $this->BankMasuk->create('kasbank_bm', $input);
|
|
|
|
//Step Ambil Data Lama
|
|
$id_kbbm = $this->BankMasuk->getID_KBBM();
|
|
$datakredit = $this->BankMasuk->getKreditData($id_kbbm[0]['KODE']);
|
|
$id_bankmasuk = $datakredit[0]['ID_BANKMASUK'];
|
|
$nominal = $datakredit[0]['KREDIT_BANKMASUK'];
|
|
$kredit_bankmasuk = $nominal+$nominal_kbbm;
|
|
$update = [
|
|
'KREDIT_BANKMASUK' => $kredit_bankmasuk
|
|
];
|
|
$action = $this->BankMasuk->update('bankmasuk', $update, 'ID_BANKMASUK', $id_bankmasuk);
|
|
|
|
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_kbbm = $this->input->post('id_kbbm');
|
|
$id_bankmasuk = $this->input->post('id_bankmasuk');
|
|
$id_perkiraan = $this->input->post('id_perkiraaned');
|
|
$nominal_kbbm = $this->input->post('nominal_kbbmed');
|
|
$ket_kbbm = $this->input->post('ket_kbbmed');
|
|
|
|
//Step Ambil Data Lama
|
|
$datakredit = $this->BankMasuk->getKreditData($id_kbbm);
|
|
$nominal = $datakredit[0]['KREDIT_BANKMASUK'];
|
|
$nominallama = $datakredit[0]['NOMINAL_KBBM'];
|
|
$nominalbaru = $nominal-$nominallama;
|
|
$update = [
|
|
'KREDIT_BANKMASUK' => $nominalbaru
|
|
];
|
|
$action = $this->BankMasuk->update('bankmasuk', $update, 'ID_BANKMASUK', $id_bankmasuk);
|
|
|
|
//Step Update Debit Bank Masuk
|
|
$update = [
|
|
'PERKIRAAN_ID' => $id_perkiraan,
|
|
'NOMINAL_KBBM' => $nominal_kbbm,
|
|
'KET_KBBM' => $ket_kbbm
|
|
];
|
|
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM',$id_kbbm);
|
|
|
|
//Step Update Bank Masuk
|
|
$datakredit = $this->BankMasuk->getKreditData($id_kbbm);
|
|
$nominal = $datakredit[0]['KREDIT_BANKMASUK'];
|
|
$nominalbaru = $nominal+$nominal_kbbm;
|
|
$update = [
|
|
'KREDIT_BANKMASUK' => $nominalbaru
|
|
];
|
|
$action = $this->BankMasuk->update('bankmasuk', $update, 'ID_BANKMASUK', $id_bankmasuk);
|
|
|
|
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->BankMasuk->getKreditData($id);
|
|
$id_bankmasuk = $datakredit[0]['ID_BANKMASUK'];
|
|
$nominal = $datakredit[0]['KREDIT_BANKMASUK'];
|
|
$kredit = $datakredit[0]['NOMINAL_KBBM'];
|
|
$nominalbaru = $nominal-$kredit;
|
|
$update = [
|
|
'KREDIT_BANKMASUK' => $nominalbaru
|
|
];
|
|
$action = $this->BankMasuk->update('bankmasuk', $update, 'ID_BANKMASUK', $id_bankmasuk);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->BankMasuk->delete('kasbank_bm',$id,'ID_KBBM');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
//Step Three, Input Detail
|
|
|
|
//Substep Three, Transaksi Sekali Jalan
|
|
public function kodeDetailKAS() {
|
|
$kk = $this->BankMasuk->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_kbbm = $this->input->post('id_kbbm');
|
|
$id_kas = $this->input->post('id_kas');
|
|
$kode_dkas = $this->kodeDetailKAS();
|
|
|
|
if ($id_kas==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbbm = $this->BankMasuk->getDataKBBM($id_kbbm);
|
|
$kredit_dkas = $kbbm[0]['NOMINAL_KBBM'];
|
|
$kode_bukti = $kbbm[0]['KODE_KBBM'];
|
|
$input = [
|
|
'KREDIT_DKAS' => $kredit_dkas,
|
|
'KAS_ID' => $id_kas,
|
|
'KODE_DKAS' => $kode_dkas,
|
|
'KODE_BUKTI' => $kode_bukti
|
|
];
|
|
$action = $this->BankMasuk->create('detail_kas', $input);
|
|
$kas = $this->BankMasuk->getSaldoKAS($id_kas);
|
|
$saldo = $kas[0]['SALDO_KAS'] - $kredit_dkas ;
|
|
$update = [
|
|
'SALDO_KAS' => $saldo
|
|
];
|
|
$action = $this->BankMasuk->update('kas', $update, 'ID_KAS', $id_kas);
|
|
$id_dkas = $this->BankMasuk->getIDDKAS();
|
|
$update = [
|
|
'DKAS_ID' => $id_dkas[0]['ID_DKAS']
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM',$id_kbbm);
|
|
|
|
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->BankMasuk->getDataKBBM($id);
|
|
$kredit_kbbm = $id_dkas[0]['NOMINAL_KBBM'];
|
|
$id_dkas = $id_dkas[0]['DKAS_ID'];
|
|
$kas = $this->BankMasuk->getDataKAS($id_dkas);
|
|
$id_kas = $kas[0]['ID_KAS'];
|
|
$saldo = $kas[0]['SALDO_KAS'];
|
|
$saldo = $saldo+$kredit_kbbm;
|
|
$update = [
|
|
'SALDO_KAS' => $saldo
|
|
];
|
|
$action = $this->BankMasuk->update('kas', $update, 'ID_KAS', $id_kas);
|
|
|
|
//Step Ambil Data Lama
|
|
$id_dkas = $this->BankMasuk->getDKASID($id);
|
|
$id_dkas = $id_dkas[0]['DKAS_ID'];
|
|
$update = [
|
|
'DKAS_ID' => NULL
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->BankMasuk->delete('detail_kas',$id_dkas,'ID_DKAS');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function kodeDetailBANK() {
|
|
$kk = $this->BankMasuk->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_kbbm = $this->input->post('id_kbbm');
|
|
$id_bank = $this->input->post('id_bank');
|
|
$kode_dbank = $this->kodeDetailBANK();
|
|
|
|
if ($id_bank==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbbm = $this->BankMasuk->getDataKBBM($id_kbbm);
|
|
$kredit_dbank = $kbbm[0]['NOMINAL_KBBM'];
|
|
$kode_bukti = $kbbm[0]['KODE_KBBM'];
|
|
$input = [
|
|
'KREDIT_DBANK' => $kredit_dbank,
|
|
'BANK_ID' => $id_bank,
|
|
'KODE_DBANK' => $kode_dbank,
|
|
'KODE_BUKTI' => $kode_bukti
|
|
];
|
|
$action = $this->BankMasuk->create('detail_bank', $input);
|
|
$bank = $this->BankMasuk->getSaldoBANK($id_bank);
|
|
$saldo = $bank[0]['SALDO_BANK'] - $kredit_dbank ;
|
|
$update = [
|
|
'SALDO_BANK' => $saldo
|
|
];
|
|
$action = $this->BankMasuk->update('bank', $update, 'ID_BANK', $id_bank);
|
|
$id_dbank = $this->BankMasuk->getIDDBANK();
|
|
$update = [
|
|
'DBANK_ID' => $id_dbank[0]['ID_DBANK']
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM',$id_kbbm);
|
|
|
|
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->BankMasuk->getDataKBBM($id);
|
|
$kredit_kbbm = $id_dbank[0]['NOMINAL_KBBM'];
|
|
$id_dbank = $id_dbank[0]['DBANK_ID'];
|
|
$bank = $this->BankMasuk->getDataBANK($id_dbank);
|
|
$id_bank = $bank[0]['ID_BANK'];
|
|
$saldo = $bank[0]['SALDO_BANK'];
|
|
$saldo = $saldo+$kredit_kbbm;
|
|
$update = [
|
|
'SALDO_BANK' => $saldo
|
|
];
|
|
$action = $this->BankMasuk->update('bank', $update, 'ID_BANK', $id_bank);
|
|
|
|
//Step Ambil Data Lama
|
|
$id_dbank = $this->BankMasuk->getDBANKID($id);
|
|
$id_dbank = $id_dbank[0]['DBANK_ID'];
|
|
$update = [
|
|
'DBANK_ID' => NULL
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->BankMasuk->delete('detail_bank',$id_dbank,'ID_DBANK');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function kodeDPJ() {
|
|
$kk = $this->BankMasuk->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_kbbm = $this->input->post('id_kbbm');
|
|
$id_pelanggan = $this->input->post('id_pelanggan');
|
|
$kode_dpj = $this->kodeDPJ();
|
|
|
|
if ($id_pelanggan==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbbm = $this->BankMasuk->getDataKBBM($id_kbbm);
|
|
$nominal_dpj = $kbbm[0]['NOMINAL_KBBM'];
|
|
$kode_bukti = $kbbm[0]['KODE_KBBM'];
|
|
$input = [
|
|
'NOMINAL_DPJ' => $nominal_dpj,
|
|
'PELANGGAN_ID' => $id_pelanggan,
|
|
'KODE_DPJ' => $kode_dpj,
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'BLOCKCON' => '0'
|
|
];
|
|
$action = $this->BankMasuk->create('dp_penjualan', $input);
|
|
$pelanggan = $this->BankMasuk->getSaldoDPJ($id_pelanggan);
|
|
$saldo = $pelanggan[0]['SALDO_PELANGGAN'] + $nominal_dpj ;
|
|
$update = [
|
|
'SALDO_PELANGGAN' => $saldo
|
|
];
|
|
$action = $this->BankMasuk->update('pelanggan', $update, 'ID_PELANGGAN', $id_pelanggan);
|
|
$id_dpj = $this->BankMasuk->getIDDPJ();
|
|
$update = [
|
|
'DPJ_ID' => $id_dpj[0]['ID_DPJ']
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM',$id_kbbm);
|
|
|
|
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->BankMasuk->getDataKBBM($id);
|
|
$kredit_kbbm = $id_dpj[0]['NOMINAL_KBBM'];
|
|
$id_dpj = $id_dpj[0]['DPJ_ID'];
|
|
$pelanggan = $this->BankMasuk->getDataPEL($id_dpj);
|
|
$id_pelanggan = $pelanggan[0]['ID_PELANGGAN'];
|
|
$saldo = $pelanggan[0]['SALDO_PELANGGAN'];
|
|
$saldo = $saldo-$kredit_kbbm;
|
|
$update = [
|
|
'SALDO_PELANGGAN' => $saldo
|
|
];
|
|
$action = $this->BankMasuk->update('pelanggan', $update, 'ID_PELANGGAN', $id_pelanggan);
|
|
|
|
//Step Ambil Data Lama
|
|
$id_dpj = $this->BankMasuk->getDPJID($id);
|
|
$id_dpj = $id_dpj[0]['DPJ_ID'];
|
|
$update = [
|
|
'DPJ_ID' => NULL
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->BankMasuk->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 kodeHutangBANK() {
|
|
$kk = $this->BankMasuk->getKodeHutangBANK();
|
|
if (is_array($kk) || is_object($kk)) {
|
|
foreach ($kk as $row) {
|
|
if ($row['KODE'] == null) {
|
|
return "HBA/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 = "HBA/000000";
|
|
$data = substr($data, 0, $panjang) . $str;
|
|
return $data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function detailhba() {
|
|
//Step Input Detail Hutang BANK
|
|
$method = $this->input->post('method');
|
|
$id_hba = $this->input->post('id');
|
|
$id_kbbm = $this->input->post('id_kbbm');
|
|
$id_bank = $this->input->post('id_bank');
|
|
$kode_hba = $this->kodeHutangBANK();
|
|
|
|
if ($id_bank==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbbm = $this->BankMasuk->getDataKBBM($id_kbbm);
|
|
$nominal_hba = $kbbm[0]['NOMINAL_KBBM'];
|
|
$kode_bukti = $kbbm[0]['KODE_KBBM'];
|
|
$input = [
|
|
'NOMINAL_HBA' => $nominal_hba,
|
|
'BANK_ID' => $id_bank,
|
|
'KODE_HBA' => $kode_hba,
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'BLOCKCON' => '0'
|
|
];
|
|
$action = $this->BankMasuk->create('hutang_bank', $input);
|
|
$bank = $this->BankMasuk->getHutangSaldoBANK($id_bank);
|
|
$hutang = $bank[0]['HUTANG_BANK'] + $nominal_hba ;
|
|
$saldo = $bank[0]['SALDO_BANK'] + $nominal_hba ;
|
|
$update = [
|
|
'HUTANG_BANK' => $hutang,
|
|
'SALDO_BANK' => $saldo
|
|
];
|
|
$action = $this->BankMasuk->update('bank', $update, 'ID_BANK', $id_bank);
|
|
$id_hba = $this->BankMasuk->getIDHBA();
|
|
$update = [
|
|
'HBA_ID' => $id_hba[0]['ID_HBA']
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM',$id_kbbm);
|
|
|
|
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 resethba() {
|
|
$id = $this->input->post('id');
|
|
|
|
//Step Reset Hutang BANK
|
|
$bank = $this->BankMasuk->getDataKBBM($id);
|
|
$nominal_kbbm = $bank[0]['NOMINAL_KBBM'];
|
|
$id_hba = $bank[0]['HBA_ID'];
|
|
$bank = $this->BankMasuk->getDataHBA($id_hba);
|
|
$id_bank = $bank[0]['ID_BANK'];
|
|
$hutang = $bank[0]['HUTANG_BANK'];
|
|
$saldo = $bank[0]['SALDO_BANK'];
|
|
$hutang = $hutang-$nominal_kbbm;
|
|
$saldo = $saldo-$nominal_kbbm;
|
|
$update = [
|
|
'HUTANG_BANK' => $hutang,
|
|
'SALDO_BANK' => $saldo
|
|
];
|
|
$action = $this->BankMasuk->update('bank', $update, 'ID_BANK', $id_bank);
|
|
|
|
//Step Ambil Data Lama
|
|
$id_hba = $this->BankMasuk->getHBAID($id);
|
|
$id_hba = $id_hba[0]['HBA_ID'];
|
|
$update = [
|
|
'HBA_ID' => NULL
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->BankMasuk->delete('hutang_bank',$id_hba,'ID_HBA');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function kodeHutangLAIN() {
|
|
$kk = $this->BankMasuk->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_kbbm = $this->input->post('id_kbbm');
|
|
$ket_hla = $this->input->post('ket_hla');
|
|
$kode_hla = $this->kodeHutangLAIN();
|
|
|
|
if ($ket_hla==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbbm = $this->BankMasuk->getDataKBBM($id_kbbm);
|
|
$nominal_hla = $kbbm[0]['NOMINAL_KBBM'];
|
|
$kode_bukti = $kbbm[0]['KODE_KBBM'];
|
|
$input = [
|
|
'NOMINAL_HLA' => $nominal_hla,
|
|
'KET_HLA' => $ket_hla,
|
|
'KODE_HLA' => $kode_hla,
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'BLOCKCON' => '0'
|
|
];
|
|
$action = $this->BankMasuk->create('hutang_lain', $input);
|
|
$id_hla = $this->BankMasuk->getIDHLA();
|
|
$update = [
|
|
'HLA_ID' => $id_hla[0]['ID_HLA']
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM',$id_kbbm);
|
|
|
|
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->BankMasuk->getHLAID($id);
|
|
$id_hla = $id_hla[0]['HLA_ID'];
|
|
$update = [
|
|
'HLA_ID' => NULL
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->BankMasuk->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->BankMasuk->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_kbbm = $this->input->post('id_kbbm');
|
|
$id_pkar = $this->input->post('id_pkar');
|
|
$kode_dpkar = $this->kodeDetailPKAR();
|
|
|
|
if ($id_pkar==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbbm = $this->BankMasuk->getDataKBBM($id_kbbm);
|
|
$nominal_pkar = $kbbm[0]['NOMINAL_KBBM'];
|
|
$kode_bukti = $kbbm[0]['KODE_KBBM'];
|
|
$input = [
|
|
'KODE_DPKAR' => $kode_dpkar,
|
|
'KODE_BUKTI' => $kode_bukti,
|
|
'PKAR_ID' => $id_pkar,
|
|
'DEBIT_DPKAR' => $nominal_pkar,
|
|
];
|
|
$action = $this->BankMasuk->create('detail_pkar', $input);
|
|
$id_dpkar = $this->BankMasuk->getIDDPKAR();
|
|
$id_dpkar = $id_dpkar[0]['ID_DPKAR'];
|
|
$update = [
|
|
'DPKAR_ID' => $id_dpkar
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM',$id_kbbm);
|
|
$blockcon = $this->BankMasuk->getBlockconPKAR($id_pkar);
|
|
$blockcon = $blockcon[0]['BLOCKCON']+$nominal_pkar;
|
|
$update = [
|
|
'BLOCKCON' => $blockcon
|
|
];
|
|
$action = $this->BankMasuk->update('piutang_karyawan', $update, 'ID_PKAR', $id_pkar);
|
|
$hutang = $this->BankMasuk->getDataPKAR($id_dpkar);
|
|
$id_karyawan = $hutang[0]['ID_KARYAWAN'];
|
|
$hutang_karyawan = $hutang[0]['HUTANG_KARYAWAN']-$nominal_pkar;
|
|
$update = [
|
|
'HUTANG_KARYAWAN' => $hutang_karyawan
|
|
];
|
|
$action = $this->BankMasuk->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->BankMasuk->getDPKARID($id);
|
|
$id_dpkar = $id_dpkar[0]['DPKAR_ID'];
|
|
$pkar = $this->BankMasuk->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->BankMasuk->update('piutang_karyawan', $update, 'ID_PKAR', $id_pkar);
|
|
$hutang = $hutang_karyawan+$debit_dpkar;
|
|
$update = [
|
|
'HUTANG_KARYAWAN' => $hutang
|
|
];
|
|
$action = $this->BankMasuk->update('karyawan', $update, 'ID_KARYAWAN', $id_karyawan);
|
|
$update = [
|
|
'DPKAR_ID' => NULL
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->BankMasuk->delete('detail_pkar',$id_dpkar,'ID_DPKAR');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function kodeDetailPPI() {
|
|
$kk = $this->BankMasuk->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_kbbm = $this->input->post('id_kbbm');
|
|
$id_ppi = $this->input->post('id_ppi');
|
|
$kode_dppi = $this->kodeDetailPPI();
|
|
|
|
if ($id_ppi==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbbm = $this->BankMasuk->getDataKBBM($id_kbbm);
|
|
$nominal_ppi = $kbbm[0]['NOMINAL_KBBM'];
|
|
$kode_bukti = $kbbm[0]['KODE_KBBM'];
|
|
$input = [
|
|
'KODE_DPPI' => $kode_dppi,
|
|
'KODE_BUKTI'=> $kode_bukti,
|
|
'PPI_ID' => $id_ppi,
|
|
'DEBIT_DPPI'=> $nominal_ppi
|
|
];
|
|
$action = $this->BankMasuk->create('detail_ppi', $input);
|
|
$id_dppi = $this->BankMasuk->getIDDPPI();
|
|
$id_dppi = $id_dppi[0]['ID_DPPI'];
|
|
$update = [
|
|
'DPPI_ID' => $id_dppi
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM',$id_kbbm);
|
|
$blockcon = $this->BankMasuk->getBlockconPPI($id_ppi);
|
|
$blockcon = $blockcon[0]['BLOCKCON']+$nominal_ppi;
|
|
$update = [
|
|
'BLOCKCON' => $blockcon
|
|
];
|
|
$action = $this->BankMasuk->update('piutang_pihakke3', $update, 'ID_PPI', $id_ppi);
|
|
$hutang = $this->BankMasuk->getDataPPI($id_dppi);
|
|
$id_pihakke3 = $hutang[0]['ID_PIHAKKE3'];
|
|
$hutang_pihakke3 = $hutang[0]['HUTANG_PIHAKKE3']-$nominal_ppi;
|
|
$update = [
|
|
'HUTANG_PIHAKKE3' => $hutang_pihakke3
|
|
];
|
|
$action = $this->BankMasuk->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->BankMasuk->getDPPIID($id);
|
|
$id_dppi = $id_dppi[0]['DPPI_ID'];
|
|
$ppi = $this->BankMasuk->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->BankMasuk->update('piutang_pihakke3', $update, 'ID_PPI', $id_ppi);
|
|
$hutang = $hutang_pihakke3+$debit_dppi;
|
|
$update = [
|
|
'HUTANG_PIHAKKE3' => $hutang
|
|
];
|
|
$action = $this->BankMasuk->update('pihakke3', $update, 'ID_PIHAKKE3', $id_pihakke3);
|
|
$update = [
|
|
'DPPI_ID' => NULL
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->BankMasuk->delete('detail_ppi',$id_dppi,'ID_DPPI');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function kodeDetailPDA() {
|
|
$kk = $this->BankMasuk->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_kbbm = $this->input->post('id_kbbm');
|
|
$id_pda = $this->input->post('id_pda');
|
|
$kode_dpda = $this->kodeDetailPDA();
|
|
|
|
if ($id_pda==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbbm = $this->BankMasuk->getDataKBBM($id_kbbm);
|
|
$nominal_pda = $kbbm[0]['NOMINAL_KBBM'];
|
|
$kode_bukti = $kbbm[0]['KODE_KBBM'];
|
|
$input = [
|
|
'KODE_DPDA' => $kode_dpda,
|
|
'KODE_BUKTI'=> $kode_bukti,
|
|
'PDA_ID' => $id_pda,
|
|
'DEBIT_DPDA'=> $nominal_pda
|
|
];
|
|
$action = $this->BankMasuk->create('detail_pda', $input);
|
|
$id_dpda = $this->BankMasuk->getIDDPDA();
|
|
$id_dpda = $id_dpda[0]['ID_DPDA'];
|
|
$update = [
|
|
'DPDA_ID' => $id_dpda
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM',$id_kbbm);
|
|
$blockcon = $this->BankMasuk->getBlockconPDA($id_pda);
|
|
$blockcon = $blockcon[0]['BLOCKCON']+$nominal_pda;
|
|
$update = [
|
|
'BLOCKCON' => $blockcon
|
|
];
|
|
$action = $this->BankMasuk->update('piutang_dagang', $update, 'ID_PDA', $id_pda);
|
|
$hutang = $this->BankMasuk->getDataPDA($id_dpda);
|
|
$id_pelanggan = $hutang[0]['ID_PELANGGAN'];
|
|
$hutang_pelanggan = $hutang[0]['HUTANG_PELANGGAN']-$nominal_pda;
|
|
$update = [
|
|
'HUTANG_PELANGGAN' => $hutang_pelanggan
|
|
];
|
|
$action = $this->BankMasuk->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->BankMasuk->getDPDAID($id);
|
|
$id_dpda = $id_dpda[0]['DPDA_ID'];
|
|
$pda = $this->BankMasuk->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->BankMasuk->update('piutang_dagang', $update, 'ID_PDA', $id_pda);
|
|
$hutang = $hutang_pelanggan+$debit_dpda;
|
|
$update = [
|
|
'HUTANG_PELANGGAN' => $hutang
|
|
];
|
|
$action = $this->BankMasuk->update('pelanggan', $update, 'ID_PELANGGAN', $id_pelanggan);
|
|
$update = [
|
|
'DPDA_ID' => NULL
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->BankMasuk->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->BankMasuk->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_kbbm = $this->input->post('id_kbbm');
|
|
$id_bp = $this->input->post('id_bp');
|
|
$kode_dbp = $this->kodeDetailBP();
|
|
|
|
if ($id_bp==="") {
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
$kbbm = $this->BankMasuk->getDataKBBM($id_kbbm);
|
|
$debit_dbp = $kbbm[0]['NOMINAL_KBBM'];
|
|
$bukti_debit = $kbbm[0]['KODE_KBBM'];
|
|
$input = [
|
|
'KODE_DBP' => $kode_dbp,
|
|
'BUKTI_DEBIT' => $bukti_debit,
|
|
'BP_ID' => $id_bp,
|
|
'DEBIT_DBP' => $debit_dbp,
|
|
];
|
|
$action = $this->BankMasuk->create('detail_bp', $input);
|
|
$id_dbp = $this->BankMasuk->getIDDBP();
|
|
$id_dbp = $id_dbp[0]['ID_DBP'];
|
|
$update = [
|
|
'DBP_ID' => $id_dbp
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM',$id_kbbm);
|
|
$blockdeb = $this->BankMasuk->getBlockdebBP($id_bp);
|
|
$blockdeb = $blockdeb[0]['BLOCKDEB_BP']+$debit_dbp;
|
|
$update = [
|
|
'BLOCKDEB_BP' => $blockdeb
|
|
];
|
|
$action = $this->BankMasuk->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->BankMasuk->getDBPID($id);
|
|
$id_dbp = $id_dbp[0]['DBP_ID'];
|
|
$bp = $this->BankMasuk->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->BankMasuk->update('biaya_pengiriman', $update, 'ID_BP', $id_bp);
|
|
$update = [
|
|
'DBP_ID' => NULL
|
|
];
|
|
$action = $this->BankMasuk->update('kasbank_bm', $update, 'ID_KBBM', $id);
|
|
|
|
//Step Hapus Data
|
|
$action = $this->BankMasuk->delete('detail_bp',$id_dbp,'ID_DBP');
|
|
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
|
|
}
|