copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManageAgen extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelAgen', 'Agen');
|
||||
$this->load->model('ModelDashboard', 'Dashboard');
|
||||
$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(){
|
||||
$datAgen = $this->Agen->getDataAgen();
|
||||
$data = [
|
||||
'sidebar' => "master data",
|
||||
'navChild' => "data master agen",
|
||||
'agen' => $datAgen
|
||||
];
|
||||
$this->load->view('master/Agen', $data);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_agen = $this->input->post('id');
|
||||
$nama_agen = $this->input->post('nama_agen');
|
||||
|
||||
$date = date('Y-m-d H:i:s');
|
||||
$input = [
|
||||
'NAMA_AGEN' => $nama_agen
|
||||
];
|
||||
|
||||
$action = $this->Agen->create('agen', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'ditambah');
|
||||
redirect('ManageAgen');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'ditambah');
|
||||
redirect('ManageAgen');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_agen = $this->input->post('id_agen');
|
||||
$nama_agen = $this->input->post('nama_agened');
|
||||
|
||||
$update = [
|
||||
'NAMA_AGEN' => $nama_agen
|
||||
];
|
||||
|
||||
$action = $this->Agen->update('agen', $update,'ID_AGEN',$id_agen);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('success', 'diubah');
|
||||
redirect('ManageAgen');
|
||||
} else {
|
||||
$this->session->set_flashdata('failed', 'diubah');
|
||||
redirect('ManageAgen');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
if ($this->Agen->delete('agen', $id, 'ID_AGEN')) {
|
||||
$action = $this ->Agen->delete('agen',$id,'ID_AGEN');
|
||||
$this->session->set_flashdata('success', 'dihapus');
|
||||
redirect('ManageAgen');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user