public function ajaxGetProducts()
 {
     if (Tools::isSubmit('id_order')) {
         $product_return_template = array();
         require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/order/ErpOrder.php';
         $objOrder = new ErpOrder((int) Tools::getValue('id_order'));
         $produits = $objOrder->getListOfProductsWithQuantity();
         if (!empty($produits)) {
             foreach ($produits as $key => &$prod) {
                 $objProd = new Product($prod['product_id']);
                 // If order is neither sent, nor cancelled, nor the current one
                 $product_return_template[$key]['reference'] = $objProd->reference;
                 $product_return_template[$key]['name'] = $objProd->getProductName($prod['product_id'], $prod['product_attribute_id']);
                 $product_return_template[$key]['quantity'] = $prod['product_quantity'];
                 if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                     $manager = StockManagerFactory::getManager();
                     $product_return_template[$key]['physical_stock'] = $manager->getProductPhysicalQuantities($prod['product_id'], $prod['product_attribute_id']);
                     $product_return_template[$key]['usable_stock'] = $manager->getProductPhysicalQuantities($prod['product_id'], $prod['product_attribute_id'], null, true);
                     $product_return_template[$key]['real_stock'] = $manager->getProductRealQuantities($prod['product_id'], $prod['product_attribute_id']);
                 } else {
                     $product_return_template[$key]['stock'] = StockAvailable::getQuantityAvailableByProduct($prod['product_id'], $prod['product_attribute_id']);
                 }
             }
         }
         $this->context->smarty->assign(array('products' => $product_return_template));
         echo $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'erpillicopresta/views/templates/admin/advanced_order/quick_view.tpl');
         die;
     }
 }
示例#2
0
    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) {
                $objProd = new Product($prod['product_id']);