87 lines
1.9 KiB
PHP
87 lines
1.9 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageRaid extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelRaid', 'MR');
|
|
$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()
|
|
{
|
|
|
|
$datRaid = $this->MR->getDataRaid();
|
|
|
|
$data = [
|
|
'sidebar' => "master data",
|
|
'navChild' => "",
|
|
'raid' => $datRaid
|
|
];
|
|
|
|
$this->load->view('master/Raid', $data);
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_raid = $this->input->post('id');
|
|
$nama_raid = $this->input->post('nama_raid');
|
|
|
|
$input = [
|
|
'NAMA_RAID' => $nama_raid
|
|
];
|
|
|
|
$action = $this->MR->create('raid', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageRaid');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageRaid');
|
|
}
|
|
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_raid = $this->input->post('id_raid');
|
|
$nama_raid = $this->input->post('nama_raided');
|
|
|
|
$update = [
|
|
'NAMA_RAID' => $nama_raid
|
|
];
|
|
|
|
$action = $this->MR->update('raid', $update,'ID_RAID',$id_raid);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diedit');
|
|
redirect('ManageRaid');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diedit');
|
|
redirect('ManageRaid');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus()
|
|
{
|
|
$id = $this->input->post('id');
|
|
if ($this->MR->delete('raid', $id, 'ID_RAID')) {
|
|
$action = $this ->MR->delete('raid',$id,'ID_RAID');
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect('ManageRaid');
|
|
}
|
|
}
|
|
|
|
}
|