Beispiel #1
0
 /**
  * Overriding check if currency rate is not empty and if currency with the same iso code already exists.
  * If it's true, currency is not added.
  *
  * @see ObjectModelCore::add()
  */
 public function add($autodate = true, $nullValues = false)
 {
     if ((double) $this->conversion_rate <= 0) {
         return false;
     }
     return Currency::exists($this->iso_code, $this->iso_code_num) ? false : parent::add($autodate, $nullValues);
 }
 /**
  * @param SimpleXMLElement $xml
  * @param bool $install_mode
  * @return bool
  * @throws PrestaShopException
  */
 protected function _installCurrencies($xml, $install_mode = false)
 {
     if (isset($xml->currencies->currency)) {
         foreach ($xml->currencies->currency as $data) {
             /** @var SimpleXMLElement $data */
             $attributes = $data->attributes();
             if (Currency::exists($attributes['iso_code'], (int) $attributes['iso_code_num'])) {
                 continue;
             }
             $currency = new Currency();
             $currency->name = (string) $attributes['name'];
             $currency->iso_code = (string) $attributes['iso_code'];
             $currency->iso_code_num = (int) $attributes['iso_code_num'];
             $currency->sign = (string) $attributes['sign'];
             $currency->blank = (int) $attributes['blank'];
             $currency->conversion_rate = 1;
             // This value will be updated if the store is online
             $currency->format = (int) $attributes['format'];
             $currency->decimals = (int) $attributes['decimals'];
             $currency->active = true;
             if (!$currency->validateFields()) {
                 $this->_errors[] = Tools::displayError('Invalid currency properties.');
                 return false;
             }
             if (!Currency::exists($currency->iso_code, $currency->iso_code_num)) {
                 if (!$currency->add()) {
                     $this->_errors[] = Tools::displayError('An error occurred while importing the currency: ') . strval($attributes['name']);
                     return false;
                 }
                 PaymentModule::addCurrencyPermissions($currency->id);
             }
         }
         if (($error = Currency::refreshCurrencies()) !== null) {
             $this->_errors[] = $error;
         }
         if (!count($this->_errors) && $install_mode && isset($attributes['iso_code']) && count($xml->currencies->currency) == 1) {
             $this->iso_currency = $attributes['iso_code'];
         }
     }
     return true;
 }
 public function execValidation($cart)
 {
     global $cookie;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'veritranspay') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $usd = Configuration::get('VT_KURS');
     $cf = Configuration::get('VT_CONVENIENCE_FEE') * 0.01;
     $list_enable_payments = array();
     if (Configuration::get('ENABLED_CREDIT_CARD')) {
         $list_enable_payments[] = "credit_card";
     }
     if (Configuration::get('ENABLED_CIMB')) {
         $list_enable_payments[] = "cimb_clicks";
     }
     if (Configuration::get('ENABLED_MANDIRI')) {
         $list_enable_payments[] = "mandiri_clickpay";
     }
     if (Configuration::get('ENABLED_PERMATAVA')) {
         $list_enable_payments[] = "bank_transfer";
     }
     if (Configuration::get('ENABLED_BRIEPAY')) {
         $list_enable_payments[] = "bri_epay";
     }
     if (Configuration::get('ENABLED_TELKOMSEL_CASH')) {
         $list_enable_payments[] = "telkomsel_cash";
     }
     if (Configuration::get('ENABLED_XL_TUNAI')) {
         $list_enable_payments[] = "xl_tunai";
     }
     if (Configuration::get('ENABLED_MANDIRI_BILL')) {
         $list_enable_payments[] = "echannel";
     }
     if (Configuration::get('ENABLED_BBM_MONEY')) {
         $list_enable_payments[] = "bbm_money";
     }
     if (Configuration::get('ENABLED_INDOMARET')) {
         $list_enable_payments[] = "cstore";
     }
     if (Configuration::get('ENABLED_INDOSAT_DOMPETKU')) {
         $list_enable_payments[] = "indosat_dompetku";
     }
     if (Configuration::get('ENABLED_MANDIRI_ECASH')) {
         $list_enable_payments[] = "mandiri_ecash";
     }
     //error_log(print_r($list_enable_payments,TRUE));
     $veritrans = new Veritrans_Config();
     //SETUP
     Veritrans_Config::$serverKey = Configuration::get('VT_SERVER_KEY');
     Veritrans_Config::$isProduction = Configuration::get('VT_ENVIRONMENT') == 'production' ? true : false;
     $url = Veritrans_Config::getBaseUrl();
     if (version_compare(Configuration::get('PS_VERSION_DB'), '1.5') == -1) {
         $shipping_cost = $cart->getOrderShippingCost();
     } else {
         $shipping_cost = $cart->getTotalShippingCost();
     }
     $currency = new Currency($cookie->id_currency);
     $total = $cart->getOrderTotal(true, Cart::BOTH);
     $mailVars = array();
     $billing_address = new Address($cart->id_address_invoice);
     $delivery_address = new Address($cart->id_address_delivery);
     if (Configuration::get('VT_3D_SECURE') == 'on' || Configuration::get('VT_3D_SECURE') == 1) {
         Veritrans_Config::$is3ds = true;
     }
     if (Configuration::get('VT_SANITIZED') == 'on' || Configuration::get('VT_SANITIZED') == 1) {
         Veritrans_Config::$isSanitized = true;
     }
     //error_log('sanitized '.Configuration::get('VT_SANITIZED'));
     // Billing Address
     $params_billing_address = array('first_name' => $billing_address->firstname, 'last_name' => $billing_address->lastname, 'address' => $billing_address->address1, 'city' => $billing_address->city, 'postal_code' => $billing_address->postcode, 'phone' => $this->determineValidPhone($billing_address->phone, $billing_address->phone_mobile), 'country_code' => 'IDN');
     if ($cart->isVirtualCart()) {
     } else {
         if ($cart->id_address_delivery != $cart->id_address_invoice) {
             $params_shipping_address = array('first_name' => $delivery_address->firstname, 'last_name' => $delivery_address->lastname, 'address' => $delivery_address->address1, 'city' => $delivery_address->city, 'postal_code' => $delivery_address->postcode, 'phone' => $this->determineValidPhone($delivery_address->phone, $delivery_address->phone_mobile), 'country_code' => 'IDN');
         } else {
             $params_shipping_address = $params_billing_address;
         }
     }
     $params_customer_details = array('first_name' => $billing_address->firstname, 'last_name' => $billing_address->lastname, 'email' => $customer->email, 'phone' => $this->determineValidPhone($billing_address->phone, $billing_address->phone_mobile), 'billing_address' => $params_billing_address, 'shipping_address' => $params_shipping_address);
     $items = $this->addCommodities($cart, $shipping_cost, $usd);
     // convert the currency
     $cart_currency = new Currency($cart->id_currency);
     if ($cart_currency->iso_code != 'IDR') {
         // check whether if the IDR is installed or not
         if (Currency::exists('IDR', null)) {
             // use default rate
             if (version_compare(Configuration::get('PS_VERSION_DB'), '1.5') == -1) {
                 $conversion_func = function ($input) use($cart_currency) {
                     return Tools::convertPrice($input, new Currency(Currency::getIdByIsoCode('IDR')), true);
                 };
             } else {
                 $conversion_func = function ($input) use($cart_currency) {
                     return Tools::convertPriceFull($input, $cart_currency, new Currency(Currency::getIdByIsoCode('IDR')));
                 };
             }
         } else {
             // use rate
             $conversion_func = function ($input) {
                 return $input * intval(Configuration::get('VT_KURS'));
             };
         }
         foreach ($items as &$item) {
             $item['price'] = intval(round(call_user_func($conversion_func, $item['price'])));
         }
     } else {
         if ($cart_currency->iso_code == 'IDR') {
             foreach ($items as &$item) {
                 $item['price'] = intval(round($item['price']));
             }
         }
     }
     $this->validateOrder($cart->id, Configuration::get('VT_ORDER_STATE_ID'), $cart->getOrderTotal(true, Cart::BOTH), $this->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
     $gross_amount = 0;
     unset($item);
     foreach ($items as $item) {
         $gross_amount += $item['price'] * $item['quantity'];
     }
     $isBniInstallment = Configuration::get('ENABLED_BNI_INSTALLMENT') == 1;
     $isMandiriInstallment = Configuration::get('ENABLED_MANDIRI_INSTALLMENT') == 1;
     $warning_redirect = false;
     $fullPayment = true;
     $installment_type_val = Configuration::get('VT_ENABLE_INSTALLMENT');
     $param_required;
     switch ($installment_type_val) {
         case 'all_product':
             if ($isBniInstallment) {
                 //$bni_term2 = $this->getTermInstallment('BNI');
                 $a = Configuration::get('VT_INSTALLMENTS_BNI');
                 $term = explode(',', $a);
                 $bni_term = $term;
                 //error_log(print_r($bni_term,true));
                 //error_log($bni_term,true);
             }
             if ($isMandiriInstallment) {
                 $mandiri_term = $this->getTermInstallment('MANDIRI');
                 $a = Configuration::get('VT_INSTALLMENTS_MANDIRI');
                 $term = explode(',', $a);
                 $mandiri_term = $term;
                 //error_log($mandiri_term,true);
                 //error_log(print_r($mandiri_term,true));
             }
             $param_installment = array();
             if ($isBniInstallment) {
                 $param_installment['bni'] = $bni_term;
             }
             if ($isMandiriInstallment) {
                 $param_installment['mandiri'] = $mandiri_term;
             }
             $param_required = "false";
             $fullPayment = false;
             break;
         case 'certain_product':
             $param_installment = null;
             $products_cart = $cart->getProducts();
             $num_product = count($products_cart);
             if ($num_product == 1) {
                 $attr_product = explode(',', $products_cart[0]['attributes_small']);
                 foreach ($attr_product as $att) {
                     $att_trim = ltrim($att);
                     $att_arr = explode(' ', $att_trim);
                     //error_log(print_r($att_arr,true));
                     if (strtolower($att_arr[0]) == 'installment') {
                         $fullPayment = false;
                         $param_installment = array();
                         $param_installment[strtolower($att_arr[1])] = array($att_arr[2]);
                     }
                 }
             } else {
                 $warning_redirect = true;
                 $keys['message'] = 1;
             }
             $param_required = "true";
             break;
         case 'off':
             $param_installment = null;
             break;
     }
     //error_log($param_installment,true);
     // $param_payment_option = array(
     // 	'installment' => array(
     // 						'required' => $param_required,
     // 						'installment_terms' => $param_installment
     // 					)
     // 	);
     $params_all = array('payment_type' => Configuration::get('VT_PAYMENT_TYPE'), 'vtweb' => array('enabled_payments' => $list_enable_payments), 'transaction_details' => array('order_id' => $this->currentOrder, 'gross_amount' => $gross_amount), 'item_details' => $items, 'customer_details' => $params_customer_details);
     if ($gross_amount < 500000) {
         $warning_redirect = true;
         $keys['message'] = 2;
     }
     if (!$warning_redirect && ($isBniInstallment || $isMandiriInstallment) && !$fullPayment) {
         $params_all['vtweb']['payment_options'] = $param_payment_option;
     }
     if (Configuration::get('VT_API_VERSION') == 2 && Configuration::get('VT_PAYMENT_TYPE') != 'vtdirect') {
         try {
             // Redirect to Veritrans VTWeb page
             if ($this->isInstallmentCart($cart->getProducts()) || $installment_type_val == 'all_product') {
                 $keys['isWarning'] = $warning_redirect;
             } else {
                 $keys['isWarning'] = false;
             }
             $keys['redirect_url'] = Veritrans_Vtweb::getRedirectionUrl($params_all);
         } catch (Exception $e) {
             $keys['errors'] = $e->getMessage();
             echo $e->getMessage();
         }
         return $keys;
     } else {
         if (Configuration::get('VT_API_VERSION') == 2 && Configuration::get('VT_PAYMENT_TYPE') == 'vtdirect') {
             echo 'not yet implementation.';
             exit;
         } else {
             echo 'The Veritrans API versions and the payment type is not valid.';
             exit;
         }
     }
 }
 protected function _installCurrencies($xml, $install_mode = false)
 {
     if (isset($xml->currencies->currency)) {
         if (!($feed = Tools::simplexml_load_file('http://www.prestashop.com/xml/currencies.xml')) and !($feed = @simplexml_load_file(dirname(__FILE__) . '/../localization/currencies.xml'))) {
             $this->_errors[] = Tools::displayError('Cannot parse the currencies XML feed.');
             return false;
         }
         foreach ($xml->currencies->currency as $data) {
             $attributes = $data->attributes();
             if (Currency::exists($attributes['iso_code'])) {
                 continue;
             }
             $currency = new Currency();
             $currency->name = strval($attributes['name']);
             $currency->iso_code = strval($attributes['iso_code']);
             $currency->iso_code_num = (int) $attributes['iso_code_num'];
             $currency->sign = strval($attributes['sign']);
             $currency->blank = (int) $attributes['blank'];
             $currency->conversion_rate = 1;
             // This value will be updated if the store is online
             $currency->format = (int) $attributes['format'];
             $currency->decimals = (int) $attributes['decimals'];
             $currency->active = $install_mode;
             if (!$currency->validateFields()) {
                 $this->_errors[] = Tools::displayError('Invalid currency properties.');
                 return false;
             }
             if (!Currency::exists($currency->iso_code)) {
                 if (!$currency->add()) {
                     $this->_errors[] = Tools::displayError('An error occurred while importing the currency: ') . strval($attributes['name']);
                     return false;
                 }
                 PaymentModule::addCurrencyPermissions($currency->id);
             }
         }
         Currency::refreshCurrencies();
         if (!sizeof($this->_errors) and $install_mode and isset($attributes['iso_code']) and sizeof($xml->currencies->currency) == 1) {
             $this->iso_currency = $attributes['iso_code'];
         }
     }
     return true;
 }
Beispiel #5
0
 /**
  * Overriding check if currency with the same iso code already exists.
  * If it's true, currency is doesn't added.
  *
  * @see ObjectModelCore::add()
  */
 public function add($autodate = true, $nullValues = false)
 {
     return Currency::exists($this->iso_code, $this->iso_code_num) ? false : parent::add();
 }
 /**
  * @see AdminController::initProcess()
  */
 public function initProcess()
 {
     if (Tools::isSubmit('SubmitExchangesRates')) {
         if ($this->tabAccess['edit'] === '1') {
             $this->action = 'exchangeRates';
         } else {
             $this->errors[] = Tools::displayError('You do not have permission to edit this.');
         }
     }
     if (Tools::isSubmit('submitAddcurrency') && !Tools::getValue('id_currency') && Currency::exists(Tools::getValue('iso_code'), Tools::getValue('iso_code_num'))) {
         $this->errors[] = Tools::displayError('This currency already exists.');
     }
     if (Tools::isSubmit('submitAddcurrency') && (double) Tools::getValue('conversion_rate') <= 0) {
         $this->errors[] = Tools::displayError('The currency conversion rate can not be equal to 0.');
     }
     parent::initProcess();
 }
Beispiel #7
0
 /**
  * @return string
  */
 public function hookDisplayPayment()
 {
     if (!Currency::exists('EUR', 0)) {
         return '<p class="payment_module" style="color:red;">' . $this->l('Mollie Payment Methods are only available when Euros are activated.') . '</p>';
     }
     $issuer_setting = $this->getConfigValue('MOLLIE_ISSUERS');
     try {
         $methods = $this->api->methods->all();
         $issuer_list = in_array($issuer_setting, array(self::ISSUERS_ALWAYS_VISIBLE, self::ISSUERS_ON_CLICK)) ? $this->_getIssuerList() : array();
     } catch (Mollie_API_Exception $e) {
         $methods = array();
         $issuer_list = array();
         if ($this->getConfigValue('MOLLIE_DEBUG_LOG') == self::DEBUG_LOG_ERRORS) {
             Logger::addLog(__METHOD__ . ' said: ' . $e->getMessage(), Mollie::ERROR);
         }
         if ($this->getConfigValue('MOLLIE_DISPLAY_ERRORS')) {
             return '<p class="payment_module" style="color:red;">' . $e->getMessage() . '</p>';
         }
     }
     $this->smarty->assign(array('methods' => $methods, 'issuers' => $issuer_list, 'issuer_setting' => $issuer_setting, 'images' => $this->getConfigValue('MOLLIE_IMAGES'), 'warning' => $this->warning, 'msg_pay_with' => $this->lang['Pay with %s'], 'msg_bankselect' => $this->lang['Select your bank:'], 'module' => $this));
     return $this->display(__FILE__, 'mollie_methods.tpl');
 }
Beispiel #8
0
 /**
  * Check technical requirements to make sure the Stripe's module will work properly
  *
  * @return array Requirements tests results
  */
 public function checkRequirements()
 {
     $tests = array('result' => true);
     $tests['curl'] = array('name' => $this->l('PHP cURL extension must be enabled on your server'), 'result' => is_callable('curl_exec'));
     if (Configuration::get('STRIPE_MODE')) {
         $tests['ssl'] = array('name' => $this->l('SSL must be enabled on your store (before entering Live mode)'), 'result' => Configuration::get('PS_SSL_ENABLED') || !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off');
     }
     $tests['currencies'] = array('name' => $this->l('The currency USD or CAD must be enabled on your store'), 'result' => Currency::exists('USD', 0) || Currency::exists('CAD', 0));
     $tests['php52'] = array('name' => $this->l('Your server must run PHP 5.2 or greater'), 'result' => version_compare(PHP_VERSION, '5.2.0', '>='));
     $tests['configuration'] = array('name' => $this->l('Your must sign-up for Stripe and configure your account settings in the module (publishable key, secret key...etc.)'), 'result' => $this->checkSettings());
     if (_PS_VERSION_ < 1.5) {
         $tests['backward'] = array('name' => $this->l('You are using the backward compatibility module'), 'result' => $this->backward, 'resolution' => $this->backward_error);
         $tmp = Module::getInstanceByName('mobile_theme');
         if ($tmp && isset($tmp->version) && !version_compare($tmp->version, '0.3.8', '>=')) {
             $tests['mobile_version'] = array('name' => $this->l('You are currently using the default mobile template, the minimum version required is v0.3.8') . ' (v' . $tmp->version . ' ' . $this->l('detected') . ' - <a target="_blank" href="http://addons.prestashop.com/en/mobile-iphone/6165-prestashop-mobile-template.html">' . $this->l('Please Upgrade') . '</a>)', 'result' => version_compare($tmp->version, '0.3.8', '>='));
         }
     }
     foreach ($tests as $k => $test) {
         if ($k != 'result' && !$test['result']) {
             $tests['result'] = false;
         }
     }
     return $tests;
 }
 public function install()
 {
     include dirname(__FILE__) . '/sql-install.php';
     foreach ($sql as $s) {
         if (!Db::getInstance()->Execute($s)) {
             return false;
         }
     }
     if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('adminOrder') || !$this->registerHook('paymentReturn') || !$this->registerHook('orderConfirmation')) {
         return false;
     }
     $this->registerHook('displayPayment');
     $this->registerHook('rightColumn');
     $this->registerHook('extraRight');
     $this->registerHook('header');
     if (!Configuration::get('KLARNA_PAYMENT_ACCEPTED')) {
         Configuration::updateValue('KLARNA_PAYMENT_ACCEPTED', $this->addState('Klarna: Payment accepted', '#DDEEFF'));
     }
     if (!Configuration::get('KLARNA_PAYMENT_PENDING')) {
         Configuration::updateValue('KLARNA_PAYMENT_PENDING', $this->addState('Klarna : payment in pending verification', '#DDEEFF'));
     }
     /*auto install currencies*/
     $currencies = array('Euro' => array('iso_code' => 'EUR', 'iso_code_num' => 978, 'symbole' => '€', 'format' => 2), 'Danish Krone' => array('iso_code' => 'DKK', 'iso_code_num' => 208, 'symbole' => 'DAN kr.', 'format' => 2), 'krone' => array('iso_code' => 'NOK', 'iso_code_num' => 578, 'symbole' => 'NOK kr', 'format' => 2), 'Krona' => array('iso_code' => 'SEK', 'iso_code_num' => 752, 'symbole' => 'SEK kr', 'format' => 2));
     $languages = array('Swedish' => array('iso_code' => 'se', 'language_code' => 'sv', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'sweden.png'), 'Deutsch' => array('iso_code' => 'de', 'language_code' => 'de', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'germany.png'), 'Dutch' => array('iso_code' => 'nl', 'language_code' => 'nl', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'netherlands.png'), 'Finnish' => array('iso_code' => 'fi', 'language_code' => 'fi', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'finland.jpg'), 'Norwegian' => array('iso_code' => 'no', 'language_code' => 'no', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'norway.png'), 'Danish' => array('iso_code' => 'da', 'language_code' => 'da', 'date_format_lite' => 'Y-m-d', 'date_format_full' => 'Y-m-d H:i:s', 'flag' => 'denmark.png'));
     foreach ($currencies as $key => $val) {
         if (_PS_VERSION_ >= 1.5) {
             $exists = Currency::exists($val['iso_code_num'], $val['iso_code_num']);
         } else {
             $exists = Currency::exists($val['iso_code_num']);
         }
         if (!$exists) {
             $currency = new Currency();
             $currency->name = $key;
             $currency->iso_code = $val['iso_code'];
             $currency->iso_code_num = $val['iso_code_num'];
             $currency->sign = $val['symbole'];
             $currency->conversion_rate = 1;
             $currency->format = $val['format'];
             $currency->decimals = 1;
             $currency->active = true;
             $currency->add();
         }
     }
     Currency::refreshCurrencies();
     $version = str_replace('.', '', _PS_VERSION_);
     $version = substr($version, 0, 2);
     foreach ($languages as $key => $val) {
         $pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . $val['language_code'] . '.xml');
         if ($pack || ($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . $val['language_code'] . '.xml'))) {
             $localizationPack = new LocalizationPack();
             $localizationPack->loadLocalisationPack($pack, array('taxes', 'languages'));
         }
         if (!Language::getIdByIso($val['language_code'])) {
             if (_PS_VERSION_ >= 1.5) {
                 Language::checkAndAddLanguage($val['language_code']);
             } else {
                 $lang = new Language();
                 $lang->name = $key;
                 $lang->iso_code = $val['iso_code'];
                 $lang->language_code = $val['language_code'];
                 $lang->date_format_lite = $val['date_format_lite'];
                 $lang->date_format_full = $val['date_format_full'];
                 $lang->add();
                 $insert_id = (int) $lang->id;
                 $pack = Tools::file_get_contents('http://www.prestashop.com/download/localization/' . $val['iso_code'] . '.xml');
                 $lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . $val['iso_code']));
                 if ($lang_pack) {
                     $flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/' . $val['iso_code'] . '.jpg');
                     if ($flag != null && !preg_match('/<body>/', $flag)) {
                         $file = fopen(dirname(__FILE__) . '/../../img/l/' . $insert_id . '.jpg', 'w');
                         if ($file) {
                             fwrite($file, $flag);
                             fclose($file);
                         }
                     }
                 }
             }
         }
     }
     foreach ($this->countries as $key => $val) {
         $country = new Country(Country::getByIso($key));
         $country->active = true;
         $country->update();
     }
     return true;
 }
 /**
  * @see AdminController::initProcess()
  */
 public function initProcess()
 {
     if (Tools::isSubmit('SubmitExchangesRates')) {
         if ($this->access('edit')) {
             $this->action = 'exchangeRates';
         } else {
             $this->errors[] = $this->trans('You do not have permission to edit this.', array(), 'Admin.Notifications.Error');
         }
     }
     if (Tools::isSubmit('submitAddcurrency') && !Tools::getValue('id_currency') && Currency::exists(Tools::getValue('iso_code'))) {
         $this->errors[] = $this->trans('This currency already exists.', array(), 'Admin.International.Notification');
     }
     if (Tools::isSubmit('submitAddcurrency') && (double) Tools::getValue('conversion_rate') <= 0) {
         $this->errors[] = $this->trans('The currency conversion rate cannot be equal to 0.', array(), 'Admin.International.Notification');
     }
     parent::initProcess();
 }
Beispiel #11
0
 /**
  * Overriding check if currency rate is not empty and if currency with the same iso code already exists.
  * If it's true, currency is not added.
  *
  * @see ObjectModelCore::add()
  */
 public function add($autodate = true, $nullValues = false)
 {
     if ((double) $this->conversion_rate <= 0) {
         return false;
     }
     $cldrCurrency = $this->cldr->getCurrency($this->iso_code);
     $this->name = $cldrCurrency['name'];
     return Currency::exists($this->iso_code) ? false : parent::add($autodate, $nullValues);
 }