Commit d1959d1d authored by Rémi Gaillard's avatar Rémi Gaillard

// Fix #PSCFV-4916

parent a7ec9048
......@@ -531,7 +531,7 @@ abstract class PaymentModuleCore extends Module
{
$history = new OrderHistory();
$history->id_order = (int)$order->id;
$history->changeIdOrderState(Configuration::get('PS_OS_OUTOFSTOCK'), (int)$order->id);
$history->changeIdOrderState(Configuration::get('PS_OS_OUTOFSTOCK'), $order);
$history->addWithemail();
}
......@@ -539,7 +539,7 @@ abstract class PaymentModuleCore extends Module
// So you migth have two order states
$new_history = new OrderHistory();
$new_history->id_order = (int)$order->id;
$new_history->changeIdOrderState((int)$id_order_state, (int)$order->id, true);
$new_history->changeIdOrderState((int)$id_order_state, $order, true);
$new_history->addWithemail(true, $extra_vars);
unset($order_detail);
......
......@@ -387,7 +387,7 @@ class OrderCore extends ObjectModel
{
$history = new OrderHistory();
$history->id_order = (int)($this->id);
$history->changeIdOrderState(Configuration::get('PS_OS_CANCELED'), (int)($this->id));
$history->changeIdOrderState(Configuration::get('PS_OS_CANCELED'), $this);
if (!$history->addWithemail())
return false;
}
......@@ -1289,7 +1289,7 @@ class OrderCore extends ObjectModel
$history = new OrderHistory();
$history->id_order = (int)$this->id;
$history->id_employee = (int)$id_employee;
$history->changeIdOrderState((int)$id_order_state, (int)$this->id);
$history->changeIdOrderState((int)$id_order_state, $this);
$res = Db::getInstance()->getRow('
SELECT `invoice_number`, `invoice_date`, `delivery_number`, `delivery_date`
FROM `'._DB_PREFIX_.'orders`
......@@ -1298,10 +1298,9 @@ class OrderCore extends ObjectModel
$this->invoice_number = $res['invoice_number'];
$this->delivery_date = $res['delivery_date'];
$this->delivery_number = $res['delivery_number'];
$history->addWithemail();
$this->current_state = $id_order_state;
$this->update();
$history->addWithemail();
}
public function addWs($autodate = true, $nullValues = false)
......
......@@ -74,13 +74,18 @@ class OrderHistoryCore extends ObjectModel
* @param int $id_order
* @param bool $use_existing_payment
*/
public function changeIdOrderState($new_order_state, $id_order, $use_existing_payment = false)
public function changeIdOrderState($new_order_state, &$id_order, $use_existing_payment = false)
{
if (!$new_order_state || !$id_order)
return;
// sets order and states
$order = new Order($id_order);
if (!is_object($id_order) && is_numeric($id_order))
$order = new Order((int)$id_order);
elseif (is_object($id_order))
$order = $id_order;
else
return;
$new_os = new OrderState((int)$new_order_state, $order->id_lang);
$old_os = $order->getCurrentOrderState();
$is_validated = $this->isValidated();
......@@ -149,7 +154,7 @@ class OrderHistoryCore extends ObjectModel
$product['product_quantity'],
Configuration::get('PS_STOCK_CUSTOMER_ORDER_REASON'),
true,
(int)$id_order
(int)$order->id
);
}
// @since.1.5.0 : if the order was shipped, and is not anymore, we need to restock products
......
......@@ -340,7 +340,7 @@ class AdminOrdersControllerCore extends AdminController
$use_existings_payment = false;
if (!$order->hasInvoice())
$use_existings_payment = true;
$history->changeIdOrderState($order_state->id, $order->id, $use_existings_payment);
$history->changeIdOrderState((int)$order_state->id, $order, $use_existings_payment);
$carrier = new Carrier($order->id_carrier, $order->id_lang);
$templateVars = array();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment