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); $datUnitProyek = $this->Dashboard->getData_UnitProyek(); $no = 0; foreach ($datUnitProyek as $key) { $datDak = $this->Dashboard->getData_DaftarAkuntansi_byUNITPROYEK($key['ID_UNITPROYEK']); if ($datDak==TRUE) { $lock = 1; } else { $lock = 0; } $datUnitProyek[$no++] += ['LOCK' => $lock]; } if ($datShm[0]['UNITPROYEK_SHM']==0) { $akses = "Tidak Berhak"; $datUnitProyek = NULL; } else if ($datShm[0]['UNITPROYEK_SHM']==1) { $akses = "Hanya Baca"; } else if ($datShm[0]['UNITPROYEK_SHM']==2) { $akses = "Akses Penuh"; } $data = [ 'sidebar' => "dashboard", 'navChild' => "", 'hak' => $datShm[0]['UNITPROYEK_SHM'], 'akses' => $akses, 'unitproyek' => $datUnitProyek, ]; $this->load->view('master/UnitProyek', $data); } public function simpan() { $method = $this->input->post('method'); $id_unitproyek = $this->input->post('id'); $nama_unitproyek = $this->input->post('nama_unitproyek'); $nama_unitproyek = strtoupper($nama_unitproyek); $datUnitProyek = $this->Dashboard->getData_UnitProyek_byNAMA($nama_unitproyek); if ($datUnitProyek==TRUE) { $this->session->set_flashdata('data_same', 'error'); redirect('ManageUnitProyek'); } $input = [ 'NAMA_UNITPROYEK' => $nama_unitproyek, ]; $action = $this->Dashboard->create('unitproyek', $input); if ($action) { $this->session->set_flashdata('success', 'ditambah'); redirect('ManageUnitProyek'); } else { $this->session->set_flashdata('failed', 'ditambah'); redirect('ManageUnitProyek'); } } public function ubah() { $method = $this->input->post('method'); $id_unitproyek = $this->input->post('id_unitproyeked'); $nama_unitproyek = $this->input->post('nama_unitproyeked'); $nama_unitproyek = strtoupper($nama_unitproyek); $datUnitProyek = $this->Dashboard->getData_UnitProyek_byNAMA($nama_unitproyek, $id_unitproyek); if ($datUnitProyek==TRUE) { $this->session->set_flashdata('data_same', 'error'); redirect('ManageUnitProyek'); } $update = [ 'NAMA_UNITPROYEK' => $nama_unitproyek, ]; $action = $this->Dashboard->update('unitproyek', $update, 'ID_UNITPROYEK', $id_unitproyek); if ($action) { $this->session->set_flashdata('success', 'diubah'); redirect('ManageUnitProyek'); } else { $this->session->set_flashdata('failed', 'diubah'); redirect('ManageUnitProyek'); } } public function hapus() { $id_unitproyek = $this->input->post('id_unitproyekdel'); $datUnitProyek = $this->Dashboard->getData_DaftarAkuntansi_byUNITPROYEK($id_unitproyek); if ($datUnitProyek==TRUE) { $this->session->set_flashdata('data_used', 'error'); redirect('ManageUnitProyek'); } $action = $this ->Dashboard->delete('unitproyek', $id_unitproyek, 'ID_UNITPROYEK'); if ($action) { $this->session->set_flashdata('success', 'dihapus'); redirect('ManageUnitProyek'); } else { $this->session->set_flashdata('failed', 'dihapus'); redirect('ManageUnitProyek'); } } }