public function getContent() { if (!extension_loaded('soap') || !class_exists('SoapClient')) { return $this->displayError($this->l('SOAP extension should be enabled on your server to use this module.')); } $output = ''; $this->configured = Configuration::get('SEUR_Configured'); if (Tools::isSubmit('submitToDefault')) { $this->setDefaultWS(); } elseif (Tools::isSubmit('submitWebservices')) { $this->storeWS(); } elseif (Tools::isSubmit('submitConfiguration')) { $update_seur_carriers = array(); $delivery = Tools::getValue('seur_cod'); if (Module::isInstalled('seurcashondelivery') == false && $delivery) { $output .= $this->displayError($this->l('To enable Cash on delivery you must install the module "SEUR Cash on delivery".')); $delivery = '0'; } $sql_update_configuration_table = ' UPDATE `' . _DB_PREFIX_ . 'seur_configuration` SET `pos` =' . (int) Tools::getValue('pos', 1) . ', `international_orders` =' . (int) Tools::getValue('international_orders') . ', `seur_cod` =' . (int) $delivery . ', `notification_advice_radio` =' . (int) Tools::getValue('notification_advice_radio') . ', `notification_distribution_radio` =' . (int) Tools::getValue('notification_distribution_radio') . ', `print_type` =' . (int) Tools::getValue('print_type') . ', `pickup` =' . (int) Tools::getValue('pickup') . ', `advice_checkbox` =' . (int) (Tools::getValue('advice_checkbox') == 'on' ? 1 : 0) . ', `distribution_checkbox` =' . (int) (Tools::getValue('distribution_checkbox') == 'on' ? 1 : 0); if (Context::getContext()->shop->isFeatureActive()) { $sql_update_configuration_table .= ', `id_shop` =' . (int) $this->context->shop->id; } if (Tools::getValue('id_seur_carrier')) { $update_seur_carriers[] = array('id' => (int) Tools::getValue('id_seur_carrier'), 'type' => 'SEN'); } if (Tools::getValue('id_seur_carrier_canarias_m')) { $update_seur_carriers[] = array('id' => (int) Tools::getValue('id_seur_carrier_canarias_m'), 'type' => 'SCN'); } if (Tools::getValue('id_seur_carrier_canarias_48')) { $update_seur_carriers[] = array('id' => (int) Tools::getValue('id_seur_carrier_canarias_48'), 'type' => 'SCE'); } if (Tools::getValue('id_seur_carrier_pos')) { $update_seur_carriers[] = array('id' => (int) Tools::getValue('id_seur_carrier_pos'), 'type' => 'SEP'); } if (!empty($update_seur_carriers)) { SeurLib::updateSeurCarriers($update_seur_carriers); } $sql_update_configuration_table .= ' WHERE `id_seur_configuration` = 1'; $this->configured = 1; Configuration::updateValue('SEUR_Configured', 1); Configuration::updateValue('SEUR_REMCAR_CARGO', (double) Tools::getValue('contra_porcentaje')); Configuration::updateValue('SEUR_REMCAR_CARGO_MIN', (double) Tools::getValue('contra_minimo')); Configuration::updateValue('SEUR_PRINTER_NAME', Tools::getValue('printer_name') ? pSQL(Tools::getValue('printer_name')) : 'Generic / Text Only'); Configuration::updateValue('SEUR_FREE_WEIGTH', (double) Tools::getValue('peso_gratis')); Configuration::updateValue('SEUR_FREE_PRICE', (double) Tools::getValue('precio_gratis')); $seur_carriers = array(); foreach ($update_seur_carriers as $value) { $seur_carriers[$value['type']] = $value['id']; } $carrier_seur = new Carrier((int) $seur_carriers['SEN']); $carrier_pos = new Carrier((int) $seur_carriers['SEP']); if (Tools::getValue('international_orders') && SeurLib::getConfigurationField('international_orders') != Tools::getValue('international_orders') && SeurLib::getConfigurationField('tarifa') && Validate::isLoadedObject($carrier_seur)) { if (Tools::getValue('international_orders') && Tools::getValue('international_orders') == 1) { $carrier_seur->addZone((int) Zone::getIdByName('Europe')); $carrier_seur->save(); } elseif (Tools::getValue('international_orders') == 0) { $carrier_seur->deleteZone((int) Zone::getIdByName('Europe')); $carrier_seur->save(); } } if (in_array(Tools::getValue('pos'), array(0, 1)) == true && Validate::isLoadedObject($carrier_pos)) { $carrier_pos->active = (int) Tools::getValue('pos'); $carrier_pos->save(); } if (!Db::getInstance()->Execute($sql_update_configuration_table)) { $output .= $this->displayError($this->l('Cannot update.')); } else { $output .= $this->displayConfirmation($this->l('Configuration updated.')); } } elseif (Tools::isSubmit('submitLogin')) { $sqlUpdateDataTable = 'UPDATE `' . _DB_PREFIX_ . 'seur_merchant` SET `nif_dni` ="' . pSQL(Tools::strtoupper(Tools::getValue('nif_dni'))) . '", `name` ="' . pSQL(Tools::strtoupper(Tools::getValue('name'))) . '", `first_name` ="' . pSQL(Tools::strtoupper(Tools::getValue('first_name'))) . '", `franchise` ="' . (Tools::getValue('franchise') ? pSQL(Tools::getValue('franchise')) : pSQL(Tools::getValue('franchise_cfg'))) . '", `company_name` ="' . pSQL(Tools::strtoupper(Tools::getValue('company_name'))) . '", `street_type` ="' . pSQL(Tools::getValue('street_type')) . '", `street_name` ="' . pSQL(Tools::strtoupper(Tools::getValue('street_name'))) . '", `street_number` ="' . pSQL(Tools::getValue('street_number')) . '", ' . (Tools::getValue('staircase') ? '`staircase` ="' . pSQL(Tools::strtoupper(Tools::getValue('staircase'))) . '",' : ' ') . ' `floor` ="' . pSQL(Tools::getValue('floor')) . '", `door` ="' . pSQL(Tools::getValue('door')) . '", `post_code` ="' . (Tools::getValue('post_code') ? pSQL(Tools::getValue('post_code')) : pSQL(Tools::getValue('post_code_cfg'))) . '", `town` ="' . (Tools::getValue('town') ? pSQL(Tools::strtoupper(Tools::getValue('town'))) : pSQL(Tools::strtoupper(Tools::getValue('town_cfg')))) . '", `state` ="' . (Tools::getValue('state') ? pSQL(Tools::strtoupper(Tools::getValue('state'))) : pSQL(Tools::strtoupper(Tools::getValue('state_cfg')))) . '", `country` ="' . (Tools::getValue('country') ? pSQL(Tools::strtoupper(Tools::getValue('country'))) : pSQL(Tools::strtoupper(Tools::getValue('country_cfg')))) . '", `phone` ="' . (int) Tools::getValue('phone') . '", `ccc` ="' . (int) Tools::getValue('ccc_cfg') . '", `cit` ="' . (int) Tools::getValue('ci') . '", ' . (Tools::getValue('fax') ? '`fax` =' . (int) Tools::getValue('fax') . ',' : ' ') . ' `email` ="' . pSQL(Tools::strtolower(Tools::getValue('email'))) . '"'; if (Tools::getValue('user_cfg') && Tools::getValue('pass_cfg')) { $sqlUpdateDataTable .= ', `USER`="' . pSQL(Tools::strtolower(Tools::getValue('user_cfg'))) . '", `PASS`="' . pSQL(Tools::strtolower(Tools::getValue('pass_cfg'))) . '" '; } $sqlUpdateDataTable .= "WHERE `id_seur_datos` = 1;"; if (Tools::getValue('user_seurcom') && Tools::getValue('pass_seurcom')) { Configuration::updateValue('SEUR_WS_USERNAME', Tools::getValue('user_seurcom')); Configuration::updateValue('SEUR_WS_PASSWORD', Tools::getValue('pass_seurcom')); } if (!Db::getInstance()->Execute($sqlUpdateDataTable)) { $output .= $this->displayError($this->l('Database fail.')); } else { $output .= $this->displayConfirmation($this->l('Configuration updated.')); } $this->stateConfigured = 1; } elseif (Tools::isSubmit('submitWithRanges')) { if (Range::setRanges()) { $output .= $this->displayConfirmation($this->l('Prices configured correctly. ')); SeurLib::setConfigurationField('tarifa', 1); } $this->configured = 1; Configuration::updateValue('SEUR_Configured', 1); die(Tools::redirectAdmin($this->getModuleLink('AdminModules'))); } elseif (Tools::isSubmit('submitWithoutRanges')) { $this->configured = 1; Configuration::updateValue('SEUR_Configured', 1); } return $this->displayForm(); }