copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class ManageTp extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ModelTp', 'MT');
|
||||
$this->load->model('ModelKota', '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()
|
||||
{
|
||||
|
||||
$datTp = $this->MT->getDataTp();
|
||||
$datKota = $this->MK->getDataKota();
|
||||
|
||||
$data = [
|
||||
'sidebar' => "master data",
|
||||
'navChild' => "",
|
||||
'tp' => $datTp,
|
||||
'kota' => $datKota
|
||||
];
|
||||
|
||||
$this->load->view('master/Tp', $data);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_tp = $this->input->post('id');
|
||||
$id_kota = $this->input->post('id_kota');
|
||||
$nama_tp = $this->input->post('nama_tp');
|
||||
$alamat_tp = $this->input->post('alamat_tp');
|
||||
$telp_tp = $this->input->post('telp_tp');
|
||||
|
||||
$input = [
|
||||
'NAMA_TP' => $nama_tp,
|
||||
'ALAMAT_TP' => $alamat_tp,
|
||||
'TELP_TP' => $telp_tp,
|
||||
'KOTA_ID' => $id_kota
|
||||
];
|
||||
|
||||
$action = $this->MT->create('tp', $input);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'ditambah');
|
||||
redirect('ManageTp');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'ditambah');
|
||||
redirect('ManageTp');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$method = $this->input->post('method');
|
||||
$id_tp = $this->input->post('id_tp');
|
||||
$id_kota = $this->input->post('id_kotaed');
|
||||
$nama_tp = $this->input->post('nama_tped');
|
||||
$alamat_tp = $this->input->post('alamat_tped');
|
||||
$telp_tp = $this->input->post('telp_tped');
|
||||
|
||||
$update = [
|
||||
'NAMA_TP' => $nama_tp,
|
||||
'ALAMAT_TP' => $alamat_tp,
|
||||
'TELP_TP' => $telp_tp,
|
||||
'KOTA_ID' => $id_kota
|
||||
];
|
||||
|
||||
$action = $this->MT->update('tp', $update,'ID_TP',$id_tp);
|
||||
|
||||
if ($action) {
|
||||
$this->session->set_flashdata('flash', 'diedit');
|
||||
redirect('ManageTp');
|
||||
} else {
|
||||
$this->session->set_flashdata('flashgagal', 'diedit');
|
||||
redirect('ManageTp');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function hapus()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
if ($this->MT->delete('tp', $id, 'ID_TP')) {
|
||||
$action = $this ->MT->delete('tp',$id,'ID_TP');
|
||||
$this->session->set_flashdata('flash', 'dihapus');
|
||||
redirect('ManageTp');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user