Пример #1
0
 public function edit($id)
 {
     if (!$this->camping->exists($id)) {
         rediect('campings');
     }
     $this->form_validation->set_rules('data[name]', 'nombre', 'required|trim');
     if ($this->form_validation->run()) {
         $this->camping->update($this->input->post('data', TRUE), $id);
         $this->session->set_flashdata('msg_success', 'El campo ha sido actualizado.');
         redirect('campings');
     }
     $stored = $this->camping->get($id)->row_array();
     $data = $this->camping->prepare_data($this->input->post('data'), $stored);
     $data['form_title'] = 'Editar Campo';
     $data['breadcrumb'] = 'Editar';
     $this->template->write('title', $data['form_title']);
     $this->template->write_view('content', 'campings/form', $data);
     $this->template->render();
 }
Пример #2
0
 public function save()
 {
     if ($this->checkRole() == FALSE) {
         $this->session->set_flashdata('failed', 'Maaf, anda tidak dapat mengakses halaman tersebut!');
         redirect('topic/');
     }
     $this->form_validation->set_rules('kategori', 'Kategori', 'required');
     $this->form_validation->set_rules('topic', 'Topic', 'required');
     $this->form_validation->set_rules('daerah', 'Daerah', 'required');
     if ($this->form_validation->run() == TRUE) {
         $user = sentinel()->getUser();
         $data = array('tenaga_ahli' => $user->id, 'category' => set_value('kategori'), 'topic' => set_value('topic'), 'daerah' => set_value('daerah'), 'created_at' => date('Y-m-d H:i:s'));
         $save = $this->model_topic->save($data);
         if ($save == TRUE) {
             $this->session->set_flashdata('success', 'New topic has successfully created.');
         } else {
             $this->session->set_flashdata('failed', 'New topic was failed to be created.');
         }
         redirect('topic/');
     } else {
         $this->session->set_flashdata('failed', validation_error());
         rediect('topic/');
     }
 }
Пример #3
0
 public function save()
 {
     if ($this->checkTA() == FALSE) {
         $this->session->set_flashdata('failed', 'Maaf, anda tidak dapat mengakses halaman tersebut!');
         redirect('topic/');
     }
     $this->form_validation->set_rules('kategori', 'Kategori', 'required');
     $this->form_validation->set_rules('topic', 'Topic', 'required');
     $this->form_validation->set_rules('type', 'Type', 'required');
     if ($this->form_validation->run() == TRUE) {
         $category = set_value('kategori');
         $getUsersCategory = $this->model_topic->get_userID_by_category($category);
         $user = sentinel()->getUser();
         $type = set_value('type');
         if ($type == 'close') {
             $provinsi = $this->input->post('provinsi');
             $kota = $this->input->post('kota');
             $kecamatan = $this->input->post('kecamatan');
             $desa = $this->input->post('desa');
             if ($desa != '') {
                 $daerah = $desa;
             } elseif ($kecamatan != '') {
                 $daerah = $kecamatan;
             } elseif ($kota != '') {
                 $daerah = $kota;
             } elseif ($provinsi != '') {
                 $daerah = $provinsi;
             } else {
                 $daerah = '00.00.00.0000';
             }
         } else {
             $daerah = '00.00.00.0000';
         }
         foreach ($getUsersCategory as $u) {
             if ($u->user_id == $user->id) {
                 $status = '1';
             } else {
                 $status = '0';
             }
         }
         $data = array('tenaga_ahli' => $user->id, 'category' => $category, 'topic' => set_value('topic'), 'daerah' => $daerah, 'created_at' => date('Y-m-d H:i:s'), 'status' => $status);
         $save = $this->model_topic->save($data);
         if ($save == TRUE) {
             $this->session->set_flashdata('success', 'New topic has successfully created.');
         } else {
             $this->session->set_flashdata('failed', 'New topic was failed to be created.');
         }
         redirect('topic/');
     } else {
         $this->session->set_flashdata('failed', validation_error());
         rediect('topic/');
     }
 }