87 lines
1.9 KiB
PHP
87 lines
1.9 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageGroup extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelGroup', '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()
|
|
{
|
|
|
|
$datGroup = $this->MG->getDataGroup();
|
|
|
|
$data = [
|
|
'sidebar' => "master data",
|
|
'navChild' => "",
|
|
'group' => $datGroup
|
|
];
|
|
|
|
$this->load->view('master/Group', $data);
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_group = $this->input->post('id');
|
|
$nama_group = $this->input->post('nama_group');
|
|
|
|
$input = [
|
|
'NAMA_GROUP' => $nama_group
|
|
];
|
|
|
|
$action = $this->MG->create('group', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageGroup');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageGroup');
|
|
}
|
|
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_group = $this->input->post('id_group');
|
|
$nama_group = $this->input->post('nama_grouped');
|
|
|
|
$update = [
|
|
'NAMA_GROUP' => $nama_group
|
|
];
|
|
|
|
$action = $this->MG->update('group', $update,'ID_GROUP',$id_group);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diedit');
|
|
redirect('ManageGroup');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diedit');
|
|
redirect('ManageGroup');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus()
|
|
{
|
|
$id = $this->input->post('id');
|
|
if ($this->MG->delete('group', $id, 'ID_GROUP')) {
|
|
$action = $this ->MG->delete('group',$id,'ID_GROUP');
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect('ManageGroup');
|
|
}
|
|
}
|
|
|
|
}
|