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); $datMerk = $this->Dashboard->getData_Merk(); $no = 0; foreach ($datMerk as $key) { $datBarang = $this->Dashboard->getData_Barang_byMERK($key['ID_MERK']); if ($datBarang==TRUE) { $lock = 1; } else { $lock = 0; } $datMerk[$no++] += ['LOCK' => $lock]; } if ($datShm[0]['MERK_SHM']==0) { $akses = "Tidak Berhak"; $datMerk = NULL; } else if ($datShm[0]['MERK_SHM']==1) { $akses = "Hanya Baca"; } else if ($datShm[0]['MERK_SHM']==2) { $akses = "Akses Penuh"; } $data = [ 'sidebar' => "dashboard", 'navChild' => "", 'merk' => $datMerk, 'hak' => $datShm[0]['MERK_SHM'], 'akses' => $akses, ]; $this->load->view('master/Merk', $data); } public function simpan() { $method = $this->input->post('method'); $id = $this->input->post('id_merk'); $nama_merk = $this->input->post('nama_merk'); $nama_merk = strtoupper($nama_merk); $datMerk = $this->Dashboard->getData_Merk_byNAMA($nama_merk); if ($datMerk==TRUE) { $this->session->set_flashdata('data_same', 'error'); redirect('ManageMerk'); } $input = [ 'NAMA_MERK' => $nama_merk ]; $action = $this->Dashboard->create('merk', $input); if ($action) { $this->session->set_flashdata('success', 'ditambah'); redirect('ManageMerk'); } else { $this->session->set_flashdata('failed', 'ditambah'); redirect('ManageMerk'); } } public function ubah() { $method = $this->input->post('method'); $id_merk = $this->input->post('id_merked'); $nama_merk = $this->input->post('nama_merked'); $nama_merk = strtoupper($nama_merk); $datMerk = $this->Dashboard->getData_Merk_byNAMA($nama_merk, $id_merk); if ($datMerk==TRUE) { $this->session->set_flashdata('data_same', 'error'); redirect('ManageMerk'); } $update = [ 'NAMA_MERK' => $nama_merk ]; $action = $this->Dashboard->update('merk', $update, 'ID_MERK', $id_merk); if ($action) { $this->session->set_flashdata('success', 'diubah'); redirect('ManageMerk'); } else { $this->session->set_flashdata('failed', 'diubah'); redirect('ManageMerk'); } } public function hapus() { $method = $this->input->post('method'); $id = $this->input->post('id_merkdel'); $datMerk = $this->Dashboard->getData_Barang_byMERK($id); if ($datMerk==TRUE) { $this->session->set_flashdata('data_used', 'error'); redirect('ManageMerk'); } $action = $this->Dashboard->delete('merk', $id, 'ID_MERK'); if ($action) { $this->session->set_flashdata('success', 'dihapus'); redirect('ManageMerk'); } else { $this->session->set_flashdata('failed', 'dihapus'); redirect('ManageMerk'); } } }