// Merge -> 10309
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10333 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+2
-1
@@ -135,7 +135,8 @@ class AddressCore extends ObjectModel
|
||||
/* Get and cache address country name */
|
||||
if ($this->id)
|
||||
{
|
||||
$result = Db::getInstance()->getRow('SELECT `name` FROM `'._DB_PREFIX_.'country_lang`
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT `name` FROM `'._DB_PREFIX_.'country_lang`
|
||||
WHERE `id_country` = '.(int)$this->id_country.'
|
||||
AND `id_lang` = '.($id_lang ? (int)$id_lang : Configuration::get('PS_LANG_DEFAULT')));
|
||||
$this->country = $result['name'];
|
||||
|
||||
@@ -483,8 +483,8 @@ abstract class AdminTabCore
|
||||
$this->_childValidation();
|
||||
|
||||
/* Checking for fields validity */
|
||||
foreach ($rules['validate'] as $field => $function)
|
||||
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
|
||||
foreach ($rules['validate'] AS $field => $function)
|
||||
if (($value = Tools::getValue($field)) !== false AND !empty($value) AND ($field != 'passwd'))
|
||||
if (!Validate::$function($value))
|
||||
$this->_errors[] = $this->l('the field').' <b>'.call_user_func(array($className, 'displayFieldName'), $field, $className).'</b> '.$this->l('is invalid');
|
||||
|
||||
|
||||
@@ -45,6 +45,11 @@ class CMSCore extends ObjectModel
|
||||
protected $table = 'cms';
|
||||
protected $identifier = 'id_cms';
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'objectNodeName' => 'content',
|
||||
'objectsNodeName' => 'content_management_system',
|
||||
);
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
$this->validateFields();
|
||||
|
||||
@@ -177,7 +177,7 @@ class CategoryCore extends ObjectModel
|
||||
public function add($autodate = true, $nullValues = false)
|
||||
{
|
||||
$this->position = self::getLastPosition((int)$this->id_parent);
|
||||
if (!isset($this->level_depth) || $this->level_depth != 0)
|
||||
if (!isset($this->level_depth))
|
||||
$this->level_depth = $this->calcLevelDepth();
|
||||
$ret = parent::add($autodate);
|
||||
if (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree)
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ class ChartCore
|
||||
$options = 'xaxis:{mode:"time",timeformat:\''.addslashes($this->format).'\',min:'.$this->from.'000,max:'.$this->to.'000}';
|
||||
if ($this->granularity == 'd')
|
||||
foreach ($this->curves as $curve)
|
||||
for ($i = $this->from; $i <= $this->to; $i += 86400)
|
||||
for ($i = $this->from; $i <= $this->to; $i = strtotime('+1 day', $i))
|
||||
if (!$curve->getPoint($i))
|
||||
$curve->setPoint($i, 0);
|
||||
}
|
||||
|
||||
+72
-110
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -27,155 +27,104 @@
|
||||
|
||||
class CompareProductCore extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
|
||||
public $id_product;
|
||||
|
||||
public $id_guest;
|
||||
|
||||
public $id_compare;
|
||||
|
||||
public $id_customer;
|
||||
|
||||
|
||||
public $date_add;
|
||||
|
||||
|
||||
public $date_upd;
|
||||
|
||||
|
||||
protected $fieldRequired = array(
|
||||
'id_product',
|
||||
'id_guest',
|
||||
'id_compare',
|
||||
'id_customer');
|
||||
|
||||
|
||||
protected $fieldsValidate = array(
|
||||
'id_product' => 'isUnsignedInt',
|
||||
'id_guest' => 'isUnsignedInt',
|
||||
'id_compare' => 'isUnsignedInt',
|
||||
'id_customer' => 'isUnsignedInt'
|
||||
);
|
||||
|
||||
protected $table = 'compare_product';
|
||||
|
||||
protected $identifier = 'id_compare_product';
|
||||
|
||||
|
||||
/**
|
||||
* Get all compare products of the guest
|
||||
* @param int $id_guest
|
||||
* @return array
|
||||
*/
|
||||
public static function getGuestCompareProducts($id_guest)
|
||||
{
|
||||
$results = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT `id_product`
|
||||
FROM `'._DB_PREFIX_.'compare_product`
|
||||
WHERE `id_guest` = '.(int)($id_guest));
|
||||
|
||||
$compareProducts = null;
|
||||
|
||||
if ($results)
|
||||
foreach($results as $result)
|
||||
$compareProducts[] = $result['id_product'];
|
||||
|
||||
return $compareProducts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a compare product for the guest
|
||||
* @param int $id_guest, int $id_product
|
||||
* @return boolean
|
||||
*/
|
||||
public static function addGuestCompareProduct($id_guest, $id_product)
|
||||
{
|
||||
return Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'compare_product` (`id_product`, `id_guest`, `id_customer`, `date_add`, `date_upd`)
|
||||
VALUES ('.(int)($id_product).', '.(int)($id_guest).', 0, NOW(), NOW())
|
||||
');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a compare product for the guest
|
||||
* @param int $id_guest, int $id_product
|
||||
* @return boolean
|
||||
*/
|
||||
public static function removeGuestCompareProduct($id_guest, $id_product)
|
||||
{
|
||||
return Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'compare_product` WHERE `id_guest` = '.(int)($id_guest).' AND `id_product` = '.(int)($id_product));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of compare products of the guest
|
||||
* @param int $id_guest
|
||||
* @return int
|
||||
*/
|
||||
public static function getGuestNumberProducts($id_guest)
|
||||
{
|
||||
return (int)(Db::getInstance()->getValue('
|
||||
SELECT count(`id_compare_product`)
|
||||
FROM `'._DB_PREFIX_.'compare_product`
|
||||
WHERE `id_guest` = '.(int)($id_guest)));;
|
||||
}
|
||||
|
||||
|
||||
protected $table = 'compare';
|
||||
|
||||
protected $identifier = 'id_compare';
|
||||
|
||||
|
||||
/**
|
||||
* Get all comapare products of the customer
|
||||
* @param int $id_customer
|
||||
* @return array
|
||||
*/
|
||||
public static function getCustomerCompareProducts($id_customer)
|
||||
public static function getCompareProducts($id_compare)
|
||||
{
|
||||
$results = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT `id_product`
|
||||
FROM `'._DB_PREFIX_.'compare_product`
|
||||
WHERE `id_customer` = '.(int)($id_customer));
|
||||
|
||||
FROM `'._DB_PREFIX_.'compare` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'compare_product` cp ON (cp.`id_compare` = c.`id_compare`)
|
||||
WHERE cp.`id_compare` = '.(int)($id_compare));
|
||||
|
||||
$compareProducts = null;
|
||||
|
||||
|
||||
if ($results)
|
||||
foreach($results as $result)
|
||||
$compareProducts[] = $result['id_product'];
|
||||
|
||||
return $compareProducts;
|
||||
|
||||
return $compareProducts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add a compare product for the customer
|
||||
* @param int $id_customer, int $id_product
|
||||
* @return boolean
|
||||
*/
|
||||
public static function addCustomerCompareProduct($id_customer, $id_product)
|
||||
public static function addCompareProduct($id_compare, $id_product)
|
||||
{
|
||||
if (!$id_compare)
|
||||
{
|
||||
$id_customer = false;
|
||||
if (Context::getContext()->customer)
|
||||
$id_customer = Context::getContext()->customer->id;
|
||||
$sql = Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'compare` (`id_compare`, `id_customer`) VALUES (NULL, "'.($id_customer ? $id_customer: '0').'")');
|
||||
if ($sql)
|
||||
{
|
||||
$id_compare = Db::getInstance()->getValue('SELECT MAX(`id_compare`) FROM `'._DB_PREFIX_.'compare`');
|
||||
$cookie->id_compare = $id_compare;
|
||||
}
|
||||
}
|
||||
return Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'compare_product` (`id_product`, `id_guest`, `id_customer`, `date_add`, `date_upd`)
|
||||
VALUES ('.(int)($id_product).', 0, '.(int)($id_customer).', NOW(), NOW())');
|
||||
INSERT INTO `'._DB_PREFIX_.'compare_product` (`id_compare`, `id_product`, `date_add`, `date_upd`)
|
||||
VALUES ('.(int)($id_compare).', '.(int)($id_product).', NOW(), NOW())');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Remove a compare product for the customer
|
||||
* @param int $id_customer, int $id_product
|
||||
* @param int $id_compare, int $id_product
|
||||
* @return boolean
|
||||
*/
|
||||
public static function removeCustomerCompareProduct($id_customer, $id_product)
|
||||
public static function removeCompareProduct($id_compare, $id_product)
|
||||
{
|
||||
return Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'compare_product` WHERE `id_customer` = '.(int)($id_customer).' AND `id_product` = '.(int)($id_product));
|
||||
}
|
||||
|
||||
|
||||
return Db::getInstance()->execute('
|
||||
DELETE cp FROM `'._DB_PREFIX_.'compare_product` cp, `'._DB_PREFIX_.'compare` c
|
||||
WHERE cp.`id_compare`=c.`id_compare`
|
||||
AND cp.`id_product` = '.(int)$id_product.'
|
||||
AND c.`id_compare` = '.(int)$id_compare);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of compare products of the customer
|
||||
* @param int $id_customer
|
||||
* @param int $id_compare
|
||||
* @return int
|
||||
*/
|
||||
public static function getCustomerNumberProducts($id_customer)
|
||||
public static function getNumberProducts($id_compare)
|
||||
{
|
||||
return (int)(Db::getInstance()->getValue('
|
||||
SELECT count(`id_compare_product`)
|
||||
SELECT count(`id_compare`)
|
||||
FROM `'._DB_PREFIX_.'compare_product`
|
||||
WHERE `id_customer` = '.(int)($id_customer)));
|
||||
WHERE `id_compare` = '.(int)($id_compare)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Clean entries which are older than the period
|
||||
* @param string $period
|
||||
@@ -191,12 +140,25 @@ class CompareProductCore extends ObjectModel
|
||||
$interval = '1 YEAR';
|
||||
else
|
||||
return;
|
||||
|
||||
|
||||
if ($interval != null)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'compare_product`
|
||||
WHERE date_upd < DATE_SUB(NOW(), INTERVAL '.pSQL($interval).')');
|
||||
DELETE cp, c FROM `'._DB_PREFIX_.'compare_product` cp, `'._DB_PREFIX_.'compare` c
|
||||
WHERE cp.date_upd < DATE_SUB(NOW(), INTERVAL 1 WEEK) AND c.`id_compare`=cp.`id_compare`');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the id_compare by id_customer
|
||||
* @param integer $id_customer
|
||||
* @return integer $id_compare
|
||||
*/
|
||||
public static function getIdCompareByIdCustomer($id_customer)
|
||||
{
|
||||
return (int)Db::getInstance()->getValue('
|
||||
SELECT `id_compare`
|
||||
FROM `'._DB_PREFIX_.'compare`
|
||||
WHERE `id_customer`= '.(int)$id_customer);
|
||||
}
|
||||
}
|
||||
@@ -220,6 +220,7 @@ class CookieCore
|
||||
*/
|
||||
public function mylogout()
|
||||
{
|
||||
unset($this->_content['id_compare']);
|
||||
unset($this->_content['id_customer']);
|
||||
unset($this->_content['id_guest']);
|
||||
unset($this->_content['is_guest']);
|
||||
|
||||
@@ -614,6 +614,8 @@ class FrontControllerCore extends Controller
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$nArray = (int)(Configuration::get('PS_PRODUCTS_PER_PAGE')) != 10 ? array((int)(Configuration::get('PS_PRODUCTS_PER_PAGE')), 10, 20, 50) : array(10, 20, 50);
|
||||
// Clean duplicate values
|
||||
$nArray = array_unique($nArray);
|
||||
asort($nArray);
|
||||
$this->n = abs((int)(Tools::getValue('n', ((isset($this->context->cookie->nb_item_per_page) AND $this->context->cookie->nb_item_per_page >= 10) ? $this->context->cookie->nb_item_per_page : (int)(Configuration::get('PS_PRODUCTS_PER_PAGE'))))));
|
||||
$this->p = abs((int)(Tools::getValue('p', 1)));
|
||||
|
||||
+7
-7
@@ -112,12 +112,12 @@ class GroupCore extends ObjectModel
|
||||
|
||||
public static function getReduction($id_customer = null)
|
||||
{
|
||||
if (!isset(self::$cache_reduction['customer'][(int)$id_customer]))
|
||||
self::$cache_reduction['customer'][(int)$id_customer] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT `reduction`
|
||||
FROM `'._DB_PREFIX_.'group`
|
||||
WHERE `id_group` = '.((int)$id_customer ? Customer::getDefaultGroupId((int)$id_customer) : (int)Configuration::get('PS_CUSTOMER_GROUP')));
|
||||
return self::$cache_reduction['customer'][(int)$id_customer];
|
||||
if (!isset(self::$_cacheReduction['customer'][(int)$id_customer]))
|
||||
{
|
||||
$id_group = $id_customer ? Customer::getDefaultGroupId((int)$id_customer) : (int)Configuration::get('PS_CUSTOMER_GROUP');
|
||||
self::$_cacheReduction['customer'][(int)$id_customer] = Group::getReductionByIdGroup($id_group);
|
||||
}
|
||||
return self::$_cacheReduction['customer'][(int)$id_customer];
|
||||
}
|
||||
|
||||
public static function getReductionByIdGroup($id_group)
|
||||
@@ -256,7 +256,7 @@ class GroupCore extends ObjectModel
|
||||
* @param integer authorized
|
||||
*/
|
||||
public static function addModulesRestrictions($id_group, $modules, $authorized)
|
||||
{
|
||||
{
|
||||
if (!is_array($modules) AND !empty($modules))
|
||||
return false;
|
||||
else
|
||||
|
||||
@@ -170,7 +170,7 @@ class GroupReductionCore extends ObjectModel
|
||||
public static function setProductReduction($id_product, $id_group, $id_category, $reduction)
|
||||
{
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT pgr.`id_product`, pgr.`id_group`, pgr.`reduction`
|
||||
SELECT pgr.`id_product`, pgr.`id_group`, pgr.`reduction`
|
||||
FROM `'._DB_PREFIX_.'product_group_reduction_cache` pgr
|
||||
WHERE pgr.`id_product` = '.(int)$id_product
|
||||
);
|
||||
@@ -197,7 +197,7 @@ class GroupReductionCore extends ObjectModel
|
||||
public static function duplicateReduction($id_product_old, $id_product)
|
||||
{
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT pgr.`id_product`, pgr.`id_group`, pgr.`reduction`
|
||||
SELECT pgr.`id_product`, pgr.`id_group`, pgr.`reduction`
|
||||
FROM `'._DB_PREFIX_.'product_group_reduction_cache` pgr
|
||||
WHERE pgr.`id_product` = '.(int)$id_product_old
|
||||
);
|
||||
@@ -216,4 +216,4 @@ class GroupReductionCore extends ObjectModel
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,8 +148,7 @@ abstract class ObjectModelCore
|
||||
$this->id = (int)($id);
|
||||
foreach ($result AS $key => $value)
|
||||
if (key_exists($key, $this))
|
||||
// Todo: stripslashes() MUST BE removed in 1.4.6 and later, but is kept in 1.4.5 for a compatibility issue
|
||||
$this->{$key} = stripslashes($value);
|
||||
$this->{$key} = $value;
|
||||
|
||||
if (!$id_lang AND method_exists($this, 'getTranslationsFieldsChild'))
|
||||
{
|
||||
|
||||
+19
-1
@@ -631,6 +631,22 @@ class PDFCore extends PDF_PageGroupCore
|
||||
$pdf->Ln(15);
|
||||
$pdf->ProdTab((self::$delivery ? true : ''));
|
||||
|
||||
|
||||
|
||||
/* Canada */
|
||||
$taxable_address = new Address((int)self::$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
if (!self::$delivery && strtoupper(Country::getIsoById((int)$taxable_address->id_country)) == 'CA')
|
||||
{
|
||||
$pdf->Ln(15);
|
||||
$taxToDisplay = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'order_tax WHERE id_order = '.(int)self::$order->id);
|
||||
foreach ($taxToDisplay AS $t)
|
||||
{
|
||||
$pdf->Cell(0, 6, utf8_decode($t['tax_name']).' ('.number_format($t['tax_rate'], 2, '.', '').'%) '.self::convertSign(Tools::displayPrice($t['amount'], self::$currency, true)), 0, 0, 'R');
|
||||
$pdf->Ln(5);
|
||||
}
|
||||
}
|
||||
/* End */
|
||||
|
||||
/* Exit if delivery */
|
||||
if (!self::$delivery)
|
||||
{
|
||||
@@ -1055,8 +1071,10 @@ class PDFCore extends PDF_PageGroupCore
|
||||
*/
|
||||
public function TaxTab(&$priceBreakDown)
|
||||
{
|
||||
$taxable_address = new Address((int)self::$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
if (strtoupper(Country::getIsoById((int)$taxable_address->id_country)) == 'CA')
|
||||
return;
|
||||
|
||||
$invoiceAddress = new Address(self::$order->id_address_invoice);
|
||||
if (Configuration::get('VATNUMBER_MANAGEMENT') AND !empty($invoiceAddress->vat_number) AND $invoiceAddress->id_country != Configuration::get('VATNUMBER_COUNTRY'))
|
||||
{
|
||||
$this->Ln();
|
||||
|
||||
+173
-46
@@ -34,7 +34,7 @@ abstract class PaymentModuleCore extends Module
|
||||
|
||||
/* @var object PaymentCC */
|
||||
public $pcc = null;
|
||||
|
||||
|
||||
public function install()
|
||||
{
|
||||
if (!parent::install())
|
||||
@@ -78,14 +78,14 @@ abstract class PaymentModuleCore extends Module
|
||||
return false;
|
||||
return parent::uninstall();
|
||||
}
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->pcc = new PaymentCC();
|
||||
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
unset($this->pcc);
|
||||
@@ -101,12 +101,12 @@ abstract class PaymentModuleCore extends Module
|
||||
* @param string $paymentMethod Payment method (eg. 'Credit card')
|
||||
* @param string $message Message to attach to order
|
||||
*/
|
||||
public function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown',
|
||||
$message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false,
|
||||
public function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown',
|
||||
$message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false,
|
||||
$secure_key = false, Shop $shop = null)
|
||||
{
|
||||
$cart = new Cart((int)($id_cart));
|
||||
|
||||
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
// Does order already exists ?
|
||||
@@ -114,7 +114,7 @@ abstract class PaymentModuleCore extends Module
|
||||
{
|
||||
if ($secure_key !== false AND $secure_key != $cart->secure_key)
|
||||
die(Tools::displayError());
|
||||
|
||||
|
||||
// For each package, generate an order
|
||||
$delivery_option_list = $cart->getDeliveryOptionList();
|
||||
$package_list = $cart->getPackageList();
|
||||
@@ -128,27 +128,27 @@ abstract class PaymentModuleCore extends Module
|
||||
$cart_delivery_option[$id_address] = $key;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$order_list = array();
|
||||
$order_detail_list = array();
|
||||
$reference = Order::generateReference();
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
|
||||
$id_currency = $currency_special ? (int)($currency_special) : (int)($cart->id_currency);
|
||||
$currency = new Currency($id_currency);
|
||||
|
||||
|
||||
$this->context->cart->order_reference = $reference;
|
||||
|
||||
|
||||
$orderCreationFailed = false;
|
||||
$cart_total_paid = (float)Tools::ps_round((float)($cart->getOrderTotal(true, Cart::BOTH)), 2);
|
||||
|
||||
|
||||
if ($cart->orderExists())
|
||||
{
|
||||
$errorMessage = Tools::displayError('An order has already been placed using this cart.');
|
||||
Logger::addLog($errorMessage, 4, '0000001', 'Cart', intval($cart->id));
|
||||
die($errorMessage);
|
||||
}
|
||||
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers)
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data)
|
||||
foreach ($data['package_list'] as $id_package)
|
||||
@@ -166,10 +166,10 @@ abstract class PaymentModuleCore extends Module
|
||||
$order->id_warehouse = $package_list[$id_address][$id_package]['id_warehouse'];
|
||||
$order->id_cart = (int)($cart->id);
|
||||
$order->reference = $reference;
|
||||
|
||||
|
||||
$order->id_shop = (int)($shop->getID() ? $shop->getID() : $cart->id_shop);
|
||||
$order->id_group_shop = (int)($shop->getID() ? $shop->getGroupID() : $cart->id_group_shop);
|
||||
|
||||
|
||||
$customer = new Customer((int)($order->id_customer));
|
||||
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($customer->secure_key));
|
||||
$order->payment = $paymentMethod;
|
||||
@@ -191,18 +191,18 @@ abstract class PaymentModuleCore extends Module
|
||||
$order->total_shipping = (float)$cart->getPackageShippingCost((int)$id_carrier, true, null, $product_list, $id_carrier);
|
||||
$order->total_shipping_tax_excl = (float)$cart->getPackageShippingCost((int)$id_carrier, false, null, $product_list, $id_carrier);
|
||||
$order->total_shipping_tax_incl = (float)$cart->getPackageShippingCost((int)$id_carrier, true, null, $product_list, $id_carrier);
|
||||
|
||||
|
||||
if (Validate::isLoadedObject($carrier))
|
||||
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
|
||||
|
||||
$order->total_wrapping = (float)abs($cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_excl = (float)abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $product_list, $id_carrier));
|
||||
$order->total_wrapping_tax_incl = (float)abs($cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $product_list, $id_carrier));
|
||||
|
||||
|
||||
$order->total_paid = (float)Tools::ps_round((float)($cart->getOrderTotal(true, Cart::BOTH, $product_list, $id_carrier)), 2);
|
||||
$order->total_paid_tax_excl = (float)Tools::ps_round((float)($cart->getOrderTotal(false, Cart::BOTH, $product_list, $id_carrier)), 2);
|
||||
$order->total_paid_tax_incl = (float)Tools::ps_round((float)($cart->getOrderTotal(true, Cart::BOTH, $product_list, $id_carrier)), 2);
|
||||
|
||||
|
||||
$order->invoice_date = '0000-00-00 00:00:00';
|
||||
$order->delivery_date = '0000-00-00 00:00:00';
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
@@ -211,12 +211,12 @@ abstract class PaymentModuleCore extends Module
|
||||
// We use number_format in order to compare two string
|
||||
if (number_format($cart_total_paid, 2) != number_format($order->total_paid_real, 2))
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
|
||||
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
$order_list[] = $order;
|
||||
|
||||
|
||||
// Insert new Order detail list using cart for the current order
|
||||
$order_detail = new OrderDetail(null, null, $this->context);
|
||||
$order_detail->createList($order, $cart, $id_order_state, $product_list);
|
||||
@@ -249,17 +249,109 @@ abstract class PaymentModuleCore extends Module
|
||||
// Insert new Order detail list using cart for the current order
|
||||
//$orderDetail = new OrderDetail(null, null, $this->context);
|
||||
//$orderDetail->createList($order, $cart, $id_order_state);
|
||||
|
||||
|
||||
//$this->addPCC($order->id, $order->id_currency, $amountPaid);
|
||||
|
||||
|
||||
// Construct order detail table for the email
|
||||
$productsList = '';
|
||||
$products = $cart->getProducts();
|
||||
|
||||
$storeAllTaxes = array();
|
||||
|
||||
foreach ($products AS $key => $product)
|
||||
{
|
||||
$price = Product::getPriceStatic((int)($product['id_product']), false, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), 6, NULL, false, true, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
$price_wt = Product::getPriceStatic((int)($product['id_product']), true, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), 2, NULL, false, true, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
|
||||
|
||||
/* Store tax info */
|
||||
$id_country = (int)Country::getDefaultCountryId();
|
||||
$id_state = 0;
|
||||
$id_county = 0;
|
||||
$rate = 0;
|
||||
$id_address = $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
|
||||
$address_infos = Address::getCountryAndState($id_address);
|
||||
if ($address_infos['id_country'])
|
||||
{
|
||||
$id_country = (int)($address_infos['id_country']);
|
||||
$id_state = (int)$address_infos['id_state'];
|
||||
$id_county = (int)County::getIdCountyByZipCode($address_infos['id_state'], $address_infos['postcode']);
|
||||
}
|
||||
$allTaxes = TaxRulesGroup::getTaxes((int)Product::getIdTaxRulesGroupByIdProduct((int)$product['id_product']), $id_country, $id_state, $id_county);
|
||||
$nTax = 0;
|
||||
foreach ($allTaxes AS $res)
|
||||
{
|
||||
if (!isset($storeAllTaxes[$res->id]))
|
||||
$storeAllTaxes[$res->id] = array();
|
||||
$storeAllTaxes[$res->id]['name'] = $res->name[(int)$order->id_lang];
|
||||
$storeAllTaxes[$res->id]['rate'] = $res->rate;
|
||||
|
||||
if (!$nTax++)
|
||||
$storeAllTaxes[$res->id]['amount'] = ($price * (1 + ($res->rate * 0.01))) - $price;
|
||||
else
|
||||
{
|
||||
$priceTmp = $price_wt / (1 + ($res->rate * 0.01));
|
||||
$storeAllTaxes[$res->id]['amount'] = $price_wt - $priceTmp;
|
||||
}
|
||||
}
|
||||
/* End */
|
||||
|
||||
// Add some informations for virtual products
|
||||
$deadline = '0000-00-00 00:00:00';
|
||||
$download_hash = NULL;
|
||||
if ($id_product_download = ProductDownload::getIdFromIdProduct((int)($product['id_product'])))
|
||||
{
|
||||
$productDownload = new ProductDownload((int)($id_product_download));
|
||||
$deadline = $productDownload->getDeadLine();
|
||||
$download_hash = $productDownload->getHash();
|
||||
}
|
||||
|
||||
// Exclude VAT
|
||||
if (Tax::excludeTaxeOption())
|
||||
{
|
||||
$product['tax'] = 0;
|
||||
$product['rate'] = 0;
|
||||
$tax_rate = 0;
|
||||
}
|
||||
else
|
||||
$tax_rate = Tax::getProductTaxRate((int)($product['id_product']), $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
$ecotaxTaxRate = 0;
|
||||
if (!empty($product['ecotax']))
|
||||
$ecotaxTaxRate = Tax::getProductEcotaxRate($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
|
||||
$product_price = (float)Product::getPriceStatic((int)($product['id_product']), false, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), (Product::getTaxCalculationMethod((int)($order->id_customer)) == PS_TAX_EXC ? 2 : 6), NULL, false, false, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), $specificPrice, false, false);
|
||||
|
||||
$group_reduction = (float)GroupReduction::getValueForProduct((int)$product['id_product'], $customer->id_default_group) * 100;
|
||||
if (!$group_reduction)
|
||||
$group_reduction = Group::getReduction((int)$order->id_customer);
|
||||
|
||||
$quantityDiscount = SpecificPrice::getQuantityDiscount((int)$product['id_product'], Shop::getCurrentShop(), (int)$cart->id_currency, (int)$vat_address->id_country, (int)$customer->id_default_group, (int)$product['cart_quantity']);
|
||||
$unitPrice = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? intval($product['id_product_attribute']) : NULL), 2, NULL, false, true, 1, false, (int)$order->id_customer, NULL, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$quantityDiscountValue = $quantityDiscount ? ((Product::getTaxCalculationMethod((int)$order->id_customer) == PS_TAX_EXC ? Tools::ps_round($unitPrice, 2) : $unitPrice) - $quantityDiscount['price'] * (1 + $tax_rate / 100)) : 0.00;
|
||||
$query .= '('.(int)($order->id).',
|
||||
'.(int)($product['id_product']).',
|
||||
'.(isset($product['id_product_attribute']) ? (int)($product['id_product_attribute']) : 'NULL').',
|
||||
\''.pSQL($product['name'].((isset($product['attributes']) AND $product['attributes'] != NULL) ? ' - '.$product['attributes'] : '')).'\',
|
||||
'.(int)($product['cart_quantity']).',
|
||||
'.$quantityInStock.',
|
||||
'.$product_price.',
|
||||
'.(float)(($specificPrice AND $specificPrice['reduction_type'] == 'percentage') ? $specificPrice['reduction'] * 100 : 0.00).',
|
||||
'.(float)(($specificPrice AND $specificPrice['reduction_type'] == 'amount') ? (!$specificPrice['id_currency'] ? Tools::convertPrice($specificPrice['reduction'], $order->id_currency) : $specificPrice['reduction']) : 0.00).',
|
||||
'.$group_reduction.',
|
||||
'.$quantityDiscountValue.',
|
||||
'.(empty($product['ean13']) ? 'NULL' : '\''.pSQL($product['ean13']).'\'').',
|
||||
'.(empty($product['upc']) ? 'NULL' : '\''.pSQL($product['upc']).'\'').',
|
||||
'.(empty($product['reference']) ? 'NULL' : '\''.pSQL($product['reference']).'\'').',
|
||||
'.(empty($product['supplier_reference']) ? 'NULL' : '\''.pSQL($product['supplier_reference']).'\'').',
|
||||
'.(float)($product['id_product_attribute'] ? $product['weight_attribute'] : $product['weight']).',
|
||||
\''.(empty($tax_rate) ? '' : pSQL($product['tax'])).'\',
|
||||
'.(float)($tax_rate).',
|
||||
'.(float)Tools::convertPrice(floatval($product['ecotax']), intval($order->id_currency)).',
|
||||
'.(float)$ecotaxTaxRate.',
|
||||
'.(($specificPrice AND $specificPrice['from_quantity'] > 1) ? 1 : 0).',
|
||||
\''.pSQL($deadline).'\',
|
||||
\''.pSQL($download_hash).'\'),';
|
||||
|
||||
$customizationQuantity = 0;
|
||||
if (isset($customizedDatas[$product['id_product']][$product['id_product_attribute']]))
|
||||
{
|
||||
@@ -269,15 +361,15 @@ abstract class PaymentModuleCore extends Module
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
|
||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] AS $text)
|
||||
$customizationText .= $text['name'].':'.' '.$text['value'].'<br />';
|
||||
|
||||
|
||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
|
||||
$customizationText .= sizeof($customization['datas'][Product::CUSTOMIZE_FILE]) .' '. Tools::displayError('image(s)').'<br />';
|
||||
|
||||
|
||||
$customizationText .= '---<br />';
|
||||
}
|
||||
|
||||
|
||||
$customizationText = rtrim($customizationText, '---<br />');
|
||||
|
||||
|
||||
$customizationQuantity = (int)($product['customizationQuantityTotal']);
|
||||
$productsList .=
|
||||
'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
|
||||
@@ -288,7 +380,7 @@ abstract class PaymentModuleCore extends Module
|
||||
<td style="padding: 0.6em 0.4em; text-align: right;">'.Tools::displayPrice($customizationQuantity * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? $price : $price_wt), $currency, false).'</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
|
||||
if (!$customizationQuantity OR (int)$product['cart_quantity'] > $customizationQuantity)
|
||||
$productsList .=
|
||||
'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
|
||||
@@ -299,11 +391,46 @@ abstract class PaymentModuleCore extends Module
|
||||
<td style="padding: 0.6em 0.4em; text-align: right;">'.Tools::displayPrice(((int)($product['cart_quantity']) - $customizationQuantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? $price : $price_wt), $currency, false).'</td>
|
||||
</tr>';
|
||||
} // end foreach ($products)
|
||||
|
||||
$cartRulesList = '';
|
||||
$result = $cart->getCartRules();
|
||||
$cartRules = ObjectModel::hydrateCollection('CartRule', $result, (int)$order->id_lang);
|
||||
foreach ($cartRules as $cartRule)
|
||||
|
||||
|
||||
/* Add carrier tax */
|
||||
$shippingCostTaxExcl = $cart->getOrderShippingCost((int)$order->id_carrier, false);
|
||||
$allTaxes = TaxRulesGroup::getTaxes((int)Carrier::getIdTaxRulesGroupByIdCarrier((int)$order->id_carrier), $id_country, $id_state, $id_county);
|
||||
$nTax = 0;
|
||||
|
||||
foreach ($allTaxes AS $res)
|
||||
{
|
||||
if (!isset($res->id))
|
||||
continue;
|
||||
|
||||
if (!isset($storeAllTaxes[$res->id]))
|
||||
$storeAllTaxes[$res->id] = array();
|
||||
if (!isset($storeAllTaxes[$res->id]['amount']))
|
||||
$storeAllTaxes[$res->id]['amount'] = 0;
|
||||
$storeAllTaxes[$res->id]['name'] = $res->name[(int)$order->id_lang];
|
||||
$storeAllTaxes[$res->id]['rate'] = $res->rate;
|
||||
|
||||
if (!$nTax++)
|
||||
$storeAllTaxes[$res->id]['amount'] += ($shippingCostTaxExcl * (1 + ($res->rate * 0.01))) - $shippingCostTaxExcl;
|
||||
else
|
||||
{
|
||||
$priceTmp = $order->total_shipping / (1 + ($res->rate * 0.01));
|
||||
$storeAllTaxes[$res->id]['amount'] += $order->total_shipping - $priceTmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Store taxes */
|
||||
foreach ($storeAllTaxes AS $t)
|
||||
Db::getInstance()->Execute('
|
||||
INSERT INTO '._DB_PREFIX_.'order_tax (id_order, tax_name, tax_rate, amount)
|
||||
VALUES ('.(int)$order->id.', \''.pSQL($t['name']).'\', \''.(float)($t['rate']).'\', '.(float)$t['amount'].')');
|
||||
|
||||
// Insert discounts from cart into order_discount table
|
||||
$discounts = $cart->getDiscounts();
|
||||
$discountsList = '';
|
||||
$total_discount_value = 0;
|
||||
$shrunk = false;
|
||||
foreach ($discounts AS $discount)
|
||||
{
|
||||
$value = $cartRule->getContextualValue(true);
|
||||
// Todo : has not been tested because order processing wasn't functionnal
|
||||
@@ -326,19 +453,19 @@ abstract class PaymentModuleCore extends Module
|
||||
Mail::Send((int)$order->id_lang, 'voucher', Mail::l('New voucher regarding your order #').$order->id, $params, $customer->email, $customer->firstname.' '.$customer->lastname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$order->addCartRule($cartRule->id, $cartRule->name, $value);
|
||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') AND $id_order_state != Configuration::get('PS_OS_CANCELED'))
|
||||
$cartRule->quantity = $cartRule->quantity - 1;
|
||||
$cartRule->update();
|
||||
|
||||
|
||||
$cartRulesList .= '
|
||||
<tr style="background-color:#EBECEE;">
|
||||
<td colspan="4" style="padding:0.6em 0.4em;text-align:right">'.$this->l('Voucher name:').' '.$cartRule->name.'</td>
|
||||
<td style="padding:0.6em 0.4em;text-align:right">'.($value != 0.00 ? '-' : '').Tools::displayPrice($value, $currency, false).'</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
|
||||
// Specify order id for message
|
||||
$oldMessage = Message::getMessageByCartId((int)($cart->id));
|
||||
if ($oldMessage)
|
||||
@@ -347,7 +474,7 @@ abstract class PaymentModuleCore extends Module
|
||||
$message->id_order = (int)$order->id;
|
||||
$message->update();
|
||||
}
|
||||
|
||||
|
||||
// Hook validate order
|
||||
$orderStatus = new OrderState((int)$id_order_state, (int)$order->id_lang);
|
||||
if (Validate::isLoadedObject($orderStatus))
|
||||
@@ -357,7 +484,7 @@ abstract class PaymentModuleCore extends Module
|
||||
if ($orderStatus->logable)
|
||||
ProductSale::addProductSale((int)$product['id_product'], (int)$product['cart_quantity']);
|
||||
}
|
||||
|
||||
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState())
|
||||
{
|
||||
$history = new OrderHistory();
|
||||
@@ -374,7 +501,7 @@ abstract class PaymentModuleCore extends Module
|
||||
$new_history->addWithemail(true, $extraVars);
|
||||
|
||||
unset($order_detail, $pcc);
|
||||
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
$order = new Order($order->id);
|
||||
|
||||
@@ -385,7 +512,7 @@ abstract class PaymentModuleCore extends Module
|
||||
$delivery = new Address((int)($order->id_address_delivery));
|
||||
$delivery_state = $delivery->id_state ? new State((int)($delivery->id_state)) : false;
|
||||
$invoice_state = $invoice->id_state ? new State((int)($invoice->id_state)) : false;
|
||||
|
||||
|
||||
$data = array(
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{lastname}' => $customer->lastname,
|
||||
@@ -434,10 +561,10 @@ abstract class PaymentModuleCore extends Module
|
||||
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $currency, false),
|
||||
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency, false),
|
||||
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $currency, false));
|
||||
|
||||
|
||||
if (is_array($extraVars))
|
||||
$data = array_merge($data, $extraVars);
|
||||
|
||||
|
||||
// Join PDF invoice
|
||||
if ((int)(Configuration::get('PS_INVOICE')) AND Validate::isLoadedObject($orderStatus) AND $orderStatus->invoice AND $order->invoice_number)
|
||||
{
|
||||
@@ -447,7 +574,7 @@ abstract class PaymentModuleCore extends Module
|
||||
}
|
||||
else
|
||||
$fileAttachment = NULL;
|
||||
|
||||
|
||||
if (Validate::isEmail($customer->email))
|
||||
Mail::Send((int)$order->id_lang, 'order_conf', Mail::l('Order confirmation', (int)$order->id_lang), $data, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, $fileAttachment);
|
||||
}
|
||||
@@ -470,7 +597,7 @@ abstract class PaymentModuleCore extends Module
|
||||
die($errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add new PaymentCC to the order
|
||||
* @var int id_order
|
||||
|
||||
+24
-7
@@ -265,6 +265,7 @@ class ProductCore extends ObjectModel
|
||||
protected $identifier = 'id_product';
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'objectMethods' => array('add' => 'addWs', 'update' => 'updateWs'),
|
||||
'objectNodeNames' => 'products',
|
||||
'fields' => array(
|
||||
'id_manufacturer' => array('xlink_resource' => 'manufacturers'),
|
||||
@@ -930,13 +931,13 @@ class ProductCore extends ObjectModel
|
||||
* @deprecated
|
||||
*/
|
||||
public function addProductAttribute($price, $weight, $unit_impact, $ecotax, $quantity, $id_images, $reference,
|
||||
$supplier_reference = null, $ean13, $default, $location = null, $upc = null)
|
||||
$supplier_reference = null, $ean13, $default, $location = null, $upc = null, $minimal_quantity = 1)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
|
||||
$id_product_attribute = $this->addAttribute(
|
||||
$price, $weight, $unit_impact, $ecotax, $id_images,
|
||||
$reference, $ean13, $default, $location, $upc
|
||||
$reference, $ean13, $default, $location, $upc, $minimal_quantity
|
||||
);
|
||||
|
||||
if (!$id_product_attribute)
|
||||
@@ -996,9 +997,10 @@ class ProductCore extends ObjectModel
|
||||
* @param string $location Location
|
||||
* @param string $ean13 Ean-13 barcode
|
||||
* @param boolean $default Is default attribute for product
|
||||
* @param integer $minimal_quantity Minimal quantity to add to cart
|
||||
* @return mixed $id_product_attribute or false
|
||||
*/
|
||||
public function addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $ean13, $default, $location = null, $upc = null)
|
||||
public function addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity = 1)
|
||||
{
|
||||
if (!$this->id)
|
||||
return;
|
||||
@@ -1017,7 +1019,8 @@ class ProductCore extends ObjectModel
|
||||
'location' => pSQL($location),
|
||||
'ean13' => pSQL($ean13),
|
||||
'upc' => pSQL($upc),
|
||||
'default_on' => (int)$default
|
||||
'default_on' => (int)$default,
|
||||
'minimal_quantity' => (int)$minimal_quantity,
|
||||
), 'INSERT');
|
||||
|
||||
$id_product_attribute = Db::getInstance()->Insert_ID();
|
||||
@@ -1042,11 +1045,11 @@ class ProductCore extends ObjectModel
|
||||
* @param string $supplier_reference DEPRECATED
|
||||
*/
|
||||
public function addCombinationEntity($wholesale_price, $price, $weight, $unit_impact, $ecotax, $quantity,
|
||||
$id_images, $reference, $supplier_reference, $ean13, $default, $location = null, $upc = null)
|
||||
$id_images, $reference, $supplier_reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity = 1)
|
||||
{
|
||||
$id_product_attribute = $this->addProductAttribute(
|
||||
$price, $weight, $unit_impact, $ecotax, $quantity, $id_images,
|
||||
$reference, $supplier_reference, $ean13, $default, $location, $upc
|
||||
$reference, $supplier_reference, $ean13, $default, $location, $upc, $minimal_quantity
|
||||
);
|
||||
|
||||
$result = Db::getInstance()->execute(
|
||||
@@ -4106,5 +4109,19 @@ class ProductCore extends ObjectModel
|
||||
return Db::getInstance()->getValue($query);
|
||||
}
|
||||
|
||||
}
|
||||
public function addWs($autodate = true, $nullValues = false)
|
||||
{
|
||||
$success = parent::add($autodate, $nullValues);
|
||||
if ($success)
|
||||
Search::indexation(false, $this->id);
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function updateWs($nullValues = false)
|
||||
{
|
||||
$success = parent::update($nullValues);
|
||||
if ($success)
|
||||
Search::indexation(false, $this->id);
|
||||
return $success;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -115,11 +115,13 @@ class TabCore extends ObjectModel
|
||||
');
|
||||
if (!$profiles || empty($profiles))
|
||||
return false;
|
||||
|
||||
/* Query definition */
|
||||
// note : insert ignore should be avoided
|
||||
$query = 'INSERT IGNORE INTO `'._DB_PREFIX_.'access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) VALUES ';
|
||||
// default admin
|
||||
$query .= '(1, '.(int)$id_tab.', 1, 1, 1, 1),';
|
||||
|
||||
foreach ($profiles as $profile)
|
||||
{
|
||||
// no cast needed for profile[id_profile], which cames from db
|
||||
@@ -251,7 +253,7 @@ class TabCore extends ObjectModel
|
||||
public static function getNewLastPosition($id_parent)
|
||||
{
|
||||
return (Db::getInstance()->getValue('
|
||||
SELECT MAX(position)+1
|
||||
SELECT IFNULL(MAX(position),0)+1
|
||||
FROM `'._DB_PREFIX_.'tab`
|
||||
WHERE `id_parent` = '.(int)$id_parent
|
||||
));
|
||||
|
||||
+44
-7
@@ -643,7 +643,7 @@ class ToolsCore
|
||||
* @param integer $id_lang Language id
|
||||
* @return array Meta tags
|
||||
*/
|
||||
public static function getMetaTags($id_lang, $page_name)
|
||||
public static function getMetaTags($id_lang, $page_name, $title = '')
|
||||
{
|
||||
global $maintenance;
|
||||
|
||||
@@ -670,6 +670,8 @@ class ToolsCore
|
||||
/* Categories specifics meta tags */
|
||||
elseif ($id_category = self::getValue('id_category'))
|
||||
{
|
||||
if (!empty($title))
|
||||
$title = ' - '.$title;
|
||||
$page_number = (int)self::getValue('p');
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description`
|
||||
@@ -682,10 +684,13 @@ class ToolsCore
|
||||
|
||||
// Paginate title
|
||||
if (!empty($row['meta_title']))
|
||||
$row['meta_title'] = $row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||
$row['meta_title'] = $title.$row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||
else
|
||||
$row['meta_title'] = $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||
|
||||
if (!empty($title))
|
||||
$row['meta_title'] = $title.(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||
|
||||
return self::completeMetaTags($row, $row['name']);
|
||||
}
|
||||
}
|
||||
@@ -1227,10 +1232,12 @@ class ToolsCore
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 1.5 use Media::minifyHTML()
|
||||
*/
|
||||
|
||||
public static $a = 0;
|
||||
|
||||
/**
|
||||
* @deprecated as of 1.5 use Media::minifyHTML()
|
||||
*/
|
||||
public static function minifyHTML($html_content)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
@@ -1276,8 +1283,21 @@ class ToolsCore
|
||||
*/
|
||||
public static function minifyHTMLpregCallback($preg_matches)
|
||||
{
|
||||
<<<<<<< .working
|
||||
Tools::displayAsDeprecated();
|
||||
return Media::minifyHTMLpregCallback($preg_matches);
|
||||
=======
|
||||
$args = array();
|
||||
preg_match_all('/[a-zA-Z0-9]+=[\"\\\'][^\"\\\']*[\"\\\']/is', $preg_matches[2], $args);
|
||||
$args = $args[0];
|
||||
sort($args);
|
||||
// if there is no args in the balise, we don't write a space (avoid previous : <title >, now : <title>)
|
||||
if (empty($args))
|
||||
$output = $preg_matches[1].'>';
|
||||
else
|
||||
$output = $preg_matches[1].' '.implode(' ', $args).'>';
|
||||
return $output;
|
||||
>>>>>>> .merge-right.r10309
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1285,8 +1305,25 @@ class ToolsCore
|
||||
*/
|
||||
public static function packJSinHTML($html_content)
|
||||
{
|
||||
<<<<<<< .working
|
||||
Tools::displayAsDeprecated();
|
||||
return Media::packJSinHTML($html_content);
|
||||
=======
|
||||
if (strlen($html_content) > 0)
|
||||
{
|
||||
$htmlContentCopy = $html_content;
|
||||
$html_content = preg_replace_callback(
|
||||
'/\\s*(<script\\b[^>]*?>)([\\s\\S]*?)(<\\/script>)\\s*/i'
|
||||
,array('Tools', 'packJSinHTMLpregCallback')
|
||||
,$html_content);
|
||||
|
||||
// If the string is too big preg_replace return null: http://php.net/manual/en/function.preg-replace-callback.php
|
||||
// In this case, we don't compress the content
|
||||
if ($html_content === null)
|
||||
{
|
||||
error_log('Error occured in function packJSinHTML');
|
||||
return $htmlContentCopy;
|
||||
>>>>>>> .merge-right.r10309
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1796,11 +1833,11 @@ FileETag INode MTime Size
|
||||
$orderByPrefix = '';
|
||||
if ($prefix)
|
||||
{
|
||||
if ($value == 'id_product' || $value == 'date_add' || $value == 'price')
|
||||
if ($value == 'id_product' || $value == 'date_add' || $value == 'date_upd' || $value == 'price')
|
||||
$orderByPrefix = 'p.';
|
||||
elseif ($value == 'name')
|
||||
$orderByPrefix = 'pl.';
|
||||
elseif ($value == 'manufacturer')
|
||||
elseif ($value == 'manufacturer_name')
|
||||
$orderByPrefix = 'm.';
|
||||
elseif ($value == 'position' || empty($value))
|
||||
$orderByPrefix = 'cp.';
|
||||
|
||||
+22
-16
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -39,12 +39,14 @@ class UpgraderCore
|
||||
|
||||
public $version_name;
|
||||
public $version_num;
|
||||
public $version_is_modified = null;
|
||||
/**
|
||||
* @var string contains hte url where to download the file
|
||||
*/
|
||||
public $link;
|
||||
public $autoupgrade;
|
||||
public $autoupgrade_module;
|
||||
public $autoupgrade_last_version;
|
||||
public $changelog;
|
||||
public $md5;
|
||||
|
||||
@@ -65,7 +67,7 @@ class UpgraderCore
|
||||
|
||||
/**
|
||||
* downloadLast download the last version of PrestaShop and save it in $dest/$filename
|
||||
*
|
||||
*
|
||||
* @param string $dest directory where to save the file
|
||||
* @param string $filename new filename
|
||||
* @return boolean
|
||||
@@ -94,13 +96,12 @@ class UpgraderCore
|
||||
|
||||
/**
|
||||
* checkPSVersion ask to prestashop.com if there is a new version. return an array if yes, false otherwise
|
||||
*
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function checkPSVersion($force = false)
|
||||
{
|
||||
if (empty($this->link))
|
||||
{
|
||||
|
||||
if (class_exists('Configuration'))
|
||||
$last_check = Configuration::get('PS_LAST_VERSION_CHECK');
|
||||
else
|
||||
@@ -112,7 +113,6 @@ class UpgraderCore
|
||||
libxml_set_streams_context(@stream_context_create(array('http' => array('timeout' => 3))));
|
||||
if ($feed = @simplexml_load_file($this->rss_version_link))
|
||||
{
|
||||
|
||||
$this->version_name = (string)$feed->version->name;
|
||||
$this->version_num = (string)$feed->version->num;
|
||||
$this->link = (string)$feed->download->link;
|
||||
@@ -120,6 +120,7 @@ class UpgraderCore
|
||||
$this->changelog = (string)$feed->download->changelog;
|
||||
$this->autoupgrade = (int)$feed->autoupgrade;
|
||||
$this->autoupgrade_module = (int)$feed->autoupgrade_module;
|
||||
$this->autoupgrade_last_version = (string)$feed->autoupgrade_last_version;
|
||||
$this->desc = (string)$feed->desc ;
|
||||
$config_last_version = array(
|
||||
'name' => $this->version_name,
|
||||
@@ -128,6 +129,7 @@ class UpgraderCore
|
||||
'md5' => $this->md5,
|
||||
'autoupgrade' => $this->autoupgrade,
|
||||
'autoupgrade_module' => $this->autoupgrade_module,
|
||||
'autoupgrade_last_version' => $this->autoupgrade_last_version,
|
||||
'changelog' => $this->changelog,
|
||||
'desc' => $this->desc
|
||||
);
|
||||
@@ -139,8 +141,7 @@ class UpgraderCore
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->loadFromConfig();
|
||||
}
|
||||
$this->loadFromConfig();
|
||||
// retro-compatibility :
|
||||
// return array(name,link) if you don't use the last version
|
||||
// false otherwise
|
||||
@@ -155,7 +156,7 @@ class UpgraderCore
|
||||
|
||||
/**
|
||||
* load the last version informations stocked in base
|
||||
*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function loadFromConfig()
|
||||
@@ -173,6 +174,8 @@ class UpgraderCore
|
||||
$this->autoupgrade = $last_version_check['autoupgrade'];
|
||||
if (isset($last_version_check['autoupgrade_module']))
|
||||
$this->autoupgrade_module = $last_version_check['autoupgrade_module'];
|
||||
if (isset($last_version_check['autoupgrade_last_version']))
|
||||
$this->autoupgrade_last_version = $last_version_check['autoupgrade_last_version'];
|
||||
if (isset($last_version_check['md5']))
|
||||
$this->md5 = $last_version_check['md5'];
|
||||
if (isset($last_version_check['desc']))
|
||||
@@ -184,17 +187,19 @@ class UpgraderCore
|
||||
}
|
||||
|
||||
/**
|
||||
* return an array of files
|
||||
* return an array of files
|
||||
* that the md5file does not match to the original md5file (provided by $rss_md5file_link_dir )
|
||||
* @return void
|
||||
*/
|
||||
public function getChangedFilesList()
|
||||
{
|
||||
if (count($this->changed_files) == 0)
|
||||
if (is_array($this->changed_files) && count($this->changed_files) == 0)
|
||||
{
|
||||
$checksum = @simplexml_load_file($this->rss_md5file_link_dir._PS_VERSION_.'.xml');
|
||||
if ($checksum === false)
|
||||
return false;
|
||||
if ($checksum == false)
|
||||
{
|
||||
$this->changed_files = false;
|
||||
}
|
||||
else
|
||||
$this->browseXmlAndCompare($checksum->ps_root_dir[0]);
|
||||
}
|
||||
@@ -202,13 +207,13 @@ class UpgraderCore
|
||||
}
|
||||
|
||||
/** populate $this->changed_files with $path
|
||||
* in sub arrays mail, translation and core items
|
||||
* in sub arrays mail, translation and core items
|
||||
* @param string $path filepath to add, relative to _PS_ROOT_DIR_
|
||||
*/
|
||||
protected function addChangedFile($path)
|
||||
{
|
||||
$this->version_is_modified = true;
|
||||
|
||||
|
||||
if (strpos($path, 'mails/') !== false)
|
||||
$this->changed_files['mail'][] = $path;
|
||||
else if (
|
||||
@@ -254,7 +259,7 @@ class UpgraderCore
|
||||
|
||||
$fullpath = str_replace('ps_root_dir', _PS_ROOT_DIR_, $fullpath);
|
||||
|
||||
// replace default admin dir by current one
|
||||
// replace default admin dir by current one
|
||||
$fullpath = str_replace(_PS_ROOT_DIR_.'/admin', _PS_ADMIN_DIR_, $fullpath);
|
||||
if (!file_exists($fullpath))
|
||||
$this->addMissingFile($relative_path);
|
||||
@@ -274,6 +279,7 @@ class UpgraderCore
|
||||
|
||||
public function isAuthenticPrestashopVersion()
|
||||
{
|
||||
|
||||
$this->getChangedFilesList();
|
||||
return !$this->version_is_modified;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class ValidateCore
|
||||
* @param string $email e-mail address to validate
|
||||
* @return boolean Validity is ok or not
|
||||
*/
|
||||
public static function isEmail($email)
|
||||
public static function isEmail($email, $required = true)
|
||||
{
|
||||
return !empty($email) AND preg_match('/^[a-z0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z0-9]+[._a-z0-9-]*\.[a-z0-9]+$/ui', $email);
|
||||
}
|
||||
|
||||
@@ -1115,7 +1115,11 @@ class OrderCore extends ObjectModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setCurrentState($id_order_state, $id_employee)
|
||||
/** Set current order state
|
||||
* @param int $id_order_state
|
||||
* @param int $id_employee (/!\ not optional except for Webservice.
|
||||
*/
|
||||
public function setCurrentState($id_order_state, $id_employee = 0)
|
||||
{
|
||||
if (empty($id_order_state))
|
||||
return false;
|
||||
|
||||
@@ -122,7 +122,8 @@ class OrderHistoryCore extends ObjectModel
|
||||
|
||||
if ($newOS->invoice AND !$order->invoice_number)
|
||||
$order->setInvoice();
|
||||
if ($newOS->delivery AND !$order->delivery_number)
|
||||
// Update delivery date even if it was already set by another state change
|
||||
if ($newOS->delivery)
|
||||
$order->setDelivery();
|
||||
Hook::postUpdateOrderStatus((int)($new_order_state), (int)($id_order));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user