// Multiple bugs fix on stock interfaces during tests

This commit is contained in:
dSevere
2011-12-08 15:22:31 +00:00
parent fe2d0ec0cf
commit 133e64cc55
6 changed files with 265 additions and 45 deletions
+4 -5
View File
@@ -1793,7 +1793,6 @@ class AdminControllerCore extends Controller
if ($this->tabAccess['add'] === '1')
{
$this->action = 'new';
$this->action = 'Informations';
$this->display = 'add';
}
else
@@ -2421,7 +2420,7 @@ EOF;
$html .= '<td>
<img style="vertical-align: middle;" alt="" src="../img/admin/lv2_b.gif" />
<label class="t">
<input class="input_group_shop" type="checkbox"
<input class="input_group_shop" type="checkbox"
name="checkBoxGroupShopAsso_'.$this->table.'_'.$this->object->id.'_'.$group_id.'" value="'.$group_id.'" '.
($group_checked ? 'checked="checked"' : '').' /> '.
$group_data['name'].'
@@ -2440,7 +2439,7 @@ EOF;
$html .= '<td>
<img style="vertical-align: middle;" alt="" src="../img/admin/lv3_'.(($j < $total - 1) ? 'b' : 'f').'.png" />
<label class="child">';
$html .= '<input class="input_shop" type="checkbox" value="'.$group_id.'"
$html .= '<input class="input_shop" type="checkbox" value="'.$group_id.'"
name="checkBoxShopAsso_'.$this->table.'_'.$this->object->id.'_'.$shop_id.'" id="checkedBox_'.$shop_id.'" '.
($checked ? 'checked="checked"' : '').' /> ';
$html .= $shop_data['name'].'</label></td>';
@@ -2598,10 +2597,10 @@ EOF;
'.$this->l('Choose language:').'<br /><br />';
foreach ($languages as $language)
if ($use_vars_instead_of_ids)
$output .= '<img src="../img/l/'.(int)$language['id_lang'].'.jpg" class="pointer" alt="'.$language['name'].'" title="'.$language['name'].'"
$output .= '<img src="../img/l/'.(int)$language['id_lang'].'.jpg" class="pointer" alt="'.$language['name'].'" title="'.$language['name'].'"
onclick="changeLanguage(\''.$id.'\', '.$ids.', '.$language['id_lang'].', \''.$language['iso_code'].'\');" /> ';
else
$output .= '<img src="../img/l/'.(int)$language['id_lang'].'.jpg" class="pointer" alt="'.$language['name'].'" title="'.$language['name'].'"
$output .= '<img src="../img/l/'.(int)$language['id_lang'].'.jpg" class="pointer" alt="'.$language['name'].'" title="'.$language['name'].'"
onclick="changeLanguage(\''.$id.'\', \''.$ids.'\', '.$language['id_lang'].', \''.$language['iso_code'].'\');" /> ';
$output .= '</div>';
+221 -25
View File
@@ -39,37 +39,233 @@ class AdminPPreferencesControllerCore extends AdminController
'title' => $this->l('Products'),
'icon' => 'tab-orders',
'fields' => array(
'PS_CATALOG_MODE' => array('title' => $this->l('Catalog mode:'), 'desc' => $this->l('When active, all features for shopping will be disabled'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'),
'PS_ORDER_OUT_OF_STOCK' => array('title' => $this->l('Allow ordering out-of-stock product:'), 'desc' => $this->l('Add to cart button is hidden when product is unavailable'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'),
'PS_STOCK_MANAGEMENT' => array('title' => $this->l('Enable stock management:'), 'desc' => '', 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool', 'js' => array('on' => 'onchange="stockManagementActivationAuthorization()"', 'off' => 'onchange="stockManagementActivationAuthorization()"')),
'PS_ADVANCED_STOCK_MANAGEMENT' => array('title' => $this->l('Enable advanced stock management:'), 'desc' => $this->l('When active, allows you to manage your physical stock, warehouses, supply orders'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'),
'PS_DISPLAY_QTIES' => array('title' => $this->l('Display available quantities on product page:'), 'desc' => '', 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'),
'PS_DISPLAY_JQZOOM' => array('title' => $this->l('Enable JqZoom instead of Thickbox on product page:'), 'desc' => '', 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'),
'PS_DISP_UNAVAILABLE_ATTR' => array('title' => $this->l('Display unavailable product attributes on product page:'), 'desc' => '', 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'),
'PS_ATTRIBUTE_CATEGORY_DISPLAY' => array('title' => $this->l('Display "add to cart" button when product has attributes:'), 'desc' => $this->l('Display or hide the "add to cart" button on category pages for products that have attributes to force customers to see the product detail'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_COMPARATOR_MAX_ITEM' => array('title' => $this->l('Max items in the comparator:'), 'desc' => $this->l('Set to 0 to disable this feature'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
'PS_PURCHASE_MINIMUM' => array('title' => $this->l('Minimum purchase total required in order to validate order:'), 'desc' => $this->l('Set to 0 to disable this feature'), 'validation' => 'isFloat', 'cast' => 'floatval', 'type' => 'price'),
'PS_LAST_QTIES' => array('title' => $this->l('Display last quantities when qty is lower than:'), 'desc' => $this->l('Set to 0 to disable this feature'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
'PS_NB_DAYS_NEW_PRODUCT' => array('title' => $this->l('Number of days during which the product is considered \'new\':'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text'),
'PS_CART_REDIRECT' => array('title' => $this->l('Re-direction after adding product to cart:'), 'desc' => $this->l('Concerns only the non-AJAX version of the cart'), 'cast' => 'intval', 'show' => true, 'required' => false, 'type' => 'radio', 'validation' => 'isBool', 'choices' => array(0 => $this->l('previous page'), 1 => $this->l('cart summary'))),
'PS_PRODUCTS_PER_PAGE' => array('title' => $this->l('Products per page:'), 'desc' => $this->l('Products displayed per page. Default is 10.'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text'),
'PS_PRODUCTS_ORDER_BY' => array('title' => $this->l('Default order by:'), 'desc' => $this->l('Default order by for product list'), 'type' => 'select', 'list' =>
array(
'PS_CATALOG_MODE' => array(
'title' => $this->l('Catalog mode:'),
'desc' => $this->l('When active, all features for shopping will be disabled'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_ORDER_OUT_OF_STOCK' => array(
'title' => $this->l('Allow ordering out-of-stock product:'),
'desc' => $this->l('Add to cart button is hidden when product is unavailable'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_STOCK_MANAGEMENT' => array(
'title' => $this->l('Enable stock management:'),
'desc' => '',
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
'js' => array(
'on' => 'onchange="stockManagementActivationAuthorization()"',
'off' => 'onchange="stockManagementActivationAuthorization()"'
)
),
'PS_ADVANCED_STOCK_MANAGEMENT' => array(
'title' => $this->l('Enable advanced stock management:'),
'desc' => $this->l('When active, allows you to manage your physical stock, warehouses and supply orders.
You have to manage at least 1 warehouse when this feature is enabled.'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_DISPLAY_QTIES' => array(
'title' => $this->l('Display available quantities on product page:'),
'desc' => '',
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_DISPLAY_JQZOOM' => array(
'title' => $this->l('Enable JqZoom instead of Thickbox on product page:'),
'desc' => '',
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_DISP_UNAVAILABLE_ATTR' => array(
'title' => $this->l('Display unavailable product attributes on product page:'),
'desc' => '',
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_ATTRIBUTE_CATEGORY_DISPLAY' => array(
'title' => $this->l('Display "add to cart" button when product has attributes:'),
'desc' => $this->l('Display or hide the "add to cart" button on category pages for products
that have attributes to force customers to see the product detail'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
),
'PS_COMPARATOR_MAX_ITEM' => array(
'title' => $this->l('Max items in the comparator:'),
'desc' => $this->l('Set to 0 to disable this feature'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
),
'PS_PURCHASE_MINIMUM' => array(
'title' => $this->l('Minimum purchase total required in order to validate order:'),
'desc' => $this->l('Set to 0 to disable this feature'),
'validation' => 'isFloat',
'cast' => 'floatval',
'type' => 'price'
),
'PS_LAST_QTIES' => array(
'title' => $this->l('Display last quantities when qty is lower than:'),
'desc' => $this->l('Set to 0 to disable this feature'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
),
'PS_NB_DAYS_NEW_PRODUCT' => array(
'title' => $this->l('Number of days during which the product is considered \'new\':'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text'
),
'PS_CART_REDIRECT' => array(
'title' => $this->l('Re-direction after adding product to cart:'),
'desc' => $this->l('Concerns only the non-AJAX version of the cart'),
'cast' => 'intval',
'show' => true,
'required' => false,
'type' => 'radio',
'validation' => 'isBool',
'choices' => array(
0 => $this->l('previous page'),
1 => $this->l('cart summary')
)
),
'PS_PRODUCTS_PER_PAGE' => array(
'title' => $this->l('Products per page:'),
'desc' => $this->l('Products displayed per page. Default is 10.'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text'
),
'PS_PRODUCTS_ORDER_BY' => array(
'title' => $this->l('Default order by:'),
'desc' => $this->l('Default order by for product list'),
'type' => 'select',
'list' => array(
array('id' => '0', 'name' => $this->l('Product name')),
array('id' => '1', 'name' => $this->l('Product price')),
array('id' => '2', 'name' => $this->l('Product added date')),
array('id' => '4', 'name' => $this->l('Position inside category')),
array('id' => '5', 'name' => $this->l('Manufacturer')),
array('id' => '3', 'name' => $this->l('Product modified date'))
), 'identifier' => 'id'),
'PS_PRODUCTS_ORDER_WAY' => array('title' => $this->l('Default order way:'), 'desc' => $this->l('Default order way for product list'), 'type' => 'select', 'list' => array(array('id' => '0', 'name' => $this->l('Ascending')), array('id' => '1', 'name' => $this->l('Descending'))), 'identifier' => 'id'),
'PS_PRODUCT_SHORT_DESC_LIMIT' => array('title' => $this->l('Short description max size'), 'desc' => $this->l('Set the maximum size of product short description'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text'),
'PS_IMAGE_GENERATION_METHOD' => array('title' => $this->l('Image generated by:'), 'validation' => 'isUnsignedId', 'required' => false, 'cast' => 'intval', 'type' => 'select', 'list' => array(array('id' => '0', 'name' => $this->l('auto')), array('id' => '1', 'name' => $this->l('width')), array('id' => '2', 'name' => $this->l('height'))), 'identifier' => 'id', 'visibility' => Shop::CONTEXT_ALL),
'PS_PRODUCT_PICTURE_MAX_SIZE' => array('title' => $this->l('Maximum size of product pictures:'), 'desc' => $this->l('The maximum size of pictures uploadable by customers (in Bytes)'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL),
'PS_PRODUCT_PICTURE_WIDTH' => array('title' => $this->l('Product pictures width:'), 'desc' => $this->l('The maximum width of pictures uploadable by customers'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL),
'PS_PRODUCT_PICTURE_HEIGHT' => array('title' => $this->l('Product pictures height:'), 'desc' => $this->l('The maximum height of pictures uploadable by customers'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL),
'PS_LEGACY_IMAGES' => array('title' => $this->l('Use the legacy image filesystem:'), 'desc' => $this->l('This should be set to yes unless you successfully moved images in Preferences > Images tab'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool', 'visibility' => Shop::CONTEXT_ALL),
'PS_QTY_DISCOUNT_ON_COMBINATION' => array('title' => $this->l('Quantity discounts based on:'), 'desc' => $this->l('How to calculate quantity discounts'), 'cast' => 'intval', 'show' => true, 'required' => false, 'type' => 'radio', 'validation' => 'isBool', 'choices' => array(0 => $this->l('Products'), 1 => $this->l('Combinations')))
),
'identifier' => 'id'
),
'PS_PRODUCTS_ORDER_WAY' => array(
'title' => $this->l('Default order way:'),
'desc' => $this->l('Default order way for product list'),
'type' => 'select',
'list' => array(
array(
'id' => '0',
'name' => $this->l('Ascending')
),
array(
'id' => '1',
'name' => $this->l('Descending')
)
),
'identifier' => 'id'
),
'PS_PRODUCT_SHORT_DESC_LIMIT' => array(
'title' => $this->l('Short description max size'),
'desc' => $this->l('Set the maximum size of product short description'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text'
),
'PS_IMAGE_GENERATION_METHOD' => array(
'title' => $this->l('Image generated by:'),
'validation' => 'isUnsignedId',
'required' => false,
'cast' => 'intval',
'type' => 'select',
'list' => array(
array(
'id' => '0',
'name' => $this->l('auto')
),
array(
'id' => '1',
'name' => $this->l('width')
),
array(
'id' => '2',
'name' => $this->l('height')
)
),
'identifier' => 'id',
'visibility' => Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_MAX_SIZE' => array(
'title' => $this->l('Maximum size of product pictures:'),
'desc' => $this->l('The maximum size of pictures uploadable by customers (in Bytes)'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text',
'visibility' => Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_WIDTH' => array(
'title' => $this->l('Product pictures width:'),
'desc' => $this->l('The maximum width of pictures uploadable by customers'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text',
'visibility' => Shop::CONTEXT_ALL
),
'PS_PRODUCT_PICTURE_HEIGHT' => array(
'title' => $this->l('Product pictures height:'),
'desc' => $this->l('The maximum height of pictures uploadable by customers'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text',
'visibility' => Shop::CONTEXT_ALL
),
'PS_LEGACY_IMAGES' => array(
'title' => $this->l('Use the legacy image filesystem:'),
'desc' => $this->l('This should be set to yes unless you successfully moved images in Preferences > Images tab'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
'visibility' => Shop::CONTEXT_ALL
),
'PS_QTY_DISCOUNT_ON_COMBINATION' => array(
'title' => $this->l('Quantity discounts based on:'),
'desc' => $this->l('How to calculate quantity discounts'),
'cast' => 'intval',
'show' => true,
'required' => false,
'type' => 'radio',
'validation' => 'isBool',
'choices' => array(
0 => $this->l('Products'),
1 => $this->l('Combinations')
)
)
),
'bottom' => '<script type="text/javascript">stockManagementActivationAuthorization();</script>',
'submit' => array()
@@ -126,7 +126,8 @@ class AdminStockConfigurationControllerCore extends AdminController
public function init()
{
// if we are managing the second list (i.e. supply order state)
if (Tools::isSubmit('addsupply_order_state') ||
if (Tools::isSubmit('submitAddsupply_order_state') ||
Tools::isSubmit('addsupply_order_state') ||
Tools::isSubmit('updatesupply_order_state') ||
Tools::isSubmit('deletesupply_order_state'))
{
@@ -135,7 +136,9 @@ class AdminStockConfigurationControllerCore extends AdminController
$this->identifier = 'id_supply_order_state';
$this->display = 'edit';
}
return parent::init();
parent::init();
p($this->display);
p($this->action);
}
/**
@@ -145,7 +148,10 @@ class AdminStockConfigurationControllerCore extends AdminController
public function renderForm()
{
// if we are managing StockMvtReason
if (Tools::isSubmit('addstock_mvt_reason') || Tools::isSubmit('updatestock_mvt_reason'))
if (Tools::isSubmit('addstock_mvt_reason') ||
Tools::isSubmit('updatestock_mvt_reason') ||
Tools::isSubmit('submitAddstock_mvt_reason') ||
Tools::isSubmit('submitUpdatestock_mvt_reason'))
{
$this->toolbar_title = $this->l('Stock : Add stock movement label');
@@ -504,10 +510,6 @@ class AdminStockConfigurationControllerCore extends AdminController
*/
public function postProcess()
{
// StockMvtReason
if (Tools::isSubmit('delete'.$this->table))
$this->deleted = true;
// SupplyOrderState
if (Tools::isSubmit('submitAddsupply_order_state') ||
Tools::isSubmit('deletesupply_order_state') ||
@@ -522,6 +524,9 @@ class AdminStockConfigurationControllerCore extends AdminController
$this->identifier = 'id_supply_order_state';
$this->_defaultOrderBy = 'id_supply_order_state';
}
// StockMvtReason
else if (Tools::isSubmit('delete'.$this->table))
$this->deleted = true;
return parent::postProcess();
}
@@ -110,22 +110,24 @@ class AdminStockCoverControllerCore extends AdminController
$id_product = (int)Tools::getValue('id');
$period = (Tools::getValue('period') ? (int)Tools::getValue('period') : 7);
$warehouse = Tools::getValue('id_warehouse', -1);
$where_warehouse = '';
if ($warehouse != -1)
$where_warehouse = ' AND s.id_warehouse = '.(int)$warehouse;
$query = new DbQuery();
$query->select('pa.id_product_attribute as id, pa.id_product, stock_view.reference, stock_view.ean13,
stock_view.upc, stock_view.usable_quantity as stock');
$query->from('product_attribute pa
INNER JOIN
$query->from('product_attribute pa');
$query->join('INNER JOIN
(
SELECT SUM(s.usable_quantity) as usable_quantity, s.id_product_attribute, s.reference, s.ean13, s.upc
FROM '._DB_PREFIX_.'stock s
WHERE s.id_product = '.($id_product).'
WHERE s.id_product = '.($id_product).
$where_warehouse.'
GROUP BY s.id_product_attribute
)
stock_view ON (stock_view.id_product_attribute = pa.id_product_attribute)');
$query->where('pa.id_product = '.$id_product);
if ($warehouse != -1)
$query->where('s.id_warehouse = '.(int)$warehouse);
$query->groupBy('pa.id_product_attribute');
$datas = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
@@ -114,6 +114,7 @@ class AdminStockInstantStateControllerCore extends AdminController
{
// query
$this->_select = '
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
SUM(a.physical_quantity) as physical_quantity,
SUM(a.usable_quantity) as usable_quantity,
SUM(a.price_te * a.physical_quantity) as valuation,
@@ -121,7 +122,21 @@ class AdminStockInstantStateControllerCore extends AdminController
$this->_group = 'GROUP BY a.id_product, a.id_product_attribute';
$this->_join = 'LEFT JOIN '._DB_PREFIX_.'warehouse w ON (w.id_warehouse = a.id_warehouse)';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = a.id_warehouse)';
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
a.id_product = pl.id_product
AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').'
)';
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.id_product_attribute = a.id_product_attribute)';
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'attribute` atr ON (atr.id_attribute = pac.id_attribute)';
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (
al.id_attribute = pac.id_attribute
AND al.id_lang = '.(int)$this->context->language->id.'
)';
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (
agl.id_attribute_group = atr.id_attribute_group
AND agl.id_lang = '.(int)$this->context->language->id.'
)';
if ($this->getCurrentCoverageWarehouse() != -1)
$this->_where .= ' AND a.id_warehouse = '.$this->getCurrentCoverageWarehouse();
@@ -173,7 +188,6 @@ class AdminStockInstantStateControllerCore extends AdminController
$item['price_te'] = '--';
$item[$this->identifier] = $item['id_product'].'_'.$item['id_product_attribute'];
$item['name'] = Product::getProductName($item['id_product'], $item['id_product_attribute']);
// gets stock manager
$manager = StockManagerFactory::getManager();
@@ -909,6 +909,8 @@ class AdminSupplyOrdersControllerCore extends AdminController
*/
public function postProcess()
{
$this->is_editing_order = false;
// Checks access
if (Tools::isSubmit('submitAddsupply_order') && !($this->tabAccess['add'] === '1'))
$this->_errors[] = Tools::displayError($this->l('You do not have the required permission to add a supply order.'));
@@ -918,6 +920,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
if (Tools::isSubmit('submitAddsupply_order') || Tools::isSubmit('submitAddsupply_orderAndStay'))
{
$this->action = 'save';
$this->is_editing_order = true;
// get supplier ID
$id_supplier = (int)Tools::getValue('id_supplier', 0);
@@ -1052,7 +1055,8 @@ class AdminSupplyOrdersControllerCore extends AdminController
if (Tools::isSubmit('create_supply_order') && Tools::isSubmit('id_supply_order'))
$this->postProcessCopyFromTemplate();
parent::postProcess();
if ( (!count($this->_errors) && $this->is_editing_order) || !$this->is_editing_order)
parent::postProcess();
// if the threshold is defined and we are saving the order
if (Tools::isSubmit('submitAddsupply_order') && $quantity_threshold != null)