Example #1
0
 public function updateMarker()
 {
     $id_marker = $this->security->xss_clean($this->input->post('id_marker'));
     $name = $this->security->xss_clean($this->input->post('name'));
     $company = $this->security->xss_clean($this->input->post('company'));
     $contact = $this->security->xss_clean($this->input->post('contact'));
     $email = $this->security->xss_clean($this->input->post('email'));
     $location = $this->security->xss_clean($this->input->post('location'));
     $price = $this->security->xss_clean($this->input->post('price'));
     $latlng = $this->security->xss_clean($this->input->post('latlng'));
     if (!empty($name) && !empty($company) && !empty($contact) && !empty($email) && !empty($price) && !empty($location)) {
         // location
         $latlng = fix_location($latlng);
         //profile
         $profile = array('name' => $name, 'company' => $company, 'contact' => $contact, 'email' => $email, 'location' => $location, 'price' => $price);
         // main data
         $data = array('id_marker' => $id_marker, 'profile' => json_encode($profile), 'latlng' => json_encode($latlng), 'updated' => date('Y-m-d H:i:s'));
         $update = $this->db->where('id_marker', $id_marker);
         $update = $this->db->update('beo_bengkel', $data);
         if ($update) {
             echo json_encode(array('ok' => 1, 'id' => $id_marker));
         }
     } else {
         echo json_encode(array('ok' => 0, 'msg' => 'Error page'));
     }
 }
Example #2
0
 public function update()
 {
     $id = $this->security->xss_clean($this->input->post('id'));
     $name = $this->security->xss_clean($this->input->post('name'));
     $username = $this->security->xss_clean($this->input->post('username'));
     $password = $this->security->xss_clean($this->input->post('password'));
     $contact = $this->security->xss_clean($this->input->post('contact'));
     $location = $this->security->xss_clean($this->input->post('location'));
     $latlng = $this->security->xss_clean($this->input->post('latlng'));
     if (!empty($id) && !empty($name) && !empty($username) && !empty($password) && !empty($contact) && !empty($location) && !empty($latlng)) {
         // location
         $latlng = fix_location($latlng);
         // profile
         $profile = array('name' => $name, 'contact' => $contact, 'location' => $location);
         $data = array('username' => $username, 'pass' => $password, 'profile' => json_encode($profile), 'latlng' => json_encode($latlng), 'updated' => date('Y-m-d H:i:s'));
         $update = $this->db->where('id', $id);
         $update = $this->db->update('beo_customer', $data);
         if ($update) {
             $result[] = array('id' => $id, 'name' => $name, 'username' => $username, 'pass' => $password, 'contact' => $contact, 'location' => $location);
             $output["ok"] = 1;
             $output["result"] = $result;
             pretty_json($output);
         } else {
             echo json_encode(array('ok' => 0, 'msg' => 'No auth found'));
         }
     } else {
         echo json_encode(array('ok' => 0, 'msg' => 'No auth found'));
     }
 }
Example #3
0
 public function _search_near($latlng)
 {
     $location_now = fix_location($latlng);
     $query = $this->db->select('id_marker, latlng')->from('beo_bengkel')->get();
     $distance = array();
     $d = array();
     foreach ($query->result() as $row) {
         $latlng = json_decode($row->latlng);
         $dis = distance($location_now['lat'], $location_now['lng'], $latlng->lat, $latlng->lng);
         $distance[$row->id_marker] = $dis;
         $d[] = $dis;
     }
     return $near_id__marker = array_search(min($d), $distance);
 }