copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManageHarga extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelHarga', 'MHarga');
|
||||
$this->load->model('ModelSku', 'MSku');
|
||||
$this->load->model('ModelBarang', 'MBarang');
|
||||
$this->load->model('ModelDistributor', 'MDistributor');
|
||||
$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("Login");
|
||||
} elseif ($jabatan != "ADMIN") {
|
||||
redirect("Login");
|
||||
}
|
||||
|
||||
$datHarga = $this->MHarga->getDataHarga();
|
||||
|
||||
$data = [
|
||||
'sidebar' => "data master",
|
||||
'navChild' => "data harga",
|
||||
'harga' => $datHarga
|
||||
];
|
||||
|
||||
$this->load->view('harga/table-harga', $data);
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$username = $this->session->userdata('username');
|
||||
if ($username == null) {
|
||||
redirect("Login");
|
||||
}
|
||||
$datSku = $this->MSku->getDataSku();
|
||||
$datHarga = $this->MHarga->getDataHarga();
|
||||
$data = [
|
||||
'sidebar' => "data master",
|
||||
'navChild' => "data harga",
|
||||
'sku' => $datSku,
|
||||
'harga' => $datHarga
|
||||
|
||||
];
|
||||
|
||||
$this->load->view('harga/harga-tambah', $data);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$po = $this->input->post('NO_PO');
|
||||
$hpp = $this->input->post('hpp');
|
||||
|
||||
$this->form_validation->set_rules('NO_PO', 'Pilih Nomor PO', 'required');
|
||||
$this->form_validation->set_rules('hpp', 'Harga', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$data = [
|
||||
'status' => false,
|
||||
'errors' => [
|
||||
'NO_PO' => form_error('NO_PO'),
|
||||
'hpp' => form_error('hpp')
|
||||
]
|
||||
];
|
||||
$this->output_json($data);
|
||||
} else {
|
||||
$input = [
|
||||
'ID_SKU' => $po,
|
||||
'HPP' => $hpp
|
||||
];
|
||||
|
||||
$action = $this->MHarga->create('harga', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'ditambah');
|
||||
//$this->output_json(['status' => true]);
|
||||
redirect('ManageHarga');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'ditambah');
|
||||
//$this->output_json(['status' => true]);
|
||||
redirect('ManageHarga');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hapus()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
if ($this->MHarga->delete('harga', $id, 'ID_HARGA')) {
|
||||
$this->session->set_flashdata('flash', 'dihapus');
|
||||
redirect('ManageHarga');
|
||||
}
|
||||
}
|
||||
|
||||
public function cek_pass($id, $pass = null)
|
||||
{
|
||||
if ($pass == null) {
|
||||
$this->output_json(['cek' => 'ksng']);
|
||||
} else {
|
||||
$dat = $this->KaryawanM->cekPass($id, $pass);
|
||||
|
||||
if ($dat != null) {
|
||||
$this->output_json(['cek' => 'benar']);
|
||||
} else {
|
||||
$this->output_json(['cek' => 'salah']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user