name = 'logistics'; $this->tab = 'shipping_logistics'; $this->version = '2.0'; $this->author = 'Antadis'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Logistics'); $this->description = $this->l('Allows to manage parcels'); } public function install() { # Add admin tabs $tabs_i18n = array( 'fr' => 'Gestion des envois', 'en' => 'Parcel management', ); $t = new Tab(); $t->id_parent = (int) Tab::getIdFromClassName('AdminOrders'); $st->position = (int) Tab::getNewLastPosition($st->id_parent); $t->active = TRUE; $t->module = 'logistics'; $t->class_name = 'AdminLogistics'; foreach(Language::getLanguages() as $lang) { if(isset($tabs_i18n[$lang['iso_code']])) { $t->name[$lang['id_lang']] = $tabs_i18n[$lang['iso_code']]; } else { $t->name[$lang['id_lang']] = $tabs_i18n['en']; } } $t->save(); return $this->installCarriers() && parent::install() && $this->registerHook('updateCarrier'); } private function installCarriers() { return // La Poste Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'lapostews` ( `id_order_detail` INTEGER UNSIGNED NOT NULL, `id_employee` INTEGER UNSIGNED NOT NULL, `quantity` INTEGER UNSIGNED NOT NULL, `shipping_number` VARCHAR(64) NOT NULL, `date_add` DATETIME NOT NULL, PRIMARY KEY(`id_order_detail`, `date_add`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ') && Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'lapostews_pr` ( `id_pr` VARCHAR(6) NOT NULL, `name` VARCHAR(255) NOT NULL, `address1` VARCHAR(255) NOT NULL, `address2` VARCHAR(255) NOT NULL, `address3` VARCHAR(255) NOT NULL, `address4` VARCHAR(255) NOT NULL, `postcode` VARCHAR(6) NOT NULL, `city` VARCHAR(255) NOT NULL, `xcoords` VARCHAR(24) NOT NULL, `ycoords` VARCHAR(24) NOT NULL, `type` VARCHAR(6) NOT NULL, `code1` VARCHAR(8) NOT NULL, `code2` VARCHAR(8) NOT NULL, PRIMARY KEY(`id_pr`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ') // Exapaq && Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'exapaqws` ( `id_order_detail` INTEGER UNSIGNED NOT NULL, `id_employee` INTEGER UNSIGNED NOT NULL, `quantity` INTEGER UNSIGNED NOT NULL, `shipping_number` VARCHAR(64) NOT NULL, `date_add` DATETIME NOT NULL, PRIMARY KEY(`id_order_detail`, `date_add`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ') && Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'exapaqws_shippingnumber` ( `shipping_number` INTEGER NOT NULL AUTO_INCREMENT, `id_order` INTEGER NOT NULL, PRIMARY KEY (`shipping_number`), INDEX (`id_order`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ') && Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'exapaqws_route` ( `iso_code` VARCHAR(2) NOT NULL, `lpfx` VARCHAR(3) NOT NULL, `postcode_start` VARCHAR(10) NOT NULL, `postcode_end` VARCHAR(10) NOT NULL, `tri1` VARCHAR(1) NOT NULL, `ligne1` VARCHAR(2) NOT NULL, `tri2` VARCHAR(1) NOT NULL, `ligne2` VARCHAR(2) NOT NULL, `ac` VARCHAR(3) NOT NULL, `acprint` VARCHAR(3) NOT NULL, `tour` VARCHAR(3) NOT NULL, `tourprint` VARCHAR(3) NOT NULL, `pretri` VARCHAR(3) NOT NULL, `cbtri` VARCHAR(4) NOT NULL, `msg` VARCHAR(1) NOT NULL, INDEX (`iso_code`), INDEX (`postcode_start`), INDEX (`postcode_end`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ') && Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'exapaqws_parcel_route` ( `shipping_number` VARCHAR(64) NOT NULL, `id_order` INTEGER NOT NULL, `weight` DECIMAL(20,6) NOT NULL, `iso_code` VARCHAR(2) NOT NULL, `lpfx` VARCHAR(3) NOT NULL, `tri1` VARCHAR(1) NOT NULL, `ligne1` VARCHAR(2) NOT NULL, `tri2` VARCHAR(1) NOT NULL, `ligne2` VARCHAR(2) NOT NULL, `ac` VARCHAR(3) NOT NULL, `acprint` VARCHAR(3) NOT NULL, `tour` VARCHAR(3) NOT NULL, `tourprint` VARCHAR(3) NOT NULL, `pretri` VARCHAR(3) NOT NULL, `cbtri` VARCHAR(4) NOT NULL, `msg` VARCHAR(255) NOT NULL, `date_add` DATETIME NOT NULL, INDEX (`id_order`), INDEX (`shipping_number`), INDEX (`iso_code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ') // Global && Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'logistics_shipping` ( `carrier` VARCHAR(32) NOT NULL, `delivery_mode` VARCHAR(16) NOT NULL, `value` varchar(64) NOT NULL, PRIMARY KEY (`carrier`, `delivery_mode`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 '); } private function uninstallCarriers() { /*Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lapostews`'); Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lapostews_pr`'); Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'exapaqws`'); Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'exapaqws_route`'); Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'exapaqws_shippingnumber`'); Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'exapaqws_parcel_route`'); Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'logistics_shipping`');*/ return TRUE; } public function uninstall() { return $this->uninstallCarriers() && parent::uninstall(); } public function getContent() { global $cookie; if(Tools::isSubmit('submitUpdate')) { /* La Poste */ Configuration::updateValue('LAPOSTEWS_CARRIERS', serialize(Tools::getValue('laposte_carriers', array()))); Configuration::updateValue('LAPOSTEWS_CONTRACT', Tools::getValue('laposte_contract')); Configuration::updateValue('LAPOSTEWS_API_PASSWORD', Tools::getValue('laposte_apipassword')); Configuration::updateValue('LAPOSTEWS_API_CONTRACT', Tools::getValue('laposte_apicontract')); Configuration::updateValue('LAPOSTEWS_API_PASSWORD2', Tools::getValue('laposte_apipassword2')); Configuration::updateValue('LAPOSTEWS_API_CONTRACT2', Tools::getValue('laposte_apicontract2')); Configuration::updateValue('LAPOSTEWS_MODE', Tools::getValue('laposte_mode')); Configuration::updateValue('LAPOSTEWS_COMMERCIALNAME', Tools::getValue('laposte_commercialname')); Configuration::updateValue('LAPOSTEWS_SHIPPING_SITE', Tools::getValue('laposte_shippingsite')); Configuration::updateValue('LAPOSTEWS_SHIPPING_SITE_CODE', Tools::getValue('laposte_shippingsite_code')); Configuration::updateValue('LAPOSTEWS_SUMMARIES_COUNT', Tools::getValue('laposte_summaries_count')); Configuration::updateValue('LAPOSTEWS_EXP_ADDR1', Tools::getValue('laposte_exp_addr1')); Configuration::updateValue('LAPOSTEWS_EXP_ADDR2', Tools::getValue('laposte_exp_addr2')); Configuration::updateValue('LAPOSTEWS_EXP_CITY', Tools::getValue('laposte_exp_city')); Configuration::updateValue('LAPOSTEWS_EXP_COMPANY', Tools::getValue('laposte_exp_company')); Configuration::updateValue('LAPOSTEWS_EXP_COUNTRY', Tools::getValue('laposte_exp_country')); Configuration::updateValue('LAPOSTEWS_EXP_EMAIL', Tools::getValue('laposte_exp_email')); Configuration::updateValue('LAPOSTEWS_EXP_FIRSTNAME', Tools::getValue('laposte_exp_firstname')); Configuration::updateValue('LAPOSTEWS_EXP_LASTNAME', Tools::getValue('laposte_exp_lastname')); Configuration::updateValue('LAPOSTEWS_EXP_PHONE', Tools::getValue('laposte_exp_phone')); Configuration::updateValue('LAPOSTEWS_EXP_POSTALCODE', Tools::getValue('laposte_exp_postalcode')); Configuration::updateValue('LAPOSTEWS_RANGE_0_P', Tools::getValue('laposte_range_0_p')); Configuration::updateValue('LAPOSTEWS_RANGE_1_P', Tools::getValue('laposte_range_1_p')); Configuration::updateValue('LAPOSTEWS_RANGE_2_P', Tools::getValue('laposte_range_2_p')); Configuration::updateValue('LAPOSTEWS_RANGE_3_P', Tools::getValue('laposte_range_3_p')); Configuration::updateValue('LAPOSTEWS_RANGE_4_P', Tools::getValue('laposte_range_4_p')); // Db::getInstance()->ExecuteS(' // INSERT INTO `'._DB_PREFIX_.'logistics_shipping` // VALUES ( // "laposte", // "0", // '.(int) Tools::getValue('laposte_range_0_s').' // ) // ON DUPLICATE KEY UPDATE // `value` = '.(int) Tools::getValue('laposte_range_0_s').' // '); // Db::getInstance()->ExecuteS(' // INSERT INTO `'._DB_PREFIX_.'logistics_shipping` // VALUES ( // "laposte", // "1", // '.(int) Tools::getValue('laposte_range_1_s').' // ) // ON DUPLICATE KEY UPDATE // `value` = '.(int) Tools::getValue('laposte_range_1_s').' // '); // Db::getInstance()->ExecuteS(' // INSERT INTO `'._DB_PREFIX_.'logistics_shipping` // VALUES ( // "laposte", // "2", // '.(int) Tools::getValue('laposte_range_2_s').' // ) // ON DUPLICATE KEY UPDATE // `value` = '.(int) Tools::getValue('laposte_range_2_s').' // '); // Db::getInstance()->ExecuteS(' // INSERT INTO `'._DB_PREFIX_.'logistics_shipping` // VALUES ( // "laposte", // "3", // '.(int) Tools::getValue('laposte_range_3_s').' // ) // ON DUPLICATE KEY UPDATE // `value` = '.(int) Tools::getValue('laposte_range_3_s').' // '); // Db::getInstance()->ExecuteS(' // INSERT INTO `'._DB_PREFIX_.'logistics_shipping` // VALUES ( // "laposte", // "4", // '.(int) Tools::getValue('laposte_range_4_s').' // ) // ON DUPLICATE KEY UPDATE // `value` = '.(int) Tools::getValue('laposte_range_4_s').' // '); Configuration::updateValue('LAPOSTEWS_RANGE_0_E', sprintf('%08d', (int) Tools::getValue('laposte_range_0_e'))); Configuration::updateValue('LAPOSTEWS_RANGE_1_E', sprintf('%08d', (int) Tools::getValue('laposte_range_1_e'))); Configuration::updateValue('LAPOSTEWS_RANGE_2_E', sprintf('%08d', (int) Tools::getValue('laposte_range_2_e'))); Configuration::updateValue('LAPOSTEWS_RANGE_3_E', sprintf('%08d', (int) Tools::getValue('laposte_range_3_e'))); Configuration::updateValue('LAPOSTEWS_RANGE_4_E', sprintf('%08d', (int) Tools::getValue('laposte_range_4_e'))); /* Exapaq */ Configuration::updateValue('EXAPAQWS_CARRIERS', serialize(Tools::getValue('exapaq_carriers', array()))); Configuration::updateValue('EXAPAQWS_EXP_ADDR1', Tools::getValue('exapaq_exp_addr1')); Configuration::updateValue('EXAPAQWS_EXP_ADDR2', Tools::getValue('exapaq_exp_addr2')); Configuration::updateValue('EXAPAQWS_EXP_CITY', Tools::getValue('exapaq_exp_city')); Configuration::updateValue('EXAPAQWS_EXP_COMPANY', Tools::getValue('exapaq_exp_company')); Configuration::updateValue('EXAPAQWS_EXP_COUNTRY', Tools::getValue('exapaq_exp_country')); Configuration::updateValue('EXAPAQWS_EXP_EMAIL', Tools::getValue('exapaq_exp_email')); Configuration::updateValue('EXAPAQWS_EXP_FIRSTNAME', Tools::getValue('exapaq_exp_firstname')); Configuration::updateValue('EXAPAQWS_EXP_LASTNAME', Tools::getValue('exapaq_exp_lastname')); Configuration::updateValue('EXAPAQWS_EXP_PHONE', Tools::getValue('exapaq_exp_phone')); Configuration::updateValue('EXAPAQWS_EXP_POSTALCODE', Tools::getValue('exapaq_exp_postalcode')); // Db::getInstance()->ExecuteS(' // INSERT INTO `'._DB_PREFIX_.'logistics_shipping` // VALUES ( // "exapaq", // "b2b", // '.(int) Tools::getValue('exapaq_b2b_shippinglow').' // ) // ON DUPLICATE KEY UPDATE // `value` = '.(int) Tools::getValue('exapaq_b2b_shippinglow').' // '); Configuration::updateValue('EXAPAQWS_B2B_SHIPPINGHIGH', Tools::getValue('exapaq_b2b_shippinghigh')); Configuration::updateValue('EXAPAQWS_B2B_AGENCYCODE', Tools::getValue('exapaq_b2b_agency')); Configuration::updateValue('EXAPAQWS_B2B_CHARGING_ACCOUNT', Tools::getValue('exapaq_b2b_charging')); Configuration::updateValue('EXAPAQWS_B2B_COUNTRY_RETURN', Tools::getValue('exapaq_b2b_creturn')); Configuration::updateValue('EXAPAQWS_B2B_COUNTRY_AGENCY', Tools::getValue('exapaq_b2b_cagency')); // Db::getInstance()->ExecuteS(' // INSERT INTO `'._DB_PREFIX_.'logistics_shipping` // VALUES ( // "exapaq", // "b2c", // '.(int) Tools::getValue('exapaq_b2c_shippinglow').' // ) // ON DUPLICATE KEY UPDATE // `value` = '.(int) Tools::getValue('exapaq_b2c_shippinglow').' // '); Configuration::updateValue('EXAPAQWS_B2C_SHIPPINGHIGH', Tools::getValue('exapaq_b2c_shippinghigh')); Configuration::updateValue('EXAPAQWS_B2C_AGENCYCODE', Tools::getValue('exapaq_b2c_agency')); Configuration::updateValue('EXAPAQWS_B2C_CHARGING_ACCOUNT', Tools::getValue('exapaq_b2c_charging')); Configuration::updateValue('EXAPAQWS_B2C_COUNTRY_RETURN', Tools::getValue('exapaq_b2c_creturn')); Configuration::updateValue('EXAPAQWS_B2C_COUNTRY_AGENCY', Tools::getValue('exapaq_b2c_cagency')); /* @Mondial relay */ Configuration::updateValue('MONDIALRELAY_EXP_COMPANY', Tools::getValue('mondialrelay_exp_company')); Configuration::updateValue('MONDIALRELAY_EXP_FIRSTNAME', Tools::getValue('mondialrelay_exp_firstname')); Configuration::updateValue('MONDIALRELAY_EXP_LASTNAME', Tools::getValue('mondialrelay_exp_lastname')); Configuration::updateValue('MONDIALRELAY_EXP_ADDR1', Tools::getValue('mondialrelay_exp_addr1')); Configuration::updateValue('MONDIALRELAY_EXP_ADDR2', Tools::getValue('mondialrelay_exp_addr2')); Configuration::updateValue('MONDIALRELAY_EXP_POSTALCODE', Tools::getValue('mondialrelay_exp_postalcode')); Configuration::updateValue('MONDIALRELAY_EXP_CITY', Tools::getValue('mondialrelay_exp_city')); Configuration::updateValue('MONDIALRELAY_EXP_COUNTRY', Tools::getValue('mondialrelay_exp_country')); Configuration::updateValue('MONDIALRELAY_EXP_PHONE', Tools::getValue('mondialrelay_exp_phone')); Configuration::updateValue('MONDIALRELAY_EXP_EMAIL', Tools::getValue('mondialrelay_exp_email')); Configuration::updateValue('MONDIALRELAY_SHIPPING_SITE', Tools::getValue('mondialrelay_shippingsite')); Configuration::updateValue('MONDIALRELAY_SHIPPING_SITE_CODE', Tools::getValue('mondialrelay_shippingsite_code')); Configuration::updateValue('MONDIALRELAY_SUMMARIES_COUNT', Tools::getValue('mondialrelay_summaries_count')); Configuration::updateValue('MONDIALRELAY_SHIPPINGLOW', Tools::getValue('mondialrelay_shippinglow')); Configuration::updateValue('MONDIALRELAY_SHIPPINGHIGH', Tools::getValue('mondialrelay_shippinghigh')); Configuration::updateValue('MONDIALRELAYWS_CARRIERS', serialize(Tools::getValue('mondialrelay_carriers', array()))); Configuration::updateValue('MONDIALRELAYWS_FTP_HOST', Tools::getValue('mondialrelay_ftp_host')); Configuration::updateValue('MONDIALRELAYWS_FTP_LOGIN', Tools::getValue('mondialrelay_ftp_login')); Configuration::updateValue('MONDIALRELAYWS_FTP_PASSWORD', Tools::getValue('mondialrelay_ftp_password')); // foreach(Tools::getValue('employee', array()) as $id_employee => $queue) { // Configuration::updateValue('LOGISTICS_QUEUE_'.(int) $id_employee, $queue); // } $lock = array(); foreach(explode(', ', Tools::getValue('lock_products')) as $item) { $lock[] = (int) $item; } Configuration::updateValue('LOGISTICS_LOCK', serialize(implode(',', $lock))); $this->_html = '
'.$this->l('Configuration updated successfully').'