is_logged_in(); } public function index() { $this->list_data(); } public function list_data() { $data = array( 'title_page' => 'Semua Data', 'common' => $this, 'modul' => $this->modul, 'title_content' => 'Data ' . $this->modul, 'list_data' => $this->informasi_model->select('*', null, null, null, array('field' => 'id_informasi', 'sort' => 'desc'))->result(), 'page' => 'webadmin/master/informasi/list' ); $this->load->view('webadmin/index', $data); } public function view($id = null) { $data = array( 'common' => $this, 'setting' => $this->setting, 'title_page' => 'Lihat Data', 'modul' => $this->modul, 'title_content' => 'Lihat ' . $this->modul, 'data' => $this->informasi_model->select('*', array('id_informasi' => $id), null, null, null)->row(), 'page' => 'webadmin/master/informasi/view' ); $this->load->view('webadmin/index', $data); } public function add() { $data = array( 'common' => $this, 'title_page' => 'Tambah Data', 'modul' => $this->modul, 'title_content' => 'Tambah ' . $this->modul, 'page' => 'webadmin/master/informasi/add', 'list_cat' => $this->listcode_model->select('*', array('head_list'=>'INFO'), null, null, array('field' => 'nama_list', 'sort' => 'asc'))->result(), ); $this->load->view('webadmin/index', $data); } public function edit($id = null) { $data = array( 'common' => $this, 'title_page' => 'Ubah Data', 'modul' => $this->modul, 'title_content' => 'Ubah informasi', 'data' => $this->informasi_model->select('*', array('id_informasi' => $id), null, null, null)->row(), 'page' => 'webadmin/master/informasi/edit', 'list_cat' => $this->listcode_model->select('*', array('head_list'=>'INFO'), null, null, array('field' => 'nama_list', 'sort' => 'asc'))->result(), ); $this->load->view('webadmin/index', $data); } public function process($action, $id = null) { $data['title'] = $this->input->post('inp_judul'); $data['tanggal'] = date('Y-m-d', strtotime($this->input->post('inp_tanggal'))); $data['isi'] = $this->input->post('inp_isi'); $data['kategori'] = $this->input->post('inp_kategori'); $data['author'] = $this->session->userdata('pps_nama'); $img1 = $this->upload_image($data['title'], 'inp_foto'); if ($img1 != '') { $data['foto'] = $img1; } if ($action == 'add') { $res = $this->informasi_model->add($data); $this->log->add_log('Tambah Data ' . $this->modul, $data['title']); if ($res) { $this->session->set_flashdata('message', $this->message->get_message('success', 'add-success')); } else { $this->session->set_flashdata('message', $this->message->get_message('success', 'failed')); } } else if ($action == 'edit') { $content = $this->informasi_model->edit($data, array('id_informasi' => $id)); $this->log->add_log('Ubah Data ' . $this->modul, $data['title']); if ($content) { $this->session->set_flashdata('message', $this->message->get_message('success', 'edit-success')); } else { $this->session->set_flashdata('message', $this->message->get_message('danger', 'failed')); } } redirect('master/informasi'); } public function upload_image($judul, $inp_foto) { $config = array( 'overwrite' => TRUE, 'file_name' => $judul . '_' . mt_rand(1, 1000), 'max_size' => '2048', 'allowed_types' => 'jpg|jpeg|png', 'upload_path' => './assets/informasi/' ); $this->upload->initialize($config); if (!empty($_FILES[$inp_foto]['name']) && $_FILES[$inp_foto]['name'] != '' && $_FILES[$inp_foto]['name'] != null) { if ($this->upload->do_upload($inp_foto)) { $dok = $this->upload->data(); return $dok['file_name']; } else { $this->session->set_flashdata('message', $this->message->get_message('danger', 'failed')); redirect('master/informasi'); } } else { return ''; } } public function delete($id = null) { $res = $this->informasi_model->delete(array('id_informasi' => $id)); $this->log->add_log('Hapus Data ' . $this->modul); if ($res) { $this->session->set_flashdata('message', $this->message->get_message('success', 'delete-success')); } else { $this->session->set_flashdata('message', $this->message->get_message('danger', 'failed')); } redirect('master/informasi'); } }