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 ManageDvd extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelDvd', 'MD');
|
||||
$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()
|
||||
{
|
||||
|
||||
$datDvd = $this->MD->getDataDvd();
|
||||
|
||||
$data = [
|
||||
'sidebar' => "master data",
|
||||
'navChild' => "",
|
||||
'dvd' => $datDvd
|
||||
];
|
||||
|
||||
$this->load->view('master/Dvd', $data);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_dvd = $this->input->post('id');
|
||||
$nama_dvd = $this->input->post('nama_dvd');
|
||||
$type_dvd = $this->input->post('type_dvd');
|
||||
|
||||
$input = [
|
||||
'NAMA_DVD' => $nama_dvd,
|
||||
'TYPE_DVD' => $type_dvd
|
||||
];
|
||||
|
||||
$action = $this->MD->create('dvd', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'ditambah');
|
||||
redirect('ManageDvd');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'ditambah');
|
||||
redirect('ManageDvd');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_dvd = $this->input->post('id_dvd');
|
||||
$nama_dvd = $this->input->post('nama_dvded');
|
||||
$type_dvd = $this->input->post('type_dvded');
|
||||
|
||||
$update = [
|
||||
'NAMA_DVD' => $nama_dvd,
|
||||
'TYPE_DVD' => $type_dvd
|
||||
];
|
||||
|
||||
$action = $this->MD->update('dvd', $update,'ID_DVD',$id_dvd);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'diedit');
|
||||
redirect('ManageDvd');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'diedit');
|
||||
redirect('ManageDvd');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
if ($this->MD->delete('dvd', $id, 'ID_DVD')) {
|
||||
$action = $this ->MD->delete('dvd',$id,'ID_DVD');
|
||||
$this->session->set_flashdata('flash', 'dihapus');
|
||||
redirect('ManageDvd');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user