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;
 }
示例#2
0
        break;
    case 'getPresenceWarehouseB':
        if (Tools::isSubmit('id_product') && Tools::isSubmit('id_product_attribute') && Tools::isSubmit('id_warehouse')) {
            $presence = ErpStock::getPresenceInStock(Tools::getValue('id_product'), Tools::getValue('id_product_attribute'), Tools::getValue('id_warehouse'));
            if ((int) $presence > 0) {
                echo 'true';
            } else {
                echo 'false';
            }
        } else {
            echo $erpip->l('Parameters missing !');
        }
        break;
    case 'products':
        if (Tools::isSubmit('id_order')) {
            $objOrder = new ErpOrder(Tools::getValue('id_order'));
            $produits = $objOrder->getListOfProductsWithQuantity();
            $message = '<table class="table_popup">
							<tr>
								<th>' . $erpip->l('SKU') . '</th>
								<th>' . $erpip->l('Description') . '</th>
								<th>' . $erpip->l('Quantity') . '</th>';
            if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                $message .= '<th>' . $erpip->l('Physical Stock') . '</th>
							 <th>' . $erpip->l('Usable Stock') . '</th>
							 <th>' . $erpip->l('Real Stock') . '</th>';
            } else {
                $message .= '<th>' . $erpip->l('Stock') . '</th>';
            }
            $message .= '</tr>';
            foreach ($produits as &$prod) {