public function ajaxUpdateStates() { $context = Context::getContext(); $retour = null; $id_employee = (int) Tools::getValue('id_employee'); require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/order/ErpOrder.php'; set_error_handler(array('ErpOrder', 'ErpOrdersAjaxErrorHandler')); switch (Tools::getValue('action')) { case 'unique': $retour = array('res' => false, 'newColor' => null); $currOrder = new ErpOrder((int) Tools::getValue('idOrder')); $currOrder->setCurrentState((int) Tools::getValue('idState'), (int) $id_employee); $currOrder = new ErpOrder((int) Tools::getValue('idOrder')); /* Recreate object because the prvious one do not update after modification */ $currOrderState = $currOrder->getCurrentOrderState(); /* Get new state (no builder, need to pass by order) */ $retour['newColor'] = $currOrderState->color; $retour['res'] = true; if (isset($context->cookie->errorOrderAjaxHandler) && !empty($context->cookie->errorOrderAjaxHandler)) { $retour['message'] .= $context->cookie->errorOrderAjaxHandler; } break; case 'masse': $retour = array('message' => 'false', 'ordersWithoutError' => array()); foreach (Tools::getValue('idOrder') as $order) { try { $currOrder = new ErpOrder($order); $currOrder->setCurrentState(Tools::getValue('idState'), (int) $id_employee); $retour['ordersWithoutError'][] = $order; } catch (Exception $e) { if ($retour['message'] == 'false') { $retour['message'] = ''; } $retour['message'] .= $erpip->l('Error for the order #') . $order . ': ' . $e->getMessage() . '<br/>'; } if ($retour['message'] == 'false' && !empty($context->cookie->errorOrderAjaxHandler)) { $retour['message'] = ''; } if (!empty($context->cookie->errorOrderAjaxHandler)) { $retour['message'] .= $context->cookie->errorOrderAjaxHandler . '<br/>'; } } break; } print Tools::jsonEncode($retour); $context->cookie->__unset('errorOrderAjaxHandler'); exit; }
print Tools::jsonEncode($erp_orderfr); exit; } else { if (Tools::isSubmit('idOrder') && Tools::isSubmit('idState') && Tools::isSubmit('action') && Tools::isSubmit('id_employee')) { $retour = null; $id_employee = (int) Tools::getValue('id_employee'); require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/order/ErpOrder.php'; set_error_handler(array('ErpOrder', 'ErpOrdersAjaxErrorHandler')); switch (Tools::getValue('action')) { case 'unique': $retour = array('res' => false, 'newColor' => null); $currOrder = new ErpOrder((int) Tools::getValue('idOrder')); $currOrder->setCurrentState((int) Tools::getValue('idState'), (int) $id_employee); $currOrder = new ErpOrder((int) Tools::getValue('idOrder')); /* Recreate object because the prvious one do not update after modification */ $currOrderState = $currOrder->getCurrentOrderState(); /* Get new state (no builder, need to pass by order) */ $retour['newColor'] = $currOrderState->color; $retour['res'] = true; if (isset($context->cookie->errorOrderAjaxHandler) && !empty($context->cookie->errorOrderAjaxHandler)) { $retour['message'] .= $context->cookie->errorOrderAjaxHandler; } break; case 'masse': $retour = array('message' => 'false', 'ordersWithoutError' => array()); foreach (Tools::getValue('idOrder') as $order) { try { $currOrder = new ErpOrder($order); $currOrder->setCurrentState(Tools::getValue('idState'), (int) $id_employee); $retour['ordersWithoutError'][] = $order; } catch (Exception $e) {