68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
require APPPATH . 'libraries/REST_Controller.php';
|
|
require APPPATH . 'libraries/Format.php';
|
|
|
|
class MenuBantuan extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->ceklogin();
|
|
$this->load->model('ModelSetData', 'Setdata');
|
|
$this->load->model('ModelBantuan', 'Bantuan');
|
|
}
|
|
public function output_json($data, $encode = true)
|
|
{
|
|
if ($encode) $data = json_encode($data);
|
|
$this->output->set_content_type('application/json')->set_output($data);
|
|
}
|
|
private function ceklogin()
|
|
{
|
|
$username = $this->session->userdata('username');
|
|
if ($username == null) {
|
|
redirect("login");
|
|
}
|
|
}
|
|
|
|
public function index() {
|
|
$id_setdata = $this->Setdata->getIDSETDATA();
|
|
$id_setdata = $id_setdata[0]['ID_SETDATA'];
|
|
$jabatan = $this->session->userdata('jabatan');
|
|
$tgl = date('Y-m-d');
|
|
$data = array(
|
|
'sidebar' => "menu bantuan",
|
|
'navChild' => "",
|
|
'id' => $id_setdata,
|
|
'jabatan' => $jabatan,
|
|
'tgl' => $tgl,
|
|
);
|
|
$this->load->view('menu/Bantuan', $data);
|
|
}
|
|
|
|
public function tambahlapor_AA1() {
|
|
$id_bantuan = $this->input->post('id');
|
|
$jenis_bantuan = $this->input->post('jenis_bantuan');
|
|
$ket_bantuan = $this->input->post('ket_bantuan');
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$input = [
|
|
'TGL_BANTUAN' => $tgl,
|
|
'JENIS_BANTUAN' => $jenis_bantuan,
|
|
'KET_BANTUAN' => $ket_bantuan,
|
|
'KARYAWAN_ID' => $id_karyawan
|
|
];
|
|
$action = $this->Setdata->create('bantuan', $input);
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'ditambah');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
}
|