* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6594 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_CAN_LOAD_FILES_')) exit; class StatsGeoLocation extends Module { private $_map_path = 'img/map.png'; private $_cross_path = 'img/cross.png'; function __construct() { $this->name = 'statsgeolocation'; $this->tab = 'analytics_stats'; $this->version = 1.0; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Geolocation'); $this->description = $this->l('Display your customers\' origin'); } function install() { $countries = array('AT' => array('x' => 294, 'y' => 68), 'AU' => array('x' => 534, 'y' => 228), 'BE' => array('x' => 276, 'y' => 62), 'BO' => array('x' => 135, 'y' => 210), 'CA' => array('x' => 84, 'y' => 45), 'CH' => array('x' => 281, 'y' => 69), 'CI' => array('x' => 253, 'y' => 156), 'CN' => array('x' => 470, 'y' => 99), 'CZ' => array('x' => 293, 'y' => 63), 'DE' => array('x' => 285, 'y' => 61), 'DK' => array('x' => 284, 'y' => 51), 'ES' => array('x' => 260, 'y' => 85), 'FI' => array('x' => 310, 'y' => 35), 'FR' => array('x' => 271, 'y' => 69), 'GB' => array('x' => 265, 'y' => 55), 'GR' => array('x' => 308, 'y' => 87), 'HK' => array('x' => 491, 'y' => 123), 'IE' => array('x' => 253, 'y' => 58), 'IL' => array('x' => 334, 'y' => 106), 'IT' => array('x' => 292, 'y' => 80), 'JP' => array('x' => 531, 'y' => 92), 'KR' => array('x' => 509, 'y' => 93), 'LU' => array('x' => 277, 'y' => 63), 'NG' => array('x' => 282, 'y' => 153), 'NL' => array('x' => 278, 'y' => 58), 'NO' => array('x' => 283, 'y' => 41), 'NZ' => array('x' => 590, 'y' => 264), 'PL' => array('x' => 300, 'y' => 59), 'PT' => array('x' => 251, 'y' => 86), 'TG' => array('x' => 267, 'y' => 154), 'SE' => array('x' => 294, 'y' => 40), 'SG' => array('x' => 475, 'y' => 169), 'US' => array('x' => 71, 'y' => 87), 'ZA' => array('x' => 311, 'y' => 239)); if ( !parent::install() OR !$this->registerHook('AdminStatsModules')) return false; if (!Db::getInstance()->Execute(' CREATE TABLE `'._DB_PREFIX_.'location_coords` ( `id_location_coords` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `x` int(4) NOT NULL, `y` int(4) NOT NULL, `id_country` INTEGER UNSIGNED NOT NULL, PRIMARY KEY(`id_location_coords`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8')) return false; $flag = 0; $query = 'INSERT INTO `'._DB_PREFIX_.'location_coords` (`x`, `y`, `id_country`) VALUES '; $result = Db::getInstance()->ExecuteS('SELECT `id_country`, `iso_code` FROM `'._DB_PREFIX_.'country`;'); foreach ($result as $index => $row) { if (isset($countries[$row['iso_code']])) { if ($flag) $query .= ', '; $query .= '(\''.$countries[$row['iso_code']]['x'].'\', \''.$countries[$row['iso_code']]['y'].'\', \''.$row['id_country'].'\')'; $flag = 1; } } return Db::getInstance()->Execute($query.';'); } function uninstall() { if (!parent::uninstall()) return false; return (Db::getInstance()->Execute('DROP TABLE `'._DB_PREFIX_.'location_coords`')); } function hookAdminStatsModules() { $this->_html = '