copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManageWarna extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelWarna', 'MW');
|
||||
$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()
|
||||
{
|
||||
|
||||
$datWarna = $this->MW->getDataWarna();
|
||||
|
||||
$data = [
|
||||
'sidebar' => "master data",
|
||||
'navChild' => "",
|
||||
'warna' => $datWarna
|
||||
];
|
||||
|
||||
$this->load->view('master/Warna', $data);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_warna = $this->input->post('id');
|
||||
$nama_warna = $this->input->post('nama_warna');
|
||||
|
||||
$input = [
|
||||
'NAMA_WARNA' => $nama_warna
|
||||
];
|
||||
|
||||
$action = $this->MW->create('warna', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'ditambah');
|
||||
redirect('ManageWarna');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'ditambah');
|
||||
redirect('ManageWarna');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_warna = $this->input->post('id_warna');
|
||||
$nama_warna = $this->input->post('nama_warnaed');
|
||||
|
||||
$update = [
|
||||
'NAMA_WARNA' => $nama_warna
|
||||
];
|
||||
|
||||
$action = $this->MW->update('warna', $update,'ID_WARNA',$id_warna);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'diedit');
|
||||
redirect('ManageWarna');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'diedit');
|
||||
redirect('ManageWarna');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
if ($this->MW->delete('warna', $id, 'ID_WARNA')) {
|
||||
$action = $this ->MW->delete('warna',$id,'ID_WARNA');
|
||||
$this->session->set_flashdata('flash', 'dihapus');
|
||||
redirect('ManageWarna');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user