87 lines
1.8 KiB
PHP
87 lines
1.8 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class ManageRam extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelRam', '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()
|
|
{
|
|
|
|
$datRam = $this->MR->getDataRam();
|
|
|
|
$data = [
|
|
'sidebar' => "master data",
|
|
'navChild' => "",
|
|
'ram' => $datRam
|
|
];
|
|
|
|
$this->load->view('master/Ram', $data);
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_ram = $this->input->post('id');
|
|
$nama_ram = $this->input->post('nama_ram');
|
|
|
|
$input = [
|
|
'NAMA_RAM' => $nama_ram
|
|
];
|
|
|
|
$action = $this->MR->create('ram', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'ditambah');
|
|
redirect('ManageRam');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'ditambah');
|
|
redirect('ManageRam');
|
|
}
|
|
|
|
}
|
|
|
|
public function edit()
|
|
{
|
|
$method = $this->input->post('method');
|
|
$id_ram = $this->input->post('id_ram');
|
|
$nama_ram = $this->input->post('nama_ramed');
|
|
|
|
$update = [
|
|
'NAMA_RAM' => $nama_ram
|
|
];
|
|
|
|
$action = $this->MR->update('ram', $update,'ID_RAM',$id_ram);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('flash', 'diedit');
|
|
redirect('ManageRam');
|
|
} else {
|
|
$this->session->set_flashdata('flashgagal', 'diedit');
|
|
redirect('ManageRam');
|
|
}
|
|
|
|
}
|
|
|
|
public function hapus()
|
|
{
|
|
$id = $this->input->post('id');
|
|
if ($this->MR->delete('ram', $id, 'ID_RAM')) {
|
|
$action = $this ->MR->delete('ram',$id,'ID_RAM');
|
|
$this->session->set_flashdata('flash', 'dihapus');
|
|
redirect('ManageRam');
|
|
}
|
|
}
|
|
|
|
}
|