This commit is contained in:
2025-03-21 20:24:43 +01:00
parent 224398df90
commit f34c9162d4
12427 changed files with 5329941 additions and 373384 deletions

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -52,6 +52,9 @@ class StockCore extends ObjectModel
/** @var string UPC */
public $upc;
/** @var string MPN */
public $mpn;
/** @var int the physical quantity in stock for the current product in the current warehouse */
public $physical_quantity;
@@ -64,36 +67,37 @@ class StockCore extends ObjectModel
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'stock',
'primary' => 'id_stock',
'fields' => array(
'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference'),
'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13'),
'isbn' => array('type' => self::TYPE_STRING, 'validate' => 'isIsbn'),
'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc'),
'physical_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'usable_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true),
'price_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
),
);
'fields' => [
'id_warehouse' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_product' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_product_attribute' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'reference' => ['type' => self::TYPE_STRING, 'validate' => 'isReference'],
'ean13' => ['type' => self::TYPE_STRING, 'validate' => 'isEan13'],
'isbn' => ['type' => self::TYPE_STRING, 'validate' => 'isIsbn'],
'upc' => ['type' => self::TYPE_STRING, 'validate' => 'isUpc'],
'mpn' => ['type' => self::TYPE_STRING, 'validate' => 'isMpn'],
'physical_quantity' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true],
'usable_quantity' => ['type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true],
'price_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
'fields' => array(
'id_warehouse' => array('xlink_resource' => 'warehouses'),
'id_product' => array('xlink_resource' => 'products'),
'id_product_attribute' => array('xlink_resource' => 'combinations'),
'real_quantity' => array('getter' => 'getWsRealQuantity', 'setter' => false),
),
'hidden_fields' => array(
),
);
protected $webserviceParameters = [
'fields' => [
'id_warehouse' => ['xlink_resource' => 'warehouses'],
'id_product' => ['xlink_resource' => 'products'],
'id_product_attribute' => ['xlink_resource' => 'combinations'],
'real_quantity' => ['getter' => 'getWsRealQuantity', 'setter' => false],
],
'hidden_fields' => [
],
];
/**
* @see ObjectModel::update()
@@ -116,7 +120,7 @@ class StockCore extends ObjectModel
}
/**
* Gets reference, ean13 , isbn and upc of the current product
* Gets reference, ean13 , isbn, mpn and upc of the current product
* Stores it in stock for stock_mvt integrity and history purposes.
*/
protected function getProductInformations()
@@ -124,7 +128,7 @@ class StockCore extends ObjectModel
// if combinations
if ((int) $this->id_product_attribute > 0) {
$query = new DbQuery();
$query->select('reference, ean13, isbn, upc');
$query->select('reference, ean13, isbn, mpn, upc');
$query->from('product_attribute');
$query->where('id_product = ' . (int) $this->id_product);
$query->where('id_product_attribute = ' . (int) $this->id_product_attribute);
@@ -139,6 +143,7 @@ class StockCore extends ObjectModel
$this->ean13 = $row['ean13'];
$this->isbn = $row['isbn'];
$this->upc = $row['upc'];
$this->mpn = $row['mpn'];
}
} else {
// else, simple product
@@ -149,6 +154,7 @@ class StockCore extends ObjectModel
$this->ean13 = $product->ean13;
$this->isbn = $product->isbn;
$this->upc = $product->upc;
$this->mpn = $product->mpn;
}
}
}

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PrestaShop\PrestaShop\Adapter\ServiceLocator;
@@ -48,11 +48,23 @@ class StockAvailableCore extends ObjectModel
/** @var int the quantity available for sale */
public $quantity = 0;
/** @var bool determine if the available stock value depends on physical stock */
/**
* @deprecated since 1.7.8
* This property was only relevant to advanced stock management and that feature is not maintained anymore
*
* @var bool determine if the available stock value depends on physical stock
*/
public $depends_on_stock = false;
/** @var bool determine if a product is out of stock - it was previously in Product class */
public $out_of_stock = false;
/**
* Determine if a product is out of stock - it was previously in Product class
* - O Deny orders
* - 1 Allow orders
* - 2 Use global setting
*
* @var int
*/
public $out_of_stock = 0;
/** @var string the location of the stock for this product / combination */
public $location = '';
@@ -60,38 +72,38 @@ class StockAvailableCore extends ObjectModel
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'stock_available',
'primary' => 'id_stock_available',
'fields' => array(
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true),
'depends_on_stock' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
'out_of_stock' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true),
'location' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
),
);
'fields' => [
'id_product' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_product_attribute' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_shop' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'id_shop_group' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'quantity' => ['type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true, 'size' => 10],
'depends_on_stock' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true],
'out_of_stock' => ['type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true],
'location' => ['type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
'fields' => array(
'id_product' => array('xlink_resource' => 'products'),
'id_product_attribute' => array('xlink_resource' => 'combinations'),
'id_shop' => array('xlink_resource' => 'shops'),
'id_shop_group' => array('xlink_resource' => 'shop_groups'),
),
'hidden_fields' => array(
),
'objectMethods' => array(
protected $webserviceParameters = [
'fields' => [
'id_product' => ['xlink_resource' => 'products'],
'id_product_attribute' => ['xlink_resource' => 'combinations'],
'id_shop' => ['xlink_resource' => 'shops'],
'id_shop_group' => ['xlink_resource' => 'shop_groups'],
],
'hidden_fields' => [
],
'objectMethods' => [
'add' => 'addWs',
'update' => 'updateWs',
),
);
],
];
/**
* For a given {id_product, id_product_attribute and id_shop}, gets the stock available id associated.
@@ -105,7 +117,7 @@ class StockAvailableCore extends ObjectModel
public function updateWs()
{
if ($this->depends_on_stock) {
return WebserviceRequest::getInstance()->setError(500, $this->trans('You cannot update the available stock when it depends on stock.', array(), 'Admin.Catalog.Notification'), 133);
return WebserviceRequest::getInstance()->setError(500, $this->trans('You cannot update the available stock when it depends on stock.', [], 'Admin.Catalog.Notification'), 133);
}
return $this->update();
@@ -163,7 +175,7 @@ class StockAvailableCore extends ObjectModel
// gets warehouse ids grouped by shops
$ids_warehouse = Warehouse::getWarehousesGroupedByShops();
if ($order_id_shop !== null) {
$order_warehouses = array();
$order_warehouses = [];
$wh = Warehouse::getWarehouses(false, (int) $order_id_shop);
foreach ($wh as $warehouse) {
$order_warehouses[] = $warehouse['id_warehouse'];
@@ -171,7 +183,7 @@ class StockAvailableCore extends ObjectModel
}
// gets all product attributes ids
$ids_product_attribute = array();
$ids_product_attribute = [];
foreach (Product::getProductAttributesIds($id_product) as $id_product_attribute) {
$ids_product_attribute[] = $id_product_attribute['id_product_attribute'];
}
@@ -190,7 +202,7 @@ class StockAvailableCore extends ObjectModel
// if it's a simple product
if (empty($ids_product_attribute)) {
$allowed_warehouse_for_product = WareHouse::getProductWarehouseList((int) $id_product, 0, (int) $id_shop);
$allowed_warehouse_for_product_clean = array();
$allowed_warehouse_for_product_clean = [];
foreach ($allowed_warehouse_for_product as $warehouse) {
$allowed_warehouse_for_product_clean[] = (int) $warehouse['id_warehouse'];
}
@@ -201,19 +213,20 @@ class StockAvailableCore extends ObjectModel
$product_quantity = $manager->getProductRealQuantities($id_product, null, $allowed_warehouse_for_product_clean, true);
Hook::exec('actionUpdateQuantity',
array(
Hook::exec(
'actionUpdateQuantity',
[
'id_product' => $id_product,
'id_product_attribute' => 0,
'quantity' => $product_quantity,
'id_shop' => $id_shop,
)
]
);
} else {
// else this product has attributes, hence loops on $ids_product_attribute
foreach ($ids_product_attribute as $id_product_attribute) {
$allowed_warehouse_for_combination = WareHouse::getProductWarehouseList((int) $id_product, (int) $id_product_attribute, (int) $id_shop);
$allowed_warehouse_for_combination_clean = array();
$allowed_warehouse_for_combination_clean = [];
foreach ($allowed_warehouse_for_combination as $warehouse) {
$allowed_warehouse_for_combination_clean[] = (int) $warehouse['id_warehouse'];
}
@@ -231,56 +244,57 @@ class StockAvailableCore extends ObjectModel
StockAvailable::addSqlShopRestriction(null, $id_shop));
if ((int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query)) {
$query = array(
$query = [
'table' => 'stock_available',
'data' => array('quantity' => $quantity),
'data' => ['quantity' => $quantity],
'where' => 'id_product = ' . (int) $id_product . ' AND id_product_attribute = ' . (int) $id_product_attribute .
StockAvailable::addSqlShopRestriction(null, $id_shop),
);
];
Db::getInstance()->update($query['table'], $query['data'], $query['where']);
} else {
$query = array(
$query = [
'table' => 'stock_available',
'data' => array(
'data' => [
'quantity' => $quantity,
'depends_on_stock' => 1,
'out_of_stock' => $out_of_stock,
'id_product' => (int) $id_product,
'id_product_attribute' => (int) $id_product_attribute,
),
);
],
];
StockAvailable::addSqlShopParams($query['data'], $id_shop);
Db::getInstance()->insert($query['table'], $query['data']);
}
$product_quantity += $quantity;
Hook::exec('actionUpdateQuantity',
array(
Hook::exec(
'actionUpdateQuantity',
[
'id_product' => $id_product,
'id_product_attribute' => $id_product_attribute,
'quantity' => $quantity,
'id_shop' => $id_shop,
)
]
);
}
}
// updates
// if $id_product has attributes, it also updates the sum for all attributes
if (($order_id_shop != null && array_intersect($warehouses, $order_warehouses)) || $order_id_shop == null) {
$query = array(
$query = [
'table' => 'stock_available',
'data' => array('quantity' => $product_quantity),
'data' => ['quantity' => $product_quantity],
'where' => 'id_product = ' . (int) $id_product . ' AND id_product_attribute = 0' .
StockAvailable::addSqlShopRestriction(null, $id_shop),
);
];
Db::getInstance()->update($query['table'], $query['data'], $query['where']);
}
}
}
// In case there are no warehouses, removes product from StockAvailable
if (count($ids_warehouse) == 0 && StockAvailable::dependsOnStock((int) $id_product)) {
Db::getInstance()->update('stock_available', array('quantity' => 0), 'id_product = ' . (int) $id_product);
Db::getInstance()->update('stock_available', ['quantity' => 0], 'id_product = ' . (int) $id_product);
}
Cache::clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $id_product . '*');
@@ -301,15 +315,15 @@ class StockAvailableCore extends ObjectModel
$existing_id = StockAvailable::getStockAvailableIdByProductId((int) $id_product, (int) $id_product_attribute, $id_shop);
if ($existing_id > 0) {
Db::getInstance()->update('stock_available', array(
Db::getInstance()->update('stock_available', [
'depends_on_stock' => (int) $depends_on_stock,
), 'id_stock_available = ' . (int) $existing_id);
], 'id_stock_available = ' . (int) $existing_id);
} else {
$params = array(
$params = [
'depends_on_stock' => (int) $depends_on_stock,
'id_product' => (int) $id_product,
'id_product_attribute' => (int) $id_product_attribute,
);
];
StockAvailable::addSqlShopParams($params, $id_shop);
@@ -340,17 +354,17 @@ class StockAvailableCore extends ObjectModel
if ($existing_id > 0) {
Db::getInstance()->update(
'stock_available',
array('out_of_stock' => (int) $out_of_stock),
['out_of_stock' => (int) $out_of_stock],
'id_product = ' . (int) $id_product .
(($id_product_attribute) ? ' AND id_product_attribute = ' . (int) $id_product_attribute : '') .
StockAvailable::addSqlShopRestriction(null, $id_shop)
);
} else {
$params = array(
$params = [
'out_of_stock' => (int) $out_of_stock,
'id_product' => (int) $id_product,
'id_product_attribute' => (int) $id_product_attribute,
);
];
StockAvailable::addSqlShopParams($params, $id_shop);
Db::getInstance()->insert('stock_available', $params, false, true, Db::ON_DUPLICATE_KEY);
@@ -381,10 +395,8 @@ class StockAvailableCore extends ObjectModel
'id_product_attribute' => $id_product_attribute,
'location' => $location,
];
throw new \InvalidArgumentException(sprintf(
'Could not update location as input data is not valid: %s',
json_encode($serializedInputData)
));
throw new \InvalidArgumentException(sprintf('Could not update location as input data is not valid: %s', json_encode($serializedInputData)));
}
$existing_id = StockAvailable::getStockAvailableIdByProductId($id_product, $id_product_attribute, $id_shop);
@@ -392,17 +404,17 @@ class StockAvailableCore extends ObjectModel
if ($existing_id > 0) {
Db::getInstance()->update(
'stock_available',
array('location' => $location),
'id_product = ' . $id_product .
(($id_product_attribute) ? ' AND id_product_attribute = ' . $id_product_attribute : '') .
['location' => pSQL($location)],
'id_product = ' . (int) $id_product .
(($id_product_attribute) ? ' AND id_product_attribute = ' . (int) $id_product_attribute : '') .
StockAvailable::addSqlShopRestriction(null, $id_shop)
);
} else {
$params = array(
'location' => $location,
'id_product' => $id_product,
'id_product_attribute' => $id_product_attribute,
);
$params = [
'location' => pSQL($location),
'id_product' => (int) $id_product,
'id_product_attribute' => (int) $id_product_attribute,
];
StockAvailable::addSqlShopParams($params, $id_shop);
Db::getInstance()->insert('stock_available', $params, false, true, Db::ON_DUPLICATE_KEY);
@@ -500,13 +512,15 @@ class StockAvailableCore extends ObjectModel
foreach ($colors as $color) {
if ($product->isColorUnavailable((int) $color['id_attribute'], (int) $this->id_shop)) {
Tools::clearColorListCache($product->id);
break;
}
}
}
}
$total_quantity = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
$total_quantity = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(
'
SELECT SUM(quantity) as quantity
FROM ' . _DB_PREFIX_ . 'stock_available
WHERE id_product = ' . (int) $this->id_product . '
@@ -529,7 +543,7 @@ class StockAvailableCore extends ObjectModel
* @param bool $add_movement Optional
* @param array $params Optional
*/
public static function updateQuantity($id_product, $id_product_attribute, $delta_quantity, $id_shop = null, $add_movement = false, $params = array())
public static function updateQuantity($id_product, $id_product_attribute, $delta_quantity, $id_shop = null, $add_movement = false, $params = [])
{
if (!Validate::isUnsignedId($id_product)) {
return false;
@@ -575,7 +589,7 @@ class StockAvailableCore extends ObjectModel
if ($id_stock_available) {
$stock_available = new StockAvailable($id_stock_available);
$deltaQuantity = -1 * ((int) $stock_available->quantity - (int) $quantity);
$deltaQuantity = (int) $quantity - (int) $stock_available->quantity;
$stock_available->quantity = (int) $quantity;
$stock_available->update();
@@ -610,12 +624,13 @@ class StockAvailableCore extends ObjectModel
}
}
Hook::exec('actionUpdateQuantity',
array(
Hook::exec(
'actionUpdateQuantity',
[
'id_product' => $id_product,
'id_product_attribute' => $id_product_attribute,
'quantity' => $stock_available->quantity,
)
]
);
}
Cache::clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $id_product . '*');
@@ -663,7 +678,7 @@ class StockAvailableCore extends ObjectModel
if ($id_product_attribute) {
if ($shop === null || !Validate::isLoadedObject($shop)) {
$shop_datas = array();
$shop_datas = [];
StockAvailable::addSqlShopParams($shop_datas);
$id_shop = (int) $shop_datas['id_shop'];
} else {
@@ -698,9 +713,9 @@ class StockAvailableCore extends ObjectModel
if (count($shop_list) > 0) {
$id_shops_list = implode(', ', $shop_list);
return Db::getInstance()->update('stock_available', array('quantity' => 0), 'id_shop IN (' . $id_shops_list . ')');
return Db::getInstance()->update('stock_available', ['quantity' => 0], 'id_shop IN (' . $id_shops_list . ')');
} else {
return Db::getInstance()->update('stock_available', array('quantity' => 0), 'id_shop_group = ' . $shop_group->id);
return Db::getInstance()->update('stock_available', ['quantity' => 0], 'id_shop_group = ' . $shop_group->id);
}
}

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -83,7 +83,7 @@ class StockManagerCore implements StockManagerInterface
$context = Context::getContext();
$mvt_params = array(
$mvt_params = [
'id_stock' => null,
'physical_quantity' => $quantity,
'id_stock_mvt_reason' => $id_stock_mvt_reason,
@@ -95,7 +95,7 @@ class StockManagerCore implements StockManagerInterface
'employee_firstname' => $context->employee->firstname ? $context->employee->firstname : $employee->firstname,
'employee_lastname' => $context->employee->lastname ? $context->employee->lastname : $employee->lastname,
'sign' => 1,
);
];
$stock_exists = false;
@@ -121,12 +121,12 @@ class StockManagerCore implements StockManagerInterface
$mvt_params['last_wa'] = $last_wa;
$mvt_params['current_wa'] = $current_wa;
$stock_params = array(
$stock_params = [
'physical_quantity' => ($stock->physical_quantity + $quantity),
'price_te' => $current_wa,
'usable_quantity' => ($is_usable ? ($stock->usable_quantity + $quantity) : $stock->usable_quantity),
'id_warehouse' => $warehouse->id,
);
];
// saves stock in warehouse
$stock->hydrate($stock_params);
@@ -137,6 +137,7 @@ class StockManagerCore implements StockManagerInterface
$mvt_params['last_wa'] = 0;
$mvt_params['current_wa'] = $price_te;
}
break;
// case FIFO / LIFO mode
@@ -152,10 +153,10 @@ class StockManagerCore implements StockManagerInterface
// there is one and only one stock for a given product in a warehouse and at the current unit price
$stock = $stock_collection->current();
$stock_params = array(
$stock_params = [
'physical_quantity' => ($stock->physical_quantity + $quantity),
'usable_quantity' => ($is_usable ? ($stock->usable_quantity + $quantity) : $stock->usable_quantity),
);
];
// updates stock in warehouse
$stock->hydrate($stock_params);
@@ -169,20 +170,21 @@ class StockManagerCore implements StockManagerInterface
default:
return false;
break;
}
if (!$stock_exists) {
$stock = new Stock();
$stock_params = array(
$stock_params = [
'id_product_attribute' => $id_product_attribute,
'id_product' => $id_product,
'physical_quantity' => $quantity,
'price_te' => $price_te,
'usable_quantity' => ($is_usable ? $quantity : 0),
'id_warehouse' => $warehouse->id,
);
];
// saves stock in warehouse
$stock->hydrate($stock_params);
@@ -226,7 +228,7 @@ class StockManagerCore implements StockManagerInterface
$ignore_pack = 0,
$employee = null
) {
$return = array();
$return = [];
if (!Validate::isLoadedObject($warehouse) || !$quantity || !$id_product) {
return $return;
@@ -270,7 +272,8 @@ class StockManagerCore implements StockManagerInterface
if ($product->pack_stock_type == Pack::STOCK_TYPE_PACK_ONLY
|| $product->pack_stock_type == Pack::STOCK_TYPE_PACK_BOTH
|| ($product->pack_stock_type == Pack::STOCK_TYPE_DEFAULT
|| (
$product->pack_stock_type == Pack::STOCK_TYPE_DEFAULT
&& (Configuration::get('PS_PACK_STOCK_TYPE') == Pack::STOCK_TYPE_PACK_ONLY
|| Configuration::get('PS_PACK_STOCK_TYPE') == Pack::STOCK_TYPE_PACK_BOTH)
)
@@ -282,8 +285,8 @@ class StockManagerCore implements StockManagerInterface
}
} else {
// gets total quantities in stock for the current product
$physical_quantity_in_stock = (int) $this->getProductPhysicalQuantities($id_product, $id_product_attribute, array($warehouse->id), false);
$usable_quantity_in_stock = (int) $this->getProductPhysicalQuantities($id_product, $id_product_attribute, array($warehouse->id), true);
$physical_quantity_in_stock = (int) $this->getProductPhysicalQuantities($id_product, $id_product_attribute, [$warehouse->id], false);
$usable_quantity_in_stock = (int) $this->getProductPhysicalQuantities($id_product, $id_product_attribute, [$warehouse->id], true);
// check quantity if we want to decrement unusable quantity
if (!$is_usable) {
@@ -305,10 +308,10 @@ class StockManagerCore implements StockManagerInterface
return $return;
}
$stock_history_qty_available = array();
$mvt_params = array();
$stock_params = array();
$quantity_to_decrement_by_stock = array();
$stock_history_qty_available = [];
$mvt_params = [];
$stock_params = [];
$quantity_to_decrement_by_stock = [];
$global_quantity_to_decrement = $quantity;
// switch on MANAGEMENT_TYPE
@@ -319,7 +322,7 @@ class StockManagerCore implements StockManagerInterface
// There is one and only one stock for a given product in a warehouse in this mode
$stock = $stock_collection->current();
$mvt_params = array(
$mvt_params = [
'id_stock' => $stock->id,
'physical_quantity' => $quantity,
'id_stock_mvt_reason' => $id_stock_mvt_reason,
@@ -331,11 +334,11 @@ class StockManagerCore implements StockManagerInterface
'employee_firstname' => $context->employee->firstname ? $context->employee->firstname : $employee->firstname,
'employee_lastname' => $context->employee->lastname ? $context->employee->lastname : $employee->lastname,
'sign' => -1,
);
$stock_params = array(
];
$stock_params = [
'physical_quantity' => ($stock->physical_quantity - $quantity),
'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $quantity) : $stock->usable_quantity),
);
];
// saves stock in warehouse
$stock->hydrate($stock_params);
@@ -362,7 +365,8 @@ class StockManagerCore implements StockManagerInterface
continue;
}
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'
SELECT sm.`id_stock_mvt`, sm.`date_add`, sm.`physical_quantity`,
IF ((sm2.`physical_quantity` is null), sm.`physical_quantity`, (sm.`physical_quantity` - SUM(sm2.`physical_quantity`))) as qty
FROM `' . _DB_PREFIX_ . 'stock_mvt` sm
@@ -370,7 +374,8 @@ class StockManagerCore implements StockManagerInterface
WHERE sm.`sign` = 1
AND sm.`id_stock` = ' . (int) $stock->id . '
GROUP BY sm.`id_stock_mvt`
ORDER BY sm.`date_add` DESC', false
ORDER BY sm.`date_add` DESC',
false
);
while ($row = Db::getInstance()->nextRow($resource)) {
@@ -386,11 +391,11 @@ class StockManagerCore implements StockManagerInterface
$timestamp = $date->format('U');
// history of the mvt
$stock_history_qty_available[$timestamp] = array(
$stock_history_qty_available[$timestamp] = [
'id_stock' => $stock->id,
'id_stock_mvt' => (int) $row['id_stock_mvt'],
'qty' => (int) $row['qty'],
);
];
// break - in LIFO mode, checks only the necessary history to handle the global quantity for the current stock
if ($warehouse->management_type == 'LIFO') {
@@ -431,7 +436,7 @@ class StockManagerCore implements StockManagerInterface
$total_quantity_for_current_stock = 0;
foreach ($quantity_to_decrement_by_stock[$stock->id] as $id_mvt_referrer => $qte) {
$mvt_params = array(
$mvt_params = [
'id_stock' => $stock->id,
'physical_quantity' => $qte,
'id_stock_mvt_reason' => $id_stock_mvt_reason,
@@ -440,7 +445,7 @@ class StockManagerCore implements StockManagerInterface
'sign' => -1,
'referer' => $id_mvt_referrer,
'id_employee' => (int) $context->employee->id ? (int) $context->employee->id : $employee->id,
);
];
// saves stock mvt
$stock_mvt = new StockMvt();
@@ -450,10 +455,10 @@ class StockManagerCore implements StockManagerInterface
$total_quantity_for_current_stock += $qte;
}
$stock_params = array(
$stock_params = [
'physical_quantity' => ($stock->physical_quantity - $total_quantity_for_current_stock),
'usable_quantity' => ($is_usable ? ($stock->usable_quantity - $total_quantity_for_current_stock) : $stock->usable_quantity),
);
];
$return[$stock->id]['quantity'] = $total_quantity_for_current_stock;
$return[$stock->id]['price_te'] = $stock->price_te;
@@ -463,6 +468,7 @@ class StockManagerCore implements StockManagerInterface
$stock->update();
}
}
break;
}
@@ -482,7 +488,7 @@ class StockManagerCore implements StockManagerInterface
// How many packs can be constituated with the remaining product stocks
$quantity_by_pack = $pack->pack_item_quantity;
$stock_available_quantity = $quantity_in_stock - $quantity;
$max_pack_quantity = max(array(0, floor($stock_available_quantity / $quantity_by_pack)));
$max_pack_quantity = max([0, floor($stock_available_quantity / $quantity_by_pack)]);
$quantity_delta = Pack::getQuantity($pack->id) - $max_pack_quantity;
if ($pack->advanced_stock_management == 1 && $quantity_delta > 0) {
@@ -505,12 +511,13 @@ class StockManagerCore implements StockManagerInterface
// if we remove a usable quantity, exec hook
if ($is_usable) {
Hook::exec('actionProductCoverage',
array(
Hook::exec(
'actionProductCoverage',
[
'id_product' => $id_product,
'id_product_attribute' => $id_product_attribute,
'warehouse' => $warehouse,
)
]
);
}
@@ -522,10 +529,10 @@ class StockManagerCore implements StockManagerInterface
*/
public function getProductPhysicalQuantities($id_product, $id_product_attribute, $ids_warehouse = null, $usable = false)
{
if (!is_null($ids_warehouse)) {
if (null !== $ids_warehouse) {
// in case $ids_warehouse is not an array
if (!is_array($ids_warehouse)) {
$ids_warehouse = array($ids_warehouse);
$ids_warehouse = [$ids_warehouse];
}
// casts for security reason
@@ -534,7 +541,7 @@ class StockManagerCore implements StockManagerInterface
return 0;
}
} else {
$ids_warehouse = array();
$ids_warehouse = [];
}
$query = new DbQuery();
@@ -557,10 +564,10 @@ class StockManagerCore implements StockManagerInterface
*/
public function getProductRealQuantities($id_product, $id_product_attribute, $ids_warehouse = null, $usable = false)
{
if (!is_null($ids_warehouse)) {
if (null !== $ids_warehouse) {
// in case $ids_warehouse is not an array
if (!is_array($ids_warehouse)) {
$ids_warehouse = array($ids_warehouse);
$ids_warehouse = [$ids_warehouse];
}
// casts for security reason
@@ -573,7 +580,8 @@ class StockManagerCore implements StockManagerInterface
if (!Pack::isPack($id_product) && $in_pack = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'SELECT id_product_pack, quantity FROM ' . _DB_PREFIX_ . 'pack
WHERE id_product_item = ' . (int) $id_product . '
AND id_product_attribute_item = ' . ($id_product_attribute ? (int) $id_product_attribute : '0'))) {
AND id_product_attribute_item = ' . ($id_product_attribute ? (int) $id_product_attribute : '0')
)) {
foreach ($in_pack as $value) {
if (Validate::isLoadedObject($product = new Product((int) $value['id_product_pack'])) &&
($product->pack_stock_type == Pack::STOCK_TYPE_PRODUCTS_ONLY || $product->pack_stock_type == Pack::STOCK_TYPE_PACK_BOTH || ($product->pack_stock_type == Pack::STOCK_TYPE_DEFAULT && Configuration::get('PS_PACK_STOCK_TYPE') > 0))) {
@@ -640,7 +648,7 @@ class StockManagerCore implements StockManagerInterface
$query->leftjoin('supply_order_state', 'sos', 'sos.id_supply_order_state = so.id_supply_order_state');
$query->where('sos.pending_receipt = 1');
$query->where('sod.id_product = ' . (int) $id_product . ' AND sod.id_product_attribute = ' . (int) $id_product_attribute);
if (!is_null($ids_warehouse) && count($ids_warehouse)) {
if (null !== $ids_warehouse && count($ids_warehouse)) {
$query->where('so.id_warehouse IN(' . implode(', ', $ids_warehouse) . ')');
}
@@ -673,7 +681,7 @@ class StockManagerCore implements StockManagerInterface
$usable_to = true
) {
// Checks if this transfer is possible
if ($this->getProductPhysicalQuantities($id_product, $id_product_attribute, array($id_warehouse_from), $usable_from) < $quantity) {
if ($this->getProductPhysicalQuantities($id_product, $id_product_attribute, [$id_warehouse_from], $usable_from) < $quantity) {
return false;
}
@@ -690,12 +698,14 @@ class StockManagerCore implements StockManagerInterface
}
// Removes from warehouse_from
$stocks = $this->removeProduct($id_product,
$stocks = $this->removeProduct(
$id_product,
$id_product_attribute,
$warehouse_from,
$quantity,
Configuration::get('PS_STOCK_MVT_TRANSFER_FROM'),
$usable_from);
$usable_from
);
if (!count($stocks)) {
return false;
}
@@ -713,13 +723,15 @@ class StockManagerCore implements StockManagerInterface
$price = Tools::convertPrice($price_converted_to_default_currency, $warehouse_to->id_currency, true);
}
if (!$this->addProduct($id_product,
if (!$this->addProduct(
$id_product,
$id_product_attribute,
$warehouse_to,
$stock['quantity'],
Configuration::get('PS_STOCK_MVT_TRANSFER_TO'),
$price,
$usable_to)) {
$usable_to
)) {
return false;
}
}
@@ -769,10 +781,12 @@ class StockManagerCore implements StockManagerInterface
}
$quantity_per_day = Tools::ps_round($quantity_out / $coverage);
$physical_quantity = $this->getProductPhysicalQuantities($id_product,
$physical_quantity = $this->getProductPhysicalQuantities(
$id_product,
$id_product_attribute,
($id_warehouse ? array($id_warehouse) : null),
true);
($id_warehouse ? [$id_warehouse] : null),
true
);
$time_left = ($quantity_per_day == 0) ? (-1) : Tools::ps_round($physical_quantity / $quantity_per_day);
return $time_left;

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/*
@@ -66,7 +66,7 @@ class StockManagerFactoryCore
foreach ($modules_infos as $module_infos) {
$module_instance = Module::getInstanceByName($module_infos['name']);
if (is_callable(array($module_instance, 'hookStockManager'))) {
if (is_callable([$module_instance, 'hookStockManager'])) {
$stock_manager = $module_instance->hookStockManager();
}

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -41,17 +41,17 @@ abstract class StockManagerModuleCore extends Module
$class_file = _PS_MODULE_DIR_ . '/' . $this->name . '/' . $this->stock_manager_class . '.php';
if (!isset($this->stock_manager_class) || !file_exists($class_file)) {
die($this->trans('Incorrect Stock Manager class [%s]', array($this->stock_manager_class), 'Admin.Catalog.Notification'));
die($this->trans('Incorrect Stock Manager class [%s]', [$this->stock_manager_class], 'Admin.Catalog.Notification'));
}
require_once $class_file;
if (!class_exists($this->stock_manager_class)) {
die($this->trans('Stock Manager class not found [%s]', array($this->stock_manager_class), 'Admin.Catalog.Notification'));
die($this->trans('Stock Manager class not found [%s]', [$this->stock_manager_class], 'Admin.Catalog.Notification'));
}
$class = $this->stock_manager_class;
if (call_user_func(array($class, 'isAvailable'))) {
if (call_user_func([$class, 'isAvailable'])) {
return new $class();
}

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -138,38 +138,38 @@ class StockMvtCore extends ObjectModel
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'stock_mvt',
'primary' => 'id_stock_mvt',
'fields' => array(
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'employee_firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'employee_lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'id_stock' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'physical_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'id_stock_mvt_reason' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_supply_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'sign' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true),
'last_wa' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'current_wa' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'price_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'referer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true),
),
);
'fields' => [
'id_employee' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'employee_firstname' => ['type' => self::TYPE_STRING, 'validate' => 'isName'],
'employee_lastname' => ['type' => self::TYPE_STRING, 'validate' => 'isName'],
'id_stock' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'physical_quantity' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true],
'id_stock_mvt_reason' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_order' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'id_supply_order' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'sign' => ['type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true],
'last_wa' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice'],
'current_wa' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice'],
'price_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
'referer' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true],
],
];
protected $webserviceParameters = array(
protected $webserviceParameters = [
'objectsNodeName' => 'stock_movements',
'objectNodeName' => 'stock_movement',
'fields' => array(
'id_employee' => array('xlink_resource' => 'employees'),
'id_stock' => array('xlink_resource' => 'stock'),
'id_stock_mvt_reason' => array('xlink_resource' => 'stock_movement_reasons'),
'id_order' => array('xlink_resource' => 'orders'),
'id_supply_order' => array('xlink_resource' => 'supply_order'),
),
);
'fields' => [
'id_employee' => ['xlink_resource' => 'employees'],
'id_stock' => ['xlink_resource' => 'stock'],
'id_stock_mvt_reason' => ['xlink_resource' => 'stock_movement_reasons'],
'id_order' => ['xlink_resource' => 'orders'],
'id_supply_order' => ['xlink_resource' => 'supply_order'],
],
];
/**
* @deprecated since 1.5.0
@@ -199,7 +199,7 @@ class StockMvtCore extends ObjectModel
*/
public static function getNegativeStockMvts($id_order, $id_product, $id_product_attribute, $quantity, $id_warehouse = null)
{
$movements = array();
$movements = [];
$quantity_total = 0;
// preps query
@@ -212,7 +212,7 @@ class StockMvtCore extends ObjectModel
$query->where('s.id_product = ' . (int) $id_product . ' AND s.id_product_attribute = ' . (int) $id_product_attribute);
// if filer by warehouse
if (!is_null($id_warehouse)) {
if (null !== $id_warehouse) {
$query->where('s.id_warehouse = ' . (int) $id_warehouse);
}

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class StockMvtReasonCore extends ObjectModel
{
@@ -47,29 +47,29 @@ class StockMvtReasonCore extends ObjectModel
* @since 1.5.0
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'stock_mvt_reason',
'primary' => 'id_stock_mvt_reason',
'multilang' => true,
'fields' => array(
'sign' => array('type' => self::TYPE_INT),
'deleted' => array('type' => self::TYPE_BOOL),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255),
),
);
'fields' => [
'sign' => ['type' => self::TYPE_INT],
'deleted' => ['type' => self::TYPE_BOOL],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
'name' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
protected $webserviceParameters = [
'objectsNodeName' => 'stock_movement_reasons',
'objectNodeName' => 'stock_movement_reason',
'fields' => array(
'sign' => array(),
),
);
'fields' => [
'sign' => [],
],
];
/**
* Gets Stock Mvt Reasons.

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -128,7 +128,7 @@ class StockMvtWSCore extends ObjectModelCore
*/
public $management_type;
/*
/**
* @var string : Name of the product (@see Product::getProductName)
*/
public $product_name;
@@ -143,6 +143,11 @@ class StockMvtWSCore extends ObjectModelCore
*/
public $upc;
/**
* @var string MPN of the product (@see Stock::product_mpn)
*/
public $mpn;
/**
* @var string Reference of the product (@see Stock::product_reference)
*/
@@ -151,69 +156,71 @@ class StockMvtWSCore extends ObjectModelCore
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'stock_mvt',
'primary' => 'id_stock_mvt',
'fields' => array(
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'employee_firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'employee_lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'id_stock' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'physical_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'id_stock_mvt_reason' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_supply_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'sign' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true),
'last_wa' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'current_wa' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'price_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'referer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true),
),
);
'fields' => [
'id_employee' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'employee_firstname' => ['type' => self::TYPE_STRING, 'validate' => 'isName'],
'employee_lastname' => ['type' => self::TYPE_STRING, 'validate' => 'isName'],
'id_stock' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'physical_quantity' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true],
'id_stock_mvt_reason' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_order' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'id_supply_order' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'sign' => ['type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true],
'last_wa' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice'],
'current_wa' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice'],
'price_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
'referer' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
'fields' => array(
'id_product' => array('xlink_resource' => 'products'),
'id_product_attribute' => array('xlink_resource' => 'combinations'),
'id_warehouse' => array('xlink_resource' => 'warehouses'),
'id_currency' => array('xlink_resource' => 'currencies'),
'management_type' => array(),
'id_employee' => array('xlink_resource' => 'employees'),
'id_stock' => array('xlink_resource' => 'stocks'),
'id_stock_mvt_reason' => array('xlink_resource' => 'stock_movement_reasons'),
'id_order' => array('xlink_resource' => 'orders'),
'id_supply_order' => array('xlink_resource' => 'supply_orders'),
'product_name' => array('getter' => 'getWSProductName', 'i18n' => true),
'ean13' => array(),
'upc' => array(),
'reference' => array(),
),
'hidden_fields' => array(
protected $webserviceParameters = [
'fields' => [
'id_product' => ['xlink_resource' => 'products'],
'id_product_attribute' => ['xlink_resource' => 'combinations'],
'id_warehouse' => ['xlink_resource' => 'warehouses'],
'id_currency' => ['xlink_resource' => 'currencies'],
'management_type' => [],
'id_employee' => ['xlink_resource' => 'employees'],
'id_stock' => ['xlink_resource' => 'stocks'],
'id_stock_mvt_reason' => ['xlink_resource' => 'stock_movement_reasons'],
'id_order' => ['xlink_resource' => 'orders'],
'id_supply_order' => ['xlink_resource' => 'supply_orders'],
'product_name' => ['getter' => 'getWSProductName', 'i18n' => true],
'ean13' => [],
'upc' => [],
'reference' => [],
'mpn' => [],
],
'hidden_fields' => [
'referer',
'employee_firstname',
'employee_lastname',
),
);
],
];
/**
* Associations tables for attributes that require different tables than stated in ObjectModel::definition.
*
* @var array
*/
protected $tables_assoc = array(
'id_product' => array('table' => 's'),
'id_product_attribute' => array('table' => 's'),
'id_warehouse' => array('table' => 's'),
'id_currency' => array('table' => 's'),
'management_type' => array('table' => 'w'),
'ean13' => array('table' => 's'),
'upc' => array('table' => 's'),
'reference' => array('table' => 's'),
);
protected $tables_assoc = [
'id_product' => ['table' => 's'],
'id_product_attribute' => ['table' => 's'],
'id_warehouse' => ['table' => 's'],
'id_currency' => ['table' => 's'],
'management_type' => ['table' => 'w'],
'ean13' => ['table' => 's'],
'upc' => ['table' => 's'],
'mpn' => ['table' => 's'],
'reference' => ['table' => 's'],
];
/**
* @see ObjectModel
@@ -243,7 +250,7 @@ class StockMvtWSCore extends ObjectModelCore
if ($full) {
$query .= ', s.id_product, s.id_product_attribute, s.id_warehouse, w.id_currency, w.management_type,
s.ean13, s.upc, s.reference ';
s.ean13, s.upc, s.mpn, s.reference ';
}
$old_filter = $filter;
@@ -287,7 +294,7 @@ class StockMvtWSCore extends ObjectModelCore
*/
public function getWSProductName()
{
$res = array();
$res = [];
foreach (Language::getIDs(true) as $id_lang) {
$res[$id_lang] = Product::getProductName($this->id_product, $this->id_product_attribute, $id_lang);
}

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -122,58 +122,58 @@ class SupplyOrderCore extends ObjectModel
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'supply_order',
'primary' => 'id_supply_order',
'fields' => array(
'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'supplier_name' => array('type' => self::TYPE_STRING, 'validate' => 'isCatalogName', 'required' => false),
'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_supply_order_state' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_ref_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'reference' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
'date_delivery_expected' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true),
'total_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'total_with_discount_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'total_ti' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'total_tax' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'discount_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => false),
'discount_value_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'is_template' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
),
);
'fields' => [
'id_supplier' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'supplier_name' => ['type' => self::TYPE_STRING, 'validate' => 'isCatalogName', 'required' => false],
'id_lang' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_warehouse' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_supply_order_state' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_currency' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_ref_currency' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'reference' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true],
'date_delivery_expected' => ['type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true],
'total_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice'],
'total_with_discount_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice'],
'total_ti' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice'],
'total_tax' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice'],
'discount_rate' => ['type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => false],
'discount_value_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice'],
'is_template' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
'fields' => array(
'id_supplier' => array('xlink_resource' => 'suppliers'),
'id_lang' => array('xlink_resource' => 'languages'),
'id_warehouse' => array('xlink_resource' => 'warehouses'),
'id_supply_order_state' => array('xlink_resource' => 'supply_order_states'),
'id_currency' => array('xlink_resource' => 'currencies'),
),
'hidden_fields' => array(
protected $webserviceParameters = [
'fields' => [
'id_supplier' => ['xlink_resource' => 'suppliers'],
'id_lang' => ['xlink_resource' => 'languages'],
'id_warehouse' => ['xlink_resource' => 'warehouses'],
'id_supply_order_state' => ['xlink_resource' => 'supply_order_states'],
'id_currency' => ['xlink_resource' => 'currencies'],
],
'hidden_fields' => [
'id_ref_currency',
),
'associations' => array(
'supply_order_details' => array(
],
'associations' => [
'supply_order_details' => [
'resource' => 'supply_order_detail',
'fields' => array(
'id' => array(),
'id_product' => array(),
'id_product_attribute' => array(),
'supplier_reference' => array(),
'product_name' => array(),
),
),
),
);
'fields' => [
'id' => [],
'id_product' => [],
'id_product_attribute' => [],
'supplier_reference' => [],
'product_name' => [],
],
],
],
];
/**
* @see ObjectModel::update()
@@ -495,7 +495,7 @@ class SupplyOrderCore extends ObjectModel
$this->id = $data[$this->def['primary']];
}
foreach ($data as $key => $value) {
if (array_key_exists($key, $this)) {
if (array_key_exists($key, get_object_vars($this))) {
// formats prices and floats
if ($this->def['fields'][$key]['validate'] == 'isFloat' ||
$this->def['fields'][$key]['validate'] == 'isPrice') {
@@ -530,7 +530,8 @@ class SupplyOrderCore extends ObjectModel
public function getAllExpectedQuantity()
{
return Db::getInstance()->getValue('
return Db::getInstance()->getValue(
'
SELECT SUM(`quantity_expected`)
FROM `' . _DB_PREFIX_ . 'supply_order_detail`
WHERE `id_supply_order` = ' . (int) $this->id
@@ -539,7 +540,8 @@ class SupplyOrderCore extends ObjectModel
public function getAllReceivedQuantity()
{
return Db::getInstance()->getValue('
return Db::getInstance()->getValue(
'
SELECT SUM(`quantity_received`)
FROM `' . _DB_PREFIX_ . 'supply_order_detail`
WHERE `id_supply_order` = ' . (int) $this->id
@@ -548,7 +550,8 @@ class SupplyOrderCore extends ObjectModel
public function getAllPendingQuantity()
{
return Db::getInstance()->getValue('
return Db::getInstance()->getValue(
'
SELECT (SUM(`quantity_expected`) - SUM(`quantity_received`))
FROM `' . _DB_PREFIX_ . 'supply_order_detail`
WHERE `id_supply_order` = ' . (int) $this->id

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -76,6 +76,11 @@ class SupplyOrderDetailCore extends ObjectModel
*/
public $upc;
/**
* @var string MPN
*/
public $mpn;
/**
* @var int Currency used to buy this particular product
*/
@@ -151,51 +156,52 @@ class SupplyOrderDetailCore extends ObjectModel
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'supply_order_detail',
'primary' => 'id_supply_order_detail',
'fields' => array(
'id_supply_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference'),
'supplier_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference'),
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13'),
'isbn' => array('type' => self::TYPE_STRING, 'validate' => 'isIsbn'),
'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc'),
'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'exchange_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true),
'unit_price_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'quantity_expected' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'quantity_received' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'price_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'discount_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true),
'discount_value_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'price_with_discount_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'tax_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true),
'tax_value' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'price_ti' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
'tax_value_with_order_discount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true),
'price_with_order_discount_te' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
),
);
'fields' => [
'id_supply_order' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_product' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_product_attribute' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'reference' => ['type' => self::TYPE_STRING, 'validate' => 'isReference'],
'supplier_reference' => ['type' => self::TYPE_STRING, 'validate' => 'isReference'],
'name' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true],
'ean13' => ['type' => self::TYPE_STRING, 'validate' => 'isEan13'],
'isbn' => ['type' => self::TYPE_STRING, 'validate' => 'isIsbn'],
'upc' => ['type' => self::TYPE_STRING, 'validate' => 'isUpc'],
'mpn' => ['type' => self::TYPE_STRING, 'validate' => 'isMpn'],
'id_currency' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'exchange_rate' => ['type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true],
'unit_price_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
'quantity_expected' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true],
'quantity_received' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'],
'price_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
'discount_rate' => ['type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true],
'discount_value_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
'price_with_discount_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
'tax_rate' => ['type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true],
'tax_value' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
'price_ti' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
'tax_value_with_order_discount' => ['type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true],
'price_with_order_discount_te' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
protected $webserviceParameters = [
'objectsNodeName' => 'supply_order_details',
'objectNodeName' => 'supply_order_detail',
'fields' => array(
'id_supply_order' => array('xlink_resource' => 'supply_orders'),
'id_product' => array('xlink_resource' => 'products'),
'id_product_attribute' => array('xlink_resource' => 'combinations'),
),
'hidden_fields' => array(
'fields' => [
'id_supply_order' => ['xlink_resource' => 'supply_orders'],
'id_product' => ['xlink_resource' => 'products'],
'id_product_attribute' => ['xlink_resource' => 'combinations'],
],
'hidden_fields' => [
'id_currency',
),
);
],
];
/**
* @see ObjectModel::update()
@@ -274,7 +280,7 @@ class SupplyOrderDetailCore extends ObjectModel
*/
public function validateController($htmlentities = true)
{
$errors = array();
$errors = [];
/* required fields */
$fields_required = $this->fieldsRequired;
@@ -292,9 +298,9 @@ class SupplyOrderDetailCore extends ObjectModel
if (!$this->id || $field != 'passwd') {
$errors[] = $this->trans(
'%s is required.',
array(
[
'<b>' . SupplyOrderDetail::displayFieldName($field, get_class($this), $htmlentities) . '</b>',
),
],
'Shop.Notifications.Error'
);
}
@@ -306,7 +312,7 @@ class SupplyOrderDetailCore extends ObjectModel
if ($value = $this->{$field} && Tools::strlen($value) > $max_length) {
$errors[] = $this->trans(
'The %1$s field is too long (%2$d chars max).',
array(SupplyOrderDetail::displayFieldName($field, get_class($this), $htmlentities), $max_length),
[SupplyOrderDetail::displayFieldName($field, get_class($this), $htmlentities), $max_length],
'Shop.Notifications.Error'
);
}
@@ -316,7 +322,7 @@ class SupplyOrderDetailCore extends ObjectModel
foreach ($this->fieldsValidate as $field => $function) {
if ($value = $this->{$field}) {
if (!Validate::$function($value) && (!empty($value) || in_array($field, $this->fieldsRequired))) {
$errors[] = '<b>' . SupplyOrderDetail::displayFieldName($field, get_class($this), $htmlentities) . '</b> ' . $this->trans('is invalid.', array(), 'Shop.Notifications.Error');
$errors[] = '<b>' . SupplyOrderDetail::displayFieldName($field, get_class($this), $htmlentities) . '</b> ' . $this->trans('is invalid.', [], 'Shop.Notifications.Error');
} elseif ($field == 'passwd') {
if ($value = Tools::getValue($field)) {
$this->{$field} = Tools::hash($value);
@@ -328,15 +334,15 @@ class SupplyOrderDetailCore extends ObjectModel
}
if ($this->quantity_expected <= 0) {
$errors[] = '<b>' . SupplyOrderDetail::displayFieldName('quantity_expected', get_class($this)) . '</b> ' . $this->trans('is invalid.', array(), 'Shop.Notifications.Error');
$errors[] = '<b>' . SupplyOrderDetail::displayFieldName('quantity_expected', get_class($this)) . '</b> ' . $this->trans('is invalid.', [], 'Shop.Notifications.Error');
}
if ($this->tax_rate < 0 || $this->tax_rate > 100) {
$errors[] = '<b>' . SupplyOrderDetail::displayFieldName('tax_rate', get_class($this)) . '</b> ' . $this->trans('is invalid.', array(), 'Shop.Notifications.Error');
$errors[] = '<b>' . SupplyOrderDetail::displayFieldName('tax_rate', get_class($this)) . '</b> ' . $this->trans('is invalid.', [], 'Shop.Notifications.Error');
}
if ($this->discount_rate < 0 || $this->discount_rate > 100) {
$errors[] = '<b>' . SupplyOrderDetail::displayFieldName('discount_rate', get_class($this)) . '</b> ' . $this->trans('is invalid.', array(), 'Shop.Notifications.Error');
$errors[] = '<b>' . SupplyOrderDetail::displayFieldName('discount_rate', get_class($this)) . '</b> ' . $this->trans('is invalid.', [], 'Shop.Notifications.Error');
}
return $errors;
@@ -352,7 +358,7 @@ class SupplyOrderDetailCore extends ObjectModel
$this->id = $data[$this->def['primary']];
}
foreach ($data as $key => $value) {
if (array_key_exists($key, $this)) {
if (array_key_exists($key, get_object_vars($this))) {
// formats prices and floats
if ($this->def['fields'][$key]['validate'] == 'isFloat' ||
$this->def['fields'][$key]['validate'] == 'isPrice') {

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -62,29 +62,29 @@ class SupplyOrderHistoryCore extends ObjectModel
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'supply_order_history',
'primary' => 'id_supply_order_history',
'fields' => array(
'id_supply_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'employee_firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'employee_lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'id_state' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true),
),
);
'fields' => [
'id_supply_order' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_employee' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'employee_firstname' => ['type' => self::TYPE_STRING, 'validate' => 'isName'],
'employee_lastname' => ['type' => self::TYPE_STRING, 'validate' => 'isName'],
'id_state' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
protected $webserviceParameters = [
'objectsNodeName' => 'supply_order_histories',
'objectNodeName' => 'supply_order_history',
'fields' => array(
'id_supply_order' => array('xlink_resource' => 'supply_orders'),
'id_employee' => array('xlink_resource' => 'employees'),
'id_state' => array('xlink_resource' => 'supply_order_states'),
),
);
'fields' => [
'id_supply_order' => ['xlink_resource' => 'supply_orders'],
'id_employee' => ['xlink_resource' => 'employees'],
'id_state' => ['xlink_resource' => 'supply_order_states'],
],
];
}

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -69,30 +69,30 @@ class SupplyOrderReceiptHistoryCore extends ObjectModel
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'supply_order_receipt_history',
'primary' => 'id_supply_order_receipt_history',
'fields' => array(
'id_supply_order_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_supply_order_state' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'employee_firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'employee_lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
),
);
'fields' => [
'id_supply_order_detail' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_supply_order_state' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_employee' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'employee_firstname' => ['type' => self::TYPE_STRING, 'validate' => 'isName'],
'employee_lastname' => ['type' => self::TYPE_STRING, 'validate' => 'isName'],
'quantity' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
protected $webserviceParameters = [
'objectsNodeName' => 'supply_order_receipt_histories',
'objectNodeName' => 'supply_order_receipt_history',
'fields' => array(
'id_supply_order_detail' => array('xlink_resource' => 'supply_order_details'),
'id_employee' => array('xlink_resource' => 'employees'),
'id_supply_order_state' => array('xlink_resource' => 'supply_order_states'),
),
);
'fields' => [
'id_supply_order_detail' => ['xlink_resource' => 'supply_order_details'],
'id_employee' => ['xlink_resource' => 'employees'],
'id_supply_order_state' => ['xlink_resource' => 'supply_order_states'],
],
];
}

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -67,30 +67,30 @@ class SupplyOrderStateCore extends ObjectModel
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'supply_order_state',
'primary' => 'id_supply_order_state',
'multilang' => true,
'fields' => array(
'delivery_note' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'editable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'receipt_state' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'pending_receipt' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'enclosed' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'),
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
),
);
'fields' => [
'delivery_note' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'editable' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'receipt_state' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'pending_receipt' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'enclosed' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'color' => ['type' => self::TYPE_STRING, 'validate' => 'isColor'],
'name' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
protected $webserviceParameters = [
'objectsNodeName' => 'supply_order_states',
'objectNodeName' => 'supply_order_state',
'fields' => array(
),
);
'fields' => [
],
];
/**
* Gets the list of supply order statuses.
@@ -111,7 +111,7 @@ class SupplyOrderStateCore extends ObjectModel
$query->from('supply_order_state', 's');
$query->leftjoin('supply_order_state_lang', 'sl', 's.id_supply_order_state = sl.id_supply_order_state AND sl.id_lang=' . (int) $id_lang);
if (!is_null($id_state_referrer)) {
if (null !== $id_state_referrer) {
$is_receipt_state = false;
$is_editable = false;
$is_delivery_note = false;
@@ -158,7 +158,7 @@ class SupplyOrderStateCore extends ObjectModel
}
if ($ids && !is_array($ids)) {
$ids = array();
$ids = [];
}
$query = new DbQuery();

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
@@ -62,53 +62,53 @@ class WarehouseCore extends ObjectModel
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'warehouse',
'primary' => 'id_warehouse',
'fields' => array(
'id_address' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'reference' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 64),
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 45),
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'management_type' => array('type' => self::TYPE_STRING, 'validate' => 'isStockManagement', 'required' => true),
'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'deleted' => array('type' => self::TYPE_BOOL),
),
);
'fields' => [
'id_address' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'reference' => ['type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 64],
'name' => ['type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true, 'size' => 45],
'id_employee' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'management_type' => ['type' => self::TYPE_STRING, 'validate' => 'isStockManagement', 'required' => true],
'id_currency' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'deleted' => ['type' => self::TYPE_BOOL],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
'fields' => array(
'id_address' => array('xlink_resource' => 'addresses'),
'id_employee' => array('xlink_resource' => 'employees'),
'id_currency' => array('xlink_resource' => 'currencies'),
'valuation' => array('getter' => 'getWsStockValue', 'setter' => false),
'deleted' => array(),
),
'associations' => array(
'stocks' => array(
protected $webserviceParameters = [
'fields' => [
'id_address' => ['xlink_resource' => 'addresses'],
'id_employee' => ['xlink_resource' => 'employees'],
'id_currency' => ['xlink_resource' => 'currencies'],
'valuation' => ['getter' => 'getWsStockValue', 'setter' => false],
'deleted' => [],
],
'associations' => [
'stocks' => [
'resource' => 'stock',
'fields' => array(
'id' => array(),
),
),
'carriers' => array(
'fields' => [
'id' => [],
],
],
'carriers' => [
'resource' => 'carrier',
'fields' => array(
'id' => array(),
),
),
'shops' => array(
'fields' => [
'id' => [],
],
],
'shops' => [
'resource' => 'shop',
'fields' => array(
'id' => array(),
'name' => array(),
),
),
),
);
'fields' => [
'id' => [],
'name' => [],
],
],
],
];
/**
* Gets the shops associated to the current warehouse.
@@ -135,7 +135,7 @@ class WarehouseCore extends ObjectModel
*/
public function getCarriers($return_reference = false)
{
$ids_carrier = array();
$ids_carrier = [];
$query = new DbQuery();
if ($return_reference) {
@@ -170,12 +170,12 @@ class WarehouseCore extends ObjectModel
public function setCarriers($ids_carriers)
{
if (!is_array($ids_carriers)) {
$ids_carriers = array();
$ids_carriers = [];
}
$row_to_insert = array();
$row_to_insert = [];
foreach ($ids_carriers as $id_carrier) {
$row_to_insert[] = array($this->def['primary'] => $this->id, 'id_carrier' => (int) $id_carrier);
$row_to_insert[] = [$this->def['primary'] => $this->id, 'id_carrier' => (int) $id_carrier];
}
Db::getInstance()->execute('
@@ -232,7 +232,7 @@ class WarehouseCore extends ObjectModel
$query->where('id_warehouse = ' . (int) $id_warehouse);
$query->where('deleted = 0');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query, false);
}
/**
@@ -254,12 +254,12 @@ class WarehouseCore extends ObjectModel
AND `id_product_attribute` = ' . (int) $id_product_attribute . '
AND `id_warehouse` = ' . (int) $id_warehouse);
$row_to_insert = array(
$row_to_insert = [
'id_product' => (int) $id_product,
'id_product_attribute' => (int) $id_product_attribute,
'id_warehouse' => (int) $id_warehouse,
'location' => pSQL($location),
);
];
return Db::getInstance()->insert('warehouse_product_location', $row_to_insert);
}
@@ -324,7 +324,7 @@ class WarehouseCore extends ObjectModel
if ($share_stock) {
$ids_shop = Shop::getShops(true, (int) $shop_group->id, true);
} else {
$ids_shop = array((int) $id_shop);
$ids_shop = [(int) $id_shop];
}
$query = new DbQuery();
@@ -352,7 +352,7 @@ class WarehouseCore extends ObjectModel
public static function getWarehouses($ignore_shop = false, $id_shop = null)
{
if (!$ignore_shop) {
if (is_null($id_shop)) {
if (null === $id_shop) {
$id_shop = Context::getContext()->shop->id;
}
}
@@ -376,7 +376,7 @@ class WarehouseCore extends ObjectModel
*/
public static function getWarehousesGroupedByShops()
{
$ids_warehouse = array();
$ids_warehouse = [];
$query = new DbQuery();
$query->select('id_warehouse, id_shop');
$query->from('warehouse_shop');
@@ -470,7 +470,7 @@ class WarehouseCore extends ObjectModel
public static function getWarehousesByProductId($id_product, $id_product_attribute = 0)
{
if (!$id_product && !$id_product_attribute) {
return array();
return [];
}
$query = new DbQuery();
@@ -518,7 +518,7 @@ class WarehouseCore extends ObjectModel
return false;
}
if (is_null($id_shop)) {
if (null === $id_shop) {
$id_shop = Context::getContext()->shop->id;
}
@@ -528,7 +528,7 @@ class WarehouseCore extends ObjectModel
$products = Pack::getItems((int) $id_product, Configuration::get('PS_LANG_DEFAULT'));
// array with all warehouses id to check
$list = array();
$list = [];
// fills $list
foreach ($pack_warehouses as $pack_warehouse) {
@@ -541,7 +541,7 @@ class WarehouseCore extends ObjectModel
if ($product->advanced_stock_management) {
// gets the warehouses of one product
$product_warehouses = Warehouse::getProductWarehouseList((int) $product->id, (int) $product->cache_default_attribute, (int) $id_shop);
$list[(int) $product->id] = array();
$list[(int) $product->id] = [];
// fills array with warehouses for this product
foreach ($product_warehouses as $product_warehouse) {
$list[(int) $product->id][] = $product_warehouse['id_warehouse'];
@@ -622,7 +622,7 @@ class WarehouseCore extends ObjectModel
*/
public function getWsCarriers()
{
$ids_carrier = array();
$ids_carrier = [];
$query = new DbQuery();
$query->select('wc.id_carrier as id');

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* @since 1.5.0
@@ -51,29 +51,29 @@ class WarehouseProductLocationCore extends ObjectModel
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
public static $definition = [
'table' => 'warehouse_product_location',
'primary' => 'id_warehouse_product_location',
'fields' => array(
'location' => array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 64),
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
),
);
'fields' => [
'location' => ['type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 64],
'id_product' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_product_attribute' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_warehouse' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = array(
'fields' => array(
'id_product' => array('xlink_resource' => 'products'),
'id_product_attribute' => array('xlink_resource' => 'combinations'),
'id_warehouse' => array('xlink_resource' => 'warehouses'),
),
'hidden_fields' => array(
),
);
protected $webserviceParameters = [
'fields' => [
'id_product' => ['xlink_resource' => 'products'],
'id_product_attribute' => ['xlink_resource' => 'combinations'],
'id_warehouse' => ['xlink_resource' => 'warehouses'],
],
'hidden_fields' => [
],
];
/**
* For a given product and warehouse, gets the location.
@@ -90,7 +90,8 @@ class WarehouseProductLocationCore extends ObjectModel
$query = new DbQuery();
$query->select('wpl.location');
$query->from('warehouse_product_location', 'wpl');
$query->where('wpl.id_product = ' . (int) $id_product . '
$query->where(
'wpl.id_product = ' . (int) $id_product . '
AND wpl.id_product_attribute = ' . (int) $id_product_attribute . '
AND wpl.id_warehouse = ' . (int) $id_warehouse
);
@@ -113,7 +114,8 @@ class WarehouseProductLocationCore extends ObjectModel
$query = new DbQuery();
$query->select('wpl.id_warehouse_product_location');
$query->from('warehouse_product_location', 'wpl');
$query->where('wpl.id_product = ' . (int) $id_product . '
$query->where(
'wpl.id_product = ' . (int) $id_product . '
AND wpl.id_product_attribute = ' . (int) $id_product_attribute . '
AND wpl.id_warehouse = ' . (int) $id_warehouse
);

View File

@@ -1,11 +1,12 @@
<?php
/**
* 2007-2018 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
@@ -16,12 +17,11 @@
*
* 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.
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');