Exemplo n.º 1
0
        }
    }
}
$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);
?>
</h1>

<?php 
\Pasteque\tpl_msg_box($message, $error);
?>

<form class="edit" action="<?php 
Exemplo n.º 2
0
function readProductLine($line, $category, $taxCat)
{
    $priceSell = $line['sellVat'] / (1 + $taxCat->getCurrentTax()->rate);
    if (isset($line['visible'])) {
        $visible = $line['visible'];
    } else {
        $visible = true;
    }
    if (isset($line['scaled']) && ($line['scaled'] !== 1 || $line['scaled'] !== true)) {
        $scaled = $line['scaled'];
    } else {
        $scaled = false;
    }
    if (isset($line['provider'])) {
        $provider = \Pasteque\ProvidersService::getByName($line['provider']);
    }
    if (isset($line['disp_order'])) {
        $dispOrder = $line['disp_order'];
    } else {
        $dispOrder = null;
    }
    $product = new \Pasteque\Product($line['reference'], $line['label'], $priceSell, $category->id, $provider->id, $dispOrder, $taxCat->id, $visible, $scaled);
    if (isset($line['barcode'])) {
        $product->barcode = $line['barcode'];
    }
    if (isset($line['price_buy'])) {
        $product->priceBuy = $line['price_buy'];
    }
    if (isset($line['discount_enabled'])) {
        $product->discountEnabled = $line['discount_enabled'];
    }
    if (isset($line['discount_rate'])) {
        $product->discountRate = $line['discount_rate'];
    }
    // TODO: add support for attribute sets
    return $product;
}