// Stock : add state management on orders + bugs fix

This commit is contained in:
dSevere
2011-10-31 16:52:40 +00:00
parent c4070782f1
commit 48c76d5889
4 changed files with 91 additions and 5 deletions
+27 -2
View File
@@ -182,7 +182,12 @@ class SupplierOrderCore extends ObjectModel
{
$this->calculatePrices();
return parent::update($null_values);
$return = parent::update($null_values);
if ($return)
$this->addHistory();
return $return;
}
/**
@@ -192,7 +197,12 @@ class SupplierOrderCore extends ObjectModel
{
$this->calculatePrices();
return parent::add($autodate, $null_values);
$return = parent::add($autodate, $null_values);
if ($return)
$this->addHistory();
return $return;
}
/**
@@ -301,4 +311,19 @@ class SupplierOrderCore extends ObjectModel
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query) == 1);
}
/**
* Add order history
*
* @return bool
*/
protected function addHistory()
{
$history = new SupplierOrderHistory();
$history->id_supplier_order = $this->id;
$history->id_state = $this->id_supplier_order_state;
$history->id_employee = $this->id_employee;
$history->save();
}
}