check_isvalidated(); $this->load->helper(array('form', 'date')); } private function check_isvalidated(){ if(! $this->session->userdata('validated_rssapintar')){ redirect('index.php/login'); } //--------------start check access this form page-------------// $this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser_rssapintar')); $this->db->where('mum_menu_id', '7'); $cekMenu = $this->db->get('master_user_menu'); $rowcount = $cekMenu->num_rows(); if($rowcount==0){ redirect('index.php'); }else{ foreach ($cekMenu->result() as $cm) { $this->vartambah=$cm->mum_tambah; $this->varedit=$cm->mum_ubah; $this->vardelete=$cm->mum_hapus; $this->varview=$cm->mum_lihat; } } //--------------end check access this form page-------------// } public function index($error = NULL) { $data['title'] = 'Dokter'; $data['main_content'] = 'master/dokter/v_dokter'; $data['error']=$error; $this->load->model('m_dokter'); $dokter = $this->m_dokter->index(); $this->load->vars('dk', $dokter); $this->load->view('includes/template', $data); } // fungsi untuk menampilkan form tambah data public function add() { //----start validate page tambah-------// if($this->vartambah==null){redirect('index.php/ps_dokter');} //----end validate page tambah---------// $data['title'] = 'Tambah Dokter'; $data['actionform'] = 'prosesadd'; $data['main_content'] = 'master/dokter/form_dokter'; $this->load->model('m_spesialis'); $spesialis = $this->m_spesialis->status(); $this->load->vars('sp', $spesialis); $this->load->view('includes/template', $data); } //fungsi untuk memproses penambahan dengan memanggil model public function prosesadd() { //----start validate page tambah-------// if($this->vartambah==null){redirect('index.php/ps_dokter');} //----end validate page tambah---------// $this->load->helper('form'); $this->load->helper('url'); $this->load->library('form_validation'); $this->form_validation->set_rules('namauser','Nama User','required'); $this->form_validation->set_rules('passworduser','Password User','required'); $this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]'); if($this->form_validation->run()==FALSE){ $data['title'] = 'Tambah Dokter'; $data['actionform'] = 'prosesadd'; $data['main_content'] = 'master/dokter/form_dokter'; $this->load->model('m_spesialis'); $spesialis = $this->m_spesialis->status(); $this->load->vars('sp', $spesialis); $this->load->view('includes/template', $data); }else{ $this->load->model('m_dokter'); $this->m_dokter->insert(); $this->session->set_flashdata('message', 'Anda berhasil menambahkan Dokter baru'); redirect('index.php/ps_dokter'); } } //fungsi untuk menampilkan form edit data dengan data terpilih public function edit($id) { //----start validate page edit-------// if($this->varedit==null){redirect('index.php/ps_dokter');} //----end validate page edit---------// $data['title'] = 'Edit Dokter'; $data['actionform'] = 'prosesedit'; $data['main_content'] = 'master/dokter/form_dokter'; $this->load->model('m_dokter'); $dokter = $this->m_dokter->edit($id); $this->load->vars('dk', $dokter); $this->load->model('m_spesialis'); $spesialis = $this->m_spesialis->status(); $this->load->vars('sp', $spesialis); $this->load->view('includes/template', $data); } //funsi untuk memproses update data public function prosesedit() { //----start validate page edit-------// if($this->varedit==null){redirect('index.php/ps_dokter');} //----end validate page edit---------// $id = $this->input->post('id'); $setpass = $this->input->post('passworduser'); $this->load->helper('form'); $this->load->helper('url'); $this->load->library('form_validation'); $this->form_validation->set_rules('namauser','Nama User','required'); if(!empty($setpass)){ $this->form_validation->set_rules('passworduser','Password User','required'); $this->form_validation->set_rules('repassworduser', 'Retype Password', 'required|matches[passworduser]'); } if($this->form_validation->run()==FALSE){ $data['title'] = 'Edit Dokter'; $data['actionform'] = 'prosesedit'; $data['main_content'] = 'master/dokter/form_dokter'; $this->load->model('m_dokter'); $dokter = $this->m_dokter->edit($id); $this->load->vars('dk', $dokter); $this->load->model('m_spesialis'); $spesialis = $this->m_spesialis->status(); $this->load->vars('sp', $spesialis); $this->load->view('includes/template', $data); } else{ $this->session->set_flashdata('message', 'Anda berhasil mengedit Dokter'); $this->load->model('m_dokter'); $this->m_dokter->prosesedit(); redirect('index.php/ps_dokter'); } } //fungsi untuk menampilkan form view data dengan data terpilih public function view($id) { //----start validate page view-------// if($this->varview==null){redirect('index.php/ps_dokter');} //----end validate page view---------// $data['title'] = 'View Dokter'; $data['actionform'] = 'prosesview'; $data['main_content'] = 'master/dokter/form_dokter'; $this->load->model('m_dokter'); $dokter = $this->m_dokter->edit($id); $this->load->vars('dk', $dokter); $this->load->model('m_spesialis'); $spesialis = $this->m_spesialis->status(); $this->load->vars('sp', $spesialis); $this->load->view('includes/template', $data); } //fungsi untuk delete function delete($id) { //----start validate page delete-------// if($this->vardelete==null){redirect('index.php/ps_dokter');} //----end validate page delete---------// $this->session->set_flashdata('message', 'Anda berhasil menghapus Dokter'); $this->load->model('m_dokter'); $this->m_dokter->delete($id); redirect('index.php/ps_dokter'); } function disabled($id) { //----start validate page delete-------// if($this->vardelete==null){redirect('index.php/ps_dokter');} //----end validate page delete---------// $this->session->set_flashdata('message', 'Anda berhasil disabled Dokter'); $this->load->model('m_dokter'); $this->m_dokter->disabled($id); redirect('index.php/ps_dokter'); } function aktif($id) { //----start validate page delete-------// if($this->vardelete==null){redirect('index.php/ps_dokter');} //----end validate page delete---------// $this->session->set_flashdata('message', 'Anda berhasil aktifkan Dokter'); $this->load->model('m_dokter'); $this->m_dokter->aktif($id); redirect('index.php/ps_dokter'); } } ?>