123 lines
3.2 KiB
PHP
123 lines
3.2 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageConfigSRV 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->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();
|
|
$datType = $this->MType->getDataType();
|
|
$datProcessor = $this->MProcessor->getDataProcessor();
|
|
$datRam = $this->MRam->getDataRam();
|
|
$datHarddisk = $this->MHarddisk->getDataHarddisk();
|
|
|
|
$data = [
|
|
'sidebar' => "data master",
|
|
'navChild' => "data config srv",
|
|
'sn' => $datSn,
|
|
'type' => $datType,
|
|
'processor' => $datProcessor,
|
|
'ram' => $datRam,
|
|
'harddisk' => $datHarddisk
|
|
];
|
|
|
|
$this->load->view('config/table-server', $data);
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$username = $this->session->userdata('username');
|
|
if ($username == null) {
|
|
redirect("Login");
|
|
}
|
|
$datSn = $this->MSn->getDataSn();
|
|
$datType = $this->MType->getDataType();
|
|
$datProcessor = $this->MProcessor->getDataProcessor();
|
|
$datRam = $this->MRam->getDataRam();
|
|
$datHarddisk = $this->MHarddisk->getDataHarddisk();
|
|
$data = [
|
|
'sidebar' => "data master",
|
|
'navChild' => "data config srv",
|
|
'sn' => $datSn,
|
|
'type' => $datType,
|
|
'processor' => $datProcessor,
|
|
'ram' => $datRam,
|
|
'harddisk' => $datHarddisk
|
|
|
|
];
|
|
$this->load->view('config/server-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');
|
|
}
|
|
}
|
|
|
|
}
|