/** * Assign template vars for simplified stores */ protected function assignStoresSimplified() { $stores = Db::getInstance()->executeS(' SELECT s.*, cl.name country, st.iso_code state FROM ' . _DB_PREFIX_ . 'store s ' . Shop::addSqlAssociation('store', 's') . ' LEFT JOIN ' . _DB_PREFIX_ . 'country_lang cl ON (cl.id_country = s.id_country) LEFT JOIN ' . _DB_PREFIX_ . 'state st ON (st.id_state = s.id_state) WHERE s.active = 1 AND cl.id_lang = ' . (int) $this->context->language->id); $addresses_formated = array(); foreach ($stores as &$store) { $address = new Address(); $address->country = Country::getNameById($this->context->language->id, $store['id_country']); $address->address1 = $store['address1']; $address->address2 = $store['address2']; $address->postcode = $store['postcode']; $address->city = $store['city']; $addresses_formated[$store['id_store']] = AddressFormat::getFormattedLayoutData($address); $store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_ . (int) $store['id_store'] . '.jpg'); if ($working_hours = $this->renderStoreWorkingHours($store)) { $store['working_hours'] = $working_hours; } } $this->context->smarty->assign(array('simplifiedStoresDiplay' => true, 'stores' => $stores, 'addresses_formated' => $addresses_formated)); }
/** * Build an address * * @param int $id_address Existing address id in order to load object (optional) */ public function __construct($id_address = null, $id_lang = null) { parent::__construct($id_address); /* Get and cache address country name */ if ($this->id) { $this->country = Country::getNameById($id_lang ? $id_lang : Configuration::get('PS_LANG_DEFAULT'), $this->id_country); } }
public function install() { Configuration::updateValue('BLOCKCONTACTINFOS_COMPANY', Configuration::get('PS_SHOP_NAME')); Configuration::updateValue('BLOCKCONTACTINFOS_ADDRESS', trim(preg_replace('/ +/', ' ', Configuration::get('PS_SHOP_ADDR1') . ' ' . Configuration::get('PS_SHOP_ADDR2') . "\n" . Configuration::get('PS_SHOP_CODE') . ' ' . Configuration::get('PS_SHOP_CITY') . "\n" . Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), Configuration::get('PS_SHOP_COUNTRY_ID'))))); Configuration::updateValue('BLOCKCONTACTINFOS_PHONE', Configuration::get('PS_SHOP_PHONE')); Configuration::updateValue('BLOCKCONTACTINFOS_EMAIL', Configuration::get('PS_SHOP_EMAIL')); $this->_clearCache('blockcontactinfos.tpl'); return parent::install() && $this->registerHook('header') && $this->registerHook('footer'); }
public function getStateName($echo, $row) { $id_state = $row['id_state']; $state = new State($id_state); $cn = new Country(177); if ($state->id) { $country = Country::getNameById(Context::getContext()->language->id, $state->id_country); return "{$state->name} ({$country})"; } return $this->l('Out of the World'); }
public function displayAccount() { $api = MailjetTemplate::getApi(); // Traitements //$tracking = $api->getTracking(); $infos = $api->getUser(); $sendersFromApi = $api->getSenders(null, $infos); $is_senders = 0; $is_domains = 0; $domains = array(); $domains = array(); $senders = array(); if ($sendersFromApi) { foreach ($sendersFromApi as $sender) { if (strpos($sender->Email->Email, '*') !== false) { $domains[] = $sender; } else { $senders[] = $sender; } $is_senders = 1; if (isset($sender->DNS)) { if ($sender->DNS->Domain == Configuration::get('PS_SHOP_DOMAIN') || $sender->DNS->Domain == Configuration::get('PS_SHOP_DOMAIN_SSL')) { $available_domain = 1; if (file_exists(_PS_ROOT_DIR_ . $sender->Filename)) { $root_file = 1; } } if (isset($sender->DNS->Domain)) { $is_domains = 1; } } } } $iso = !empty($infos->AddressCountry) ? $infos->AddressCountry : 'fr'; $country = Country::getNameById($this->context->language->id, Country::getByIso($iso)); $language = explode('_', $infos->Locale); $language = Tools::strtoupper($language[0]); // countries list $countries = Country::getCountries($this->context->language->id); // Assign $this->context->smarty->assign(array('countries' => $countries, 'infos' => $infos, 'country' => $country, 'language' => $language, 'domains' => $domains, 'sender' => $senders, 'is_senders' => $is_senders, 'is_domains' => $is_domains, 'root_file' => $root_file, 'available_domain' => $available_domain)); }
public function getContent() { $this->_postProcess(); if (($id_lang = Language::getIdByIso('EN')) == 0) { $english_language_id = (int) $this->context->employee->id_lang; } else { $english_language_id = (int) $id_lang; } $this->context->smarty->assign(array('PayPal_WPS' => (int) WPS, 'PayPal_HSS' => (int) HSS, 'PayPal_ECS' => (int) ECS, 'PP_errors' => $this->_errors, 'PayPal_logo' => $this->paypal_logos->getLogos(), 'PayPal_allowed_methods' => $this->getPaymentMethods(), 'PayPal_country' => Country::getNameById((int) $english_language_id, (int) $this->default_country), 'PayPal_country_id' => (int) $this->default_country, 'PayPal_business' => Configuration::get('PAYPAL_BUSINESS'), 'PayPal_payment_method' => (int) Configuration::get('PAYPAL_PAYMENT_METHOD'), 'PayPal_api_username' => Configuration::get('PAYPAL_API_USER'), 'PayPal_api_password' => Configuration::get('PAYPAL_API_PASSWORD'), 'PayPal_api_signature' => Configuration::get('PAYPAL_API_SIGNATURE'), 'PayPal_api_business_account' => Configuration::get('PAYPAL_BUSINESS_ACCOUNT'), 'PayPal_express_checkout_shortcut' => (int) Configuration::get('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT'), 'PayPal_in_context_checkout' => (int) Configuration::get('PAYPAL_IN_CONTEXT_CHECKOUT'), 'PayPal_in_context_checkout_merchant_id' => Configuration::get('PAYPAL_IN_CONTEXT_CHECKOUT_M_ID'), 'PayPal_sandbox_mode' => (int) Configuration::get('PAYPAL_SANDBOX'), 'PayPal_payment_capture' => (int) Configuration::get('PAYPAL_CAPTURE'), 'PayPal_country_default' => (int) $this->default_country, 'PayPal_change_country_url' => 'index.php?tab=AdminCountries&token=' . Tools::getAdminTokenLite('AdminCountries') . '#footer', 'Countries' => Country::getCountries($english_language_id), 'One_Page_Checkout' => (int) Configuration::get('PS_ORDER_PROCESS_TYPE'), 'PayPal_integral_evolution_template' => Configuration::get('PAYPAL_HSS_TEMPLATE'), 'PayPal_integral_evolution_solution' => Configuration::get('PAYPAL_HSS_SOLUTION'), 'PayPal_login' => (int) Configuration::get('PAYPAL_LOGIN'), 'PayPal_login_client_id' => Configuration::get('PAYPAL_LOGIN_CLIENT_ID'), 'PayPal_login_secret' => Configuration::get('PAYPAL_LOGIN_SECRET'), 'PayPal_login_tpl' => (int) Configuration::get('PAYPAL_LOGIN_TPL'), 'default_lang_iso' => Language::getIsoById($this->context->employee->id_lang))); $this->getTranslations(); $output = $this->fetchTemplate('/views/templates/admin/back_office.tpl'); if ($this->active == false) { return $output . $this->hookBackOfficeHeader(); } return $output; }
public function hookDisplayAdminOrder($params) { if (!$this->hasShiptomyidOption($params['id_order'])) { return; } $shipto_order = ShiptomyidOrder::getByIdOrder($params['id_order']); if (!Validate::isLoadedObject($shipto_order)) { return false; } $order = new Order($shipto_order->id_order); if ($order->current_state == self::$os_ps_canceled || $order->current_state == self::$os_cancel) { return false; } $shipto_order->country_name = Country::getNameById($this->context->language->id, $shipto_order->id_country); $shipto_order->state_name = State::getNameById($shipto_order->id_state); $this->context->smarty->assign(array('shipto_order' => $shipto_order)); return $this->display($this->_path, 'admin-order.tpl'); }
public function hookPayment($params) { global $cookie; $this->_validateErrors = array(); session_start(); $_SESSION['params1'] = ''; $_SESSION['cart_currency'] = ''; $_SESSION['cart_amount'] = ''; $_SESSION['params1'] = $params; if (!$this->active) { return; } global $smarty; $address = new Address(intval($params['cart']->id_address_invoice)); $customer = new Customer(intval($params['cart']->id_customer)); $merchant_id = trim(Configuration::get('CCAVENUE_MERCHANT_ID')); $access_code = trim(Configuration::get('CCAVENUE_ACCESS_CODE')); $encryption_key = trim(Configuration::get('CCAVENUE_ENCRYPTION_KEY')); $ccavenue_title = trim(Configuration::get('CCAVENUE_TITLE')); $Redirect_Url = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/ccavenue/validation.php'; $Cancel_Url = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/ccavenue/validation.php'; $language = 'EN'; $currency = $this->getCurrency('INR'); $OrderId = date('Ymdhis') . '-' . intval($params['cart']->id); $Amount = $params['cart']->getOrderTotal(true, 3); $_SESSION['cart_amount'] = $Amount; $default_currency_support_ccavnenue = 'INR'; $default_currency_id = Db::getInstance()->getValue("\n\t\t\t\t\t\tSELECT `id_currency`\n\t\t\t\t\t\tFROM `" . _DB_PREFIX_ . "currency`\n\t\t\t\t\t\tWHERE `iso_code` = '" . $default_currency_support_ccavnenue . "'"); $base_currency_id = Configuration::get('PS_CURRENCY_DEFAULT'); $default_currency = new Currency((int) $default_currency_id); $base_currency = new Currency((int) $base_currency_id); $base_currency_code = $base_currency->iso_code; $current_currency = new Currency((int) $params['cart']->id_currency); $_SESSION['cart_currency'] = $params['cart']->id_currency; $current_currency_code = $current_currency->iso_code; $billing_name = $address->firstname . $address->lastname; $billing_address = $address->address1 . $address->address2; $billing_city = $address->city; $billing_zip = $address->postcode; $billing_tel = $address->phone; $billing_email = $customer->email; $country = new Country(intval($address->id_country)); $state = new State(intval($address->id_state)); $billing_state = $state->getNameById($address->id_state); $land_id = $params['cart']->id_lang; $billing_country = $country->getNameById($land_id, $address->id_country); $merchant_param1 = (int) $params['cart']->id; $merchant_param2 = date('YmdHis'); $merchant_param3 = $params['cart']->secure_key; $cust_notes_message = Message::getMessageByCartId(intval($params['cart']->id)); $cust_notes = $cust_notes_message['message']; $billing_cust_notes = $cust_notes; $delivery_name = ''; $delivery_address = ''; $delivery_city = ''; $delivery_state = ''; $delivery_tel = ''; $delivery_zip = ''; $delivery_country = ''; $delivery_name = $address->firstname . $address->lastname; $delivery_address = $address->address1 . $address->address2; $delivery_city = $address->city; $delivery_zip = $address->postcode; $delivery_tel = $address->phone; $delivery_state = $billing_state; $delivery_country = $billing_country; $merchant_data_array = array(); $merchant_data_array['merchant_id'] = $merchant_id; $merchant_data_array['order_id'] = $OrderId; $merchant_data_array['currency'] = 'INR'; $merchant_data_array['amount'] = $Amount; $merchant_data_array['redirect_url'] = $Redirect_Url; $merchant_data_array['cancel_url'] = $Cancel_Url; $merchant_data_array['language'] = $language; $merchant_data_array['billing_name'] = $billing_name; $merchant_data_array['billing_address'] = $billing_address; $merchant_data_array['billing_city'] = $billing_city; $merchant_data_array['billing_state'] = $billing_state; $merchant_data_array['billing_zip'] = $billing_zip; $merchant_data_array['billing_country'] = $billing_country; $merchant_data_array['billing_tel'] = $billing_tel; $merchant_data_array['billing_email'] = $billing_email; $merchant_data_array['delivery_name'] = $delivery_name; $merchant_data_array['delivery_address'] = $delivery_address; $merchant_data_array['delivery_city'] = $delivery_city; $merchant_data_array['delivery_state'] = $delivery_state; $merchant_data_array['delivery_zip'] = $delivery_zip; $merchant_data_array['delivery_country'] = $delivery_country; $merchant_data_array['delivery_tel'] = $delivery_tel; $merchant_data_array['merchant_param1'] = $merchant_param1; $merchant_data_array['merchant_param2'] = $merchant_param2; $merchant_data_array['merchant_param3'] = $merchant_param3; $merchant_data = implode("&", $merchant_data_array); $ccavenue_post_data = ''; $ccavenue_post_data_array = array(); foreach ($merchant_data_array as $key => $value) { $ccavenue_post_data_array[] .= $key . '=' . urlencode($value); } $ccavenue_post_data = implode("&", $ccavenue_post_data_array); $encrypted_data = $this->encrypt($ccavenue_post_data, $encryption_key); $smarty->assign(array('ccavenueUrl' => $this->getccavenueUrl(), 'ccavenue_title' => $ccavenue_title, 'encRequest' => $encrypted_data, 'access_code' => $access_code)); $ccavenue_payment_error_status = ''; $ccavenue_error_message = ''; if ($cookie->__get("ccavenue_validate_error_message")) { $ccavenue_error_message = $cookie->__get("ccavenue_validate_error_message"); } if ($ccavenue_error_message != '') { $ccavenue_payment_error_status = 'ERROR'; } $smarty->assign('payment_status', $ccavenue_payment_error_status); $smarty->assign('message', $ccavenue_error_message); return $this->display(__FILE__, 'payccavenue.tpl'); }
public function initContent() { // Adding Css $this->addCSS(__PS_BASE_URI__ . str_replace(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR, '', _PS_ADMIN_DIR_) . '/themes/' . $this->bo_theme . '/css/modules.css', 'all'); // If we are on a module configuration, no need to load all modules if (Tools::getValue('configure') != '') { return true; } // Init $smarty = $this->context->smarty; $autocompleteList = 'var moduleList = ['; $nameCountryDefault = Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT')); $categoryFiltered = array(); $filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_' . (int) $this->id_employee)); if (count($filterCategories) > 0) { foreach ($filterCategories as $fc) { if (!empty($fc)) { $categoryFiltered[$fc] = 1; } } } foreach ($this->list_modules_categories as $k => $v) { $this->list_modules_categories[$k]['nb'] = 0; } // Retrieve Modules Preferences $modules_preferences = ''; $tab_modules_preferences = array(); $modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'module_preference` WHERE `id_employee` = ' . (int) $this->id_employee); $tab_modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'tab_module_preference` WHERE `id_employee` = ' . (int) $this->id_employee); foreach ($tab_modules_preferences_tmp as $i => $j) { $tab_modules_preferences[$j['module']][] = $j['id_tab']; } foreach ($modules_preferences_tmp as $k => $v) { if ($v['interest'] == null) { unset($v['interest']); } if ($v['favorite'] == null) { unset($v['favorite']); } $modules_preferences[$v['module']] = $v; } // Retrieve Modules List $modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee); $this->initModulesList($modules); $this->nb_modules_total = count($modules); $module_errors = array(); $module_success = array(); // Browse modules list foreach ($modules as $km => $module) { //if we are in favorites view we only display installed modules if (Tools::getValue('select') == 'favorites' && !$module->id) { unset($modules[$km]); continue; } // Upgrade Module process, init check if a module could be upgraded if (Module::initUpgradeModule($module)) { // When the XML cache file is up-to-date, the module may not be loaded yet if (!class_exists($module->name)) { if (!file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) { continue; } require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php'; } if ($object = new $module->name()) { $object->runUpgradeModule(); if (count($errors_module_list = $object->getErrors())) { $module_errors[] = array('name' => $module->name, 'message' => $errors_module_list); } else { if (count($conf_module_list = $object->getConfirmations())) { $module_success[] = array('name' => $module->name, 'message' => $conf_module_list); } } unset($object); } } elseif (Module::getUpgradeStatus($module->name)) { // When the XML cache file is up-to-date, the module may not be loaded yet if (!class_exists($module->name)) { if (file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) { require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php'; $object = new $module->name(); $module_success[] = array('name' => $module->name, 'message' => array(0 => $this->l('Current version:') . $object->version, 1 => $this->l('No file upgrades applied (none exist).'))); } else { continue; } } unset($object); } // Make modules stats $this->makeModulesStats($module); // Assign warnings if ($module->active && isset($module->warning) && !empty($module->warning)) { $this->warnings[] = sprintf($this->l('%1$s: %2$s'), $module->displayName, $module->warning); } // AutoComplete array $autocompleteList .= Tools::jsonEncode(array('displayName' => (string) $module->displayName, 'desc' => (string) $module->description, 'name' => (string) $module->name, 'author' => (string) $module->author, 'image' => isset($module->image) ? (string) $module->image : '', 'option' => '')) . ', '; // Apply filter if ($this->isModuleFiltered($module) && Tools::getValue('select') != 'favorites') { unset($modules[$km]); } else { $this->fillModuleData($module); $module->categoryName = isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name']; if (isset($modules_preferences[$modules[$km]->name])) { $modules[$km]->preferences = $modules_preferences[$modules[$km]->name]; } } unset($object); } // Don't display categories without modules $cleaned_list = array(); foreach ($this->list_modules_categories as $k => $list) { if ($list['nb'] > 0) { $cleaned_list[$k] = $list; } } // Actually used for the report of the upgraded errors if (count($module_errors)) { $html = $this->generateHtmlMessage($module_errors); $this->errors[] = sprintf(Tools::displayError('The following module(s) were not upgraded successfully: %s'), $html); } if (count($module_success)) { $html = $this->generateHtmlMessage($module_success); $this->confirmations[] = sprintf($this->l('The following module(s) were upgraded successfully:') . ' %s', $html); } // Init tpl vars for smarty $tpl_vars = array(); $tpl_vars['token'] = $this->token; $tpl_vars['currentIndex'] = self::$currentIndex; $tpl_vars['dirNameCurrentIndex'] = dirname(self::$currentIndex); $tpl_vars['ajaxCurrentIndex'] = str_replace('index', 'ajax-tab', self::$currentIndex); $tpl_vars['autocompleteList'] = rtrim($autocompleteList, ' ,') . '];'; $tpl_vars['showTypeModules'] = $this->filter_configuration['PS_SHOW_TYPE_MODULES_' . (int) $this->id_employee]; $tpl_vars['showCountryModules'] = $this->filter_configuration['PS_SHOW_COUNTRY_MODULES_' . (int) $this->id_employee]; $tpl_vars['showInstalledModules'] = $this->filter_configuration['PS_SHOW_INSTALLED_MODULES_' . (int) $this->id_employee]; $tpl_vars['showEnabledModules'] = $this->filter_configuration['PS_SHOW_ENABLED_MODULES_' . (int) $this->id_employee]; $tpl_vars['nameCountryDefault'] = Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT')); $tpl_vars['isoCountryDefault'] = $this->iso_default_country; $tpl_vars['categoryFiltered'] = $categoryFiltered; $tpl_vars['modules'] = $modules; $tpl_vars['nb_modules'] = $this->nb_modules_total; $tpl_vars['nb_modules_favorites'] = Db::getInstance()->getValue('SELECT COUNT(`id_module_preference`) FROM `' . _DB_PREFIX_ . 'module_preference` WHERE `id_employee` = ' . (int) $this->id_employee . ' AND `favorite` = 1 AND (`interest` = 1 OR `interest` IS NULL)'); $tpl_vars['nb_modules_installed'] = $this->nb_modules_installed; $tpl_vars['nb_modules_uninstalled'] = $tpl_vars['nb_modules'] - $tpl_vars['nb_modules_installed']; $tpl_vars['nb_modules_activated'] = $this->nb_modules_activated; $tpl_vars['nb_modules_unactivated'] = $tpl_vars['nb_modules_installed'] - $tpl_vars['nb_modules_activated']; $tpl_vars['list_modules_categories'] = $cleaned_list; $tpl_vars['list_modules_authors'] = $this->modules_authors; $tpl_vars['check_url_fopen'] = ini_get('allow_url_fopen') ? 'ok' : 'ko'; $tpl_vars['check_openssl'] = extension_loaded('openssl') ? 'ok' : 'ko'; $tpl_vars['add_permission'] = $this->tabAccess['add']; $tpl_vars['tab_modules_preferences'] = $tab_modules_preferences; if ($this->logged_on_addons) { $tpl_vars['logged_on_addons'] = 1; $tpl_vars['username_addons'] = $this->context->cookie->username_addons; } $smarty->assign($tpl_vars); }
public function hookdisplayAdminOrder() { $orderId = Tools::getValue('id_order'); $sql = "SELECT * FROM skrill_order_ref WHERE id_order ='" . $orderId . "'"; $row = Db::getInstance()->getRow($sql); if ($row) { if (Tools::isSubmit('skrillUpdateOrder') && $row['order_status'] != $this->refundedStatus) { $fieldParams = $this->getSkrillCredentials(); $fieldParams['type'] = 'mb_trn_id'; $fieldParams['id'] = $row['ref_id']; $paymentResult = ''; $isPaymentAccepted = SkrillPaymentCore::isPaymentAccepted($fieldParams, $paymentResult); if ($isPaymentAccepted) { $responseUpdateOrder = SkrillPaymentCore::getResponseArray($paymentResult); $this->updateTransLogStatus($row['ref_id'], $responseUpdateOrder['status']); $sql = "SELECT * FROM skrill_order_ref WHERE id_order ='" . $orderId . "'"; $row = Db::getInstance()->getRow($sql); } } $paymentInfo = array(); $paymentInfo['name'] = $this->getFrontendPaymentLocale($row['payment_method']); $isSkrill = strpos($paymentInfo['name'], 'Skrill'); if ($isSkrill === false) { $paymentInfo['name'] = 'Skrill ' . $paymentInfo['name']; } $trnStatus = SkrillPaymentCore::getTrnStatus($row['order_status']); $paymentInfo['status'] = $this->getTrnStatusLocale($trnStatus); $paymentInfo['method'] = $this->getFrontendPaymentLocale('SKRILL_FRONTEND_PM_' . $row['payment_code']); $paymentInfo['currency'] = $row['currency']; $additionalInformation = $this->getAdditionalInformation($row['add_information']); $langId = Context::getContext()->language->id; $orderOriginId = $this->getCountryIdByIso($additionalInformation['SKRILL_BACKEND_ORDER_ORIGIN']); $paymentInfo['order_origin'] = Country::getNameById($langId, $orderOriginId); $getCountryIso2 = SkrillPaymentCore::getCountryIso2($additionalInformation['SKRILL_BACKEND_ORDER_COUNTRY']); $orderCountryId = $this->getCountryIdByIso($getCountryIso2); $paymentInfo['order_country'] = Country::getNameById($langId, $orderCountryId); $buttonUpdateOrder = $row['order_status'] == $this->refundedStatus ? false : true; $this->context->smarty->assign(array('orderId' => $orderId, 'paymentInfo' => $paymentInfo, 'buttonUpdateOrder' => $buttonUpdateOrder)); return $this->display(__FILE__, 'views/templates/hook/displayAdminOrder.tpl'); } return ''; }
public function hookPayment($params) { global $cart; global $smarty, $cart, $cookie; $invoice_address = new Address((int) $cart->id_address_invoice); $key = Configuration::get('PAYU_MERCHANT_ID'); $salt = Configuration::get('PAYU_SALT'); if (!$this->active) { return; } $mode = Configuration::get('PAYU_MODE'); $log = Configuration::get('PAYU_LOGS'); $amount = $cart->getOrderTotal(true, Cart::BOTH); $curr_currency = CurrencyCore::getCurrency($cart->id_currency); if ($invoice_address->id_country == 110) { $key = 'VLBB6Z'; $salt = 'KQUxLUkT'; if ($cart->id_currency != 4) { //convert to USD(default) $amount = Tools::convertPrice($amount, $cart->id_currency, false); //convert to INT $amount = Tools::convertPrice($amount, 4); $inr_currency = CurrencyCore::getCurrency(4); $curr_conversion_msg = "<p>Dear Customer, any order with an Indian billing address entails processing of the order value in {$inr_currency['iso_code']} ({$inr_currency['name']}). The order value of <b>" . Tools::displayPrice($amount, 4) . "</b> will be processed.</p><p>Currency conversion rates are provided by openexchangerates.org</p>"; $smarty->assign("curr_conversion_msg", $curr_conversion_msg); } } else { if ((int) $curr_currency['paypal_support'] === 1 && $cart->id_currency != 2) { //For all Paypal supported curencies except USD, we dont show PayU return; } else { if ($cart->id_currency != 2) { // Currency not supported by Paypal and not USD, convert to USD and proceed $amount = Tools::convertPrice($amount, $cart->id_currency, false); $this_currency = CurrencyCore::getCurrency($cart->id_currency); $curr_conversion_msg = "<p>Unfortunately we are unable to accept payments in <b>{$this_currency['name']}</b>.</p> <p>An equivalent order value of USD <b>" . Tools::displayPrice($amount, 2) . "</b> will be processed.</p>"; $smarty->assign("curr_conversion_msg", $curr_conversion_msg); } } } $amount = round($amount); //else //return; //convert to INR if the currency is not //if ($cart->id_currency != 4) //$amount = Tools::convertPrice($amount, 4, true); $customer = new Customer((int) $cart->id_customer); $action = 'https://test.payu.in/_payment.php'; $txnid = $cart->id; $productInfo = 'Payu product information'; $firstname = $customer->firstname; $Lastname = $customer->lastname; $deloveryAddress = new Address((int) $cart->id_address_invoice); $Zipcode = $deloveryAddress->postcode; $email = $customer->email; $phone = $deloveryAddress->phone; $deloveryAddress->country = Country::getNameById(1, $deloveryAddress->id_country); $deloveryAddress->state = State::getNameById($deloveryAddress->id_state); if ($mode == 'real') { $action = 'https://secure.payu.in/_payment.php'; } $request = $key . '|' . $txnid . '|' . $amount . '|' . $productInfo . '|' . $firstname . '|' . $email . '|||||||||||' . $salt; $Hash = hash('sha512', $key . '|' . $txnid . '|' . $amount . '|' . $productInfo . '|' . $firstname . '|' . $email . '|||||||||||' . $salt); $baseUrl = Tools::getShopDomain(true, true) . __PS_BASE_URI__; if ($log == 1) { $query = "insert into ps_payu_order(id_order,payment_request) values({$orderId},'{$request}')"; Db::getInstance()->Execute($query); } $surl = $baseUrl . 'modules/' . $this->name . '/success.php'; $curl = $baseUrl . 'modules/' . $this->name . '/failure.php'; $Furl = $baseUrl . 'modules/' . $this->name . '/failure.php'; $Pg = 'CC'; $payuInfo = array('action' => $action, 'key' => $key, 'txnid' => $txnid, 'amount' => $amount, 'productinfo' => $productInfo, 'firstname' => $firstname, 'Lastname' => $Lastname, 'Zipcode' => $Zipcode, 'email' => $email, 'phone' => $phone, 'surl' => $surl, 'Furl' => $Furl, 'curl' => $curl, 'Hash' => $Hash, 'Pg' => $Pg, 'deliveryAddress' => $deloveryAddress); $smarty->assign('Message', 'Please wait, you will be redirected to payu website'); $smarty->assign($payuInfo); return $this->display(__FILE__, 'payu.tpl'); }
public function displayList() { global $currentIndex, $cookie; $modulesAuthors = array(); $autocompleteList = 'var moduleList = ['; $showTypeModules = Configuration::get('PS_SHOW_TYPE_MODULES_' . (int) $cookie->id_employee); $showInstalledModules = Configuration::get('PS_SHOW_INSTALLED_MODULES_' . (int) $cookie->id_employee); $showEnabledModules = Configuration::get('PS_SHOW_ENABLED_MODULES_' . (int) $cookie->id_employee); $showCountryModules = Configuration::get('PS_SHOW_COUNTRY_MODULES_' . (int) $cookie->id_employee); $nameCountryDefault = Country::getNameById($cookie->id_lang, _PS_COUNTRY_DEFAULT_); $isoCountryDefault = Country::getIsoById(_PS_COUNTRY_DEFAULT_); $serialModules = ''; $modules = Module::getModulesOnDisk(true); foreach ($modules as $module) { if (!in_array($module->name, $this->listNativeModules)) { $serialModules .= $module->name . ' ' . $module->version . '-' . ($module->active ? 'a' : 'i') . "\n"; } $moduleAuthor = $module->author; if (!empty($moduleAuthor) && $moduleAuthor != "") { $modulesAuthors[(string) $moduleAuthor] = true; } } $serialModules = urlencode($serialModules); $filterName = Tools::getValue('filtername'); if (!empty($filterName)) { echo ' <script type="text/javascript"> $(document).ready(function() { $(\'#all_open\').hide(); $(\'#all_close\').show(); $(\'.tab_module_content\').each(function(){ $(this).slideDown(); $(\'.header_module_img\').each(function(){ $(this).attr(\'src\', \'../img/admin/less.png\'); }); }); }); </script>'; } //filter module list foreach ($modules as $key => $module) { switch ($showTypeModules) { case 'nativeModules': if (!in_array($module->name, $this->listNativeModules)) { unset($modules[$key]); } break; case 'partnerModules': if (!in_array($module->name, $this->listPartnerModules)) { unset($modules[$key]); } break; case 'otherModules': if (in_array($module->name, $this->listPartnerModules) or in_array($module->name, $this->listNativeModules)) { unset($modules[$key]); } break; default: if (strpos($showTypeModules, 'authorModules[') !== false) { $author_selected = $this->_getSubmitedModuleAuthor($showTypeModules); $modulesAuthors[$author_selected] = 'selected'; // setting selected author in authors set if (empty($module->author) || $module->author != $author_selected) { unset($modules[$key]); } } break; } switch ($showInstalledModules) { case 'installed': if (!$module->id) { unset($modules[$key]); } break; case 'unistalled': if ($module->id) { unset($modules[$key]); } break; } switch ($showEnabledModules) { case 'enabled': if (!$module->active) { unset($modules[$key]); } break; case 'disabled': if ($module->active) { unset($modules[$key]); } break; } if ($showCountryModules) { if (isset($module->limited_countries) and !empty($module->limited_countries) and (is_array($module->limited_countries) and sizeof($module->limited_countries) and !in_array(strtolower($isoCountryDefault), $module->limited_countries) or !is_array($module->limited_countries) and strtolower($isoCountryDefault) != strval($module->limited_countries))) { unset($modules[$key]); } } if (!empty($filterName)) { if (stristr($module->name, $filterName) === false and stristr($module->displayName, $filterName) === false and stristr($module->description, $filterName) === false) { unset($modules[$key]); } } } foreach ($modules as $module) { $autocompleteList .= Tools::jsonEncode(array('displayName' => (string) $module->displayName, 'desc' => (string) $module->description, 'name' => (string) $module->name, 'author' => (string) $module->author)) . ', '; } $autocompleteList = rtrim($autocompleteList, ' ,') . '];'; // Display CSS Fancy Box echo '<link href="' . _PS_CSS_DIR_ . 'jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" media="screen" />'; echo '<script type="text/javascript">' . $autocompleteList . '</script>'; $this->displayJavascript(); echo ' <span onclick="$(\'#module_install\').slideToggle()" style="cursor:pointer"><img src="../img/admin/add.gif" alt="' . $this->l('Add a new module') . '" class="middle" /> ' . $this->l('Add a module from my computer') . ' </span> | '; echo '<a href="index.php?tab=AdminAddonsMyAccount&token=' . Tools::getAdminTokenLite('AdminAddonsMyAccount') . '"> <img src="https://addons.prestashop.com/modules.php?' . (isset($_SERVER['SERVER_ADDR']) ? 'server=' . ip2long($_SERVER['SERVER_ADDR']) . '&' : '') . 'mods=' . $serialModules . '" alt="Add" class="middle" /> ' . $this->l('Add a module from PrestaShop Addons') . ' </a>'; echo '<form action="' . $currentIndex . '&token=' . $this->token . '" method="post" id="filternameForm" style="float:right"><input type="text" name="filtername" value="' . Tools::htmlentitiesUTF8(Tools::getValue('filtername')) . '" /> <input type="submit" value="' . $this->l('Search') . '" class="button" /></form> <div class="clear"> </div> <div id="module_install" style="width:900px; ' . ((Tools::isSubmit('submitDownload') or Tools::isSubmit('submitDownload2')) ? '' : 'display: none;') . '"> <fieldset> <legend><img src="../img/admin/add.gif" alt="' . $this->l('Add a new module') . '" class="middle" /> ' . $this->l('Add a new module') . '</legend> <p>' . $this->l('The module must either be a zip file or a tarball.') . '</p> <hr /> <div style="float:right;margin-right:50px;border-left:solid 1px #DFD5C3"> <form action="' . $currentIndex . '&token=' . $this->token . '" method="post" enctype="multipart/form-data"> <label style="width: 100px">' . $this->l('Module file') . '</label> <div class="margin-form" style="padding-left: 140px"> <input type="file" name="file" /> <p>' . $this->l('Upload the module from your computer.') . '</p> </div> <div class="margin-form" style="padding-left: 140px"> <input type="submit" name="submitDownload2" value="' . $this->l('Upload this module') . '" class="button" /> </div> </form> </div> <div> <form action="' . $currentIndex . '&token=' . $this->token . '" method="post"> <label style="width: 100px">' . $this->l('Module URL') . '</label> <div class="margin-form" style="padding-left: 140px"> <input type="text" name="url" style="width: 200px;" value="' . (Tools::getValue('url') ? Tools::getValue('url') : 'http://') . '" /> <p>' . $this->l('Download the module directly from a website.') . '</p> </div> <div class="margin-form" style="padding-left: 140px"> <input type="submit" name="submitDownload" value="' . $this->l('Download this module') . '" class="button" /> </div> </form> </div> </fieldset> <br /> </div>'; if (Configuration::get('PRESTASTORE_LIVE')) { echo ' <div id="prestastore" style="margin-left:40px; display:none; float: left" class="width1"> </div>'; } /* Scan modules directories and load modules classes */ $warnings = array(); $orderModule = array(); $irow = 0; foreach ($modules as $module) { $orderModule[(isset($module->tab) and !empty($module->tab) and array_key_exists(strval($module->tab), $this->listTabModules)) ? strval($module->tab) : 'others'][] = $module; } uasort($orderModule, array('AdminModules', 'sortModule')); $concatWarning = array(); foreach ($orderModule as $tabModule) { foreach ($tabModule as $module) { if ($module->active and $module->warning) { $warnings[] = '<a href="' . $currentIndex . '&configure=' . urlencode($module->name) . '&token=' . $this->token . '">' . $module->displayName . '</a> - ' . stripslashes(pSQL($module->warning)); } } } $this->displayWarning($warnings); echo '<form method="POST"> <table cellpadding="0" cellspacing="0" style="width:100%;margin-bottom:5px;"> <tr> <th style="border-right:solid 1px;border:inherit"> <span class="button" style="padding:0.4em;"> <a id="all_open" class="module_toggle_all" style="display:inherit;text-decoration:none;" href="#"> <span style="padding-right:0.5em"> <img src="../img/admin/more.png" alt="" /> </span> <span id="all_open">' . $this->l('Open all tabs') . '</span> </a> <a id="all_close" class="module_toggle_all" style="display:none;text-decoration:none;" href="#"> <span style="padding-right:0.5em"> <img src="../img/admin/less.png" alt="" /> </span> <span id="all_open">' . $this->l('Close all tabs') . '</span> </a> </span> </th> <th colspan="3" style="border:inherit"> <select name="module_type"> <option value="allModules" ' . ($showTypeModules == 'allModules' ? 'selected="selected"' : '') . '>' . $this->l('All Modules') . '</option> <option value="nativeModules" ' . ($showTypeModules == 'nativeModules' ? 'selected="selected"' : '') . '>' . $this->l('Native Modules') . '</option> <option value="partnerModules" ' . ($showTypeModules == 'partnerModules' ? 'selected="selected"' : '') . '>' . $this->l('Partner Modules') . '</option>' . $this->_buildModuleAuthorsOptGroup($modulesAuthors, 'authorModules') . ' <option value="otherModules" ' . ($showTypeModules == 'otherModules' ? 'selected="selected"' : '') . '>' . $this->l('Other Modules') . '</option> </select> <select name="module_install"> <option value="installedUninstalled" ' . ($showInstalledModules == 'installedUninstalled' ? 'selected="selected"' : '') . '>' . $this->l('Installed & Uninstalled') . '</option> <option value="installed" ' . ($showInstalledModules == 'installed' ? 'selected="selected"' : '') . '>' . $this->l('Installed Modules') . '</option> <option value="unistalled" ' . ($showInstalledModules == 'unistalled' ? 'selected="selected"' : '') . '>' . $this->l('Uninstalled Modules') . '</option> </select> <select name="module_status"> <option value="enabledDisabled" ' . ($showEnabledModules == 'enabledDisabled' ? 'selected="selected"' : '') . '>' . $this->l('Enabled & Disabled') . '</option> <option value="enabled" ' . ($showEnabledModules == 'enabled' ? 'selected="selected"' : '') . '>' . $this->l('Enabled Modules') . '</option> <option value="disabled" ' . ($showEnabledModules == 'disabled' ? 'selected="selected"' : '') . '>' . $this->l('Disabled Modules') . '</option> </select> <select name="country_module_value"> <option value="0" >' . $this->l('All countries') . '</option> <option value="1" ' . ($showCountryModules == 1 ? 'selected="selected"' : '') . '>' . $this->l('Current country:') . ' ' . $nameCountryDefault . '</option> </select> </th> <th style="border:inherit"> <div style="float:right"> <input type="submit" class="button" name="resetFilterModules" value="' . $this->l('Reset') . '"> <input type="submit" class="button" name="filterModules" value="' . $this->l('Filter') . '"> </div> </th> </tr> </table> </form>'; echo $this->displaySelectedFilter(); if ($tab_module = Tools::getValue('tab_module')) { if (array_key_exists($tab_module, $this->listTabModules)) { $goto = $tab_module; } else { $goto = 'others'; } } else { $goto = false; } echo ' <script src="' . __PS_BASE_URI__ . 'js/jquery/jquery.scrollTo-1.4.2-min.js"></script> <script> $(document).ready(function() { $(\'.header_module_toggle, .module_toggle_all\').unbind(\'click\').click(function(){ var id = $(this).attr(\'id\'); if (id == \'all_open\') $(\'.tab_module_content\').each(function(){ $(this).slideDown(); $(\'#all_open\').hide(); $(\'#all_close\').show(); $(\'.header_module_img\').each(function(){ $(this).attr(\'src\', \'../img/admin/less.png\'); }); }); else if (id == \'all_close\') $(\'.tab_module_content\').each(function(){ $(\'#all_open\').show(); $(\'#all_close\').hide(); $(this).slideUp(); $(\'.header_module_img\').each(function(){ $(this).attr(\'src\', \'../img/admin/more.png\'); }); }); else { if ($(\'#\'+id+\'_content\').css(\'display\') == \'none\') $(\'#\'+id+\'_img\').attr(\'src\', \'../img/admin/less.png\'); else $(\'#\'+id+\'_img\').attr(\'src\', \'../img/admin/more.png\'); $(\'#\'+$(this).attr(\'id\')+\'_content\').slideToggle(); } return false; }); ' . (!$goto ? '' : 'if ($(\'#' . $goto . '_content\').length > 0) $(\'#' . $goto . '_content\').slideToggle( function (){ $(\'#' . $goto . '_img\').attr(\'src\', \'../img/admin/less.png\'); ' . (!$goto ? '' : 'if ($("#modgo_' . Tools::getValue('module_name') . '").length > 0) $.scrollTo($("#modgo_' . Tools::getValue('module_name') . '"), 300 , {onAfter:function(){ $("#modgo_' . Tools::getValue('module_name') . '").fadeTo(100, 0, function (){ $(this).fadeTo(100, 0, function (){ $(this).fadeTo(50, 1, function (){ $(this).fadeTo(50, 0, function (){ $(this).fadeTo(50, 1 )} )} )} )} )} });') . ' });') . ' }); </script>'; if (!empty($orderModule)) { /* Browse modules by tab type */ foreach ($orderModule as $tab => $tabModule) { echo ' <div id="' . $tab . '" class="header_module"> <span class="nbr_module" style="width:100px;text-align:right">' . sizeof($tabModule) . ' ' . (sizeof($tabModule) > 1 ? $this->l('modules') : $this->l('module')) . '</span> <a class="header_module_toggle" id="' . $tab . '" href="modgo_' . $tab . '" style="margin-left: 5px;"> <span style="padding-right:0.5em"> <img class="header_module_img" id="' . $tab . '_img" src="../img/admin/more.png" alt="" /> </span>' . $this->listTabModules[$tab] . '</a> </div> <div id="' . $tab . '_content" class="tab_module_content" style="display:none;border:solid 1px #CCC">'; /* Display modules for each tab type */ foreach ($tabModule as $module) { echo '<div id="modgo_' . $module->name . '" title="' . $module->name . '">'; if ($module->id) { $img = '<img src="../img/admin/module_install.png" alt="' . $this->l('Module enabled') . '" title="' . $this->l('Module enabled') . '" />'; if ($module->warning) { $img = '<img src="../img/admin/module_warning.png" alt="' . $this->l('Module installed but with warnings') . '" title="' . $this->l('Module installed but with warnings') . '" />'; } if (!$module->active) { $img = '<img src="../img/admin/module_disabled.png" alt="' . $this->l('Module disabled') . '" title="' . $this->l('Module disabled') . '" />'; } } else { $img = '<img src="../img/admin/module_notinstall.png" alt="' . $this->l('Module not installed') . '" title="' . $this->l('Module not installed') . '" />'; } $disp_author = $this->_getDispAuthor($module->author); $disp_author = empty($disp_author) ? '' : ' ' . $this->l('by') . ' <i>' . Tools::htmlentitiesUTF8($disp_author) . '</i>'; echo '<table style="width:100%" cellpadding="0" cellspacing="0" > <tr' . ($irow % 2 ? ' class="alt_row"' : '') . ' style="height: 42px;"> <td style="padding-right: 10px;padding-left:10px;width:30px"> <input type="checkbox" name="modules" value="' . urlencode($module->name) . '" ' . (empty($module->confirmUninstall) ? 'rel="false"' : 'rel="' . addslashes($module->confirmUninstall) . '"') . ' /> </td> <td style="padding:2px 4px 2px 10px;width:500px"><img src="../modules/' . $module->name . '/logo.gif" alt="" /> <b>' . stripslashes($module->displayName) . '</b>' . ($module->version ? ' v' . $module->version . (strpos($module->version, '.') !== false ? '' : '.0') : '') . $disp_author . '<br />' . stripslashes($module->description) . '</td> <td rowspan="2">'; if (Tools::getValue('module_name') == $module->name || in_array($module->name, explode('|', Tools::getValue('modules_list'))) && (int) Tools::getValue('conf') > 0) { $this->displayConf(); } echo '</td> <td class="center" style="width:60px" rowspan="2">'; if ($module->id) { echo '<a href="' . $currentIndex . '&token=' . $this->token . '&module_name=' . $module->name . '&' . ($module->active ? 'desactive' : 'active') . '">'; } echo $img; if ($module->id) { '</a>'; } $href = $currentIndex . '&uninstall=' . urlencode($module->name) . '&token=' . $this->token . '&tab_module=' . $module->tab . '&module_name=' . $module->name; echo ' </td> <td class="center" width="120" rowspan="2">' . (!$module->id ? '<input type="button" class="button small" name="Install" value="' . $this->l('Install') . '" onclick="javascript:document.location.href=\'' . $currentIndex . '&install=' . urlencode($module->name) . '&token=' . $this->token . '&tab_module=' . $module->tab . '&module_name=' . $module->name . '\'">' : '<input type="button" class="button small" name="Uninstall" value="' . $this->l('Uninstall') . '" onclick="' . (!method_exists($module, 'onclickOption') ? (empty($module->confirmUninstall) ? '' : 'if (confirm(\'' . addslashes($module->confirmUninstall) . '\')) ') . 'document.location.href=\'' . $href . '\'' : $module->onclickOption('uninstall', $href)) . '">') . '</td> </tr> <tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . '> <td style="padding-left:50px;padding-bottom:5px;padding-top:5px" colspan="2">' . $this->displayOptions($module) . '</td> </tr> </table> </div>'; } echo '</div>'; } echo ' <div style="margin-top: 12px; width:600px;"> <input type="button" class="button big" value="' . $this->l('Install the selection') . '" onclick="modules_management(\'install\')"/> <input type="button" class="button big" value="' . $this->l('Uninstall the selection') . '" onclick="modules_management(\'uninstall\')" /> </div> <br /> <table cellpadding="0" cellspacing="0" class="table" style="width:100%;"> <tr style="height:35px;background-color:#EEEEEE"> <td><strong>' . $this->l('Icon legend') . ' : </strong></td> <td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_install.png" /> ' . $this->l('Module installed and enabled') . '</td> <td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_disabled.png" /> ' . $this->l('Module installed but disabled') . '</td> <td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_warning.png" /> ' . $this->l('Module installed but with warnings') . '</td> <td style="text-align:center"><img src="../img/admin/module_notinstall.png" /> ' . $this->l('Module not installed') . '</td> </tr> </table> <div style="clear:both"> </div>'; } else { echo '<table cellpadding="0" cellspacing="0" class="table" style="width:100%;"><tr><td align="center">' . $this->l('No module found') . '</td></tr></table>'; } }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); if (!$this->errors) { if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) { $this->product->quantity = 0; } $this->product->description = $this->transformDescriptionWithImg($this->product->description); // Assign to the template the id of the virtual product. "0" if the product is not downloadable. $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id)); $this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']))); if (Tools::isSubmit('submitCustomizedDatas')) { // If cart has not been saved, we need to do it so that customization fields can have an id_cart // We check that the cookie exists first to avoid ghost carts if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) { $this->context->cart->add(); $this->context->cookie->id_cart = (int) $this->context->cart->id; } $this->pictureUpload(); $this->textRecord(); $this->formTargetFormat(); } elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) { $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.'); } $pictures = array(); $text_fields = array(); if ($this->product->customizable) { $files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true); foreach ($files as $file) { $pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value']; } $texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true); foreach ($texts as $text_field) { $text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']); } } $this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields)); $this->product->customization_required = false; $customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false; if (is_array($customization_fields)) { foreach ($customization_fields as $customization_field) { if ($this->product->customization_required = $customization_field['required']) { break; } } } // Assign template vars related to the category + execute hooks related to the category $this->assignCategory(); // Assign template vars related to the price and tax $this->assignPriceAndTax(); // Assign template vars related to the images $this->assignImages(); // Assign attribute groups to the template $this->assignAttributesGroups(); // Assign attributes combinations to the template $this->assignAttributesCombinations(); // Pack management $pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array(); $this->context->smarty->assign('packItems', $pack_items); $this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1)); if (isset($this->category->id) && $this->category->id) { $return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category)); } else { $return_link = 'javascript: history.back();'; } $accessories = $this->product->getAccessories($this->context->language->id); if ($this->product->cache_is_pack || count($accessories)) { $this->context->controller->addCSS(_THEME_CSS_DIR_ . 'product_list.css'); } if ($this->product->customizable) { $customization_datas = $this->context->cart->getProductCustomization($this->product->id, null, true); } // by webkul $htl_features = array(); $obj_hotel_room_type = new HotelRoomType(); $room_info_by_product_id = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($this->product->id); $hotel_id = $room_info_by_product_id['id_hotel']; if (isset($hotel_id) && $hotel_id) { $obj_hotel_branch = new HotelBranchInformation(); $hotel_info_by_id = $obj_hotel_branch->hotelBranchInfoById($hotel_id); $hotel_policies = $hotel_info_by_id['policies']; $hotel_name = $hotel_info_by_id['hotel_name']; $country = Country::getNameById($this->context->language->id, $hotel_info_by_id['country_id']); $state = State::getNameById($hotel_info_by_id['state_id']); $hotel_location = $hotel_info_by_id['city'] . ', ' . $state . ', ' . $country; $obj_hotel_feaures_ids = $obj_hotel_branch->getFeaturesOfHotelByHotelId($hotel_id); if (isset($obj_hotel_feaures_ids) && $obj_hotel_feaures_ids) { foreach ($obj_hotel_feaures_ids as $key => $value) { $obj_htl_ftr = new HotelFeatures(); $htl_info = $obj_htl_ftr->getFeatureInfoById($value['feature_id']); $htl_features[] = $htl_info['name']; } } } $date_from = Tools::getValue('date_from'); $date_to = Tools::getValue('date_to'); if (!($date_from = Tools::getValue('date_from'))) { $date_from = date('Y-m-d'); $date_to = date('Y-m-d', strtotime($date_from) + 86400); } if (!($date_to = Tools::getValue('date_to'))) { $date_to = date('Y-m-d', strtotime($date_from) + 86400); } $obj_booking_detail = new HotelBookingDetail(); $num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to); $priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id); if (!$priceDisplay || $priceDisplay == 2) { $price_tax = true; } elseif ($priceDisplay == 1) { $price_tax = false; } $price_tax_incl = Product::getPriceStatic($this->product->id, $price_tax); $total_price = $price_tax_incl * $num_days; $obj_booking_dtl = new HotelBookingDetail(); $hotel_room_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $hotel_id, $this->product->id, 1); $obj_htl_cart_booking_data = new HotelCartBookingData(); $num_cart_rooms = $obj_htl_cart_booking_data->getCountRoomsByIdCartIdProduct($this->context->cart->id, $this->product->id, $date_from, $date_to); if ($hotel_room_data) { $total_available_rooms = $hotel_room_data['stats']['num_avail'] - $num_cart_rooms; } //end $location_enable = Configuration::get('WK_HOTEL_LOCATION_ENABLE'); $hotel_branch_obj = new HotelBranchInformation(); $hotel_info = $hotel_branch_obj->getActiveHotelBranchesInfo(); $search_data['date_from'] = $date_from; $search_data['date_to'] = $date_to; $search_data['htl_dtl'] = $hotel_branch_obj->hotelBranchInfoById($hotel_id); if (Tools::getValue('error')) { $this->context->smarty->assign('error', Tools::getValue('error')); } $this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customization_fields, 'id_customization' => empty($customization_datas) ? null : $customization_datas[0]['id_customization'], 'accessories' => $accessories, 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'ratting_img_path' => _MODULE_DIR_ . 'hotelreservationsystem/views/img/Slices/icons-sprite.png', 'num_reviews' => ProductComment::getCommentNumber($this->product->id), 'ratting' => ProductComment::getAverageGrade($this->product->id)['grade'], 'total_available_rooms' => $total_available_rooms, 'all_hotels_info' => $hotel_info, 'location_enable' => $location_enable, 'total_price' => $total_price, 'product_controller_url' => $this->context->link->getPageLink('product'), 'num_days' => $num_days, 'date_from' => $date_from, 'date_to' => $date_to, 'hotel_location' => $hotel_location, 'hotel_name' => $hotel_name, 'hotel_policies' => $hotel_policies, 'hotel_features' => $htl_features, 'ftr_img_src' => _PS_IMG_ . 'rf/', 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE'), 'search_data' => $search_data)); } $this->setTemplate(_PS_THEME_DIR_ . 'product.tpl'); }
private function setDelivery() { $product_price = $this->give_it_product->data['details']['price']; // add a delivery option $delivery = new GiveItSdkOption(array('id' => 'my_id', 'type' => 'layered_delivery', 'name' => 'Shipping', 'tax_delivery' => true)); // loop through all countries for which shipping is defined and create a choice on this option $this->getShippingRules(); $zones = Zone::getZones(false); foreach (self::$shipping_rules as $rule) { if (is_numeric($rule['iso_code'])) { // it's a zone not a country foreach ($zones as $zone) { if ($zone['id_zone'] == $rule['iso_code']) { $country_name = $zone['name']; } } } else { $country_id = Country::getByIso($rule['iso_code']); $country_name = Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), $country_id); } $choice = new GiveItSdkChoice(array('id' => $rule['iso_code'], 'name' => $country_name, 'choices_title' => $country_name)); // look for options for this country foreach (self::$shipping_rules as $option) { if ($option['iso_code'] == $rule['iso_code']) { // if option has free_above and price > then display 0 price $option_price = $option['price']; if ($option['free_above'] > 0 && $product_price > $option['free_above']) { $option_price = 0; } $choice->addChoice(new GiveItSdkChoice(array('id' => $option['id'], 'name' => $option['name'], 'price' => $option_price, 'tax_percent' => (int) $option['tax_percent']))); } } $delivery->addChoice($choice); } return $delivery; }
public function postProcess() { // On construit un login pour le compte // ------------------------------------ // Si PS_SHOP_EMAIL = info@axalone.com // Alors login = ps-info-axalone // 1/ On ajoute 'ps-' devant l'email // 2/ On retire l'extention .com à la fin // 3/ On remplace toutes les lettres accentuées par leurs équivalents sans accent // 4/ On remplace tous les sigles par des tirets // 5/ Enfin on remplace les doubles/triples tirets par des simples // -------------------------------------------------------------------------------- $company_login = '******' . Configuration::get('PS_SHOP_EMAIL'); $company_login = Tools::substr($company_login, 0, strrpos($company_login, '.')); $company_login = EMTools::removeAccents($company_login); $company_login = Tools::strtolower($company_login); $company_login = preg_replace('/[^a-z0-9-]/', '-', $company_login); $company_login = preg_replace('/-{2,}/', '-', $company_login); $cart_product = (string) Tools::getValue('product', ''); // Initialisation de l'API // ----------------------- if (Tools::isSubmit('submitInscription')) { // On prépare l'ouverture du compte // -------------------------------- $company_name = (string) Tools::getValue('company_name'); $company_email = (string) Tools::getValue('company_email'); $company_phone = (string) Tools::getValue('company_phone'); $company_address1 = (string) Tools::getValue('company_address1'); $company_address2 = (string) Tools::getValue('company_address2'); $company_zipcode = (string) Tools::getValue('company_zipcode'); $company_city = (string) Tools::getValue('company_city'); $country_id = (int) Tools::getValue('country_id'); $country = new Country($country_id); if (!is_object($country) || empty($country->id)) { $this->errors[] = Tools::displayError('Country is invalid'); } else { $company_country = Country::getNameById($this->context->language->id, $country_id); } if (!Validate::isGenericName($company_name)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop name', 'AdminStores') . ' »'); } if (!Validate::isEmail($company_email)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop email', 'AdminStores') . ' »'); } if (!Validate::isPhoneNumber($company_phone)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Phone', 'AdminStores') . ' »'); } if (!Validate::isAddress($company_address1)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop address line 1', 'AdminStores') . ' »'); } if ($country->zip_code_format && !$country->checkZipCode($company_zipcode)) { $this->errors[] = Tools::displayError('Your Zip/postal code is incorrect.') . '<br />' . Tools::displayError('It must be entered as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))); } elseif (empty($company_zipcode) && $country->need_zip_code) { $this->errors[] = Tools::displayError('A Zip/postal code is required.'); } elseif ($company_zipcode && !Validate::isPostCode($company_zipcode)) { $this->errors[] = Tools::displayError('The Zip/postal code is invalid.'); } if (!Validate::isGenericName($company_city)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('City', 'AdminStores') . ' »'); } // We save these informations in the database // ------------------------------------------ Db::getInstance()->insert('expressmailing_order_address', array('id_address' => 1, 'company_name' => pSQL($company_name), 'company_email' => pSQL($company_email), 'company_address1' => pSQL($company_address1), 'company_address2' => pSQL($company_address2), 'company_zipcode' => pSQL($company_zipcode), 'company_city' => pSQL($company_city), 'country_id' => $country_id, 'company_country' => pSQL($company_country), 'company_phone' => pSQL($company_phone), 'product' => pSQL($cart_product)), false, false, Db::REPLACE); // If form contains 1 or more errors, we stop the process // ------------------------------------------------------ if (is_array($this->errors) && count($this->errors)) { return false; } // Open a session on Express-Mailing API // ------------------------------------- if ($this->session_api->openSession()) { // We create the account // --------------------- $response_array = array(); $base_url = Configuration::get('PS_SSL_ENABLED') == 0 ? Tools::getShopDomain(true, true) : Tools::getShopDomainSsl(true, true); $module_dir = Tools::str_replace_once(_PS_ROOT_DIR_, '', _PS_MODULE_DIR_); $parameters = array('login' => $company_login, 'info_company' => $company_name, 'info_email' => $company_email, 'info_phone' => $company_phone, 'info_address' => $company_address1 . "\r\n" . $company_address2, 'info_country' => $company_country, 'info_zipcode' => $company_zipcode, 'info_city' => $company_city, 'info_phone' => $company_phone, 'info_contact_firstname' => $this->context->employee->firstname, 'info_contact_lastname' => $this->context->employee->lastname, 'email_report' => $this->context->employee->email, 'gift_code' => 'prestashop_' . Translate::getModuleTranslation('expressmailing', '3320', 'session_api'), 'INFO_WWW' => $base_url . $module_dir . $this->module->name . '/campaigns/index.php'); if ($this->session_api->createAccount($parameters, $response_array)) { // If the form include the buying process (field 'product') // We initiate a new cart with the product selected // -------------------------------------------------------- if ($cart_product) { Tools::redirectAdmin('index.php?controller=AdminMarketingBuy&submitCheckout&campaign_id=' . $this->campaign_id . '&media=' . $this->next_controller . '&product=' . $cart_product . '&token=' . Tools::getAdminTokenLite('AdminMarketingBuy')); exit; } // Else we back to the mailing process // ----------------------------------- Tools::redirectAdmin($this->next_action); exit; } if ($this->session_api->error == 11) { // Account already existe, we print the rescue form (with password input) // ---------------------------------------------------------------------- $response_array = array(); $parameters = array('login' => $company_login); $this->session_api->resendPassword($parameters, $response_array); $this->generateRescueForm(); return; } else { // Other error // ----------- $this->errors[] = sprintf($this->module->l('Unable to create an account : %s', 'adminmarketinginscription'), $this->session_api->getError()); return false; } } else { $this->errors[] = sprintf($this->module->l('Error during communication with Express-Mailing API : %s', 'adminmarketinginscription'), $this->session_api->getError()); return false; } } elseif (Tools::isSubmit('submitRescue')) { // Rescue form : ask for existing password // --------------------------------------- if ($this->session_api->openSession()) { $response_array = array(); $password = trim((string) Tools::getValue('api_password')); $parameters = array('login' => $company_login, 'password' => $password); if ($this->session_api->connectUser($parameters, $response_array)) { Db::getInstance()->insert('expressmailing', array('api_login' => pSQL($company_login), 'api_password' => pSQL($password)), false, false, Db::REPLACE); // If the form include the buying process (field 'product') // We initiate a new cart with the product selected // -------------------------------------------------------- if ($cart_product) { Tools::redirectAdmin('index.php?controller=AdminMarketingBuy&submitCheckout&campaign_id=' . $this->campaign_id . '&media=' . $this->next_controller . '&product=' . $cart_product . '&token=' . Tools::getAdminTokenLite('AdminMarketingBuy')); exit; } // Else we back to the mailing process // ----------------------------------- Tools::redirectAdmin($this->next_action); exit; } } $this->errors[] = sprintf($this->module->l('Error during communication with Express-Mailing API : %s', 'adminmarketinginscription'), $this->session_api->getError()); return false; } }
public function displayList() { global $currentIndex, $cookie; $serialModules = ''; $modules = Module::getModulesOnDisk(); foreach ($modules as $module) { $serialModules .= $module->name . ' ' . $module->version . '-' . ($module->active ? 'a' : 'i') . "\n"; } $serialModules = urlencode($serialModules); $this->displayJavascript(); $linkToSettings = 'index.php?tab=AdminPreferences&token=' . Tools::getAdminToken('AdminPreferences' . intval(Tab::getIdFromClassName('AdminPreferences')) . intval($cookie->id_employee)); echo '<span onclick="openCloseLayer(\'module_install\', 0);" style="cursor: pointer;font-weight: 700; float: left;"><img src="../img/admin/add.gif" alt="' . $this->l('Add a new module') . '" class="middle" /> ' . $this->l('Add a new module') . '</span>'; if (Configuration::get('PRESTASTORE_LIVE') and @ini_get('allow_url_fopen')) { echo '<script type="text/javascript"> function getPrestaStore(){if (getE("prestastore").style.display!=\'block\')return;$.post("' . dirname($currentIndex) . '/ajax.php",{page:"prestastore"},function(a){getE("prestastore-content").innerHTML=a;})} </script> <span onclick="openCloseLayer(\'prestastore\', 0); getPrestaStore();" style="cursor: pointer;font-weight: 700; float: left;margin-left:20px;"><img src="../img/admin/prestastore.gif" class="middle" /> ' . $this->l('PrestaShop Addons') . '</span> (<a href="' . $linkToSettings . '">' . $this->l('disable') . '</a>)'; } echo ' <div class="clear"> </div> <div id="module_install" style="float: left;' . ((Tools::isSubmit('submitDownload') or Tools::isSubmit('submitDownload2')) ? '' : 'display: none;') . '" class="width1"> <fieldset class="width2"> <legend><img src="../img/admin/add.gif" alt="' . $this->l('Add a new module') . '" class="middle" /> ' . $this->l('Add a new module') . '</legend> <p>' . $this->l('The module must be either a zip file or a tarball.') . '</p> <hr /> <form action="' . $currentIndex . '&token=' . $this->token . '" method="post"> <label style="width: 100px">' . $this->l('Module URL:') . '</label> <div class="margin-form" style="padding-left: 140px"> <input type="text" name="url" style="width: 200px;" value="' . (Tools::getValue('url') ? Tools::getValue('url') : 'http://') . '" /> <p>' . $this->l('Download the module directly from a website.') . '</p> </div> <div class="margin-form" style="padding-left: 140px"> <input type="submit" name="submitDownload" value="' . $this->l('Download this module') . '" class="button" /> </div> </form> <hr /> <form action="' . $currentIndex . '&token=' . $this->token . '" method="post" enctype="multipart/form-data"> <label style="width: 100px">' . $this->l('Module file:') . '</label> <div class="margin-form" style="padding-left: 140px"> <input type="file" name="file" /> <p>' . $this->l('Upload the module from your computer.') . '</p> </div> <div class="margin-form" style="padding-left: 140px"> <input type="submit" name="submitDownload2" value="' . $this->l('Upload this module') . '" class="button" /> </div> </form> </fieldset> </div>'; if (Configuration::get('PRESTASTORE_LIVE')) { echo ' <div id="prestastore" style="margin-left:40px; display:none; float: left" class="width1"> <fieldset> <legend><img src="http://addons.prestashop.com/modules.php?' . (isset($_SERVER['SERVER_ADDR']) ? 'server=' . ip2long($_SERVER['SERVER_ADDR']) . '&' : '') . 'mods=' . $serialModules . '" class="middle" />' . $this->l('Live from PrestaShop Addons!') . '</legend> <div id="prestastore-content"></div> </fieldset> </div>'; } echo '<div class="clear"> </div>'; /* Scan modules directories and load modules classes */ $warnings = array(); $orderModule = array(); $irow = 0; foreach ($modules as $module) { $orderModule[(isset($module->tab) and !empty($module->tab)) ? $module->tab : $this->l('Not specified')][] = $module; } asort($orderModule); foreach ($orderModule as $tabModule) { foreach ($tabModule as $module) { if ($module->active and $module->warning) { $this->displayWarning('<a href="' . $currentIndex . '&configure=' . urlencode($module->name) . '&token=' . $this->token . '">' . $module->displayName . '</a> - ' . stripslashes(pSQL($module->warning))); } } } $nameCountryDefault = Country::getNameById($cookie->id_lang, Configuration::get('PS_COUNTRY_DEFAULT')); echo ' <form method="POST" id="form_all_module" name="fomr_all_module" action=""> <input type="hidden" name="all_module_send" value="" /> <input type="checkbox" name="all_module" style="vertical-align: middle;" id="all_module" ' . (!Configuration::get('PS_SHOW_ALL_MODULES') ? 'checked="checked"' : '') . ' onclick="document.getElementById(\'form_all_module\').submit();" /> <label class="t" for="all_module">' . $this->l('Show only modules that can be used in my country') . '</label> (' . $this->l('Current country:') . ' <a href="index.php?tab=AdminCountries&token=' . Tools::getAdminToken('AdminCountries' . intval(Tab::getIdFromClassName('AdminCountries')) . intval($cookie->id_employee)) . '">' . $nameCountryDefault . '</a>) </form>'; $showAllModules = Configuration::get('PS_SHOW_ALL_MODULES'); $isoCountryDefault = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')); echo ' <div style="float:left; width:300px;">'; /* Browse modules by tab type */ foreach ($orderModule as $tab => $tabModule) { echo '<br /> <table cellpadding="0" cellspacing="0" class="table width3"> <tr> <th colspan="4" class="center" style="cursor: pointer" onclick="openCloseLayer(\'' . addslashes($tab) . '\');"><b>' . $tab . '</b> - <span style="color: red">' . sizeof($tabModule) . '</span> ' . (sizeof($tabModule) > 1 ? $this->l('modules') : $this->l('module')) . '</th> </tr> </table> <div id="' . $tab . '" style="width:600px;"> <table cellpadding="0" cellspacing="0" class="table width3">'; /* Display modules for each tab type */ foreach ($tabModule as $module) { if ($showAllModules || !$showAllModules && (isset($module->limited_countries) && in_array(strtolower($isoCountryDefault), $module->limited_countries) || !isset($module->limited_countries))) { if ($module->id) { $img = '<img src="../img/admin/enabled.gif" alt="' . $this->l('Module enabled') . '" title="' . $this->l('Module enabled') . '" />'; if ($module->warning) { $img = '<img src="../img/admin/warning.gif" alt="' . $this->l('Module installed but with warnings') . '" title="' . $this->l('Module installed but with warnings') . '" />'; } if (!$module->active) { $img = '<img src="../img/admin/disabled.gif" alt="' . $this->l('Module disabled') . '" title="' . $this->l('Module disabled') . '" />'; } } else { $img = '<img src="../img/admin/cog.gif" alt="' . $this->l('Module not installed') . '" title="' . $this->l('Module not installed') . '" />'; } echo ' <tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' style="height: 42px;"> <td style="padding-left: 10px;"><img src="../modules/' . $module->name . '/logo.gif" alt="" /> <b>' . stripslashes($module->displayName) . '</b>' . ($module->version ? ' v' . $module->version . (strpos($module->version, '.') !== false ? '' : '.0') : '') . '<br />' . $module->description . '</td> <td width="85">' . (($module->id and method_exists($module, 'getContent')) ? '<a href="' . $currentIndex . '&configure=' . urlencode($module->name) . '&token=' . $this->token . '">>> ' . $this->l('Configure') . '</a>' : '') . '</td> <td class="center" width="20">'; if ($module->id) { echo '<a href="' . $currentIndex . '&token=' . $this->token . '&module_name=' . $module->name . '&' . ($module->active ? 'desactive' : 'active') . '">'; } echo $img; if ($module->id) { '</a>'; } echo ' </td> <td class="center" width="80">' . (!$module->id ? '<input type="button" class="button small" name="Install" value="' . $this->l('Install') . '" onclick="javascript:document.location.href=\'' . $currentIndex . '&install=' . urlencode($module->name) . '&token=' . $this->token . '\'" />' : '<input type="button" class="button small" name="Uninstall" value="' . $this->l('Uninstall') . '" onclick="' . (empty($module->confirmUninstall) ? '' : 'if(confirm(\'' . addslashes($module->confirmUninstall) . '\')) ') . 'document.location.href=\'' . $currentIndex . '&uninstall=' . urlencode($module->name) . '&token=' . $this->token . '\';" />') . '</td> <td style="padding-right: 10px"> <input type="checkbox" name="modules" value="' . urlencode($module->name) . '" ' . (empty($module->confirmUninstall) ? 'rel="false"' : 'rel="' . addslashes($module->confirmUninstall) . '"') . ' /> </td> </tr>'; } } echo '</table> </div>'; } echo ' <div style="margin-top: 12px; width:600px;" class="center"> <input type="button" class="button small" value="' . $this->l('Install the selection') . '" onclick="modules_management(\'install\')"/> <input type="button" class="button small" value="' . $this->l('Uninstall the selection') . '" onclick="modules_management(\'uninstall\')" /> </div> </div> <div style="float:right; width:300px;"> <br /> <table cellpadding="0" cellspacing="0" class="table width3" style="width:300px;"><tr><th colspan="4" class="center"><strong>' . $this->l('Icon legend') . '</strong></th></tr></table> <table cellpadding="0" cellspacing="0" class="table width3" style="width:300px;"><tr style="height: 42px;"> <td> <table cellpadding="10" cellspacing="5"> <tr><td><img src="../img/admin/cog.gif" /> ' . $this->l('Module not installed') . '</td></tr> <tr><td><img src="../img/admin/enabled.gif" /> ' . $this->l('Module installed and enabled') . '</td></tr> <tr><td><img src="../img/admin/disabled.gif" /> ' . $this->l('Module installed but disabled') . '</td></tr> <tr><td><img src="../img/admin/warning.gif" /> ' . $this->l('Module installed but some warnings') . '</td></tr> </table> </td> </tr></table> </div> <div style="clear:both"> </div>'; }
/** * it is used to create a list of relevant addresses for given address. * used in admin panel to validate the postcode * * @param array $address The content will be the edit form for address from admin * $address contain next keys * MANDATORY * country * city * * OPTIONAL * region * address * street * @return bool|string */ public function findAllSimilarAddressesForAddress($address) { $address['region'] = ''; $country_name = ''; if (!empty($address['country_id'])) { $country_object = new Country(); $country_name = $country_object->getNameById($address['lang_id'], $address['country_id']); $address['country'] = $country_name; } if ($this->isEnabledAutocompleteForPostcode($country_name)) { if ($address['region_id']) { $region_name = State::getNameById($address['region_id']); $address['region'] = $region_name; } if (empty($address['region'])) { $regions = DpdGroupDpdPostcodeMysql::identifyRegionByCity($address['city']); if ($regions && count($regions) == 1) { $address['region'] = array_pop($regions); } } $found_addresses = self::getInstance()->searchSimilarAddresses($address); return $found_addresses; } return false; }
private function getVATDetailsByCountry() { $user_lang = (int) $this->context->employee->id_lang; $euro_vat_array = self::$europe_vat_array; $available_vat_array = $this->getAvailableTaxesDetails(); foreach ($euro_vat_array as $euro_vat_name => $eur_vat_details) { $country_id = Country::getByIso((string) $eur_vat_details['iso_country']); $country_name = Country::getNameById($user_lang, (int) $country_id); if (in_array($euro_vat_name, $available_vat_array)) { $id_tax = array_search($euro_vat_name, $available_vat_array); $euro_vat_array[$euro_vat_name]['vat_found'] = array('label' => (string) $available_vat_array[$id_tax], 'id_tax' => (int) $id_tax); } else { $euro_vat_array[$euro_vat_name]['vat_found'] = false; } $euro_vat_array[$euro_vat_name]['eur_vat_label'] = (string) $country_name . ' (' . (string) $eur_vat_details['iso_country'] . ')' . (Tools::strlen($euro_vat_name) > 3 ? ' - ' . (string) Tools::substr($euro_vat_name, -3) : ''); $euro_vat_array[$euro_vat_name]['country_name'] = $country_name; $euro_vat_array[$euro_vat_name]['iso_country'] = (string) $eur_vat_details['iso_country']; $euro_vat_array[$euro_vat_name]['euro_vat_name'] = (string) $euro_vat_name; } return $euro_vat_array; }
* @author: Artem Rossokha <*****@*****.**> */ ?> <div id="table" class="info four2 type3"> <table> <tr> <td class="name"> <h4><?php echo CHtml::encode($data->getName()); ?> </h4> </td> <td> <span><?php echo CHtml::encode(Country::getNameById($data->city->countryId)); ?> </span> <strong style="font-size: 15px;"><?php echo CHtml::encode($data->city->name); ?> </strong> <span><?php echo CHtml::encode(Region::getNameById($data->city->regionId)); ?> </span> </td> <td> <h6><?php echo CHtml::encode($data->scopeOfActivity->name); ?>
/** * Display edit country settings page * * @param int $id_sm_kiala_country * @return string */ function _displayEditCountry($id_sm_kiala_country) { global $cookie, $currentIndex; $kiala_country = new SmKialaCountry($id_sm_kiala_country); return ' <form action="index.php?tab=' . htmlentities(Tools::getValue('tab')) . '&configure=' . Tools::getValue('configure') . '&token=' . Tools::getValue('token') . '&tab_module=' . Tools::getValue('tab_module') . '&module_name=' . Tools::getValue('module_name') . '" method="post"> <fieldset> <legend><img src="../img/admin/picture.gif" />' . Country::getNameById($cookie->id_lang, $kiala_country->id_country) . '</legend><br /> <label>' . $this->l('Kiala User ID:') . ' </label> <div class="margin-form"> <input type="text" name="dspid" id="dspid" size="30" value="' . htmlentities($kiala_country->dspid, ENT_COMPAT, 'UTF-8') . '" /> </div> <label>' . $this->l('Kiala Sender ID:') . ' </label> <div class="margin-form"> <input type="text" name="sender_id" id="sender_id" size="30" value="' . htmlentities($kiala_country->sender_id, ENT_COMPAT, 'UTF-8') . '" /> </div> <label>' . $this->l('Kiala password:'******' </label> <div class="margin-form"> <input type="password" name="password" id="password" size="30" value="' . htmlentities($kiala_country->password, ENT_COMPAT, 'UTF-8') . '" /> </div> <label>' . $this->l('Preparation delay:') . ' </label> <div class="margin-form"> <input type="text" name="preparation_delay" id="preparation_delay" size="3" value="' . (int) $kiala_country->preparation_delay . '" /> </div> <label>' . $this->l('Active:') . ' </label> <div class="margin-form"> <input type="radio" name="kiala_active" id="active_on" value="1" ' . ($kiala_country->active ? 'checked="checked" ' : '') . '/> <label class="t" for="active_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" /></label> <input type="radio" name="kiala_active" id="active_off" value="0" ' . (!$kiala_country->active ? 'checked="checked" ' : '') . '/> <label class="t" for="active_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" /></label> <p>' . $this->l('If not active Kiala will not be available for customers of this country') . '</p> </div> <input type="hidden" name="id_sm_kiala_country" value="' . (int) $id_sm_kiala_country . '"/> <div class="margin-form"> <input type="submit" value="' . $this->l(' Save ') . '" name="submitEditCountry" class="button" /> </div> <div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div> </fieldset> </form> <br /><br /><a href="index.php?tab=' . Tools::safeOutput(Tools::getValue('tab') . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&tab_module=' . Tools::getValue('tab_module') . '&module_name=' . Tools::getValue('module_name')) . '"><img src="../img/admin/arrow2.gif" /> ' . $this->l('Back to list') . '</a><br />'; }
protected function getFormFieldsValue() { $name = Configuration::get('PS_SHOP_NAME'); //employee name $this->context->employee->firstname; $email = Configuration::get('PS_SHOP_EMAIL'); $phone = Configuration::get('PS_SHOP_PHONE'); $country = Country::getNameById($this->context->language->id, (int) Configuration::get('PS_SHOP_COUNTRY_ID')); $company = Configuration::get('PS_SHOP_NAME'); return array('CASHWAY_API_KEY' => Tools::getValue('CASHWAY_API_KEY', Configuration::get('CASHWAY_API_KEY')), 'CASHWAY_API_SECRET' => Tools::getValue('CASHWAY_API_SECRET', Configuration::get('CASHWAY_API_SECRET')), 'CASHWAY_PAYMENT_TEMPLATE' => Tools::getValue('CASHWAY_PAYMENT_TEMPLATE', Configuration::get('CASHWAY_PAYMENT_TEMPLATE')), 'CASHWAY_SEND_EMAIL' => Tools::getValue('CASHWAY_SEND_EMAIL', Configuration::get('CASHWAY_SEND_EMAIL')), 'CASHWAY_OS_PAYMENT' => (int) Tools::getValue('CASHWAY_OS_PAYMENT', Configuration::get('CASHWAY_OS_PAYMENT')), 'name' => Tools::getValue('name', $name), 'email' => Tools::getValue('email', $email), 'phone' => Tools::getValue('phone', $phone), 'country' => Tools::getValue('country', $country), 'company' => Tools::getValue('company', $company)); }
public function storeContactImportOne($info, $shop_is_feature_active, $regenerate, $force_ids, $validateOnly = false) { AdminImportController::setDefaultValues($info); if ($force_ids && isset($info['id']) && (int) $info['id']) { $store = new Store((int) $info['id']); } else { if (array_key_exists('id', $info) && (int) $info['id'] && Store::existsInDatabase((int) $info['id'], 'store')) { $store = new Store((int) $info['id']); } else { $store = new Store(); } } AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $store); if (isset($store->image) && !empty($store->image)) { if (!AdminImportController::copyImg($store->id, null, $store->image, 'stores', !$regenerate)) { $this->warnings[] = $store->image . ' ' . $this->trans('cannot be copied.', array(), 'Admin.Parameters.Notification'); } } if (isset($store->hours) && is_array($store->hours)) { $store->hours = serialize($store->hours); } if (isset($store->country) && is_numeric($store->country)) { if (Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), (int) $store->country)) { $store->id_country = (int) $store->country; } } elseif (isset($store->country) && is_string($store->country) && !empty($store->country)) { if ($id_country = Country::getIdByName(null, $store->country)) { $store->id_country = (int) $id_country; } else { $country = new Country(); $country->active = 1; $country->name = AdminImportController::createMultiLangField($store->country); $country->id_zone = 0; // Default zone for country to create $country->iso_code = Tools::strtoupper(Tools::substr($store->country, 0, 2)); // Default iso for country to create $country->contains_states = 0; // Default value for country to create $lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true); if (($field_error = $country->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $country->add()) { $store->id_country = (int) $country->id; } else { if (!$validateOnly) { $default_language_id = (int) Configuration::get('PS_LANG_DEFAULT'); $this->errors[] = sprintf($this->trans('%s cannot be saved', array(), 'Admin.Parameters.Notification'), $country->name[$default_language_id]); } if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) { $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } } } if (isset($store->state) && is_numeric($store->state)) { if (State::getNameById((int) $store->state)) { $store->id_state = (int) $store->state; } } elseif (isset($store->state) && is_string($store->state) && !empty($store->state)) { if ($id_state = State::getIdByName($store->state)) { $store->id_state = (int) $id_state; } else { $state = new State(); $state->active = 1; $state->name = $store->state; $state->id_country = isset($country->id) ? (int) $country->id : 0; $state->id_zone = 0; // Default zone for state to create $state->iso_code = Tools::strtoupper(Tools::substr($store->state, 0, 2)); // Default iso for state to create $state->tax_behavior = 0; if (($field_error = $state->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $state->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $state->add()) { $store->id_state = (int) $state->id; } else { if (!$validateOnly) { $this->errors[] = sprintf($this->trans('%s cannot be saved', array(), 'Admin.Parameters.Notification'), $state->name); } if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) { $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } } } $res = false; if (($field_error = $store->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $store->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { if ($store->id && $store->storeExists($store->id)) { $res = $validateOnly ? $validateOnly : $store->update(); } $store->force_id = (bool) $force_ids; if (!$res) { $res = $validateOnly ? $validateOnly : $store->add(); } if (!$res) { $this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), $info['name'], isset($info['id']) ? $info['id'] : 'null'); } } else { $this->errors[] = $this->l('Store is invalid') . ' (' . $store->name . ')'; $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''); } }
public function getContent() { $this->_postProcess(); if (($id_lang = Language::getIdByIso('EN')) == 0) { $english_language_id = (int) $this->context->employee->id_lang; } else { $english_language_id = (int) $id_lang; } $this->context->smarty->assign(array('PayPal_WPS' => (int) WPS, 'PayPal_HSS' => (int) HSS, 'PayPal_ECS' => (int) ECS, 'PP_errors' => $this->_errors, 'PayPal_logo' => $this->paypal_logos->getLogos(), 'PayPal_allowed_methods' => $this->getPaymentMethods(), 'PayPal_country' => Country::getNameById((int) $english_language_id, (int) $this->default_country), 'PayPal_country_id' => (int) $this->default_country, 'PayPal_business' => Configuration::get('PAYPAL_BUSINESS'), 'PayPal_payment_method' => (int) Configuration::get('PAYPAL_PAYMENT_METHOD'), 'PayPal_api_username' => Configuration::get('PAYPAL_API_USER'), 'PayPal_api_password' => Configuration::get('PAYPAL_API_PASSWORD'), 'PayPal_api_signature' => Configuration::get('PAYPAL_API_SIGNATURE'), 'PayPal_api_business_account' => Configuration::get('PAYPAL_BUSINESS_ACCOUNT'), 'PayPal_express_checkout_shortcut' => (int) Configuration::get('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT'), 'PayPal_sandbox_mode' => (int) Configuration::get('PAYPAL_SANDBOX'), 'PayPal_payment_capture' => (int) Configuration::get('PAYPAL_CAPTURE'), 'PayPal_country_default' => (int) $this->default_country, 'PayPal_change_country_url' => 'index.php?tab=AdminCountries&token=' . Tools::getAdminTokenLite('AdminCountries') . '#footer', 'Countries' => Country::getCountries($english_language_id))); $this->getTranslations(); return $this->fetchTemplate('/views/templates/back/', 'back_office'); }
public function initContent() { $this->meta_title = 'Modules'; // If we are on a module configuration, no need to load all modules if (Tools::getValue('configure') != '') { return true; } $this->initToolbar(); $this->initPageHeaderToolbar(); // Init $smarty = $this->context->smarty; $autocompleteList = 'var moduleList = ['; $nameCountryDefault = Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT')); $categoryFiltered = array(); $filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_' . (int) $this->id_employee)); if (count($filterCategories) > 0) { foreach ($filterCategories as $fc) { if (!empty($fc)) { $categoryFiltered[$fc] = 1; } } } if (empty($categoryFiltered) && Tools::getValue('tab_module')) { $categoryFiltered[Tools::getValue('tab_module')] = 1; } foreach ($this->list_modules_categories as $k => $v) { $this->list_modules_categories[$k]['nb'] = 0; } // Retrieve Modules Preferences $modules_preferences = ''; $tab_modules_preferences = array(); $modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'module_preference` WHERE `id_employee` = ' . (int) $this->id_employee); $tab_modules_preferences_tmp = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'tab_module_preference` WHERE `id_employee` = ' . (int) $this->id_employee); foreach ($tab_modules_preferences_tmp as $i => $j) { $tab_modules_preferences[$j['module']][] = $j['id_tab']; } foreach ($modules_preferences_tmp as $k => $v) { if ($v['interest'] == null) { unset($v['interest']); } if ($v['favorite'] == null) { unset($v['favorite']); } $modules_preferences[$v['module']] = $v; } // Retrieve Modules List $modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee); $this->initModulesList($modules); $this->nb_modules_total = count($modules); $module_errors = array(); $module_success = array(); $upgrade_available = array(); $dont_filter = false; // Browse modules list foreach ($modules as $km => $module) { //if we are in favorites view we only display installed modules if (Tools::getValue('select') == 'favorites' && !$module->id) { unset($modules[$km]); continue; } // Upgrade Module process, init check if a module could be upgraded if (Module::initUpgradeModule($module)) { // When the XML cache file is up-to-date, the module may not be loaded yet if (!class_exists($module->name)) { if (!file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) { continue; } require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php'; } if ($object = new $module->name()) { $object->runUpgradeModule(); if (count($errors_module_list = $object->getErrors())) { $module_errors[] = array('name' => $module->displayName, 'message' => $errors_module_list); } else { if (count($conf_module_list = $object->getConfirmations())) { $module_success[] = array('name' => $module->displayName, 'message' => $conf_module_list); } } unset($object); } } elseif (Module::getUpgradeStatus($module->name)) { // When the XML cache file is up-to-date, the module may not be loaded yet if (!class_exists($module->name)) { if (file_exists(_PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php')) { require_once _PS_MODULE_DIR_ . $module->name . '/' . $module->name . '.php'; $object = new $module->name(); $module_success[] = array('name' => $module->name, 'message' => array(0 => sprintf($this->l('Current version: %s'), $object->version), 1 => $this->l('No file upgrades applied (none exist).'))); } else { continue; } } unset($object); } elseif (Tools::getValue('updated') && Tools::getValue('module_name')) { $module_names = (string) Tools::getValue('module_name'); if (strpos($module_names, '|')) { $module_names = explode('|', $module_names); $dont_filter = true; } if (!is_array($module_names)) { $module_names = (array) $module_names; } if (in_array($module->name, $module_names)) { $module_success[] = array('name' => $module->displayName, 'message' => array(0 => sprintf($this->l('Current version: %s'), $module->version))); } } // Make modules stats $this->makeModulesStats($module); // Assign warnings if ($module->active && isset($module->warning) && !empty($module->warning) && !$this->ajax) { $href = Context::getContext()->link->getAdminLink('AdminModules', true) . '&module_name=' . $module->name . '&tab_module=' . $module->tab . '&configure=' . $module->name; $this->context->smarty->assign('text', sprintf($this->l('%1$s: %2$s'), $module->displayName, $module->warning)); $this->context->smarty->assign('module_link', $href); $this->displayWarning($this->context->smarty->fetch('controllers/modules/warning_module.tpl')); } // AutoComplete array $autocompleteList .= Tools::jsonEncode(array('displayName' => (string) $module->displayName, 'desc' => (string) $module->description, 'name' => (string) $module->name, 'author' => (string) $module->author, 'image' => isset($module->image) ? (string) $module->image : '', 'option' => '')) . ', '; // Apply filter if ($this->isModuleFiltered($module) && Tools::getValue('select') != 'favorites') { unset($modules[$km]); } else { if (isset($modules_preferences[$modules[$km]->name])) { $modules[$km]->preferences = $modules_preferences[$modules[$km]->name]; } $this->fillModuleData($module, 'array'); $module->categoryName = isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name']; } unset($object); if ($module->installed && isset($module->version_addons) && $module->version_addons) { $upgrade_available[] = array('anchor' => ucfirst($module->name), 'name' => $module->name, 'displayName' => $module->displayName); } if (in_array($module->name, $this->list_partners_modules)) { $module->type = 'addonsPartner'; } if (isset($module->description_full) && trim($module->description_full) != '') { $module->show_quick_view = true; } } // Don't display categories without modules $cleaned_list = array(); foreach ($this->list_modules_categories as $k => $list) { if ($list['nb'] > 0) { $cleaned_list[$k] = $list; } } // Actually used for the report of the upgraded errors if (count($module_errors)) { $html = $this->generateHtmlMessage($module_errors); $this->errors[] = sprintf(Tools::displayError('The following module(s) were not upgraded successfully: %s'), $html); } if (count($module_success)) { $html = $this->generateHtmlMessage($module_success); $this->confirmations[] = sprintf($this->l('The following module(s) were upgraded successfully:') . ' %s', $html); } ConfigurationKPI::updateValue('UPDATE_MODULES', count($upgrade_available)); if (count($upgrade_available) == 0 && (int) Tools::getValue('check') == 1) { $this->confirmations[] = $this->l('Everything is up-to-date'); } // Init tpl vars for smarty $tpl_vars = array('token' => $this->token, 'upgrade_available' => $upgrade_available, 'currentIndex' => self::$currentIndex, 'dirNameCurrentIndex' => dirname(self::$currentIndex), 'ajaxCurrentIndex' => str_replace('index', 'ajax-tab', self::$currentIndex), 'autocompleteList' => rtrim($autocompleteList, ' ,') . '];', 'showTypeModules' => $this->filter_configuration['PS_SHOW_TYPE_MODULES_' . (int) $this->id_employee], 'showCountryModules' => $this->filter_configuration['PS_SHOW_COUNTRY_MODULES_' . (int) $this->id_employee], 'showInstalledModules' => $this->filter_configuration['PS_SHOW_INSTALLED_MODULES_' . (int) $this->id_employee], 'showEnabledModules' => $this->filter_configuration['PS_SHOW_ENABLED_MODULES_' . (int) $this->id_employee], 'nameCountryDefault' => Country::getNameById($this->context->language->id, Configuration::get('PS_COUNTRY_DEFAULT')), 'isoCountryDefault' => $this->iso_default_country, 'categoryFiltered' => $categoryFiltered, 'modules' => $modules, 'nb_modules' => $this->nb_modules_total, 'nb_modules_favorites' => count($this->context->employee->favoriteModulesList()), 'nb_modules_installed' => $this->nb_modules_installed, 'nb_modules_uninstalled' => $this->nb_modules_total - $this->nb_modules_installed, 'nb_modules_activated' => $this->nb_modules_activated, 'nb_modules_unactivated' => $this->nb_modules_installed - $this->nb_modules_activated, 'list_modules_categories' => $cleaned_list, 'list_modules_authors' => $this->modules_authors, 'add_permission' => $this->tabAccess['add'], 'tab_modules_preferences' => $tab_modules_preferences, 'kpis' => $this->renderKpis(), 'module_name' => Tools::getValue('module_name'), 'page_header_toolbar_title' => $this->page_header_toolbar_title, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn, 'modules_uri' => __PS_BASE_URI__ . basename(_PS_MODULE_DIR_), 'dont_filter' => $dont_filter); if ($this->logged_on_addons) { $tpl_vars['logged_on_addons'] = 1; $tpl_vars['username_addons'] = $this->context->cookie->username_addons; } $smarty->assign($tpl_vars); }
public function addressImport() { $this->receiveTab(); $default_language_id = (int) Configuration::get('PS_LANG_DEFAULT'); $handle = $this->openCsvFile(); AdminImportController::setLocale(); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) { if (Tools::getValue('convert')) { $line = $this->utf8EncodeArray($line); } $info = AdminImportController::getMaskedRow($line); AdminImportController::setDefaultValues($info); $address = new Address(); AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $address); if (isset($address->country) && is_numeric($address->country)) { if (Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), (int) $address->country)) { $address->id_country = (int) $address->country; } } elseif (isset($address->country) && is_string($address->country) && !empty($address->country)) { if ($id_country = Country::getIdByName(null, $address->country)) { $address->id_country = (int) $id_country; } else { $country = new Country(); $country->active = 1; $country->name = AdminImportController::createMultiLangField($address->country); $country->id_zone = 0; // Default zone for country to create $country->iso_code = Tools::strtoupper(Tools::substr($address->country, 0, 2)); // Default iso for country to create $country->contains_states = 0; // Default value for country to create $lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true); if (($field_error = $country->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $country->add()) { $address->id_country = (int) $country->id; } else { $this->errors[] = sprintf(Tools::displayError('%s cannot be saved'), $country->name[$default_language_id]); $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } } if (isset($address->state) && is_numeric($address->state)) { if (State::getNameById((int) $address->state)) { $address->id_state = (int) $address->state; } } elseif (isset($address->state) && is_string($address->state) && !empty($address->state)) { if ($id_state = State::getIdByName($address->state)) { $address->id_state = (int) $id_state; } else { $state = new State(); $state->active = 1; $state->name = $address->state; $state->id_country = isset($country->id) ? (int) $country->id : 0; $state->id_zone = 0; // Default zone for state to create $state->iso_code = Tools::strtoupper(Tools::substr($address->state, 0, 2)); // Default iso for state to create $state->tax_behavior = 0; if (($field_error = $state->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $state->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $state->add()) { $address->id_state = (int) $state->id; } else { $this->errors[] = sprintf(Tools::displayError('%s cannot be saved'), $state->name); $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } } if (isset($address->customer_email) && !empty($address->customer_email)) { if (Validate::isEmail($address->customer_email)) { // a customer could exists in different shop $customer_list = Customer::getCustomersByEmail($address->customer_email); if (count($customer_list) == 0) { $this->errors[] = sprintf(Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s), and therefore cannot be saved.'), Db::getInstance()->getMsgError(), $address->customer_email, isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null'); } } else { $this->errors[] = sprintf(Tools::displayError('"%s" is not a valid email address.'), $address->customer_email); continue; } } elseif (isset($address->id_customer) && !empty($address->id_customer)) { if (Customer::customerIdExistsStatic((int) $address->id_customer)) { $customer = new Customer((int) $address->id_customer); // a customer could exists in different shop $customer_list = Customer::getCustomersByEmail($customer->email); if (count($customer_list) == 0) { $this->errors[] = sprintf(Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s), and therefore cannot be saved.'), Db::getInstance()->getMsgError(), $customer->email, (int) $address->id_customer); } } else { $this->errors[] = sprintf(Tools::displayError('The customer ID #%d does not exist in the database, and therefore cannot be saved.'), $address->id_customer); } } else { $customer_list = array(); $address->id_customer = 0; } if (isset($address->manufacturer) && is_numeric($address->manufacturer) && Manufacturer::manufacturerExists((int) $address->manufacturer)) { $address->id_manufacturer = (int) $address->manufacturer; } elseif (isset($address->manufacturer) && is_string($address->manufacturer) && !empty($address->manufacturer)) { $manufacturer = new Manufacturer(); $manufacturer->name = $address->manufacturer; if (($field_error = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $manufacturer->add()) { $address->id_manufacturer = (int) $manufacturer->id; } else { $this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $manufacturer->name, isset($manufacturer->id) && !empty($manufacturer->id) ? $manufacturer->id : 'null'); $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } if (isset($address->supplier) && is_numeric($address->supplier) && Supplier::supplierExists((int) $address->supplier)) { $address->id_supplier = (int) $address->supplier; } elseif (isset($address->supplier) && is_string($address->supplier) && !empty($address->supplier)) { $supplier = new Supplier(); $supplier->name = $address->supplier; if (($field_error = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $supplier->add()) { $address->id_supplier = (int) $supplier->id; } else { $this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $supplier->name, isset($supplier->id) && !empty($supplier->id) ? $supplier->id : 'null'); $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } $res = false; if (($field_error = $address->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $address->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { if (isset($customer_list) && count($customer_list) > 0) { $filter_list = array(); foreach ($customer_list as $customer) { if (in_array($customer['id_customer'], $filter_list)) { continue; } $filter_list[] = $customer['id_customer']; unset($address->id); $address->id_customer = $customer['id_customer']; $res = $address->add(); if (!$res) { $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $info['alias'], isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null'); } } } else { $address->force_id = (bool) Tools::getValue('forceIDs'); if ($address->id && $address->addressExists($address->id)) { $res = $address->update(); } if (!$res) { $res = $address->add(); } } } if (!$res) { $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $info['alias'], isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null'); $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } $this->closeCsvFile($handle); }
public function addressImport() { $this->receiveTab(); $defaultLanguageId = (int) Configuration::get('PS_LANG_DEFAULT'); $handle = $this->openCsvFile(); self::setLocale(); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, Tools::getValue('separator')); $current_line++) { if (Tools::getValue('convert')) { $line = $this->utf8_encode_array($line); } $info = self::getMaskedRow($line); self::setDefaultValues($info); $address = new Address(); self::array_walk($info, array('AdminImport', 'fillInfo'), $address); if (isset($address->country) and is_numeric($address->country)) { if (Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), (int) $address->country)) { $address->id_country = (int) $address->country; } } elseif (isset($address->country) and is_string($address->country) and !empty($address->country)) { if ($id_country = Country::getIdByName(NULL, $address->country)) { $address->id_country = (int) $id_country; } else { $country = new Country(); $country->active = 1; $country->name = self::createMultiLangField($address->country); $country->id_zone = 0; // Default zone for country to create $country->iso_code = strtoupper(substr($address->country, 0, 2)); // Default iso for country to create $country->contains_states = 0; // Default value for country to create $langFieldError = $country->validateFieldsLang(UNFRIENDLY_ERROR, true); if (($fieldError = $country->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $country->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $country->add()) { $address->id_country = (int) $country->id; } else { $this->_errors[] = $country->name[$defaultLanguageId] . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } } if (isset($address->state) and is_numeric($address->state)) { if (State::getNameById((int) $address->state)) { $address->id_state = (int) $address->state; } } elseif (isset($address->state) and is_string($address->state) and !empty($address->state)) { if ($id_state = State::getIdByName($address->state)) { $address->id_state = (int) $id_state; } else { $state = new State(); $state->active = 1; $state->name = $address->state; $state->id_country = isset($country->id) ? (int) $country->id : 0; $state->id_zone = 0; // Default zone for state to create $state->iso_code = strtoupper(substr($address->state, 0, 2)); // Default iso for state to create $state->tax_behavior = 0; if (($fieldError = $state->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $state->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $state->add()) { $address->id_state = (int) $state->id; } else { $this->_errors[] = $state->name . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } } if (isset($address->customer_email) and !empty($address->customer_email)) { if (Validate::isEmail($address->customer_email)) { $customer = Customer::customerExists($address->customer_email, true); if ($customer) { $address->id_customer = (int) $customer; } else { $this->_errors[] = mysql_error() . ' ' . $address->customer_email . ' ' . Tools::displayError('does not exist in database') . ' ' . (isset($info['id']) ? ' (ID ' . $info['id'] . ')' : '') . ' ' . Tools::displayError('Cannot be saved'); } } else { $this->_errors[] = '"' . $address->customer_email . '" :' . Tools::displayError('Is not a valid Email'); } } if (isset($address->manufacturer) and is_numeric($address->manufacturer) and Manufacturer::manufacturerExists((int) $address->manufacturer)) { $address->id_manufacturer = (int) $address->manufacturer; } elseif (isset($address->manufacturer) and is_string($address->manufacturer) and !empty($address->manufacturer)) { $manufacturer = new Manufacturer(); $manufacturer->name = $address->manufacturer; if (($fieldError = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $manufacturer->add()) { $address->id_manufacturer = (int) $manufacturer->id; } else { $this->_errors[] = mysql_error() . ' ' . $manufacturer->name . (isset($manufacturer->id) ? ' (' . $manufacturer->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } if (isset($address->supplier) and is_numeric($address->supplier) and Supplier::supplierExists((int) $address->supplier)) { $address->id_supplier = (int) $address->supplier; } elseif (isset($address->supplier) and is_string($address->supplier) and !empty($address->supplier)) { $supplier = new Supplier(); $supplier->name = $address->supplier; if (($fieldError = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $supplier->add()) { $address->id_supplier = (int) $supplier->id; } else { $this->_errors[] = mysql_error() . ' ' . $supplier->name . (isset($supplier->id) ? ' (' . $supplier->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } $res = false; if (($fieldError = $address->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $address->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { if ($address->id and $address->addressExists($address->id)) { $res = $address->update(); } if (!$res) { $res = $address->add(); } } if (!$res) { $this->_errors[] = $info['alias'] . (isset($info['id']) ? ' (ID ' . $info['id'] . ')' : '') . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } $this->closeCsvFile($handle); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); if (Tools::isSubmit('ajax') && Tools::getValue('method') == 'updateExtraCarrier') { // Change virtualy the currents delivery options $delivery_option = $this->context->cart->getDeliveryOption(); $delivery_option[(int) Tools::getValue('id_address')] = Tools::getValue('id_delivery_option'); $this->context->cart->setDeliveryOption($delivery_option); $this->context->cart->save(); $return = array('content' => Hook::exec('displayCarrierList', array('address' => new Address((int) Tools::getValue('id_address'))))); die(Tools::jsonEncode($return)); } // start of implementation of the module code - taxamo if ((int) $this->step == 2) { // $this->errors = array_merge($this->errors, $taxamo_errores); // $this->step = 0; $merchants_self_settings = Tools::getMerchantsSelfSettings(); if ($merchants_self_settings['allow_sms_verification']) { $invoice_address = new Address((int) $this->context->cart->id_address_invoice); $iso_country_code = Country::getIsoById($invoice_address->id_country); $token_taxamo = Tools::getValue('tokenTaxamo'); if ($token_taxamo) { $res_api_verify_sms_token = Tools::taxamoVerifySmsToken($token_taxamo); if (isset($res_api_verify_sms_token['country_code']) && $res_api_verify_sms_token['country_code'] == $iso_country_code) { Taxamoeuvat::updateCCPrefix((int) $this->context->cart->id_customer, null, null, $token_taxamo); } else { $iso_country_residence = Taxamoeuvat::getCountryByCustomer((int) $this->context->cart->id_customer); $cc_prefix = Taxamoeuvat::getPrefixByCustomer((int) $this->context->cart->id_customer); Taxamoeuvat::updateCCPrefix((int) $this->context->cart->id_customer, $iso_country_residence, $cc_prefix, null); } } } if ($taxamo_errores = Tools::taxamoVerifyTaxes($this->context->cart)) { $this->errors = array_merge($this->errors, $taxamo_errores); $this->context->smarty->assign('allow_sms_verification', $merchants_self_settings['allow_sms_verification']); if ($merchants_self_settings['allow_sms_verification']) { $this->context->smarty->assign('iso_country_code', $iso_country_code); $country_name = Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), $invoice_address->id_country); $this->context->smarty->assign('country_name', $country_name); } $this->setTemplate(_PS_MODULE_DIR_ . 'taxamoeuvat/views/templates/front/info.tpl'); return; } } // end of code implementation module - taxamo if ($this->nbProducts) { $this->context->smarty->assign('virtual_cart', $this->context->cart->isVirtualCart()); } if (!Tools::getValue('multi-shipping')) { $this->context->cart->setNoMultishipping(); } // 4 steps to the order switch ((int) $this->step) { case -1: $this->context->smarty->assign('empty', 1); $this->setTemplate(_PS_THEME_DIR_ . 'shopping-cart.tpl'); break; case 1: $this->_assignAddress(); $this->processAddressFormat(); if (Tools::getValue('multi-shipping') == 1) { $this->_assignSummaryInformations(); $this->context->smarty->assign('product_list', $this->context->cart->getProducts()); $this->setTemplate(_PS_THEME_DIR_ . 'order-address-multishipping.tpl'); } else { $this->setTemplate(_PS_THEME_DIR_ . 'order-address.tpl'); } break; case 2: if (Tools::isSubmit('processAddress')) { $this->processAddress(); } $this->autoStep(); $this->_assignCarrier(); $this->setTemplate(_PS_THEME_DIR_ . 'order-carrier.tpl'); break; case 3: // Check that the conditions (so active) were accepted by the customer $cgv = Tools::getValue('cgv') || $this->context->cookie->check_cgv; if (Configuration::get('PS_CONDITIONS') && (!Validate::isBool($cgv) || $cgv == false)) { Tools::redirect('index.php?controller=order&step=2'); } Context::getContext()->cookie->check_cgv = true; // Check the delivery option is set if (!$this->context->cart->isVirtualCart()) { if (!Tools::getValue('delivery_option') && !Tools::getValue('id_carrier') && !$this->context->cart->delivery_option && !$this->context->cart->id_carrier) { Tools::redirect('index.php?controller=order&step=2'); } elseif (!Tools::getValue('id_carrier') && !$this->context->cart->id_carrier) { $deliveries_options = Tools::getValue('delivery_option'); if (!$deliveries_options) { $deliveries_options = $this->context->cart->delivery_option; } foreach ($deliveries_options as $delivery_option) { if (empty($delivery_option)) { Tools::redirect('index.php?controller=order&step=2'); } } } } $this->autoStep(); // Bypass payment step if total is 0 if (($id_order = $this->_checkFreeOrder()) && $id_order) { if ($this->context->customer->is_guest) { $order = new Order((int) $id_order); $email = $this->context->customer->email; $this->context->customer->mylogout(); // If guest we clear the cookie for security reason Tools::redirect('index.php?controller=guest-tracking&id_order=' . urlencode($order->reference) . '&email=' . urlencode($email)); } else { Tools::redirect('index.php?controller=history'); } } $this->_assignPayment(); // assign some informations to display cart $this->_assignSummaryInformations(); $this->setTemplate(_PS_THEME_DIR_ . 'order-payment.tpl'); break; default: $this->_assignSummaryInformations(); $this->setTemplate(_PS_THEME_DIR_ . 'shopping-cart.tpl'); break; } $this->context->smarty->assign(array('currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank)); }
protected function getPSAddress(Customer $customer, ShopgateAddress $shopgateAddress) { // Get country $id_country = Country::getByIso($shopgateAddress->getCountry()); if (!$id_country) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_UNKNOWN_COUNTRY_CODE, 'Invalid country code:' . $id_country, true); } // Get state $id_state = 0; if ($shopgateAddress->getState()) { $id_state = (int) Db::getInstance()->getValue('SELECT `id_state` FROM `' . _DB_PREFIX_ . 'state` WHERE `id_country` = ' . $id_country . ' AND `iso_code` = \'' . pSQL(Tools::substr($shopgateAddress->getState(), 3, 2)) . '\''); } // Create alias $alias = Tools::substr('Shopgate_' . $customer->id . '_' . sha1($customer->id . '-' . $shopgateAddress->getFirstName() . '-' . $shopgateAddress->getLastName() . '-' . $shopgateAddress->getCompany() . '-' . $shopgateAddress->getStreet1() . '-' . $shopgateAddress->getStreet2() . '-' . $shopgateAddress->getZipcode() . '-' . $shopgateAddress->getCity()), 0, 32); // Try getting address id by alias $id_address = Db::getInstance()->getValue('SELECT `id_address` FROM `' . _DB_PREFIX_ . 'address` WHERE `alias` = \'' . pSQL($alias) . '\' AND `id_customer`=' . $customer->id); // Get or create address $address = new Address($id_address ? $id_address : null); if (!$address->id) { $address->id_customer = $customer->id; $address->id_country = $id_country; $address->id_state = $id_state; $address->country = Country::getNameById($this->id_lang, $address->id_country); $address->alias = $alias; $address->company = $shopgateAddress->getCompany(); $address->lastname = $shopgateAddress->getLastName(); $address->firstname = $shopgateAddress->getFirstName(); $address->address1 = $shopgateAddress->getStreet1(); $address->address2 = $shopgateAddress->getStreet2(); $address->postcode = $shopgateAddress->getZipcode(); $address->city = $shopgateAddress->getCity(); $address->phone = $shopgateAddress->getPhone(); $address->phone_mobile = $shopgateAddress->getMobile(); if (!$address->add()) { throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_DATABASE_ERROR, 'Unable to create address', true); } } return $address; }
private function checkAddress() { $company_name = (string) Tools::getValue('company_name'); $company_email = (string) Tools::getValue('company_email'); $company_phone = (string) Tools::getValue('company_phone'); $company_address1 = (string) Tools::getValue('company_address1'); $company_address2 = (string) Tools::getValue('company_address2'); $company_zipcode = (string) Tools::getValue('company_zipcode'); $company_city = (string) Tools::getValue('company_city'); $country_id = (int) Tools::getValue('country_id'); $country = new Country($country_id); if (!is_object($country) || empty($country->id)) { $this->errors[] = Tools::displayError('Country is invalid'); } else { $company_country = Country::getNameById($this->context->language->id, $country_id); } if (!Validate::isGenericName($company_name)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop name', 'AdminStores') . ' »'); } if (!Validate::isEmail($company_email)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop email', 'AdminStores') . ' »'); } if (!Validate::isPhoneNumber($company_phone)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Phone', 'AdminStores') . ' »'); } if (!Validate::isAddress($company_address1)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('Shop address line 1', 'AdminStores') . ' »'); } if ($country->zip_code_format && !$country->checkZipCode($company_zipcode)) { $this->errors[] = Tools::displayError('Your Zip/postal code is incorrect.') . '<br />' . Tools::displayError('It must be entered as follows:') . ' ' . str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))); } elseif (empty($company_zipcode) && $country->need_zip_code) { $this->errors[] = Tools::displayError('A Zip/postal code is required.'); } elseif ($company_zipcode && !Validate::isPostCode($company_zipcode)) { $this->errors[] = Tools::displayError('The Zip/postal code is invalid.'); } if (!Validate::isGenericName($company_city)) { $this->errors[] = sprintf(Tools::displayError('The %s field is required.'), '« ' . Translate::getAdminTranslation('City', 'AdminStores') . ' »'); } // We save these informations in the database // ------------------------------------------ Db::getInstance()->insert('expressmailing_order_address', array('id_address' => 1, 'company_name' => pSQL($company_name), 'company_email' => pSQL($company_email), 'company_address1' => pSQL($company_address1), 'company_address2' => pSQL($company_address2), 'company_zipcode' => pSQL($company_zipcode), 'company_city' => pSQL($company_city), 'country_id' => (int) $country_id, 'company_country' => pSQL($company_country), 'company_phone' => pSQL($company_phone)), false, false, Db::REPLACE); // If no error we update the cart // ------------------------------ if (!count($this->errors)) { $response = array(); $parameters = array('order_session' => $this->order_session, 'account_email' => $company_email); $this->session_api->callExternal('http://www.express-mailing.com/api/cart/ws.php', 'common', 'order', 'update', $parameters, $response); } return !count($this->errors); }