Ejemplo n.º 1
0
 public function update()
 {
     check_if_both();
     $data['page'] = "update";
     $data['newline'] = "<br/>";
     // temp id and username
     $user_id = $this->session->userdata('id');
     $username = $this->session->userdata('username');
     $user = $this->Users_model->find($username);
     $result = $this->Users_model->find_info($user_id);
     if (isset($_POST['btnUpdate'])) {
         $input = array("firstname" => $_POST['firstname'], "middlename" => $_POST['middlename'], "lastname" => $_POST['lastname'], "email" => $_POST['email'], "gender" => isset($_POST['gender']) ? $_POST['gender'] : "", "occupation" => $_POST['occupation'], "otherinfo" => $_POST['otherinfo']);
         $updated_data["first_name"] = $input["firstname"];
         $updated_data["middle_name"] = $input["middlename"];
         $updated_data["last_name"] = $input["lastname"];
         $updated_data["email"] = $input["email"];
         $updated_data["gender"] = $input["gender"];
         $updated_data["occupation"] = $input["occupation"];
         $updated_data["about"] = $input["otherinfo"];
         $this->Users_model->update($updated_data, $user_id);
         header('Location: update');
     }
     $_POST['username'] = $user["username"];
     $_POST['firstname'] = $result["first_name"];
     $_POST['middlename'] = $result["middle_name"];
     $_POST['lastname'] = $result["last_name"];
     $_POST['email'] = $result["email"];
     $_POST['gender'] = $result["gender"];
     $_POST['occupation'] = $result["occupation"];
     $_POST['otherinfo'] = $result["about"];
     $this->load->view('templates/header');
     $this->load->view('users/update', $data);
     $this->load->view('templates/footer');
 }
Ejemplo n.º 2
0
 public function getinfo($id)
 {
     $data['info'] = $this->Tools_model->find($id);
     $data['version'] = $this->Tools_model->find_version($id);
     $data['request'] = $this->Tools_model->find_request($id);
     check_if_both();
     header('Content-Type: application/json');
     if (empty($data['request'])) {
         echo json_encode($data['info'] + $data['version']);
     } else {
         echo json_encode($data['info'] + $data['version'] + $data['request']);
     }
     $view["created_at"] = $date = date('Y/m/d H:i:s');
     $view["tool_id"] = $id;
     $tools = $this->Tools_model->add_view($view);
 }