Ejemplo n.º 1
0
 public static function isApplicable($id_country)
 {
     $isApplicable = in_array(Country::getIsoById((int) $id_country), VatNumber::getPrefixIntracomVAT());
     if ($isApplicable == "") {
         return 0;
     }
     return 1;
 }
Ejemplo n.º 2
0
 public function validateController($htmlentities = true)
 {
     $errors = parent::validateController($htmlentities);
     if (!Configuration::get('VATNUMBER_CHECKING')) {
         return $errors;
     }
     include_once _PS_MODULE_DIR_ . 'vatnumber/vatnumber.php';
     if (class_exists('VatNumber', false)) {
         return array_merge($errors, VatNumber::WebServiceCheck($this->vat_number));
     }
     return $errors;
 }
Ejemplo n.º 3
0
 /**
  * Assign template vars related to vat number
  * @todo move this in vatnumber module !
  */
 protected function assignVatNumber()
 {
     $vat_number_exists = file_exists(_PS_MODULE_DIR_ . 'vatnumber/vatnumber.php');
     $vat_number_management = Configuration::get('VATNUMBER_MANAGEMENT');
     if ($vat_number_management && $vat_number_exists) {
         include_once _PS_MODULE_DIR_ . 'vatnumber/vatnumber.php';
     }
     if ($vat_number_management && $vat_number_exists && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT'))) {
         $vat_display = 2;
     } else {
         if ($vat_number_management) {
             $vat_display = 1;
         } else {
             $vat_display = 0;
         }
     }
     $this->context->smarty->assign(array('vatnumber_ajax_call' => file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'), 'vat_display' => $vat_display));
 }
 public function renderForm()
 {
     $this->fields_form = array('legend' => array('title' => $this->l('Addresses'), 'image' => '../img/admin/contact.gif'), 'input' => array(array('type' => 'text_customer', 'label' => $this->l('Customer'), 'name' => 'id_customer', 'size' => 33, 'required' => false), array('type' => 'text', 'label' => $this->l('Identification Number'), 'name' => 'dni', 'size' => 30, 'required' => false, 'desc' => $this->l('DNI / NIF / NIE')), array('type' => 'text', 'label' => $this->l('Address alias'), 'name' => 'alias', 'size' => 33, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Home phone'), 'name' => 'phone', 'size' => 33, 'required' => false), array('type' => 'text', 'label' => $this->l('Mobile phone'), 'name' => 'phone_mobile', 'size' => 33, 'required' => false, 'desc' => sprintf($this->l('You must register at least one phone number %s'), '<sup>*</sup>')), array('type' => 'textarea', 'label' => $this->l('Other'), 'name' => 'other', 'cols' => 36, 'rows' => 4, 'required' => false, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span>')), 'submit' => array('title' => $this->l('   Save   '), 'class' => 'button'));
     $id_customer = (int) Tools::getValue('id_customer');
     if (!$id_customer && Validate::isLoadedObject($this->object)) {
         $id_customer = $this->object->id_customer;
     }
     if ($id_customer) {
         $customer = new Customer((int) $id_customer);
         $token_customer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $this->context->employee->id);
     }
     // @todo in 1.4, this include was done before the class declaration
     // We should use a hook now
     if (Configuration::get('VATNUMBER_MANAGEMENT') && file_exists(_PS_MODULE_DIR_ . 'vatnumber/vatnumber.php')) {
         include_once _PS_MODULE_DIR_ . 'vatnumber/vatnumber.php';
     }
     if (Configuration::get('VATNUMBER_MANAGEMENT')) {
         if (file_exists(_PS_MODULE_DIR_ . 'vatnumber/vatnumber.php') && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT'))) {
             $vat = 'is_applicable';
         } else {
             $vat = 'management';
         }
     }
     $this->tpl_form_vars = array('vat' => isset($vat) ? $vat : null, 'customer' => isset($customer) ? $customer : null, 'tokenCustomer' => isset($token_customer) ? $token_customer : null);
     // Order address fields depending on country format
     $addresses_fields = $this->processAddressFormat();
     // we use  delivery address
     $addresses_fields = $addresses_fields['dlv_all_fields'];
     $temp_fields = array();
     foreach ($addresses_fields as $addr_field_item) {
         if ($addr_field_item == 'company') {
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company', 'size' => 33, 'required' => false, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span>');
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('VAT number'), 'name' => 'vat_number', 'size' => 33);
         } else {
             if ($addr_field_item == 'lastname') {
                 if (isset($customer) && !Tools::isSubmit('submit' . strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object)) {
                     $default_value = $customer->lastname;
                 } else {
                     $default_value = '';
                 }
                 $temp_fields[] = array('type' => 'text', 'label' => $this->l('Last name'), 'name' => 'lastname', 'size' => 33, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span>', 'default_value' => $default_value);
             } else {
                 if ($addr_field_item == 'firstname') {
                     if (isset($customer) && !Tools::isSubmit('submit' . strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object)) {
                         $default_value = $customer->firstname;
                     } else {
                         $default_value = '';
                     }
                     $temp_fields[] = array('type' => 'text', 'label' => $this->l('First name'), 'name' => 'firstname', 'size' => 33, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span>', 'default_value' => $default_value);
                 } else {
                     if ($addr_field_item == 'address1') {
                         $temp_fields[] = array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address1', 'size' => 33, 'required' => true);
                     } else {
                         if ($addr_field_item == 'address2') {
                             $temp_fields[] = array('type' => 'text', 'label' => $this->l('Address') . ' (2)', 'name' => 'address2', 'size' => 33, 'required' => false);
                         } elseif ($addr_field_item == 'postcode') {
                             $temp_fields[] = array('type' => 'text', 'label' => $this->l('Postal Code/Zip Code'), 'name' => 'postcode', 'size' => 33, 'required' => true);
                         } else {
                             if ($addr_field_item == 'city') {
                                 $temp_fields[] = array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'size' => 33, 'required' => true);
                             } else {
                                 if ($addr_field_item == 'country' || $addr_field_item == 'Country:name') {
                                     $temp_fields[] = array('type' => 'select', 'label' => $this->l('Country:'), 'name' => 'id_country', 'required' => false, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name'));
                                     $temp_fields[] = array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => false, 'options' => array('query' => array(), 'id' => 'id_state', 'name' => 'name'));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // merge address format with the rest of the form
     array_splice($this->fields_form['input'], 3, 0, $temp_fields);
     return parent::renderForm();
 }
 public function process()
 {
     parent::process();
     /* Secure restriction for guest */
     if (self::$cookie->is_guest) {
         Tools::redirect('addresses.php');
     }
     if (Tools::isSubmit('id_country') and Tools::getValue('id_country') != NULL and is_numeric(Tools::getValue('id_country'))) {
         $selectedCountry = (int) Tools::getValue('id_country');
     } elseif (isset($this->_address) and isset($this->_address->id_country) and !empty($this->_address->id_country) and is_numeric($this->_address->id_country)) {
         $selectedCountry = (int) $this->_address->id_country;
     } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $array = preg_split('/,|-/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         if (!Validate::isLanguageIsoCode($array[0]) or !($selectedCountry = Country::getByIso($array[0]))) {
             $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
         }
     } else {
         $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
     }
     $countries = Country::getCountries((int) self::$cookie->id_lang, true);
     $countriesList = '';
     foreach ($countries as $country) {
         $countriesList .= '<option value="' . (int) $country['id_country'] . '" ' . ($country['id_country'] == $selectedCountry ? 'selected="selected"' : '') . '>' . htmlentities($country['name'], ENT_COMPAT, 'UTF-8') . '</option>';
     }
     if ((Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(_PS_MODULE_DIR_ . 'vatnumber/vatnumber.php')) && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT'))) {
         self::$smarty->assign('vat_display', 2);
     } else {
         if (Configuration::get('VATNUMBER_MANAGEMENT')) {
             self::$smarty->assign('vat_display', 1);
         } else {
             self::$smarty->assign('vat_display', 0);
         }
     }
     self::$smarty->assign('ajaxurl', _MODULE_DIR_);
     self::$smarty->assign(array('countries_list' => $countriesList, 'countries' => $countries, 'errors' => $this->errors, 'token' => Tools::getToken(false), 'select_address' => (int) Tools::getValue('select_address')));
 }
Ejemplo n.º 6
0
/*
* 2007-2011 PrestaShop 
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2011 PrestaShop SA
*  @version  Release: $Revision: 6594 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../init.php';
include dirname(__FILE__) . '/vatnumber.php';
echo VatNumber::isApplicable($_GET['id_country']);
Ejemplo n.º 7
0
 public function renderForm()
 {
     ${"GLOBALS"}["dddtfrxpcw"] = "idx";
     global $cookie;
     ${"GLOBALS"}["oqzraukpnhx"] = "idx";
     $cfgszngkkdgu = "conf";
     ${"GLOBALS"}["hiukelnql"] = "token_shop";
     ${"GLOBALS"}["yfpqvur"] = "ad";
     $okhklostdzy = "idx";
     $mrppodshf = "isoTinyMCE";
     $vayvrofuh = "iso";
     $tlyqnsqamoo = "obj";
     if (!(${$tlyqnsqamoo} = $this->loadObject(true))) {
         return;
     }
     $swbexjxsqcx = "id_customer";
     ${"GLOBALS"}["grhnkmgq"] = "token_shop";
     ${$vayvrofuh} = $this->context->language->iso_code;
     ${$mrppodshf} = file_exists(_PS_ROOT_DIR_ . "/js/tiny_mce/langs/" . $this->context->language->iso_code . ".js") ? $this->context->language->iso_code : "en";
     ${"GLOBALS"}["yuhqxxl"] = "linktoshop";
     ${${"GLOBALS"}["yfpqvur"]} = dirname($_SERVER["PHP_SELF"]);
     $this->context->smarty->assign(array("ad" => ${${"GLOBALS"}["ysuzwjqph"]}, "isoTinyMCE" => ${${"GLOBALS"}["lyfpont"]}, "base_dir" => _PS_BASE_URL_ . __PS_BASE_URI__, "base_dir_ssl" => _PS_BASE_URL_SSL_ . __PS_BASE_URI__, "theme_css_dir" => _THEME_CSS_DIR_));
     ${${"GLOBALS"}["hiukelnql"]} = Tools::getAdminToken("AdminShopUrl" . (int) Tab::getIdFromClassName("AdminShopUrl") . (int) $this->context->employee->id);
     ${${"GLOBALS"}["yuhqxxl"]} = "./index.php?controller=AdminShopUrl&token=" . ${${"GLOBALS"}["grhnkmgq"]} . "&id_shop=" . $this->object->id_shop;
     $this->fields_form = array("legend" => array("title" => $this->l('Seller Info'), "image" => "../img/admin/tab-customers.gif"), "input" => array(array("type" => "text_customer", "label" => $this->l('Front Store Account:'), "name" => "id_customer", "size" => 33, "required" => false), array("type" => "text_seller_employee", "label" => $this->l('Back office Account:'), "name" => "id_seller", "size" => 33, "required" => false), array("type" => "select", "label" => $this->l('Seller Home Category:'), "name" => "id_category_default", "required" => false, "default_value" => 0, "options" => array("query" => Category::getCategories($cookie->id_lang, true, false), "id" => "id_category", "name" => "name")), array("type" => "select", "label" => $this->l('Shop:'), "name" => "id_shop", "required" => false, "default_value" => 0, "options" => array("query" => $this->getAllShops(false), "id" => "id_shop", "name" => "name"), "desc" => "<a href=\"" . ${${"GLOBALS"}["jjmxkznq"]} . "\">" . $this->l('Click here to go shop managenment page') . "</a>"), array("type" => "text", "label" => $this->l('Company:'), "name" => "company", "size" => 33, "lang" => true, "required" => true, "hint" => $this->l('Forbidden characters:') . " 0-9!<>,;?=+()@#\"?{}_\$%:")));
     $this->fields_form["input"][] = array("type" => "select", "label" => $this->l('Primary Type'), "name" => "id_sellertype1", "required" => false, "options" => array("query" => Module::isInstalled("agilemultipleshop") ? SellerType::getSellerTypes($this->context->language->id, $this->l('Please choose seller type')) : array(), "id" => "id_sellertype", "name" => "name"));
     ${"GLOBALS"}["khxuuqb"] = "idx";
     $vkfmusoiw = "token_employee";
     $this->fields_form["input"][] = array("type" => "select", "label" => $this->l('Secondary Type'), "name" => "id_sellertype2", "required" => false, "options" => array("query" => Module::isInstalled("agilemultipleshop") ? SellerType::getSellerTypes($this->context->language->id, $this->l('Please choose seller type')) : array(), "id" => "id_sellertype", "name" => "name"));
     $this->fields_form["input"][] = array("type" => "file", "label" => $this->l('Logo:'), "name" => "logo", "display_image" => true, "col" => 6, "desc" => $this->l('Upload seller logo from your computer'));
     $this->fields_form["input"][] = array("type" => "textarea", "label" => $this->l('Description:'), "name" => "description", "lang" => true, "autoload_rte" => true, "rows" => 10, "cols" => 100, "hint" => $this->l('Invalid characters:') . " <>;=#{}");
     $vofzvpkc = "seller_employee";
     $qnjhtskd = "id_customer";
     $this->fields_form["input"][] = array("type" => "text", "label" => $this->l('Address Line1:'), "name" => "address1", "lang" => true, "size" => 33, "required" => true, "hint" => $this->l('Forbidden characters:') . " 0-9!<>,;?=+()@#\"?{}_\$%:");
     $this->fields_form["input"][] = array("type" => "text", "label" => $this->l('Address Line2:'), "name" => "address2", "lang" => true, "size" => 33, "required" => false, "hint" => $this->l('Invalid characters:') . " 0-9!<>,;?=+()@#\"?{}_\$%:");
     $this->fields_form["input"][] = array("type" => "text", "label" => $this->l('City:'), "name" => "city", "lang" => true, "size" => 33, "required" => true, "hint" => $this->l('Invalid characters:') . " 0-9!<>,;?=+()@#\"?{}_\$%:");
     $irumgsgqqjyo = "idx";
     ${"GLOBALS"}["yfrskcvv"] = "logo_image";
     $this->fields_form["input"][] = array("type" => "text", "label" => $this->l('Postal Code:'), "name" => "postcode", "size" => 33, "required" => true);
     $this->fields_form["input"][] = array("type" => "select", "label" => $this->l('State'), "name" => "id_state", "required" => false, "options" => array("query" => array(), "id" => "id_state", "name" => "name"));
     ${"GLOBALS"}["hxbjsmu"] = "customer";
     $this->fields_form["input"][] = array("type" => "select", "label" => $this->l('Country:'), "name" => "id_country", "required" => true, "default_value" => (int) $this->context->country->id, "options" => array("query" => Country::getCountries($this->context->language->id, true), "id" => "id_country", "name" => "name"));
     $this->fields_form["input"][] = array("type" => "text", "label" => $this->l('Phone:'), "name" => "phone", "size" => 33, "required" => false);
     $this->fields_form["input"][] = array("type" => "text", "label" => $this->l('Fax:'), "name" => "fax", "size" => 33, "required" => false);
     $this->fields_form["input"][] = array("type" => "text", "label" => $this->l('Identification:'), "name" => "dni", "size" => 33, "required" => false);
     $this->fields_form["input"][] = array("type" => "text", "label" => $this->l('Latitude:'), "name" => "latitude", "size" => 33, "required" => false);
     $this->fields_form["input"][] = array("type" => "text", "label" => $this->l('Longitude:'), "name" => "longitude", "size" => 33, "required" => false);
     ${$cfgszngkkdgu} = Configuration::getMultiple(array("AGILE_MS_SELLER_TEXT1", "AGILE_MS_SELLER_TEXT2", "AGILE_MS_SELLER_TEXT3", "AGILE_MS_SELLER_TEXT4", "AGILE_MS_SELLER_TEXT5", "AGILE_MS_SELLER_TEXT6", "AGILE_MS_SELLER_TEXT7", "AGILE_MS_SELLER_TEXT8", "AGILE_MS_SELLER_TEXT9", "AGILE_MS_SELLER_TEXT10", "AGILE_MS_SELLER_HTML1", "AGILE_MS_SELLER_HTML2", "AGILE_MS_SELLER_NUMBER1", "AGILE_MS_SELLER_NUMBER2", "AGILE_MS_SELLER_NUMBER3", "AGILE_MS_SELLER_NUMBER4", "AGILE_MS_SELLER_NUMBER5", "AGILE_MS_SELLER_DATE1", "AGILE_MS_SELLER_DATE2", "AGILE_MS_SELLER_DATE3", "AGILE_MS_SELLER_DATE4", "AGILE_MS_SELLER_DATE5"));
     ${"GLOBALS"}["wfpjljldqp"] = "idx";
     ${"GLOBALS"}["hcfmkerjksv"] = "id_seller";
     for (${${"GLOBALS"}["khxuuqb"]} = 1; ${${"GLOBALS"}["mkdxvwk"]} <= 10; ${${"GLOBALS"}["mkdxvwk"]}++) {
         ${"GLOBALS"}["ybndfnrbxa"] = "conf";
         $xnfolwno = "idx";
         $kykjjpjyw = "conf";
         if (isset(${${"GLOBALS"}["ybndfnrbxa"]}["AGILE_MS_SELLER_TEXT" . ${${"GLOBALS"}["mkdxvwk"]}]) and ${$kykjjpjyw}["AGILE_MS_SELLER_TEXT" . ${$xnfolwno}]) {
             ${"GLOBALS"}["mdpisxrrstb"] = "idx";
             $this->fields_form["input"][] = array("type" => "text", "label" => $this->custom_labels["ams_custom_text" . ${${"GLOBALS"}["mkdxvwk"]}], "name" => "ams_custom_text" . ${${"GLOBALS"}["mdpisxrrstb"]}, "lang" => true, "size" => 100, "required" => false);
         }
     }
     for (${${"GLOBALS"}["wfpjljldqp"]} = 1; ${$irumgsgqqjyo} <= 2; ${$okhklostdzy}++) {
         ${"GLOBALS"}["ykynuwygbxsx"] = "conf";
         $nhkctnss = "idx";
         $pmfejhu = "idx";
         if (isset(${${"GLOBALS"}["ykynuwygbxsx"]}["AGILE_MS_SELLER_HTML" . ${$nhkctnss}]) and ${${"GLOBALS"}["fpybeyzhk"]}["AGILE_MS_SELLER_HTML" . ${$pmfejhu}]) {
             $wjkzjmpxq = "idx";
             $this->fields_form["input"][] = array("type" => "textarea", "label" => $this->custom_labels["ams_custom_html" . ${${"GLOBALS"}["mkdxvwk"]}], "name" => "ams_custom_html" . ${$wjkzjmpxq}, "lang" => true, "autoload_rte" => true, "rows" => 10, "cols" => 100, "required" => false);
         }
     }
     for (${${"GLOBALS"}["mkdxvwk"]} = 1; ${${"GLOBALS"}["oqzraukpnhx"]} <= 10; ${${"GLOBALS"}["mkdxvwk"]}++) {
         ${"GLOBALS"}["xfwmtomgx"] = "conf";
         if (isset(${${"GLOBALS"}["xfwmtomgx"]}["AGILE_MS_SELLER_NUMBER" . ${${"GLOBALS"}["mkdxvwk"]}]) and ${${"GLOBALS"}["fpybeyzhk"]}["AGILE_MS_SELLER_NUMBER" . ${${"GLOBALS"}["mkdxvwk"]}]) {
             $xubipgq = "idx";
             $this->fields_form["input"][] = array("type" => "text", "label" => $this->custom_labels["ams_custom_number" . ${${"GLOBALS"}["mkdxvwk"]}], "name" => "ams_custom_number" . ${$xubipgq});
         }
     }
     ${"GLOBALS"}["injkquajrp"] = "id_seller";
     ${"GLOBALS"}["qfnrzaw"] = "token_employee";
     ${"GLOBALS"}["ysydpigmsjw"] = "id_seller";
     for (${${"GLOBALS"}["mkdxvwk"]} = 1; ${${"GLOBALS"}["mkdxvwk"]} <= 5; ${${"GLOBALS"}["dddtfrxpcw"]}++) {
         $nwusbqthad = "idx";
         $oivqmjyo = "conf";
         if (isset(${$oivqmjyo}["AGILE_MS_SELLER_DATE" . ${${"GLOBALS"}["mkdxvwk"]}]) and ${${"GLOBALS"}["fpybeyzhk"]}["AGILE_MS_SELLER_DATE" . ${$nwusbqthad}]) {
             $this->fields_form["input"][] = array("type" => "date", "label" => $this->custom_labels["ams_custom_date" . ${${"GLOBALS"}["mkdxvwk"]}], "name" => "ams_custom_date" . ${${"GLOBALS"}["mkdxvwk"]}, "size" => 30);
         }
     }
     $this->fields_form["input"][] = array("type" => "google_map", "label" => $this->l('Map:'), "name" => "google_map", "required" => false);
     ${"GLOBALS"}["ixmuyengwu"] = "token_customer";
     if (!Module::isInstalled("agilemultipleshop")) {
         $nsyympiirvx = "i";
         ${"GLOBALS"}["dswivenyh"] = "i";
         for (${${"GLOBALS"}["yjobmyxznm"]} = 0; ${$nsyympiirvx} < count($this->fields_form["input"]); ${${"GLOBALS"}["dswivenyh"]}++) {
             ${"GLOBALS"}["ofnkmlnty"] = "i";
             if ($this->fields_form["input"][${${"GLOBALS"}["ofnkmlnty"]}]["name"] == "id_sellertype1" or $this->fields_form["input"][${${"GLOBALS"}["yjobmyxznm"]}]["name"] == "id_sellertype2") {
                 $mlwiiklojahc = "i";
                 unset($this->fields_form["input"][${$mlwiiklojahc}]);
             }
         }
     }
     $this->fields_form["submit"] = array("title" => $this->l('Save'), "class" => "btn btn-default pull-right");
     ${${"GLOBALS"}["jrcgrrr"]} = (int) Tools::getValue("id_customer");
     if (!${$qnjhtskd} && Validate::isLoadedObject($this->object)) {
         ${$swbexjxsqcx} = $this->object->id_customer;
     }
     if (${${"GLOBALS"}["jrcgrrr"]} > 0) {
         ${"GLOBALS"}["bltpsbtmczvh"] = "customer";
         ${${"GLOBALS"}["bltpsbtmczvh"]} = new Customer((int) ${${"GLOBALS"}["jrcgrrr"]});
         ${${"GLOBALS"}["rwpflypen"]} = Tools::getAdminToken("AdminCustomers" . (int) Tab::getIdFromClassName("AdminCustomers") . (int) $this->context->employee->id);
     }
     $mnlknnmlhtlq = "obj";
     ${${"GLOBALS"}["eyyibnxz"]} = (int) Tools::getValue("id_seller");
     if (!${${"GLOBALS"}["hcfmkerjksv"]} && Validate::isLoadedObject($this->object)) {
         ${${"GLOBALS"}["injkquajrp"]} = $this->object->id_seller;
     }
     if (${${"GLOBALS"}["ysydpigmsjw"]} > 0) {
         ${"GLOBALS"}["cpirvsll"] = "seller_employee";
         ${"GLOBALS"}["uetgcpbf"] = "seller_employee";
         ${${"GLOBALS"}["uetgcpbf"]} = new Employee((int) ${${"GLOBALS"}["eyyibnxz"]});
         if (Validate::isLoadedObject(${${"GLOBALS"}["urmtkk"]})) {
             ${${"GLOBALS"}["xwldamgmwyk"]} = Tools::getAdminToken("AdminEmployees" . (int) Tab::getIdFromClassName("AdminEmployees") . (int) $this->context->employee->id);
         } else {
             unset(${${"GLOBALS"}["cpirvsll"]});
         }
     }
     if (Configuration::get("VATNUMBER_MANAGEMENT") && file_exists(_PS_MODULE_DIR_ . "vatnumber/vatnumber.php")) {
         include_once _PS_MODULE_DIR_ . "vatnumber/vatnumber.php";
     }
     if (Configuration::get("VATNUMBER_MANAGEMENT")) {
         $kklclhqeiyjy = "vat";
         if (file_exists(_PS_MODULE_DIR_ . "vatnumber/vatnumber.php") && VatNumber::isApplicable(Configuration::get("PS_COUNTRY_DEFAULT"))) {
             ${${"GLOBALS"}["gmedzghdfbu"]} = "is_applicable";
         } else {
             ${$kklclhqeiyjy} = "management";
         }
     }
     ${${"GLOBALS"}["ejcxwlrcubn"]} = SellerInfo::get_seller_logo_url_static(Tools::getValue("id_sellerinfo"));
     $this->tpl_form_vars = array("vat" => isset(${${"GLOBALS"}["gmedzghdfbu"]}) ? ${${"GLOBALS"}["gmedzghdfbu"]} : null, "customer" => isset(${${"GLOBALS"}["hxbjsmu"]}) ? ${${"GLOBALS"}["lbmumw"]} : null, "seller_employee" => isset(${$vofzvpkc}) ? ${${"GLOBALS"}["urmtkk"]} : null, "agilemultipleseller_views" => _PS_ROOT_DIR_ . "/modules/agilemultipleseller/views/", "base_dir" => _PS_BASE_URL_ . __PS_BASE_URI__, "base_dir_ssl" => _PS_BASE_URL_SSL_ . __PS_BASE_URI__, "tokenCustomer" => isset(${${"GLOBALS"}["rwpflypen"]}) ? ${${"GLOBALS"}["ixmuyengwu"]} : null, "tokenEmployee" => isset(${$vkfmusoiw}) ? ${${"GLOBALS"}["qfnrzaw"]} : null, "logo_image_url" => ${${"GLOBALS"}["yfrskcvv"]} ? ${${"GLOBALS"}["ejcxwlrcubn"]} : false, "sellerinfo_obj" => ${$mnlknnmlhtlq});
     return parent::renderForm();
 }
Ejemplo n.º 8
0
 protected function _getGuestInformations()
 {
     if (!$this->isOpcModuleActive()) {
         return parent::_getGuestInformations();
     }
     $customer = $this->context->customer;
     $address_delivery = new Address($this->context->cart->id_address_delivery);
     if ($customer->birthday) {
         $birthday = explode('-', $customer->birthday);
     } else {
         $birthday = array('0', '0', '0');
     }
     $ret = array('use_another_invoice_address' => (bool) ((int) $this->context->cart->id_address_invoice != (int) $this->context->cart->id_address_delivery), 'id_address_invoice' => (int) $this->context->cart->id_address_invoice, 'id_customer' => (int) $customer->id, 'email' => Tools::htmlentitiesUTF8($customer->email), 'customer_lastname' => Tools::htmlentitiesUTF8($customer->lastname), 'customer_firstname' => Tools::htmlentitiesUTF8($customer->firstname), 'newsletter' => (int) $customer->newsletter, 'optin' => (int) $customer->optin, 'id_address_delivery' => (int) $this->context->cart->id_address_delivery, 'company' => Tools::htmlentitiesUTF8($address_delivery->company), 'lastname' => Tools::htmlentitiesUTF8($address_delivery->lastname), 'firstname' => Tools::htmlentitiesUTF8($address_delivery->firstname), 'vat_number' => Tools::htmlentitiesUTF8($address_delivery->vat_number), 'dni' => Tools::htmlentitiesUTF8($address_delivery->dni), 'address1' => Tools::htmlentitiesUTF8($address_delivery->address1), 'address2' => Tools::htmlentitiesUTF8($address_delivery->address2), 'postcode' => Tools::htmlentitiesUTF8($address_delivery->postcode), 'city' => Tools::htmlentitiesUTF8($address_delivery->city), 'other' => Tools::htmlentitiesUTF8($address_delivery->other), 'phone' => Tools::htmlentitiesUTF8($address_delivery->phone), 'phone_mobile' => Tools::htmlentitiesUTF8($address_delivery->phone_mobile), 'alias' => Tools::htmlentitiesUTF8($address_delivery->alias), 'id_country' => (int) $address_delivery->id_country, 'id_state' => (int) $address_delivery->id_state, 'id_gender' => (int) $customer->id_gender, 'sl_year' => $birthday[0], 'sl_month' => $birthday[1], 'sl_day' => $birthday[2]);
     if ($this->inv_first_on || (int) $this->context->cart->id_address_invoice != (int) $this->context->cart->id_address_delivery) {
         $address_invoice = new Address((int) $this->context->cart->id_address_invoice);
         $customers_address = (int) $this->context->cookie->id_customer == $address_invoice->id_customer ? true : false;
         $invoice = array('id_country_invoice' => (int) $address_invoice->id_country, 'id_state_invoice' => (int) $address_invoice->id_state);
         if (Configuration::get('VATNUMBER_MANAGEMENT') && file_exists(_PS_MODULE_DIR_ . '/vatnumber/vatnumber.php') && !class_exists("VatNumber", false)) {
             include _PS_MODULE_DIR_ . '/vatnumber/vatnumber.php';
         }
         if (Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(dirname(__FILE__) . '/../../modules/vatnumber/vatnumber.php') && VatNumber::isApplicable($address_invoice->id_country) && Configuration::get('VATNUMBER_COUNTRY') != $address_invoice->id_country) {
             $allow_eu_vat = 1;
         } else {
             $allow_eu_vat = 0;
         }
         if ($customers_address) {
             $addr = array('company_invoice' => Tools::htmlentitiesUTF8($address_invoice->company), 'lastname_invoice' => Tools::htmlentitiesUTF8($address_invoice->lastname), 'firstname_invoice' => Tools::htmlentitiesUTF8($address_invoice->firstname), 'vat_number_invoice' => Tools::htmlentitiesUTF8($address_invoice->vat_number), 'dni_invoice' => Tools::htmlentitiesUTF8($address_invoice->dni), 'address1_invoice' => Tools::htmlentitiesUTF8($address_invoice->address1), 'address2_invoice' => Tools::htmlentitiesUTF8($address_invoice->address2), 'postcode_invoice' => Tools::htmlentitiesUTF8($address_invoice->postcode), 'city_invoice' => Tools::htmlentitiesUTF8($address_invoice->city), 'other_invoice' => Tools::htmlentitiesUTF8($address_invoice->other), 'phone_invoice' => Tools::htmlentitiesUTF8($address_invoice->phone), 'phone_mobile_invoice' => Tools::htmlentitiesUTF8($address_invoice->phone_mobile), 'alias_invoice' => Tools::htmlentitiesUTF8($address_invoice->alias), 'allow_eu_vat_invoice' => $allow_eu_vat);
         } else {
             $addr = array();
         }
         $invoice = array_merge($invoice, $addr);
         $ret = array_merge($ret, $invoice);
     }
     return $ret;
 }
Ejemplo n.º 9
0
<?php

/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2014 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../init.php';
include dirname(__FILE__) . '/vatnumber.php';
echo VatNumber::isApplicable(Tools::getValue('id_country'));
Ejemplo n.º 10
0
 protected function assignVatNumber()
 {
     $gfdkrlst = "vat_display";
     $qssokcw = "vat_number_management";
     $gbsjsf = "vat_number_management";
     $yxoeuqffs = "vat_number_exists";
     ${${"GLOBALS"}["ifraese"]} = file_exists(_PS_MODULE_DIR_ . "vatnumber/vatnumber.php");
     ${$qssokcw} = Configuration::get("VATNUMBER_MANAGEMENT");
     if (${${"GLOBALS"}["ioffteysj"]} && ${${"GLOBALS"}["ifraese"]}) {
         include_once _PS_MODULE_DIR_ . "vatnumber/vatnumber.php";
     }
     if (${${"GLOBALS"}["ioffteysj"]} && ${$yxoeuqffs} && VatNumber::isApplicable(Configuration::get("PS_COUNTRY_DEFAULT"))) {
         ${$gfdkrlst} = 2;
     } else {
         if (${$gbsjsf}) {
             ${${"GLOBALS"}["drynrbcbmgcb"]} = 1;
         } else {
             ${${"GLOBALS"}["drynrbcbmgcb"]} = 0;
         }
     }
     $this->context->smarty->assign(array("vatnumber_ajax_call" => file_exists(_PS_MODULE_DIR_ . "vatnumber/ajax.php"), "vat_display" => ${${"GLOBALS"}["drynrbcbmgcb"]}));
 }
Ejemplo n.º 11
0
    public function displayForm($isMainTab = true)
    {
        global $currentIndex, $cookie;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
		' . ((int) $obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . (int) $obj->id . '" />' : '') . '
		' . (($id_order = (int) Tools::getValue('id_order')) ? '<input type="hidden" name="id_order" value="' . (int) $id_order . '" />' : '') . '
		' . (($address_type = (int) Tools::getValue('address_type')) ? '<input type="hidden" name="address_type" value="' . (int) $address_type . '" />' : '') . '
		' . (Tools::getValue('realedit') ? '<input type="hidden" name="realedit" value="1" />' : '') . '
			<fieldset>
				<legend><img src="../img/admin/contact.gif" alt="" />' . $this->l('Addresses') . '</legend>';
        switch ($this->addressType) {
            case 'manufacturer':
                echo '<label>' . $this->l('Choose manufacturer') . '</label>
				<div class="margin-form">';
                $manufacturers = Manufacturer::getManufacturers();
                echo '<select name="id_manufacturer">';
                if (!sizeof($manufacturers)) {
                    echo '<option value="0">' . $this->l('No manufacturer available') . '&nbsp</option>';
                }
                foreach ($manufacturers as $manufacturer) {
                    echo '<option value="' . (int) $manufacturer['id_manufacturer'] . '"' . ($this->getFieldValue($obj, 'id_manufacturer') == $manufacturer['id_manufacturer'] ? ' selected="selected"' : '') . '>' . $manufacturer['name'] . '&nbsp</option>';
                }
                echo '</select>';
                echo '</div>';
                echo '<input type="hidden" name="alias" value="manufacturer">';
                break;
            case 'customer':
            default:
                if ($obj->id) {
                    $customer = new Customer($obj->id_customer);
                    $tokenCustomer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee);
                    echo '
					<label>' . $this->l('Customer') . '</label>
					<div class="margin-form"><a style="display: block; padding-top: 4px;" href="?tab=AdminCustomers&id_customer=' . $customer->id . '&viewcustomer&token=' . $tokenCustomer . '">' . $customer->lastname . ' ' . $customer->firstname . ' (' . $customer->email . ')</a></div>
					<input type="hidden" name="id_customer" value="' . $customer->id . '" />
					<input type="hidden" name="email" value="' . $customer->email . '" />';
                } else {
                    echo '<label>' . $this->l('Customer e-mail') . '</label>
					<div class="margin-form">
						<input type="text" size="33" name="email" value="' . htmlentities(Tools::getValue('email'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: lowercase;" /> <sup>*</sup>
					</div>';
                }
                echo '
					<label for="dni">' . $this->l('Identification Number') . '</label>
					<div class="margin-form">
					<input type="text" name="dni" id="dni" value="' . htmlentities($this->getFieldValue($obj, 'dni'), ENT_COMPAT, 'UTF-8') . '" />
					<p>' . $this->l('DNI / NIF / NIE') . '</p>
					</div>';
                echo '<label>' . $this->l('Alias') . '</label>
				<div class="margin-form">
					<input type="text" size="33" name="alias" value="' . htmlentities($this->getFieldValue($obj, 'alias'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
				</div>';
                break;
        }
        $addresses_fields = $this->processAddressFormat();
        $addresses_fields = $addresses_fields["dlv_all_fields"];
        // we use  delivery address
        foreach ($addresses_fields as $addr_field_item) {
            if ($addr_field_item == 'company') {
                if ($this->addressType != 'manufacturer') {
                    echo '<label>' . $this->l('Company') . '</label>
						<div class="margin-form">
						<input type="text" size="33" name="company" value="' . htmlentities($this->getFieldValue($obj, 'company'), ENT_COMPAT, 'UTF-8') . '" />
						<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
						</div>';
                    if ((Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(_PS_MODULE_DIR_ . 'vatnumber/vatnumber.php')) && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT'))) {
                        echo '<div id="vat_area" style="display: visible">';
                    } elseif (Configuration::get('VATNUMBER_MANAGEMENT')) {
                        echo '<div id="vat_area" style="display: hidden">';
                    } else {
                        echo '<div style="display: none;">';
                    }
                    echo '<label>' . $this->l('VAT number') . '</label>
						<div class="margin-form">
						<input type="text" size="33" name="vat_number" value="' . htmlentities($this->getFieldValue($obj, 'vat_number'), ENT_COMPAT, 'UTF-8') . '" />
						</div>
						</div>';
                }
            } elseif ($addr_field_item == 'lastname') {
                echo '
					<label>' . $this->l('Last name') . '</label>
					<div class="margin-form">
					<input type="text" size="33" name="lastname" value="' . htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span></span>
					</div>';
            } elseif ($addr_field_item == 'firstname') {
                echo '
					<label>' . $this->l('First name') . '</label>
					<div class="margin-form">
					<input type="text" size="33" name="firstname" value="' . htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span></span>
					</div>';
            } elseif ($addr_field_item == 'address1') {
                echo '
					<label>' . $this->l('Address') . '</label>
					<div class="margin-form">
					<input type="text" size="33" name="address1" value="' . htmlentities($this->getFieldValue($obj, 'address1'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					</div>';
            } elseif ($addr_field_item == 'address2') {
                echo '
					<label>' . $this->l('Address') . ' (2)</label>
									     <div class="margin-form">
												      <input type="text" size="33" name="address2" value="' . htmlentities($this->getFieldValue($obj, 'address2'), ENT_COMPAT, 'UTF-8') . '" />
															      </div>';
            } elseif ($addr_field_item == 'postcode') {
                echo '
					<label>' . $this->l('Postcode/ Zip Code') . '</label>
					<div class="margin-form">
					<input type="text" size="33" name="postcode" value="' . htmlentities($this->getFieldValue($obj, 'postcode'), ENT_COMPAT, 'UTF-8') . '" />
					</div>';
            } elseif ($addr_field_item == 'city') {
                echo '
					<label>' . $this->l('City') . '</label>
					<div class="margin-form">
					<input type="text" size="33" name="city" value="' . htmlentities($this->getFieldValue($obj, 'city'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: uppercase;" /> <sup>*</sup>
					</div>';
            } elseif ($addr_field_item == 'country' || $addr_field_item == 'Country:name') {
                echo '
					<label>' . $this->l('Country') . '</label>
					<div class="margin-form">
					<select name="id_country" id="id_country" />';
                $selectedCountry = $this->getFieldValue($obj, 'id_country');
                foreach ($this->countriesArray as $id_country => $name) {
                    echo '		<option value="' . $id_country . '"' . ((!$selectedCountry and Configuration::get('PS_COUNTRY_DEFAULT') == $id_country) ? ' selected="selected"' : ($selectedCountry == $id_country ? ' selected="selected"' : '')) . '>' . $name . '</option>';
                }
                echo '		</select> <sup>*</sup>
					</div>';
                echo '
				<div id="contains_states" ' . (!Country::containsStates((int) $selectedCountry) ? 'style="display:none;"' : '') . '>
				<label>' . $this->l('State') . '</label>
				<div class="margin-form">
				<select name="id_state" id="id_state">
				</select>
				<sup>*</sup>
				</div>
				</div>';
                $id_country_ajax = (int) $this->getFieldValue($obj, 'id_country');
                echo '
					<script type="text/javascript">
					$(document).ready(function(){
							ajaxStates ();
							$(\'#id_country\').change(function() {
								ajaxStates ();
								});
							function ajaxStates ()
							{
								$.ajax({
									url: "ajax.php",
									cache: false,
									data: "ajaxStates=1&id_country="+$(\'#id_country\').val()+"&id_state="+$(\'#id_state\').val(),
									success: function(html)
										{
											if (html == \'false\')
											{
												$("#contains_states").fadeOut();
												$(\'#id_state option[value=0]\').attr("selected", "selected");
}
											else
											{
												$("#id_state").html(html);
												$("#contains_states").fadeIn();
												$(\'#id_state option[value=' . (int) $obj->id_state . ']\').attr("selected", "selected");
											}
										}
									}); ';
                if (file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php')) {
                    echo '	$.ajax({
					type: "GET",
					url: "' . _MODULE_DIR_ . 'vatnumber/ajax.php?id_country="+$(\'#id_country\').val(),
					success: function(isApplicable)
						{
							if (isApplicable == 1)
								$(\'#vat_area\').show();
							else
								$(\'#vat_area\').hide();
						}
					});';
                }
                echo '	}; }); </script>';
            }
        }
        // End foreach
        echo '
				<label>' . $this->l('Home phone') . '</label>
				<div class="margin-form">
					<input type="text" size="33" name="phone" value="' . htmlentities($this->getFieldValue($obj, 'phone'), ENT_COMPAT, 'UTF-8') . '" />
				</div>';
        echo '
				<label>' . $this->l('Mobile phone') . '</label>
				<div class="margin-form">
					<input type="text" size="33" name="phone_mobile" value="' . htmlentities($this->getFieldValue($obj, 'phone_mobile'), ENT_COMPAT, 'UTF-8') . '" />
				</div>';
        echo '
				<label>' . $this->l('Other') . '</label>
				<div class="margin-form">
					<textarea name="other" cols="36" rows="4">' . htmlentities($this->getFieldValue($obj, 'other'), ENT_COMPAT, 'UTF-8') . '</textarea>
					<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
				</div>';
        echo '
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>';
        echo '
		</form>';
    }
Ejemplo n.º 12
0
 public function process()
 {
     parent::process();
     /* Secure restriction for guest */
     if (self::$cookie->is_guest) {
         Tools::redirect('addresses.php');
     }
     if (Tools::isSubmit('id_country') and Tools::getValue('id_country') != NULL and is_numeric(Tools::getValue('id_country'))) {
         $selectedCountry = (int) Tools::getValue('id_country');
     } elseif (isset($this->_address) and isset($this->_address->id_country) and !empty($this->_address->id_country) and is_numeric($this->_address->id_country)) {
         $selectedCountry = (int) $this->_address->id_country;
     } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $array = preg_split('/,|-/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         if (!Validate::isLanguageIsoCode($array[0]) or !($selectedCountry = Country::getByIso($array[0]))) {
             $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
         }
     } else {
         $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
     }
     if (Tools::isSubmit('id_state') and Tools::getValue('id_state') != NULL and is_numeric(Tools::getValue('id_state'))) {
         $selected_state = Tools::getValue('id_state');
     } elseif (isset($this->_address) and isset($this->_address->id_country) and !empty($this->_address->id_country) and isset($this->_address->id_state)) {
         $selected_state = $this->_address->id_state;
     } else {
         $selected_state = 244;
     }
     // default to karnataka.
     $countries = Country::getCountries(1);
     $country_names = Country::getActiveCountries();
     self::$smarty->assign('countries', $countries);
     self::$smarty->assign('country_names', $country_names);
     if ((Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(_PS_MODULE_DIR_ . 'vatnumber/vatnumber.php')) && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT'))) {
         self::$smarty->assign('vat_display', 2);
     } else {
         if (Configuration::get('VATNUMBER_MANAGEMENT')) {
             self::$smarty->assign('vat_display', 1);
         } else {
             self::$smarty->assign('vat_display', 0);
         }
     }
     self::$smarty->assign('ajaxurl', _MODULE_DIR_);
     self::$smarty->assign('vatnumber_ajax_call', (int) file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'));
     self::$smarty->assign(array('selected_state' => $selected_state, 'errors' => $this->errors, 'token' => Tools::getToken(false), 'select_address' => (int) Tools::getValue('select_address')));
     $customer = new Customer((int) self::$cookie->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         die(Tools::displayError('Customer not found'));
     }
     self::$smarty->assign('address_count', sizeof($customer->getAddresses((int) self::$cookie->id_lang)));
 }
 protected function assignVatNumber()
 {
     ${"GLOBALS"}["vfyrrtr"] = "vat_number_exists";
     ${"GLOBALS"}["bhsvndabmia"] = "vat_number_management";
     ${"GLOBALS"}["nmgkvhi"] = "vat_number_exists";
     ${${"GLOBALS"}["vfyrrtr"]} = file_exists(_PS_MODULE_DIR_ . "vatnumber/vatnumber.php");
     $egrwjbj = "vat_number_management";
     ${$egrwjbj} = Configuration::get("VATNUMBER_MANAGEMENT");
     if (${${"GLOBALS"}["bhsvndabmia"]} && ${${"GLOBALS"}["nmgkvhi"]}) {
         include_once _PS_MODULE_DIR_ . "vatnumber/vatnumber.php";
     }
     $xotzrgkltvlh = "vat_display";
     if (${${"GLOBALS"}["mjmlmbldprsl"]} && ${${"GLOBALS"}["fjlbulnvkw"]} && VatNumber::isApplicable(Configuration::get("PS_COUNTRY_DEFAULT"))) {
         ${${"GLOBALS"}["tapzcfv"]} = 2;
     } else {
         if (${${"GLOBALS"}["mjmlmbldprsl"]}) {
             ${${"GLOBALS"}["tapzcfv"]} = 1;
         } else {
             ${$xotzrgkltvlh} = 0;
         }
     }
     $this->context->smarty->assign(array("vatnumber_ajax_call" => file_exists(_PS_MODULE_DIR_ . "vatnumber/ajax.php"), "vat_display" => ${${"GLOBALS"}["tapzcfv"]}));
 }
Ejemplo n.º 14
0
 public function hookActionValidateCustomerAddressForm(&$params)
 {
     $form = $params['form'];
     $is_valid = true;
     if (($vatNumber = $form->getField('vat_number')) && Configuration::get('VATNUMBER_MANAGEMENT') && Configuration::get('VATNUMBER_CHECKING')) {
         $isAVatNumber = VatNumber::WebServiceCheck($vatNumber->getValue());
         if (is_array($isAVatNumber) && count($isAVatNumber) > 0) {
             $vatNumber->addError($isAVatNumber[0]);
             $is_valid = false;
         }
     }
     return $is_valid;
 }
Ejemplo n.º 15
0
 public function postProcess()
 {
     if (!$this->isOpcModuleActive()) {
         return parent::postProcess();
     }
     $inv_first_on = Configuration::get('OPC_INVOICE_FIRST') == "1";
     if (Tools::isSubmit('submitAddress') && Tools::isSubmit('ajax')) {
         if (Tools::isSubmit('type')) {
             if (Tools::getValue('type') == 'delivery') {
                 if (!$inv_first_on) {
                     $id_address = isset($this->context->cart->id_address_delivery) ? (int) $this->context->cart->id_address_delivery : 0;
                 } else {
                     $id_address = (Tools::isSubmit('id_address') and (int) Tools::getValue('id_address', 0) != $this->context->cart->id_address_invoice) ? (int) Tools::getValue('id_address', 0) : 0;
                 }
             } elseif (Tools::getValue('type') == 'invoice') {
                 if (!$inv_first_on) {
                     $id_address = (Tools::isSubmit('id_address') and (int) Tools::getValue('id_address', 0) != $this->context->cart->id_address_delivery) ? (int) Tools::getValue('id_address', 0) : 0;
                 } else {
                     $id_address = isset($this->context->cart->id_address_invoice) ? (int) $this->context->cart->id_address_invoice : 0;
                 }
             } else {
                 exit;
             }
         } else {
             $id_address = (int) Tools::getValue('id_address', 0);
         }
         if (Tools::getValue('alias') == Tools::getValue('default_alias') && Tools::getValue('address1') && trim(Tools::getValue('address1')) != "") {
             $_POST['alias'] = Tools::substr(preg_replace('/[;#]/', '_', Tools::getValue('address1')), 0, 32);
         }
         $address = new Address();
         $this->errors = $address->validateController();
         if (Tools::getValue('type') == 'invoice' && isset($id_address) && $id_address > 0) {
             $this->context->cart->id_address_invoice = $id_address;
             $this->context->cart->update();
         }
         $address_old = new Address((int) $id_address);
         if (!sizeof($this->errors) && isset($id_address) && (int) $id_address > 0 && Validate::isLoadedObject($address_old) and Customer::customerHasAddress((int) $this->context->cookie->id_customer, (int) $address_old->id)) {
             if ($address_old->isUsed() && $address_old->isDifferent($address)) {
                 $address_1 = new Address();
                 $_POST['alias'] = Tools::substr(preg_replace('/[;#]/', '_', Tools::getValue('address1')), 0, 32);
                 $this->errors = $address_1->validateController();
                 $address_1->id_customer = (int) $this->context->cookie->id_customer;
                 if ((!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) || (!($country = new Country((int) $address_1->id_country)) or !Validate::isLoadedObject($country)) || ($country->isNeedDni() and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) || ((int) $country->contains_states and !(int) $address_1->id_state)) {
                 } elseif ($result = $address_1->save()) {
                     $id_address = $address_1->id;
                     if (Tools::getValue('type') == 'delivery') {
                         if ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice) {
                             $this->context->cart->id_address_invoice = (int) $address_1->id;
                         }
                         $this->context->cart->id_address_delivery = (int) $address_1->id;
                         $this->context->cart->update();
                     }
                     if (Tools::getValue('type') == 'invoice') {
                         if ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice) {
                             $this->context->cart->id_address_delivery = (int) $address_1->id;
                         }
                         $this->context->cart->id_address_invoice = (int) $address_1->id;
                         $this->context->cart->update();
                     }
                 }
             }
         }
         $this->_processSubmitAddress($id_address, Tools::getValue('type'));
     } elseif (Tools::isSubmit('partialSubmitAddress')) {
         // called separately for delivery country/state change and invoice country/state change
         $is_separate_invoice_address = Tools::getValue('invoice_address');
         $is_separate_delivery_address = Tools::getValue('delivery_address');
         $type = Tools::getValue('type');
         $id_country = Tools::getValue('id_country');
         $id_state = Tools::getValue('id_state');
         $postcode = Tools::getValue('postcode');
         $city = Tools::getValue('city');
         $firstname = Tools::getValue('firstname');
         $lastname = Tools::getValue('lastname');
         $addr1 = Tools::getValue('address1');
         $id_address_delivery = 0;
         $id_address_invoice = 0;
         $create_different_delivery_address = 0;
         $create_different_invoice_address = 0;
         $last_addr_id = 0;
         $last_addr_ids_tmp = Customer::getLastTwoCustomerAddressIds($this->context->cart->id_customer);
         if ($id_country !== false && $id_state !== false) {
             if ($type == 'delivery' && isset($this->context->cart->id_address_delivery) && $this->context->cart->id_address_delivery > 0) {
                 $address_old1 = new Address((int) $this->context->cart->id_address_delivery);
                 $address1 = new Address();
                 $errors1 = $address1->validateController();
                 if (Validate::isLoadedObject($address_old1) && $address_old1->isUsed() && $address_old1->isDifferent($address1, true)) {
                     $create_different_delivery_address = 1;
                 }
             }
             if ($is_separate_invoice_address) {
                 if ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice) {
                     $create_different_invoice_address = 1;
                 }
                 if (isset($last_addr_ids_tmp) && $last_addr_ids_tmp != false && is_array($last_addr_ids_tmp) && count($last_addr_ids_tmp) > 0) {
                     foreach ($last_addr_ids_tmp as $item) {
                         if ($item != $this->context->cart->id_address_delivery) {
                             $last_addr_id = $item;
                             break;
                         }
                     }
                 }
             }
             if ($is_separate_delivery_address) {
                 if ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice) {
                     $create_different_delivery_address = 1;
                 }
                 if (isset($last_addr_ids_tmp) && $last_addr_ids_tmp != false && is_array($last_addr_ids_tmp) && count($last_addr_ids_tmp) > 0) {
                     foreach ($last_addr_ids_tmp as $item) {
                         if ($item != $this->context->cart->id_address_invoice) {
                             $last_addr_id = $item;
                             break;
                         }
                     }
                 }
             }
             if ($type == 'delivery') {
                 $id_address_delivery = $last_addr_id > 0 && $create_different_delivery_address ? $last_addr_id : $this->saveAddress($create_different_delivery_address ? $last_addr_id : $this->context->cart->id_address_delivery, $id_country, $id_state, $postcode, $city, $firstname, $lastname, $addr1);
             } else {
                 $id_address_invoice = $last_addr_id > 0 && $create_different_invoice_address ? $last_addr_id : $this->saveAddress($create_different_invoice_address ? $last_addr_id : $this->context->cart->id_address_invoice, $id_country, $id_state, $postcode, $city, $firstname, $lastname, $addr1);
             }
         }
         if ($id_address_delivery > 0) {
             $this->context->cart->id_address_delivery = $id_address_delivery;
             if ($is_separate_invoice_address == 0 && $is_separate_delivery_address == 0) {
                 $this->context->cart->id_address_invoice = $this->context->cart->id_address_delivery;
             }
         } elseif ($id_address_invoice > 0) {
             $this->context->cart->id_address_invoice = $id_address_invoice;
             if ($is_separate_invoice_address == 0 && $is_separate_delivery_address == 0) {
                 $this->context->cart->id_address_delivery = $this->context->cart->id_address_invoice;
             }
         }
         $this->context->cart->update();
         if (Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(dirname(__FILE__) . '/../../modules/vatnumber/vatnumber.php') && VatNumber::isApplicable($id_country) && Configuration::get('VATNUMBER_COUNTRY') != $id_country) {
             $allow_eu_vat = 1;
         } else {
             $allow_eu_vat = 0;
         }
         if (Tools::isSubmit('ajax')) {
             $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'id_address_delivery' => $this->context->cart->id_address_delivery, 'id_address_invoice' => $this->context->cart->id_address_invoice, 'allow_eu_vat' => $allow_eu_vat);
             die(Tools::jsonEncode($return));
         }
     } else {
         # assign pre-guessed address to this customer
         if (Tools::getValue('type') == 'invoice' && (isset($this->context->cart->id_address_invoice) and $this->context->cart->id_address_invoice != $this->context->cart->id_address_delivery) && isset($this->context->cookie->id_customer) and (int) $this->context->cookie->id_customer > 0) {
             $address_a = new Address($this->context->cart->id_address_invoice);
             $address_a->id_customer = (int) $this->context->cookie->id_customer;
             $address_a->save();
         }
         # then call original postProcess to make standard validations and save to DB
         parent::postProcess();
     }
 }
Ejemplo n.º 16
0
 public function postProcess()
 {
     if (!$this->isOpcModuleActive()) {
         return parent::postProcess();
     }
     $inv_first_on = Configuration::get('OPC_INVOICE_FIRST') == "1";
     // handle case when already used address (assigned to an order) is being changed - we need to create new one and save it's reference to order
     if (Tools::isSubmit('submitAddress') && Tools::isSubmit('ajax')) {
         if (Tools::isSubmit('type')) {
             if (Tools::getValue('type') == 'delivery') {
                 if (!$inv_first_on) {
                     $id_address = isset($this->context->cart->id_address_delivery) ? (int) $this->context->cart->id_address_delivery : 0;
                 } else {
                     $id_address = (Tools::isSubmit('id_address') and (int) Tools::getValue('id_address', 0) != $this->context->cart->id_address_invoice) ? (int) Tools::getValue('id_address', 0) : 0;
                 }
             } elseif (Tools::getValue('type') == 'invoice') {
                 //$id_address = (isset($this->context->cart->id_address_invoice) AND $this->context->cart->id_address_invoice != $this->context->cart->id_address_delivery) ? (int)$this->context->cart->id_address_invoice : 0;
                 if (!$inv_first_on) {
                     $id_address = (Tools::isSubmit('id_address') and (int) Tools::getValue('id_address', 0) != $this->context->cart->id_address_delivery) ? (int) Tools::getValue('id_address', 0) : 0;
                 } else {
                     $id_address = isset($this->context->cart->id_address_invoice) ? (int) $this->context->cart->id_address_invoice : 0;
                 }
             } else {
                 exit;
             }
         } else {
             $id_address = (int) Tools::getValue('id_address', 0);
         }
         if (Tools::getValue('alias') == Tools::getValue('default_alias') && Tools::getValue('address1') && trim(Tools::getValue('address1')) != "") {
             $_POST['alias'] = Tools::substr(preg_replace('/[;#]/', '_', Tools::getValue('address1')), 0, 32);
         }
         $address = new Address();
         $this->errors = $address->validateController();
         // AuthController sets (hardocded) invoice address to be same as delivery, because of guest checkout can have
         // only delivery address (in standard OPC)
         if (Tools::getValue('type') == 'invoice' && isset($id_address) && $id_address > 0) {
             $this->context->cart->id_address_invoice = $id_address;
             $this->context->cart->update();
         }
         $address_old = new Address((int) $id_address);
         if (!sizeof($this->errors) && isset($id_address) && (int) $id_address > 0 && Validate::isLoadedObject($address_old) and Customer::customerHasAddress((int) $this->context->cookie->id_customer, (int) $address_old->id)) {
             if ($address_old->isUsed() && $address_old->isDifferent($address)) {
                 // save as new and assing reference to cart
                 $address_1 = new Address();
                 $_POST['alias'] = Tools::substr(preg_replace('/[;#]/', '_', Tools::getValue('address1')), 0, 32);
                 $this->errors = $address_1->validateController();
                 $address_1->id_customer = (int) $this->context->cookie->id_customer;
                 if ((!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) || (!($country = new Country((int) $address_1->id_country)) or !Validate::isLoadedObject($country)) || ($country->isNeedDni() and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) || ((int) $country->contains_states and !(int) $address_1->id_state)) {
                     /* empty */
                 } elseif ($result = $address_1->save()) {
                     $id_address = $address_1->id;
                     if (Tools::getValue('type') == 'delivery') {
                         if ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice) {
                             $this->context->cart->id_address_invoice = (int) $address_1->id;
                         }
                         $this->context->cart->id_address_delivery = (int) $address_1->id;
                         $this->context->cart->update();
                     }
                     if (Tools::getValue('type') == 'invoice') {
                         if ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice) {
                             $this->context->cart->id_address_delivery = (int) $address_1->id;
                         }
                         $this->context->cart->id_address_invoice = (int) $address_1->id;
                         $this->context->cart->update();
                     }
                 }
             }
             //if ($address_old->isUsed)
         }
         //if (Validate::isLoaded...)
         $this->_processSubmitAddress($id_address, Tools::getValue('type'));
         // parent::postProcess(); // call parent's method anyway, we only wanted to store this new address
     } elseif (Tools::isSubmit('partialSubmitAddress')) {
         // called separately for delivery country/state change and invoice country/state change
         // $this->context->cookie->id_cart by mohol byt kluc ku mazaniu adresy pri vytvoreni skutocneho accountu
         // not-null DB fields: id_address, id_country, alias, lastname, firstname, address1, city
         $is_separate_invoice_address = Tools::getValue('invoice_address');
         $is_separate_delivery_address = Tools::getValue('delivery_address');
         // $type is 'delivery' or 'invoice'
         $type = Tools::getValue('type');
         // Delivery address
         $id_country = Tools::getValue('id_country');
         $id_state = Tools::getValue('id_state');
         $postcode = Tools::getValue('postcode');
         $city = Tools::getValue('city');
         $firstname = Tools::getValue('firstname');
         $lastname = Tools::getValue('lastname');
         $addr1 = Tools::getValue('address1');
         $id_address_delivery = 0;
         $id_address_invoice = 0;
         $create_different_delivery_address = 0;
         $create_different_invoice_address = 0;
         $last_addr_id = 0;
         $last_addr_ids_tmp = Customer::getLastTwoCustomerAddressIds($this->context->cart->id_customer);
         if ($id_country !== false && $id_state !== false) {
             /* type is delivery AND cart's address is used and cart's address is different than form post*/
             if ($type == 'delivery' && isset($this->context->cart->id_address_delivery) && $this->context->cart->id_address_delivery > 0) {
                 $address_old1 = new Address((int) $this->context->cart->id_address_delivery);
                 $address1 = new Address();
                 $errors1 = $address1->validateController();
                 if (Validate::isLoadedObject($address_old1) && $address_old1->isUsed() && $address_old1->isDifferent($address1, true)) {
                     $create_different_delivery_address = 1;
                 }
             }
             if ($is_separate_invoice_address) {
                 if ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice) {
                     $create_different_invoice_address = 1;
                 }
                 // check whether we have some recently used addresses (excluded actual delivery address)
                 if (isset($last_addr_ids_tmp) && $last_addr_ids_tmp != false && is_array($last_addr_ids_tmp) && count($last_addr_ids_tmp) > 0) {
                     foreach ($last_addr_ids_tmp as $item) {
                         if ($item != $this->context->cart->id_address_delivery) {
                             $last_addr_id = $item;
                             break;
                         }
                     }
                 }
                 //if (isset($last_addr_ids_tmp)...
             }
             //if  ($is_separate_invoice_address)
             if ($is_separate_delivery_address) {
                 if ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice) {
                     $create_different_delivery_address = 1;
                 }
                 // check whether we have some recently used addresses (excluded actual delivery address)
                 if (isset($last_addr_ids_tmp) && $last_addr_ids_tmp != false && is_array($last_addr_ids_tmp) && count($last_addr_ids_tmp) > 0) {
                     foreach ($last_addr_ids_tmp as $item) {
                         if ($item != $this->context->cart->id_address_invoice) {
                             $last_addr_id = $item;
                             break;
                         }
                     }
                 }
                 //if (isset($last_addr_ids_tmp)...
             }
             //if  ($is_separate_delivery_address)
             if ($type == 'delivery') {
                 $id_address_delivery = $last_addr_id > 0 && $create_different_delivery_address ? $last_addr_id : $this->saveAddress($create_different_delivery_address ? $last_addr_id : $this->context->cart->id_address_delivery, $id_country, $id_state, $postcode, $city, $firstname, $lastname, $addr1);
             } else {
                 $id_address_invoice = $last_addr_id > 0 && $create_different_invoice_address ? $last_addr_id : $this->saveAddress($create_different_invoice_address ? $last_addr_id : $this->context->cart->id_address_invoice, $id_country, $id_state, $postcode, $city, $firstname, $lastname, $addr1);
             }
         }
         if ($id_address_delivery > 0) {
             $this->context->cart->id_address_delivery = $id_address_delivery;
             if ($is_separate_invoice_address == 0 && $is_separate_delivery_address == 0) {
                 $this->context->cart->id_address_invoice = $this->context->cart->id_address_delivery;
             }
         } elseif ($id_address_invoice > 0) {
             $this->context->cart->id_address_invoice = $id_address_invoice;
             if ($is_separate_invoice_address == 0 && $is_separate_delivery_address == 0) {
                 $this->context->cart->id_address_delivery = $this->context->cart->id_address_invoice;
             }
         }
         $this->context->cart->update();
         if (Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(dirname(__FILE__) . '/../../modules/vatnumber/vatnumber.php') && VatNumber::isApplicable($id_country) && Configuration::get('VATNUMBER_COUNTRY') != $id_country) {
             $allow_eu_vat = 1;
         } else {
             $allow_eu_vat = 0;
         }
         if (Tools::isSubmit('ajax')) {
             $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'id_address_delivery' => $this->context->cart->id_address_delivery, 'id_address_invoice' => $this->context->cart->id_address_invoice, 'allow_eu_vat' => $allow_eu_vat);
             die(Tools::jsonEncode($return));
         }
     } else {
         # assign pre-guessed address to this customer
         if (Tools::getValue('type') == 'invoice' && (isset($this->context->cart->id_address_invoice) and $this->context->cart->id_address_invoice != $this->context->cart->id_address_delivery) && isset($this->context->cookie->id_customer) and (int) $this->context->cookie->id_customer > 0) {
             $address_a = new Address($this->context->cart->id_address_invoice);
             $address_a->id_customer = (int) $this->context->cookie->id_customer;
             $address_a->save();
         }
         # then call original postProcess to make standard validations and save to DB
         parent::postProcess();
     }
 }