* @subpackage Stock * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkEdit(); $stock_id = CValue::getOrSession('stock_id'); $category_id = CValue::getOrSession('category_id'); $product_id = CValue::get('product_id'); $letter = CValue::getOrSession('letter', "%"); // Loads the stock in function of the stock ID or the product ID $stock = new CProductStockGroup(); // If stock_id has been provided, we load the associated product if ($stock_id) { $stock->stock_id = $stock_id; $stock->loadMatchingObject(); $stock->loadRefsFwd(); $stock->_ref_product->loadRefsFwd(); } else { if ($product_id) { $product = new CProduct(); $product->load($product_id); $stock->product_id = $product_id; $stock->_ref_product = $product; } else { $stock->loadRefsFwd(); } } $stock->updateFormFields(); // Loads the required Category and the complete list $category = new CProductCategory();
/** * Get the related stock * * @return CProductStockGroup */ function getStock() { if ($this->_ref_stock_group) { return $this->_ref_stock_group; } $this->loadReference(); $this->loadOrder(); $stock = new CProductStockGroup(); $stock->group_id = $this->_ref_order->group_id; $stock->product_id = $this->_ref_reference->product_id; $stock->loadMatchingObject(); return $this->_ref_stock_group = $stock; }