load->model('ModelHdd', 'MH'); $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() { $datHdd = $this->MH->getDataHdd(); $data = [ 'sidebar' => "master data", 'navChild' => "", 'hdd' => $datHdd ]; $this->load->view('master/Hdd', $data); } public function save() { $method = $this->input->post('method'); $id_hdd = $this->input->post('id'); $nama_hdd = $this->input->post('nama_hdd'); $input = [ 'NAMA_HDD' => $nama_hdd ]; $action = $this->MH->create('hdd', $input); if ($action) { $this->session->set_flashdata('flash', 'ditambah'); redirect('ManageHdd'); } else { $this->session->set_flashdata('flashgagal', 'ditambah'); redirect('ManageHdd'); } } public function edit() { $method = $this->input->post('method'); $id_hdd = $this->input->post('id_hdd'); $nama_hdd = $this->input->post('nama_hdded'); $update = [ 'NAMA_HDD' => $nama_hdd ]; $action = $this->MH->update('hdd', $update,'ID_HDD',$id_hdd); if ($action) { $this->session->set_flashdata('flash', 'diedit'); redirect('ManageHdd'); } else { $this->session->set_flashdata('flashgagal', 'diedit'); redirect('ManageHdd'); } } public function hapus() { $id = $this->input->post('id'); if ($this->MH->delete('hdd', $id, 'ID_HDD')) { $action = $this ->MH->delete('hdd',$id,'ID_HDD'); $this->session->set_flashdata('flash', 'dihapus'); redirect('ManageHdd'); } } }