language->load('information/support'); $this->data = array_merge($this->data, $this->load->language('locator/locator')); // Load models $this->load->model('locator/agency'); $this->load->model('locator/region'); $this->load->model('locator/category'); $this->load->model('locator/organization'); $this->load->model('locator/country'); $this->load->model('locator/continent'); // // Request params // // Type if (isset($this->request->get['type']) && !empty($this->request->get['type'])) { $type = $this->request->get['type']; } else { $type = constant('ModelLocatorAgency::TypeSales'); } // Country if (isset($this->request->get['country_id']) && !empty($this->request->get['country_id'])) { $country_id = $this->request->get['country_id']; } else { $country_id = constant('ModelLocatorCountry::CountryItaly'); } // Region if (isset($this->request->get['region_id'])) { $region_id = $this->request->get['region_id']; } else { $region_id = ""; } // Continent if (isset($this->request->get['continent_id'])) { $continent_id = $this->request->get['continent_id']; } else { $continent_id = ""; } // Product line if (isset($this->request->get['category_id'])) { $category_id = $this->request->get['category_id']; } else { $category_id = ""; } // Sales organization if (isset($this->request->get['organization_id'])) { $organization_id = $this->request->get['organization_id']; } else { $organization_id = ""; } // Page if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } // Breadcrumbs $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false ); $this->data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title'), 'href' => $this->url->link('locator/locator'), 'separator' => $this->language->get('text_separator') ); // Document settings $this->document->setTitle($this->language->get('heading_title')); //$this->document->setDescription($this->language->get('locator_description')); //$this->document->setKeywords($this->language->get('locator_keyword')); $this->document->addStyle('catalog/view/theme/default/stylesheet/locator.css'); $this->document->addScript('catalog/view/javascript/jquery/jquery.total-storage.min.js'); // Data $this->data['type'] = $type; $this->data['type_sales'] = constant('ModelLocatorAgency::TypeSales'); $this->data['type_support'] = constant('ModelLocatorAgency::TypeSupport'); $this->data['country_id'] = $country_id; $this->data['country_italy'] = constant('ModelLocatorCountry::CountryItaly'); $this->data['country_uk'] = constant('ModelLocatorCountry::CountryUK'); $this->data['country_korea'] = constant('ModelLocatorCountry::CountryKorea'); $this->data['country_international'] = constant('ModelLocatorCountry::CountryInternational'); $this->data['filter_countries'] = $this->model_locator_country->getCountriesByContinent($continent_id); $this->data['is_country_international'] = $this->model_locator_country->isInternational($country_id); $this->data['url'] = $this->url->link('locator/locator', ''); $this->data['region_id'] = $region_id; $this->data['filter_regions'] = $this->model_locator_region->getRegionsByCountry($country_id); $this->data['continent_id'] = $continent_id; $this->data['filter_continents'] = $this->model_locator_continent->getContinents(); $this->data['category_id'] = $category_id; $this->data['filter_categories'] = $this->model_locator_category->getProductLines(); $this->data['organization_id'] = $organization_id; $this->data['filter_organizations'] = $this->model_locator_organization->getSalesOrganizations(); // Filters $limit = constant('ModelLocatorAgency::QueryLimit'); $data = array( 'type' => $type, 'country_id' => $country_id, 'region_id' => $region_id, 'continent_id' => $continent_id, 'category_id' => $category_id, 'organization_id' => $organization_id, 'start' => ($page - 1) * $limit ); // Total number of agencies $total = $this->model_locator_agency->getTotalAgencies($data); //echo("getTotalAgencies: " . $total); // Get agencies $results = $this->model_locator_agency->getAgencies($data); //print_r($results); // Agencies $this->data['agencies'] = array(); // For each agency foreach ($results as $result) { // Agency data $this->data['agencies'][] = array( 'agency_id' => $result['agency_id'], 'name' => $result['name'], 'address' => $result['address'], 'city' => $result['city'], 'postcode' => $result['postcode'], 'latitude' => $result['latitude'], 'longitude' => $result['longitude'], 'contacts' => $this->model_locator_agency->getAgencyContacts($result['agency_id']), 'regions' => $this->model_locator_region->getRegionsByAgency($result['agency_id'], $organization_id), 'countries' => $this->model_locator_country->getCountriesByAgency($result['agency_id']) //'categories' => $this->model_locator_agency->getAgencyProductLines($result['agency_id']), //'organizations' => $this->model_locator_agency->getAgencySalesOrganization($result['agency_id']), ); } // Pagination $pagination = new Pagination(); $pagination->total = $total; $pagination->page = $page; $pagination->limit = $limit; $pagination->text = $this->language->get('text_pagination'); $pagination_query_string = str_replace("route=locator/locator", "", $_SERVER['QUERY_STRING']); $pagination_query_string = str_replace("&", "&", $pagination_query_string); $pagination_query_string = preg_replace("/&page=[0-9]+/", "", $pagination_query_string); $pagination->url = $this->url->link('locator/locator', $pagination_query_string . '&page={page}'); $this->data['pagination'] = $pagination->render(); // Set template if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/locator/locator.tpl')) { $this->template = $this->config->get('config_template') . '/template/locator/locator.tpl'; } else { $this->template = 'default/template/locator/locator.tpl'; } $this->children = array( 'common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header' ); $this->response->setOutput($this->render()); } public function customlocator() { $zone = $_POST['zone']; $productLine = $_POST['productLine']; $salesOrganization = $_POST['salesOrganization']; $type = $_POST['type']; $this->load->model('locator/agency'); $arr = $this->model_locator_agency->generateXml($zone,$productLine,$salesOrganization,$type); function filterarray(&$value) { $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); } array_walk_recursive($arr, "filterarray"); $output = ""; $output .= "\n"; foreach ($arr as $agency) { $output .= "\n"; } $output .= ""; $fp = fopen('l/locator.xml', 'w+'); fwrite($fp, $output); fclose($fp); //echo json_encode($arr); } protected function validate() { return true; } } ?>