Assalamualaikum,..
ini skrip di administrator pak
// Controller Modul Prestasi
function prestasi(){
cek_session_akses('prestasi',$this->session->id_session);
if ($this->session->level=='admin'){
$data['record'] = $this->model_app->view_ordering('prestasi','id_prestasi','DESC');
}else{
$data['record'] = $this->model_app->view_where_ordering('prestasi',array('username'=>$this->session->username),'id_prestasi','DESC'); }
$this->template->load('administrator/template','administrator/mod_prestasi/view_prestasi',$data);
}
function tambah_prestasi(){
cek_session_akses('prestasi',$this->session->id_session);
if (isset($_POST['submit'])){ $config['upload_path'] = 'asset/foto_prestasi/';
$config['allowed_types'] = 'gif|jpg|png|JPG|JPEG';
$config['max_size'] = '3000'; // kb
$this->load->library('upload', $config);
$this->upload->do_upload('c');
$hasil=$this->upload->data();
if ($hasil['file_name']==''){
$data = array('tema'->$this->db->escape_str($this->input->post('a')), 'tema_seo'->seo_title($this->input->post('a')),
'isi_prestasi'->$this->input->post('b'),
'pengirim'->$this->db->escape_str($this->input->post('g')),
'tgl_posting'->date('Y-m-d'), 'username'->$this->session->username);
}
else{
$data = array('tema'->$this->db->escape_str($this->input->post('a')), 'tema_seo'->seo_title($this->input->post('a')),
'isi_prestasi'->$this->input->post('b'),
'pengirim'->$this->db->escape_str($this->input->post('g')),
'gambar'->$hasil['file_name'],
'tgl_posting'->date('Y-m-d'), 'username'->$this->session->username);
}
$this->model_app->insert('prestasi',$data);
redirect('administrator/prestasi');
}
else{
$this->template->load('administrator/template','administrator/mod_prestasi/view_prestasi_tambah');
}
}
function edit_prestasi(){
cek_session_akses('prestasi',$this->session->id_session);
$id = $this->uri->segment(3);
if (isset($_POST['submit'])){ $config['upload_path'] = 'asset/foto_prestasi/';
$config['allowed_types'] = 'gif|jpg|png|JPG|JPEG';
$config['max_size'] = '3000'; // kb
$this->load->library('upload', $config);
$this->upload->do_upload('c');
$hasil=$this->upload->data();
if ($hasil['file_name']==''){
$data = array('tema'->$this->db->escape_str($this->input->post('a'))); 'tema_seo'->seo_title($this->input->post('a'));
'isi_prestasi'->$this->input->post('b');
'pengirim'->$this->db->escape_str($this->input->post('g'));
}
else{
$data = array('tema'->$this->db->escape_str($this->input->post('a'))); 'tema_seo'->seo_title($this->input->post('a'));
'isi_prestasi'->$this->input->post('b');
'pengirim'->$this->db->escape_str($this->input->post('g'));
'gambar'->$hasil['file_name'];
}
$where = array('id_prestasi' => $this->input->post('id')); $this->model_app->update('prestasi', $data, $where);
redirect('administrator/prestasi');
}else{
if ($this->session->level=='admin'){
$proses = $this->model_app->edit('prestasi', array('id_prestasi' => $id))->row_array(); }else{
$proses = $this->model_app->edit('prestasi', array('id_prestasi' => $id, 'username' => $this->session->username))->row_array(); }
$data = array('rows' => $proses); $this->template->load('administrator/template','administrator/mod_prestasi/view_prestasi_edit',$data);
}
}
function delete_prestasi(){
cek_session_akses('prestasi',$this->session->id_session);
if ($this->session->level=='admin'){
$id = array('id_prestasi' => $this->uri->segment(3)); }else{
$id = array('id_prestasi' => $this->uri->segment(3), 'username'=>$this->session->username); }
$this->model_app->delete('prestasi',$id);
redirect('administrator/prestasi');
}