Files
2026-06-13 16:02:07 +10:00

91 lines
2.0 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ManageOs extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('ModelOs', 'MO');
$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()
{
$datOs = $this->MO->getDataOs();
$data = [
'sidebar' => "master data",
'navChild' => "",
'os' => $datOs
];
$this->load->view('master/Os', $data);
}
public function save()
{
$method = $this->input->post('method');
$id_os = $this->input->post('id');
$nama_os = $this->input->post('nama_os');
$type_os = $this->input->post('type_os');
$input = [
'NAMA_OS' => $nama_os,
'TYPE_OS' => $type_os
];
$action = $this->MO->create('os', $input);
if ($action) {
$this->session->set_flashdata('flash', 'ditambah');
redirect('ManageOs');
} else {
$this->session->set_flashdata('flashgagal', 'ditambah');
redirect('ManageOs');
}
}
public function edit()
{
$method = $this->input->post('method');
$id_os = $this->input->post('id_os');
$nama_os = $this->input->post('nama_osed');
$type_os = $this->input->post('type_osed');
$update = [
'NAMA_OS' => $nama_os,
'TYPE_OS' => $type_os
];
$action = $this->MO->update('os', $update,'ID_OS',$id_os);
if ($action) {
$this->session->set_flashdata('flash', 'diedit');
redirect('ManageOs');
} else {
$this->session->set_flashdata('flashgagal', 'diedit');
redirect('ManageOs');
}
}
public function hapus()
{
$id = $this->input->post('id');
if ($this->MO->delete('os', $id, 'ID_OS')) {
$action = $this ->MO->delete('os',$id,'ID_OS');
$this->session->set_flashdata('flash', 'dihapus');
redirect('ManageOs');
}
}
}