} } break; case 'updateListeTransfert': if (Tools::isSubmit('values')) { echo '<tr> <td></td> <td width="60"></td> <td width="80"></td> </tr>'; require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/ErpProduct.php'; require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/helpers/StockTransferHelper.php'; $data = StockTransferHelper::getTransfertDataAsArray(Tools::getValue('values')); /* Get addition information */ foreach ($data as $key => &$val) { $val['product_name'] = ErpProduct::getProductName($val['id_product'], $val['id_product_attribute']); echo '<tr> <td>' . $val['product_name'] . '</td> <td>' . $val['quantity'] . '</td> <td style="cursor: pointer;" class="deleteAwaitinTft"><input type="hidden" value="' . $key . '" /> <img src="../img/admin/delete.gif" /> </td> </tr>'; } } else { echo '<tr> <td colspan="3">No tranfert</td> </tr>'; } 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'));
protected function renderCSV() { if (Tools::isSubmit('ids_mvt_csv')) { require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/ErpProduct.php'; $warehouseSrc = new Warehouse(Tools::getValue('id_warehouse_src')); $warehouseDst = new Warehouse(Tools::getValue('id_warehouse_dst')); //csv file name $file_name = 'stock_transfert_' . date('Y-m-d_His') . '.csv'; // header header('Content-type: text/csv'); header('Cache-Control: no-store, no-cache'); header('Content-disposition: attachment; filename="' . $file_name); // write headers column $keys = array($this->l('warehouse_source_id'), $this->l('warehouse_source_name'), $this->l('warehouse_destination_id'), $this->l('warehouse_destination_name'), $this->l('id_product'), $this->l('id_product_attribute'), $this->l('sku'), $this->l('ean'), $this->l('product_name'), $this->l('quantity')); $keys = array_map(array('AdminStockTransferController', 'transformText'), $keys); echo sprintf("%s\n", implode(';', $keys)); // call the helper "traducteur" of the transfert chain to get datas require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/helpers/StockTransferHelper.php'; $data = StockTransferHelper::getTransfertDataAsArray(Tools::getValue('ids_mvt_csv')); // write datas foreach ($data as &$product) { // get additional informations $product['product_name'] = ErpProduct::getProductName($product['id_product'], $product['id_product_attribute']); $productInfo = ErpProduct::getProductsInfo($product['id_product'], $product['id_product_attribute']); $product['ean13'] = isset($productInfo['ean13']) ? $productInfo['ean13'] : ''; $product['reference'] = isset($productInfo['reference']) ? $productInfo['reference'] : ''; $file_content = array((int) $warehouseSrc->id, self::transformText($warehouseSrc->name), (int) $warehouseDst->id, self::transformText($warehouseDst->name), (int) $product['id_product'], (int) $product['id_product_attribute'], $product['reference'], $product['ean13'], self::transformText($product['product_name']), (int) $product['quantity'] . PHP_EOL); echo implode(';', $file_content); } exit; } }