87 lines
1.9 KiB
PHP
87 lines
1.9 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageLain extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelLain', 'Lain');
|
|
$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()
|
|
{
|
|
|
|
$datLain = $this->Lain->getDataLain();
|
|
|
|
$data = [
|
|
'sidebar' => "master data",
|
|
'navChild' => "",
|
|
'lain' => $datLain
|
|
];
|
|
|
|
$this->load->view('master/Lain', $data);
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_lain = $this->input->post('id');
|
|
$nama_lain = $this->input->post('nama_lain');
|
|
|
|
$input = [
|
|
'NAMA_LAIN' => $nama_lain
|
|
];
|
|
|
|
$action = $this->Lain->create('lain', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageLain');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageLain');
|
|
}
|
|
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_lain = $this->input->post('id_lain');
|
|
$nama_lain = $this->input->post('nama_lained');
|
|
|
|
$update = [
|
|
'NAMA_LAIN' => $nama_lain
|
|
];
|
|
|
|
$action = $this->Lain->update('lain', $update,'ID_LAIN',$id_lain);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diedit');
|
|
redirect('ManageLain');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diedit');
|
|
redirect('ManageLain');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus()
|
|
{
|
|
$id = $this->input->post('id');
|
|
if ($this->Lain->delete('lain', $id, 'ID_LAIN')) {
|
|
$action = $this ->Lain->delete('lain',$id,'ID_LAIN');
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect('ManageLain');
|
|
}
|
|
}
|
|
|
|
}
|