copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManageKm extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelKm', 'MK');
|
||||
$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()
|
||||
{
|
||||
|
||||
$datKm = $this->MK->getDataKm();
|
||||
|
||||
$data = [
|
||||
'sidebar' => "master data",
|
||||
'navChild' => "",
|
||||
'km' => $datKm
|
||||
];
|
||||
|
||||
$this->load->view('master/Km', $data);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_km = $this->input->post('id');
|
||||
$nama_km = $this->input->post('nama_km');
|
||||
$type_km = $this->input->post('type_km');
|
||||
|
||||
$input = [
|
||||
'NAMA_KM' => $nama_km,
|
||||
'TYPE_KM' => $type_km
|
||||
];
|
||||
|
||||
$action = $this->MK->create('km', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'ditambah');
|
||||
redirect('ManageKm');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'ditambah');
|
||||
redirect('ManageKm');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_km = $this->input->post('id_km');
|
||||
$nama_km = $this->input->post('nama_kmed');
|
||||
$type_km = $this->input->post('type_kmed');
|
||||
|
||||
$update = [
|
||||
'NAMA_KM' => $nama_km,
|
||||
'TYPE_KM' => $type_km
|
||||
];
|
||||
|
||||
$action = $this->MK->update('km', $update,'ID_KM',$id_km);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'diedit');
|
||||
redirect('ManageKm');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'diedit');
|
||||
redirect('ManageKm');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
if ($this->MK->delete('km', $id, 'ID_KM')) {
|
||||
$action = $this ->MK->delete('km',$id,'ID_KM');
|
||||
$this->session->set_flashdata('flash', 'dihapus');
|
||||
redirect('ManageKm');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user