This commit is contained in:
@@ -1,280 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
if(Configuration::get('VATNUMBER_MANAGEMENT') AND file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php'))
|
||||
include_once(_PS_MODULE_DIR_.'vatnumber/vatnumber.php');
|
||||
|
||||
class AddressControllerCore extends FrontController
|
||||
{
|
||||
protected $_address;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = true;
|
||||
$this->guestAllowed = true;
|
||||
$this->php_self = 'address.php';
|
||||
$this->authRedirection = 'addresses.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
if ($back = Tools::getValue('back'))
|
||||
self::$smarty->assign('back', Tools::safeOutput($back));
|
||||
if ($mod = Tools::getValue('mod'))
|
||||
self::$smarty->assign('mod', Tools::safeOutput($mod));
|
||||
|
||||
if (Tools::isSubmit('ajax') AND Tools::isSubmit('type'))
|
||||
{
|
||||
if (Tools::getValue('type') == 'delivery')
|
||||
$id_address = isset(self::$cart->id_address_delivery) ? (int)self::$cart->id_address_delivery : 0;
|
||||
elseif (Tools::getValue('type') == 'invoice')
|
||||
$id_address = (isset(self::$cart->id_address_invoice) AND self::$cart->id_address_invoice != self::$cart->id_address_delivery) ? (int)self::$cart->id_address_invoice : 0;
|
||||
else
|
||||
exit;
|
||||
}
|
||||
else
|
||||
$id_address = (int)Tools::getValue('id_address', 0);
|
||||
|
||||
if ($id_address)
|
||||
{
|
||||
$this->_address = new Address((int)$id_address);
|
||||
if (Validate::isLoadedObject($this->_address) AND Customer::customerHasAddress((int)(self::$cookie->id_customer), (int)($id_address)))
|
||||
{
|
||||
if (Tools::isSubmit('delete'))
|
||||
{
|
||||
if (self::$cart->id_address_invoice == $this->_address->id)
|
||||
unset(self::$cart->id_address_invoice);
|
||||
if (self::$cart->id_address_delivery == $this->_address->id)
|
||||
unset(self::$cart->id_address_delivery);
|
||||
if ($this->_address->delete())
|
||||
Tools::redirect('index.php?controller=addresses');
|
||||
$this->errors[] = Tools::displayError('This address cannot be deleted.');
|
||||
}
|
||||
self::$smarty->assign(array('address' => $this->_address, 'id_address' => (int)$id_address));
|
||||
}
|
||||
elseif (Tools::isSubmit('ajax'))
|
||||
exit;
|
||||
else
|
||||
Tools::redirect('index.php?controller=addresses');
|
||||
}
|
||||
if (Tools::isSubmit('submitAddress'))
|
||||
{
|
||||
$address = new Address();
|
||||
$this->errors = $address->validateControler();
|
||||
$address->id_customer = (int)(self::$cookie->id_customer);
|
||||
|
||||
if (!Tools::getValue('phone') AND !Tools::getValue('phone_mobile'))
|
||||
$this->errors[] = Tools::displayError('You must register at least one phone number');
|
||||
if (!$country = new Country((int)$address->id_country) OR !Validate::isLoadedObject($country))
|
||||
die(Tools::displayError());
|
||||
|
||||
/* 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->zip_code_format;
|
||||
if ($country->need_zip_code)
|
||||
{
|
||||
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->iso_code, $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->iso_code, 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.').'<br />'.Tools::displayError('Must be typed as follows:').' '.str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
|
||||
}
|
||||
if ($country->isNeedDni() AND !Tools::getValue('dni') AND !Validate::isDniLite(Tools::getValue('dni')))
|
||||
$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
|
||||
elseif (!$country->isNeedDni())
|
||||
$address->dni = NULL;
|
||||
if (Configuration::get('PS_TOKEN_ENABLE') == 1 AND
|
||||
strcmp(Tools::getToken(false), Tools::getValue('token')) AND
|
||||
self::$cookie->isLogged(true) === true)
|
||||
$this->errors[] = Tools::displayError('Invalid token');
|
||||
|
||||
if ((int)($country->contains_states) AND !(int)($address->id_state))
|
||||
$this->errors[] = Tools::displayError('This country requires a state selection.');
|
||||
|
||||
if (!sizeof($this->errors))
|
||||
{
|
||||
if (isset($id_address))
|
||||
{
|
||||
$country = new Country((int)($address->id_country));
|
||||
if (Validate::isLoadedObject($country) AND !$country->contains_states)
|
||||
$address->id_state = 0;
|
||||
$address_old = new Address((int)$id_address);
|
||||
if (Validate::isLoadedObject($address_old) AND Customer::customerHasAddress((int)self::$cookie->id_customer, (int)$address_old->id))
|
||||
{
|
||||
if (!Tools::isSubmit('ajax'))
|
||||
{
|
||||
if (self::$cart->id_address_invoice == $address_old->id)
|
||||
unset(self::$cart->id_address_invoice);
|
||||
if (self::$cart->id_address_delivery == $address_old->id)
|
||||
unset(self::$cart->id_address_delivery);
|
||||
}
|
||||
|
||||
if ($address_old->isUsed())
|
||||
$address_old->delete();
|
||||
else
|
||||
{
|
||||
$address->id = (int)($address_old->id);
|
||||
$address->date_add = $address_old->date_add;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (self::$cookie->is_guest)
|
||||
Tools::redirect('index.php?controller=addresses');
|
||||
|
||||
if ($result = $address->save())
|
||||
{
|
||||
if ((bool)(Tools::getValue('select_address', false)) == true OR (Tools::isSubmit('ajax') AND Tools::getValue('type') == 'invoice'))
|
||||
{
|
||||
/* This new adress is for invoice_adress, select it */
|
||||
self::$cart->id_address_invoice = (int)($address->id);
|
||||
self::$cart->update();
|
||||
}
|
||||
if (Tools::isSubmit('ajax'))
|
||||
{
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'id_address_delivery' => self::$cart->id_address_delivery,
|
||||
'id_address_invoice' => self::$cart->id_address_invoice
|
||||
);
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
Tools::redirect($back ? ($mod ? $back.'&back='.$mod : $back) : 'addresses.php');
|
||||
}
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating your address.');
|
||||
}
|
||||
}
|
||||
elseif (!$id_address)
|
||||
{
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
if (Validate::isLoadedObject($customer))
|
||||
{
|
||||
$_POST['firstname'] = $customer->firstname;
|
||||
$_POST['lastname'] = $customer->lastname;
|
||||
}
|
||||
}
|
||||
if (Tools::isSubmit('ajax') AND sizeof($this->errors))
|
||||
{
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors
|
||||
);
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addJS(_THEME_JS_DIR_.'tools/statesManagement.js');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
/* Secure restriction for guest */
|
||||
if (self::$cookie->is_guest)
|
||||
Tools::redirect('index.php?controller=addresses');
|
||||
|
||||
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'))
|
||||
));
|
||||
}
|
||||
|
||||
public function displayHeader()
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayHeader();
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
|
||||
$this->_processAddressFormat();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'address.tpl');
|
||||
}
|
||||
|
||||
public function displayFooter()
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayFooter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AddressesControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = true;
|
||||
$this->php_self = 'addresses.php';
|
||||
$this->authRedirection = 'addresses.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
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()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'addresses.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,411 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AuthControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$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('index.php?controller=my-account');
|
||||
|
||||
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') AND !Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))
|
||||
$this->errors[] = Tools::displayError('You cannot create a guest account.');
|
||||
if (!Tools::getValue('is_new_customer'))
|
||||
$_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');
|
||||
$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') AND !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 (!@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');
|
||||
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'));
|
||||
}
|
||||
|
||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)($_POST['years']).'-'.(int)($_POST['months']).'-'.(int)($_POST['days']));
|
||||
|
||||
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('index.php?controller=my-account');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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_customer = (int)($customer->id);
|
||||
self::$cookie->customer_lastname = $customer->lastname;
|
||||
self::$cookie->customer_firstname = $customer->firstname;
|
||||
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));
|
||||
self::$cart->update();
|
||||
Module::hookExec('authentication');
|
||||
if (!Tools::isSubmit('ajax'))
|
||||
{
|
||||
if ($back = Tools::getValue('back'))
|
||||
Tools::redirect($back);
|
||||
Tools::redirect('index.php?controller=my-account');
|
||||
}
|
||||
}
|
||||
}
|
||||
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'));
|
||||
$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);
|
||||
}
|
||||
|
||||
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))
|
||||
$back .= (strpos($back, '?') !== false ? '&' : '?').'key='.$key;
|
||||
if (!empty($back))
|
||||
{
|
||||
self::$smarty->assign('back', Tools::safeOutput($back));
|
||||
if (strpos($back, 'order.php') !== false)
|
||||
{
|
||||
$countries = Country::getCountries((int)(self::$cookie->id_lang), true);
|
||||
self::$smarty->assign(array(
|
||||
'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
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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'});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class BestSalesControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->php_self = 'best-sales.php';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
$this->productSort();
|
||||
$nbProducts = (int)(ProductSale::getNbSales());
|
||||
$this->pagination($nbProducts);
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'products' => ProductSale::getBestSales((int)(self::$cookie->id_lang), (int)($this->p) - 1, (int)($this->n), $this->orderBy, $this->orderWay),
|
||||
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
||||
'nbProducts' => $nbProducts,
|
||||
'homeSize' => Image::getSize('home')
|
||||
));
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'best-sales.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class CmsControllerCore extends FrontController
|
||||
{
|
||||
public $assignCase;
|
||||
public $cms;
|
||||
public $cms_category;
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
if ($id_cms = (int)Tools::getValue('id_cms'))
|
||||
$this->cms = new CMS($id_cms, self::$cookie->id_lang);
|
||||
elseif ($id_cms_category = (int)Tools::getValue('id_cms_category'))
|
||||
$this->cms_category = new CMSCategory($id_cms_category, self::$cookie->id_lang);
|
||||
|
||||
// Automatically redirect to the canonical URL if the current in is the right one
|
||||
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
|
||||
if ($this->cms AND $canonicalURL = self::$link->getCMSLink($this->cms))
|
||||
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
|
||||
{
|
||||
header('HTTP/1.0 301 Moved');
|
||||
if (defined(_PS_MODE_DEV_) AND _PS_MODE_DEV_ )
|
||||
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');
|
||||
Tools::redirectLink($canonicalURL);
|
||||
}
|
||||
if ($this->cms_category AND $canonicalURL = self::$link->getCMSCategoryLink($this->cms_category))
|
||||
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
|
||||
{
|
||||
header('HTTP/1.0 301 Moved');
|
||||
if (_PS_MODE_DEV_ )
|
||||
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');
|
||||
Tools::redirectLink($canonicalURL);
|
||||
}
|
||||
|
||||
parent::preProcess();
|
||||
|
||||
/* assignCase (1 = CMS page, 2 = CMS category) */
|
||||
if (Validate::isLoadedObject($this->cms) AND ($this->cms->active OR (Tools::getValue('adtoken') == Tools::encrypt('PreviewCMS'.$this->cms->id) AND file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad').'/ajax.php'))))
|
||||
$this->assignCase = 1;
|
||||
elseif (Validate::isLoadedObject($this->cms_category))
|
||||
$this->assignCase = 2;
|
||||
else
|
||||
Tools::redirect('index.php?controller=404');
|
||||
|
||||
if((int)(Configuration::get('PS_REWRITING_SETTINGS')))
|
||||
{
|
||||
$rewrite_infos = (isset($id_cms) AND !isset($id_cms_category)) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
|
||||
$default_rewrite = array();
|
||||
foreach ($rewrite_infos AS $infos)
|
||||
{
|
||||
$arr_link = (isset($id_cms) AND !isset($id_cms_category)) ?
|
||||
self::$link->getCMSLink($id_cms, $infos['link_rewrite'], $this->ssl, $infos['id_lang']) :
|
||||
self::$link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
|
||||
$default_rewrite[$infos['id_lang']] = $arr_link;
|
||||
}
|
||||
self::$smarty->assign('lang_rewrite_urls', $default_rewrite);
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
|
||||
if ($this->assignCase == 1)
|
||||
Tools::addJS(_THEME_JS_DIR_.'cms.js');
|
||||
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'cms.css');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
$parent_cat = new CMSCategory(1, (int)(self::$cookie->id_lang));
|
||||
self::$smarty->assign('id_current_lang', self::$cookie->id_lang);
|
||||
self::$smarty->assign('home_title', $parent_cat->name);
|
||||
self::$smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
|
||||
if ($this->assignCase == 1)
|
||||
{
|
||||
self::$smarty->assign(array(
|
||||
'cms' => $this->cms,
|
||||
'content_only' => (int)(Tools::getValue('content_only')),
|
||||
'path' => ((isset($this->cms->id_cms_category) AND $this->cms->id_cms_category) ? Tools::getFullPath((int)($this->cms->id_cms_category), $this->cms->meta_title, 'CMS') : Tools::getFullPath(1, $this->cms->meta_title, 'CMS'))
|
||||
));
|
||||
}
|
||||
elseif ($this->assignCase == 2)
|
||||
{
|
||||
self::$smarty->assign(array(
|
||||
'category' => $this->cms_category,
|
||||
'sub_category' => $this->cms_category->getSubCategories((int)(self::$cookie->id_lang)),
|
||||
'cms_pages' => CMS::getCMSPages((int)(self::$cookie->id_lang), (int)($this->cms_category->id) ),
|
||||
'path' => ($this->cms_category->id !== 1) ? Tools::getPath((int)($this->cms_category->id), $this->cms_category->name, false, 'CMS') : '',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'cms.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,242 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class CartControllerCore extends FrontController
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$this->init();
|
||||
$this->preProcess();
|
||||
|
||||
if (Tools::getValue('ajax') == 'true')
|
||||
{
|
||||
if (Tools::getIsset('summary'))
|
||||
{
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
|
||||
{
|
||||
if (self::$cookie->id_customer)
|
||||
{
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
$groups = $customer->getGroups();
|
||||
}
|
||||
else
|
||||
$groups = array(1);
|
||||
if ((int)self::$cart->id_address_delivery)
|
||||
$deliveryAddress = new Address((int)self::$cart->id_address_delivery);
|
||||
$result = array('carriers' => Carrier::getCarriersForOrder((int)Country::getIdZone((isset($deliveryAddress) AND (int)$deliveryAddress->id) ? (int)$deliveryAddress->id_country : (int)Configuration::get('PS_COUNTRY_DEFAULT')), $groups));
|
||||
}
|
||||
$result['summary'] = self::$cart->getSummaryDetails();
|
||||
$result['customizedDatas'] = Product::getAllCustomizedDatas((int)(self::$cart->id));
|
||||
$result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']);
|
||||
$result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']);
|
||||
die(Tools::jsonEncode($result));
|
||||
}
|
||||
else
|
||||
$this->includeCartModule();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setMedia();
|
||||
$this->displayHeader();
|
||||
$this->process();
|
||||
$this->displayContent();
|
||||
$this->displayFooter();
|
||||
}
|
||||
}
|
||||
|
||||
public function includeCartModule()
|
||||
{
|
||||
require_once(_PS_MODULE_DIR_.'/blockcart/blockcart-ajax.php');
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
$orderTotal = self::$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
|
||||
|
||||
$this->cartDiscounts = self::$cart->getDiscounts();
|
||||
foreach ($this->cartDiscounts AS $k => $this->cartDiscount)
|
||||
if ($error = self::$cart->checkDiscountValidity(new Discount((int)($this->cartDiscount['id_discount'])), $this->cartDiscounts, $orderTotal, self::$cart->getProducts()))
|
||||
self::$cart->deleteDiscount((int)($this->cartDiscount['id_discount']));
|
||||
|
||||
$add = Tools::getIsset('add') ? 1 : 0;
|
||||
$delete = Tools::getIsset('delete') ? 1 : 0;
|
||||
|
||||
if (Configuration::get('PS_TOKEN_ENABLE') == 1 &&
|
||||
strcasecmp(Tools::getToken(false), strval(Tools::getValue('token'))) &&
|
||||
self::$cookie->isLogged() === true)
|
||||
$this->errors[] = Tools::displayError('Invalid token');
|
||||
|
||||
// Update the cart ONLY if $this->cookies are available, in order to avoid ghost carts created by bots
|
||||
if (($add OR Tools::getIsset('update') OR $delete) AND isset(self::$cookie->date_add))
|
||||
{
|
||||
//get the values
|
||||
$idProduct = (int)(Tools::getValue('id_product', NULL));
|
||||
$idProductAttribute = (int)(Tools::getValue('id_product_attribute', Tools::getValue('ipa')));
|
||||
$customizationId = (int)(Tools::getValue('id_customization', 0));
|
||||
$qty = (int)(abs(Tools::getValue('qty', 1)));
|
||||
if ($qty == 0)
|
||||
$this->errors[] = Tools::displayError('Null quantity');
|
||||
elseif (!$idProduct)
|
||||
$this->errors[] = Tools::displayError('Product not found');
|
||||
else
|
||||
{
|
||||
$producToAdd = new Product((int)($idProduct), true, (int)(self::$cookie->id_lang));
|
||||
if ((!$producToAdd->id OR !$producToAdd->active) AND !$delete)
|
||||
if (Tools::getValue('ajax') == 'true')
|
||||
die('{"hasError" : true, "errors" : ["'.Tools::displayError('Pproduct is no longer available.', false).'"]}');
|
||||
else
|
||||
$this->errors[] = Tools::displayError('Pproduct is no longer available.', false);
|
||||
else
|
||||
{
|
||||
/* Check the quantity availability */
|
||||
if ($idProductAttribute AND is_numeric($idProductAttribute))
|
||||
{
|
||||
if (!$delete AND !$producToAdd->isAvailableWhenOutOfStock($producToAdd->out_of_stock) AND !Attribute::checkAttributeQty((int)$idProductAttribute, (int)$qty))
|
||||
if (Tools::getValue('ajax') == 'true')
|
||||
die('{"hasError" : true, "errors" : ["'.Tools::displayError('There is not enough product in stock.', false).'"]}');
|
||||
else
|
||||
$this->errors[] = Tools::displayError('There is not enough product in stock.');
|
||||
}
|
||||
elseif ($producToAdd->hasAttributes() AND !$delete)
|
||||
{
|
||||
$idProductAttribute = Product::getDefaultAttribute((int)$producToAdd->id, (int)$producToAdd->out_of_stock == 2 ? !(int)Configuration::get('PS_ORDER_OUT_OF_STOCK') : !(int)$producToAdd->out_of_stock);
|
||||
if (!$idProductAttribute)
|
||||
Tools::redirectAdmin($link->getProductLink($producToAdd));
|
||||
elseif (!$delete AND !$producToAdd->isAvailableWhenOutOfStock($producToAdd->out_of_stock) AND !Attribute::checkAttributeQty((int)$idProductAttribute, (int)$qty))
|
||||
if (Tools::getValue('ajax') == 'true')
|
||||
die('{"hasError" : true, "errors" : ["'.Tools::displayError('There is not enough product in stock.', false).'"]}');
|
||||
else
|
||||
$this->errors[] = Tools::displayError('There is not enough product in stock.');
|
||||
}
|
||||
elseif (!$delete AND !$producToAdd->checkQty((int)$qty))
|
||||
if (Tools::getValue('ajax') == 'true')
|
||||
die('{"hasError" : true, "errors" : ["'.Tools::displayError('There is not enough product in stock.').'"]}');
|
||||
else
|
||||
$this->errors[] = Tools::displayError('There is not enough product in stock.');
|
||||
/* Check vouchers compatibility */
|
||||
if ($add AND (($producToAdd->specificPrice AND (float)($producToAdd->specificPrice['reduction'])) OR $producToAdd->on_sale))
|
||||
{
|
||||
$discounts = self::$cart->getDiscounts();
|
||||
foreach($discounts as $discount)
|
||||
if (!$discount['cumulable_reduction'])
|
||||
$this->errors[] = Tools::displayError('Cannot add this product because current voucher does not allow additional discounts.');
|
||||
}
|
||||
if (!sizeof($this->errors))
|
||||
{
|
||||
if ($add AND $qty >= 0)
|
||||
{
|
||||
/* Product addition to the cart */
|
||||
if (!isset(self::$cart->id) OR !self::$cart->id)
|
||||
{
|
||||
self::$cart->add();
|
||||
if (self::$cart->id)
|
||||
self::$cookie->id_cart = (int)(self::$cart->id);
|
||||
}
|
||||
if ($add AND !$producToAdd->hasAllRequiredCustomizableFields() AND !$customizationId)
|
||||
$this->errors[] = Tools::displayError('Please fill in all required fields, then save the customization.');
|
||||
if (!sizeof($this->errors))
|
||||
{
|
||||
$updateQuantity = self::$cart->updateQty((int)($qty), (int)($idProduct), (int)($idProductAttribute), $customizationId, Tools::getValue('op', 'up'));
|
||||
|
||||
if ($updateQuantity < 0)
|
||||
{
|
||||
/* if product has attribute, minimal quantity is set with minimal quantity of attribute*/
|
||||
if ((int)$idProductAttribute)
|
||||
$minimal_quantity = Attribute::getAttributeMinimalQty((int)$idProductAttribute);
|
||||
else
|
||||
$minimal_quantity = $producToAdd->minimal_quantity;
|
||||
if (Tools::getValue('ajax') == 'true')
|
||||
die('{"hasError" : true, "errors" : ["'.Tools::displayError('You must add', false).' '.$minimal_quantity.' '.Tools::displayError('Minimum quantity', false).'"]}');
|
||||
else
|
||||
$this->errors[] = Tools::displayError('You must add').' '.$minimal_quantity.' '.Tools::displayError('Minimum quantity')
|
||||
.((isset($_SERVER['HTTP_REFERER']) AND basename($_SERVER['HTTP_REFERER']) == 'order.php' OR (!Tools::isSubmit('ajax') AND substr(basename($_SERVER['REQUEST_URI']),0, strlen('cart.php')) == 'cart.php')) ? ('<script language="javascript">setTimeout("history.back()",5000);</script><br />- '.
|
||||
Tools::displayError('You will be redirected to your cart in a few seconds.')) : '');
|
||||
}
|
||||
elseif (!$updateQuantity)
|
||||
{
|
||||
if (Tools::getValue('ajax') == 'true')
|
||||
die('{"hasError" : true, "errors" : ["'.Tools::displayError('You already have the maximum quantity available for this product.', false).'"]}');
|
||||
else
|
||||
$this->errors[] = Tools::displayError('You already have the maximum quantity available for this product.')
|
||||
.((isset($_SERVER['HTTP_REFERER']) AND basename($_SERVER['HTTP_REFERER']) == 'order.php' OR (!Tools::isSubmit('ajax') AND substr(basename($_SERVER['REQUEST_URI']),0, strlen('cart.php')) == 'cart.php')) ? ('<script language="javascript">setTimeout("history.back()",5000);</script><br />- '.
|
||||
Tools::displayError('You will be redirected to your cart in a few seconds.')) : '');
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($delete)
|
||||
{
|
||||
if (self::$cart->deleteProduct((int)($idProduct), (int)($idProductAttribute), (int)($customizationId)))
|
||||
if (!Cart::getNbProducts((int)(self::$cart->id)))
|
||||
{
|
||||
self::$cart->id_carrier = 0;
|
||||
self::$cart->gift = 0;
|
||||
self::$cart->gift_message = '';
|
||||
self::$cart->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
$discounts = self::$cart->getDiscounts();
|
||||
foreach($discounts AS $discount)
|
||||
{
|
||||
$discountObj = new Discount((int)($discount['id_discount']), (int)(self::$cookie->id_lang));
|
||||
if ($error = self::$cart->checkDiscountValidity($discountObj, $discounts, self::$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS), self::$cart->getProducts()))
|
||||
{
|
||||
self::$cart->deleteDiscount((int)($discount['id_discount']));
|
||||
self::$cart->update();
|
||||
$errors[] = $error;
|
||||
}
|
||||
}
|
||||
if (!sizeof($this->errors))
|
||||
{
|
||||
$queryString = Tools::safeOutput(Tools::getValue('query', NULL));
|
||||
if ($queryString AND !Configuration::get('PS_CART_REDIRECT'))
|
||||
Tools::redirect('index.php?controller=search&search='.$queryString);
|
||||
if (isset($_SERVER['HTTP_REFERER']))
|
||||
{
|
||||
// Redirect to previous page
|
||||
preg_match('!http(s?)://(.*)/(.*)!', $_SERVER['HTTP_REFERER'], $regs);
|
||||
if (isset($regs[3]) AND !Configuration::get('PS_CART_REDIRECT') AND Tools::getValue('ajax') != 'true')
|
||||
Tools::redirect($regs[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Tools::getValue('ajax') != 'true' AND !sizeof($this->errors))
|
||||
Tools::redirect('index.php?controller=order&'.(isset($idProduct) ? 'ipa='.(int)($idProduct) : ''));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'errors.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class CategoryControllerCore extends FrontController
|
||||
{
|
||||
protected $category;
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(array(
|
||||
_PS_CSS_DIR_.'jquery.cluetip.css' => 'all',
|
||||
_THEME_CSS_DIR_.'scenes.css' => 'all',
|
||||
_THEME_CSS_DIR_.'category.css' => 'all',
|
||||
_THEME_CSS_DIR_.'product_list.css' => 'all'));
|
||||
|
||||
if (Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0)
|
||||
Tools::addJS(_THEME_JS_DIR_.'products-comparison.js');
|
||||
}
|
||||
|
||||
public function displayHeader()
|
||||
{
|
||||
parent::displayHeader();
|
||||
$this->productSort();
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
if ($id_category = (int)Tools::getValue('id_category'))
|
||||
$this->category = new Category($id_category, self::$cookie->id_lang);
|
||||
if (!Validate::isLoadedObject($this->category))
|
||||
{
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header('Status: 404 Not Found');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Automatically redirect to the canonical URL if the current in is the right one
|
||||
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
|
||||
$currentURL = self::$link->getCategoryLink($this->category);
|
||||
$currentURL = preg_replace('/[?&].*$/', '', $currentURL);
|
||||
if (!preg_match('/^'.Tools::pRegexp($currentURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
|
||||
{
|
||||
header('HTTP/1.0 301 Moved');
|
||||
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_ )
|
||||
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$currentURL.'">'.$currentURL.'</a>');
|
||||
Tools::redirectLink($currentURL);
|
||||
}
|
||||
}
|
||||
|
||||
parent::preProcess();
|
||||
|
||||
if((int)(Configuration::get('PS_REWRITING_SETTINGS')))
|
||||
if ($id_category = (int)Tools::getValue('id_category'))
|
||||
{
|
||||
$rewrite_infos = Category::getUrlRewriteInformations((int)$id_category);
|
||||
|
||||
$default_rewrite = array();
|
||||
foreach ($rewrite_infos AS $infos)
|
||||
$default_rewrite[$infos['id_lang']] = self::$link->getCategoryLink((int)$id_category, $infos['link_rewrite'], $infos['id_lang']);
|
||||
|
||||
self::$smarty->assign('lang_rewrite_urls', $default_rewrite);
|
||||
}
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
if (!($id_category = (int)Tools::getValue('id_category')) OR !Validate::isUnsignedId($id_category))
|
||||
$this->errors[] = Tools::displayError('Missing category ID');
|
||||
else
|
||||
{
|
||||
if (!Validate::isLoadedObject($this->category))
|
||||
$this->errors[] = Tools::displayError('Category does not exist');
|
||||
elseif (!$this->category->checkAccess((int)(self::$cookie->id_customer)))
|
||||
$this->errors[] = Tools::displayError('You do not have access to this category.');
|
||||
elseif (!$this->category->active)
|
||||
self::$smarty->assign('category', $this->category);
|
||||
else
|
||||
{
|
||||
$rewrited_url = self::$link->getCategoryLink((int)$this->category->id, $this->category->link_rewrite);
|
||||
|
||||
/* Scenes (could be externalised to another controler if you need them */
|
||||
self::$smarty->assign('scenes', Scene::getScenes((int)($this->category->id), (int)(self::$cookie->id_lang), true, false));
|
||||
|
||||
/* Scenes images formats */
|
||||
if ($sceneImageTypes = ImageType::getImagesTypes('scenes'))
|
||||
{
|
||||
foreach ($sceneImageTypes AS $sceneImageType)
|
||||
{
|
||||
if ($sceneImageType['name'] == 'thumb_scene')
|
||||
$thumbSceneImageType = $sceneImageType;
|
||||
elseif ($sceneImageType['name'] == 'large_scene')
|
||||
$largeSceneImageType = $sceneImageType;
|
||||
}
|
||||
self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
|
||||
self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
|
||||
}
|
||||
|
||||
$this->category->description = nl2br2($this->category->description);
|
||||
$subCategories = $this->category->getSubCategories((int)(self::$cookie->id_lang));
|
||||
self::$smarty->assign('category', $this->category);
|
||||
if (Db::getInstance()->numRows())
|
||||
{
|
||||
self::$smarty->assign('subcategories', $subCategories);
|
||||
self::$smarty->assign(array(
|
||||
'subcategories_nb_total' => sizeof($subCategories),
|
||||
'subcategories_nb_half' => ceil(sizeof($subCategories) / 2)));
|
||||
}
|
||||
if ($this->category->id != 1)
|
||||
{
|
||||
$nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
|
||||
$this->pagination((int)$nbProducts);
|
||||
self::$smarty->assign('nb_products', (int)$nbProducts);
|
||||
$cat_products = $this->category->getProducts((int)(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay);
|
||||
}
|
||||
self::$smarty->assign(array(
|
||||
'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL,
|
||||
'id_category' => (int)($this->category->id),
|
||||
'id_category_parent' => (int)($this->category->id_parent),
|
||||
'return_category_name' => Tools::safeOutput($this->category->name),
|
||||
'path' => Tools::getPath((int)($this->category->id)),
|
||||
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
||||
'categorySize' => Image::getSize('category'),
|
||||
'mediumSize' => Image::getSize('medium'),
|
||||
'thumbSceneSize' => Image::getSize('thumb_scene'),
|
||||
'homeSize' => Image::getSize('home')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'allow_oosp' => (int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')),
|
||||
'comparator_max_item' => (int)(Configuration::get('PS_COMPARATOR_MAX_ITEM')),
|
||||
'suppliers' => Supplier::getSuppliers()
|
||||
));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'category.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class CompareControllerCore extends FrontController
|
||||
{
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'/comparator.css');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
$hasProduct = false;
|
||||
$product_list = Tools::getValue('compare_product_list');
|
||||
$postProducts = isset($product_list) ? rtrim($product_list,'|') : '';
|
||||
|
||||
if (!Configuration::get('PS_COMPARATOR_MAX_ITEM'))
|
||||
return Tools::redirect('index.php?controller=404');
|
||||
|
||||
if ($postProducts)
|
||||
{
|
||||
$ids = array_unique(explode('|', $postProducts));
|
||||
|
||||
if (sizeof($ids) > 0)
|
||||
{
|
||||
if (sizeof($ids) > Configuration::get('PS_COMPARATOR_MAX_ITEM'))
|
||||
$ids = array_slice($ids, 0, Configuration::get('PS_COMPARATOR_MAX_ITEM'));
|
||||
|
||||
$listProducts = array();
|
||||
$listFeatures = array();
|
||||
|
||||
foreach ($ids AS $id)
|
||||
{
|
||||
$curProduct = new Product((int)($id), true, (int)(self::$cookie->id_lang));
|
||||
if (!Validate::isLoadedObject($curProduct))
|
||||
continue;
|
||||
|
||||
foreach ($curProduct->getFrontFeatures(self::$cookie->id_lang) AS $feature)
|
||||
$listFeatures[$curProduct->id][$feature['id_feature']] = $feature['value'];
|
||||
|
||||
$cover = Product::getCover((int)$id);
|
||||
|
||||
$curProduct->id_image = Tools::htmlentitiesUTF8(Product::defineProductImage(array('id_image' => $cover['id_image'], 'id_product' => $id), self::$cookie->id_lang));
|
||||
$listProducts[] = $curProduct;
|
||||
}
|
||||
|
||||
if (sizeof($listProducts) > 0)
|
||||
{
|
||||
$width = 80 / sizeof($listProducts);
|
||||
|
||||
$hasProduct = true;
|
||||
$ordered_features = Feature::getFeaturesForComparison($ids, self::$cookie->id_lang);
|
||||
self::$smarty->assign(array(
|
||||
'ordered_features' => $ordered_features,
|
||||
'product_features' => $listFeatures,
|
||||
'products' => $listProducts,
|
||||
'link' => new Link(),
|
||||
'width' => $width,
|
||||
'homeSize' => Image::getSize('home')
|
||||
));
|
||||
self::$smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Module::hookExec('extraProductComparison', array('list_ids_product' => $ids)));
|
||||
}
|
||||
}
|
||||
}
|
||||
self::$smarty->assign('hasProduct', $hasProduct);
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'products-comparison.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,264 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class ContactControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->php_self = 'contact-form.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
if (self::$cookie->isLogged())
|
||||
{
|
||||
self::$smarty->assign('isLogged', 1);
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
if (!Validate::isLoadedObject($customer))
|
||||
die(Tools::displayError('Customer not found'));
|
||||
$products = array();
|
||||
$orders = array();
|
||||
$getOrders = Db::getInstance()->ExecuteS('
|
||||
SELECT id_order
|
||||
FROM '._DB_PREFIX_.'orders
|
||||
WHERE id_customer = '.(int)$customer->id.' ORDER BY date_add');
|
||||
foreach ($getOrders as $row)
|
||||
{
|
||||
$order = new Order($row['id_order']);
|
||||
$date = explode(' ', $order->date_add);
|
||||
$orders[$row['id_order']] = Tools::displayDate($date[0], self::$cookie->id_lang);
|
||||
$tmp = $order->getProducts();
|
||||
foreach ($tmp as $key => $val)
|
||||
$products[$val['product_id']] = $val['product_name'];
|
||||
}
|
||||
|
||||
$orderList = '';
|
||||
foreach ($orders as $key => $val)
|
||||
$orderList .= '<option value="'.$key.'" '.((int)(Tools::getValue('id_order')) == $key ? 'selected' : '').' >'.$key.' -- '.$val.'</option>';
|
||||
$orderedProductList = '';
|
||||
|
||||
foreach ($products as $key => $val)
|
||||
$orderedProductList .= '<option value="'.$key.'" '.((int)(Tools::getValue('id_product')) == $key ? 'selected' : '').' >'.$val.'</option>';
|
||||
self::$smarty->assign('orderList', $orderList);
|
||||
self::$smarty->assign('orderedProductList', $orderedProductList);
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitMessage'))
|
||||
{
|
||||
$fileAttachment = NULL;
|
||||
if (isset($_FILES['fileUpload']['name']) AND !empty($_FILES['fileUpload']['name']) AND !empty($_FILES['fileUpload']['tmp_name']))
|
||||
{
|
||||
$extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg');
|
||||
$filename = uniqid().substr($_FILES['fileUpload']['name'], -5);
|
||||
$fileAttachment['content'] = file_get_contents($_FILES['fileUpload']['tmp_name']);
|
||||
$fileAttachment['name'] = $_FILES['fileUpload']['name'];
|
||||
$fileAttachment['mime'] = $_FILES['fileUpload']['type'];
|
||||
}
|
||||
$message = Tools::htmlentitiesUTF8(Tools::getValue('message'));
|
||||
if (!($from = trim(Tools::getValue('from'))) OR !Validate::isEmail($from))
|
||||
$this->errors[] = Tools::displayError('Invalid e-mail address');
|
||||
elseif (!($message = nl2br2($message)))
|
||||
$this->errors[] = Tools::displayError('Message cannot be blank');
|
||||
elseif (!Validate::isMessage($message))
|
||||
$this->errors[] = Tools::displayError('Invalid message');
|
||||
elseif (!($id_contact = (int)(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact((int)($id_contact), (int)(self::$cookie->id_lang)))))
|
||||
$this->errors[] = Tools::displayError('Please select a subject on the list.');
|
||||
elseif (!empty($_FILES['fileUpload']['name']) AND $_FILES['fileUpload']['error'] != 0)
|
||||
$this->errors[] = Tools::displayError('An error occurred during the file upload');
|
||||
elseif (!empty($_FILES['fileUpload']['name']) AND !in_array(substr($_FILES['fileUpload']['name'], -4), $extension) AND !in_array(substr($_FILES['fileUpload']['name'], -5), $extension))
|
||||
$this->errors[] = Tools::displayError('Bad file extension');
|
||||
else
|
||||
{
|
||||
if ((int)(self::$cookie->id_customer))
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
else
|
||||
{
|
||||
$customer = new Customer();
|
||||
$customer->getByEmail($from);
|
||||
}
|
||||
|
||||
$contact = new Contact($id_contact, self::$cookie->id_lang);
|
||||
|
||||
if (!((
|
||||
$id_customer_thread = (int)Tools::getValue('id_customer_thread')
|
||||
AND (int)Db::getInstance()->getValue('
|
||||
SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm
|
||||
WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND token = \''.pSQL(Tools::getValue('token')).'\'')
|
||||
) OR (
|
||||
$id_customer_thread = (int)Db::getInstance()->getValue('
|
||||
SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm
|
||||
WHERE cm.email = \''.pSQL($from).'\' AND cm.id_order = '.(int)(Tools::getValue('id_order')).'')
|
||||
)))
|
||||
{
|
||||
$fields = Db::getInstance()->ExecuteS('
|
||||
SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email
|
||||
FROM '._DB_PREFIX_.'customer_thread cm
|
||||
WHERE email = \''.pSQL($from).'\' AND ('.
|
||||
($customer->id ? 'id_customer = '.(int)($customer->id).' OR ' : '').'
|
||||
id_order = '.(int)(Tools::getValue('id_order')).')');
|
||||
$score = 0;
|
||||
foreach ($fields as $key => $row)
|
||||
{
|
||||
$tmp = 0;
|
||||
if ((int)$row['id_customer'] AND $row['id_customer'] != $customer->id AND $row['email'] != $from)
|
||||
continue;
|
||||
if ($row['id_order'] != 0 AND Tools::getValue('id_order') != $row['id_order'])
|
||||
continue;
|
||||
if ($row['email'] == $from)
|
||||
$tmp += 4;
|
||||
if ($row['id_contact'] == $id_contact)
|
||||
$tmp++;
|
||||
if (Tools::getValue('id_product') != 0 AND $row['id_product'] == Tools::getValue('id_product'))
|
||||
$tmp += 2;
|
||||
if ($tmp >= 5 AND $tmp >= $score)
|
||||
{
|
||||
$score = $tmp;
|
||||
$id_customer_thread = $row['id_customer_thread'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$old_message = Db::getInstance()->getValue('
|
||||
SELECT cm.message FROM '._DB_PREFIX_.'customer_message cm
|
||||
WHERE cm.id_customer_thread = '.(int)($id_customer_thread).'
|
||||
ORDER BY date_add DESC');
|
||||
if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8'))
|
||||
{
|
||||
self::$smarty->assign('alreadySent', 1);
|
||||
$contact->email = '';
|
||||
$contact->customer_service = 0;
|
||||
}
|
||||
if (!empty($contact->email))
|
||||
{
|
||||
if (Mail::Send((int)(self::$cookie->id_lang), 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, ((int)(self::$cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment)
|
||||
AND Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from))
|
||||
self::$smarty->assign('confirmation', 1);
|
||||
else
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
}
|
||||
|
||||
if ($contact->customer_service)
|
||||
{
|
||||
if ((int)$id_customer_thread)
|
||||
{
|
||||
$ct = new CustomerThread($id_customer_thread);
|
||||
$ct->status = 'open';
|
||||
$ct->id_lang = (int)self::$cookie->id_lang;
|
||||
$ct->id_contact = (int)($id_contact);
|
||||
if ($id_order = (int)Tools::getValue('id_order'))
|
||||
$ct->id_order = $id_order;
|
||||
if ($id_product = (int)Tools::getValue('id_product'))
|
||||
$ct->id_product = $id_product;
|
||||
$ct->update();
|
||||
}
|
||||
else
|
||||
{
|
||||
$ct = new CustomerThread();
|
||||
if (isset($customer->id))
|
||||
$ct->id_customer = (int)($customer->id);
|
||||
if ($id_order = (int)Tools::getValue('id_order'))
|
||||
$ct->id_order = $id_order;
|
||||
if ($id_product = (int)Tools::getValue('id_product'))
|
||||
$ct->id_product = $id_product;
|
||||
$ct->id_contact = (int)($id_contact);
|
||||
$ct->id_lang = (int)self::$cookie->id_lang;
|
||||
$ct->email = $from;
|
||||
$ct->status = 'open';
|
||||
$ct->token = Tools::passwdGen(12);
|
||||
$ct->add();
|
||||
}
|
||||
|
||||
if ($ct->id)
|
||||
{
|
||||
$cm = new CustomerMessage();
|
||||
$cm->id_customer_thread = $ct->id;
|
||||
$cm->message = htmlentities($message, ENT_COMPAT, 'UTF-8');
|
||||
if (isset($filename) AND rename($_FILES['fileUpload']['tmp_name'], _PS_MODULE_DIR_.'../upload/'.$filename))
|
||||
$cm->file_name = $filename;
|
||||
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
|
||||
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
|
||||
if ($cm->add())
|
||||
{
|
||||
if (empty($contact->email))
|
||||
Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from);
|
||||
self::$smarty->assign('confirmation', 1);
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
}
|
||||
if (count($this->errors) > 1)
|
||||
array_unique($this->errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'contact-form.css');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
$email = Tools::safeOutput(Tools::getValue('from', ((isset(self::$cookie) AND isset(self::$cookie->email) AND Validate::isEmail(self::$cookie->email)) ? self::$cookie->email : '')));
|
||||
self::$smarty->assign(array(
|
||||
'errors' => $this->errors,
|
||||
'email' => $email,
|
||||
'fileupload' => Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD')
|
||||
));
|
||||
|
||||
|
||||
if ($id_customer_thread = (int)Tools::getValue('id_customer_thread') AND $token = Tools::getValue('token'))
|
||||
{
|
||||
$customerThread = Db::getInstance()->getRow('
|
||||
SELECT cm.* FROM '._DB_PREFIX_.'customer_thread cm
|
||||
WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND token = \''.pSQL($token).'\'');
|
||||
self::$smarty->assign('customerThread', $customerThread);
|
||||
}
|
||||
|
||||
self::$smarty->assign(array('contacts' => Contact::getContacts((int)(self::$cookie->id_lang)),
|
||||
'message' => html_entity_decode(Tools::getValue('message'))
|
||||
));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
$_POST = array_merge($_POST, $_GET);
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class DiscountControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = true;
|
||||
$this->php_self = 'discount.php';
|
||||
$this->authRedirection = 'discount.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
$discounts = Discount::getCustomerDiscounts((int)(self::$cookie->id_lang), (int)(self::$cookie->id_customer), true, false);
|
||||
$nbDiscounts = 0;
|
||||
foreach ($discounts AS $discount)
|
||||
if ($discount['quantity_for_user'])
|
||||
$nbDiscounts++;
|
||||
|
||||
self::$smarty->assign(array('nbDiscounts' => (int)($nbDiscounts), 'discount' => $discounts));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'discount.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class GuestTrackingControllerCore extends FrontController
|
||||
{
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
if (self::$cookie->isLogged())
|
||||
Tools::redirect('index.php?controller=history');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
if ($id_order = Tools::getValue('id_order') AND $email = Tools::getValue('email'))
|
||||
{
|
||||
$order = new Order((int)$id_order);
|
||||
if (!Validate::isLoadedObject($order))
|
||||
$this->errors[] = Tools::displayError('Invalid order');
|
||||
elseif (!$order->isAssociatedAtGuest($email))
|
||||
$this->errors[] = Tools::displayError('Invalid order');
|
||||
else
|
||||
{
|
||||
$customer = new Customer((int)$order->id_customer);
|
||||
$id_order_state = (int)($order->getCurrentState());
|
||||
$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));
|
||||
if ($order->total_discounts > 0)
|
||||
self::$smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts));
|
||||
$products = $order->getProducts();
|
||||
$customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart));
|
||||
Product::addCustomizationPrice($products, $customizedDatas);
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'shop_name' => Configuration::get('PS_SHOP_NAME'),
|
||||
'order' => $order,
|
||||
'return_allowed' => false,
|
||||
'currency' => new Currency($order->id_currency),
|
||||
'order_state' => (int)($id_order_state),
|
||||
'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')),
|
||||
'invoice' => (OrderState::invoiceAvailable((int)($id_order_state)) AND $order->invoice_number),
|
||||
'order_history' => $order->getHistory((int)(self::$cookie->id_lang), false, true),
|
||||
'products' => $products,
|
||||
'discounts' => $order->getDiscounts(),
|
||||
'carrier' => $carrier,
|
||||
'address_invoice' => $addressInvoice,
|
||||
'invoiceState' => (Validate::isLoadedObject($addressInvoice) AND $addressInvoice->id_state) ? new State((int)($addressInvoice->id_state)) : false,
|
||||
'address_delivery' => $addressDelivery,
|
||||
'deliveryState' => (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state) ? new State((int)($addressDelivery->id_state)) : false,
|
||||
'is_guest' => true,
|
||||
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
|
||||
'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_,
|
||||
'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_,
|
||||
'use_tax' => Configuration::get('PS_TAX'),
|
||||
'customizedDatas' => $customizedDatas));
|
||||
if ($carrier->url AND $order->shipping_number)
|
||||
self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
|
||||
self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
|
||||
Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
|
||||
|
||||
if (Tools::isSubmit('submitTransformGuestToCustomer'))
|
||||
{
|
||||
if (!Validate::isPasswd(Tools::getValue('password')))
|
||||
$this->errors[] = Tools::displayError('Invalid password');
|
||||
$customer = new Customer((int)$order->id_customer);
|
||||
if (!Validate::isLoadedObject($customer))
|
||||
$this->errors[] = Tools::displayError('Invalid customer');
|
||||
if (!$customer->transformToCustomer(self::$cookie->id_lang, Tools::getValue('password')))
|
||||
$this->errors[] = Tools::displayError('An error occurred while transforming guest to customer.');
|
||||
else
|
||||
self::$smarty->assign('transformSuccess', true);
|
||||
}
|
||||
}
|
||||
if (sizeof($this->errors))
|
||||
/* Handle brute force attacks */
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'action' => 'guest-tracking.php',
|
||||
'errors' => $this->errors
|
||||
));
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'history.css');
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class HistoryControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = true;
|
||||
$this->php_self = 'history.php';
|
||||
$this->authRedirection = 'history.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'history.css');
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
|
||||
Tools::addJS(array(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js', _THEME_JS_DIR_.'history.js'));
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
if ($orders = Order::getCustomerOrders((int)(self::$cookie->id_customer)))
|
||||
foreach ($orders AS &$order)
|
||||
{
|
||||
$myOrder = new Order((int)($order['id_order']));
|
||||
if (Validate::isLoadedObject($myOrder))
|
||||
$order['virtual'] = $myOrder->isVirtual(false);
|
||||
}
|
||||
self::$smarty->assign(array(
|
||||
'orders' => $orders,
|
||||
'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')),
|
||||
'slowValidation' => Tools::isSubmit('slowvalidation')
|
||||
));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'history.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class IdentityControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = true;
|
||||
$this->php_self = 'identity.php';
|
||||
$this->authRedirection = 'identity.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
|
||||
if (sizeof($_POST))
|
||||
{
|
||||
$exclusion = array('secure_key', 'old_passwd', 'passwd', 'active', 'date_add', 'date_upd', 'last_passwd_gen', 'newsletter_date_add', 'id_default_group');
|
||||
$fields = $customer->getFields();
|
||||
foreach ($fields AS $key => $value)
|
||||
if (!in_array($key, $exclusion))
|
||||
$customer->{$key} = key_exists($key, $_POST) ? trim($_POST[$key]) : 0;
|
||||
}
|
||||
|
||||
if (isset($_POST['years']) AND isset($_POST['months']) AND isset($_POST['days']))
|
||||
$customer->birthday = (int)($_POST['years']).'-'.(int)($_POST['months']).'-'.(int)($_POST['days']);
|
||||
|
||||
if (Tools::isSubmit('submitIdentity'))
|
||||
{
|
||||
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');
|
||||
else
|
||||
{
|
||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)($_POST['years']).'-'.(int)($_POST['months']).'-'.(int)($_POST['days']));
|
||||
|
||||
$_POST['old_passwd'] = trim($_POST['old_passwd']);
|
||||
if (empty($_POST['old_passwd']) OR (Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd))
|
||||
$this->errors[] = Tools::displayError('Your password is incorrect.');
|
||||
elseif ($_POST['passwd'] != $_POST['confirmation'])
|
||||
$this->errors[] = Tools::displayError('Password and confirmation do not match');
|
||||
else
|
||||
{
|
||||
$prev_id_default_group = $customer->id_default_group;
|
||||
$this->errors = $customer->validateControler();
|
||||
}
|
||||
if (!sizeof($this->errors))
|
||||
{
|
||||
$customer->id_default_group = (int)($prev_id_default_group);
|
||||
$customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
|
||||
if (Tools::getValue('passwd'))
|
||||
self::$cookie->passwd = $customer->passwd;
|
||||
if ($customer->update())
|
||||
{
|
||||
self::$cookie->customer_lastname = $customer->lastname;
|
||||
self::$cookie->customer_firstname = $customer->firstname;
|
||||
self::$smarty->assign('confirmation', 1);
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('Cannot update information');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
$_POST = array_map('stripslashes', $customer->getFields());
|
||||
|
||||
if ($customer->birthday)
|
||||
$birthday = explode('-', $customer->birthday);
|
||||
else
|
||||
$birthday = array('-', '-', '-');
|
||||
|
||||
/* Generate years, months and days */
|
||||
self::$smarty->assign(array(
|
||||
'years' => Tools::dateYears(),
|
||||
'sl_year' => $birthday[0],
|
||||
'months' => Tools::dateMonths(),
|
||||
'sl_month' => $birthday[1],
|
||||
'days' => Tools::dateDays(),
|
||||
'sl_day' => $birthday[2],
|
||||
'errors' => $this->errors
|
||||
));
|
||||
|
||||
self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'identity.css');
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'identity.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class IndexControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->php_self = Configuration::get('PS_HOMEPAGE_PHP_SELF');
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
self::$smarty->assign('HOOK_HOME', Module::hookExec('home'));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'index.tpl');
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class ManufacturerControllerCore extends FrontController
|
||||
{
|
||||
protected $manufacturer;
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
if ($id_manufacturer = Tools::getValue('id_manufacturer'))
|
||||
{
|
||||
$this->manufacturer = new Manufacturer((int)$id_manufacturer, self::$cookie->id_lang);
|
||||
if (Validate::isLoadedObject($this->manufacturer) AND $this->manufacturer->active)
|
||||
{
|
||||
$nbProducts = $this->manufacturer->getProducts($id_manufacturer, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
|
||||
$this->pagination((int)$nbProducts);
|
||||
self::$smarty->assign(array(
|
||||
'nb_products' => $nbProducts,
|
||||
'products' => $this->manufacturer->getProducts($id_manufacturer, (int)self::$cookie->id_lang, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay),
|
||||
'path' => ($this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : ''),
|
||||
'manufacturer' => $this->manufacturer));
|
||||
}
|
||||
else
|
||||
{
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header('Status: 404 Not Found');
|
||||
$this->errors[] = Tools::displayError('Manufacturer does not exist.');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Configuration::get('PS_DISPLAY_SUPPLIERS'))
|
||||
{
|
||||
$data = call_user_func(array('Manufacturer', 'getManufacturers'), true, (int)(self::$cookie->id_lang), true);
|
||||
$nbProducts = count($data);
|
||||
$this->pagination($nbProducts);
|
||||
|
||||
$data = call_user_func(array('Manufacturer', 'getManufacturers'), true, (int)(self::$cookie->id_lang), true, $this->p, $this->n);
|
||||
$imgDir = _PS_MANU_IMG_DIR_;
|
||||
foreach ($data AS &$item)
|
||||
$item['image'] = (!file_exists($imgDir.'/'.$item['id_manufacturer'].'-medium.jpg')) ?
|
||||
Language::getIsoById((int)(self::$cookie->id_lang)).'-default' : $item['id_manufacturer'];
|
||||
self::$smarty->assign(array(
|
||||
'pages_nb' => ceil($nbProducts / (int)($this->n)),
|
||||
'nbManufacturers' => $nbProducts,
|
||||
'mediumSize' => Image::getSize('medium'),
|
||||
'manufacturers' => $data,
|
||||
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
||||
));
|
||||
}
|
||||
else
|
||||
self::$smarty->assign('nbManufacturers', 0);
|
||||
}
|
||||
}
|
||||
|
||||
public function displayHeader()
|
||||
{
|
||||
parent::displayHeader();
|
||||
$this->productSort();
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
if ($this->manufacturer)
|
||||
self::$smarty->display(_PS_THEME_DIR_.'manufacturer.tpl');
|
||||
else
|
||||
self::$smarty->display(_PS_THEME_DIR_.'manufacturer-list.tpl');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class MyAccountControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = true;
|
||||
$this->php_self = 'my-account.php';
|
||||
$this->authRedirection = 'my-account.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'my-account.css');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')),
|
||||
'returnAllowed' => (int)(Configuration::get('PS_ORDER_RETURN'))
|
||||
));
|
||||
self::$smarty->assign('HOOK_CUSTOMER_ACCOUNT', Module::hookExec('customerAccount'));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'my-account.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class NewProductsControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->php_self = 'new-products.php';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
$this->productSort();
|
||||
$nbProducts = (int)(Product::getNewProducts((int)(self::$cookie->id_lang), isset($this->p) ? (int)($this->p) - 1 : NULL, isset($this->n) ? (int)($this->n) : NULL, true));
|
||||
$this->pagination($nbProducts);
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'products' => Product::getNewProducts((int)(self::$cookie->id_lang), (int)($this->p) - 1, (int)($this->n), false, $this->orderBy, $this->orderWay),
|
||||
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
||||
'nbProducts' => (int)($nbProducts),
|
||||
'homeSize' => Image::getSize('home')
|
||||
));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'new-products.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class OrderConfirmationControllerCore extends FrontController
|
||||
{
|
||||
public $id_cart;
|
||||
public $id_module;
|
||||
public $id_order;
|
||||
public $secure_key;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->php_self = 'order-confirmation.php';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
$this->id_cart = (int)(Tools::getValue('id_cart', 0));
|
||||
|
||||
/* check if the cart has been made by a Guest customer, for redirect link */
|
||||
if (Cart::isGuestCartByCartId($this->id_cart))
|
||||
$redirectLink = 'guest-tracking.php';
|
||||
else
|
||||
$redirectLink = 'history.php';
|
||||
|
||||
$this->id_module = (int)(Tools::getValue('id_module', 0));
|
||||
$this->id_order = Order::getOrderByCartId((int)($this->id_cart));
|
||||
$this->secure_key = Tools::getValue('key', false);
|
||||
if (!$this->id_order OR !$this->id_module OR !$this->secure_key OR empty($this->secure_key))
|
||||
Tools::redirect($redirectLink.(Tools::isSubmit('slowvalidation') ? '?slowvalidation' : ''));
|
||||
|
||||
$order = new Order((int)($this->id_order));
|
||||
if (!Validate::isLoadedObject($order) OR $order->id_customer != self::$cookie->id_customer OR $this->secure_key != $order->secure_key)
|
||||
Tools::redirect($redirectLink);
|
||||
$module = Module::getInstanceById((int)($this->id_module));
|
||||
if ($order->payment != $module->displayName)
|
||||
Tools::redirect($redirectLink);
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
self::$smarty->assign(array(
|
||||
'is_guest' => self::$cookie->is_guest,
|
||||
'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int)($this->id_order)),
|
||||
'HOOK_PAYMENT_RETURN' => Hook::paymentReturn((int)($this->id_order), (int)($this->id_module))
|
||||
));
|
||||
|
||||
if (self::$cookie->is_guest)
|
||||
{
|
||||
self::$smarty->assign(array(
|
||||
'id_order' => $this->id_order,
|
||||
'id_order_formatted' => sprintf('#%06d', $this->id_order)
|
||||
));
|
||||
/* If guest we clear the cookie for security reason */
|
||||
self::$cookie->logout();
|
||||
}
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'order-confirmation.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,283 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
ControllerFactory::includeController('ParentOrderController');
|
||||
|
||||
class OrderControllerCore extends ParentOrderController
|
||||
{
|
||||
public $step;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->step = (int)(Tools::getValue('step'));
|
||||
if (!$this->nbProducts)
|
||||
$this->step = -1;
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
global $isVirtualCart, $orderTotal;
|
||||
|
||||
parent::preProcess();
|
||||
|
||||
/* If some products have disappear */
|
||||
if (!self::$cart->checkQuantities())
|
||||
{
|
||||
$this->step = 0;
|
||||
$this->errors[] = Tools::displayError('An item in your cart is no longer available for this quantity, you cannot proceed with your order.');
|
||||
}
|
||||
|
||||
/* Check minimal amount */
|
||||
$currency = Currency::getCurrency((int)self::$cart->id_currency);
|
||||
|
||||
$orderTotal = self::$cart->getOrderTotal();
|
||||
$minimalPurchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
|
||||
|
||||
if ($orderTotal < $minimalPurchase)
|
||||
{
|
||||
$this->step = 0;
|
||||
$this->errors[] = Tools::displayError('A minimum purchase total of').' '.Tools::displayPrice($minimalPurchase, $currency).
|
||||
' '.Tools::displayError('is required in order to validate your order.');
|
||||
}
|
||||
|
||||
if (!self::$cookie->isLogged(true) AND in_array($this->step, array(1, 2, 3)))
|
||||
Tools::redirect('index.php?controller=authentication&back=order.php?step='.$this->step);
|
||||
|
||||
if ($this->nbProducts)
|
||||
self::$smarty->assign('virtual_cart', $isVirtualCart);
|
||||
}
|
||||
|
||||
public function displayHeader()
|
||||
{
|
||||
if (!Tools::getValue('ajax'))
|
||||
parent::displayHeader();
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
/* 4 steps to the order */
|
||||
switch ((int)$this->step)
|
||||
{
|
||||
case -1;
|
||||
self::$smarty->assign('empty', 1);
|
||||
break;
|
||||
case 1:
|
||||
$this->_assignAddress();
|
||||
break;
|
||||
case 2:
|
||||
if(Tools::isSubmit('processAddress'))
|
||||
$this->processAddress();
|
||||
$this->autoStep();
|
||||
$this->_assignCarrier();
|
||||
break;
|
||||
case 3:
|
||||
if(Tools::isSubmit('processCarrier'))
|
||||
$this->processCarrier();
|
||||
$this->autoStep();
|
||||
/* Bypass payment step if total is 0 */
|
||||
if (($id_order = $this->_checkFreeOrder()) AND $id_order)
|
||||
{
|
||||
if (self::$cookie->is_guest)
|
||||
{
|
||||
$email = self::$cookie->email;
|
||||
self::$cookie->logout(); // If guest we clear the cookie for security reason
|
||||
Tools::redirect('index.php?controller=guest-tracking&id_order='.(int)$id_order.'&email='.urlencode($email));
|
||||
}
|
||||
else
|
||||
Tools::redirect('index.php?controller=history');
|
||||
}
|
||||
$this->_assignPayment();
|
||||
break;
|
||||
default:
|
||||
$this->_assignSummaryInformations();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
switch ((int)$this->step)
|
||||
{
|
||||
case -1:
|
||||
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:
|
||||
self::$smarty->display(_PS_THEME_DIR_.'order-carrier.tpl');
|
||||
break;
|
||||
case 3:
|
||||
self::$smarty->display(_PS_THEME_DIR_.'order-payment.tpl');
|
||||
break;
|
||||
default:
|
||||
self::$smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function displayFooter()
|
||||
{
|
||||
if (!Tools::getValue('ajax'))
|
||||
parent::displayFooter();
|
||||
}
|
||||
|
||||
/* Order process controller */
|
||||
public function autoStep()
|
||||
{
|
||||
global $isVirtualCart;
|
||||
|
||||
if ($this->step >= 2 AND (!self::$cart->id_address_delivery OR !self::$cart->id_address_invoice))
|
||||
Tools::redirect('index.php?controller=order&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)
|
||||
unset(self::$cart->id_address_delivery);
|
||||
if ($invoice->deleted)
|
||||
unset(self::$cart->id_address_invoice);
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
}
|
||||
elseif ($this->step >= 3 AND !self::$cart->id_carrier AND !$isVirtualCart)
|
||||
Tools::redirect('index.php?controller=order&step=2');
|
||||
}
|
||||
|
||||
/*
|
||||
* Manage address
|
||||
*/
|
||||
public function processAddress()
|
||||
{
|
||||
if (!Tools::isSubmit('id_address_delivery') OR !Address::isCountryActiveById((int)Tools::getValue('id_address_delivery')))
|
||||
$this->errors[] = Tools::displayError('This address is not in a valid area.');
|
||||
else
|
||||
{
|
||||
self::$cart->id_address_delivery = (int)(Tools::getValue('id_address_delivery'));
|
||||
self::$cart->id_address_invoice = Tools::isSubmit('same') ? self::$cart->id_address_delivery : (int)(Tools::getValue('id_address_invoice'));
|
||||
if (!self::$cart->update())
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating your cart.');
|
||||
|
||||
if (Tools::isSubmit('message'))
|
||||
$this->_updateMessage(Tools::getValue('message'));
|
||||
}
|
||||
if (sizeof($this->errors))
|
||||
{
|
||||
if (Tools::getValue('ajax'))
|
||||
die('{"hasError" : true, "errors" : ["'.implode('\',\'', $this->errors).'"]}');
|
||||
$this->step = 1;
|
||||
}
|
||||
if (Tools::getValue('ajax'))
|
||||
die(true);
|
||||
}
|
||||
|
||||
/* Carrier step */
|
||||
protected function processCarrier()
|
||||
{
|
||||
global $orderTotal;
|
||||
|
||||
parent::_processCarrier();
|
||||
|
||||
if (sizeof($this->errors))
|
||||
{
|
||||
self::$smarty->assign('errors', $this->errors);
|
||||
$this->_assignCarrier();
|
||||
$this->step = 2;
|
||||
$this->displayContent();
|
||||
include(dirname(__FILE__).'/../footer.php');
|
||||
exit;
|
||||
}
|
||||
$orderTotal = self::$cart->getOrderTotal();
|
||||
}
|
||||
|
||||
/* Address step */
|
||||
protected function _assignAddress()
|
||||
{
|
||||
parent::_assignAddress();
|
||||
|
||||
self::$smarty->assign('cart', self::$cart);
|
||||
if (self::$cookie->is_guest)
|
||||
Tools::redirect('index.php?controller=order?step=2');
|
||||
}
|
||||
|
||||
/* Carrier step */
|
||||
protected function _assignCarrier()
|
||||
{
|
||||
global $defaultCountry;
|
||||
|
||||
if (isset(self::$cookie->id_customer))
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
else
|
||||
die(Tools::displayError('Fatal error: No customer'));
|
||||
// Assign carrier
|
||||
parent::_assignCarrier();
|
||||
// Assign wrapping and TOS
|
||||
$this->_assignWrappingAndTOS();
|
||||
|
||||
self::$smarty->assign('is_guest' ,(isset(self::$cookie->is_guest) ? self::$cookie->is_guest : 0));
|
||||
}
|
||||
|
||||
/* Payment step */
|
||||
protected function _assignPayment()
|
||||
{
|
||||
global $orderTotal;
|
||||
|
||||
// Redirect instead of displaying payment modules if any module are grefted on
|
||||
Hook::backBeforePayment('order.php?step=3');
|
||||
|
||||
/* We may need to display an order summary */
|
||||
self::$smarty->assign(self::$cart->getSummaryDetails());
|
||||
self::$smarty->assign(array(
|
||||
'total_price' => (float)($orderTotal),
|
||||
'taxes_enabled' => (int)(Configuration::get('PS_TAX'))
|
||||
));
|
||||
self::$cookie->checkedTOS = '1';
|
||||
|
||||
parent::_assignPayment();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class OrderDetailControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = true;
|
||||
$this->authRedirection = 'history.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
if (Tools::isSubmit('submitMessage'))
|
||||
{
|
||||
$idOrder = (int)(Tools::getValue('id_order'));
|
||||
$msgText = htmlentities(Tools::getValue('msgText'), ENT_COMPAT, 'UTF-8');
|
||||
|
||||
if (!$idOrder OR !Validate::isUnsignedId($idOrder))
|
||||
$this->errors[] = Tools::displayError('Order is no longer valid');
|
||||
elseif (empty($msgText))
|
||||
$this->errors[] = Tools::displayError('Message cannot be blank');
|
||||
elseif (!Validate::isMessage($msgText))
|
||||
$this->errors[] = Tools::displayError('Message is invalid (HTML is not allowed)');
|
||||
if(!sizeof($this->errors))
|
||||
{
|
||||
$order = new Order((int)($idOrder));
|
||||
if (Validate::isLoadedObject($order) AND $order->id_customer == self::$cookie->id_customer)
|
||||
{
|
||||
$message = new Message();
|
||||
$message->id_customer = (int)(self::$cookie->id_customer);
|
||||
$message->message = $msgText;
|
||||
$message->id_order = (int)($idOrder);
|
||||
$message->private = false;
|
||||
$message->add();
|
||||
if (!Configuration::get('PS_MAIL_EMAIL_MESSAGE'))
|
||||
$to = strval(Configuration::get('PS_SHOP_EMAIL'));
|
||||
else
|
||||
{
|
||||
$to = new Contact((int)(Configuration::get('PS_MAIL_EMAIL_MESSAGE')));
|
||||
$to = strval($to->email);
|
||||
}
|
||||
$toName = strval(Configuration::get('PS_SHOP_NAME'));
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
if (Validate::isLoadedObject($customer))
|
||||
Mail::Send((int)(self::$cookie->id_lang), 'order_customer_comment', Mail::l('Message from a customer'),
|
||||
array(
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{email}' => $customer->email,
|
||||
'{id_order}' => (int)($message->id_order),
|
||||
'{message}' => $message->message),
|
||||
$to, $toName, $customer->email, $customer->firstname.' '.$customer->lastname);
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
Tools::redirect('index.php?controller=order-detail&id_order='.(int)($idOrder));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errors[] = Tools::displayError('Order not found');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$id_order = (int)(Tools::getValue('id_order')) OR !Validate::isUnsignedId($id_order))
|
||||
$this->errors[] = Tools::displayError('Order ID required');
|
||||
else
|
||||
{
|
||||
$order = new Order($id_order);
|
||||
if (Validate::isLoadedObject($order) AND $order->id_customer == self::$cookie->id_customer)
|
||||
{
|
||||
$id_order_state = (int)($order->getCurrentState());
|
||||
$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();
|
||||
|
||||
$customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart));
|
||||
Product::addCustomizationPrice($products, $customizedDatas);
|
||||
|
||||
$customer = new Customer($order->id_customer);
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'shop_name' => strval(Configuration::get('PS_SHOP_NAME')),
|
||||
'order' => $order,
|
||||
'return_allowed' => (int)($order->isReturnable()),
|
||||
'currency' => new Currency($order->id_currency),
|
||||
'order_state' => (int)($id_order_state),
|
||||
'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')),
|
||||
'invoice' => (OrderState::invoiceAvailable((int)($id_order_state)) AND $order->invoice_number),
|
||||
'order_history' => $order->getHistory((int)(self::$cookie->id_lang), false, true),
|
||||
'products' => $products,
|
||||
'discounts' => $order->getDiscounts(),
|
||||
'carrier' => $carrier,
|
||||
'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)),
|
||||
'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_,
|
||||
'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_,
|
||||
'use_tax' => Configuration::get('PS_TAX'),
|
||||
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
|
||||
'customizedDatas' => $customizedDatas));
|
||||
if ($carrier->url AND $order->shipping_number)
|
||||
self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
|
||||
self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
|
||||
Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('Cannot find this order');
|
||||
}
|
||||
}
|
||||
|
||||
public function displayHeader()
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayHeader();
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'order-detail.tpl');
|
||||
}
|
||||
|
||||
public function displayFooter()
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayFooter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class OrderFollowControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = true;
|
||||
$this->php_self = 'order-follow.php';
|
||||
$this->authRedirection = 'order-follow.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
if (Tools::isSubmit('submitReturnMerchandise'))
|
||||
{
|
||||
$customizationQtyInput = Tools::getValue('customization_qty_input');
|
||||
|
||||
if (!$id_order = (int)(Tools::getValue('id_order')))
|
||||
Tools::redirect('index.php?controller=history');
|
||||
if (!$order_qte_input = Tools::getValue('order_qte_input'))
|
||||
Tools::redirect('index.php?controller=order-follow&errorDetail1');
|
||||
if ($customizationIds = Tools::getValue('customization_ids') AND !$customizationQtyInput)
|
||||
Tools::redirect('index.php?controller=order-follow&errorDetail1');
|
||||
if (!$ids_order_detail = Tools::getValue('ids_order_detail') AND !$customizationIds)
|
||||
Tools::redirect('index.php?controller=order-follow&errorDetail2');
|
||||
|
||||
$order = new Order((int)($id_order));
|
||||
if (!$order->isReturnable()) Tools::redirect('index.php?controller=order-follow&errorNotReturnable');
|
||||
if ($order->id_customer != self::$cookie->id_customer)
|
||||
die(Tools::displayError());
|
||||
$orderReturn = new OrderReturn();
|
||||
$orderReturn->id_customer = (int)(self::$cookie->id_customer);
|
||||
$orderReturn->id_order = $id_order;
|
||||
$orderReturn->question = strval(Tools::getValue('returnText'));
|
||||
if (empty($orderReturn->question))
|
||||
Tools::redirect('index.php?controller=order-follow&errorMsg');
|
||||
if (!$orderReturn->checkEnoughProduct($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput))
|
||||
Tools::redirect('index.php?controller=order-follow&errorQuantity');
|
||||
|
||||
$orderReturn->state = 1;
|
||||
$orderReturn->add();
|
||||
$orderReturn->addReturnDetail($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput);
|
||||
Module::hookExec('orderReturn', array('orderReturn' => $orderReturn));
|
||||
Tools::redirect('index.php?controller=order-follow');
|
||||
}
|
||||
|
||||
$ordersReturn = OrderReturn::getOrdersReturn((int)(self::$cookie->id_customer));
|
||||
if (Tools::isSubmit('errorQuantity'))
|
||||
self::$smarty->assign('errorQuantity', true);
|
||||
elseif (Tools::isSubmit('errorMsg'))
|
||||
self::$smarty->assign('errorMsg', true);
|
||||
elseif (Tools::isSubmit('errorDetail1'))
|
||||
self::$smarty->assign('errorDetail1', true);
|
||||
elseif (Tools::isSubmit('errorDetail2'))
|
||||
self::$smarty->assign('errorDetail2', true);
|
||||
elseif (Tools::isSubmit('errorNotReturnable'))
|
||||
self::$smarty->assign('errorNotReturnable',true);
|
||||
|
||||
self::$smarty->assign('ordersReturn', $ordersReturn);
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'history.css');
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
|
||||
Tools::addJS(array(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js', _THEME_JS_DIR_.'history.js'));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'order-follow.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,479 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
ControllerFactory::includeController('ParentOrderController');
|
||||
|
||||
class OrderOpcControllerCore extends ParentOrderController
|
||||
{
|
||||
public $isLogged;
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
if ($this->nbProducts)
|
||||
self::$smarty->assign('virtual_cart', false);
|
||||
$this->isLogged = (bool)((int)(self::$cookie->id_customer) AND Customer::customerIdExistsStatic((int)(self::$cookie->id_customer)));
|
||||
|
||||
if (self::$cart->nbProducts())
|
||||
{
|
||||
if (Tools::isSubmit('ajax'))
|
||||
{
|
||||
if (Tools::isSubmit('method'))
|
||||
{
|
||||
switch (Tools::getValue('method'))
|
||||
{
|
||||
case 'updateMessage':
|
||||
if (Tools::isSubmit('message'))
|
||||
{
|
||||
$txtMessage = urldecode(Tools::getValue('message'));
|
||||
$this->_updateMessage($txtMessage);
|
||||
if (sizeof($this->errors))
|
||||
die('{"hasError" : true, "errors" : ["'.implode('\',\'', $this->errors).'"]}');
|
||||
die(true);
|
||||
}
|
||||
break;
|
||||
case 'updateCarrierAndGetPayments':
|
||||
if (Tools::isSubmit('id_carrier') AND Tools::isSubmit('recyclable') AND Tools::isSubmit('gift') AND Tools::isSubmit('gift_message'))
|
||||
{
|
||||
if ($this->_processCarrier())
|
||||
{
|
||||
$return = array(
|
||||
'summary' => self::$cart->getSummaryDetails(),
|
||||
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
|
||||
'HOOK_PAYMENT' => self::_getPaymentMethods()
|
||||
);
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('Error occurred updating cart.');
|
||||
if (sizeof($this->errors))
|
||||
die('{"hasError" : true, "errors" : ["'.implode('\',\'', $this->errors).'"]}');
|
||||
exit;
|
||||
}
|
||||
break;
|
||||
case 'updateTOSStatusAndGetPayments':
|
||||
if (Tools::isSubmit('checked'))
|
||||
{
|
||||
self::$cookie->checkedTOS = (int)(Tools::getValue('checked'));
|
||||
die(Tools::jsonEncode(array(
|
||||
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
|
||||
'HOOK_PAYMENT' => self::_getPaymentMethods()
|
||||
)));
|
||||
}
|
||||
break;
|
||||
case 'getCarrierList':
|
||||
die(Tools::jsonEncode(self::_getCarrierList()));
|
||||
break;
|
||||
case 'editCustomer':
|
||||
if (!$this->isLogged)
|
||||
exit;
|
||||
$customer = new Customer((int)self::$cookie->id_customer);
|
||||
if (Tools::getValue('years'))
|
||||
$customer->birthday = (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days');
|
||||
$_POST['lastname'] = $_POST['customer_lastname'];
|
||||
$_POST['firstname'] = $_POST['customer_firstname'];
|
||||
$this->errors = $customer->validateControler();
|
||||
$customer->newsletter = (int)Tools::isSubmit('newsletter');
|
||||
$customer->optin = (int)Tools::isSubmit('optin');
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'id_customer' => (int)self::$cookie->id_customer,
|
||||
'token' => Tools::getToken(false)
|
||||
);
|
||||
if (!sizeof($this->errors))
|
||||
$return['isSaved'] = (bool)$customer->update();
|
||||
else
|
||||
$return['isSaved'] = false;
|
||||
die(Tools::jsonEncode($return));
|
||||
break;
|
||||
case 'getAddressBlockAndCarriersAndPayments':
|
||||
if (self::$cookie->isLogged())
|
||||
{
|
||||
if (file_exists(_PS_MODULE_DIR_.'blockuserinfo/blockuserinfo.php'))
|
||||
{
|
||||
include_once(_PS_MODULE_DIR_.'blockuserinfo/blockuserinfo.php');
|
||||
$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'));
|
||||
$wrapping_fees_tax = new Tax((int)(Configuration::get('PS_GIFT_WRAPPING_TAX')));
|
||||
$wrapping_fees_tax_inc = $wrapping_fees * (1 + (((float)($wrapping_fees_tax->rate) / 100)));
|
||||
$return = array(
|
||||
'order_opc_adress' => self::$smarty->fetch(_PS_THEME_DIR_.'order-address.tpl'),
|
||||
'block_user_info' => (isset($blockUserInfo) ? $blockUserInfo->hookTop(array()) : ''),
|
||||
'carrier_list' => self::_getCarrierList(),
|
||||
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
|
||||
'HOOK_PAYMENT' => self::_getPaymentMethods(),
|
||||
'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int)(self::$cookie->id_currency))))
|
||||
);
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
die(Tools::displayError());
|
||||
break;
|
||||
case 'makeFreeOrder':
|
||||
/* Bypass payment step if total is 0 */
|
||||
if (($id_order = $this->_checkFreeOrder()) AND $id_order)
|
||||
{
|
||||
$email = self::$cookie->email;
|
||||
if (self::$cookie->is_guest)
|
||||
self::$cookie->logout(); // If guest we clear the cookie for security reason
|
||||
die('freeorder:'.$id_order.':'.$email);
|
||||
}
|
||||
exit;
|
||||
break;
|
||||
case 'updateAddressesSelected':
|
||||
$id_address_delivery = (int)(Tools::getValue('id_address_delivery'));
|
||||
$id_address_invoice = (int)(Tools::getValue('id_address_invoice'));
|
||||
$address_delivery = new Address((int)(Tools::getValue('id_address_delivery')));
|
||||
$address_invoice = ((int)(Tools::getValue('id_address_delivery')) == (int)(Tools::getValue('id_address_invoice')) ? $address_delivery : new Address((int)(Tools::getValue('id_address_invoice'))));
|
||||
|
||||
if (!Address::isCountryActiveById((int)(Tools::getValue('id_address_delivery'))))
|
||||
$this->errors[] = Tools::displayError('This address is not in a valid area.');
|
||||
elseif (!Validate::isLoadedObject($address_delivery) OR !Validate::isLoadedObject($address_invoice) OR $address_invoice->deleted OR $address_delivery->deleted)
|
||||
$this->errors[] = Tools::displayError('This address is invalid.');
|
||||
else
|
||||
{
|
||||
self::$cart->id_address_delivery = (int)(Tools::getValue('id_address_delivery'));
|
||||
self::$cart->id_address_invoice = Tools::isSubmit('same') ? self::$cart->id_address_delivery : (int)(Tools::getValue('id_address_invoice'));
|
||||
if (!self::$cart->update())
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating your cart.');
|
||||
if (!sizeof($this->errors))
|
||||
{
|
||||
if (self::$cookie->id_customer)
|
||||
{
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
$groups = $customer->getGroups();
|
||||
}
|
||||
else
|
||||
$groups = array(1);
|
||||
$result = self::_getCarrierList();
|
||||
// Wrapping fees
|
||||
$wrapping_fees = (float)(Configuration::get('PS_GIFT_WRAPPING_PRICE'));
|
||||
$wrapping_fees_tax = new Tax((int)(Configuration::get('PS_GIFT_WRAPPING_TAX')));
|
||||
$wrapping_fees_tax_inc = $wrapping_fees * (1 + (((float)($wrapping_fees_tax->rate) / 100)));
|
||||
$result = array_merge($result, array(
|
||||
'summary' => self::$cart->getSummaryDetails(),
|
||||
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
|
||||
'HOOK_PAYMENT' => self::_getPaymentMethods(),
|
||||
'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int)(self::$cookie->id_currency))))
|
||||
));
|
||||
die(Tools::jsonEncode($result));
|
||||
}
|
||||
}
|
||||
if (sizeof($this->errors))
|
||||
die('{"hasError" : true, "errors" : ["'.implode('\',\'', $this->errors).'"]}');
|
||||
break;
|
||||
default:
|
||||
exit;
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
elseif (Tools::isSubmit('ajax'))
|
||||
exit;
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
|
||||
// Adding CSS style sheet
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'order-opc.css');
|
||||
// Adding JS files
|
||||
Tools::addJS(_THEME_JS_DIR_.'order-opc.js');
|
||||
Tools::addJs(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js');
|
||||
Tools::addJS(_THEME_JS_DIR_.'tools/statesManagement.js');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
// SHOPPING CART
|
||||
$this->_assignSummaryInformations();
|
||||
// WRAPPING AND TOS
|
||||
$this->_assignWrappingAndTOS();
|
||||
|
||||
$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
$countries = Country::getCountries((int)(self::$cookie->id_lang), true);
|
||||
self::$smarty->assign(array(
|
||||
'isLogged' => $this->isLogged,
|
||||
'isGuest' => isset(self::$cookie->is_guest) ? self::$cookie->is_guest : 0,
|
||||
'countries' => $countries,
|
||||
'sl_country' => isset($selectedCountry) ? $selectedCountry : 0,
|
||||
'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'),
|
||||
'errorCarrier' => Tools::displayError('You must choose a carrier before', false),
|
||||
'errorTOS' => Tools::displayError('You must accept terms of service before', false),
|
||||
'isPaymentStep' => (bool)(isset($_GET['isPaymentStep']) AND $_GET['isPaymentStep'])
|
||||
));
|
||||
$years = Tools::dateYears();
|
||||
$months = Tools::dateMonths();
|
||||
$days = Tools::dateDays();
|
||||
self::$smarty->assign(array(
|
||||
'years' => $years,
|
||||
'months' => $months,
|
||||
'days' => $days,
|
||||
));
|
||||
|
||||
/* Load guest informations */
|
||||
if ($this->isLogged AND self::$cookie->is_guest)
|
||||
self::$smarty->assign('guestInformations', $this->_getGuestInformations());
|
||||
|
||||
if ($this->isLogged)
|
||||
$this->_assignAddress(); // ADDRESS
|
||||
// CARRIER
|
||||
$this->_assignCarrier();
|
||||
// PAYMENT
|
||||
$this->_assignPayment();
|
||||
Tools::safePostVars();
|
||||
|
||||
self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
|
||||
}
|
||||
|
||||
public function displayHeader()
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayHeader();
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
|
||||
$this->_processAddressFormat();
|
||||
|
||||
self::$smarty->display(_PS_THEME_DIR_.'errors.tpl');
|
||||
self::$smarty->display(_PS_THEME_DIR_.'order-opc.tpl');
|
||||
}
|
||||
|
||||
public function displayFooter()
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayFooter();
|
||||
}
|
||||
|
||||
protected function _getGuestInformations()
|
||||
{
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
$address_delivery = new Address((int)self::$cart->id_address_delivery);
|
||||
|
||||
if ($customer->birthday)
|
||||
$birthday = explode('-', $customer->birthday);
|
||||
else
|
||||
$birthday = array('0', '0', '0');
|
||||
|
||||
return array(
|
||||
'id_customer' => (int)(self::$cookie->id_customer),
|
||||
'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)self::$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),
|
||||
'postcode' => Tools::htmlentitiesUTF8($address_delivery->postcode),
|
||||
'city' => Tools::htmlentitiesUTF8($address_delivery->city),
|
||||
'phone' => Tools::htmlentitiesUTF8($address_delivery->phone),
|
||||
'phone_mobile' => Tools::htmlentitiesUTF8($address_delivery->phone_mobile),
|
||||
'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]
|
||||
);
|
||||
}
|
||||
|
||||
protected function _assignCarrier()
|
||||
{
|
||||
if (!$this->isLogged)
|
||||
{
|
||||
$carriers = Carrier::getCarriersForOrder(Country::getIdZone((int)Configuration::get('PS_COUNTRY_DEFAULT')));
|
||||
self::$smarty->assign(array(
|
||||
'checked' => $this->_setDefaultCarrierSelection($carriers),
|
||||
'carriers' => $carriers,
|
||||
'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT')),
|
||||
'HOOK_EXTRACARRIER' => NULL,
|
||||
'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers))
|
||||
));
|
||||
}
|
||||
else
|
||||
parent::_assignCarrier();
|
||||
}
|
||||
|
||||
protected function _assignPayment()
|
||||
{
|
||||
self::$smarty->assign(array(
|
||||
'HOOK_TOP_PAYMENT' => ($this->isLogged ? Module::hookExec('paymentTop') : ''),
|
||||
'HOOK_PAYMENT' => self::_getPaymentMethods()
|
||||
));
|
||||
}
|
||||
|
||||
protected function _getPaymentMethods()
|
||||
{
|
||||
if (!$this->isLogged)
|
||||
return '<p class="warning">'.Tools::displayError('Please sign in to see payment methods').'</p>';
|
||||
if (self::$cart->OrderExists())
|
||||
return '<p class="warning">'.Tools::displayError('Error: this order is already validated').'</p>';
|
||||
if (!self::$cart->id_customer OR !Customer::customerIdExistsStatic(self::$cart->id_customer) OR Customer::isBanned(self::$cart->id_customer))
|
||||
return '<p class="warning">'.Tools::displayError('Error: no customer').'</p>';
|
||||
$address_delivery = new Address(self::$cart->id_address_delivery);
|
||||
$address_invoice = (self::$cart->id_address_delivery == self::$cart->id_address_invoice ? $address_delivery : new Address(self::$cart->id_address_invoice));
|
||||
if (!self::$cart->id_address_delivery OR !self::$cart->id_address_invoice OR !Validate::isLoadedObject($address_delivery) OR !Validate::isLoadedObject($address_invoice) OR $address_invoice->deleted OR $address_delivery->deleted)
|
||||
return '<p class="warning">'.Tools::displayError('Error: please choose an address').'</p>';
|
||||
if (!self::$cart->id_carrier AND !self::$cart->isVirtualCart())
|
||||
return '<p class="warning">'.Tools::displayError('Error: please choose a carrier').'</p>';
|
||||
elseif (self::$cart->id_carrier != 0)
|
||||
{
|
||||
$carrier = new Carrier((int)(self::$cart->id_carrier));
|
||||
if (!Validate::isLoadedObject($carrier) OR $carrier->deleted OR !$carrier->active)
|
||||
return '<p class="warning">'.Tools::displayError('Error: the carrier is invalid').'</p>';
|
||||
}
|
||||
if (!self::$cart->id_currency)
|
||||
return '<p class="warning">'.Tools::displayError('Error: no currency has been selected').'</p>';
|
||||
if (!self::$cookie->checkedTOS AND Configuration::get('PS_CONDITIONS'))
|
||||
return '<p class="warning">'.Tools::displayError('Please accept Terms of Service').'</p>';
|
||||
|
||||
/* If some products have disappear */
|
||||
if (!self::$cart->checkQuantities())
|
||||
return '<p class="warning">'.Tools::displayError('An item in your cart is no longer available, you cannot proceed with your order.').'</p>';
|
||||
|
||||
/* Check minimal amount */
|
||||
$currency = Currency::getCurrency((int)self::$cart->id_currency);
|
||||
|
||||
$orderTotal = self::$cart->getOrderTotal();
|
||||
$minimalPurchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
|
||||
if ($orderTotal < $minimalPurchase)
|
||||
return '<p class="warning">'.Tools::displayError('A minimum purchase total of').' '.Tools::displayPrice($minimalPurchase, $currency).
|
||||
' '.Tools::displayError('is required in order to validate your order.').'</p>';
|
||||
|
||||
/* Bypass payment step if total is 0 */
|
||||
if (self::$cart->getOrderTotal() <= 0)
|
||||
return '<p class="center"><input type="button" class="exclusive_large" name="confirmOrder" id="confirmOrder" value="'.Tools::displayError('I confirm my order').'" onclick="confirmFreeOrder();" /></p>';
|
||||
|
||||
$return = Module::hookExecPayment();
|
||||
if (!$return)
|
||||
return '<p class="warning">'.Tools::displayError('No payment method is available').'</p>';
|
||||
return $return;
|
||||
}
|
||||
|
||||
protected function _getCarrierList()
|
||||
{
|
||||
$address_delivery = new Address(self::$cart->id_address_delivery);
|
||||
if (self::$cookie->id_customer)
|
||||
{
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
$groups = $customer->getGroups();
|
||||
}
|
||||
else
|
||||
$groups = array(1);
|
||||
if (!Address::isCountryActiveById((int)(self::$cart->id_address_delivery)))
|
||||
$this->errors[] = Tools::displayError('This address is not in a valid area.');
|
||||
elseif (!Validate::isLoadedObject($address_delivery) OR $address_delivery->deleted)
|
||||
$this->errors[] = Tools::displayError('This address is invalid.');
|
||||
else
|
||||
{
|
||||
$carriers = Carrier::getCarriersForOrder((int)Address::getZoneById((int)($address_delivery->id)), $groups);
|
||||
$result = array(
|
||||
'checked' => $this->_setDefaultCarrierSelection($carriers),
|
||||
'carriers' => $carriers,
|
||||
'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers)),
|
||||
'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address_delivery))
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
if (sizeof($this->errors))
|
||||
return array(
|
||||
'hasError' => true,
|
||||
'errors' => $this->errors
|
||||
);
|
||||
}
|
||||
|
||||
protected function _setDefaultCarrierSelection($carriers)
|
||||
{
|
||||
if (sizeof($carriers))
|
||||
{
|
||||
$defaultCarrierIsPresent = false;
|
||||
if (self::$cart->id_carrier != 0)
|
||||
foreach ($carriers AS $carrier)
|
||||
if ($carrier['id_carrier'] == self::$cart->id_carrier)
|
||||
{
|
||||
$defaultCarrierIsPresent = true;
|
||||
self::$cart->id_carrier = $carrier['id_carrier'];
|
||||
}
|
||||
if (!$defaultCarrierIsPresent)
|
||||
foreach ($carriers AS $carrier)
|
||||
if ($carrier['id_carrier'] == Configuration::get('PS_CARRIER_DEFAULT'))
|
||||
{
|
||||
$defaultCarrierIsPresent = true;
|
||||
self::$cart->id_carrier = $carrier['id_carrier'];
|
||||
}
|
||||
if (!$defaultCarrierIsPresent)
|
||||
self::$cart->id_carrier = $carriers[0]['id_carrier'];
|
||||
}
|
||||
else
|
||||
self::$cart->id_carrier = 0;
|
||||
if (self::$cart->update())
|
||||
return self::$cart->id_carrier;
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function _processAddressFormat()
|
||||
{
|
||||
$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
|
||||
$address_delivery = new Address((int)self::$cart->id_address_delivery);
|
||||
$address_invoice = new Address((int)self::$cart->id_address_invoice);
|
||||
|
||||
$inv_adr_fields = AddressFormat::getOrderedAddressFields((int)$address_delivery->id_country);
|
||||
$dlv_adr_fields = AddressFormat::getOrderedAddressFields((int)$address_invoice->id_country);
|
||||
|
||||
$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'});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class OrderReturnControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = true;
|
||||
$this->php_self = 'order-return.php';
|
||||
$this->authRedirection = 'order-follow.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
if (!isset($_GET['id_order_return']) OR !Validate::isUnsignedId($_GET['id_order_return']))
|
||||
$this->errors[] = Tools::displayError('Order ID required');
|
||||
else
|
||||
{
|
||||
$orderRet = new OrderReturn((int)($_GET['id_order_return']));
|
||||
if (Validate::isLoadedObject($orderRet) AND $orderRet->id_customer == self::$cookie->id_customer)
|
||||
{
|
||||
$order = new Order((int)($orderRet->id_order));
|
||||
if (Validate::isLoadedObject($order))
|
||||
{
|
||||
$state = new OrderReturnState((int)($orderRet->state));
|
||||
self::$smarty->assign(array(
|
||||
'orderRet' => $orderRet,
|
||||
'order' => $order,
|
||||
'state_name' => $state->name[(int)(self::$cookie->id_lang)],
|
||||
'return_allowed' => false,
|
||||
'products' => OrderReturn::getOrdersReturnProducts((int)($orderRet->id), $order),
|
||||
'returnedCustomizations' => OrderReturn::getReturnedCustomizedProducts((int)($orderRet->id_order)),
|
||||
'customizedDatas' => Product::getAllCustomizedDatas((int)($order->id_cart))
|
||||
));
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('Cannot find this order return');
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('Cannot find this order return');
|
||||
}
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'errors' => $this->errors,
|
||||
'nbdaysreturn' => (int)(Configuration::get('PS_ORDER_RETURN_NB_DAYS'))
|
||||
));
|
||||
}
|
||||
|
||||
public function displayHeader()
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayHeader();
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'order-return.tpl');
|
||||
}
|
||||
|
||||
public function displayFooter()
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayFooter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class OrderSlipControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->auth = true;
|
||||
$this->php_self = 'order-slip.php';
|
||||
$this->authRedirection = 'order-slip.php';
|
||||
$this->ssl = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'history.css');
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
|
||||
Tools::addJS(array(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js',_THEME_JS_DIR_.'history.js'));
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
self::$smarty->assign('ordersSlip', OrderSlip::getOrdersSlip((int)(self::$cookie->id_customer)));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'order-slip.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class PageNotFoundControllerCore extends FrontController
|
||||
{
|
||||
public function displayContent()
|
||||
{
|
||||
self::$smarty->display(_PS_THEME_DIR_.'404.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,392 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
/* Class FreeOrder to use PaymentModule (abstract class, cannot be instancied) */
|
||||
class FreeOrder extends PaymentModule {}
|
||||
|
||||
class ParentOrderControllerCore extends FrontController
|
||||
{
|
||||
public $nbProducts;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ssl = true;
|
||||
parent::__construct();
|
||||
|
||||
/* Disable some cache related bugs on the cart/order */
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->nbProducts = self::$cart->nbProducts();
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
global $isVirtualCart;
|
||||
|
||||
parent::preProcess();
|
||||
|
||||
// Redirect to the good order process
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 AND Tools::getValue('controller') != 'order')
|
||||
Tools::redirect('index.php?controller=order');
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1 AND Tools::getValue('controller') != 'order-opc')
|
||||
{
|
||||
if (isset($_GET['step']) AND $_GET['step'] == 3)
|
||||
Tools::redirect('index.php?controller=order-opc&isPaymentStep=true');
|
||||
Tools::redirect('index.php?controller=order-opc');
|
||||
}
|
||||
|
||||
if (Configuration::get('PS_CATALOG_MODE'))
|
||||
$this->errors[] = Tools::displayError('This store has not accepted your new order.');
|
||||
|
||||
if (Tools::isSubmit('submitReorder') AND $id_order = (int)Tools::getValue('id_order'))
|
||||
{
|
||||
$oldCart = new Cart(Order::getCartIdStatic((int)$id_order, (int)self::$cookie->id_customer));
|
||||
$duplication = $oldCart->duplicate();
|
||||
if (!$duplication OR !Validate::isLoadedObject($duplication['cart']))
|
||||
$this->errors[] = Tools::displayError('Sorry, we cannot renew your order.');
|
||||
elseif (!$duplication['success'])
|
||||
$this->errors[] = Tools::displayError('Missing items - we are unable renew your order');
|
||||
else
|
||||
{
|
||||
self::$cookie->id_cart = $duplication['cart']->id;
|
||||
self::$cookie->write();
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
|
||||
Tools::redirect('index.php?controller=order-opc');
|
||||
Tools::redirect('index.php?controller=order');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->nbProducts)
|
||||
{
|
||||
if (Tools::isSubmit('submitAddDiscount') AND Tools::getValue('discount_name'))
|
||||
{
|
||||
$discountName = Tools::getValue('discount_name');
|
||||
if (!Validate::isDiscountName($discountName))
|
||||
$this->errors[] = Tools::displayError('Voucher name invalid.');
|
||||
else
|
||||
{
|
||||
$discount = new Discount((int)(Discount::getIdByName($discountName)));
|
||||
if (Validate::isLoadedObject($discount))
|
||||
{
|
||||
if ($tmpError = self::$cart->checkDiscountValidity($discount, self::$cart->getDiscounts(), self::$cart->getOrderTotal(), self::$cart->getProducts(), true))
|
||||
$this->errors[] = $tmpError;
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('Voucher name invalid.');
|
||||
if (!sizeof($this->errors))
|
||||
{
|
||||
self::$cart->addDiscount((int)($discount->id));
|
||||
Tools::redirect('index.php?controller=order-opc');
|
||||
}
|
||||
}
|
||||
self::$smarty->assign(array(
|
||||
'errors' => $this->errors,
|
||||
'discount_name' => Tools::safeOutput($discountName)
|
||||
));
|
||||
}
|
||||
elseif (isset($_GET['deleteDiscount']) AND Validate::isUnsignedId($_GET['deleteDiscount']))
|
||||
{
|
||||
self::$cart->deleteDiscount((int)($_GET['deleteDiscount']));
|
||||
Tools::redirect('index.php?controller=order-opc');
|
||||
}
|
||||
|
||||
/* Is there only virtual product in cart */
|
||||
if ($isVirtualCart = self::$cart->isVirtualCart())
|
||||
$this->_setNoCarrier();
|
||||
}
|
||||
|
||||
self::$smarty->assign('back', Tools::safeOutput(Tools::getValue('back')));
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
|
||||
// Adding CSS style sheet
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
|
||||
Tools::addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen');
|
||||
|
||||
// Adding JS files
|
||||
Tools::addJS(_THEME_JS_DIR_.'tools.js');
|
||||
if ((Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 AND Tools::getValue('step') == 1) OR Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
|
||||
Tools::addJS(_THEME_JS_DIR_.'order-address.js');
|
||||
Tools::addJS(_PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js');
|
||||
if ((int)(Configuration::get('PS_BLOCK_CART_AJAX')) OR Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
|
||||
{
|
||||
Tools::addJS(_THEME_JS_DIR_.'cart-summary.js');
|
||||
Tools::addJS(_PS_JS_DIR_.'jquery/jquery-typewatch.pack.js');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _checkFreeOrder()
|
||||
{
|
||||
if (self::$cart->getOrderTotal() <= 0)
|
||||
{
|
||||
$order = new FreeOrder();
|
||||
$order->free_order_class = true;
|
||||
$order->validateOrder((int)(self::$cart->id), _PS_OS_PAYMENT_, 0, Tools::displayError('Free order', false));
|
||||
return (int)Order::getOrderByCartId((int)self::$cart->id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function _updateMessage($messageContent)
|
||||
{
|
||||
if ($messageContent)
|
||||
{
|
||||
if (!Validate::isMessage($messageContent))
|
||||
$this->errors[] = Tools::displayError('Invalid message');
|
||||
elseif ($oldMessage = Message::getMessageByCartId((int)(self::$cart->id)))
|
||||
{
|
||||
$message = new Message((int)($oldMessage['id_message']));
|
||||
$message->message = htmlentities($messageContent, ENT_COMPAT, 'UTF-8');
|
||||
$message->update();
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = new Message();
|
||||
$message->message = htmlentities($messageContent, ENT_COMPAT, 'UTF-8');
|
||||
$message->id_cart = (int)(self::$cart->id);
|
||||
$message->id_customer = (int)(self::$cart->id_customer);
|
||||
$message->add();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($oldMessage = Message::getMessageByCartId((int)(self::$cart->id)))
|
||||
{
|
||||
$message = new Message((int)($oldMessage['id_message']));
|
||||
$message->delete();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function _processCarrier()
|
||||
{
|
||||
self::$cart->recyclable = (int)(Tools::getValue('recyclable'));
|
||||
self::$cart->gift = (int)(Tools::getValue('gift'));
|
||||
if ((int)(Tools::getValue('gift')))
|
||||
{
|
||||
if (!Validate::isMessage($_POST['gift_message']))
|
||||
$this->errors[] = Tools::displayError('Invalid gift message');
|
||||
else
|
||||
self::$cart->gift_message = strip_tags($_POST['gift_message']);
|
||||
}
|
||||
|
||||
if (isset(self::$cookie->id_customer) AND self::$cookie->id_customer)
|
||||
{
|
||||
$address = new Address((int)(self::$cart->id_address_delivery));
|
||||
if (!($id_zone = Address::getZoneById($address->id)))
|
||||
$this->errors[] = Tools::displayError('No zone match with your address');
|
||||
}
|
||||
else
|
||||
$id_zone = Country::getIdZone((int)Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
|
||||
if (Validate::isInt(Tools::getValue('id_carrier')) AND sizeof(Carrier::checkCarrierZone((int)(Tools::getValue('id_carrier')), (int)($id_zone))))
|
||||
self::$cart->id_carrier = (int)(Tools::getValue('id_carrier'));
|
||||
elseif (!self::$cart->isVirtualCart() AND (int)(Tools::getValue('id_carrier')) == 0)
|
||||
$this->errors[] = Tools::displayError('Invalid carrier or no carrier selected');
|
||||
|
||||
Module::hookExec('processCarrier', array('cart' => self::$cart));
|
||||
|
||||
return self::$cart->update();
|
||||
}
|
||||
|
||||
protected function _assignSummaryInformations()
|
||||
{
|
||||
global $currency;
|
||||
|
||||
if (file_exists(_PS_SHIP_IMG_DIR_.(int)(self::$cart->id_carrier).'.jpg'))
|
||||
self::$smarty->assign('carrierPicture', 1);
|
||||
$summary = self::$cart->getSummaryDetails();
|
||||
$customizedDatas = Product::getAllCustomizedDatas((int)(self::$cart->id));
|
||||
Product::addCustomizationPrice($summary['products'], $customizedDatas);
|
||||
|
||||
if ($free_ship = Tools::convertPrice((float)(Configuration::get('PS_SHIPPING_FREE_PRICE')), new Currency((int)(self::$cart->id_currency))))
|
||||
{
|
||||
$discounts = self::$cart->getDiscounts();
|
||||
$total_free_ship = $free_ship - ($summary['total_products_wt'] + $summary['total_discounts']);
|
||||
foreach ($discounts as $discount)
|
||||
if ($discount['id_discount_type'] == 3)
|
||||
{
|
||||
$total_free_ship = 0;
|
||||
break;
|
||||
}
|
||||
self::$smarty->assign('free_ship', $total_free_ship);
|
||||
}
|
||||
// for compatibility with 1.2 themes
|
||||
foreach($summary['products'] AS $key => $product)
|
||||
$summary['products'][$key]['quantity'] = $product['cart_quantity'];
|
||||
self::$smarty->assign($summary);
|
||||
self::$smarty->assign(array(
|
||||
'token_cart' => Tools::getToken(false),
|
||||
'isVirtualCart' => self::$cart->isVirtualCart(),
|
||||
'productNumber' => self::$cart->nbProducts(),
|
||||
'voucherAllowed' => Configuration::get('PS_VOUCHERS'),
|
||||
'shippingCost' => self::$cart->getOrderTotal(true, Cart::ONLY_SHIPPING),
|
||||
'shippingCostTaxExc' => self::$cart->getOrderTotal(false, Cart::ONLY_SHIPPING),
|
||||
'customizedDatas' => $customizedDatas,
|
||||
'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_,
|
||||
'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_,
|
||||
'lastProductAdded' => self::$cart->getLastProduct(),
|
||||
'displayVouchers' => Discount::getVouchersToCartDisplay((int)(self::$cookie->id_lang), (isset(self::$cookie->id_customer) ? (int)(self::$cookie->id_customer) : 0)),
|
||||
'currencySign' => $currency->sign,
|
||||
'currencyRate' => $currency->conversion_rate,
|
||||
'currencyFormat' => $currency->format,
|
||||
'currencyBlank' => $currency->blank));
|
||||
self::$smarty->assign(array(
|
||||
'HOOK_SHOPPING_CART' => Module::hookExec('shoppingCart', $summary),
|
||||
'HOOK_SHOPPING_CART_EXTRA' => Module::hookExec('shoppingCartExtra', $summary)
|
||||
));
|
||||
}
|
||||
|
||||
protected function _assignAddress()
|
||||
{
|
||||
if (!Customer::getAddressesTotalById((int)(self::$cookie->id_customer)))
|
||||
Tools::redirect('index.php?controller=address&back=order.php&step=1');
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
if (Validate::isLoadedObject($customer))
|
||||
{
|
||||
/* Getting customer addresses */
|
||||
$customerAddresses = $customer->getAddresses((int)(self::$cookie->id_lang));
|
||||
self::$smarty->assign('addresses', $customerAddresses);
|
||||
|
||||
/* Setting default addresses for cart */
|
||||
if ((!isset(self::$cart->id_address_delivery) OR empty(self::$cart->id_address_delivery)) AND sizeof($customerAddresses))
|
||||
{
|
||||
self::$cart->id_address_delivery = (int)($customerAddresses[0]['id_address']);
|
||||
$update = 1;
|
||||
}
|
||||
if ((!isset(self::$cart->id_address_invoice) OR empty(self::$cart->id_address_invoice)) AND sizeof($customerAddresses))
|
||||
{
|
||||
self::$cart->id_address_invoice = (int)($customerAddresses[0]['id_address']);
|
||||
$update = 1;
|
||||
}
|
||||
/* Update cart addresses only if needed */
|
||||
if (isset($update) AND $update)
|
||||
self::$cart->update();
|
||||
|
||||
/* If delivery address is valid in cart, assign it to Smarty */
|
||||
if (isset(self::$cart->id_address_delivery))
|
||||
{
|
||||
$deliveryAddress = new Address((int)(self::$cart->id_address_delivery));
|
||||
if (Validate::isLoadedObject($deliveryAddress) AND ($deliveryAddress->id_customer == $customer->id))
|
||||
self::$smarty->assign('delivery', $deliveryAddress);
|
||||
}
|
||||
|
||||
/* If invoice address is valid in cart, assign it to Smarty */
|
||||
if (isset(self::$cart->id_address_invoice))
|
||||
{
|
||||
$invoiceAddress = new Address((int)(self::$cart->id_address_invoice));
|
||||
if (Validate::isLoadedObject($invoiceAddress) AND ($invoiceAddress->id_customer == $customer->id))
|
||||
self::$smarty->assign('invoice', $invoiceAddress);
|
||||
}
|
||||
}
|
||||
if ($oldMessage = Message::getMessageByCartId((int)(self::$cart->id)))
|
||||
self::$smarty->assign('oldMessage', $oldMessage['message']);
|
||||
}
|
||||
|
||||
protected function _assignCarrier()
|
||||
{
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
$address = new Address((int)(self::$cart->id_address_delivery));
|
||||
$id_zone = Address::getZoneById((int)($address->id));
|
||||
$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups());
|
||||
|
||||
$checked = 0;
|
||||
if (Validate::isUnsignedInt(self::$cart->id_carrier) AND self::$cart->id_carrier)
|
||||
{
|
||||
$carrier = new Carrier((int)(self::$cart->id_carrier));
|
||||
if ($carrier->active AND !$carrier->deleted)
|
||||
$checked = (int)(self::$cart->id_carrier);
|
||||
}
|
||||
self::$smarty->assign(array(
|
||||
'checked' => (int)($checked),
|
||||
'carriers' => $carriers,
|
||||
'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT')),
|
||||
'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address)),
|
||||
'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers))
|
||||
));
|
||||
}
|
||||
|
||||
protected function _assignWrappingAndTOS()
|
||||
{
|
||||
// Wrapping fees
|
||||
$wrapping_fees = (float)(Configuration::get('PS_GIFT_WRAPPING_PRICE'));
|
||||
$wrapping_fees_tax = new Tax((int)(Configuration::get('PS_GIFT_WRAPPING_TAX')));
|
||||
$wrapping_fees_tax_inc = $wrapping_fees * (1 + (((float)($wrapping_fees_tax->rate) / 100)));
|
||||
|
||||
// TOS
|
||||
$cms = new CMS((int)(Configuration::get('PS_CONDITIONS_CMS_ID')), (int)(self::$cookie->id_lang));
|
||||
$this->link_conditions = self::$link->getCMSLink($cms, $cms->link_rewrite, true);
|
||||
if (!strpos($this->link_conditions, '?'))
|
||||
$this->link_conditions .= '?content_only=1';
|
||||
else
|
||||
$this->link_conditions .= '&content_only=1';
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'checkedTOS' => (int)(self::$cookie->checkedTOS),
|
||||
'recyclablePackAllowed' => (int)(Configuration::get('PS_RECYCLABLE_PACK')),
|
||||
'giftAllowed' => (int)(Configuration::get('PS_GIFT_WRAPPING')),
|
||||
'cms_id' => (int)(Configuration::get('PS_CONDITIONS_CMS_ID')),
|
||||
'conditions' => (int)(Configuration::get('PS_CONDITIONS')),
|
||||
'link_conditions' => $this->link_conditions,
|
||||
'recyclable' => (int)(self::$cart->recyclable),
|
||||
'gift_wrapping_price' => (float)(Configuration::get('PS_GIFT_WRAPPING_PRICE')),
|
||||
'total_wrapping_cost' => Tools::convertPrice($wrapping_fees_tax_inc, new Currency((int)(self::$cookie->id_currency))),
|
||||
'total_wrapping_tax_exc_cost' => Tools::convertPrice($wrapping_fees, new Currency((int)(self::$cookie->id_currency)))));
|
||||
}
|
||||
|
||||
protected function _assignPayment()
|
||||
{
|
||||
self::$smarty->assign(array(
|
||||
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
|
||||
'HOOK_PAYMENT' => Module::hookExecPayment()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id_carrier to 0 (no shipping price)
|
||||
*
|
||||
*/
|
||||
protected function _setNoCarrier()
|
||||
{
|
||||
self::$cart->id_carrier = 0;
|
||||
self::$cart->update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
define('MIN_PASSWD_LENGTH', 8);
|
||||
|
||||
class PasswordControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->php_self = 'password';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
if (Tools::isSubmit('email'))
|
||||
{
|
||||
if (!($email = Tools::getValue('email')) OR !Validate::isEmail($email))
|
||||
$this->errors[] = Tools::displayError('Invalid e-mail address');
|
||||
else
|
||||
{
|
||||
$customer = new Customer();
|
||||
$customer->getByemail($email);
|
||||
if (!Validate::isLoadedObject($customer))
|
||||
$this->errors[] = Tools::displayError('There is no account registered to this e-mail address.');
|
||||
else
|
||||
{
|
||||
if ((strtotime($customer->last_passwd_gen.'+'.(int)($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')).' minutes') - time()) > 0)
|
||||
$this->errors[] = Tools::displayError('You can regenerate your password only each').' '.(int)($min_time).' '.Tools::displayError('minute(s)');
|
||||
else
|
||||
{
|
||||
if (Mail::Send((int)(self::$cookie->id_lang), 'password_query', Mail::l('Password query confirmation'),
|
||||
array('{email}' => $customer->email,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{url}' => self::$link->getPageLink('password', true).'?token='.$customer->secure_key.'&id_customer='.(int)$customer->id),
|
||||
$customer->email,
|
||||
$customer->firstname.' '.$customer->lastname))
|
||||
self::$smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
|
||||
else
|
||||
$this->errors[] = Tools::displayError('Error occured when sending the e-mail.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (($token = Tools::getValue('token')) && ($id_customer = (int)(Tools::getValue('id_customer'))))
|
||||
{
|
||||
$email = Db::getInstance()->getValue('SELECT `email` FROM '._DB_PREFIX_.'customer c WHERE c.`secure_key` = "'.pSQL($token).'" AND c.id_customer='.(int)($id_customer));
|
||||
if ($email)
|
||||
{
|
||||
$customer = new Customer();
|
||||
$customer->getByemail($email);
|
||||
if ((strtotime($customer->last_passwd_gen.'+'.(int)($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')).' minutes') - time()) > 0)
|
||||
Tools::redirect('index.php?controller=authentication&error_regen_pwd');
|
||||
else
|
||||
{
|
||||
$customer->passwd = Tools::encrypt($password = Tools::passwdGen((int)(MIN_PASSWD_LENGTH)));
|
||||
$customer->last_passwd_gen = date('Y-m-d H:i:s', time());
|
||||
if ($customer->update())
|
||||
{
|
||||
if (Mail::Send((int)(self::$cookie->id_lang), 'password', Mail::l('Your password'),
|
||||
array('{email}' => $customer->email,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{passwd}' => $password),
|
||||
$customer->email,
|
||||
$customer->firstname.' '.$customer->lastname))
|
||||
self::$smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
|
||||
else
|
||||
$this->errors[] = Tools::displayError('Error occured when sending the e-mail.');
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
|
||||
}
|
||||
elseif (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer')))
|
||||
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'password.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class PricesDropControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->php_self = 'prices-drop.php';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
$this->productSort();
|
||||
$nbProducts = Product::getPricesDrop((int)(self::$cookie->id_lang), NULL, NULL, true);
|
||||
$this->pagination($nbProducts);
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'products' => Product::getPricesDrop((int)(self::$cookie->id_lang), (int)($this->p) - 1, (int)($this->n), false, $this->orderBy, $this->orderWay),
|
||||
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
||||
'nbProducts' => $nbProducts,
|
||||
'homeSize' => Image::getSize('home')
|
||||
));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'prices-drop.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,462 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class ProductControllerCore extends FrontController
|
||||
{
|
||||
protected $product;
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'product.css');
|
||||
Tools::addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen');
|
||||
Tools::addJS(array(
|
||||
_PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js',
|
||||
_PS_JS_DIR_.'jquery/jquery.idTabs.modified.js',
|
||||
_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js',
|
||||
_PS_JS_DIR_.'jquery/jquery.serialScroll-1.2.2-min.js',
|
||||
_THEME_JS_DIR_.'tools.js',
|
||||
_THEME_JS_DIR_.'product.js'));
|
||||
|
||||
if (Configuration::get('PS_DISPLAY_JQZOOM') == 1)
|
||||
{
|
||||
Tools::addCSS(_PS_CSS_DIR_.'jqzoom.css', 'screen');
|
||||
Tools::addJS(_PS_JS_DIR_.'jquery/jquery.jqzoom.js');
|
||||
}
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
if ($id_product = (int)Tools::getValue('id_product'))
|
||||
$this->product = new Product($id_product, true, self::$cookie->id_lang);
|
||||
|
||||
if (!Validate::isLoadedObject($this->product))
|
||||
{
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header('Status: 404 Not Found');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Automatically redirect to the canonical URL if the current in is the right one
|
||||
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
|
||||
if (Validate::isLoadedObject($this->product))
|
||||
{
|
||||
$canonicalURL = self::$link->getProductLink($this->product);
|
||||
p($canonicalURL);
|
||||
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
|
||||
{
|
||||
header('HTTP/1.0 301 Moved');
|
||||
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_)
|
||||
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');
|
||||
Tools::redirectLink($canonicalURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent::preProcess();
|
||||
|
||||
if((int)(Configuration::get('PS_REWRITING_SETTINGS')))
|
||||
if ($id_product = (int)Tools::getValue('id_product'))
|
||||
{
|
||||
$rewrite_infos = Product::getUrlRewriteInformations((int)$id_product);
|
||||
|
||||
$default_rewrite = array();
|
||||
foreach ($rewrite_infos AS $infos)
|
||||
$default_rewrite[$infos['id_lang']] = self::$link->getProductLink((int)$id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int)$infos['id_lang']);
|
||||
|
||||
self::$smarty->assign('lang_rewrite_urls', $default_rewrite);
|
||||
}
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
global $cart;
|
||||
|
||||
if (!$id_product = (int)(Tools::getValue('id_product')) OR !Validate::isUnsignedId($id_product))
|
||||
$this->errors[] = Tools::displayError('Product not found');
|
||||
else
|
||||
{
|
||||
if (!Validate::isLoadedObject($this->product)
|
||||
OR (!$this->product->active AND (Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct'.$this->product->id))
|
||||
|| !file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad').'/ajax.php')))
|
||||
{
|
||||
header('HTTP/1.1 404 page not found');
|
||||
$this->errors[] = Tools::displayError('Pproduct is no longer available.');
|
||||
}
|
||||
elseif (!$this->product->checkAccess((int)(self::$cookie->id_customer)))
|
||||
$this->errors[] = Tools::displayError('You do not have access to this product.');
|
||||
else
|
||||
{
|
||||
self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)($this->product->id)));
|
||||
|
||||
if (!$this->product->active)
|
||||
self::$smarty->assign('adminActionDisplay', true);
|
||||
|
||||
/* rewrited url set */
|
||||
$rewrited_url = self::$link->getProductLink($this->product->id, $this->product->link_rewrite);
|
||||
|
||||
/* Product pictures management */
|
||||
require_once('images.inc.php');
|
||||
self::$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
|
||||
|
||||
if (Tools::isSubmit('submitCustomizedDatas'))
|
||||
{
|
||||
$this->pictureUpload($this->product, $cart);
|
||||
$this->textRecord($this->product, $cart);
|
||||
$this->formTargetFormat();
|
||||
}
|
||||
elseif (isset($_GET['deletePicture']) AND !$cart->deletePictureToProduct((int)($this->product->id), (int)(Tools::getValue('deletePicture'))))
|
||||
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
|
||||
|
||||
$files = self::$cookie->getFamily('pictures_'.(int)($this->product->id));
|
||||
$textFields = self::$cookie->getFamily('textFields_'.(int)($this->product->id));
|
||||
foreach ($textFields as $key => $textField)
|
||||
$textFields[$key] = str_replace('<br />', "\n", $textField);
|
||||
self::$smarty->assign(array(
|
||||
'pictures' => $files,
|
||||
'textFields' => $textFields));
|
||||
|
||||
$productPriceWithTax = Product::getPriceStatic($id_product, true, NULL, 6);
|
||||
if (Product::$_taxCalculationMethod == PS_TAX_INC)
|
||||
$productPriceWithTax = Tools::ps_round($productPriceWithTax, 2);
|
||||
|
||||
$productPriceWithoutEcoTax = (float)($productPriceWithTax - $this->product->ecotax);
|
||||
$configs = Configuration::getMultiple(array('PS_ORDER_OUT_OF_STOCK', 'PS_LAST_QTIES'));
|
||||
|
||||
/* Features / Values */
|
||||
$features = $this->product->getFrontFeatures((int)(self::$cookie->id_lang));
|
||||
$attachments = $this->product->getAttachments((int)(self::$cookie->id_lang));
|
||||
|
||||
/* Category */
|
||||
$category = false;
|
||||
if (isset($_SERVER['HTTP_REFERER']) AND preg_match('!^(.*)\/([0-9]+)\-(.*[^\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) AND !strstr($_SERVER['HTTP_REFERER'], '.html'))
|
||||
{
|
||||
if (isset($regs[2]) AND is_numeric($regs[2]))
|
||||
{
|
||||
if (Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)($regs[2])))))
|
||||
$category = new Category((int)($regs[2]), (int)(self::$cookie->id_lang));
|
||||
}
|
||||
elseif (isset($regs[5]) AND is_numeric($regs[5]))
|
||||
{
|
||||
if (Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)($regs[5])))))
|
||||
$category = new Category((int)($regs[5]), (int)(self::$cookie->id_lang));
|
||||
}
|
||||
}
|
||||
if (!$category)
|
||||
$category = new Category($this->product->id_category_default, (int)(self::$cookie->id_lang));
|
||||
|
||||
if (isset($category) AND Validate::isLoadedObject($category))
|
||||
{
|
||||
self::$smarty->assign(array(
|
||||
'path' => Tools::getPath((int)$category->id, $this->product->name, true),
|
||||
'category' => $category,
|
||||
'subCategories' => $category->getSubCategories((int)(self::$cookie->id_lang), true),
|
||||
'id_category_current' => (int)($category->id),
|
||||
'id_category_parent' => (int)($category->id_parent),
|
||||
'return_category_name' => Tools::safeOutput($category->name)));
|
||||
}
|
||||
else
|
||||
self::$smarty->assign('path', Tools::getPath((int)$this->product->id_category_default, $this->product->name));
|
||||
|
||||
self::$smarty->assign('return_link', (isset($category->id) AND $category->id) ? Tools::safeOutput(self::$link->getCategoryLink($category)) : 'javascript: history.back();');
|
||||
|
||||
$lang = Configuration::get('PS_LANG_DEFAULT');
|
||||
if (Pack::isPack((int)($this->product->id), (int)($lang)) AND !Pack::isInStock((int)($this->product->id), (int)($lang)))
|
||||
$this->product->quantity = 0;
|
||||
|
||||
$group_reduction = (100 - Group::getReduction((int)(self::$cookie->id_customer))) / 100;
|
||||
$id_customer = (isset(self::$cookie->id_customer) AND self::$cookie->id_customer) ? (int)(self::$cookie->id_customer) : 0;
|
||||
$id_group = $id_customer ? (int)(Customer::getDefaultGroupId($id_customer)) : _PS_DEFAULT_CUSTOMER_GROUP_;
|
||||
$id_country = (int)($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
|
||||
// Tax
|
||||
$tax = (float)(Tax::getProductTaxRate((int)($this->product->id), $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
self::$smarty->assign('tax_rate', $tax);
|
||||
|
||||
$ecotax_rate = (float) Tax::getProductEcotaxRate($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2);
|
||||
if (Product::$_taxCalculationMethod == PS_TAX_INC)
|
||||
$ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int)($this->product->id), (int)(Shop::getCurrentShop()), (int)(self::$cookie->id_currency), $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (float)($tax)),
|
||||
'product' => $this->product,
|
||||
'ecotax_tax_inc' => $ecotaxTaxAmount,
|
||||
'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2),
|
||||
'ecotaxTax_rate' => $ecotax_rate,
|
||||
'homeSize' => Image::getSize('home'),
|
||||
'product_manufacturer' => new Manufacturer((int)($this->product->id_manufacturer), Configuration::get('PS_LANG_DEFAULT')),
|
||||
'token' => Tools::getToken(false),
|
||||
'productPriceWithoutEcoTax' => (float)($productPriceWithoutEcoTax),
|
||||
'features' => $features,
|
||||
'attachments' => $attachments,
|
||||
'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int)($this->product->out_of_stock)),
|
||||
'last_qties' => (int)($configs['PS_LAST_QTIES']),
|
||||
'group_reduction' => $group_reduction,
|
||||
'col_img_dir' => _PS_COL_IMG_DIR_,
|
||||
));
|
||||
self::$smarty->assign(array(
|
||||
'HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'),
|
||||
'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'),
|
||||
'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product),
|
||||
'HOOK_PRODUCT_FOOTER' => Hook::productFooter($this->product, $category),
|
||||
'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'),
|
||||
'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'),
|
||||
'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent')
|
||||
));
|
||||
|
||||
$images = $this->product->getImages((int)(self::$cookie->id_lang));
|
||||
$productImages = array();
|
||||
foreach ($images AS $k => $image)
|
||||
{
|
||||
if ($image['cover'])
|
||||
{
|
||||
self::$smarty->assign('mainImage', $images[0]);
|
||||
$cover = $image;
|
||||
$cover['id_image'] = (int)($this->product->id).'-'.$cover['id_image'];
|
||||
$cover['id_image_only'] = (int)($image['id_image']);
|
||||
}
|
||||
$productImages[(int)($image['id_image'])] = $image;
|
||||
}
|
||||
if (!isset($cover))
|
||||
$cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang).'-default', 'legend' => 'No picture', 'title' => 'No picture');
|
||||
$size = Image::getSize('large');
|
||||
self::$smarty->assign(array(
|
||||
'cover' => $cover,
|
||||
'imgWidth' => (int)($size['width']),
|
||||
'mediumSize' => Image::getSize('medium'),
|
||||
'largeSize' => Image::getSize('large'),
|
||||
'accessories' => $this->product->getAccessories((int)(self::$cookie->id_lang))));
|
||||
if (sizeof($productImages))
|
||||
self::$smarty->assign('images', $productImages);
|
||||
|
||||
/* Attributes / Groups & colors */
|
||||
$colors = array();
|
||||
$attributesGroups = $this->product->getAttributesGroups((int)(self::$cookie->id_lang));
|
||||
if (is_array($attributesGroups) AND sizeof($attributesGroups))
|
||||
{
|
||||
$combinationImages = $this->product->getCombinationImages((int)(self::$cookie->id_lang));
|
||||
foreach ($attributesGroups AS $k => $row)
|
||||
{
|
||||
/* Color management */
|
||||
if (((isset($row['attribute_color']) AND $row['attribute_color']) OR (file_exists(_PS_COL_IMG_DIR_.$row['id_attribute'].'.jpg'))) AND $row['id_attribute_group'] == $this->product->id_color_default)
|
||||
{
|
||||
$colors[$row['id_attribute']]['value'] = $row['attribute_color'];
|
||||
$colors[$row['id_attribute']]['name'] = $row['attribute_name'];
|
||||
if (!isset($colors[$row['id_attribute']]['attributes_quantity']))
|
||||
$colors[$row['id_attribute']]['attributes_quantity'] = 0;
|
||||
$colors[$row['id_attribute']]['attributes_quantity'] += (int)($row['quantity']);
|
||||
}
|
||||
|
||||
$groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name'];
|
||||
$groups[$row['id_attribute_group']]['name'] = $row['public_group_name'];
|
||||
$groups[$row['id_attribute_group']]['is_color_group'] = $row['is_color_group'];
|
||||
if ($row['default_on'])
|
||||
$groups[$row['id_attribute_group']]['default'] = (int)($row['id_attribute']);
|
||||
if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']]))
|
||||
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0;
|
||||
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int)($row['quantity']);
|
||||
|
||||
$combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
|
||||
$combinations[$row['id_product_attribute']]['attributes'][] = (int)($row['id_attribute']);
|
||||
$combinations[$row['id_product_attribute']]['price'] = (float)($row['price']);
|
||||
$combinations[$row['id_product_attribute']]['ecotax'] = (float)($row['ecotax']);
|
||||
$combinations[$row['id_product_attribute']]['weight'] = (float)($row['weight']);
|
||||
$combinations[$row['id_product_attribute']]['quantity'] = (int)($row['quantity']);
|
||||
$combinations[$row['id_product_attribute']]['reference'] = $row['reference'];
|
||||
$combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
|
||||
$combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity'];
|
||||
$combinations[$row['id_product_attribute']]['id_image'] = isset($combinationImages[$row['id_product_attribute']][0]['id_image']) ? $combinationImages[$row['id_product_attribute']][0]['id_image'] : -1;
|
||||
}
|
||||
//wash attributes list (if some attributes are unavailables and if allowed to wash it)
|
||||
if (!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0)
|
||||
{
|
||||
foreach ($groups AS &$group)
|
||||
foreach ($group['attributes_quantity'] AS $key => &$quantity)
|
||||
if (!$quantity)
|
||||
unset($group['attributes'][$key]);
|
||||
foreach ($colors AS $key => $color)
|
||||
if (!$color['attributes_quantity'])
|
||||
unset($colors[$key]);
|
||||
}
|
||||
foreach($groups AS &$group)
|
||||
natcasesort($group['attributes']);
|
||||
foreach ($combinations AS $id_product_attribute => $comb)
|
||||
{
|
||||
$attributeList = '';
|
||||
foreach ($comb['attributes'] AS $id_attribute)
|
||||
$attributeList .= '\''.(int)($id_attribute).'\',';
|
||||
$attributeList = rtrim($attributeList, ',');
|
||||
$combinations[$id_product_attribute]['list'] = $attributeList;
|
||||
}
|
||||
self::$smarty->assign(array(
|
||||
'groups' => $groups,
|
||||
'combinaisons' => $combinations, /* Kept for compatibility purpose only */
|
||||
'combinations' => $combinations,
|
||||
'colors' => (sizeof($colors) AND $this->product->id_color_default) ? $colors : false,
|
||||
'combinationImages' => $combinationImages));
|
||||
}
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'no_tax' => Tax::excludeTaxeOption() OR !Tax::getProductTaxRate((int)$this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}),
|
||||
'customizationFields' => $this->product->getCustomizationFields((int)(self::$cookie->id_lang))
|
||||
));
|
||||
|
||||
// Pack management
|
||||
self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int)(self::$cookie->id_lang), true) : array());
|
||||
self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int)(self::$cookie->id_lang), true, 1));
|
||||
}
|
||||
}
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'ENT_NOQUOTES' => ENT_NOQUOTES,
|
||||
'outOfStockAllowed' => (int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')),
|
||||
'errors' => $this->errors,
|
||||
'categories' => Category::getHomeCategories((int)(self::$cookie->id_lang)),
|
||||
'have_image' => Product::getCover((int)(Tools::getValue('id_product'))),
|
||||
'tax_enabled' => Configuration::get('PS_TAX'),
|
||||
'display_qties' => (int)(Configuration::get('PS_DISPLAY_QTIES')),
|
||||
'display_ht' => !Tax::excludeTaxeOption(),
|
||||
'ecotax' => (!sizeof($this->errors) AND $this->product->ecotax > 0 ? Tools::convertPrice((float)($this->product->ecotax)) : 0),
|
||||
));
|
||||
|
||||
global $currency;
|
||||
self::$smarty->assign(array(
|
||||
'currencySign' => $currency->sign,
|
||||
'currencyRate' => $currency->conversion_rate,
|
||||
'currencyFormat' => $currency->format,
|
||||
'currencyBlank' => $currency->blank,
|
||||
'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM')
|
||||
));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'product.tpl');
|
||||
}
|
||||
|
||||
public function pictureUpload(Product $product, Cart $cart)
|
||||
{
|
||||
if (!$fieldIds = $this->product->getCustomizationFieldIds())
|
||||
return false;
|
||||
$authorizedFileFields = array();
|
||||
foreach ($fieldIds AS $fieldId)
|
||||
if ($fieldId['type'] == _CUSTOMIZE_FILE_)
|
||||
$authorizedFileFields[(int)($fieldId['id_customization_field'])] = 'file'.(int)($fieldId['id_customization_field']);
|
||||
$indexes = array_flip($authorizedFileFields);
|
||||
foreach ($_FILES AS $fieldName => $file)
|
||||
if (in_array($fieldName, $authorizedFileFields) AND isset($file['tmp_name']) AND !empty($file['tmp_name']))
|
||||
{
|
||||
$fileName = md5(uniqid(rand(), true));
|
||||
if ($error = checkImage($file, (int)(Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE'))))
|
||||
$this->errors[] = $error;
|
||||
|
||||
if ($error OR (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($file['tmp_name'], $tmpName)))
|
||||
return false;
|
||||
/* Original file */
|
||||
elseif (!imageResize($tmpName, _PS_UPLOAD_DIR_.$fileName))
|
||||
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
|
||||
/* A smaller one */
|
||||
elseif (!imageResize($tmpName, _PS_UPLOAD_DIR_.$fileName.'_small', (int)(Configuration::get('PS_PRODUCT_PICTURE_WIDTH')), (int)(Configuration::get('PS_PRODUCT_PICTURE_HEIGHT'))))
|
||||
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
|
||||
elseif (!chmod(_PS_UPLOAD_DIR_.$fileName, 0777) OR !chmod(_PS_UPLOAD_DIR_.$fileName.'_small', 0777))
|
||||
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
|
||||
else
|
||||
$cart->addPictureToProduct((int)($this->product->id), $indexes[$fieldName], $fileName);
|
||||
unlink($tmpName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function textRecord(Product $product, Cart $cart)
|
||||
{
|
||||
if (!$fieldIds = $this->product->getCustomizationFieldIds())
|
||||
return false;
|
||||
$authorizedTextFields = array();
|
||||
foreach ($fieldIds AS $fieldId)
|
||||
if ($fieldId['type'] == _CUSTOMIZE_TEXTFIELD_)
|
||||
$authorizedTextFields[(int)($fieldId['id_customization_field'])] = 'textField'.(int)($fieldId['id_customization_field']);
|
||||
$indexes = array_flip($authorizedTextFields);
|
||||
foreach ($_POST AS $fieldName => $value)
|
||||
if (in_array($fieldName, $authorizedTextFields) AND !empty($value))
|
||||
{
|
||||
if (!Validate::isMessage($value))
|
||||
$this->errors[] = Tools::displayError('Invalid message');
|
||||
else
|
||||
$cart->addTextFieldToProduct((int)($this->product->id), $indexes[$fieldName], $value);
|
||||
}
|
||||
elseif (in_array($fieldName, $authorizedTextFields) AND empty($value))
|
||||
$cart->deleteTextFieldFromProduct((int)($this->product->id), $indexes[$fieldName]);
|
||||
}
|
||||
|
||||
public function formTargetFormat()
|
||||
{
|
||||
$customizationFormTarget = Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']));
|
||||
foreach ($_GET AS $field => $value)
|
||||
if (strncmp($field, 'group_', 6) == 0)
|
||||
$customizationFormTarget = preg_replace('/&group_([[:digit:]]+)=([[:digit:]]+)/', '', $customizationFormTarget);
|
||||
if (isset($_POST['quantityBackup']))
|
||||
self::$smarty->assign('quantityBackup', (int)($_POST['quantityBackup']));
|
||||
self::$smarty->assign('customizationFormTarget', $customizationFormTarget);
|
||||
}
|
||||
|
||||
public function formatQuantityDiscounts($specificPrices, $price, $taxRate)
|
||||
{
|
||||
foreach ($specificPrices AS $key => &$row)
|
||||
{
|
||||
$row['quantity'] = &$row['from_quantity'];
|
||||
if ($row['price'] != 0) // The price may be directly set
|
||||
{
|
||||
$cur_price = (Product::$_taxCalculationMethod == PS_TAX_EXC ? $row['price'] : $row['price'] * (1 + $taxRate / 100));
|
||||
|
||||
if ($row['reduction_type'] == 'amount')
|
||||
{
|
||||
$cur_price = Product::$_taxCalculationMethod == PS_TAX_INC ? $cur_price - $row['reduction'] : $cur_price - ($row['reduction'] / (1 + $taxRate / 100));
|
||||
} else {
|
||||
$cur_price = $cur_price * ( 1 - ($row['reduction']));
|
||||
}
|
||||
|
||||
$row['real_value'] = $price - $cur_price;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($row['reduction_type'] == 'amount')
|
||||
{
|
||||
$row['real_value'] = Product::$_taxCalculationMethod == PS_TAX_INC ? $row['reduction'] : $row['reduction'] / (1 + $taxRate / 100);
|
||||
} else {
|
||||
$row['real_value'] = $row['reduction'] * 100;
|
||||
}
|
||||
}
|
||||
$row['nextQuantity'] = (isset($specificPrices[$key + 1]) ? (int)($specificPrices[$key + 1]['from_quantity']) : -1);
|
||||
}
|
||||
return $specificPrices;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class SearchControllerCore extends FrontController
|
||||
{
|
||||
public $instantSearch;
|
||||
public $ajaxSearch;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->php_self = 'search.php';
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->instantSearch = Tools::getValue('instantSearch');
|
||||
$this->ajaxSearch = Tools::getValue('ajaxSearch');
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
$query = urldecode(Tools::getValue('q'));
|
||||
if ($this->ajaxSearch)
|
||||
{
|
||||
self::$link = new Link();
|
||||
$searchResults = Search::find((int)(Tools::getValue('id_lang')), $query, 1, 10, 'position', 'desc', true);
|
||||
foreach ($searchResults AS &$product)
|
||||
$product['product_link'] = self::$link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
|
||||
die(Tools::jsonEncode($searchResults));
|
||||
}
|
||||
|
||||
if ($this->instantSearch && !is_array($query))
|
||||
{
|
||||
$this->productSort();
|
||||
$this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))));
|
||||
$this->p = abs((int)(Tools::getValue('p', 1)));
|
||||
$search = Search::find((int)(self::$cookie->id_lang), $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
|
||||
Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
|
||||
$nbProducts = $search['total'];
|
||||
$this->pagination($nbProducts);
|
||||
self::$smarty->assign(array(
|
||||
'products' => $search['result'], // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
|
||||
'search_products' => $search['result'],
|
||||
'nbProducts' => $search['total'],
|
||||
'search_query' => $query,
|
||||
'instantSearch' => $this->instantSearch,
|
||||
'homeSize' => Image::getSize('home')));
|
||||
}
|
||||
elseif ($query = Tools::getValue('search_query', Tools::getValue('ref')) AND !is_array($query))
|
||||
{
|
||||
$this->productSort();
|
||||
$this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))));
|
||||
$this->p = abs((int)(Tools::getValue('p', 1)));
|
||||
$search = Search::find((int)(self::$cookie->id_lang), $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
|
||||
Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
|
||||
$nbProducts = $search['total'];
|
||||
$this->pagination($nbProducts);
|
||||
self::$smarty->assign(array(
|
||||
'products' => $search['result'], // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
|
||||
'search_products' => $search['result'],
|
||||
'nbProducts' => $search['total'],
|
||||
'search_query' => $query,
|
||||
'homeSize' => Image::getSize('home')));
|
||||
}
|
||||
elseif ($tag = urldecode(Tools::getValue('tag')) AND !is_array($tag))
|
||||
{
|
||||
$nbProducts = (int)(Search::searchTag((int)(self::$cookie->id_lang), $tag, true));
|
||||
$this->pagination($nbProducts);
|
||||
$result = Search::searchTag((int)(self::$cookie->id_lang), $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
|
||||
Module::hookExec('search', array('expr' => $tag, 'total' => sizeof($result)));
|
||||
self::$smarty->assign(array(
|
||||
'search_tag' => $tag,
|
||||
'products' => $result, // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
|
||||
'search_products' => $result,
|
||||
'nbProducts' => $nbProducts,
|
||||
'homeSize' => Image::getSize('home')));
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$smarty->assign(array(
|
||||
'products' => array(),
|
||||
'search_products' => array(),
|
||||
'pages_nb' => 1,
|
||||
'nbProducts' => 0));
|
||||
}
|
||||
self::$smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'));
|
||||
}
|
||||
|
||||
public function displayHeader()
|
||||
{
|
||||
if (!$this->instantSearch AND !$this->ajaxSearch)
|
||||
parent::displayHeader();
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'search.tpl');
|
||||
}
|
||||
|
||||
public function displayFooter()
|
||||
{
|
||||
if (!$this->instantSearch AND !$this->ajaxSearch)
|
||||
parent::displayFooter();
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
|
||||
if (!$this->instantSearch AND !$this->ajaxSearch)
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class SitemapControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->php_self = 'sitemap.php';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'sitemap.css');
|
||||
Tools::addJS(_THEME_JS_DIR_.'tools/treeManagement.js');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
self::$smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0));
|
||||
self::$smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(_USER_ID_LANG_, 1, 1, 1));
|
||||
self::$smarty->assign('voucherAllowed', (int)(Configuration::get('PS_VOUCHERS')));
|
||||
$blockmanufacturer = Module::getInstanceByName('blockmanufacturer');
|
||||
$blocksupplier = Module::getInstanceByName('blocksupplier');
|
||||
self::$smarty->assign('display_manufacturer_link', (((int)$blockmanufacturer->id AND Configuration::get('PS_DISPLAY_SUPPLIERS')) ? true : false));
|
||||
self::$smarty->assign('display_supplier_link', (((int)$blocksupplier->id AND Configuration::get('PS_DISPLAY_SUPPLIERS')) ? true : false));
|
||||
self::$smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS'));
|
||||
self::$smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP'));
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'sitemap.tpl');
|
||||
}
|
||||
}
|
||||
@@ -1,209 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class StoresControllerCore extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->php_self = 'stores.php';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
global $smarty, $cookie;
|
||||
|
||||
$simplifiedStoreLocator = Configuration::get('PS_STORES_SIMPLIFIED');
|
||||
$distanceUnit = Configuration::get('PS_DISTANCE_UNIT');
|
||||
if (!in_array($distanceUnit, array('km', 'mi')))
|
||||
$distanceUnit = 'km';
|
||||
|
||||
if ($simplifiedStoreLocator)
|
||||
{
|
||||
$stores = Db::getInstance()->ExecuteS('
|
||||
SELECT s.*, cl.name country, st.iso_code state
|
||||
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)
|
||||
WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang));
|
||||
|
||||
foreach ($stores AS &$store)
|
||||
$store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Tools::getValue('all') == 1)
|
||||
{
|
||||
$stores = Db::getInstance()->ExecuteS('
|
||||
SELECT s.*, cl.name country, st.iso_code state
|
||||
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)
|
||||
WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang));
|
||||
}
|
||||
else
|
||||
{
|
||||
$distance = (int)(Tools::getValue('radius', 100));
|
||||
$multiplicator = ($distanceUnit == 'km' ? 6371 : 3959);
|
||||
|
||||
$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, 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)
|
||||
WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang).'
|
||||
HAVING distance < '.(int)($distance).'
|
||||
ORDER BY distance ASC
|
||||
LIMIT 0,20');
|
||||
}
|
||||
|
||||
if (Tools::getValue('ajax') == 1)
|
||||
{
|
||||
$dom = new DOMDocument('1.0');
|
||||
$node = $dom->createElement('markers');
|
||||
$parnode = $dom->appendChild($node);
|
||||
|
||||
$days[1] = 'Monday';
|
||||
$days[2] = 'Tuesday';
|
||||
$days[3] = 'Wednesday';
|
||||
$days[4] = 'Thursday';
|
||||
$days[5] = 'Friday';
|
||||
$days[6] = 'Saturday';
|
||||
$days[7] = 'Sunday';
|
||||
|
||||
foreach ($stores AS $store)
|
||||
{
|
||||
$days_datas = array();
|
||||
$node = $dom->createElement('marker');
|
||||
$newnode = $parnode->appendChild($node);
|
||||
$newnode->setAttribute('name', $store['name']);
|
||||
$address = $this->_processStoreAddress($store);
|
||||
|
||||
$other = '';
|
||||
if (!empty($store['hours']))
|
||||
{
|
||||
$hours = unserialize($store['hours']);
|
||||
|
||||
for ($i = 1; $i < 8; $i++)
|
||||
{
|
||||
$hours_datas = array();
|
||||
$hours_datas['day'] = $days[$i];
|
||||
$hours_datas['hours'] = $hours[(int)($i) - 1];
|
||||
$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');
|
||||
}
|
||||
|
||||
$newnode->setAttribute('addressNoHtml', strip_tags(str_replace('<br />', ' ', $address)));
|
||||
$newnode->setAttribute('address', $address);
|
||||
$newnode->setAttribute('other', $other);
|
||||
$newnode->setAttribute('phone', $store['phone']);
|
||||
$newnode->setAttribute('id_store', (int)($store['id_store']));
|
||||
$newnode->setAttribute('has_store_picture', file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg'));
|
||||
$newnode->setAttribute('lat', (float)($store['latitude']));
|
||||
$newnode->setAttribute('lng', (float)($store['longitude']));
|
||||
|
||||
if (isset($store['distance']))
|
||||
$newnode->setAttribute('distance', (int)($store['distance']));
|
||||
}
|
||||
|
||||
header('Content-type: text/xml');
|
||||
die($dom->saveXML());
|
||||
}
|
||||
else
|
||||
$smarty->assign('hasStoreIcon', file_exists(dirname(__FILE__).'/../img/logo_stores.gif'));
|
||||
}
|
||||
|
||||
$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();
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'defaultLat' => (float)Configuration::get('PS_STORES_CENTER_LAT'),
|
||||
'defaultLong' => (float)Configuration::get('PS_STORES_CENTER_LONG')
|
||||
));
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'stores.css');
|
||||
if (!Configuration::get('PS_STORES_SIMPLIFIED'))
|
||||
Tools::addJS(_THEME_JS_DIR_.'stores.js');
|
||||
Tools::addJS('http://maps.google.com/maps/api/js?sensor=true');
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'stores.tpl');
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class SupplierControllerCore extends FrontController
|
||||
{
|
||||
protected $supplier;
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
if ($id_supplier = Tools::getValue('id_supplier'))
|
||||
{
|
||||
$this->supplier = new Supplier((int)$id_supplier, self::$cookie->id_lang);
|
||||
if (Validate::isLoadedObject($this->supplier) AND $this->supplier->active)
|
||||
{
|
||||
$nbProducts = $this->supplier->getProducts($id_supplier, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
|
||||
$this->pagination((int)$nbProducts);
|
||||
self::$smarty->assign(array(
|
||||
'nb_products' => $nbProducts,
|
||||
'products' => $this->supplier->getProducts($id_supplier, (int)self::$cookie->id_lang, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay),
|
||||
'path' => ($this->supplier->active ? Tools::safeOutput($this->supplier->name) : ''),
|
||||
'supplier' => $this->supplier));
|
||||
}
|
||||
else
|
||||
{
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header('Status: 404 Not Found');
|
||||
$this->errors[] = Tools::displayError('Supplier does not exist');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Configuration::get('PS_DISPLAY_SUPPLIERS'))
|
||||
{
|
||||
$data = call_user_func(array('Supplier', 'getSuppliers'), true, (int)(self::$cookie->id_lang), true);
|
||||
$nbProducts = count($data);
|
||||
$this->pagination($nbProducts);
|
||||
|
||||
$data = call_user_func(array('Supplier', 'getSuppliers'), true, (int)(self::$cookie->id_lang), true, $this->p, $this->n);
|
||||
$imgDir = _PS_MANU_IMG_DIR_;
|
||||
foreach ($data AS &$item)
|
||||
$item['image'] = (!file_exists($imgDir.'/'.$item['id_supplier'].'-medium.jpg')) ?
|
||||
Language::getIsoById((int)(self::$cookie->id_lang)).'-default' : $item['id_supplier'];
|
||||
self::$smarty->assign(array(
|
||||
'pages_nb' => ceil($nbProducts / (int)($this->n)),
|
||||
'nbSuppliers' => $nbProducts,
|
||||
'mediumSize' => Image::getSize('medium'),
|
||||
'suppliers' => $data,
|
||||
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
||||
));
|
||||
}
|
||||
else
|
||||
self::$smarty->assign('nbSuppliers', 0);
|
||||
}
|
||||
}
|
||||
|
||||
public function displayHeader()
|
||||
{
|
||||
parent::displayHeader();
|
||||
$this->productSort();
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
if ($this->supplier)
|
||||
self::$smarty->display(_PS_THEME_DIR_.'supplier.tpl');
|
||||
else
|
||||
self::$smarty->display(_PS_THEME_DIR_.'supplier-list.tpl');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user