load->helper('url'); $this->listobjects(); } protected function renderGeoServicesPage($page_name, $data) { $this->load->view('admin/view_admin_header', $data); $this->load->view('geoservices/' . $page_name, $data); $this->load->view('admin/view_admin_footer', $data); } public function listobjects() { $data = array(); $this->load->library('table'); $this->table->set_template($this->template); $data["page_title"] = "List Geofence Objects"; $mysql = "SELECT * FROM geofence_area_country"; $query = $this->read_replica->query($mysql); $data["geofence_area_country"] = $this->table->generate($query); $mysql = "SELECT a.id,b.country,a.name, c.name AS transport_provider "; $mysql.= " FROM country_services a, geofence_area_country b, transport_providers c"; $mysql.= " WHERE b.id=a.country_id AND c.id=a.transport_provider_id"; $query = $this->read_replica->query($mysql); $data["country_services"] = $this->table->generate($query); $mysql = "SELECT * FROM geofence_area_city"; $query = $this->read_replica->query($mysql); $data["geofence_area_city"] = $this->table->generate($query); $mysql = "SELECT a.id,b.country,b.city,a.name, c.name AS transport_provider "; $mysql.= " FROM city_services a, geofence_area_city b, transport_providers c"; $mysql.= " WHERE b.id=a.city_id AND c.id=a.transport_provider_id"; $query = $this->read_replica->query($mysql); $data["city_services"] = $this->table->generate($query); $this->renderGeoServicesPage("view_listobjects",$data); } public function checkgps() { $data = array(); $this->load->library('table'); $this->table->set_template($this->template); global $savvyext; $httpAuthToken = $savvyext->cfgReadChar('system.oauth2_token'); $encryptionAlg = $savvyext->cfgReadChar('encryption.algorithm'); $encryptionKey = $savvyext->cfgReadChar('encryption.key'); $encryptionIV = $savvyext->cfgReadChar('encryption.iv'); $api_url = $savvyext->cfgReadChar('system.api_url'); $data['latitude'] = 37.777412; $data['longitude'] = -122.472961; if ($this->input->post()) { $data['latitude'] = $this->input->post('latitude'); $data['longitude'] = $this->input->post('longitude'); } $url = $api_url . "/booking/api/options/?latitude=" . $data['latitude'] . "&longitude=" . $data['longitude']; $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_VERBOSE, false); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Authorization: Server-Token ' . $httpAuthToken, "client_id: BackOffice" ) ); $body = curl_exec($ch); $result = json_decode($body, true); $payload = openssl_decrypt( hex2bin( $result['payload'] ), $encryptionAlg, $encryptionKey, OPENSSL_RAW_DATA, $encryptionIV ); $data["payload"] = json_decode($payload, true); $data["page_title"] = "Check Services by GPS coordinates"; $this->renderGeoServicesPage("view_checkgps",$data); } }