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); $datKota = $this->Dashboard->getData_Kota(); $no = 0; foreach ($datKota as $key) { $datSupplier = $this->Dashboard->getData_Supplier_byKOTA($key['ID_KOTA']); $datPelanggan = $this->Dashboard->getData_Pelanggan_byKOTA($key['ID_KOTA']); $datPihakke3 = $this->Dashboard->getData_Pihakke3_byKOTA($key['ID_KOTA']); if ($datSupplier==TRUE OR $datPelanggan==TRUE OR $datPihakke3==TRUE) { $lock = 1; } else { $lock = 0; } $datKota[$no++] += ['LOCK' => $lock]; } if ($datShm[0]['KOTA_SHM']==0) { $akses = "Tidak Berhak"; $datKota = NULL; } else if ($datShm[0]['KOTA_SHM']==1) { $akses = "Hanya Baca"; } else if ($datShm[0]['KOTA_SHM']==2) { $akses = "Akses Penuh"; } $data = [ 'sidebar' => "dashboard", 'navChild' => "", 'kota' => $datKota, 'hak' => $datShm[0]['KOTA_SHM'], 'akses' => $akses, ]; $this->load->view('master/Kota', $data); } public function simpan() { $method = $this->input->post('method'); $id_kota = $this->input->post('id'); $nama_kota = $this->input->post('nama_kota'); $input = [ 'NAMA_KOTA' => $nama_kota ]; $action = $this->Dashboard->create('kota', $input); if ($action) { $this->session->set_flashdata('success', 'ditambah'); redirect('ManageKota'); } else { $this->session->set_flashdata('failed', 'ditambah'); redirect('ManageKota'); } } public function ubah() { $method = $this->input->post('method'); $id_kota = $this->input->post('id_kotaed'); $nama_kota = $this->input->post('nama_kotaed'); $update = [ 'NAMA_KOTA' => $nama_kota ]; $action = $this->Dashboard->update('kota', $update,'ID_KOTA',$id_kota); if ($action) { $this->session->set_flashdata('success', 'diubah'); redirect('ManageKota'); } else { $this->session->set_flashdata('failed', 'diubah'); redirect('ManageKota'); } } public function hapus() { $id = $this->input->post('id_kotadel'); $datSupplier = $this->Dashboard->getData_Supplier_byKOTA($id); $datPelanggan = $this->Dashboard->getData_Pelanggan_byKOTA($id); $datPihakke3 = $this->Dashboard->getData_Pihakke3_byKOTA($id); if ($datSupplier==TRUE OR $datPelanggan==TRUE OR $datPihakke3==TRUE) { $this->session->set_flashdata('data_used', 'error'); redirect($_SERVER['HTTP_REFERER']); } $action = $this->Dashboard->delete('kota', $id, 'ID_KOTA'); if ($action) { $this->session->set_flashdata('success', 'dihapus'); redirect('ManageKota'); } else { $this->session->set_flashdata('failed', 'dihapus'); redirect('ManageKota'); } } }