87 lines
2.0 KiB
PHP
87 lines
2.0 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageProcessor extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelProcessor', 'MP');
|
|
$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()
|
|
{
|
|
|
|
$datProcessor = $this->MP->getDataProcessor();
|
|
|
|
$data = [
|
|
'sidebar' => "master data",
|
|
'navChild' => "",
|
|
'processor' => $datProcessor
|
|
];
|
|
|
|
$this->load->view('master/Processor', $data);
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_processor = $this->input->post('id');
|
|
$nama_processor = $this->input->post('nama_processor');
|
|
|
|
$input = [
|
|
'NAMA_PROCESSOR' => $nama_processor
|
|
];
|
|
|
|
$action = $this->MP->create('processor', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageProcessor');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageProcessor');
|
|
}
|
|
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_processor = $this->input->post('id_processor');
|
|
$nama_processor = $this->input->post('nama_processored');
|
|
|
|
$update = [
|
|
'NAMA_PROCESSOR' => $nama_processor
|
|
];
|
|
|
|
$action = $this->MP->update('processor', $update,'ID_PROCESSOR',$id_processor);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diedit');
|
|
redirect('ManageProcessor');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diedit');
|
|
redirect('ManageProcessor');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus()
|
|
{
|
|
$id = $this->input->post('id');
|
|
if ($this->MP->delete('processor', $id, 'ID_PROCESSOR')) {
|
|
$action = $this ->MP->delete('processor',$id,'ID_PROCESSOR');
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect('ManageProcessor');
|
|
}
|
|
}
|
|
|
|
}
|