// Stock Available : Improve BackOffice interfaces with groups of shops management + bugs fix

This commit is contained in:
dSevere
2011-12-02 17:31:16 +00:00
parent 7733bc9efe
commit f426575405
13 changed files with 42 additions and 36 deletions
@@ -29,10 +29,10 @@
{block name="override_tpl"}
<h2>{$manufacturer->name}</h2>
<h3>{l s='Total addresses:'} {count($addresses)}</h3>
<hr />
{if !count($addresses)}
{l s='No address for this manufacturer'}
{else}
@@ -61,7 +61,7 @@
{/foreach}
{/if}
<br /><br />
<h3>{l s='Total products:'} {count($products)}</h3>
{foreach $products AS $product}
<hr />
@@ -70,7 +70,7 @@
<a href="?tab=AdminProducts&id_product={$product->id}&updateproduct&token={getAdminToken tab='AdminProducts'}" class="button">{l s='Edit'}</a>
<a href="?tab=AdminProducts&id_product={$product->id}&deleteproduct&token={getAdminToken tab='AdminProducts'}" class="button" onclick="return confirm('{l s='Delete item #'}{$product->id} ?');">{l s='Delete'}</a>
</div>
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width:990px;">
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width:80%;margin-left:10%;">
<tr>
<th>{$product->name}</th>
{if !empty($product->reference)}<th width="150">{l s='Ref:'} {$product->reference}</th>{/if}
@@ -85,13 +85,13 @@
<a href="?tab=AdminProducts&id_product={$product->id}&deleteproduct&token={getAdminToken tab='AdminProducts'}" class="button" onclick="return confirm('{l s='Delete item #'}{$product->id} ?');">{l s='Delete'}</a>
</div>
<h3><a href="?tab=AdminProducts&id_product={$product->id}&updateproduct&token={getAdminToken tab='AdminProducts'}">{$product->name}</a></h3>
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width:990px;">
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width:80%;margin-left:10%;">
<tr>
<th>{l s='Attribute name'}</th>
<th width="80">{l s='Reference'}</th>
<th width="80">{l s='EAN13'}</th>
<th width="80">{l s='UPC'}</th>
{if $stock_management}<th class="right" width="40">{l s='Quantity'}</th>{/if}
{if $stock_management && $shopContext != Shop::CONTEXT_ALL}<th class="right" width="150">{l s='Available Quantity'}</th>{/if}
</tr>
{foreach $product->combinaison AS $id_product_attribute => $product_attribute}
<tr {if $id_product_attribute %2}class="alt_row"{/if} >
@@ -99,7 +99,7 @@
<td>{$product_attribute.reference}</td>
<td>{$product_attribute.ean13}</td>
<td>{$product_attribute.upc}</td>
{if $stock_management}<td class="right">{$product_attribute.quantity}</td>{/if}
{if $stock_management && $shopContext != Shop::CONTEXT_ALL}<td class="right">{$product_attribute.quantity}</td>{/if}
</tr>
{/foreach}
</table>
+2 -2
View File
@@ -51,7 +51,7 @@
<th width="80">{l s='Reference'}</th>
<th width="80">{l s='EAN13'}</th>
<th width="80">{l s='UPC'}</th>
{if $stock_management}<th class="right" width="150">{l s='Available Quantity'}</th>{/if}
{if $stock_management && $shopContext != Shop::CONTEXT_ALL}<th class="right" width="150">{l s='Available Quantity'}</th>{/if}
</tr>
{foreach $product->combinaison AS $id_product_attribute => $product_attribute}
<tr {if $id_product_attribute %2}class="alt_row"{/if} >
@@ -59,7 +59,7 @@
<td>{$product_attribute.reference}</td>
<td>{$product_attribute.ean13}</td>
<td>{$product_attribute.upc}</td>
{if $stock_management}<td class="right">{$product_attribute.quantity}</td>{/if}
{if $stock_management && $shopContext != Shop::CONTEXT_ALL}<td class="right">{$product_attribute.quantity}</td>{/if}
</tr>
{/foreach}
</table>
+3 -3
View File
@@ -394,7 +394,7 @@ class CartCore extends ObjectModel
pl.`description_short`, pl.`available_now`, pl.`available_later`, p.`id_product`, p.`id_category_default`, p.`id_supplier`,
p.`id_manufacturer`, p.`on_sale`, p.`ecotax`, p.`additional_shipping_cost`, p.`available_for_order`, p.`price`, p.`weight`,
stock.`quantity` quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, p.`active`, p.`date_add`,
p.`date_upd`, t.`id_tax`, tl.`name` AS tax, t.`rate`, stock.quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
p.`date_upd`, t.`id_tax`, tl.`name` AS tax, t.`rate`, IFNULL(stock.quantity, 0), pl.`link_rewrite`, cl.`link_rewrite` AS category,
CONCAT(cp.`id_product`, cp.`id_product_attribute`, cp.`id_address_delivery`) AS unique_id, cp.id_address_delivery');
// Build FROM
@@ -783,7 +783,7 @@ class CartCore extends ObjectModel
{
if ($operator == 'up')
{
$sql = 'SELECT stock.out_of_stock, stock.quantity
$sql = 'SELECT stock.out_of_stock, IFNULL(stock.quantity, 0)
FROM '._DB_PREFIX_.'product p
'.Product::sqlStock('p', $id_product_attribute, true, $shop).'
WHERE p.id_product = '.$id_product;
@@ -825,7 +825,7 @@ class CartCore extends ObjectModel
/* Add product to the cart */
else
{
$sql = 'SELECT stock.out_of_stock, stock.quantity
$sql = 'SELECT stock.out_of_stock, IFNULL(stock.quantity, 0)
FROM '._DB_PREFIX_.'product p
'.Product::sqlStock('p', $id_product_attribute, true, $shop).'
WHERE p.id_product = '.$id_product;
+1 -1
View File
@@ -597,7 +597,7 @@ class CategoryCore extends ObjectModel
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
$sql = 'SELECT p.*, stock.out_of_stock, stock.quantity as quantity, pa.`id_product_attribute`, pl.`description`, pl.`description_short`, pl.`available_now`,
$sql = 'SELECT p.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pa.`id_product_attribute`, pl.`description`, pl.`description_short`, pl.`available_now`,
pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, i.`id_image`,
il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name, t.`rate`, cl.`name` AS category_default,
DATEDIFF(p.`date_add`, DATE_SUB(NOW(),
+1 -1
View File
@@ -335,7 +335,7 @@ class ManufacturerCore extends ObjectModel
return (int)count($result);
}
$sql = 'SELECT p.*, stock.out_of_stock, stock.quantity as quantity, pa.`id_product_attribute`,
$sql = 'SELECT p.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pa.`id_product_attribute`,
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`,
pl.`meta_title`, pl.`name`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name, t.`rate`,
DATEDIFF(
+8 -8
View File
@@ -571,7 +571,7 @@ class ProductCore extends ObjectModel
FROM '._DB_PREFIX_.'product_attribute pa'
.($minimum_quantity > 0 ? Product::sqlStock('pa', 'pa') : '').
' WHERE pa.default_on = 1 '
.($minimum_quantity > 0 ? ' AND stock.quantity >= '.(int)$minimum_quantity : '').
.($minimum_quantity > 0 ? ' AND IFNULL(stock.quantity, 0) >= '.(int)$minimum_quantity : '').
' AND pa.id_product = '.(int)$id_product;
$result = Db::getInstance()->getValue($sql);
@@ -581,7 +581,7 @@ class ProductCore extends ObjectModel
FROM '._DB_PREFIX_.'product_attribute pa'
.($minimum_quantity > 0 ? Product::sqlStock('pa', 'pa') : '').
' WHERE pa.id_product = '.(int)$id_product
.($minimum_quantity > 0 ? ' AND stock.quantity >= '.(int)$minimum_quantity : '');
.($minimum_quantity > 0 ? ' AND IFNULL(stock.quantity, 0) >= '.(int)$minimum_quantity : '');
$result = Db::getInstance()->getValue($sql);
}
@@ -1632,7 +1632,7 @@ class ProductCore extends ObjectModel
if (!Combination::isFeatureActive())
return array();
$sql = 'SELECT pa.*, GROUP_CONCAT(agl.`name`, \''.pSQL($attribute_value_separator).'\',
al.`name` SEPARATOR \''.pSQL($attribute_separator).'\') as attribute_designation, stock.quantity
al.`name` SEPARATOR \''.pSQL($attribute_separator).'\') as attribute_designation, IFNULL(stock.quantity, 0)
FROM `'._DB_PREFIX_.'product_attribute` pa
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute`
@@ -1656,7 +1656,7 @@ class ProductCore extends ObjectModel
if (!Combination::isFeatureActive())
return array();
$sql = 'SELECT pa.*, ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, al.`name` AS attribute_name,
a.`id_attribute`, pa.`unit_price_impact`, stock.quantity
a.`id_attribute`, pa.`unit_price_impact`, IFNULL(stock.quantity, 0) as quantity
FROM `'._DB_PREFIX_.'product_attribute` pa
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute`
@@ -1775,7 +1775,7 @@ class ProductCore extends ObjectModel
$sql = new DbQuery();
$sql->select(
'p.*, stock.out_of_stock, stock.quantity as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
'p.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name,
DATEDIFF(
p.`date_add`,
@@ -1972,7 +1972,7 @@ class ProductCore extends ObjectModel
return (int)$result['nb'];
}
$sql = 'SELECT p.*, stock.out_of_stock, stock.quantity as quantity, pl.`description`, pl.`description_short`,
$sql = 'SELECT p.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`,
pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`,
pl.`name`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name,
DATEDIFF(
@@ -2766,7 +2766,7 @@ class ProductCore extends ObjectModel
return array();
$sql = 'SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name,
a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, pa.`id_product_attribute`,
stock.quantity, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference`, pa.`unit_price_impact`,
IFNULL(stock.quantity, 0) as quantity, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference`, pa.`unit_price_impact`,
pa.`minimal_quantity`, pa.`available_date`, ag.`group_type`
FROM `'._DB_PREFIX_.'product_attribute` pa
'.Product::sqlStock('pa', 'pa').'
@@ -2838,7 +2838,7 @@ class ProductCore extends ObjectModel
if (!$context)
$context = Context::getContext();
$sql = 'SELECT p.*, stock.out_of_stock, stock.quantity as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`,
$sql = 'SELECT p.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`,
pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`,
i.`id_image`, il.`legend`, t.`rate`, m.`name` as manufacturer_name, cl.`name` AS category_default,
DATEDIFF(
+1 -1
View File
@@ -78,7 +78,7 @@ class ProductSaleCore
$groups = FrontController::getCurrentCustomerGroups();
$sqlGroups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
$sql = 'SELECT p.*, stock.out_of_stock, stock.quantity as quantity,
$sql = 'SELECT p.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, m.`name` AS manufacturer_name, p.`id_manufacturer` as id_manufacturer,
i.`id_image`, il.`legend`,
ps.`quantity` AS sales, t.`rate`, pl.`meta_keywords`, pl.`meta_title`, pl.`meta_description`,
+2 -2
View File
@@ -263,7 +263,7 @@ class SearchCore
return $db->executeS($sql);
}
$sql = 'SELECT p.*, stock.out_of_stock, stock.quantity as quantity,
$sql = 'SELECT p.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
tax.`rate`, i.`id_image`, il.`legend`, m.`name` manufacturer_name '.$score.',
DATEDIFF(
@@ -600,7 +600,7 @@ class SearchCore
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
$sql = 'SELECT DISTINCT p.*, stock.out_of_stock, stock.quantity as quantity, pl.`description_short`, pl.`link_rewrite`, pl.`name`,
$sql = 'SELECT DISTINCT p.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description_short`, pl.`link_rewrite`, pl.`name`,
tax.`rate`, i.`id_image`, il.`legend`, m.`name` manufacturer_name, 1 position,
DATEDIFF(
p.`date_add`,
+1 -1
View File
@@ -231,7 +231,7 @@ class SupplierCore extends ObjectModel
$nb_days_new_product = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20;
$sql = 'SELECT p.*, stock.out_of_stock,
stock.quantity as quantity,
IFNULL(stock.quantity, 0) as quantity,
pl.`description`,
pl.`description_short`,
pl.`link_rewrite`,
+9 -5
View File
@@ -540,7 +540,6 @@ class StockAvailableCore extends ObjectModel
public static function addSqlShopRestriction(DbQuery $sql = null, $id_shop = null, $alias = null)
{
$context = Context::getContext();
$group_ok = false;
if (!empty($alias))
$alias .= '.';
@@ -565,12 +564,17 @@ class StockAvailableCore extends ObjectModel
$sql = ' AND '.pSQL($alias).'id_group_shop = '.(int)$group_shop->id.' ';
$sql .= ' AND '.pSQL($alias).'id_shop = 0 ';
}
$group_ok = true;
}
// else if we are in group context
else if ($context->shop() == Shop::CONTEXT_GROUP)
{
if (is_object($sql))
$sql->where(pSQL($alias).'id_shop IN ('.implode(', ', Shop::getShops(true, $group_shop->id, true)).')');
else
$sql = ' AND '.pSQL($alias).'id_shop IN ('.implode(', ', Shop::getShops(true, $group_shop->id, true)).') ';
}
// if no group specific restriction, set simple shop restriction
if (!$group_ok)
else
{
if (is_object($sql))
$sql->where(pSQL($alias).'id_shop = '.(int)$id_shop);
@@ -89,7 +89,7 @@ class AdminManufacturersControllerCore extends AdminController
parent::__construct();
}
public function setMedia()
{
parent::setMedia();
@@ -606,6 +606,7 @@ class AdminManufacturersControllerCore extends AdminController
'addresses' => $addresses,
'products' => $products,
'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'),
'shopContext' => Context::getContext()->shop(),
);
return parent::renderView();
@@ -53,14 +53,14 @@ class AdminSuppliersControllerCore extends AdminController
parent::__construct();
}
public function setMedia()
{
parent::setMedia();
$this->addJqueryUi('ui.widget');
$this->addJqueryPlugin('tagify');
}
public function renderForm()
{
$this->fields_form = array(
@@ -201,6 +201,7 @@ class AdminSuppliersControllerCore extends AdminController
'supplier' => $this->object,
'products' => $products,
'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'),
'shopContext' => Context::getContext()->shop(),
);
return parent::renderView();
@@ -125,7 +125,7 @@ class AdminTrackingController extends AdminController
SELECT DISTINCT(id_product)
FROM `'._DB_PREFIX_.'product_attribute`
)
AND stock.quantity <= 0
AND IFNULL(stock.quantity, 0) <= 0
)';
$this->tpl_list_vars = array('sub_title' => $this->l('List of products with attributes and without available quantities for sale:'));
@@ -163,7 +163,7 @@ class AdminTrackingController extends AdminController
SELECT DISTINCT(id_product)
FROM `'._DB_PREFIX_.'product_attribute`
)
AND stock.quantity <= 0
AND IFNULL(stock.quantity, 0) <= 0
)';
$this->tpl_list_vars = array('sub_title' => $this->l('List of products without attributes and without available quantities for sale:'));