diff --git a/cache/class_index.php b/cache/class_index.php index 724b23638..606505b20 100644 --- a/cache/class_index.php +++ b/cache/class_index.php @@ -327,6 +327,8 @@ 'AdminCountriesController' => '', 'AdminCurrenciesControllerCore' => 'controllers/admin/AdminCurrenciesController.php', 'AdminCurrenciesController' => '', + 'AdminCustomersControllerCore' => 'controllers/admin/AdminCustomersController.php', + 'AdminCustomersController' => '', 'AdminDbControllerCore' => 'controllers/admin/AdminDbController.php', 'AdminDbController' => '', 'AdminDeliverySlipControllerCore' => 'controllers/admin/AdminDeliverySlipController.php', @@ -343,8 +345,12 @@ 'AdminHomeControllerCore' => 'controllers/admin/AdminHomeController.php', 'AdminHomeController' => 'override/controllers/admin/AdminHomeController.php', 'AdminImagesController' => 'controllers/admin/AdminImagesController.php', + 'AdminInformationControllerCore' => 'controllers/admin/AdminInformationController.php', + 'AdminInformationController' => '', 'AdminInvoicesControllerCore' => 'controllers/admin/AdminInvoicesController.php', 'AdminInvoicesController' => '', + 'AdminLanguagesControllerCore' => 'controllers/admin/AdminLanguagesController.php', + 'AdminLanguagesController' => '', 'AdminLogsControllerCore' => 'controllers/admin/AdminLogsController.php', 'AdminLogsController' => '', 'AdminMetaControllerCore' => 'controllers/admin/AdminMetaController.php', @@ -354,7 +360,13 @@ 'AdminOrdersController' => '', 'AdminPDFControllerCore' => 'controllers/admin/AdminPDFController.php', 'AdminPDFController' => '', + 'AdminPPreferencesControllerCore' => 'controllers/admin/AdminPPreferencesController.php', + 'AdminPPreferencesController' => '', + 'AdminPaymentControllerCore' => 'controllers/admin/AdminPaymentController.php', + 'AdminPaymentController' => '', 'AdminProductsController' => 'controllers/admin/AdminProductsController.php', + 'AdminProfilesControllerCore' => 'controllers/admin/AdminProfilesController.php', + 'AdminProfilesController' => '', 'AdminQuickAccessesController' => 'controllers/admin/AdminQuickAccessesController.php', 'AdminRequestSqlControllerCore' => 'controllers/admin/AdminRequestSqlController.php', 'AdminRequestSqlController' => '', diff --git a/classes/Order.php b/classes/Order.php index 54e8744bb..57f7d30b3 100644 --- a/classes/Order.php +++ b/classes/Order.php @@ -538,7 +538,7 @@ class OrderCore extends ObjectModel */ protected function setProductCurrentStock(&$product) { - $product['current_stock'] = StockManagerFactory::getManager()->getProductRealQuantities($product['product_id'], $product['product_attribute_id'], null, true); + $product['current_stock'] = StockManagerFactory::getManager()->getProductPhysicalQuantities($product['product_id'], $product['product_attribute_id'], null, true); } /** diff --git a/classes/Product.php b/classes/Product.php index 7edd8e4c7..d09a456fd 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -2085,7 +2085,7 @@ class ProductCore extends ObjectModel else if (is_string($productAttribute)) $sql->where('stock.id_product_attribute = IFNULL('.pSQL($productAttribute).'.id_product_attribute, 0)'); } - $sql->where(ltrim($shop->addSqlRestriction(Shop::SHARE_STOCK, 'stock'), ' AND ')); + $sql->where(ltrim($shop->addSqlRestriction(false, 'stock'), ' AND ')); } else { @@ -2099,7 +2099,7 @@ class ProductCore extends ObjectModel else if (is_string($productAttribute)) $sql .= ' AND stock.id_product_attribute = IFNULL('.pSQL($productAttribute).'.id_product_attribute, 0)'; } - $sql .= $shop->addSqlRestriction(Shop::SHARE_STOCK, 'stock').' '; + $sql .= $shop->addSqlRestriction(false, 'stock').' '; } return $sql; @@ -2125,7 +2125,7 @@ class ProductCore extends ObjectModel FROM '._DB_PREFIX_.'stock_available WHERE id_product = '.$this->id.' AND id_product_attribute = 0'. - $context->shop->addSqlRestriction(Shop::SHARE_STOCK); + $context->shop->addSqlRestriction(); return (int)Db::getInstance()->getValue($sql); } @@ -2149,7 +2149,7 @@ class ProductCore extends ObjectModel FROM '._DB_PREFIX_.'stock_available WHERE id_product = '.$this->id.' AND id_product_attribute = 0'. - $context->shop->addSqlRestriction(Shop::SHARE_STOCK); + $context->shop->addSqlRestriction(); return (int)Db::getInstance()->getValue($sql); } @@ -2157,7 +2157,7 @@ class ProductCore extends ObjectModel * Update available product quantities * * @deprecated since 1.5.0 - * + * * @param array $product Array with ordered product (quantity, id_product_attribute if applicable) * @return mixed Query result */ @@ -2185,6 +2185,9 @@ class ProductCore extends ObjectModel return $productObj->addStockMvt(-(int)$product['cart_quantity'], (int)_STOCK_MOVEMENT_ORDER_REASON_, (int)$product['id_product_attribute'], (int)$id_order, null); } + /** + * @deprecated since 1.5.0 + */ public static function reinjectQuantities(&$orderDetail, $quantity, Context $context = null) { if (!$context) @@ -2227,7 +2230,7 @@ class ProductCore extends ObjectModel if ($this->isAvailableWhenOutOfStock($this->getOutOfStock())) return true; - + if(isset($this->id_product_attribute)) $id_product_attribute = $this->id_product_attribute; else diff --git a/classes/shop/GroupShop.php b/classes/shop/GroupShop.php index f763cdf59..d5781d27c 100644 --- a/classes/shop/GroupShop.php +++ b/classes/shop/GroupShop.php @@ -1,6 +1,6 @@ 64); protected $fieldsValidate = array( 'active' => 'isBool', 'share_customer' => 'isBool', 'share_order' => 'isBool', - 'share_stock' => 'isBool', 'name' => 'isGenericName', ); protected $table = 'group_shop'; @@ -51,7 +49,6 @@ class GroupShopCore extends ObjectModel private static $assoTables = array( 'attribute_group' => array('type' => 'group_shop'), 'attribute' => array('type' => 'group_shop'), - //'customer_group' => array('type' => 'group_shop'), 'feature' => array('type' => 'group_shop'), 'group' => array('type' => 'group_shop'), 'manufacturer' => array('type' => 'group_shop'), @@ -66,20 +63,19 @@ class GroupShopCore extends ObjectModel $fields['name'] = pSQL($this->name); $fields['share_customer'] = (int)$this->share_customer; - $fields['share_stock'] = (int)$this->share_stock; - $fields['share_order'] = ($fields['share_customer'] && $fields['share_stock']) ? (int)$this->share_order : false; + $fields['share_order'] = ($fields['share_customer']) ? (int)$this->share_order : false; $fields['active'] = (int)$this->active; $fields['deleted'] = (int)$this->deleted; return $fields; } - + public static function getGroupShops($active = true) { - return Db::getInstance()->executeS('SELECT * + return Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'group_shop WHERE `deleted`= 0 AND `active`='.(int)$active); } - + public function delete() { if (!$res = parent::delete()) @@ -126,7 +122,7 @@ class GroupShopCore extends ObjectModel /** * Return a group shop ID from group shop name - * + * * @param string $name * @return int */ @@ -137,7 +133,7 @@ class GroupShopCore extends ObjectModel WHERE name = \''.pSQL($name).'\''; return (int)Db::getInstance()->getValue($sql); } - + public function copyGroupShopData($old_id, $tables_import = false, $deleted = false) { foreach (GroupShop::getAssoTables() AS $table_name => $row) diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 4a5da5949..396d90769 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -79,7 +79,6 @@ class ShopCore extends ObjectModel 'module_currency' => array('type' => 'fk_shop'), 'module_country' => array('type' => 'fk_shop'), 'module_group' => array('type' => 'fk_shop'), - //'stock' => array('type' => 'fk_shop', 'primary' => 'id_stock'), 'product' => array('type' => 'shop'), 'product_lang' => array('type' => 'fk_shop'), 'referrer' => array('type' => 'shop'), @@ -108,7 +107,6 @@ class ShopCore extends ObjectModel */ const SHARE_CUSTOMER = 'share_customer'; const SHARE_ORDER = 'share_order'; - const SHARE_STOCK = 'share_stock'; public function getFields() { @@ -162,14 +160,6 @@ class ShopCore extends ObjectModel foreach (Shop::getAssoTables() as $table_name => $row) { - // Special case for stock if current shop is in a share stock group - /*if ($table_name == 'stock') - { - $group = new GroupShop($this->id_group_shop); - if ($group->share_stock && $group->getTotalShops() > 1) - continue; - }*/ - $id = 'id_'.$row['type']; if ($row['type'] == 'fk_shop') $id = 'id_shop'; @@ -410,7 +400,6 @@ class ShopCore extends ObjectModel 'name' => $row['group_name'], 'share_customer' => $row['share_customer'], 'share_order' => $row['share_order'], - 'share_stock' => $row['share_stock'], 'totalShops' => self::getTotalShopsByIdGroupShop($row['id_group_shop']), 'shops' => array(), ); @@ -537,12 +526,12 @@ class ShopCore extends ObjectModel * If the shop group has the option $type activated, get all shops ID of this group, else get current shop ID * * @param int $shop_id - * @param int $type Shop::SHARE_CUSTOMER | Shop::SHARE_ORDER | Shop::SHARE_STOCK + * @param int $type Shop::SHARE_CUSTOMER | Shop::SHARE_ORDER * @return array */ public static function getSharedShops($shop_id, $type) { - if (!in_array($type, array(Shop::SHARE_CUSTOMER, Shop::SHARE_ORDER, Shop::SHARE_STOCK))) + if (!in_array($type, array(Shop::SHARE_CUSTOMER, Shop::SHARE_ORDER))) die('Wrong argument ($type) in Shop::getSharedShops() method'); Shop::cacheShops(); @@ -670,8 +659,8 @@ class ShopCore extends ObjectModel { if ($shop_id || $shop_group_id) $restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', $this->getListOfID($share)).') '; - else if ($share == Shop::SHARE_STOCK) - $restriction = ' AND '.$alias.'id_shop = '.$this->getID(true); + //else if ($share == Shop::SHARE_STOCK) + // $restriction = ' AND '.$alias.'id_shop = '.$this->getID(true); } return $restriction; diff --git a/controllers/admin/AdminGroupShopController.php b/controllers/admin/AdminGroupShopController.php index 4c79021fe..fbdbdbe3a 100644 --- a/controllers/admin/AdminGroupShopController.php +++ b/controllers/admin/AdminGroupShopController.php @@ -83,27 +83,6 @@ class AdminGroupShopControllerCore extends AdminController ), 'p' => $this->l('Share customers between shops of this group') ), - array( - 'type' => 'radio', - 'label' => $this->l('Share stock:'), - 'name' => 'share_stock', - 'required' => true, - 'class' => 't', - 'is_bool' => true, - 'values' => array( - array( - 'id' => 'share_stock_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'share_stock_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ), - 'p' => $this->l('Share stock between shops of this group') - ), array( 'type' => 'radio', 'label' => $this->l('Share orders:'), @@ -159,7 +138,6 @@ class AdminGroupShopControllerCore extends AdminController if (Shop::getTotalShops() > 1 && $obj->id) $disabled = array( 'share_customer' => true, - 'share_stock' => true, 'share_order' => true, 'active' => false ); diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 39163bbcc..72252bb55 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -59,7 +59,6 @@ class AdminProductsController extends AdminController 'name_category' => array('title' => $this->l('Category'), 'width' => 100, 'filter_key' => 'cl!name'), 'price' => array('title' => $this->l('Base price'), 'width' => 70, 'price' => true, 'align' => 'right', 'filter_key' => 'a!price'), 'price_final' => array('title' => $this->l('Final price'), 'width' => 70, 'price' => true, 'align' => 'right', 'havingFilter' => true, 'orderby' => false), - 'quantity' => array('title' => $this->l('Quantity'), 'width' => 30, 'align' => 'right', 'filter_key' => 'a!quantity', 'type' => 'decimal'), 'active' => array('title' => $this->l('Displayed'), 'active' => 'status', 'filter_key' => 'a!active', 'align' => 'center', 'type' => 'bool', 'orderby' => false), 'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'cp!position', 'align' => 'center', 'position' => 'position'), ); @@ -70,14 +69,14 @@ class AdminProductsController extends AdminController else $this->_category = new Category(1); - $this->_join = Product::sqlStock('a').' + $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (a.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang`) LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` AND i.`cover` = 1) LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product`) LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)$this->context->country->id.' AND tr.`id_state` = 0) LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)'; $this->_filter = 'AND cp.`id_category` = '.(int)($this->_category->id); - $this->_select = 'cl.name `name_category`, cp.`position`, i.`id_image`, (a.`price` * ((100 + (t.`rate`))/100)) AS price_final, SUM(stock.quantity) AS quantity'; + $this->_select = 'cl.name `name_category`, cp.`position`, i.`id_image`, (a.`price` * ((100 + (t.`rate`))/100)) AS price_final'; parent::__construct(); } diff --git a/modules/mailalerts/mailalerts.php b/modules/mailalerts/mailalerts.php index b34205a7e..b488615cd 100644 --- a/modules/mailalerts/mailalerts.php +++ b/modules/mailalerts/mailalerts.php @@ -1,6 +1,6 @@ author = 'PrestaShop'; parent::__construct(); - + if ($this->id) $this->_refreshProperties(); @@ -104,7 +104,7 @@ class MailAlerts extends Module return false; return parent::uninstall(); } - + private function _refreshProperties() { $this->_merchant_mails = Configuration::get('MA_MERCHANT_MAILS'); @@ -133,7 +133,7 @@ class MailAlerts extends Module $message = $this->l('No message'); $itemsTable = ''; - + $products = $params['order']->getProducts(); $customizedDatas = Product::getAllCustomizedDatas(intval($params['cart']->id)); Product::addCustomizationPrice($products, $customizedDatas); @@ -141,7 +141,7 @@ class MailAlerts extends Module { $unit_price = $product['product_price_wt']; $price = $product['total_price']; - + $customizationText = ''; if (isset($customizedDatas[$product['product_id']][$product['product_attribute_id']])) { @@ -151,16 +151,16 @@ class MailAlerts extends Module if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] AS $text) $customizationText .= $text['name'].':'.' '.$text['value'].'
'; - + if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) $customizationText .= sizeof($customization['datas'][Product::CUSTOMIZE_FILE]) .' '. Tools::displayError('image(s)').'
'; - - $customizationText .= '---
'; + + $customizationText .= '---
'; } - + $customizationText = rtrim($customizationText, '---
'); } - + $itemsTable .= ' '.$product['product_reference'].' @@ -192,11 +192,11 @@ class MailAlerts extends Module '{email}' => $customer->email, '{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"), '{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"), - '{delivery_block_html}' => $this->_getFormatedAddress($delivery, "
", + '{delivery_block_html}' => $this->_getFormatedAddress($delivery, "
", array( - 'firstname' => '%s', + 'firstname' => '%s', 'lastname' => '%s')), - '{invoice_block_html}' => $this->_getFormatedAddress($invoice, "
", + '{invoice_block_html}' => $this->_getFormatedAddress($invoice, "
", array( 'firstname' => '%s', 'lastname' => '%s')), @@ -277,10 +277,10 @@ class MailAlerts extends Module public function customerHasNotification($id_customer, $id_product, $id_product_attribute) { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT * - FROM `'._DB_PREFIX_.'mailalert_customer_oos` - WHERE `id_customer` = '.(int)($id_customer).' - AND `id_product` = '.(int)($id_product).' + SELECT * + FROM `'._DB_PREFIX_.'mailalert_customer_oos` + WHERE `id_customer` = '.(int)($id_customer).' + AND `id_product` = '.(int)($id_product).' AND `id_product_attribute` = '.(int)($id_product_attribute)); return sizeof($result); } @@ -327,20 +327,20 @@ class MailAlerts extends Module $sql = 'SELECT id_product, quantity FROM '._DB_PREFIX_.'stock_available WHERE id_product_attribute = '.(int)$params['id_product_attribute'] - .Context::getContext()->shop->addSqlRestriction(Shop::SHARE_STOCK); + .Context::getContext()->shop->addSqlRestriction(); $result = Db::getInstance()->getRow($sql); if ($this->_customer_qty AND $result['quantity'] > 0) $this->sendCustomerAlert((int)$result['id_product'], (int)$params['id_product_attribute']); } - + public function sendCustomerAlert($id_product, $id_product_attribute) { $customers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT id_customer, customer_email FROM `'._DB_PREFIX_.'mailalert_customer_oos` WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute); - + $product = new Product((int)$id_product, false, $this->context->language->id); $templateVars = array( '{product}' => (is_array($product->name) ? $product->name[(int)Configuration::get('PS_LANG_DEFAULT')] : $product->name), @@ -368,12 +368,12 @@ class MailAlerts extends Module self::deleteAlert((int)$customer_id, strval($customer_email), (int)$id_product, (int)$id_product_attribute); } } - + public function hookCustomerAccount($params) { return $this->_customer_qty ? $this->display(__FILE__, 'my-account.tpl') : NULL; } - + public function hookMyAccountBlock($params) { return $this->hookCustomerAccount($params); @@ -525,7 +525,7 @@ class MailAlerts extends Module foreach ($result AS $k => $row) $products[$i]['attributes_small'] .= $row['attribute_name'].', '; $products[$i]['attributes_small'] = rtrim($products[$i]['attributes_small'], ', '); - + // cover $attrgrps = $obj->getAttributesGroups($id_lang); foreach ($attrgrps AS $attrgrp) @@ -556,18 +556,18 @@ class MailAlerts extends Module public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute) { return Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'mailalert_customer_oos` + DELETE FROM `'._DB_PREFIX_.'mailalert_customer_oos` WHERE `id_customer` = '.(int)($id_customer).' AND `customer_email` = \''.pSQL($customer_email).'\' AND `id_product` = '.(int)($id_product).' AND `id_product_attribute` = '.(int)($id_product_attribute)); } - + public function hookDeleteProduct($params) { Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'mailalert_customer_oos` WHERE `id_product` = '.(int)$params['product']->id); } - + public function hookDeleteProductAttribute($params) { if ($params['deleteAllAttributes']) @@ -575,7 +575,7 @@ class MailAlerts extends Module WHERE `id_product` = '.(int)$params['id_product']); else Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'mailalert_customer_oos` - WHERE `id_product_attribute` = '.(int)$params['id_product_attribute'].' + WHERE `id_product_attribute` = '.(int)$params['id_product_attribute'].' AND `id_product` = '.(int)$params['id_product']); } }