load->model('model'); $this->load->model('m_tabel_ss'); $level = $this->session->userdata('level'); if ($level != 'admin') { $html = ''; print_r($html); } } function index() { if ($this->input->post('proses') == 'hapus_warkop') { // print_r('sini hapus'); // print_r($this->input->post('id')); $dir = 'images/'.$this->input->post('id').'/'; $files = glob($dir.'*'); // get all file names foreach($files as $file){ // iterate files if(is_file($file)) unlink($file); // delete file } rmdir($dir); $this->model->delete('tb_list_puskesmas',array('no' => $this->input->post('id'))); print_r(""); } elseif ($this->input->post('proses') == 'edit_detail_puskesmas') { // print_r('sini_edit'); $data = $this->model->serialize(json_decode($this->input->post('data'))); // print_r($data); // print_r($this->input->post('id')); if ($this->input->post('foto') == 'ada') { // print_r('ada') $dir = 'images/'.$this->input->post('id').'/'; $files = glob($dir.'*'); // get all file names foreach($files as $file){ // iterate files if(is_file($file)) unlink($file); // delete file } $countfiles = count($_FILES['files']['name']); for($index = 0;$index < $countfiles;$index++){ $filename = $_FILES['files']['name'][$index]; $path = $dir.$filename; move_uploaded_file($_FILES['files']['tmp_name'][$index],$path); } // print_r($countfiles); } $this->model->update('tb_list_puskesmas',array('no' => $this->input->post('id')), $data); // print_r($this->db->affected_rows()); if ($this->db->affected_rows() == 1) { print_r(""); } elseif ($this->input->post('foto') == 'ada') { print_r(""); } else{ print_r(""); } } elseif ($this->input->post('proses') == 'cek_foto_detail') { // header('Access-Control-Allow-Origin: *'); $html = ''; foreach (glob('images/'.$this->input->post('id').'/*.*') as $key => $value){ // print_r($key); if ($key == 0) { $html .= '
Klik Untuk Melihat Foto
'; }else{ $html .= ''; } } print_r($html); } elseif ($this->input->post('proses') == 'cek_data_detail') { $id = $this->input->post('id'); // print_r($id); $data = $this->model->tampil_data_where('tb_list_puskesmas',array('no' => $id))->result(); print_r(json_encode($data[0])); } elseif ($this->input->post('proses') == 'tambah') { $data = $this->model->serialize(json_decode($this->input->post('data'))); $this->model->insert('tb_list_puskesmas',$data); $data_last = $this->model->tampil_data_last('tb_list_puskesmas','no')->result(); // print_r($data_last[0]->no); $dir = 'images/'.$data_last[0]->no.'/'; if(is_dir($dir) === false ) { mkdir($dir); } $countfiles = count($_FILES['files']['name']); for($index = 0;$index < $countfiles;$index++){ $filename = $_FILES['files']['name'][$index]; $path = $dir.$filename; move_uploaded_file($_FILES['files']['tmp_name'][$index],$path); } // print_r($_FILES['files']); // print_r($data); print_r(""); } else{ $main['header'] = "Halaman Utama Admin"; $this->load->view('admin/index',$main); } } function puskesmas() { $main['kecamatan'] = $this->model->tampil_data_keseluruhan('tb_kecamatan')->result(); $main['header'] = "Halaman List Puskesmas"; $this->load->view('admin/menu/puskesmas',$main); } function ambil_peta_changing() { header('Access-Control-Allow-Origin: *'); if ($this->input->post('posisi') != '' or $this->input->post('posisi') != null) { # code... // print_r($this->input->post('cek_peta')); if ($this->input->post('posisi') == 'kecamatan') { $cek_data = $this->model->tampil_data_where('tb_kecamatan',array('no' => $this->input->post('cek_peta')))->result(); $cek_data_kelurahan = $this->model->tampil_data_where('tb_kelurahan',array('kecamatan' => $this->input->post('cek_peta')))->result(); ?> input->post('posisi') == 'kelurahan') { $cek_data = $this->model->tampil_data_where('tb_kelurahan',array('no' => $this->input->post('cek_peta')))->result(); $center = $cek_data[0]->center; } ?>
uri->segment(3) == "pengaduan") { $list = $this->m_tabel_ss->get_datatables(array('nama','email' , 'waktu'),array(null, 'nama','email','waktu',null),array('no' => 'asc'),"tb_pengaduan",null); $data = array(); $no = $_POST['start']; foreach ($list as $field) { $no++; $row = array(); $ket = str_replace("\r\n",'+', $field->ket); $row[] = $no; $row[] = $field->nama; $row[] = $field->email; $row[] = $field->waktu; $row[] = '
'; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->m_tabel_ss->count_all("tb_pengaduan",null), "recordsFiltered" => $this->m_tabel_ss->count_filtered(array('nama','email' , 'waktu'),array(null, 'nama','email','waktu',null),array('no' => 'asc'),"tb_pengaduan",null), "data" => $data, ); //output dalam format JSON echo json_encode($output); } elseif ($this->uri->segment(3) == "puskesmas") { $list = $this->m_tabel_ss->get_datatables(array('nama','alamat' ,),array(null, 'nama','alamat',null),array('no' => 'asc'),'tb_list_puskesmas',null); $data = array(); $no = $_POST['start']; foreach ($list as $field) { $no++; $row = array(); // $ket = str_replace("\r\n",'+', $field->ket); $row[] = $no; $row[] = $field->nama; $row[] = $field->alamat; // $row[] = $field->kordinat; // $row[] = '
'; $row[] = '
'; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->m_tabel_ss->count_all("tb_list_puskesmas",null), "recordsFiltered" => $this->m_tabel_ss->count_filtered(array('nama','alamat' ,),array(null, 'nama','alamat',null),array('no' => 'asc'),'tb_list_puskesmas',null), "data" => $data, ); //output dalam format JSON echo json_encode($output); } else{ redirect('/admin'); } } function pengaduan() { // print_r('sini pengaduan'); $main['header'] = "Halaman Pengaduan User"; $this->load->view('admin/menu/pengaduan',$main); } function logout() { if ($this->input->post('proses') == 'logout') { $this->session->unset_userdata('level'); } } function ambil_kordinat_sekarang() { header('Access-Control-Allow-Origin: *'); ?>