copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,193 @@
|
||||
<?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 ManageAccounting extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelAccounting', 'MA');
|
||||
$this->load->model('ModelBank', 'MBa');
|
||||
$this->load->model('ModelBiaya', 'MBi');
|
||||
$this->load->model('ModelHutang', 'MH');
|
||||
$this->load->model('ModelKas', 'MK');
|
||||
$this->load->model('ModelKasbank', 'MKB');
|
||||
$this->load->model('ModelPiutang', 'MP');
|
||||
$this->load->model('ModalTransaksi', 'MT');
|
||||
$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()
|
||||
{
|
||||
|
||||
$datPembelian = $this->MP->getDataPembelianHarga();
|
||||
$datSupplier = $this->MS->getDataSupplier();
|
||||
|
||||
$data = [
|
||||
'sidebar' => "menu pembelian",
|
||||
'navChild' => "",
|
||||
'pembelian' => $datPembelian,
|
||||
'supplier' => $datSupplier
|
||||
];
|
||||
|
||||
$this->load->view('proses/PembelianINV', $data);
|
||||
}
|
||||
|
||||
public function tambahHarga($id)
|
||||
{
|
||||
$stock = $this->MP->getPembelianHarga($id);
|
||||
$title = $this->MP->getSJPembelian($id);
|
||||
$barang = $this->MB->getDataBarangPembelian();
|
||||
$gudang = $this->MG->getDataGudangPembelian();
|
||||
|
||||
$data = [
|
||||
'sidebar' => "menu pembelian",
|
||||
'navChild' => "",
|
||||
'stock' => $stock,
|
||||
'id_pembelian' => $id,
|
||||
'sj_pembelian' => $title[0]['SJ_PEMBELIAN'],
|
||||
'barang' => $barang,
|
||||
'gudang' => $gudang
|
||||
];
|
||||
|
||||
$this->load->view('proses/PembelianHarga', $data);
|
||||
}
|
||||
|
||||
public function saveharga()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_pembelian = $this->input->post('id_pembelian');
|
||||
$id_stock = $this->input->post('id_stock');
|
||||
$qty = $this->input->post('qty');
|
||||
$radio_beli = $this->input->post('radio_beli');
|
||||
$radio_ppn = $this->input->post('radio_ppn');
|
||||
$invoice_pembelian = $this->input->post('invoice_pembelian');
|
||||
$tgl_invoicebeli = $this->input->post('tgl_invoicebeli');
|
||||
$dpp_satuan = $this->input->post('dpp_satuan');
|
||||
$dpp_total = $dpp_satuan*$qty;
|
||||
|
||||
$inputharga = [
|
||||
'DPP_BELI_SATUAN' => $dpp_satuan,
|
||||
'DPP_BELI_TOTAL' => $dpp_total,
|
||||
'STATUS_PPN' => $radio_ppn,
|
||||
'STATUS_BELI' => $radio_beli,
|
||||
'STOCK_ID' => $id_stock
|
||||
];
|
||||
|
||||
$actionharga = $this->MP->create('harga', $inputharga);
|
||||
|
||||
$harga_id = $this->MP->getStockHargaID();
|
||||
$updatestock = [
|
||||
'HARGA_ID' => $harga_id[0]['ID_HARGA']
|
||||
];
|
||||
$updatepembelian = [
|
||||
'INVOICE_PEMBELIAN' => $invoice_pembelian,
|
||||
'TGL_INVOICEBELI' => $tgl_invoicebeli
|
||||
];
|
||||
$actionstock = $this->MP->update('stock', $updatestock, 'ID_STOCK', $id_stock);
|
||||
$actionpembelian = $this->MP->update('pembelian', $updatepembelian, 'ID_PEMBELIAN', $id_pembelian);
|
||||
|
||||
if ($actionstock) {
|
||||
$this->session->set_flashdata('flash', 'ditambah');
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'ditambah');
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function editharga()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_pembelian = $this->input->post('id_pembelian');
|
||||
$id_stock = $this->input->post('id_stock');
|
||||
$id_harga = $this->input->post('id_harga');
|
||||
$qty = $this->input->post('qty');
|
||||
$radio_beli = $this->input->post('radio_belied');
|
||||
$radio_ppn = $this->input->post('radio_ppned');
|
||||
$invoice_pembelian = $this->input->post('invoice_pembelianed');
|
||||
$tgl_invoicebeli = $this->input->post('tgl_invoicebelied');
|
||||
$dpp_satuan = $this->input->post('dpp_satuaned');
|
||||
$dpp_total = $dpp_satuan*$qty;
|
||||
|
||||
$updateharga = [
|
||||
'DPP_BELI_SATUAN' => $dpp_satuan,
|
||||
'DPP_BELI_TOTAL' => $dpp_total,
|
||||
'STATUS_PPN' => $radio_ppn,
|
||||
'STATUS_BELI' => $radio_beli,
|
||||
'STOCK_ID' => $id_stock
|
||||
];
|
||||
|
||||
$updatepembelian = [
|
||||
'INVOICE_PEMBELIAN' => $invoice_pembelian,
|
||||
'TGL_INVOICEBELI' => $tgl_invoicebeli
|
||||
];
|
||||
|
||||
$actionharga = $this->MP->update('harga', $updateharga, 'ID_HARGA', $id_harga);
|
||||
$actionpembelian = $this->MP->update('pembelian', $updatepembelian, 'ID_PEMBELIAN', $id_pembelian);
|
||||
|
||||
if ($actionpembelian) {
|
||||
$this->session->set_flashdata('flash', 'diedit');
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'diedit');
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function konfirmasi()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_pembelian = $this->input->post('id_pembelian');
|
||||
|
||||
$update = [
|
||||
'STATUS_PEMBELIAN' => "INVOICE PEMBELIAN OK"
|
||||
];
|
||||
|
||||
$action = $this->MP->update('pembelian', $update, 'ID_PEMBELIAN', $id_pembelian);
|
||||
|
||||
$datTransaksi = $this->MP->createTransaksi($id_pembelian);
|
||||
$datHargaTotal = $this->MP->getHargaTotal($id_pembelian);
|
||||
$data1 = $datTransaksi[0]['INVOICE_PEMBELIAN'];
|
||||
$data2 = $datTransaksi[0]['TGL_INVOICEBELI'];
|
||||
$data3 = "Hutang";
|
||||
|
||||
if ($datTransaksi[0]['STATUS_PPN']==='Include') {
|
||||
$data4 = $datHargaTotal[0]['DPP_BELI_TOTAL'];
|
||||
} else if ($datTransaksi[0]['STATUS_PPN']==='Exclude') {
|
||||
$data4 = $datHargaTotal[0]['DPP_BELI_TOTAL']*1.1;
|
||||
}
|
||||
|
||||
$inputTransaksi = [
|
||||
'DOKUMEN_TRANSAKSI' => $data1,
|
||||
'TGL_TRANSAKSI' => $data2,
|
||||
'JENIS_TRANSAKSI' => $data3,
|
||||
'NILAI_TRANSAKSI' => $data4,
|
||||
|
||||
];
|
||||
|
||||
$actiontransaksi = $this->MP->create('transaksi', $inputTransaksi);
|
||||
|
||||
if ($actiontransaksi) {
|
||||
$this->session->set_flashdata('flash', 'dikonfirmasi');
|
||||
redirect('ManagePembelianINV');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'dikonfirmasi');
|
||||
redirect('ManagePembelianINV');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user