Beispiel #1
0
 public function __construct()
 {
     $this->name = 'paypal';
     $this->tab = 'payments_gateways';
     $this->version = '2.4';
     $this->currencies = true;
     $this->currencies_mode = 'radio';
     parent::__construct();
     $this->_errors = array();
     $this->page = basename(__FILE__, '.php');
     $this->displayName = $this->l('PayPal');
     $this->description = $this->l('Accepts payments by credit cards (CB, Visa, MasterCard, Amex, Aurore, Cofinoga, 4 stars) with PayPal.');
     $this->confirmUninstall = $this->l('Are you sure you want to delete your details?');
     if (Configuration::get('PAYPAL_BUSINESS') == '*****@*****.**') {
         $this->warning = $this->l('You are currently using the default PayPal e-mail address, please enter your own e-mail address.');
     }
     $this->_checkAndUpdateFromOldVersion();
     if (file_exists(_PS_ROOT_DIR_ . '/modules/paypalapi/paypalapi.php') and $this->active) {
         $this->warning = $this->l('In order to REMOVE this warning, please uninstall and remove the PayPalAPI module.');
     }
     global $cookie;
     $context = stream_context_create(array('http' => array('method' => "GET", 'timeout' => 5)));
     $content = @file_get_contents('https://www.prestashop.com/partner/preactivation/preactivation-warnings.php?version=1.0&partner=paypal&iso_country=' . Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))) . '&iso_lang=' . Tools::strtolower(Language::getIsoById(intval($cookie->id_lang))) . '&id_lang=' . (int) $cookie->id_lang . '&email=' . urlencode(Configuration::get('PS_SHOP_EMAIL')) . '&security=' . md5(Configuration::get('PS_SHOP_EMAIL') . _COOKIE_IV_), false, $context);
     $content = explode('|', $content);
     if ($content[0] == 'OK') {
         if (!empty($this->warning)) {
             $this->warning .= ', ';
         }
         $this->warning .= $content[1];
     }
 }
 public static function isApplicable($id_country)
 {
     $isApplicable = in_array(Country::getIsoById((int) $id_country), VatNumber::getPrefixIntracomVAT());
     if ($isApplicable == "") {
         return 0;
     }
     return 1;
 }
Beispiel #3
0
 public function install()
 {
     if (false === function_exists('curl_init')) {
         $this->_errors[] = $this->l('This module requires the cURL PHP extension to work, it is not enabled on your server.') . ' ' . $this->l('Please ask your web hosting provider for assistance.');
         return false;
     }
     $iso_code = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
     if (in_array($iso_code, $this->limited_countries) == false) {
         $this->_errors[] = $this->l('This module is not available in your country');
         return false;
     }
     return parent::install() && $this->registerHook('displayPayment') && $this->registerHook('displayPaymentReturn') && $this->registerHook('actionOrderStatusUpdate') && $this->installDefaultValues() && $this->installOrderState();
 }
 protected function checkMobileNeeds()
 {
     $allow_mobile = (bool) Configuration::get('PS_ALLOW_MOBILE_DEVICE');
     if (!$allow_mobile && Context::getContext()->shop->getTheme() == 'default') {
         return;
     }
     $iso_code = Country::getIsoById((int) Configuration::get('PS_COUNTRY_DEFAULT'));
     $paypal_installed = (bool) Module::isInstalled('paypal');
     $paypal_countries = array('ES', 'FR', 'PL', 'IT');
     if (!$paypal_installed && in_array($iso_code, $paypal_countries)) {
         $this->warnings[] = $this->l('The mobile theme only works with the PayPal\'s payment module at this time. Please activate the module to enable payments.') . '<br>' . $this->l('In order to use the mobile theme you have to install and configure the PayPal module.');
     }
 }
Beispiel #5
0
 /**
  * Don't forget to create update methods if needed:
  * http://doc.prestashop.com/display/PS16/Enabling+the+Auto-Update
  */
 public function install()
 {
     if (extension_loaded('curl') == false) {
         $this->_errors[] = $this->l('You have to enable the cURL extension on your server to install this module');
         return false;
     }
     $iso_code = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
     if (in_array($iso_code, $this->limited_countries) == false) {
         $this->_errors[] = $this->l('This module is not available in your country');
         return false;
     }
     Configuration::updateValue('EGYAPAYE_LIVE_MODE', false);
     return parent::install() && $this->registerHook('header') && $this->registerHook('backOfficeHeader') && $this->registerHook('payment') && $this->registerHook('paymentReturn') && $this->registerHook('actionPaymentConfirmation');
 }
Beispiel #6
0
 public function install()
 {
     if (extension_loaded('curl') == false) {
         $this->_errors[] = $this->l('You have to enable the cURL extension on your server to install this module');
         return false;
     }
     $iso_code = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
     if (in_array($iso_code, $this->limited_countries) == false) {
         $this->_errors[] = $this->l('This module is not available in your country');
         return false;
     }
     Configuration::updateValue('APLAZAME_LIVE_MODE', false);
     return parent::install() && $this->registerHook('payment') && $this->registerHook('paymentReturn') && $this->registerHook('actionProductCancel') && $this->registerHook('actionOrderDetail') && $this->registerHook('actionOrderStatusPostUpdate') && $this->registerHook('actionOrderStatusUpdate') && $this->registerHook('actionPaymentConfirmation') && $this->registerHook('actionValidateOrder') && $this->registerHook('displayBeforePayment') && $this->registerHook('displayFooter') && $this->registerHook('displayAdminOrder') && $this->registerHook('displayOrderConfirmation') && $this->registerHook('displayPayment') && $this->registerHook('displayPaymentReturn');
 }
 public function init()
 {
     $address = new Address($this->_id_address_delivery);
     $weight = $this->_mondialRelay->account_shop['MR_WEIGHT_COEFFICIENT'] * $this->_weight;
     if (!$address) {
         throw new Exception($this->_mondialrelay->l('Customer address can\'t be found'));
     }
     $this->_fields['list']['Enseigne']['value'] = $this->_mondialRelay->account_shop['MR_ENSEIGNE_WEBSERVICE'];
     $this->_fields['list']['Poids']['value'] = $weight < 100 ? 100 : $weight;
     $this->_fields['list']['Pays']['value'] = trim(Country::getIsoById($address->id_country));
     $this->_fields['list']['Ville']['value'] = trim($address->city);
     $this->_fields['list']['CP']['value'] = trim($address->postcode);
     $this->_fields['list']['CP']['params']['id_country'] = $address->id_country;
     $this->_generateMD5SecurityKey();
     unset($address);
 }
 public function init()
 {
     $this->_mondialRelay = new MondialRelay();
     $address = new Address($this->_id_address_delivery);
     if (!$address) {
         throw new Exception($this->_mondialrelay->l('Customer address can\'t be found'));
     }
     $this->_fields['list']['Enseigne']['value'] = Configuration::get('MR_ENSEIGNE_WEBSERVICE');
     $this->_fields['list']['Poids']['value'] = Configuration::get('MR_WEIGHT_COEF') * $this->_weight;
     $this->_fields['list']['Pays']['value'] = Country::getIsoById($address->id_country);
     $this->_fields['list']['Ville']['value'] = $address->city;
     $this->_fields['list']['CP']['value'] = $address->postcode;
     $this->_fields['list']['CP']['params']['id_country'] = $address->id_country;
     $this->_generateMD5SecurityKey();
     unset($address);
 }
    public static function checkZipcodeByCountry($zipcode, $params)
    {
        $id_country = $params['id_country'];
        $zipcodeFormat = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
				SELECT `zip_code_format`
				FROM `' . _DB_PREFIX_ . 'country`
				WHERE `id_country` = ' . (int) $id_country);
        // Skip the cheking format if doesn't exist
        if (!$zipcodeFormat) {
            return true;
        }
        $regxMask = str_replace(array('N', 'C', 'L'), array('[0-9]', Country::getIsoById((int) $id_country), '[a-zA-Z]'), $zipcodeFormat);
        if (preg_match('/' . $regxMask . '/', $zipcode)) {
            return true;
        }
        return false;
    }
Beispiel #10
0
 public function install()
 {
     if (!extension_loaded('curl')) {
         $this->_errors[] = $this->l('You have to enable the cURL extension on your server to install this module');
         return false;
     }
     $iso_code = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
     if (!in_array($iso_code, $this->limited_countries)) {
         $this->_errors[] = $this->l('This module is not available in your country');
         return false;
     }
     Configuration::updateValue('APLAZAME_SANDBOX', false);
     Configuration::updateValue('APLAZAME_BUTTON_IMAGE', 'white-148x46');
     Configuration::updateValue('APLAZAME_BUTTON', '#aplazame_payment_button');
     Configuration::updateValue('APLAZAME_WIDGET_PROD', '0');
     return parent::install() && $this->registerHook('actionOrderSlipAdd') && $this->registerHook('actionOrderStatusPostUpdate') && $this->registerHook('displayAdminProductsExtra') && $this->registerHook('displayHeader') && $this->registerHook('displayPayment') && $this->registerHook('displayProductButtons') && $this->registerHook('displayRightColumn') && $this->registerHook('displayRightColumnProduct') && $this->registerHook('displayShoppingCart') && $this->registerHook('payment') && $this->registerHook('paymentOptions') && $this->registerHook('paymentReturn') && $this->registerController('AdminAplazameApiProxy', 'Aplazame API Proxy');
 }
    /**
     * Get SmKialaCountry object by id_country
     *
     * @param int $id_country
     * @return boolean|SmKialaCountry fetched object or false
     */
    public static function getByIdCountry($id_country)
    {
        // Luxemburg is grouped with Belgium by Kiala
        if (Country::getIsoById($id_country) == 'LU') {
            $id_country = Country::getByIso('BE');
        }
        $result = Db::getInstance()->getRow('
			SELECT `id_sm_kiala_country`, `id_country`, `dspid`, `sender_id`, `password`, `preparation_delay`, `active`
			FROM `' . _DB_PREFIX_ . 'sm_kiala_country`
			WHERE `id_country` = ' . (int) $id_country);
        if (!$result) {
            return false;
        }
        $kiala_country = new self();
        $kiala_country->setData($result);
        return $kiala_country;
    }
Beispiel #12
0
 private function getInfosForm($account = false)
 {
     $infos = array();
     $realex = new RealexRedirect();
     $cart = $this->context->cart;
     $id_customer = $cart->id_customer;
     $customer = new Customer((int) $id_customer);
     $infos['customer'] = $customer;
     $infos['iso_currency'] = $this->context->currency->iso_code;
     $date = new DateTime();
     $infos['timestamp'] = $date->format('YmdHis');
     $infos['order_id'] = $cart->id . '-' . $infos['timestamp'];
     $infos['settlement'] = $realex->settlement == 'auto' ? 1 : 0;
     if ($account) {
         $sql = 'SELECT dcc_realex_subaccount FROM `' . _DB_PREFIX_ . 'realex_subaccount` WHERE name_realex_subaccount = "' . pSQL($account) . '"';
         $result = Db::getInstance()->getRow($sql);
         $infos['settlement'] = $result['dcc_realex_subaccount'] || $realex->settlement == 'auto' ? 1 : 0;
     }
     if (!$customer->is_guest) {
         $sql = 'SELECT `id_realex_payerref`,`refuser_realex` FROM `' . _DB_PREFIX_ . 'realex_payerref` WHERE `id_user_realex` = ' . $id_customer;
         $payer_ref = Db::getInstance()->getRow($sql);
         $infos['payer_exists'] = !empty($payer_ref['refuser_realex']) ? 1 : 0;
         $infos['ref_payer'] = !empty($payer_ref['refuser_realex']) ? $payer_ref['refuser_realex'] : $id_customer . $infos['timestamp'];
         $infos['id_realex_payerref'] = $payer_ref['id_realex_payerref'];
     }
     $billing_adresse = new Address((int) $cart->id_address_invoice);
     $infos['billing_streetumber'] = $this->parseInt($billing_adresse->address1);
     $infos['billing_co'] = Country::getIsoById($billing_adresse->id_country);
     $infos['billing_postcode'] = $this->parseInt($billing_adresse->postcode);
     $shipping_adresse = new Address((int) $cart->id_address_delivery);
     $infos['shipping_streetumber'] = $this->parseInt($shipping_adresse->address1);
     $infos['shipping_co'] = Country::getIsoById($shipping_adresse->id_country);
     $infos['shipping_postcode'] = $this->parseInt($shipping_adresse->postcode);
     $infos['cart'] = $cart;
     if ($realex->realvault == '1' && !$customer->is_guest) {
         $times = $infos['timestamp'];
         $chaine = $times . '.' . $realex->merchant_id . '.' . $infos['order_id'] . '.' . $realex->getAmountFormat($cart->getOrderTotal(true, Cart::BOTH));
         $chaine .= '.' . $infos['iso_currency'] . '.' . $infos['ref_payer'] . '.' . $cart->id . $infos['timestamp'];
     } else {
         $chaine = $infos['timestamp'] . '.' . $realex->merchant_id . '.' . $infos['order_id'];
         $chaine .= '.' . $realex->getAmountFormat($cart->getOrderTotal(true, Cart::BOTH)) . '.' . $infos['iso_currency'];
     }
     $sha1_temp_new = sha1($chaine);
     $infos['sha1_new'] = sha1($sha1_temp_new . '.' . $realex->shared_secret);
     return $infos;
 }
Beispiel #13
0
    public static function getPrice($total_weight, $id_carrier, $cart)
    {
        $iso_country = '';
        if ($id_country = (int) Tools::getValue('id_country')) {
            $iso_country = Country::getIsoById($id_country);
        } else {
            $address = new Address((int) $cart->id_address_delivery);
            $iso_country = Country::getIsoById((int) $address->id_country);
        }
        $price_rules = DB::getInstance()->executeS('
			SELECT `parcel_price`, `cod_price`, `iso_country`
			FROM `' . _DB_PREFIX_ . _DPDPOLAND_PRICE_RULE_DB_ . '`
			WHERE (`iso_country` = "' . pSQL($iso_country) . '" OR `iso_country` = "*")
				AND `weight_from` <= "' . pSQL($total_weight) . '"
				AND `weight_to` >= "' . pSQL($total_weight) . '"
				AND `id_carrier` = "' . (int) $id_carrier . '"
				AND `id_shop` = "' . (int) Context::getContext()->shop->id . '"
		');
        if (!$price_rules) {
            return false;
        }
        $available_prices_count = count($price_rules);
        for ($i = 0; $i < $available_prices_count; $i++) {
            if ($price_rules[$i]['iso_country'] != '*' && !Country::getByIso($price_rules[$i]['iso_country'])) {
                //if country is not deleted
                unset($price_rules[$i]);
            }
        }
        if (!$price_rules) {
            return false;
        }
        $price_rules = $price_rules[0];
        //accept first matching rule
        if (!$price_rules['cod_price']) {
            $price_rules['cod_price'] = 0;
        }
        //CSV validation allows empty value of COD price
        $price = $price_rules['parcel_price'];
        if ($id_carrier == _DPDPOLAND_STANDARD_COD_ID_) {
            $price += $price_rules['cod_price'];
        }
        return $price;
    }
 /**
  * Convert the entities data into an xml object and return the xml object as a string
  *
  * @param array $aEntity Entity data
  */
 public function formatEntityToXML($aEntity)
 {
     $dom = new DOMDocument('1.0', 'utf-8');
     // Set the root of the XML
     $root = $dom->createElement($this->sEntity);
     $dom->appendChild($root);
     $oCustomer = new Customer((int) $aEntity['id_customer']);
     // Check if the customer has visited the website since a specific number of days $this->nbDaysCustomerValid
     $aLastConnection = $oCustomer->getLastConnections();
     if ($aLastConnection[0]['date_add'] < date('Y-m-d H:i:s', mktime(0, 0, 0, date('m'), date('d') - (int) $this->nbDaysCustomerValid, date('Y')))) {
         $this->nbEntitiesTreated--;
         $this->nbEntities--;
         return ' ';
     }
     unset($aLastConnection);
     $id = $dom->createElement('id', (int) $oCustomer->id);
     $root->appendChild($id);
     if (($sBirthday = strtotime($oCustomer->birthday)) && !empty($sBirthday)) {
         $dobyear = $dom->createElement('dobyear', date('Y', $sBirthday));
         $root->appendChild($dobyear);
     }
     $gender = $dom->createElement('gender', (int) $oCustomer->id_gender == 1 ? 'male' : 'female');
     $root->appendChild($gender);
     $oAddress = new Address((int) Address::getFirstCustomerAddressId((int) $oCustomer->id));
     unset($oCustomer);
     if (($sLocation = trim($oAddress->city)) && !empty($sLocation)) {
         $location = $dom->createElement('location', $sLocation);
         $root->appendChild($location);
     }
     if (($sCountry = Country::getIsoById((int) $oAddress->id_country)) && !empty($sCountry)) {
         $country = $dom->createElement('country', $sCountry);
         $root->appendChild($country);
     }
     $sReturn = $dom->saveHTML();
     unset($oAddress);
     unset($dom);
     return $sReturn;
 }
Beispiel #15
0
 public static function isApplicable($id_country)
 {
     return ((int) $id_country and in_array(Country::getIsoById($id_country), self::getPrefixIntracomVAT())) ? 1 : 0;
 }
 public function searchModule()
 {
     $this->_list['modules'] = array();
     $all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id);
     foreach ($all_modules as $module) {
         if (stripos($module->name, $this->query) !== false || stripos($module->displayName, $this->query) !== false || stripos($module->description, $this->query) !== false) {
             $module->linkto = 'index.php?tab=AdminModules&tab_module=' . $module->tab . '&module_name=' . $module->name . '&anchor=' . ucfirst($module->name) . '&token=' . Tools::getAdminTokenLite('AdminModules');
             $this->_list['modules'][] = $module;
         }
     }
     if (!is_numeric(trim($this->query)) && !Validate::isEmail($this->query)) {
         $iso_lang = Tools::strtolower(Context::getContext()->language->iso_code);
         $iso_country = Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
         if (($json_content = Tools::file_get_contents('https://api.addons.prestashop.com/' . _PS_VERSION_ . '/search/' . urlencode($this->query) . '/' . $iso_country . '/' . $iso_lang . '/')) != false) {
             $this->_list['addons'] = Tools::jsonDecode($json_content, true);
         }
     }
 }
Beispiel #17
0
 public function __construct()
 {
     // Basic vars
     global $currentIndex;
     $this->current_index = $currentIndex;
     $this->token = Tools::getValue('token');
     $this->name = 'twenga';
     $this->tab = 'smart_shopping';
     $this->version = '1.8';
     parent::__construct();
     $this->displayName = $this->l('Twenga API');
     $this->description = $this->l('Module role: export of your products on Twenga and installation of the sales tracking brought by Twenga (requires sign up to Twenga)');
     // For Twenga subscription
     $protocol = 'http://';
     if (isset($_SERVER['https']) && $_SERVER['https'] != 'off') {
         $protocol = 'https://';
     }
     $this->site_url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__);
     self::$base_dir = _PS_ROOT_DIR_ . '/modules/twenga/';
     self::$base_path = $this->site_url . '/modules/twenga/';
     $this->feed_url = self::$base_path . 'export.php?twenga_token=' . sha1(Configuration::get('TWENGA_TOKEN') . _COOKIE_KEY_);
     self::$shop_country = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
     require_once realpath(self::$base_dir . '/lib/PrestashopStats.php');
     require_once realpath(self::$base_dir . '/lib/TwengaObj.php');
     // set the base dir to load files needed for the TwengaObj class
     TwengaObj::$base_dir = self::$base_dir . '/lib';
     TwengaObj::setTranslationObject($this);
     TwengaException::setTranslationObject($this);
     if (!in_array(strtolower(self::$shop_country), $this->limited_countries)) {
         $this->_allowToWork = false;
         $this->warning = $this->l('Twenga module works only in specific countries (iso code list:') . ' ' . implode(', ', $this->limited_countries) . ').';
         return false;
     }
     // instanciate (just once) the TwengaObj and PrestashopStats
     if (self::$obj_twenga === NULL) {
         self::$obj_twenga = new TwengaObj();
     }
     if (self::$obj_ps_stats === NULL) {
         self::$obj_ps_stats = new PrestashopStats($this->site_url);
     }
     $this->_initCurrentIsoCodeCountry();
 }
Beispiel #18
0
 public static function addonsRequest($request, $params = array())
 {
     if (!self::$is_addons_up) {
         return false;
     }
     $postData = http_build_query(array('version' => isset($params['version']) ? $params['version'] : _PS_VERSION_, 'iso_lang' => Tools::strtolower(isset($params['iso_lang']) ? $params['iso_lang'] : Context::getContext()->language->iso_code), 'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))), 'shop_url' => isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain(), 'mail' => isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL')));
     $protocols = array('https');
     switch ($request) {
         case 'native':
             $protocols[] = 'http';
             $postData .= '&method=listing&action=native';
             break;
         case 'native_all':
             $protocols[] = 'http';
             $postData .= '&method=listing&action=native&iso_code=all';
             break;
         case 'must-have':
             $protocols[] = 'http';
             $postData .= '&method=listing&action=must-have';
             break;
         case 'must-have-themes':
             $protocols[] = 'http';
             $postData .= '&method=listing&action=must-have-themes';
             break;
         case 'customer':
             $postData .= '&method=listing&action=customer&username='******'&password='******'customer_themes':
             $postData .= '&method=listing&action=customer-themes&username='******'&password='******'check_customer':
             $postData .= '&method=check_customer&username='******'username_addons']) . '&password='******'password_addons']);
             break;
         case 'check_module':
             $postData .= '&method=check&module_name=' . urlencode($params['module_name']) . '&module_key=' . urlencode($params['module_key']);
             break;
         case 'module':
             $postData .= '&method=module&id_module=' . urlencode($params['id_module']);
             if (isset($params['username_addons']) && isset($params['password_addons'])) {
                 $postData .= '&username='******'username_addons']) . '&password='******'password_addons']);
             } else {
                 $protocols[] = 'http';
             }
             break;
         case 'install-modules':
             $protocols[] = 'http';
             $postData .= '&method=listing&action=install-modules';
             break;
         default:
             return false;
     }
     $context = stream_context_create(array('http' => array('method' => 'POST', 'content' => $postData, 'header' => 'Content-type: application/x-www-form-urlencoded', 'timeout' => 5)));
     foreach ($protocols as $protocol) {
         if ($content = Tools::file_get_contents($protocol . '://api.addons.prestashop.com', false, $context)) {
             return $content;
         }
     }
     self::$is_addons_up = false;
     return false;
 }
Beispiel #19
0
 public static function isApplicable($id_country)
 {
     return (int) $id_country && array_key_exists(Country::getIsoById($id_country), self::getPrefixIntracomVAT()) ? 1 : 0;
 }
 /**
  * Set the values of the fields that will be exported
  *
  * @param array $kiala_order content of the KialaOrder object
  * @return array|bool fields to be exported or false
  */
 public function initRecordData($kiala_order, $dspid)
 {
     if (!Validate::isLoadedObject($kiala_order)) {
         return false;
     }
     $order = new Order($kiala_order->id_order);
     $cart = new Cart($order->id_cart);
     $customer = new Customer($kiala_order->id_customer);
     $address = new Address($order->id_address_delivery);
     if (!Validate::isLoadedObject($order) || !Validate::isLoadedObject($customer) || !Validate::isLoadedObject($address)) {
         return false;
     }
     $products = $cart->getProducts();
     $width = 1;
     $height = 1;
     $depth = 1;
     foreach ($products as $product) {
         $width = $width < $product['width'] ? $product['width'] : $width;
         $height = $height < $product['height'] ? $product['height'] : $height;
         $depth = $depth < $product['depth'] ? $product['depth'] : $depth;
     }
     // volume in liters
     $volume = $width * $height * $depth / 1000;
     if ($volume < 1) {
         $volume = 1;
     }
     $prefix = Configuration::get('KIALA_NUMBER_PREFIX');
     $fields = array();
     $fields['partnerId']['value'] = $dspid;
     // Parcel information
     $fields['parcelBarcode']['value'] = '';
     $fields['parcelNumber']['value'] = $prefix . $kiala_order->id;
     $fields['orderNumber']['value'] = $prefix . $kiala_order->id;
     $fields['orderDate']['value'] = $this->formatDate($order->date_add);
     $fields['invoiceNumber']['value'] = $order->invoice_number ? $order->invoice_number : '';
     $fields['invoiceDate']['value'] = $this->formatDate($order->invoice_date);
     $fields['shipmentNumber']['value'] = '';
     // @todo Need to check currency = EUR
     if ($order->module == 'cashondelivery') {
         $cod_amount = $order->total_paid;
     } else {
         $cod_amount = '0';
     }
     $fields['CODAmount']['value'] = sprintf('%.2f', $cod_amount);
     $fields['CODCurrency']['value'] = 'EUR';
     $fields['commercialValue']['value'] = sprintf('%.2f', $kiala_order->commercialValue);
     $fields['commercialCurrency']['value'] = 'EUR';
     $fields['parcelWeight']['value'] = sprintf('%.3f', $order->getTotalWeight());
     $fields['parcelVolume']['value'] = sprintf('%.3f', $volume);
     $fields['parcelDescription']['value'] = $kiala_order->parcelDescription;
     // Point information
     $fields['kialaPoint']['value'] = $kiala_order->point_short_id;
     $fields['backupKialaPoint']['value'] = '';
     // Recipient information
     $fields['customerId']['value'] = $customer->id;
     $fields['customerName']['value'] = $customer->lastname;
     $fields['customerFirstName']['value'] = $customer->firstname;
     switch ($customer->id_gender) {
         case '1':
             $title = $this->kiala_instance->l('Mr.');
             break;
         case '2':
             $title = $this->kiala_instance->l('Ms.');
             break;
         default:
             $title = '';
     }
     $fields['customerTitle']['value'] = $title;
     $fields['customerExtraAddressLine']['value'] = $address->address2;
     $fields['customerStreet']['value'] = $address->address1;
     $fields['customerStreetNumber']['value'] = '';
     $fields['customerLocality']['value'] = State::getNameById($address->id_state);
     $fields['customerZip']['value'] = $address->postcode;
     $fields['customerCity']['value'] = $address->city;
     $fields['customerCountry']['value'] = Country::getIsoById($address->id_country);
     $fields['customerLanguage']['value'] = strtolower(Language::getIsoById($order->id_lang));
     $fields['positiveNotificationRequested']['value'] = 'Y';
     $fields['customerPhone1']['value'] = $address->phone;
     $fields['customerPhone2']['value'] = $address->phone_mobile;
     $fields['customerPhone3']['value'] = '';
     $fields['customerEmail1']['value'] = $customer->email;
     $fields['customerEmail2']['value'] = '';
     $fields['customerEmail3']['value'] = '';
     return $fields;
 }
 public function preProcess()
 {
     parent::preProcess();
     if (self::$cookie->isLogged() and !Tools::isSubmit('ajax')) {
         Tools::redirect('my-account.php');
     }
     if (Tools::getValue('create_account')) {
         $create_account = 1;
         self::$smarty->assign('email_create', 1);
     }
     if (Tools::isSubmit('SubmitCreate')) {
         if (!Validate::isEmail($email = Tools::getValue('email_create')) or empty($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } elseif (Customer::customerExists($email)) {
             $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
             $_POST['email'] = $_POST['email_create'];
             unset($_POST['email_create']);
         } else {
             $create_account = 1;
             self::$smarty->assign('email_create', Tools::safeOutput($email));
             $_POST['email'] = $email;
         }
     }
     if (Tools::isSubmit('submitAccount') or Tools::isSubmit('submitGuestAccount')) {
         $create_account = 1;
         if (Tools::isSubmit('submitAccount')) {
             self::$smarty->assign('email_create', 1);
         }
         /* New Guest customer */
         if (!Tools::getValue('is_new_customer', 1) and !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
             $this->errors[] = Tools::displayError('You cannot create a guest account.');
         }
         if (!Tools::getValue('is_new_customer', 1)) {
             $_POST['passwd'] = md5(time() . _COOKIE_KEY_);
         }
         if (isset($_POST['guest_email']) and $_POST['guest_email']) {
             $_POST['email'] = $_POST['guest_email'];
         }
         /* Preparing customer */
         $customer = new Customer();
         $lastnameAddress = $_POST['lastname'];
         $firstnameAddress = $_POST['firstname'];
         $_POST['lastname'] = $_POST['customer_lastname'];
         $_POST['firstname'] = $_POST['customer_firstname'];
         if (!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) {
             $this->errors[] = Tools::displayError('You must register at least one phone number');
         }
         if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
             $this->errors[] = Tools::displayError('Invalid date of birth');
         }
         $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
         $this->errors = array_unique(array_merge($this->errors, $customer->validateControler()));
         /* Preparing address */
         $address = new Address();
         $_POST['lastname'] = $lastnameAddress;
         $_POST['firstname'] = $firstnameAddress;
         $address->id_customer = 1;
         $this->errors = array_unique(array_merge($this->errors, $address->validateControler()));
         /* US customer: normalize the address */
         if ($address->id_country == Country::getByIso('US')) {
             include_once _PS_TAASC_PATH_ . 'AddressStandardizationSolution.php';
             $normalize = new AddressStandardizationSolution();
             $address->address1 = $normalize->AddressLineStandardization($address->address1);
             $address->address2 = $normalize->AddressLineStandardization($address->address2);
         }
         $zip_code_format = Country::getZipCodeFormat((int) Tools::getValue('id_country'));
         if (Country::getNeedZipCode((int) Tools::getValue('id_country'))) {
             if ($postcode = Tools::getValue('postcode') and $zip_code_format) {
                 $zip_regexp = '/^' . $zip_code_format . '$/ui';
                 $zip_regexp = str_replace(' ', '( |)', $zip_regexp);
                 $zip_regexp = str_replace('-', '(-|)', $zip_regexp);
                 $zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
                 $zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
                 $zip_regexp = str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), $zip_regexp);
                 if (!preg_match($zip_regexp, $postcode)) {
                     $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.') . '<br />' . Tools::displayError('Must be typed as follows:') . ' ' . str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
                 }
             } elseif ($zip_code_format) {
                 $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is required.');
             } elseif ($postcode and !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode)) {
                 $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.');
             }
         }
         if (Country::isNeedDniByCountryId($address->id_country) and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) {
             $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
         } elseif (!Country::isNeedDniByCountryId($address->id_country)) {
             $address->dni = NULL;
         }
         if (!sizeof($this->errors)) {
             if (Customer::customerExists(Tools::getValue('email'))) {
                 $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
             }
             if (Tools::isSubmit('newsletter')) {
                 $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
                 $customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
             }
             if (!sizeof($this->errors)) {
                 if (!($country = new Country($address->id_country, Configuration::get('PS_LANG_DEFAULT'))) or !Validate::isLoadedObject($country)) {
                     die(Tools::displayError());
                 }
                 if ((int) $country->contains_states and !(int) $address->id_state) {
                     $this->errors[] = Tools::displayError('This country requires a state selection.');
                 } else {
                     $customer->active = 1;
                     /* New Guest customer */
                     if (Tools::isSubmit('is_new_customer')) {
                         $customer->is_guest = !Tools::getValue('is_new_customer', 1);
                     } else {
                         $customer->is_guest = 0;
                     }
                     if (!$customer->add()) {
                         $this->errors[] = Tools::displayError('An error occurred while creating your account.');
                     } else {
                         $address->id_customer = (int) $customer->id;
                         if (!$address->add()) {
                             $this->errors[] = Tools::displayError('An error occurred while creating your address.');
                         } else {
                             if (!$customer->is_guest) {
                                 if (!Mail::Send((int) self::$cookie->id_lang, 'account', Mail::l('Welcome!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                                     $this->errors[] = Tools::displayError('Cannot send email');
                                 }
                             }
                             self::$smarty->assign('confirmation', 1);
                             self::$cookie->id_customer = (int) $customer->id;
                             self::$cookie->customer_lastname = $customer->lastname;
                             self::$cookie->customer_firstname = $customer->firstname;
                             self::$cookie->passwd = $customer->passwd;
                             self::$cookie->logged = 1;
                             self::$cookie->email = $customer->email;
                             self::$cookie->is_guest = !Tools::getValue('is_new_customer', 1);
                             /* Update cart address */
                             self::$cart->secure_key = $customer->secure_key;
                             self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id);
                             self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id);
                             self::$cart->update();
                             Module::hookExec('createAccount', array('_POST' => $_POST, 'newCustomer' => $customer));
                             if (Tools::isSubmit('ajax')) {
                                 $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => true, 'id_customer' => (int) self::$cookie->id_customer, 'id_address_delivery' => self::$cart->id_address_delivery, 'id_address_invoice' => self::$cart->id_address_invoice, 'token' => Tools::getToken(false));
                                 die(Tools::jsonEncode($return));
                             }
                             if ($back = Tools::getValue('back')) {
                                 Tools::redirect($back);
                             }
                             Tools::redirect('my-account.php');
                         }
                     }
                 }
             }
         }
         if (sizeof($this->errors)) {
             if (!Tools::getValue('is_new_customer')) {
                 unset($_POST['passwd']);
             }
             if (Tools::isSubmit('ajax')) {
                 $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => false, 'id_customer' => 0);
                 die(Tools::jsonEncode($return));
             }
         }
     }
     if (Tools::isSubmit('SubmitLogin')) {
         Module::hookExec('beforeAuthentication');
         $passwd = trim(Tools::getValue('passwd'));
         $email = trim(Tools::getValue('email'));
         if (empty($email)) {
             $this->errors[] = Tools::displayError('E-mail address required');
         } elseif (!Validate::isEmail($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } elseif (empty($passwd)) {
             $this->errors[] = Tools::displayError('Password is required');
         } elseif (Tools::strlen($passwd) > 32) {
             $this->errors[] = Tools::displayError('Password is too long');
         } elseif (!Validate::isPasswd($passwd)) {
             $this->errors[] = Tools::displayError('Invalid password');
         } else {
             $customer = new Customer();
             $authentication = $customer->getByEmail(trim($email), trim($passwd));
             if (!$authentication or !$customer->id) {
                 /* Handle brute force attacks */
                 sleep(1);
                 $this->errors[] = Tools::displayError('Authentication failed');
             } else {
                 self::$cookie->id_compare = isset(self::$cookie->id_compare) ? self::$cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id);
                 self::$cookie->id_customer = (int) $customer->id;
                 self::$cookie->customer_lastname = $customer->lastname;
                 self::$cookie->customer_firstname = $customer->firstname;
                 self::$cookie->id_default_group = $customer->id_default_group;
                 self::$cookie->logged = 1;
                 self::$cookie->is_guest = $customer->isGuest();
                 self::$cookie->passwd = $customer->passwd;
                 self::$cookie->email = $customer->email;
                 if (Configuration::get('PS_CART_FOLLOWING') and (empty(self::$cookie->id_cart) or Cart::getNbProducts(self::$cookie->id_cart) == 0)) {
                     self::$cookie->id_cart = (int) Cart::lastNoneOrderedCart((int) $customer->id);
                 }
                 /* Update cart address */
                 self::$cart->id_carrier = 0;
                 self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id);
                 self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id);
                 // If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated
                 self::$cart->secure_key = $customer->secure_key;
                 self::$cart->update();
                 Module::hookExec('authentication');
                 if (!Tools::isSubmit('ajax')) {
                     if ($back = Tools::getValue('back')) {
                         Tools::redirect($back);
                     }
                     Tools::redirect('my-account.php');
                 }
             }
         }
         if (Tools::isSubmit('ajax')) {
             $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'token' => Tools::getToken(false));
             die(Tools::jsonEncode($return));
         }
     }
     if (isset($create_account)) {
         /* Select the most appropriate country */
         if (isset($_POST['id_country']) and is_numeric($_POST['id_country'])) {
             $selectedCountry = (int) $_POST['id_country'];
         }
         /* FIXME : language iso and country iso are not similar,
         			 * maybe an associative table with country an language can resolve it,
         			 * But for now it's a bug !
         			 * @see : bug #6968
         			 * @link:http://www.prestashop.com/bug_tracker/view/6968/
         			elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
         			{
         				$array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         				if (Validate::isLanguageIsoCode($array[0]))
         				{
         					$selectedCountry = Country::getByIso($array[0]);
         					if (!$selectedCountry)
         						$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
         				}
         			}*/
         if (!isset($selectedCountry)) {
             $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
         }
         if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
             $countries = Carrier::getDeliveredCountries((int) self::$cookie->id_lang, true, true);
         } else {
             $countries = Country::getCountries((int) self::$cookie->id_lang, true);
         }
         self::$smarty->assign(array('countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'vat_management' => Configuration::get('VATNUMBER_MANAGEMENT')));
         /* Call a hook to display more information on form */
         self::$smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')));
     }
     /* Generate years, months and days */
     if (isset($_POST['years']) and is_numeric($_POST['years'])) {
         $selectedYears = (int) $_POST['years'];
     }
     $years = Tools::dateYears();
     if (isset($_POST['months']) and is_numeric($_POST['months'])) {
         $selectedMonths = (int) $_POST['months'];
     }
     $months = Tools::dateMonths();
     if (isset($_POST['days']) and is_numeric($_POST['days'])) {
         $selectedDays = (int) $_POST['days'];
     }
     $days = Tools::dateDays();
     self::$smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0));
     self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
 }
 protected function geolocationManagement($default_country)
 {
     if (!in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1'))) {
         /* Check if Maxmind Database exists */
         if (file_exists(_PS_GEOIP_DIR_ . 'GeoLiteCity.dat')) {
             if (!isset($this->context->cookie->iso_code_country) || isset($this->context->cookie->iso_code_country) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')))) {
                 include_once _PS_GEOIP_DIR_ . 'geoipcity.inc';
                 $gi = geoip_open(realpath(_PS_GEOIP_DIR_ . 'GeoLiteCity.dat'), GEOIP_STANDARD);
                 $record = geoip_record_by_addr($gi, Tools::getRemoteAddr());
                 if (is_object($record)) {
                     if (!in_array(strtoupper($record->country_code), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && !FrontController::isInWhitelistForGeolocation()) {
                         if (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_) {
                             $this->restrictedCountry = true;
                         } elseif (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_) {
                             $this->context->smarty->assign(array('restricted_country_mode' => true, 'geolocation_country' => $record->country_name));
                         }
                     } else {
                         $has_been_set = !isset($this->context->cookie->iso_code_country);
                         $this->context->cookie->iso_code_country = strtoupper($record->country_code);
                     }
                 }
             }
             if (isset($this->context->cookie->iso_code_country) && $this->context->cookie->iso_code_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country)) {
                 $this->context->cookie->iso_code_country = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
             }
             if (isset($this->context->cookie->iso_code_country) && ($id_country = Country::getByIso(strtoupper($this->context->cookie->iso_code_country)))) {
                 /* Update defaultCountry */
                 if ($default_country->iso_code != $this->context->cookie->iso_code_country) {
                     $default_country = new Country($id_country);
                 }
                 if (isset($has_been_set) && $has_been_set) {
                     $this->context->cookie->id_currency = (int) Currency::getCurrencyInstance($default_country->id_currency ? (int) $default_country->id_currency : Configuration::get('PS_CURRENCY_DEFAULT'))->id;
                 }
                 return $default_country;
             } elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_ && !FrontController::isInWhitelistForGeolocation()) {
                 $this->restrictedCountry = true;
             } elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_ && !FrontController::isInWhitelistForGeolocation()) {
                 $this->context->smarty->assign(array('restricted_country_mode' => true, 'geolocation_country' => 'Undefined'));
             }
         } else {
             Configuration::updateValue('PS_GEOLOCATION_ENABLED', 0);
         }
     }
     return false;
 }
Beispiel #23
0
//发货信息
$shippingFirstName = trim($shipInfo->lastname);
$shippingLastName = trim($shipInfo->lastname);
$shippingAddress1 = $shipInfo->address1;
$shippingAddress2 = $shipInfo->address2;
$shippingCity = trim($shipInfo->city);
$shippingCountry = trim($shipInfo->country);
$_shippingState = new State((int) $shipInfo->id_state);
$shippingState = $_shippingState->iso_code;
$shippingZipcode = trim($shipInfo->postcode);
$shippingTelephone = !empty($shipInfo->phone_mobile) ? $shipInfo->phone_mobile : $shipInfo->phone;
//除了prestashop1.2版本国家获取全称之外,其他版本都是获取国家简称.
if (strpos(_PS_VERSION_, "1.2") !== 0) {
    $billingCountry = Country::getIsoById($billInfo->id_country);
    //获取国家简称
    $shippingCountry = Country::getIsoById($shipInfo->id_country);
}
$billingState = isset($billingState) ? $billingState : '-';
$shippingState = isset($shippingState) ? $shippingState : '-';
//组装参数
$data = array('mode' => Configuration::get('GOFPAY_MODE'), 'websiteid' => Configuration::get('GOFPAY_WEBSITE_ID'), 'orderid' => $orderNo, 'domain' => $_SERVER['HTTP_HOST'], 'email' => $email, 'ipaddress' => get_client_ip(), 'currency' => $orderCurrency, 'amount' => $orderAmount, 'discount' => $discount, 'tax' => '0.00', 'freight' => $shipFee, 'billingfirstname' => $billingFirstName, 'billinglastname' => $billingLastName, 'billingaddress1' => $billingAddress1, 'billingaddress2' => $billingAddress2, 'billingcity' => $billingCity, 'billingcountry' => $billingCountry, 'billingstate' => $billingState, 'billingzipcode' => $billingZipcode, 'billingtelephone' => $billingTelephone, 'shippingfirstname' => $shippingFirstName, 'shippinglastname' => $shippingLastName, 'shippingaddress1' => $shippingAddress1, 'shippingaddress2' => $shippingAddress2, 'shippingcity' => $shippingCity, 'shippingcountry' => $shippingCountry, 'shippingstate' => $shippingState, 'shippingzipcode' => $shippingZipcode, 'shippingtelephone' => $shippingTelephone, 'creditcardname' => $billingFirstName . ' ' . $billingLastName, 'creditcardnumber' => $_REQUEST["gofpay_creditcard_number"], 'creditcardcsc2' => $_REQUEST["gofpay_security_code"], 'creditcardexpire' => $_REQUEST["gofpay_expire_year"] . $_REQUEST["gofpay_expire_month"], 'signature' => md5(Configuration::get('GOFPAY_WEBSITE_ID') . $orderNo . $email . $orderCurrency . $orderAmount . '0.00' . '0.00' . $shipFee . Configuration::get('GOFPAY_SECRET_KEY')));
if (Configuration::get('GOFPAY_GATEWAY_COUPON_STATUS')) {
    $data['coupon'] = isset($_REQUEST["gofpay_coupon_code"]) ? $_REQUEST["gofpay_coupon_code"] : '';
}
// 商品信息
$arr = $cart->getProducts();
for ($i = 0; $i < sizeof($arr); $i++) {
    $data['productsku' . ($i + 1)] = $arr[$i]["id_product"];
    $data['productname' . ($i + 1)] = $arr[$i]['name'];
    $data['productprice' . ($i + 1)] = number_format($arr[$i]["price"], 2, '.', '');
    $data['productquantity' . ($i + 1)] = $arr[$i]["cart_quantity"];
 public function checkPreValidation()
 {
     $errorList = array('error' => array(), 'warn' => array());
     $list = array('Expe_Langage' => array('value' => $this->_mondialrelay->account_shop['MR_LANGUAGE'], 'error' => $this->_mondialrelay->l('Please check your language configuration', $this->class_name)), 'Expe_Ad1' => array('value' => Configuration::get('PS_SHOP_NAME'), 'error' => $this->_mondialrelay->l('Please check your shop name configuration', $this->class_name)), 'Expe_Ad3' => array('value' => Configuration::get('PS_SHOP_ADDR1'), 'error' => $this->_mondialrelay->l('Please check your address 1 configuration', $this->class_name)), 'Expe_Ville' => array('value' => Configuration::get('PS_SHOP_CITY'), 'error' => $this->_mondialrelay->l('Please check your city configuration', $this->class_name)), 'Expe_CP' => array('value' => Configuration::get('PS_SHOP_CODE'), 'error' => $this->_mondialrelay->l('Please check your zipcode configuration', $this->class_name)), 'Expe_Pays' => array('value' => _PS_VERSION_ >= '1.4' ? Country::getIsoById(Configuration::get('PS_SHOP_COUNTRY_ID')) : substr(Configuration::get('PS_SHOP_COUNTRY'), 0, 2), 'error' => $this->_mondialrelay->l('Please check your country configuration', $this->class_name)), 'Expe_Tel1' => array('value' => MRTools::getFormatedPhone(Configuration::get('PS_SHOP_PHONE')), 'error' => $this->_mondialrelay->l('Please check your Phone configuration', $this->class_name)), 'Expe_Mail' => array('value' => Configuration::get('PS_SHOP_EMAIL'), 'error' => $this->_mondialrelay->l('Please check your mail configuration', $this->class_name)));
     foreach ($list as $name => $tab) {
         // Mac server make an empty string instead of a cleaned string
         // TODO : test on windows and linux server
         $cleanedString = MRTools::removeAccents($tab['value']);
         $tab['value'] = !empty($cleanedString) ? strtoupper($cleanedString) : strtoupper($tab['value']);
         if ($name == 'Expe_CP') {
             if (version_compare(_PS_VERSION_, '1.4', '>=')) {
                 if (!($zipcodeError = MRTools::checkZipcodeByCountry($tab['value'], array('id_country' => Configuration::get('PS_COUNTRY_DEFAULT'))))) {
                     $errorList['error'][$name] = $tab['error'];
                 }
             } else {
                 $errorList['warn'][$name] = $this->_mondialrelay->l('Post code cannot be validated with PrestaShop versions older than 1.4', $this->class_name);
             }
         } else {
             if (isset($this->_fields['list'][$name]['regexValidation']) && !preg_match($this->_fields['list'][$name]['regexValidation'], $tab['value'], $matches)) {
                 $errorList['error'][$name] = $tab['error'];
             }
         }
     }
     return $errorList;
 }
Beispiel #25
0
    $tabs = array();
    recursiveTab($id_tab);
    $tabs = array_reverse($tabs);
    $bread = '';
    foreach ($tabs as $key => $item) {
        $bread .= ' <img src="../img/admin/separator_breadcrum.png" style="margin-right:5px" />
			' . (sizeof($tabs) - 1 > $key ? '<a href="?tab=' . $item['class_name'] . '&token=' . Tools::getAdminToken($item['class_name'] . intval($item['id_tab']) . intval($cookie->id_employee)) . '">' : '') . '
			' . $item['name'] . (sizeof($tabs) - 1 > $key ? '</a>' : '');
    }
    echo '<script type="text/javascript">

		$(function() {
			$.ajax({
				type: \'POST\',
				url: \'ajax.php\',
				data: \'helpAccess=1&item=' . $item['class_name'] . '&isoUser='******'&country=' . Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')) . '&version=' . _PS_VERSION_ . '\',
				async : true,
				success: function(msg) {
					$("#help-button").html(msg);
					$("#help-button").fadeIn("slow");
				}
			});
		});</script>';
    echo '<div class="path_bar">
		<div id="help-button" class="floatr" style="display: none; font-family: Verdana; font-size: 10px; margin-right: 4px; margin-top: 4px;">
		</div>
			<a href="?token=' . Tools::getAdminToken($tab . intval(Tab::getIdFromClassName($tab)) . intval($cookie->id_employee)) . '">' . translate('Back Office') . '</a>
			' . $bread . '
		</div>';
    if (Validate::isLoadedObject($adminObj)) {
        if ($adminObj->checkToken()) {
 public function ajaxProcessGetBlogRss()
 {
     $return = array('has_errors' => false, 'rss' => array());
     if (!$this->isFresh('/config/xml/blog-' . $this->context->language->iso_code . '.xml', 86400)) {
         if (!$this->refresh('/config/xml/blog-' . $this->context->language->iso_code . '.xml', _PS_API_URL_ . '/rss/blog/blog-' . $this->context->language->iso_code . '.xml')) {
             $return['has_errors'] = true;
         }
     }
     if (!$return['has_errors']) {
         $rss = @simplexml_load_file(_PS_ROOT_DIR_ . '/config/xml/blog-' . $this->context->language->iso_code . '.xml');
         if (!$rss) {
             $return['has_errors'] = true;
         }
         $articles_limit = 2;
         if ($rss) {
             foreach ($rss->channel->item as $item) {
                 if ($articles_limit > 0 && Validate::isCleanHtml((string) $item->title) && Validate::isCleanHtml((string) $item->description) && isset($item->link) && isset($item->title)) {
                     if (in_array($this->context->mode, array(Context::MODE_HOST, Context::MODE_HOST_CONTRIB))) {
                         $utm_content = 'cloud';
                     } else {
                         $utm_content = 'download';
                     }
                     $shop_default_country_id = (int) Configuration::get('PS_COUNTRY_DEFAULT');
                     $shop_default_iso_country = (string) Tools::strtoupper(Country::getIsoById($shop_default_country_id));
                     $analytics_params = array('utm_source' => 'back-office', 'utm_medium' => 'rss', 'utm_campaign' => 'back-office-' . $shop_default_iso_country, 'utm_content' => $utm_content);
                     $url_query = parse_url($item->link, PHP_URL_QUERY);
                     parse_str($url_query, $link_query_params);
                     if ($link_query_params) {
                         $full_url_params = array_merge($link_query_params, $analytics_params);
                         $base_url = explode('?', (string) $item->link);
                         $base_url = (string) $base_url[0];
                         $article_link = $base_url . '?' . http_build_query($full_url_params);
                     } else {
                         $article_link = (string) $item->link . '?' . http_build_query($analytics_params);
                     }
                     $return['rss'][] = array('date' => Tools::displayDate(date('Y-m-d', strtotime((string) $item->pubDate))), 'title' => (string) Tools::htmlentitiesUTF8($item->title), 'short_desc' => Tools::truncateString(strip_tags((string) $item->description), 150), 'link' => (string) $article_link);
                 } else {
                     break;
                 }
                 $articles_limit--;
             }
         }
     }
     die(Tools::jsonEncode($return));
 }
Beispiel #27
0
 /**
  * Check if COD carrier can be visible in checkout pages
  * depending on customer delivery address country and selected currency
  *
  * @param Cart $cart
  * @param DpdGroupConfiguration $configuration
  * @param $id_customer_country
  * @return bool
  */
 private function isCODCarrierAvailable(Cart $cart, DpdGroupConfiguration $configuration, $id_customer_country)
 {
     if ($configuration->dpd_country_select == DpdGroupConfiguration::OTHER_COUNTRY) {
         return true;
     }
     $customer_country_iso_code = Country::getIsoById((int) $id_customer_country);
     if ($configuration->dpd_country_select != $customer_country_iso_code) {
         return false;
     }
     require_once _DPDGROUP_CONTROLLERS_DIR_ . 'Configuration.controller.php';
     $configuration_controller = new DpdGroupConfigurationController();
     $configuration_controller->setAvailableCountries();
     $sender_currency = '';
     if (isset($configuration_controller->countries[$configuration->dpd_country_select]['currency'])) {
         $sender_currency = $configuration_controller->countries[$configuration->dpd_country_select]['currency'];
     }
     if (!$sender_currency) {
         return false;
     }
     $id_cart_currency = (int) $cart->id_currency;
     $cart_currency = Currency::getCurrency((int) $id_cart_currency);
     if ($sender_currency != $cart_currency['iso_code']) {
         return false;
     }
     return true;
 }
    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>
		&nbsp;|&nbsp;';
        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">&nbsp;</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>
						&nbsp;
						<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>
						&nbsp;
						<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>
						&nbsp;
						<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" />&nbsp;&nbsp;' . $this->l('Module installed and enabled') . '</td>
						<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_disabled.png" />&nbsp;&nbsp;' . $this->l('Module installed but disabled') . '</td>
						<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_warning.png" />&nbsp;&nbsp;' . $this->l('Module installed but with warnings') . '</td>
						<td style="text-align:center"><img src="../img/admin/module_notinstall.png" />&nbsp;&nbsp;' . $this->l('Module not installed') . '</td>
					</tr>
				</table>
			<div style="clear:both">&nbsp;</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>';
        }
    }
Beispiel #29
0
    public function display()
    {
        global $cookie;
        $this->warnDomainName();
        $tab = get_class();
        $protocol = Tools::usingSecureMode() ? 'https' : 'http';
        $isoDefault = Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT')));
        $isoUser = Language::getIsoById(intval($cookie->id_lang));
        $isoCountry = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
        $currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT'));
        $employee = new Employee($cookie->id_employee);
        echo '<div>
		<h1>' . $this->l('Dashboard') . '</h1>
		<hr style="background-color: #812143;color: #812143;" />
		<br />';
        if (@ini_get('allow_url_fopen')) {
            $upgrade = new Upgrader();
            if ($update = $upgrade->checkPSVersion()) {
                echo '<div class="warning warn" style="margin-bottom:30px;"><h3>' . $this->l('New PrestaShop version available') . ' : <a style="text-decoration: underline;" href="' . $update['link'] . '" target="_blank">' . $this->l('Download') . '&nbsp;' . $update['name'] . '</a> !</h3></div>';
            }
        } else {
            echo '<p>' . $this->l('Update notification unavailable') . '</p>';
            echo '<p>&nbsp;</p>';
            echo '<p>' . $this->l('To receive PrestaShop update warnings, you need to activate the <b>allow_url_fopen</b> command in your <b>php.ini</b> config file.') . ' [<a href="http://www.php.net/manual/' . $isoUser . '/ref.filesystem.php">' . $this->l('more info') . '</a>]</p>';
            echo '<p>' . $this->l('If you don\'t know how to do that, please contact your host administrator !') . '</p><br>';
        }
        echo '</div>';
        if ($employee->bo_show_screencast) {
            echo '
			<div id="adminpresentation">
				<iframe src="' . $protocol . '://screencasts.prestashop.com/screencast.php?iso_lang=' . Tools::strtolower($isoUser) . '" style="border:none;width:100%;height:420px;" scrolling="no"></iframe>
				<div id="footer_iframe_home">
					<!--<a href="#">' . $this->l('View more video tutorials') . '</a>-->
					<input type="checkbox" id="screencast_dont_show_again"><label for="screencast_dont_show_again">' . $this->l('don\'t show again') . '</label>
				</div>
			</div>
			<script type="text/javascript">
			$(document).ready(function() {
				$(\'#screencast_dont_show_again\').click(function() {
					if ($(this).is(\':checked\'))
					{
						$.ajax({
							type: \'POST\',
							async: true,
							url: \'ajax.php?toggleScreencast\',
							success: function(data) {
								$(\'#adminpresentation\').slideUp(\'slow\');
							}
						});
					}
				});
			});
			</script>
			<div class="clear"></div><br />';
        }
        echo '
		<div id="column_left">
			<ul class="F_list clearfix">
				<li id="first_block">
					<h4><a href="index.php?tab=AdminCatalog&addcategory&token=' . Tools::getAdminTokenLite('AdminCatalog') . '">' . $this->l('New category') . '</a></h4>
					<p>' . $this->l('Create a new category and organize your products.') . '</p>
				</li>
				<li id="second_block">
					<h4><a href="index.php?tab=AdminCatalog&id_category=1&addproduct&token=' . Tools::getAdminTokenLite('AdminCatalog') . '">' . $this->l('New product') . '</a></h4>
					<p>' . $this->l('Fill up your catalog with new articles and attributes.') . '</p>
				</li>
				<li id="third_block">
					<h4><a href="index.php?tab=AdminStats&token=' . Tools::getAdminTokenLite('AdminStats') . '">' . $this->l('Statistics') . '</a></h4>
					<p>' . $this->l('Manage your activity with a thorough analysis of your e-shop.') . '</p>
				</li>
				<li id="fourth_block">
					<h4><a href="index.php?tab=AdminEmployees&addemployee&token=' . Tools::getAdminTokenLite('AdminEmployees') . '">' . $this->l('New employee') . '</a></h4>
					<p>' . $this->l('Add a new employee account and discharge a part of your duties of shop owner.') . '</p>
				</li>
			</ul>
			';
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT SUM(o.`total_paid_real` / o.conversion_rate) as total_sales, COUNT(*) as total_orders
			FROM `' . _DB_PREFIX_ . 'orders` o
			WHERE o.valid = 1
			AND o.`invoice_date` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\' ');
        $result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT COUNT(`id_customer`) AS total_registrations
			FROM `' . _DB_PREFIX_ . 'customer` c
			WHERE c.`date_add` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\'');
        $result3 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT SUM(pv.`counter`) AS total_viewed
			FROM `' . _DB_PREFIX_ . 'page_viewed` pv
			LEFT JOIN `' . _DB_PREFIX_ . 'date_range` dr ON pv.`id_date_range` = dr.`id_date_range`
			LEFT JOIN `' . _DB_PREFIX_ . 'page` p ON pv.`id_page` = p.`id_page`
			LEFT JOIN `' . _DB_PREFIX_ . 'page_type` pt ON pt.`id_page_type` = p.`id_page_type`
			WHERE pt.`name` = \'product.php\'
			AND dr.`time_start` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\'
			AND dr.`time_end` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\'');
        $results = array_merge($result, array_merge($result2, $result3));
        echo '
			<div class="table_info">
				<h5><a href="index.php?tab=AdminStats&token=' . Tools::getAdminTokenLite('AdminStats') . '">' . $this->l('View more') . '</a> ' . $this->l('Monthly Statistics') . ' </h5>
				<table class="table_info_details">
					<tr class="tr_odd">
						<td class="td_align_left">
						' . $this->l('Sales') . '
						</td>
						<td>
							' . Tools::displayPrice($results['total_sales'], $currency) . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Total registrations') . '
						</td>
						<td>
							' . (int) $results['total_registrations'] . '
						</td>
					</tr>
					<tr class="tr_odd">
						<td class="td_align_left">
							' . $this->l('Total orders') . '
						</td>
						<td>
							' . (int) $results['total_orders'] . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Product pages viewed') . '
						</td>
						<td>
							' . (int) $results['total_viewed'] . '
						</td>
					</tr>
				</table>
			</div>
			';
        $all = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'customer_thread');
        $unread = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'customer_thread` WHERE `status` = "open"');
        $pending = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'customer_thread` WHERE `status` LIKE "%pending%"');
        $close = $all - ($unread + $pending);
        echo '
			<div class="table_info" id="table_info_last">
				<h5><a href="index.php?tab=AdminCustomerThreads&token=' . Tools::getAdminTokenLite('AdminCustomerThreads') . '">' . $this->l('View more') . '</a> ' . $this->l('Customers service') . '</h5>
				<table class="table_info_details">
					<tr class="tr_odd">
						<td class="td_align_left">
						' . $this->l('Thread unread') . '
						</td>
						<td>
							' . $unread . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Thread pending') . '
						</td>
						<td>
							' . $pending . '
						</td>
					</tr>
					<tr class="tr_odd">
						<td class="td_align_left">
							' . $this->l('Thread closed') . '
						</td>
						<td>
							' . $close . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Total thread') . '
						</td>
						<td>
							' . $all . '
						</td>
					</tr>
				</table>
			</div>

			<div id="table_info_large">
				<h5><a href="index.php?tab=AdminStats&token=' . Tools::getAdminTokenLite('AdminStats') . '">' . $this->l('View more') . '</a> <strong>' . $this->l('Statistics') . '</strong> / ' . $this->l('Sales of the week') . '</h5>
				<div id="stat_google">';
        define('PS_BASE_URI', __PS_BASE_URI__);
        $chart = new Chart();
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
			SELECT total_paid / conversion_rate as total_converted, invoice_date
			FROM ' . _DB_PREFIX_ . 'orders o
			WHERE valid = 1
			AND invoice_date BETWEEN \'' . date('Y-m-d', strtotime('-7 DAYS', time())) . ' 00:00:00\' AND \'' . date('Y-m-d H:i:s') . '\'');
        foreach ($result as $row) {
            $chart->getCurve(1)->setPoint(strtotime($row['invoice_date']), $row['total_converted']);
        }
        $chart->setSize(580, 170);
        $chart->setTimeMode(strtotime('-7 DAYS', time()), time(), 'd');
        $chart->getCurve(1)->setLabel($this->l('Sales +Tx') . ' (' . strtoupper($currency->iso_code) . ')');
        $chart->display();
        echo '	</div>
			</div>
			<table cellpadding="0" cellspacing="0" id="table_customer">
				<thead>
					<tr>
						<th class="order_id"><span class="first">' . $this->l('ID') . '</span></th>
						<th class="order_customer"><span>' . $this->l('Customer Name') . '</span></th>
						<th class="order_status"><span>' . $this->l('Status') . '</span></th>
						<th class="order_total"><span>' . $this->l('Total') . '</span></th>
						<th class="order_action"><span class="last">' . $this->l('Action') . '</span></th>
					<tr>
				</thead>
				<tbody>';
        $orders = Order::getOrdersWithInformations(10);
        $i = 0;
        foreach ($orders as $order) {
            $currency = Currency::getCurrency((int) $order['id_currency']);
            echo '
					<tr' . ($i % 2 ? ' id="order_line1"' : '') . '>
						<td class="order_td_first order_id">' . (int) $order['id_order'] . '</td>
						<td class="order_customer">' . Tools::htmlentitiesUTF8($order['firstname']) . ' ' . Tools::htmlentitiesUTF8($order['lastname']) . '</td>
						<td class="order_status">' . Tools::htmlentitiesUTF8($order['state_name']) . '</td>
						<td class="order_total">' . Tools::displayPrice((double) $order['total_paid'], $currency) . '</td>
						<td class="order_action">
							<a href="index.php?tab=AdminOrders&id_order=' . (int) $order['id_order'] . '&vieworder&token=' . Tools::getAdminTokenLite('AdminOrders') . '" title="' . $this->l('Details') . '"><img src="../img/admin/details.gif" alt="' . $this->l('See') . '" /></a>
						</td>
					</tr>
				';
            $i++;
        }
        echo '
				</tbody>
			</table>
		</div>
		<div id="column_right">
			<script type="text/javascript">
				$(document).ready(function() {
					$.ajax({
						url: "ajax.php",
						dataType: "json",
						data: "getAdminHomeElement",
						success: function(json) {
							if (json.screencast != \'NOK\')
								$(\'#adminpresentation\').fadeIn(\'slow\');
							else
								$(\'#adminpresentation\').fadeOut(\'slow\');

							$(\'#partner_preactivation\').fadeOut(\'slow\', function() {
								if (json.partner_preactivation != \'NOK\')
									$(\'#partner_preactivation\').html(json.partner_preactivation);
								else
									$(\'#partner_preactivation\').html(\'\');
								$(\'#partner_preactivation\').fadeIn(\'slow\');
							});

							$(\'#discover_prestashop\').fadeOut(\'slow\', function() {
								if (json.discover_prestashop != \'NOK\')
									$(\'#discover_prestashop\').html(json.discover_prestashop);
								else
									$(\'#discover_prestashop\').html(\'\');
								$(\'#discover_prestashop\').fadeIn(\'slow\');
							});
						},
						error: function(XMLHttpRequest, textStatus, errorThrown)
						{
							$(\'#adminpresentation\').fadeOut(\'slow\');
							$(\'#partner_preactivation\').fadeOut(\'slow\');
							$(\'#discover_prestashop\').fadeOut(\'slow\');
						}
					});
				});
			</script>
			<div id="partner_preactivation">
				<p class="center"><img src="../img/loader.gif" alt="" /> ' . translate('Loading...') . '</p>
			</div>
		';
        if (Tools::isSubmit('hideOptimizationTips')) {
            Configuration::updateValue('PS_HIDE_OPTIMIZATION_TIPS', 1);
        }
        $this->_displayOptimizationTips();
        echo '
			<div id="discover_prestashop">
				<p class="center"><img src="../img/loader.gif" alt="" /> ' . translate('Loading...') . '</p>
			</div>
		</div>
		<div class="clear"></div>';
        echo Module::hookExec('backOfficeHome');
    }
Beispiel #30
0
        $value = '';
        foreach ($hookedModules as $module) {
            $ids = explode('_', $module);
            $value .= '(' . $ids[1] . ', (SELECT id_hook FROM `' . _DB_PREFIX_ . 'hook` WHERE `name` = \'' . pSQL($hook) . '\' LIMIT 0, 1), ' . $i . '),';
            $i++;
        }
        $value = rtrim($value, ',');
        Db::getInstance()->Execute('INSERT INTO  `' . _DB_PREFIX_ . 'hook_module` (`id_module`, `id_hook`, `position`) VALUES ' . $value);
    }
    die('{"hasError" : false, "errors" : ""}');
}
if (Tools::isSubmit('getAdminHomeElement')) {
    $result = array();
    $protocol = (!empty($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http';
    $isoUser = Language::getIsoById(intval($cookie->id_lang));
    $isoCountry = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
    $context = stream_context_create(array('http' => array('method' => "GET", 'timeout' => 5)));
    // SCREENCAST
    if (@fsockopen('www.prestashop.com', 80, $errno, $errst, 3)) {
        $result['screencast'] = 'OK';
    } else {
        $result['screencast'] = 'NOK';
    }
    // PREACTIVATION
    $content = @file_get_contents($protocol . '://www.prestashop.com/partner/preactivation/preactivation-block.php?version=1.0&shop=' . urlencode(Configuration::get('PS_SHOP_NAME')) . '&protocol=' . $protocol . '&url=' . urlencode($_SERVER['HTTP_HOST']) . '&iso_country=' . $isoCountry . '&iso_lang=' . Tools::strtolower($isoUser) . '&id_lang=' . (int) $cookie->id_lang . '&email=' . urlencode(Configuration::get('PS_SHOP_EMAIL')) . '&date_creation=' . _PS_CREATION_DATE_ . '&v=' . _PS_VERSION_ . '&security=' . md5(Configuration::get('PS_SHOP_EMAIL') . _COOKIE_IV_), false, $context);
    if (!$content) {
        $result['partner_preactivation'] = 'NOK';
    } else {
        $content = explode('|', $content);
        if ($content[0] == 'OK') {
            $result['partner_preactivation'] = $content[2];