load->model('ModelDashboard', 'Dashboard'); $this->load->model('AllModels', 'Amod'); $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); $datPart = $this->Dashboard->getData_Part(); $tgl = date('Y-m-d'); $no = 0; foreach ($datPart as $key) { $datIo = $this->Dashboard->getData_TransaksiStock_byPART($key['ID_PART']); if ($datIo==TRUE) { $lock = 1; } else { $lock = 0; } $datPart[$no++] += ['LOCK' => $lock]; } if ($datShm[0]['PART_SHM']==0) { $akses = "Tidak Berhak"; $datPart = NULL; } else if ($datShm[0]['PART_SHM']==1) { $akses = "Hanya Baca"; } else if ($datShm[0]['PART_SHM']==2) { $akses = "Akses Penuh"; } $data = [ 'sidebar' => "dashboard", 'navChild' => "", 'part' => $datPart, 'hak' => $datShm[0]['PART_SHM'], 'akses' => $akses, 'tgl' => $tgl ]; $this->load->view('master/Part', $data); } public function simpan() { $method = $this->input->post('method'); $id_part = $this->input->post('id'); $nama_part = $this->input->post('nama_part'); $hpp_hpar = $this->input->post('hpp_hpar'); $tgl = date('Y-m-d'); $hpp_hpar = str_replace(',', '.', $hpp_hpar); $check_nilai = is_numeric($hpp_hpar); if ($check_nilai==FALSE) { $hpp_hpar = 0; } if ($hpp_hpar<=0) { $this->session->set_flashdata('not_zero_negative', 'error'); redirect($_SERVER['HTTP_REFERER']); } $input = [ 'NAMA_PART' => $nama_part ]; $action = $this->Dashboard->create('part', $input); $datPart = $this->Dashboard->getID_PartMax(); $id_part = $datPart[0]['ID_PART']; $input = [ 'PART_ID' => $id_part, 'TGL_HPAR' => $tgl, 'HPP_HPAR' => $hpp_hpar ]; $action = $this->Dashboard->create('harga_part', $input); if ($action) { $this->session->set_flashdata('success', 'ditambah'); redirect($_SERVER['HTTP_REFERER']); } else { $this->session->set_flashdata('failed', 'ditambah'); redirect($_SERVER['HTTP_REFERER']); } } public function ubah() { $method = $this->input->post('method'); $id_part = $this->input->post('id_parted'); $hpp_hpar = $this->input->post('hpp_hpared'); $tgl = date('Y-m-d'); $hpp_hpar = str_replace(',', '.', $hpp_hpar); $check_nilai = is_numeric($hpp_hpar); if ($check_nilai==FALSE) { $hpp_hpar = 0; } if ($hpp_hpar<=0) { $this->session->set_flashdata('not_zero_negative', 'error'); redirect($_SERVER['HTTP_REFERER']); } $input = [ 'HPP_HPAR' => $hpp_hpar, 'TGL_HPAR' => $tgl, 'PART_ID' => $id_part ]; $action = $this->Dashboard->create('harga_part', $input); if ($action) { $this->session->set_flashdata('success', 'diperbaruhi'); redirect($_SERVER['HTTP_REFERER']); } else { $this->session->set_flashdata('failed', 'diperbaruhi'); redirect($_SERVER['HTTP_REFERER']); } } public function hapus() { $method = $this->input->post('method'); $id = $this->input->post('id_partdel'); $datIo = $this->Dashboard->getData_TransaksiStock_byPART($id); if ($datIo==TRUE) { $this->session->set_flashdata('data_used', 'error'); redirect($_SERVER['HTTP_REFERER']); } $action = $this->Dashboard->delete('harga_part', $id, 'PART_ID'); $action = $this->Dashboard->delete('part', $id, 'ID_PART'); if ($action) { $this->session->set_flashdata('success', 'dihapus'); redirect($_SERVER['HTTP_REFERER']); } else { $this->session->set_flashdata('failed', 'dihapus'); redirect($_SERVER['HTTP_REFERER']); } } }