private function filterAddressInput($array) { if (is_array($array)) { foreach ($array as &$value) { $value = DpdGroupDpdPostcodeMysql::applyFiltersForAddress($value); } } return $array; }
$controller = new DpdGroupCSVController(); $controller->generateCSV(); } if (Tools::getValue('action') == 'postcode-recommendation') { require_once _DPDGROUP_CLASSES_DIR_ . 'PostcodeSearch.php'; require_once _DPDGROUP_CLASSES_DIR_ . 'Address.php'; require_once _DPDGROUP_CLASSES_DIR_ . 'Mysql.php'; require_once _DPDGROUP_CLASSES_DIR_ . 'CachedData.php'; require_once _DPDGROUP_CLASSES_DIR_ . 'PostcodeSearch.php'; $data = array(); $address = array('city' => Tools::getValue('city'), 'country_id' => Tools::getValue('id_country'), 'region_id' => Tools::getValue('id_state'), 'lang_id' => (int) Context::getContext()->language->id, 'address' => Tools::getValue('address1') . ' ' . Tools::getValue('address2')); $postcode_search = new DpdGroupPostcodeSearch(); $results = $postcode_search->findAllSimilarAddressesForAddress($address); if (!$results) { die(Tools::jsonEncode($data)); } foreach ((array) $results as $address) { $data[] = array('label' => ($address['address'] ? $address['address'] . ', ' : '') . $address['city'] . ', ' . $address['region'], 'postcode' => $address['postcode']); } die(Tools::jsonEncode($data)); } if (Tools::getValue('action') == 'validate_postcode') { $psotcode = Tools::getValue('dpdpostcode'); $result = true; require_once _DPDGROUP_CLASSES_DIR_ . 'Mysql.php'; $model = new DpdGroupDpdPostcodeMysql(); if (!DpdGroupDpdPostcodeMysql::postcodeExistsInDB($psotcode)) { $result = false; } die(Tools::jsonEncode(array('is_valid' => $result))); }
private function isEnabledAutocompleteForPostcode($country_name) { return DpdGroupDpdPostcodeMysql::applyFiltersForAddress($country_name) == DpdGroupSearch::ENABLED_COUNTRY; }