Esempio n. 1
0
                    $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();
                    }