170 lines
4.9 KiB
PHP
170 lines
4.9 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 KasMasuk extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelPembelian', 'MP');
|
|
$this->load->model('ModelSupplier', 'MS');
|
|
$this->load->model('ModelBarang', 'MB');
|
|
$this->load->model('ModelGudang', 'MG');
|
|
$this->load->model('ModelTransaksi', 'MT');
|
|
$this->load->model('ModelNeraca', 'MN');
|
|
$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()
|
|
{
|
|
|
|
$datTransaksi = $this->MT->getDataTransaksi();
|
|
$datNeraca = $this->MN->getDataNeraca();
|
|
|
|
$data = [
|
|
'sidebar' => "menu accounting",
|
|
'navChild' => "",
|
|
'relasi' => $datTransaksi,
|
|
'neraca' => $datNeraca
|
|
];
|
|
|
|
$this->load->view('proses/AccountingKasMasuk', $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 saverelasi()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_transaksi = $this->input->post('id_transaksi');
|
|
$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 SUDAH PROSES"
|
|
];
|
|
|
|
$action = $this->MP->update('pembelian', $update, 'ID_PEMBELIAN', $id_pembelian);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'dikonfirmasi');
|
|
redirect('ManagePembelianINV');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'dikonfirmasi');
|
|
redirect('ManagePembelianINV');
|
|
}
|
|
|
|
}
|
|
|
|
}
|