Exemple #1
0
function pdf_barcode($pdf, $productId, $col, $row)
{
    $product = \Pasteque\ProductsService::get($productId);
    $x = H_MARGIN + $col * COL_SIZE + $col * H_PADDING;
    $y = V_MARGIN + $row * ROW_SIZE + $row * V_PADDING;
    $pdf->SetXY($x, $y);
    $pdf->Cell(BARCODE_WIDTH, TEXT_HEIGHT, utf8_decode($product->reference), 0, 1, "C");
    $pdf->SetXY($x, $y + TEXT_HEIGHT);
    $data = \Barcode::fpdf($pdf, "000000", $pdf->GetX() + BARCODE_WIDTH / 2, $pdf->GetY() + BARCODE_HEIGHT / 2, 0, "ean13", array('code' => $product->barcode), BARCODE_WIDTH / (15 * 7), BARCODE_HEIGHT);
    $pdf->SetXY($x, $y + BARCODE_HEIGHT + TEXT_HEIGHT);
    $pdf->Cell(BARCODE_WIDTH, TEXT_HEIGHT, $product->barcode, 0, 1, "C");
}
Exemple #2
0
if (in_array("stock_multilocations", $modules)) {
    $multilocations = true;
}
$dateStr = isset($_POST['date']) ? $_POST['date'] : \i18nDate(time());
$time = \i18nRevDate($dateStr);
if (isset($_POST['reason']) && !isset($_POST['sendCsv'])) {
    $reason = $_POST['reason'];
    if ($multilocations) {
        $locationId = $_POST['location'];
    } else {
        $locationId = $defaultLocationId;
    }
    foreach ($_POST as $key => $value) {
        if (strpos($key, "qty-") === 0) {
            $productId = substr($key, 4);
            $product = \Pasteque\ProductsService::get($productId);
            switch ($reason) {
                case \Pasteque\StockMove::REASON_OUT_SELL:
                case \Pasteque\StockMove::REASON_IN_REFUND:
                    $price = $product->priceSell;
                    break;
                case \Pasteque\StockMove::REASON_IN_BUY:
                case \Pasteque\StockMove::REASON_OUT_BACK:
                case \Pasteque\StockMove::REASON_IN_MOVEMENT:
                case \Pasteque\StockMove::REASON_OUT_REFUND:
                case \Pasteque\StockMove::REASON_OUT_MOVEMENT:
                case \Pasteque\StockMove::REASON_RESET:
                    if ($product->priceBuy !== null) {
                        $price = $product->priceBuy;
                    } else {
                        $price = 0.0;
            }
            $prd = new \Pasteque\Product($_POST['reference'], $_POST['label'], $_POST['realsell'], $catId, $provId, $disp_order, $taxCatId, $visible, $scaled, $_POST['priceBuy'], $attr, $_POST['barcode'], $img !== null, $discount_enabled, $discount_rate);
            $id = \Pasteque\ProductsService::create($prd, $img);
            if ($id !== FALSE) {
                $message = \i18n("Product saved. <a href=\"%s\">Go to the product page</a>.", PLUGIN_NAME, \Pasteque\get_module_url_action(PLUGIN_NAME, 'product_edit', array('id' => $id)));
            } else {
                $error = \i18n("Unable to save changes");
            }
        }
    }
}
$product = NULL;
$vatprice = "";
$price = "";
if (isset($_GET['id'])) {
    $product = \Pasteque\ProductsService::get($_GET['id']);
    $taxCat = \Pasteque\TaxesService::get($product->taxCatId);
    $tax = $taxCat->getCurrentTax();
    $vatprice = $product->priceSell * (1 + $tax->rate);
    $price = sprintf("%.2f", $product->priceSell);
}
$taxes = \Pasteque\TaxesService::getAll();
$categories = \Pasteque\CategoriesService::getAll();
$providers = \Pasteque\ProvidersService::getAll();
$level = NULL;
if ($stocks === TRUE && $product != NULL) {
    $level = \Pasteque\StocksService::getLevel($product->id);
}
?>
<h1><?php 
\pi18n("Edit a product", PLUGIN_NAME);