Files
shopee-apps/application/delete/controllers/ManageLayar.php
T
2026-06-13 16:02:07 +10:00

95 lines
2.2 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ManageLayar extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('ModelLayar', 'ML');
$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()
{
$datLayar = $this->ML->getDataLayar();
$data = [
'sidebar' => "master data",
'navChild' => "",
'layar' => $datLayar
];
$this->load->view('master/Layar', $data);
}
public function save()
{
$method = $this->input->post('method');
$id_layar = $this->input->post('id');
$nama_layar = $this->input->post('nama_layar');
$type_layar = $this->input->post('type_layar');
$touch_ready = $this->input->post('touch_ready');
$input = [
'NAMA_LAYAR' => $nama_layar,
'TYPE_LAYAR' => $type_layar,
'TOUCH_READY' => $touch_ready
];
$action = $this->ML->create('layar', $input);
if ($action) {
$this->session->set_flashdata('flash', 'ditambah');
redirect('ManageLayar');
} else {
$this->session->set_flashdata('flashgagal', 'ditambah');
redirect('ManageLayar');
}
}
public function edit()
{
$method = $this->input->post('method');
$id_layar = $this->input->post('id_layar');
$nama_layar = $this->input->post('nama_layared');
$type_layar = $this->input->post('type_layared');
$touch_ready = $this->input->post('touch_ready');
$update = [
'NAMA_LAYAR' => $nama_layar,
'TYPE_LAYAR' => $type_layar,
'TOUCH_READY' => $touch_ready
];
$action = $this->ML->update('layar', $update,'ID_LAYAR',$id_layar);
if ($action) {
$this->session->set_flashdata('flash', 'diedit');
redirect('ManageLayar');
} else {
$this->session->set_flashdata('flashgagal', 'diedit');
redirect('ManageLayar');
}
}
public function hapus()
{
$id = $this->input->post('id');
if ($this->ML->delete('layar', $id, 'ID_LAYAR')) {
$action = $this ->ML->delete('layar',$id,'ID_LAYAR');
$this->session->set_flashdata('flash', 'dihapus');
redirect('ManageLayar');
}
}
}