load->model('ModelDashboard', 'Dashboard'); $this->load->library(['datatables', 'form_validation']); $this->form_validation->set_error_delimiters('', ''); $this->Dashboard->ceklogin(); } 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() { $id_karyawan = $this->session->userdata('id_karyawan'); $datShm = $this->Dashboard->getData_SetHakMaster_byKARYAWAN($id_karyawan); $datProgram = $this->Dashboard->getData_Program(); $no = 0; foreach ($datProgram as $key) { $datLkpr = $this->Dashboard->getData_LinkKlaimProgram_byPROGRAM($key['ID_PROGRAM']); if ($datLkpr==TRUE) { $lock = 1; } else { $lock = 0; } $datProgram[$no++] += ['LOCK' => $lock]; } if ($datShm[0]['PROGRAM_SHM']==0) { $akses = "Tidak Berhak"; $datProgram = NULL; } else if ($datShm[0]['PROGRAM_SHM']==1) { $akses = "Hanya Baca"; } else if ($datShm[0]['PROGRAM_SHM']==2) { $akses = "Akses Penuh"; } $data = [ 'sidebar' => "dashboard", 'navChild' => "", 'program' => $datProgram, 'hak' => $datShm[0]['PROGRAM_SHM'], 'akses' => $akses, ]; $this->load->view('master/Program', $data); } public function simpan() { $method = $this->input->post('method'); $id = $this->input->post('id_program'); $kode_program = $this->input->post('kode_program'); $nama_program = $this->input->post('nama_program'); $datProgram = $this->Dashboard->getData_Program_byNAMA($nama_program); if ($datProgram==TRUE) { $this->session->set_flashdata('data_same', 'error'); redirect('ManageProgram'); } $kode_program = strtoupper($kode_program); $input = [ 'KODE_PROGRAM' => $kode_program, 'NAMA_PROGRAM' => $nama_program, ]; $action = $this->Dashboard->create('program', $input); if ($action) { $this->session->set_flashdata('success', 'ditambah'); redirect('ManageProgram'); } else { $this->session->set_flashdata('failed', 'ditambah'); redirect('ManageProgram'); } } public function ubah() { $method = $this->input->post('method'); $id_program = $this->input->post('id_programed'); $kode_program = $this->input->post('kode_programed'); $nama_program = $this->input->post('nama_programed'); $datProgram = $this->Dashboard->getData_Program_byNAMA($nama_program, $id_program); if ($datProgram==TRUE) { $this->session->set_flashdata('data_same', 'error'); redirect('ManageProgram'); } $kode_program = strtoupper($kode_program); $update = [ 'KODE_PROGRAM' => $kode_program, 'NAMA_PROGRAM' => $nama_program, ]; $action = $this->Dashboard->update('program', $update, 'ID_PROGRAM', $id_program); if ($action) { $this->session->set_flashdata('success', 'diubah'); redirect('ManageProgram'); } else { $this->session->set_flashdata('failed', 'diubah'); redirect('ManageProgram'); } } public function hapus() { $method = $this->input->post('method'); $id = $this->input->post('id_programdel'); $datLkpr = $this->Dashboard->getData_LinkKlaimProgram_byPROGRAM($id); if ($datLkpr==TRUE) { $this->session->set_flashdata('data_used', 'error'); redirect('ManageProgram'); } $action = $this->Dashboard->delete('program', $id, 'ID_PROGRAM'); if ($action) { $this->session->set_flashdata('success', 'dihapus'); redirect('ManageProgram'); } else { $this->session->set_flashdata('failed', 'dihapus'); redirect('ManageProgram'); } } }