function init_csv() { if ($_FILES['csv']['tmp_name'] === NULL) { return NULL; } $ext = strchr($_FILES['csv']['type'], "/"); $ext = strtolower($ext); if ($ext !== "/csv") { return NULL; } $key = array('area', 'reference', 'sellVat'); $csv = new \Pasteque\Csv($_FILES['csv']['tmp_name'], $key, array(), PLUGIN_NAME); if (!$csv->open()) { return $csv; } return $csv; }
function init_csv() { if ($_FILES['csv']['tmp_name'] === NULL) { return NULL; } $ext = strchr($_FILES['csv']['type'], "/"); $ext = strtolower($ext); if ($ext !== "/csv") { return NULL; } $key = array('Designation', 'Parent', 'Ordre'); $csv = new \Pasteque\Csv($_FILES['csv']['tmp_name'], $key); if (!$csv->open()) { return $csv; } return $csv; }
function init_csv() { if ($_FILES['csv']['tmp_name'] === NULL) { return NULL; } $ext = strchr($_FILES['csv']['type'], "/"); $ext = strtolower($ext); if ($ext !== "/csv" && $ext !== "/plain") { return NULL; } $key = array('reference', 'barcode', 'label', 'sellVat', 'category', 'tax_cat'); $optionKey = array('price_buy', 'visible', 'scaled', 'disp_order', 'discount_rate', 'discount_enabled', 'stock_min', 'provider', 'stock_max'); $csv = new \Pasteque\Csv($_FILES['csv']['tmp_name'], $key, $optionKey, PLUGIN_NAME); if (!$csv->open()) { return $csv; } //manage empty string $csv->setEmptyStringValue("visible", true); $csv->setEmptyStringValue("scaled", false); $csv->setEmptyStringValue("disp_order", null); $csv->setEmptyStringValue("provider", null); return $csv; }
} else { $move = new \Pasteque\StockMove($time, $reason, $productId, $locationId, null, $qty, $price); if (\Pasteque\StocksService::addMove($move)) { $message = \i18n("Changes saved"); } else { $error = \i18n("Unable to save changes"); } } } } } } else { if (isset($_POST['sendCsv'])) { $key = array('Quantity', 'Reference'); $csv = new \Pasteque\Csv($_FILES['csv']['tmp_name'], $key, array(), PLUGIN_NAME); if (!$csv->open()) { $error = $csv->getErrors(); } else { //manage empty string $csv->setEmptyStringValue("Quantity", "0"); echo "<script type=\"text/javascript\">\n"; echo "jQuery(document).ready(function() {\n"; while ($tab = $csv->readLine()) { $productOk = false; $quantityOk = false; $product = \Pasteque\ProductsService::getByRef($tab['Reference']); if ($product !== null) { $productOk = true; } else { if ($error === null) { $error = array();