// merge 1.4 (5397)
This commit is contained in:
@@ -51,6 +51,27 @@ class AddressesControllerCore extends FrontController
|
||||
if (!Validate::isLoadedObject($customer))
|
||||
die(Tools::displayError('Customer not found'));
|
||||
self::$smarty->assign('addresses', $customer->getAddresses((int)(self::$cookie->id_lang)));
|
||||
|
||||
$values = array();
|
||||
$customer_address = $customer->getAddresses((int)(self::$cookie->id_lang));
|
||||
|
||||
foreach($customer_address as $addr_item)
|
||||
$ordered_fields = AddressFormat::getOrderedAddressFields($addr_item['id_country']);
|
||||
|
||||
self::$smarty->assign('addresses_style', array(
|
||||
'company' => 'address_company'
|
||||
,'vat_number' => 'address_company'
|
||||
,'firstname' => 'address_name'
|
||||
,'lastname' => 'address_name'
|
||||
,'address1' => 'address_address1'
|
||||
,'address2' => 'address_address2'
|
||||
,'city' => 'address_city'
|
||||
,'country' => 'address_country'
|
||||
,'phone' => 'address_phone'
|
||||
,'phone_mobile' => 'address_phone_mobile'
|
||||
,'alias' => 'address_title'
|
||||
));
|
||||
self::$smarty->assign('ordered_fields', $ordered_fields);
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -31,17 +31,17 @@ class AuthControllerCore extends FrontController
|
||||
{
|
||||
$this->ssl = true;
|
||||
$this->php_self = 'authentication.php';
|
||||
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@@ -54,7 +54,7 @@ class AuthControllerCore extends FrontController
|
||||
$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.');
|
||||
$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']);
|
||||
}
|
||||
@@ -63,6 +63,7 @@ class AuthControllerCore extends FrontController
|
||||
$create_account = 1;
|
||||
self::$smarty->assign('email_create', Tools::safeOutput($email));
|
||||
$_POST['email'] = $email;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +71,7 @@ class AuthControllerCore extends FrontController
|
||||
{
|
||||
$create_account = 1;
|
||||
if (Tools::isSubmit('submitAccount'))
|
||||
self::$smarty->assign('email_create', 1);
|
||||
self::$smarty->assign('email_create', 1);
|
||||
/* New Guest customer */
|
||||
if (!Tools::getValue('is_new_customer') AND !Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))
|
||||
$this->errors[] = Tools::displayError('You cannot create a guest account.');
|
||||
@@ -190,7 +191,7 @@ class AuthControllerCore extends FrontController
|
||||
if (Tools::isSubmit('ajax'))
|
||||
{
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'isSaved' => true,
|
||||
'id_customer' => (int)self::$cookie->id_customer,
|
||||
@@ -215,7 +216,7 @@ class AuthControllerCore extends FrontController
|
||||
if (Tools::isSubmit('ajax'))
|
||||
{
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'isSaved' => false,
|
||||
'id_customer' => 0
|
||||
@@ -224,7 +225,7 @@ class AuthControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Tools::isSubmit('SubmitLogin'))
|
||||
{
|
||||
Module::hookExec('beforeAuthentication');
|
||||
@@ -262,6 +263,7 @@ class AuthControllerCore extends FrontController
|
||||
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));
|
||||
self::$cart->update();
|
||||
@@ -277,7 +279,7 @@ class AuthControllerCore extends FrontController
|
||||
if (Tools::isSubmit('ajax'))
|
||||
{
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'token' => Tools::getToken(false)
|
||||
);
|
||||
@@ -290,10 +292,10 @@ class AuthControllerCore extends FrontController
|
||||
/* 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,
|
||||
/* 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
|
||||
* @see : bug #6968
|
||||
* @link:http://www.prestashop.com/bug_tracker/view/6968/
|
||||
elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
|
||||
{
|
||||
@@ -321,7 +323,7 @@ class AuthControllerCore extends FrontController
|
||||
'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']);
|
||||
@@ -333,7 +335,7 @@ class AuthControllerCore extends FrontController
|
||||
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),
|
||||
@@ -344,18 +346,18 @@ class AuthControllerCore extends FrontController
|
||||
));
|
||||
self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
|
||||
}
|
||||
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'authentication.css');
|
||||
Tools::addJS(array(_THEME_JS_DIR_.'tools/statesManagement.js', _PS_JS_DIR_.'jquery/jquery-typewatch.pack.js'));
|
||||
}
|
||||
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
|
||||
$back = Tools::getValue('back');
|
||||
$key = Tools::safeOutput(Tools::getValue('key'));
|
||||
if (!empty($key))
|
||||
@@ -367,7 +369,7 @@ class AuthControllerCore extends FrontController
|
||||
{
|
||||
$countries = Country::getCountries((int)(self::$cookie->id_lang), true);
|
||||
self::$smarty->assign(array(
|
||||
'inOrderProcess' => true,
|
||||
'inOrderProcess' => true,
|
||||
'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'),
|
||||
'sl_country' => (int)Tools::getValue('id_country', Configuration::get('PS_COUNTRY_DEFAULT')),
|
||||
'countries' => $countries
|
||||
@@ -375,12 +377,35 @@ class AuthControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
$this->processAddressFormat();
|
||||
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'authentication.tpl');
|
||||
}
|
||||
|
||||
protected function processAddressFormat()
|
||||
{
|
||||
$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
$inv_adr_fields = AddressFormat::getOrderedAddressFields($selectedCountry);
|
||||
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($selectedCountry);
|
||||
|
||||
$inv_all_fields = array();
|
||||
$dlv_all_fields = array();
|
||||
|
||||
|
||||
foreach (array('inv','dlv') as $adr_type)
|
||||
{
|
||||
foreach (${$adr_type.'_adr_fields'} as $fields_line)
|
||||
foreach(explode(' ',$fields_line) as $field_item)
|
||||
${$adr_type.'_all_fields'}[] = trim($field_item);
|
||||
|
||||
self::$smarty->assign($adr_type.'_adr_fields', ${$adr_type.'_adr_fields'});
|
||||
self::$smarty->assign($adr_type.'_all_fields', ${$adr_type.'_all_fields'});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ class GuestTrackingControllerCore extends FrontController
|
||||
$products = $order->getProducts();
|
||||
$customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart));
|
||||
Product::addCustomizationPrice($products, $customizedDatas);
|
||||
|
||||
|
||||
$this->processAddressFormat($addressDelivery, $addressInvoice);
|
||||
self::$smarty->assign(array(
|
||||
'shop_name' => Configuration::get('PS_SHOP_NAME'),
|
||||
'order' => $order,
|
||||
@@ -124,4 +125,15 @@ class GuestTrackingControllerCore extends FrontController
|
||||
|
||||
self::$smarty->display(_PS_THEME_DIR_.'guest-tracking.tpl');
|
||||
}
|
||||
|
||||
private function processAddressFormat(Address $delivery, Address $invoice)
|
||||
{
|
||||
|
||||
$inv_adr_fields = AddressFormat::getOrderedAddressFields($invoice->id_country);
|
||||
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($delivery->id_country);
|
||||
|
||||
self::$smarty->assign('inv_adr_fields', $inv_adr_fields);
|
||||
self::$smarty->assign('dlv_adr_fields', $dlv_adr_fields);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,19 @@ class OrderControllerCore extends ParentOrderController
|
||||
}
|
||||
}
|
||||
|
||||
private function processAddressFormat()
|
||||
{
|
||||
$delivery = new Address((int)(self::$cart->id_address_delivery));
|
||||
$invoice = new Address((int)(self::$cart->id_address_invoice));
|
||||
|
||||
$inv_adr_fields = AddressFormat::getOrderedAddressFields($invoice->id_country);
|
||||
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($delivery->id_country);
|
||||
|
||||
self::$smarty->assign('inv_adr_fields', $inv_adr_fields);
|
||||
self::$smarty->assign('dlv_adr_fields', $dlv_adr_fields);
|
||||
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
@@ -132,6 +145,7 @@ class OrderControllerCore extends ParentOrderController
|
||||
self::$smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl');
|
||||
break;
|
||||
case 1:
|
||||
$this->processAddressFormat();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'order-address.tpl');
|
||||
break;
|
||||
case 2:
|
||||
@@ -161,6 +175,7 @@ class OrderControllerCore extends ParentOrderController
|
||||
Tools::redirect('order.php?step=1');
|
||||
$delivery = new Address((int)(self::$cart->id_address_delivery));
|
||||
$invoice = new Address((int)(self::$cart->id_address_invoice));
|
||||
|
||||
if ($delivery->deleted OR $invoice->deleted)
|
||||
{
|
||||
if ($delivery->deleted)
|
||||
|
||||
@@ -104,6 +104,11 @@ class OrderDetailControllerCore extends FrontController
|
||||
$carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang));
|
||||
$addressInvoice = new Address((int)($order->id_address_invoice));
|
||||
$addressDelivery = new Address((int)($order->id_address_delivery));
|
||||
|
||||
$inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
|
||||
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
|
||||
|
||||
|
||||
if ($order->total_discounts > 0)
|
||||
self::$smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts));
|
||||
$products = $order->getProducts();
|
||||
@@ -128,6 +133,8 @@ class OrderDetailControllerCore extends FrontController
|
||||
'address_invoice' => $addressInvoice,
|
||||
'invoiceState' => (Validate::isLoadedObject($addressInvoice) AND $addressInvoice->id_state) ? new State((int)($addressInvoice->id_state)) : false,
|
||||
'address_delivery' => $addressDelivery,
|
||||
'inv_adr_fields' => $inv_adr_fields,
|
||||
'dlv_adr_fields' => $dlv_adr_fields,
|
||||
'deliveryState' => (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state) ? new State((int)($addressDelivery->id_state)) : false,
|
||||
'is_guest' => false,
|
||||
'messages' => Message::getMessagesByOrderId((int)($order->id)),
|
||||
|
||||
@@ -120,6 +120,7 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
$blockUserInfo = new BlockUserInfo();
|
||||
}
|
||||
self::$smarty->assign('isVirtualCart', self::$cart->isVirtualCart());
|
||||
$this->processAddressFormat();
|
||||
$this->_assignAddress();
|
||||
// Wrapping fees
|
||||
$wrapping_fees = (float)(Configuration::get('PS_GIFT_WRAPPING_PRICE'));
|
||||
@@ -265,7 +266,9 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
|
||||
|
||||
$this->processAddressFormat();
|
||||
|
||||
self::$smarty->display(_PS_THEME_DIR_.'errors.tpl');
|
||||
self::$smarty->display(_PS_THEME_DIR_.'order-opc.tpl');
|
||||
}
|
||||
@@ -446,6 +449,30 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
return self::$cart->id_carrier;
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function processAddressFormat()
|
||||
{
|
||||
$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
$inv_adr_fields = AddressFormat::getOrderedAddressFields($selectedCountry);
|
||||
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($selectedCountry);
|
||||
|
||||
$inv_all_fields = array();
|
||||
$dlv_all_fields = array();
|
||||
|
||||
foreach (array('inv','dlv') as $adr_type)
|
||||
{
|
||||
foreach (${$adr_type.'_adr_fields'} as $fields_line)
|
||||
foreach(explode(' ',$fields_line) as $field_item)
|
||||
${$adr_type.'_all_fields'}[] = trim($field_item);
|
||||
|
||||
// DEBUG echo('<br />processAddressFormat: inv_all_fields: ' . var_export($inv_all_fields, true)
|
||||
// DEBUG .'<br />processAddressFormat: inv_all_fields: ' . var_export($dlv_all_fields, true));
|
||||
|
||||
self::$smarty->assign($adr_type.'_adr_fields', ${$adr_type.'_adr_fields'});
|
||||
self::$smarty->assign($adr_type.'_all_fields', ${$adr_type.'_all_fields'});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ class SearchControllerCore extends FrontController
|
||||
parent::setMedia();
|
||||
|
||||
if (!$this->instantSearch AND !$this->ajaxSearch)
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'product-list.css');
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class StoresControllerCore extends FrontController
|
||||
|
||||
$stores = Db::getInstance()->ExecuteS('
|
||||
SELECT s.*, cl.name country, st.iso_code state,
|
||||
('.(int)($multiplicator).' * acos(cos(radians('.(float)(Tools::getValue('latitude')).')) * cos(radians(latitude)) * cos(radians(longitude) - radians('.(float)(Tools::getValue('longitude')).')) + sin(radians('.(float)(Tools::getValue('latitude')).')) * sin(radians(latitude)))) distance
|
||||
('.(int)($multiplicator).' * acos(cos(radians('.(float)(Tools::getValue('latitude')).')) * cos(radians(latitude)) * cos(radians(longitude) - radians('.(float)(Tools::getValue('longitude')).')) + sin(radians('.(float)(Tools::getValue('latitude')).')) * sin(radians(latitude)))) distance, cl.id_country id_country
|
||||
FROM '._DB_PREFIX_.'store s
|
||||
LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
|
||||
LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
|
||||
@@ -103,7 +103,8 @@ class StoresControllerCore extends FrontController
|
||||
$node = $dom->createElement('marker');
|
||||
$newnode = $parnode->appendChild($node);
|
||||
$newnode->setAttribute('name', $store['name']);
|
||||
$address = $store['address1'].(!empty($store['address2']) ? '<br />'.$store['address2'] : '').'<br />'.$store['postcode'].' '.$store['city'].', '.$store['state'].'<br />'.$store['country'];
|
||||
$address = $this->_processStoreAddress($store);
|
||||
|
||||
$other = '';
|
||||
if (!empty($store['hours']))
|
||||
{
|
||||
@@ -117,6 +118,8 @@ class StoresControllerCore extends FrontController
|
||||
$days_datas[] = $hours_datas;
|
||||
}
|
||||
$smarty->assign('days_datas', $days_datas);
|
||||
$smarty->assign('id_country', $store['id_country']);
|
||||
|
||||
$other .= self::$smarty->fetch(_PS_THEME_DIR_.'store_infos.tpl');
|
||||
}
|
||||
|
||||
@@ -143,6 +146,42 @@ class StoresControllerCore extends FrontController
|
||||
$smarty->assign(array('distance_unit' => $distanceUnit, 'simplifiedStoresDiplay' => $simplifiedStoreLocator, 'stores' => $stores, 'mediumSize' => Image::getSize('medium')));
|
||||
}
|
||||
|
||||
private function _processStoreAddress($store)
|
||||
{
|
||||
$ignore_field = array(
|
||||
'firstname' =>1
|
||||
, 'lastname' =>1
|
||||
);
|
||||
|
||||
$out = '';
|
||||
$out_datas = array();
|
||||
|
||||
$address_datas = AddressFormat::getOrderedAddressFields($store['id_country']);
|
||||
|
||||
foreach ($address_datas as $data_line)
|
||||
{
|
||||
$data_fields = explode(' ', $data_line);
|
||||
$adr_out = array();
|
||||
|
||||
$data_fields_mod = false;
|
||||
foreach ($data_fields as $field_item)
|
||||
{
|
||||
$field_item = trim($field_item);
|
||||
if (!isset($ignore_field[$field_item]) && !empty($store[$field_item]) && $store[$field_item] != '')
|
||||
{
|
||||
$adr_out[] = $store[$field_item];
|
||||
$data_fields_mod = true;
|
||||
}
|
||||
}
|
||||
if ($data_fields_mod)
|
||||
$out_datas[] = implode(' ', $adr_out);
|
||||
}
|
||||
|
||||
$out = implode('<br />', $out_datas);
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
Reference in New Issue
Block a user