97 lines
2.4 KiB
PHP
97 lines
2.4 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageHargaBeli extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelHargaBeli', 'MHBeli');
|
|
$this->load->model('ModelBeli', 'MBeli');
|
|
$this->load->model('ModelSupplier', 'MSupplier');
|
|
$this->load->model('ModelBarang', 'MBarang');
|
|
$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()
|
|
{
|
|
$username = $this->session->userdata('username');
|
|
$jabatan = $this->session->userdata('jabatan');
|
|
if ($username == null) {
|
|
redirect("Action");
|
|
} elseif ($jabatan != "ADMIN") {
|
|
redirect("Action");
|
|
}
|
|
|
|
$datHBeli = $this->MHBeli->getDataHargaBeli();
|
|
|
|
$data = [
|
|
'sidebar' => "data proses pembelian",
|
|
'navChild' => "data proses hargabeli",
|
|
'hargabeli' => $datHBeli
|
|
];
|
|
|
|
$this->load->view('master/HargaBeli', $data);
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$username = $this->session->userdata('username');
|
|
if ($username == null) {
|
|
redirect("Login");
|
|
}
|
|
$datBeli = $this->MBeli->getDataBeliID();
|
|
$data = [
|
|
'sidebar' => "data proses pembelian",
|
|
'navChild' => "data proses hargabeli",
|
|
'beli' => $datBeli
|
|
];
|
|
$this->load->view('proses/TambahHargaBeli', $data);
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_beli = $this->input->post('id');
|
|
$beli = $this->input->post('BELI');
|
|
$harga_beli = $this->input->post('harga_beli');
|
|
|
|
$datID = $this->MBeli->getDataBeliID($beli);
|
|
|
|
$input = [
|
|
'HARGA_BELI' => $harga_beli
|
|
];
|
|
|
|
if (is_array($datID)||is_object($$datID)) {
|
|
$input = [
|
|
'HARGA_BELI' => $harga_beli
|
|
];
|
|
$action = $this->MBeli->update('beli', $input, 'ID_BELI',$datID[0]['ID_BELI']);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageHargaBeli');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageHargaBeli');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus()
|
|
{
|
|
$id = $this->input->post('id');
|
|
if ($this->MBeli->delete('beli', $id, 'ID_BELI')) {
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect('ManageHargaBeli');
|
|
}
|
|
}
|
|
|
|
}
|