// StockManagement: added hints with the last unit price and the last quantity of the last stock mvt when adding stock. Quantity is now usable by default when adding stock.

This commit is contained in:
bMancone
2011-12-28 18:16:51 +00:00
parent 5b6681472a
commit d993f8ced4
4 changed files with 58 additions and 8 deletions
+1 -1
View File
@@ -2334,7 +2334,7 @@ class AdminControllerCore extends Controller
if (!$type)
return;
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.$this->table.'_'.$type.($id_object ? ' WHERE `'.$this->identifier.'`='.(int)$id_object : ''));
foreach ($assos as $asso)
+4 -4
View File
@@ -95,12 +95,12 @@ class HelperFormCore extends Helper
{
// Added Jquery plugin treeview (css and js files)
$this->context->controller->addJqueryPlugin('treeview');
// Added JS files
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.async.js');
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.edit.js');
$this->context->controller->addJS(_PS_JS_DIR_.'admin-categories-tree.js');
if (isset($params['use_search']) && $params['use_search'])
$this->context->controller->addJS(_PS_JS_DIR_.'jquery/plugins/autocomplete/jquery.autocomplete.js');
$categories = false;
@@ -129,7 +129,7 @@ class HelperFormCore extends Helper
$this->tpl_vars['path_css'] = _THEME_CSS_DIR_;
$this->tpl_vars['ad'] = dirname($_SERVER['PHP_SELF']);
$this->tpl_vars['tinymce'] = true;
$this->context->controller->addJS(_PS_JS_DIR_.'tiny_mce/tiny_mce.js');
$this->context->controller->addJS(_PS_JS_DIR_.'tinymce.inc.js');
$tinymce = false;
@@ -141,7 +141,7 @@ class HelperFormCore extends Helper
$this->tpl->assign(array(
'title' => $this->title,
'toolbar_btn' => $this->toolbar_btn,
'ps_help_context' => $this->ps_help_context,
'class_name' => get_class($this->context->controller),
'iso_user' => $this->context->language->id,
+23
View File
@@ -211,4 +211,27 @@ class StockMvtCore extends ObjectModel
return $mvts;
}
/**
* For a given product, gets the last positive stock mvt
* @param int $id_product
* @param int $id_product_attribute
* @return bool|array
*/
public static function getLastPositiveStockMvt($id_product, $id_product_attribute)
{
$query = new DbQuery();
$query->select('sm.*, w.id_currency, (s.usable_quantity = sm.physical_quantity) as is_usable');
$query->from('stock_mvt', 'sm');
$query->innerJoin('stock', 's', 's.id_stock = sm.id_stock');
$query->innerJoin('warehouse', 'w', 'w.id_warehouse = s.id_warehouse');
$query->where('sm.sign = 1');
$query->where('s.id_product = '.(int)$id_product.' AND s.id_product_attribute = '.(int)$id_product_attribute);
$query->orderBy('date_add DESC');
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
if ($res !== false)
return $res['0'];
return false;
}
}