// Fixed CSV export without pagination. Fixed StockManager, with new Collection object. Fixed StockMvt : id_supply_order was missing.

This commit is contained in:
bMancone
2011-12-06 09:37:23 +00:00
parent b83886bd10
commit de96b5bd2e
4 changed files with 25 additions and 13 deletions
+6 -6
View File
@@ -88,12 +88,12 @@ class StockManagerCore implements StockManagerInterface
$stock_collection = $this->getStockCollection($id_product, $id_product_attribute, $warehouse->id);
// if this product is already in stock
if (count($stock_collection) > 0)
if ($stock_collection->count() > 0)
{
$stock_exists = true;
// for a warehouse using WA, there is one and only one stock for a given product
$stock = $stock_collection[0];
$stock = $stock_collection->current();
// calculates WA price
$last_wa = $stock->price_te;
@@ -128,12 +128,12 @@ class StockManagerCore implements StockManagerInterface
$stock_collection = $this->getStockCollection($id_product, $id_product_attribute, $warehouse->id, $price_te);
// if this product is already in stock
if (count($stock_collection) > 0)
if ($stock_collection->count() > 0)
{
$stock_exists = true;
// there is one and only one stock for a given product in a warehouse and at the current unit price
$stock = $stock_collection[0];
$stock = $stock_collection->current();
$stock_params = array(
'physical_quantity' => ($stock->physical_quantity + $quantity),
@@ -234,7 +234,7 @@ class StockManagerCore implements StockManagerInterface
$stock_collection = $this->getStockCollection($id_product, $id_product_attribute, $warehouse->id);
// check if the collection is loaded
if (count($stock_collection) <= 0)
if ($stock_collection->count() <= 0)
return $return;
$stock_history_qty_available = array();
@@ -249,7 +249,7 @@ class StockManagerCore implements StockManagerInterface
// case CUMP mode
case 'WA':
// There is one and only one stock for a given product in a warehouse in this mode
$stock = $stock_collection[0];
$stock = $stock_collection->current();
$mvt_params = array(
'id_stock' => $stock->id,
+3 -1
View File
@@ -83,7 +83,7 @@ class StockMvtCore extends ObjectModel
* @since 1.5.0
* @var int Used when the movement is due to a supplier order
*/
public $id_supplier_order = null;
public $id_supply_order = null;
/**
* @since 1.5.0
@@ -146,6 +146,7 @@ class StockMvtCore extends ObjectModel
'physical_quantity' => 'isUnsignedInt',
'id_stock_mvt_reason' => 'isUnsignedId',
'id_order' => 'isUnsignedId',
'id_supply_order' => 'isUnsignedId',
'sign' => 'isInt',
'last_wa' => 'isPrice',
'current_wa' => 'isPrice',
@@ -175,6 +176,7 @@ class StockMvtCore extends ObjectModel
$fields['physical_quantity'] = (int)$this->physical_quantity;
$fields['id_stock_mvt_reason'] = (int)$this->id_stock_mvt_reason;
$fields['id_order'] = (int)$this->id_order;
$fields['id_supply_order'] = (int)$this->id_supply_order;
$fields['sign'] = (int)$this->sign;
$fields['last_wa'] = (float)Tools::ps_round($this->last_wa, 6);
$fields['current_wa'] = (float)Tools::ps_round($this->current_wa, 6);
+13 -6
View File
@@ -203,6 +203,9 @@ class AdminStockMvtControllerCore extends AdminController
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
if (Tools::isSubmit('csv'))
$limit = false;
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
//If there is a field product_name in the list, check if this field is null and display standard message
@@ -253,18 +256,22 @@ class AdminStockMvtControllerCore extends AdminController
header('Content-disposition: attachment; filename="'.$filename);
// puts keys
$keys = array('id_order', 'id_supply_order', 'firstname', 'lastname', 'quantity',
'date', 'sign', 'price_te', 'product_name', 'label', 'reference', 'ean13', 'upc');
$keys = array('id_order', 'id_supply_order', 'emloyee_firstname', 'employee_lastname', 'physical_quantity',
'date_add', 'sign', 'price_te', 'product_name', 'label', 'product_reference', 'product_ean13', 'product_upc');
echo sprintf("%s\n", implode(';', $keys));
// puts rows
foreach ($this->_list as $row)
{
// unsets not needed keys
unset($row['id_stock_mvt'], $row['id_stock'], $row['id_stock_mvt_reason'],
$row['id_employee'], $row['last_wa'], $row['current_wa'], $row['referer'], $row['id_currency'], $row['employee']);
$row_csv = array($row['id_order'], $row['id_supply_order'], $row['employee_firstname'],
$row['employee_lastname'], $row['physical_quantity'], $row['date_add'],
$row['sign'], $row['price_te'], $row['product_name'],
$row['reason'], $row['product_reference'], $row['product_ean13'], $row['product_upc']
);
// puts one row
echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $row)));
echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $row_csv)));
}
}
@@ -306,6 +306,9 @@ class AdminSupplyOrdersControllerCore extends AdminController
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
if (Tools::isSubmit('csv_orders') || Tools::isSubmit('csv_orders_details') || Tools::isSubmit('csv_order_details'))
$limit = false;
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
// actions filters on supply orders list