public function install() { global $defaultCountry; if (!parent::install() or !$this->installExternalCarrier($this->_config) or !Configuration::updateValue('EXTERNAL_CARRIER_OVERCOST', 5) or !$this->registerHook('updateCarrier') or !$this->registerHook('extraCarrier') or !$this->registerHook('newOrder') or !$this->registerHook('processCarrier') or !$this->registerHook('orderDetailDisplayed')) { return false; } // Install SQL include dirname(__FILE__) . '/sql-install.php'; foreach ($sql as $s) { if (!Db::getInstance()->Execute($s)) { return false; } } // Create country settings foreach ($this->countries as $iso_code) { $id_country = Country::getByIso($iso_code); if ($id_country) { $kiala_country = new KialaCountry(); $kiala_country->id_country = $id_country; $kiala_country->preparation_delay = $this->default_preparation_delay; $kiala_country->active = 0; // Is this the merchant home country? if ($id_country == Configuration::get('PS_COUNTRY_DEFAULT')) { $kiala_country->pickup_country = 1; } $kiala_country->save(); } } $result = Db::getInstance()->getRow(' SELECT `id_tab` FROM `' . _DB_PREFIX_ . 'tab` WHERE `class_name` = "AdminKiala"'); if (!$result) { /*tab install */ $tab = new Tab(); $tab->class_name = 'AdminKiala'; $tab->id_parent = (int) Tab::getIdFromClassName('AdminOrders'); $tab->module = 'kiala'; $tab->name[(int) Configuration::get('PS_LANG_DEFAULT')] = $this->l('Kiala'); $tab->add(); @copy(_PS_MODULE_DIR_ . 'kiala/logo.gif', _PS_ADMIN_IMG_ . '/AdminKiala.gif'); } // If module isn't installed, set default values if (!Configuration::get('KIALA_VERSION')) { Configuration::updateValue('KIALA_VERSION', $this->version); Configuration::updateValue('KIALA_EXPORT_FOLDER', str_replace('\\', '/', _PS_MODULE_DIR_) . 'kiala/export/'); Configuration::updateValue('KIALA_EXPORT_SINGLE', '1'); Configuration::updateValue('KIALA_SECURITY_TOKEN', Tools::passwdGen(30)); Configuration::updateValue('KIALA_SEARCH_BY', 'order'); } return true; }