copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManageConfigNB extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelSn', 'MSn');
|
||||
$this->load->model('ModelType', 'MType');
|
||||
$this->load->model('ModelProcessor', 'MProcessor');
|
||||
$this->load->model('ModelRam', 'MRam');
|
||||
$this->load->model('ModelHarddisk', 'MHarddisk');
|
||||
$this->load->model('ModelSsd', 'MSsd');
|
||||
$this->load->model('ModelVga', 'MVga');
|
||||
$this->load->model('ModelOs', 'MOs');
|
||||
$this->load->model('ModelDvd', 'MDvd');
|
||||
$this->load->model('ModelWarna', 'MWarna');
|
||||
$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");
|
||||
}
|
||||
|
||||
$datSn = $this->MSn->getDataSn();
|
||||
|
||||
$data = [
|
||||
'sidebar' => "data master",
|
||||
'navChild' => "data sn",
|
||||
'sn' => $datSn
|
||||
];
|
||||
|
||||
$this->load->view('sn/table-sn', $data);
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$username = $this->session->userdata('username');
|
||||
if ($username == null) {
|
||||
redirect("Login");
|
||||
}
|
||||
$datSn = $this->MSn->getDataSn();
|
||||
$datInvoice = $this->MInvoice->getDataInvoice();
|
||||
$datSGudang = $this->MSGudang->getDataSGudang();
|
||||
$datSPenjualan = $this->MSPenjualan->getDataSPenjualan();
|
||||
$data = [
|
||||
'sidebar' => "data master",
|
||||
'navChild' => "data sn",
|
||||
'sn' => $datSn,
|
||||
'invoice' => $datInvoice,
|
||||
'sgudang' => $datSGudang,
|
||||
'spenjualan' => $datSPenjualan
|
||||
|
||||
];
|
||||
$this->load->view('sn/sn-tambah', $data);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$no_sn = $this->input->post('no_sn');
|
||||
$no_invoice = $this->input->post('no_invoice');
|
||||
|
||||
$this->form_validation->set_rules('no_sn', 'Nomor SN', 'required');
|
||||
$this->form_validation->set_rules('no_invoice', 'Nomor Invoice', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$data = [
|
||||
'status' => false,
|
||||
'errors' => [
|
||||
'no_sn' => form_error('no_sn'),
|
||||
'no_invoice' => form_error('no_invoice')
|
||||
]
|
||||
];
|
||||
$this->output_json($data);
|
||||
} else {
|
||||
$input = [
|
||||
'NO_SN' => $no_sn,
|
||||
'ID_INVOICE' => $no_invoice,
|
||||
'ID_STATUSGUDANG' => '1',
|
||||
'ID_STATUSPENJUALAN' => '1'
|
||||
];
|
||||
|
||||
$action = $this->MSn->create('sn', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'ditambah');
|
||||
redirect('ManageSn');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'ditambah');
|
||||
redirect('ManageSn');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hapus()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
if ($this->MSn->delete('sn', $id, 'ID_SN')) {
|
||||
$this->session->set_flashdata('flash', 'dihapus');
|
||||
redirect('ManageSn');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user