From 70884dcea0ecf0fc8a5ba70dedd58875e26e6749 Mon Sep 17 00:00:00 2001 From: PLESK5 Date: Fri, 21 Oct 2016 11:39:37 +0200 Subject: [PATCH] add synchro erp action --- controllers/admin/AdminOrdersController.php | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index dde8b0e..93204c9 100755 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1520,6 +1520,35 @@ class AdminOrdersControllerCore extends AdminController } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } + } elseif (Tools::getValue('syncherp') == 1) { + $id_order = Tools::getValue('id_order', false); + if ($id_order) { + $order = new Order((int)$id_order); + if (!$order->isSynchIntoErp()) { + + if ($order->getIdErp() === 1) { + $order->deletIdErpIfNotSynch(); + } + + $params['id_order'] = $order->id; + $params['newOrderStatus'] = new StdClass(); + + if ($order->hasStatusInHistory(2)) { + $params['newOrderStatus']->id = 2; + } elseif ($order->hasStatusInHistory(10)) { + $params['newOrderStatus']->id = 10; + } elseif ($order->hasStatusInHistory(1)) { + $params['newOrderStatus']->id = 1; + } + + if (!empty($params['newOrderStatus']->id)) { + $erporder = Module::getInstanceByName('erporder'); + if ($erporder) { + return $erporder->hookActionOrderStatusPostUpdate($params); + } + } + } + } } parent::postProcess();