87 lines
1.9 KiB
PHP
87 lines
1.9 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageGrup extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelGrup', 'MG');
|
|
$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()
|
|
{
|
|
|
|
$datGrup = $this->MG->getDataGrup();
|
|
|
|
$data = [
|
|
'sidebar' => "master data",
|
|
'navChild' => "",
|
|
'grup' => $datGrup
|
|
];
|
|
|
|
$this->load->view('master/Grup', $data);
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_grup = $this->input->post('id');
|
|
$nama_grup = $this->input->post('nama_grup');
|
|
|
|
$input = [
|
|
'NAMA_GRUP' => $nama_grup
|
|
];
|
|
|
|
$action = $this->MG->create('grup', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageGrup');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageGrup');
|
|
}
|
|
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_grup = $this->input->post('id_grup');
|
|
$nama_grup = $this->input->post('nama_gruped');
|
|
|
|
$update = [
|
|
'NAMA_GRUP' => $nama_grup
|
|
];
|
|
|
|
$action = $this->MG->update('grup', $update,'ID_GRUP',$id_grup);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diedit');
|
|
redirect('ManageGrup');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diedit');
|
|
redirect('ManageGrup');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus()
|
|
{
|
|
$id = $this->input->post('id');
|
|
if ($this->MG->delete('grup', $id, 'ID_GRUP')) {
|
|
$action = $this ->MG->delete('grup',$id,'ID_GRUP');
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect('ManageGrup');
|
|
}
|
|
}
|
|
|
|
}
|